@@ -2,15 +2,25 @@ package com.xxmassdeveloper.mpchartexample
22
33import androidx.test.core.graphics.writeToTestStorage
44import androidx.test.espresso.Espresso
5+ import androidx.test.espresso.Espresso.onData
6+ import androidx.test.espresso.action.ViewActions.click
57import androidx.test.espresso.matcher.ViewMatchers
8+ import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
9+ import androidx.test.espresso.matcher.ViewMatchers.withId
610import androidx.test.espresso.screenshot.captureToBitmap
711import androidx.test.ext.junit.rules.activityScenarioRule
812import androidx.test.ext.junit.runners.AndroidJUnit4
913import com.xxmassdeveloper.mpchartexample.notimportant.MainActivity
14+ import org.hamcrest.CoreMatchers.allOf
15+ import org.hamcrest.CoreMatchers.anything
16+ import org.junit.After
17+ import org.junit.Before
1018import org.junit.Rule
1119import org.junit.Test
1220import org.junit.rules.TestName
1321import org.junit.runner.RunWith
22+ import androidx.test.espresso.intent.Intents
23+ import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
1424
1525@RunWith(AndroidJUnit4 ::class )
1626class StartTest {
@@ -21,10 +31,36 @@ class StartTest {
2131 @get:Rule
2232 var nameRule = TestName ()
2333
34+ @Before
35+ fun setUp () {
36+ Intents .init ()
37+ }
38+
39+ @After
40+ fun cleanUp () {
41+ Intents .release()
42+ }
43+
2444 @Test
2545 fun smokeTestSimplyStart () {
2646 Espresso .onView(ViewMatchers .isRoot())
2747 .captureToBitmap()
2848 .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
49+
50+ MainActivity .menuItems.forEachIndexed { index, contentItem ->
51+ contentItem.clazz?.let {
52+ println (" Intended ${index} -${it.simpleName} " )
53+
54+ onData(anything())
55+ .inAdapterView(allOf(withId(R .id.listView1), isCompletelyDisplayed()))
56+ .atPosition(index).perform(click())
57+
58+ Espresso .onView(ViewMatchers .isRoot())
59+ .captureToBitmap()
60+ .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -${index} -${it.simpleName} " )
61+ Intents .intended(hasComponent(it.name))
62+ Espresso .pressBack()
63+ }
64+ }
2965 }
3066}
0 commit comments