Skip to content

Commit 77f989c

Browse files
authored
Merge pull request #107 from AppDevNext/morePolylineTests
More Polyline tests
2 parents 55c3963 + c03b90b commit 77f989c

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.xxmassdeveloper.mpchartexample
2+
3+
import android.view.View
4+
import android.widget.SeekBar
5+
import androidx.test.core.graphics.writeToTestStorage
6+
import androidx.test.espresso.Espresso.onView
7+
import androidx.test.espresso.UiController
8+
import androidx.test.espresso.ViewAction
9+
import androidx.test.espresso.matcher.ViewMatchers
10+
import androidx.test.espresso.matcher.ViewMatchers.withId
11+
import androidx.test.espresso.screenshot.captureToBitmap
12+
import androidx.test.ext.junit.rules.activityScenarioRule
13+
import androidx.test.ext.junit.runners.AndroidJUnit4
14+
import org.hamcrest.Matcher
15+
import org.junit.Rule
16+
import org.junit.Test
17+
import org.junit.rules.TestName
18+
import org.junit.runner.RunWith
19+
20+
21+
@RunWith(AndroidJUnit4::class)
22+
class PieTest {
23+
24+
@get:Rule
25+
val activityScenarioRule = activityScenarioRule<PiePolylineChartActivity>()
26+
27+
@get:Rule
28+
var nameRule = TestName()
29+
30+
@Test
31+
fun piePolyline() {
32+
onView(ViewMatchers.isRoot())
33+
.captureToBitmap()
34+
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")
35+
36+
for(x in 10..50 step 10) {
37+
onView(withId(R.id.seekBar1)).perform(setProgress(x))
38+
onView(ViewMatchers.isRoot())
39+
.captureToBitmap()
40+
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}1-${x}")
41+
}
42+
43+
for(x in 50..200 step 50) {
44+
onView(withId(R.id.seekBar2)).perform(setProgress(x))
45+
onView(ViewMatchers.isRoot())
46+
.captureToBitmap()
47+
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}2-${x}")
48+
}
49+
}
50+
51+
private fun setProgress(progress: Int): ViewAction {
52+
return object : ViewAction {
53+
override fun perform(uiController: UiController?, view: View) {
54+
val seekBar = view as SeekBar
55+
seekBar.progress = progress
56+
}
57+
58+
override fun getDescription(): String {
59+
return "Set a progress on a SeekBar"
60+
}
61+
62+
override fun getConstraints(): Matcher<View> {
63+
return ViewMatchers.isAssignableFrom(SeekBar::class.java)
64+
}
65+
}
66+
}
67+
68+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
android:layout_marginBottom="35dp"
3131
android:layout_toLeftOf="@+id/tvXMax"
3232
android:layout_marginRight="5dp"
33-
android:max="25"
33+
android:max="50"
3434
android:paddingBottom="12dp" />
3535

3636
<TextView

0 commit comments

Comments
 (0)