@@ -51,19 +51,19 @@ class UnlockerTest {
5151 given(outputReceiverProvider.get()).willReturn(outputReceiver)
5252 }
5353
54- // @Test
55- // fun `nothing is done when power button is chosen`() {
56- // val classToTest = Unlocker(
57- // deviceWrapper,
58- // POWER_BUTTON.string,
59- // pin,
60- // password
61- // )
62- //
63- // classToTest.unlock()
64- //
65- // then(device).should(never()).executeShellCommand(any(), any())
66- // }
54+ @Test
55+ fun `nothing is done when power button is chosen` () {
56+ val classToTest = Unlocker (
57+ deviceWrapper,
58+ POWER_BUTTON .string,
59+ pin,
60+ password
61+ )
62+
63+ classToTest.unlock()
64+
65+ then(device).should(never()).executeShellCommand(any(), any())
66+ }
6767
6868 @Test
6969 fun `device can be unlocked by swipe` () {
@@ -93,122 +93,122 @@ class UnlockerTest {
9393 classToTestSwipe.unlock()
9494 }
9595
96- // @Test(expected = GradleException::class)
97- // fun `gradle exception is thrown when pin is blank`() {
98- // val classToTest = Unlocker(
99- // deviceWrapper,
100- // PIN.string,
101- // emptyString,
102- // password
103- // )
104- //
105- // classToTest.unlock()
106- // }
107-
108- // @Test(expected = GradleException::class)
109- // fun `gradle exception is thrown when pin has less than 4 digits`() {
110- // val classToTest = Unlocker(
111- // deviceWrapper,
112- // PIN.string,
113- // wrongPin1,
114- // password
115- // )
116- //
117- // classToTest.unlock()
118- // }
119- //
120- // @Test(expected = GradleException::class)
121- // fun `gradle exception is thrown when pin is not only numbers`() {
122- // val classToTest = Unlocker(
123- // deviceWrapper,
124- // PIN.string,
125- // wrongPin2,
126- // password
127- // )
128- //
129- // classToTest.unlock()
130- // }
131- //
132- // @Test
133- // fun `device can be unlocked by pin`() {
134- // val classToTest = Unlocker(
135- // deviceWrapper,
136- // PIN.string,
137- // pin,
138- // password
139- // )
140- //
141- // given(outputReceiver.output).willReturn(output)
142- //
143- // classToTest.unlock()
144- //
145- // thenPassPhraseShouldBeEntered(device, pin)
146- // }
96+ @Test(expected = GradleException ::class )
97+ fun `gradle exception is thrown when pin is blank` () {
98+ val classToTest = Unlocker (
99+ deviceWrapper,
100+ PIN .string,
101+ emptyString,
102+ password
103+ )
104+
105+ classToTest.unlock()
106+ }
107+
108+ @Test(expected = GradleException ::class )
109+ fun `gradle exception is thrown when pin has less than 4 digits` () {
110+ val classToTest = Unlocker (
111+ deviceWrapper,
112+ PIN .string,
113+ wrongPin1,
114+ password
115+ )
116+
117+ classToTest.unlock()
118+ }
119+
120+ @Test(expected = GradleException ::class )
121+ fun `gradle exception is thrown when pin is not only numbers` () {
122+ val classToTest = Unlocker (
123+ deviceWrapper,
124+ PIN .string,
125+ wrongPin2,
126+ password
127+ )
128+
129+ classToTest.unlock()
130+ }
131+
132+ @Test
133+ fun `device can be unlocked by pin` () {
134+ val classToTest = Unlocker (
135+ deviceWrapper,
136+ PIN .string,
137+ pin,
138+ password
139+ )
140+
141+ given(outputReceiver.output).willReturn(output)
142+
143+ classToTest.unlock()
144+
145+ thenPassPhraseShouldBeEntered(device, pin)
146+ }
147147
148148 private fun thenPassPhraseShouldBeEntered (device : IDevice , passPhrase : String ){
149149 then(device).should(Times (2 )).executeShellCommand(eq(DUMPSYS_WINDOW ), any())
150150 then(device).should().executeShellCommand(eq(" input swipe 50 160 80 40" ), any())
151151 then(device).should().executeShellCommand(eq(" $INPUT_TEXT $passPhrase " ), any())
152152 then(device).should().executeShellCommand(eq(INPUT_PRESS_ENTER ), any())
153153 }
154- //
155- // @Test(expected = GradleException::class)
156- // fun `gradle exception is thrown when password is blank`() {
157- // val classToTest = Unlocker(
158- // deviceWrapper,
159- // PASSWORD.string,
160- // pin,
161- // wrongPassword1
162- // )
163- //
164- // given(outputReceiver.output).willReturn(output)
165- //
166- // classToTest.unlock()
167- // }
168- //
169- // @Test(expected = GradleException::class)
170- // fun `gradle exception is thrown when password is empty`() {
171- // val classToTest = Unlocker(
172- // deviceWrapper,
173- // PASSWORD.string,
174- // pin,
175- // wrongPassword2
176- // )
177- //
178- // given(outputReceiver.output).willReturn(output)
179- //
180- // classToTest.unlock()
181- // }
182- //
183- //
184- // @Test
185- // fun `device can be unlocked by password`() {
186- // val classToTest = Unlocker(
187- // deviceWrapper,
188- // PASSWORD.string,
189- // pin,
190- // password
191- // )
192- //
193- // given(outputReceiver.output).willReturn(output)
194- //
195- // classToTest.unlock()
196- //
197- //
198- // thenPassPhraseShouldBeEntered(device, password)
199- // }
200- //
201- // @Test(expected = GradleException::class)
202- // fun `gradle exception is thrown when wrong unlock method is chosen`() {
203- // val classToTest = Unlocker(
204- // deviceWrapper,
205- // wrongMethod,
206- // pin,
207- // password
208- // )
209- //
210- // given(outputReceiver.output).willReturn(output)
211- //
212- // classToTest.unlock()
213- // }
154+
155+ @Test(expected = GradleException ::class )
156+ fun `gradle exception is thrown when password is blank` () {
157+ val classToTest = Unlocker (
158+ deviceWrapper,
159+ PASSWORD .string,
160+ pin,
161+ wrongPassword1
162+ )
163+
164+ given(outputReceiver.output).willReturn(output)
165+
166+ classToTest.unlock()
167+ }
168+
169+ @Test(expected = GradleException ::class )
170+ fun `gradle exception is thrown when password is empty` () {
171+ val classToTest = Unlocker (
172+ deviceWrapper,
173+ PASSWORD .string,
174+ pin,
175+ wrongPassword2
176+ )
177+
178+ given(outputReceiver.output).willReturn(output)
179+
180+ classToTest.unlock()
181+ }
182+
183+
184+ @Test
185+ fun `device can be unlocked by password` () {
186+ val classToTest = Unlocker (
187+ deviceWrapper,
188+ PASSWORD .string,
189+ pin,
190+ password
191+ )
192+
193+ given(outputReceiver.output).willReturn(output)
194+
195+ classToTest.unlock()
196+
197+
198+ thenPassPhraseShouldBeEntered(device, password)
199+ }
200+
201+ @Test(expected = GradleException ::class )
202+ fun `gradle exception is thrown when wrong unlock method is chosen` () {
203+ val classToTest = Unlocker (
204+ deviceWrapper,
205+ wrongMethod,
206+ pin,
207+ password
208+ )
209+
210+ given(outputReceiver.output).willReturn(output)
211+
212+ classToTest.unlock()
213+ }
214214}
0 commit comments