Skip to content

Commit da7bd2c

Browse files
authored
Merge pull request #78 from AppDevNext/DeprecationEspresso
Fix deprecation in Espresso
2 parents e642410 + 16649af commit da7bd2c

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

sample/src/androidTest/java/info/hannes/logcat/AllFragmentsTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package info.hannes.logcat
22

33
import android.Manifest
4-
import android.view.View
54
import androidx.test.espresso.Espresso.onView
65
import androidx.test.espresso.assertion.ViewAssertions
76
import androidx.test.espresso.matcher.ViewMatchers.*
7+
import androidx.test.ext.junit.rules.ActivityScenarioRule
88
import androidx.test.ext.junit.runners.AndroidJUnit4
99
import androidx.test.filters.SdkSuppress
1010
import androidx.test.filters.Suppress
11-
import androidx.test.rule.ActivityTestRule
1211
import androidx.test.rule.GrantPermissionRule
1312
import com.moka.utils.Screenshot
1413
import org.hamcrest.Matchers.allOf
@@ -21,7 +20,7 @@ import org.junit.runner.RunWith
2120
class AllFragmentsTest {
2221

2322
@get:Rule
24-
var mActivityTestRule = ActivityTestRule(BothLogActivity::class.java)
23+
var mActivityTestRule = ActivityScenarioRule(BothLogActivity::class.java)
2524

2625
@get:Rule
2726
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
@@ -31,7 +30,7 @@ class AllFragmentsTest {
3130
@Test
3231
@Suppress
3332
fun basicTest() {
34-
onView(allOf<View>(withContentDescription("All log"),
33+
onView(allOf(withContentDescription("All log"),
3534
withParent(withId(R.id.action_bar)),
3635
isDisplayed()))
3736

sample/src/androidTest/java/info/hannes/logcat/LogcatTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package info.hannes.logcat
22

33
import android.Manifest
4-
import android.view.View
54
import androidx.test.espresso.Espresso.onView
65
import androidx.test.espresso.assertion.ViewAssertions
76
import androidx.test.espresso.matcher.ViewMatchers.*
7+
import androidx.test.ext.junit.rules.ActivityScenarioRule
88
import androidx.test.ext.junit.runners.AndroidJUnit4
99
import androidx.test.filters.SdkSuppress
1010
import androidx.test.filters.Suppress
11-
import androidx.test.rule.ActivityTestRule
1211
import androidx.test.rule.GrantPermissionRule
1312
import com.moka.utils.Screenshot
1413
import org.hamcrest.Matchers.allOf
@@ -21,7 +20,7 @@ import org.junit.runner.RunWith
2120
class LogcatTest {
2221

2322
@get:Rule
24-
var mActivityTestRule = ActivityTestRule(LogcatActivity::class.java)
23+
var mActivityTestRule = ActivityScenarioRule(LogcatActivity::class.java)
2524

2625
@get:Rule
2726
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
@@ -31,7 +30,7 @@ class LogcatTest {
3130
@Test
3231
@Suppress
3332
fun basicTest() {
34-
onView(allOf<View>(withContentDescription("Logcat"),
33+
onView(allOf(withContentDescription("Logcat"),
3534
withParent(withId(R.id.action_bar)),
3635
isDisplayed()))
3736

sample/src/androidTest/java/info/hannes/logcat/MainActivityTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package info.hannes.logcat
22

33
import android.Manifest
4-
import android.view.View
54
import androidx.test.espresso.Espresso.onView
65
import androidx.test.espresso.action.ViewActions.click
76
import androidx.test.espresso.assertion.ViewAssertions.matches
87
import androidx.test.espresso.matcher.ViewMatchers.*
8+
import androidx.test.ext.junit.rules.ActivityScenarioRule
99
import androidx.test.ext.junit.runners.AndroidJUnit4
1010
import androidx.test.filters.SdkSuppress
11-
import androidx.test.rule.ActivityTestRule
1211
import androidx.test.rule.GrantPermissionRule
1312
import com.moka.utils.Screenshot
1413
import org.hamcrest.Matchers.allOf
@@ -23,7 +22,7 @@ import org.junit.runner.RunWith
2322
class MainActivityTest {
2423

2524
@get:Rule
26-
val mActivityTestRule = ActivityTestRule(MainActivity::class.java)
25+
val mActivityTestRule = ActivityScenarioRule(MainActivity::class.java)
2726

2827
@get:Rule
2928
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
@@ -32,7 +31,7 @@ class MainActivityTest {
3231

3332
@Before
3433
fun openDrawer() {
35-
val navMain = onView(allOf<View>(withContentDescription("Navigate up"), isDisplayed()))
34+
val navMain = onView(allOf(withContentDescription("Navigate up"), isDisplayed()))
3635
navMain.perform(click())
3736
Screenshot.takeScreenshot("End")
3837
}

0 commit comments

Comments
 (0)