Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17557 from zacc/bug_983684
Browse files Browse the repository at this point in the history
Bug 983684 - Detect device/b2g type and set gaiatest timeout as appropri...
  • Loading branch information
Zac committed Apr 30, 2014
2 parents 489ce25 + c1b46a1 commit 95f99ed
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
6 changes: 4 additions & 2 deletions tests/python/gaia-ui-tests/README.md
Expand Up @@ -94,8 +94,10 @@ Options:
device back to a common state
--yocto gather power draw data while running tests
(see https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform/Automated_testing/gaia-ui-tests/Gaia_UI_Tests_Run_Tests#Gathering_Power_Draw_Data)
--timeout < time in milliseconds > to set default timeout values (30s for page load timeout,
10s for search timeout and 10s for script timeout) to a common specified value
--timeout < time in milliseconds > to set all of the gaiatest and Marionette
timeout values to the specified value. Without this set, gaiatest will
try to detect the b2g instance and set safe timeouts for search, page
and script timeouts.

Testing on a Device
===================
Expand Down
37 changes: 32 additions & 5 deletions tests/python/gaia-ui-tests/gaiatest/gaia_test.py
Expand Up @@ -658,6 +658,12 @@ def is_emulator(self):
self._is_emulator = self.marionette.session_capabilities['device'] == 'qemu'
return self._is_emulator

@property
def is_desktop_b2g(self):
if self.testvars.get('is_desktop_b2g') is None:
self.testvars['is_desktop_b2g'] = self.marionette.session_capabilities['device'] == 'desktop'
return self.testvars['is_desktop_b2g']

@property
def is_online(self):
# Returns true if the device has a network connection established (cell data, wifi, etc)
Expand Down Expand Up @@ -859,14 +865,35 @@ def setUp(self):
self.cleanup_data()
self.device.start_b2g()

# we need to set the default timeouts because we may have a new session
if self.marionette.timeout is not None:
# We need to set the default timeouts because we may have a new session
if self.marionette.timeout is None:
# if no timeout is passed in, we detect the hardware type and set reasonable defaults
timeouts = {}
if self.device.is_desktop_b2g:
self.marionette.timeout = 5000
timeouts[self.marionette.TIMEOUT_SEARCH] = 5000
timeouts[self.marionette.TIMEOUT_SCRIPT] = 10000
timeouts[self.marionette.TIMEOUT_PAGE] = 10000
elif self.device.is_emulator:
self.marionette.timeout = 30000
timeouts[self.marionette.TIMEOUT_SEARCH] = 30000
timeouts[self.marionette.TIMEOUT_SCRIPT] = 60000
timeouts[self.marionette.TIMEOUT_PAGE] = 60000
else:
# else, it is a device, the type of which is difficult to detect
self.marionette.timeout = 10000
timeouts[self.marionette.TIMEOUT_SEARCH] = 10000
timeouts[self.marionette.TIMEOUT_SCRIPT] = 20000
timeouts[self.marionette.TIMEOUT_PAGE] = 20000

for k, v in timeouts.items():
self.marionette.timeouts(k, v)

else:
# if the user has passed in --timeout then we override everything
self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_SCRIPT, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, self.marionette.timeout)
else:
self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, 30000)

self.apps = GaiaApps(self.marionette)
self.data_layer = GaiaData(self.marionette, self.testvars)
Expand Down

0 comments on commit 95f99ed

Please sign in to comment.