Skip to content

Commit e653fc6

Browse files
committed
Viewpager test
1 parent c5b6915 commit e653fc6

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.xxmassdeveloper.mpchartexample
2+
3+
import androidx.test.core.graphics.writeToTestStorage
4+
import androidx.test.espresso.Espresso.onView
5+
import androidx.test.espresso.action.ViewActions.swipeLeft
6+
import androidx.test.espresso.matcher.ViewMatchers
7+
import androidx.test.espresso.matcher.ViewMatchers.withId
8+
import androidx.test.espresso.screenshot.captureToBitmap
9+
import androidx.test.ext.junit.rules.activityScenarioRule
10+
import androidx.test.ext.junit.runners.AndroidJUnit4
11+
import com.xxmassdeveloper.mpchartexample.fragments.SimpleChartDemo
12+
import org.junit.Rule
13+
import org.junit.Test
14+
import org.junit.rules.TestName
15+
import org.junit.runner.RunWith
16+
17+
@RunWith(AndroidJUnit4::class)
18+
class ViewPagerTest {
19+
20+
@get:Rule
21+
val activityScenarioRule = activityScenarioRule<SimpleChartDemo>()
22+
23+
@get:Rule
24+
var nameRule = TestName()
25+
26+
@Test
27+
fun smokeTestSimplyStart() {
28+
onView(ViewMatchers.isRoot())
29+
.captureToBitmap()
30+
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")
31+
32+
repeat(4) {
33+
onView(withId(R.id.pager)).perform(swipeLeft());
34+
onView(ViewMatchers.isRoot())
35+
.captureToBitmap()
36+
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}-${it}")
37+
}
38+
}
39+
}

MPChartExample/src/main/res/layout/activity_awesomedesign.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
android:orientation="vertical">
66

77
<androidx.viewpager.widget.ViewPager
8-
xmlns:android="http://schemas.android.com/apk/res/android"
9-
android:id="@+id/pager"
10-
android:layout_width="match_parent"
11-
android:layout_height="match_parent" />
8+
android:id="@+id/pager"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent" />
1211

1312
</RelativeLayout>

0 commit comments

Comments
 (0)