Skip to content

More Polyline tests #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.xxmassdeveloper.mpchartexample

import android.view.View
import android.widget.SeekBar
import androidx.test.core.graphics.writeToTestStorage
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.screenshot.captureToBitmap
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.hamcrest.Matcher
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestName
import org.junit.runner.RunWith


@RunWith(AndroidJUnit4::class)
class PieTest {

@get:Rule
val activityScenarioRule = activityScenarioRule<PiePolylineChartActivity>()

@get:Rule
var nameRule = TestName()

@Test
fun piePolyline() {
onView(ViewMatchers.isRoot())
.captureToBitmap()
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")

for(x in 10..50 step 10) {
onView(withId(R.id.seekBar1)).perform(setProgress(x))
onView(ViewMatchers.isRoot())
.captureToBitmap()
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}1-${x}")
}

for(x in 50..200 step 50) {
onView(withId(R.id.seekBar2)).perform(setProgress(x))
onView(ViewMatchers.isRoot())
.captureToBitmap()
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}2-${x}")
}
}

private fun setProgress(progress: Int): ViewAction {
return object : ViewAction {
override fun perform(uiController: UiController?, view: View) {
val seekBar = view as SeekBar
seekBar.progress = progress
}

override fun getDescription(): String {
return "Set a progress on a SeekBar"
}

override fun getConstraints(): Matcher<View> {
return ViewMatchers.isAssignableFrom(SeekBar::class.java)
}
}
}

}
2 changes: 1 addition & 1 deletion MPChartExample/src/main/res/layout/activity_piechart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
android:layout_marginBottom="35dp"
android:layout_toLeftOf="@+id/tvXMax"
android:layout_marginRight="5dp"
android:max="25"
android:max="50"
android:paddingBottom="12dp" />

<TextView
Expand Down