This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
/
AgendaTest.kt
62 lines (55 loc) · 2.23 KB
/
AgendaTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.samples.apps.iosched.tests.ui
import android.widget.TextView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.samples.apps.iosched.R
import com.google.samples.apps.iosched.di.CoroutinesModule
import com.google.samples.apps.iosched.tests.SetPreferencesRule
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import dagger.hilt.android.testing.UninstallModules
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.instanceOf
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@HiltAndroidTest
@UninstallModules(CoroutinesModule::class)
@RunWith(AndroidJUnit4::class)
class AgendaTest {
@get:Rule(order = 0)
var hiltRule = HiltAndroidRule(this)
// Sets the preferences so no welcome screens are shown
@get:Rule(order = 1)
var preferencesRule = SetPreferencesRule()
@get:Rule(order = 2)
var activityRule = MainActivityTestRule(R.id.navigation_agenda)
@Test
fun agenda_basicViewsDisplayed() {
// Title
onView(allOf(instanceOf(TextView::class.java), withParent(withId(R.id.toolbar))))
.check(matches(withText(R.string.agenda)))
// One of the blocks
onView(withText("Breakfast")).check(matches(isDisplayed()))
}
}