From c1b46a110281c8b1e9df4742191814e866bc654f Mon Sep 17 00:00:00 2001 From: Zac Date: Tue, 29 Apr 2014 17:24:27 +0100 Subject: [PATCH] Bug 983684 - Detect device/b2g type and set gaiatest timeout as appropriate r=davehunt --- tests/python/gaia-ui-tests/README.md | 6 ++- .../gaia-ui-tests/gaiatest/gaia_test.py | 37 ++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/python/gaia-ui-tests/README.md b/tests/python/gaia-ui-tests/README.md index e13b9cf0d0c2..00e2f746cf71 100644 --- a/tests/python/gaia-ui-tests/README.md +++ b/tests/python/gaia-ui-tests/README.md @@ -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 =================== diff --git a/tests/python/gaia-ui-tests/gaiatest/gaia_test.py b/tests/python/gaia-ui-tests/gaiatest/gaia_test.py index bb158d699c14..0268578b8989 100644 --- a/tests/python/gaia-ui-tests/gaiatest/gaia_test.py +++ b/tests/python/gaia-ui-tests/gaiatest/gaia_test.py @@ -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) @@ -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)