author | Jonathan Griffin <jgriffin@mozilla.com> |
Mon, 09 Dec 2013 20:17:54 -0800 | |
changeset 159629 | 76ddaf7db5bf467c4ae6772342a1315193e7a482 |
parent 159628 | 263980931d1be65ecf6fe06a48bf3412c179327a |
child 159630 | 712628797f219e9ecc406a176702b65d4cae4b82 |
push id | 25808 |
push user | cbook@mozilla.com |
push date | Tue, 10 Dec 2013 12:03:31 +0000 |
treeherder | mozilla-central@7fb91a422c5e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | vicamo |
bugs | 926280 |
milestone | 29.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/testing/marionette/client/marionette/emulator.py +++ b/testing/marionette/client/marionette/emulator.py @@ -340,16 +340,36 @@ waitFor( self.screen.initialize() if self.logcat_dir: self.save_logcat() # setup DNS fix for networking self._run_adb(['shell', 'setprop', 'net.dns1', '10.0.2.3']) + def wait_for_homescreen(self, marionette): + print 'waiting for homescreen...' + + created_session = False + if not marionette.session: + marionette.start_session() + created_session = True + + marionette.set_context(marionette.CONTEXT_CONTENT) + marionette.execute_async_script(""" +window.addEventListener('mozbrowserloadend', function loaded(aEvent) { + if (aEvent.target.src.indexOf('ftu') != -1 || aEvent.target.src.indexOf('homescreen') != -1) { + window.removeEventListener('mozbrowserloadend', loaded); + marionetteScriptFinished(); + } +});""", script_timeout=60000) + print '...done' + if created_session: + marionette.delete_session() + def setup(self, marionette, gecko_path=None, busybox=None): if busybox: self.install_busybox(busybox) if gecko_path: self.install_gecko(gecko_path, marionette) self.wait_for_system_message(marionette)
--- a/testing/marionette/client/marionette/marionette_test.py +++ b/testing/marionette/client/marionette/marionette_test.py @@ -349,26 +349,27 @@ class MarionetteTestCase(CommonTestCase) class MarionetteJSTestCase(CommonTestCase): head_js_re = re.compile(r"MARIONETTE_HEAD_JS(\s*)=(\s*)['|\"](.*?)['|\"];") context_re = re.compile(r"MARIONETTE_CONTEXT(\s*)=(\s*)['|\"](.*?)['|\"];") timeout_re = re.compile(r"MARIONETTE_TIMEOUT(\s*)=(\s*)(\d+);") inactivity_timeout_re = re.compile(r"MARIONETTE_INACTIVITY_TIMEOUT(\s*)=(\s*)(\d+);") match_re = re.compile(r"test_(.*)\.js$") - def __init__(self, marionette_weakref, methodName='runTest', jsFile=None): + def __init__(self, marionette_weakref, methodName='runTest', jsFile=None, **kwargs): assert(jsFile) self.jsFile = jsFile self._marionette_weakref = marionette_weakref self.marionette = None + self.oop = kwargs.pop('oop') CommonTestCase.__init__(self, methodName) @classmethod def add_tests_to_suite(cls, mod_name, filepath, suite, testloader, marionette, testvars, **kwargs): - suite.addTest(cls(weakref.ref(marionette), jsFile=filepath)) + suite.addTest(cls(weakref.ref(marionette), jsFile=filepath, **kwargs)) def runTest(self): if self.marionette.session is None: self.marionette.start_session() self.marionette.test_name = os.path.basename(self.jsFile) self.marionette.execute_script("log('TEST-START: %s');" % self.jsFile.replace('\\', '\\\\')) f = open(self.jsFile, 'r') @@ -390,16 +391,57 @@ class MarionetteJSTestCase(CommonTestCas if os.path.basename(self.jsFile).startswith('test_'): head_js = self.head_js_re.search(js); if head_js: head_js = head_js.group(3) head = open(os.path.join(os.path.dirname(self.jsFile), head_js), 'r') js = head.read() + js; + if self.oop: + print 'running oop' + result = self.marionette.execute_async_script(""" +let setReq = navigator.mozSettings.createLock().set({'lockscreen.enabled': false}); +setReq.onsuccess = function() { + let appsReq = navigator.mozApps.mgmt.getAll(); + appsReq.onsuccess = function() { + let apps = appsReq.result; + for (let i = 0; i < apps.length; i++) { + let app = apps[i]; + if (app.manifest.name === 'Test Container') { + app.launch(); + window.addEventListener('apploadtime', function apploadtime(){ + window.removeEventListener('apploadtime', apploadtime); + marionetteScriptFinished(true); + }); + return; + } + } + marionetteScriptFinished(false); + } + appsReq.onerror = function() { + marionetteScriptFinished(false); + } +} +setReq.onerror = function() { + marionetteScriptFinished(false); +}""", script_timeout=60000) + self.assertTrue(result) + + self.marionette.switch_to_frame( + self.marionette.find_element( + 'css selector', + 'iframe[src*="app://test-container.gaiamobile.org/index.html"]' + )) + + main_process = self.marionette.execute_script(""" + return SpecialPowers.isMainProcess(); + """) + self.assertFalse(main_process) + context = self.context_re.search(js) if context: context = context.group(3) self.marionette.set_context(context) if context != "chrome": self.marionette.navigate('data:text/html,<html>test page</html>')
--- a/testing/marionette/client/marionette/runtests.py +++ b/testing/marionette/client/marionette/runtests.py @@ -570,16 +570,32 @@ class MarionetteTestRunner(object): def run_test(self, test, expected='pass'): if not self.httpd: print "starting httpd" self.start_httpd() if not self.marionette: self.start_marionette() + if self.emulator: + self.marionette.emulator.wait_for_homescreen(self.marionette) + + testargs = {} + if self.type is not None: + testtypes = self.type.replace('+', ' +').replace('-', ' -').split() + for atype in testtypes: + if atype.startswith('+'): + testargs.update({ atype[1:]: 'true' }) + elif atype.startswith('-'): + testargs.update({ atype[1:]: 'false' }) + else: + testargs.update({ atype: 'true' }) + oop = testargs.get('oop', False) + if isinstance(oop, basestring): + oop = False if oop == 'false' else 'true' filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): if self.shuffle: random.shuffle(files) for filename in files: @@ -592,27 +608,16 @@ class MarionetteTestRunner(object): return mod_name,file_ext = os.path.splitext(os.path.split(filepath)[-1]) testloader = unittest.TestLoader() suite = unittest.TestSuite() if file_ext == '.ini': - testargs = {} - if self.type is not None: - testtypes = self.type.replace('+', ' +').replace('-', ' -').split() - for atype in testtypes: - if atype.startswith('+'): - testargs.update({ atype[1:]: 'true' }) - elif atype.startswith('-'): - testargs.update({ atype[1:]: 'false' }) - else: - testargs.update({ atype: 'true' }) - manifest = TestManifest() manifest.read(filepath) all_tests = manifest.active_tests(disabled=False) manifest_tests = manifest.active_tests(disabled=False, device=self.device, app=self.appName) skip_tests = list(set([x['path'] for x in all_tests]) - @@ -628,19 +633,20 @@ class MarionetteTestRunner(object): if self.shuffle: random.shuffle(target_tests) for i in target_tests: self.run_test(i["path"], i["expected"]) if self.marionette.check_for_crash(): return return - self.logger.info('TEST-START %s' % os.path.basename(test)) + self.logger.info('TEST-START %s' % os.path.basename(test)) self.test_kwargs['expected'] = expected + self.test_kwargs['oop'] = oop for handler in self.test_handlers: if handler.match(os.path.basename(test)): handler.add_tests_to_suite(mod_name, filepath, suite, testloader, self.marionette, self.testvars,