-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
demo/src/androidTest/java/info/hannes/slidingup/demo/Matcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package info.hannes.slidingup.demo | ||
|
||
import android.util.Log | ||
import android.view.View | ||
import androidx.test.espresso.UiController | ||
import androidx.test.espresso.ViewAction | ||
import androidx.test.espresso.matcher.BoundedMatcher | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import com.sothree.slidinguppanel.PanelState | ||
import com.sothree.slidinguppanel.SlidingUpPanelLayout | ||
import org.hamcrest.Description | ||
import org.hamcrest.Matcher | ||
|
||
fun withValue(expectedValue: PanelState): Matcher<View?> { | ||
return object : BoundedMatcher<View?, SlidingUpPanelLayout>(SlidingUpPanelLayout::class.java) { | ||
override fun describeTo(description: Description) { | ||
description.appendText("expected: $expectedValue") | ||
} | ||
|
||
override fun matchesSafely(slider: SlidingUpPanelLayout): Boolean { | ||
Log.d("slider", slider.panelState.toString()) | ||
return slider.panelState == expectedValue | ||
} | ||
} | ||
} | ||
|
||
fun setValue(value: PanelState): ViewAction { | ||
return object : ViewAction { | ||
override fun getDescription(): String { | ||
return "Set Slider value to $value" | ||
} | ||
|
||
override fun getConstraints(): Matcher<View> { | ||
return ViewMatchers.isAssignableFrom(SlidingUpPanelLayout::class.java) | ||
} | ||
|
||
override fun perform(uiController: UiController?, view: View) { | ||
val seekBar = view as SlidingUpPanelLayout | ||
seekBar.panelState = value | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters