1
1
package info.hannes.slidingup.demo
2
2
3
+ import android.util.Log
4
+ import android.view.View
5
+ import androidx.test.espresso.assertion.ViewAssertions.matches
6
+ import com.sothree.slidinguppanel.demo.R
3
7
import androidx.test.core.graphics.writeToTestStorage
4
- import androidx.test.espresso.Espresso
8
+ import androidx.test.espresso.Espresso.onView
9
+ import androidx.test.espresso.UiController
10
+ import androidx.test.espresso.ViewAction
11
+ import androidx.test.espresso.matcher.BoundedMatcher
5
12
import androidx.test.espresso.matcher.ViewMatchers
13
+ import androidx.test.espresso.matcher.ViewMatchers.withId
6
14
import androidx.test.espresso.screenshot.captureToBitmap
7
15
import androidx.test.ext.junit.rules.activityScenarioRule
8
16
import androidx.test.ext.junit.runners.AndroidJUnit4
17
+ import com.sothree.slidinguppanel.PanelState
18
+ import com.sothree.slidinguppanel.SlidingUpPanelLayout
9
19
import com.sothree.slidinguppanel.demo.DemoActivity
20
+ import org.hamcrest.Description
21
+ import org.hamcrest.Matcher
10
22
import org.junit.Rule
11
23
import org.junit.Test
12
24
import org.junit.rules.TestName
@@ -15,6 +27,8 @@ import org.junit.runner.RunWith
15
27
@RunWith(AndroidJUnit4 ::class )
16
28
class StartTest {
17
29
30
+ private val WAIT_SLIDER = 600L
31
+
18
32
@get:Rule
19
33
val activityScenarioRule = activityScenarioRule<DemoActivity >()
20
34
@@ -23,9 +37,50 @@ class StartTest {
23
37
24
38
@Test
25
39
fun smokeTestSimplyStart () {
26
- Thread .sleep(1000 )
27
- Espresso .onView(ViewMatchers .isRoot())
40
+ onView(ViewMatchers .isRoot())
28
41
.captureToBitmap()
29
42
.writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} " )
30
43
}
44
+
45
+ @Test
46
+ fun testExpand () {
47
+ onView(ViewMatchers .isRoot())
48
+ .captureToBitmap()
49
+ .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -1" )
50
+ onView(withId(R .id.sliding_layout)).check(matches(withValue(PanelState .COLLAPSED )))
51
+
52
+ onView(withId(R .id.sliding_layout)).perform(setValue(PanelState .EXPANDED ))
53
+
54
+ Thread .sleep(WAIT_SLIDER )
55
+ onView(withId(R .id.sliding_layout)).check(matches(withValue(PanelState .EXPANDED )))
56
+ onView(ViewMatchers .isRoot())
57
+ .captureToBitmap()
58
+ .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -2" )
59
+
60
+ onView(withId(R .id.sliding_layout)).perform(setValue(PanelState .COLLAPSED ))
61
+ Thread .sleep(WAIT_SLIDER )
62
+ onView(withId(R .id.sliding_layout)).check(matches(withValue(PanelState .COLLAPSED )))
63
+ onView(ViewMatchers .isRoot())
64
+ .captureToBitmap()
65
+ .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -3" )
66
+ }
67
+
68
+ @Test
69
+ fun testAnchorWithoutSetAnchored () {
70
+ onView(withId(R .id.sliding_layout)).check(matches(withValue(PanelState .COLLAPSED )))
71
+
72
+ onView(withId(R .id.sliding_layout)).perform(setValue(PanelState .EXPANDED ))
73
+
74
+ Thread .sleep(WAIT_SLIDER )
75
+ onView(withId(R .id.sliding_layout)).check(matches(withValue(PanelState .EXPANDED )))
76
+
77
+ // without state anchored, a state ANCHORED should be ignored
78
+ onView(withId(R .id.sliding_layout)).perform(setValue(PanelState .ANCHORED ))
79
+ Thread .sleep(WAIT_SLIDER )
80
+ // should be still EXPANDED
81
+ onView(withId(R .id.sliding_layout)).check(matches(withValue(PanelState .EXPANDED )))
82
+ onView(ViewMatchers .isRoot())
83
+ .captureToBitmap()
84
+ .writeToTestStorage(" ${javaClass.simpleName} _${nameRule.methodName} -2" )
85
+ }
31
86
}
0 commit comments