Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: components/proximity_auth/e2e_test/cros.py

Issue 1261643006: Handle Smart Lock for Android promotion screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 import time 9 import time
10 10
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 Note: This does not include the app's background page. 211 Note: This does not include the app's background page.
212 """ 212 """
213 213
214 class PairingState: 214 class PairingState:
215 """ The current state of the setup flow. """ 215 """ The current state of the setup flow. """
216 SCAN = 'scan' 216 SCAN = 'scan'
217 PAIR = 'pair' 217 PAIR = 'pair'
218 CLICK_FOR_TRIAL_RUN = 'click_for_trial_run' 218 CLICK_FOR_TRIAL_RUN = 'click_for_trial_run'
219 TRIAL_RUN_COMPLETED = 'trial_run_completed' 219 TRIAL_RUN_COMPLETED = 'trial_run_completed'
220 PROMOTE_SMARTLOCK_FOR_ANDROID = 'promote-smart-lock-for-android'
220 221
221 def __init__(self, app_page, chromeos): 222 def __init__(self, app_page, chromeos):
222 """ 223 """
223 Args: 224 Args:
224 app_page: Inspector page of the app window. 225 app_page: Inspector page of the app window.
225 chromeos: The parent Chrome wrapper. 226 chromeos: The parent Chrome wrapper.
226 """ 227 """
227 self._app_page = app_page 228 self._app_page = app_page
228 self._chromeos = chromeos 229 self._chromeos = chromeos
229 230
230 @property 231 @property
231 def pairing_state(self): 232 def pairing_state(self):
232 ''' Returns the state the app is currently in. 233 ''' Returns the state the app is currently in.
233 234
234 Raises: 235 Raises:
235 ValueError: The current state is unknown. 236 ValueError: The current state is unknown.
236 ''' 237 '''
237 state = self._app_page.EvaluateJavaScript( 238 state = self._app_page.EvaluateJavaScript(
238 'document.body.getAttribute("step")') 239 'document.body.getAttribute("step")')
239 if state == 'scan': 240 if state == 'scan':
240 return SmartLockApp.PairingState.SCAN 241 return SmartLockApp.PairingState.SCAN
241 elif state == 'pair': 242 elif state == 'pair':
242 return SmartLockApp.PairingState.PAIR 243 return SmartLockApp.PairingState.PAIR
244 elif state == 'promote-smart-lock-for-android':
245 return SmartLockApp.PairingState.PROMOTE_SMARTLOCK_FOR_ANDROID
243 elif state == 'complete': 246 elif state == 'complete':
244 button_text = self._app_page.EvaluateJavaScript( 247 button_text = self._app_page.EvaluateJavaScript(
245 'document.getElementById("pairing-button").textContent') 248 'document.getElementById("pairing-button").textContent')
246 button_text = button_text.strip().lower() 249 button_text = button_text.strip().lower()
247 if button_text == 'try it out': 250 if button_text == 'try it out':
248 return SmartLockApp.PairingState.CLICK_FOR_TRIAL_RUN 251 return SmartLockApp.PairingState.CLICK_FOR_TRIAL_RUN
249 elif button_text == 'done': 252 elif button_text == 'done':
250 return SmartLockApp.PairingState.TRIAL_RUN_COMPLETED 253 return SmartLockApp.PairingState.TRIAL_RUN_COMPLETED
251 else: 254 else:
252 raise ValueError('Unknown button text: %s', button_text) 255 raise ValueError('Unknown button text: %s', button_text)
(...skipping 22 matching lines...) Expand all
275 def PairPhone(self): 278 def PairPhone(self):
276 """ Starts the step of finding nearby phones. 279 """ Starts the step of finding nearby phones.
277 280
278 The app must be in the PAIR state. 281 The app must be in the PAIR state.
279 282
280 Returns: 283 Returns:
281 True if pairing succeeded, else False. 284 True if pairing succeeded, else False.
282 """ 285 """
283 assert(self.pairing_state == self.PairingState.PAIR) 286 assert(self.pairing_state == self.PairingState.PAIR)
284 self._ClickPairingButton() 287 self._ClickPairingButton()
288 assert(
Tim Song 2015/08/03 21:42:19 The PROMOTE_SMARTLOCK_FOR_ANDROID state doesn't al
vsankar 2015/08/03 22:32:13 Done.
289 self.pairing_state == self.PairingState.PROMOTE_SMARTLOCK_FOR_ANDROID)
290 self._ClickPairingButton()
285 return self.pairing_state == self.PairingState.CLICK_FOR_TRIAL_RUN 291 return self.pairing_state == self.PairingState.CLICK_FOR_TRIAL_RUN
286 292
287 def StartTrialRun(self): 293 def StartTrialRun(self):
288 """ Starts the trial run. 294 """ Starts the trial run.
289 295
290 The app must be in the CLICK_FOR_TRIAL_RUN state. 296 The app must be in the CLICK_FOR_TRIAL_RUN state.
291 297
292 Raises: 298 Raises:
293 TimeoutException: Timed out starting the trial run. 299 TimeoutException: Timed out starting the trial run.
294 """ 300 """
295 assert(self.pairing_state == self.PairingState.CLICK_FOR_TRIAL_RUN) 301 assert(self.pairing_state == self.PairingState.CLICK_FOR_TRIAL_RUN)
296 self._app_page.EvaluateJavaScript( 302 self._app_page.EvaluateJavaScript(
297 'document.getElementById("pairing-button").click()') 303 'document.getElementById("pairing-button").click()')
298 util.WaitFor(lambda: (self._chromeos.session_state == 304 util.WaitFor(lambda: (self._chromeos.session_state ==
299 ChromeOS.SessionState.LOCK_SCREEN), 305 ChromeOS.SessionState.LOCK_SCREEN),
300 10) 306 10)
301 307
302 def DismissApp(self): 308 def DismissApp(self):
303 """ Dismisses the app after setup is completed. 309 """ Dismisses the app after setup is completed.
304 310
305 The app must be in the TRIAL_RUN_COMPLETED state. 311 The app must be in the TRIAL_RUN_COMPLETED state.
306 """ 312 """
307 assert(self.pairing_state == self.PairingState.TRIAL_RUN_COMPLETED) 313 assert(self.pairing_state == self.PairingState.TRIAL_RUN_COMPLETED)
308 self._app_page.EvaluateJavaScript( 314 self._app_page.EvaluateJavaScript(
309 'document.getElementById("pairing-button").click()') 315 'document.getElementById("pairing-button").click()')
310 316
311 def _ClickPairingButton(self): 317 def _ClickPairingButton(self):
318 # Waits are needed because the clicks occur before the button label changes.
319 time.sleep(2)
Tim Song 2015/08/03 21:42:18 Can you reduce the time to 1 second? I think that
vsankar 2015/08/03 22:32:13 Done.
312 self._app_page.EvaluateJavaScript( 320 self._app_page.EvaluateJavaScript(
313 'document.getElementById("pairing-button").click()') 321 'document.getElementById("pairing-button").click()')
322 time.sleep(2)
314 util.WaitFor(lambda: self._app_page.EvaluateJavaScript( 323 util.WaitFor(lambda: self._app_page.EvaluateJavaScript(
315 '!document.getElementById("pairing-button").disabled'), 60) 324 '!document.getElementById("pairing-button").disabled'), 60)
325 time.sleep(2)
316 util.WaitFor(lambda: self._app_page.EvaluateJavaScript( 326 util.WaitFor(lambda: self._app_page.EvaluateJavaScript(
317 '!document.getElementById("pairing-button-title")' 327 '!document.getElementById("pairing-button-title")'
318 '.classList.contains("animated-fade-out")'), 5) 328 '.classList.contains("animated-fade-out")'), 5)
319 util.WaitFor(lambda: self._app_page.EvaluateJavaScript( 329 util.WaitFor(lambda: self._app_page.EvaluateJavaScript(
320 '!document.getElementById("pairing-button-title")' 330 '!document.getElementById("pairing-button-title")'
321 '.classList.contains("animated-fade-in")'), 5) 331 '.classList.contains("animated-fade-in")'), 5)
322 332
323 333
324 class ChromeOS(object): 334 class ChromeOS(object):
325 """ Wrapper for a remote ChromeOS device. 335 """ Wrapper for a remote ChromeOS device.
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 try: 562 try:
553 extensions = self._browser.extensions.GetByExtensionId( 563 extensions = self._browser.extensions.GetByExtensionId(
554 'mkaemigholebcgchlkbankmihknojeak') 564 'mkaemigholebcgchlkbankmihknojeak')
555 except KeyError: 565 except KeyError:
556 return None 566 return None
557 for extension_page in extensions: 567 for extension_page in extensions:
558 pathname = extension_page.EvaluateJavaScript('document.location.pathname') 568 pathname = extension_page.EvaluateJavaScript('document.location.pathname')
559 if pathname == page_name: 569 if pathname == page_name:
560 return extension_page 570 return extension_page
561 return None 571 return None
OLDNEW
« no previous file with comments | « no previous file | components/proximity_auth/e2e_test/setup_test.py » ('j') | components/proximity_auth/e2e_test/setup_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698