@@ -24,6 +24,9 @@ class PresenterTest {
24
24
private val device: DeviceParams = mock()
25
25
private val props = Properties ()
26
26
27
+ /* *
28
+ * Set initial device values
29
+ */
27
30
@Before
28
31
fun setup () {
29
32
whenever(device.currentBackgroundColor()).thenReturn(100 )
@@ -32,6 +35,9 @@ class PresenterTest {
32
35
whenever(device.getStatusBarHeight()).thenReturn(80 )
33
36
}
34
37
38
+ /* *
39
+ * Check initial styles & properties
40
+ */
35
41
@Test
36
42
fun testInitialValues () {
37
43
val presenter = Presenter (pref, device, props)
@@ -44,6 +50,9 @@ class PresenterTest {
44
50
assert (presenter.centerY == 960 )
45
51
}
46
52
53
+ /* *
54
+ * Default background color
55
+ */
47
56
@Test
48
57
fun testDefaultBgColor () {
49
58
props.backgroundColor = 200
@@ -52,6 +61,9 @@ class PresenterTest {
52
61
assert (props.backgroundColor == 200 )
53
62
}
54
63
64
+ /* *
65
+ * Title gravity
66
+ */
55
67
@Test
56
68
fun testGravity () {
57
69
val presenter = Presenter (pref, device, props)
@@ -61,6 +73,9 @@ class PresenterTest {
61
73
assert (props.titleGravity == Gravity .TOP )
62
74
}
63
75
76
+ /* *
77
+ * Title style
78
+ */
64
79
@Test
65
80
fun testTitleStyle () {
66
81
val presenter = Presenter (pref, device, props)
@@ -70,6 +85,9 @@ class PresenterTest {
70
85
assert (props.titleStyle == 101 )
71
86
}
72
87
88
+ /* *
89
+ * If view with same id show before, don't show again
90
+ */
73
91
@Test
74
92
fun testNotShownBefore () {
75
93
whenever(pref.isShownBefore(anyVararg())).thenReturn(false )
@@ -86,6 +104,9 @@ class PresenterTest {
86
104
assert (onShowTriggered)
87
105
}
88
106
107
+ /* *
108
+ * Wait for laid out if try to show before laid out
109
+ */
89
110
@Test
90
111
fun testViewNotLaidOut () {
91
112
whenever(pref.isShownBefore(anyVararg())).thenReturn(false )
@@ -103,6 +124,9 @@ class PresenterTest {
103
124
assert (! onShowTriggered)
104
125
}
105
126
127
+ /* *
128
+ * Test dismissListener triggers if shown before
129
+ */
106
130
@Test
107
131
fun testShownBefore () {
108
132
whenever(pref.isShownBefore(anyVararg())).thenReturn(true )
@@ -120,8 +144,11 @@ class PresenterTest {
120
144
}
121
145
122
146
147
+ /* *
148
+ * Test dismissListener triggers if shown before
149
+ */
123
150
@Test
124
- fun testFocus () {
151
+ fun `test dismissListener onSkipped is not called if not shown before` () {
125
152
whenever(pref.isShownBefore(anyVararg())).thenReturn(false )
126
153
props.focusedView = mock()
127
154
props.dismissListener = mock()
@@ -136,6 +163,9 @@ class PresenterTest {
136
163
assert (onShowTriggered)
137
164
}
138
165
166
+ /* *
167
+ * Test calculated height before focus
168
+ */
139
169
@Test
140
170
fun testCalculationsWithoutFocus () {
141
171
val presenter = Presenter (pref, device, props)
@@ -149,6 +179,9 @@ class PresenterTest {
149
179
assert (presenter.bitmapHeight == 1920 )
150
180
}
151
181
182
+ /* *
183
+ * Test calculated values
184
+ */
152
185
@Test
153
186
fun testCalculationsWithFocus () {
154
187
val presenter = Presenter (pref, device, props)
@@ -164,6 +197,9 @@ class PresenterTest {
164
197
assert (presenter.circleCenterY == 120 )
165
198
}
166
199
200
+ /* *
201
+ * Test calculated values for abobe 19 devices
202
+ */
167
203
@Test
168
204
fun testCalculationsWithFocus2 () {
169
205
val presenter = Presenter (pref, device, props)
@@ -180,13 +216,19 @@ class PresenterTest {
180
216
assert (presenter.circleCenterY == 200 )
181
217
}
182
218
219
+ /* *
220
+ * Set pref
221
+ */
183
222
@Test
184
223
fun testWriteShown () {
185
224
val presenter = Presenter (pref, device, props)
186
225
presenter.writeShown(" id" )
187
226
verify(pref).writeShown(" id" )
188
227
}
189
228
229
+ /* *
230
+ * Circle focus position
231
+ */
190
232
@Test
191
233
fun testFocusPositionsCircle () {
192
234
val presenter = Presenter (pref, device, props)
@@ -202,6 +244,9 @@ class PresenterTest {
202
244
assert (presenter.hasFocus)
203
245
}
204
246
247
+ /* *
248
+ * Rectangle focus position
249
+ */
205
250
@Test
206
251
fun testFocusPositionsRectangle () {
207
252
val presenter = Presenter (pref, device, props)
@@ -221,6 +266,9 @@ class PresenterTest {
221
266
222
267
}
223
268
269
+ /* *
270
+ * Auto text position calculations below
271
+ */
224
272
@Test
225
273
fun testAutoTextPositionBelow () {
226
274
val presenter = Presenter (pref, device, props)
@@ -238,6 +286,9 @@ class PresenterTest {
238
286
assert (pos.height == 1770 )
239
287
}
240
288
289
+ /* *
290
+ * Auto text position calculations above
291
+ */
241
292
@Test
242
293
fun testAutoTextPositionAbove () {
243
294
val presenter = Presenter (pref, device, props)
@@ -256,6 +307,9 @@ class PresenterTest {
256
307
assert (pos.height == 1200 )
257
308
}
258
309
310
+ /* *
311
+ * Click in the focused zone
312
+ */
259
313
@Test
260
314
fun testClickWithinZoneCircle () {
261
315
val presenter = Presenter (pref, device, props)
0 commit comments