Bug 1043699 - Add Mulet reftests support. r=jgriffin

This commit is contained in:
Armen Zambrano Gasparnian 2014-11-04 09:18:27 -05:00
Родитель 52f3641c23
Коммит eeb05f45e8
6 изменённых файлов: 136 добавлений и 11 удалений

Просмотреть файл

@ -12,6 +12,11 @@ DEFINES += -DBOOTSTRAP
DIST_FILES += bootstrap.js
endif
ifeq ($(MOZ_BUILD_APP),b2g/dev)
DEFINES += -DBOOTSTRAP
DEFINES += -DREFTEST_B2G
endif
ifeq ($(MOZ_BUILD_APP),b2g)
DEFINES += -DBOOTSTRAP
DEFINES += -DREFTEST_B2G
@ -30,6 +35,7 @@ _HARNESS_FILES = \
$(srcdir)/remotereftest.py \
$(srcdir)/runreftestb2g.py \
$(srcdir)/b2g_desktop.py \
$(srcdir)/gaia_lock_screen.js \
automation.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanager.py \
$(topsrcdir)/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py \

Просмотреть файл

@ -3,17 +3,17 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function, unicode_literals
import json
import os
import signal
import sys
import threading
here = os.path.abspath(os.path.dirname(__file__))
from runreftest import RefTest, ReftestOptions
from marionette import Marionette
from marionette import Marionette, expected
from marionette.wait import Wait
from marionette.by import By
from mozprocess import ProcessHandler
from mozrunner import FirefoxRunner
import mozinfo
@ -22,6 +22,7 @@ import mozlog
log = mozlog.getLogger('REFTEST')
class B2GDesktopReftest(RefTest):
build_type = "desktop"
marionette = None
def __init__(self, marionette_args):
@ -37,6 +38,9 @@ class B2GDesktopReftest(RefTest):
self.marionette = Marionette(**self.marionette_args)
assert(self.marionette.wait_for_port())
self.marionette.start_session()
if self.build_type == "mulet":
self._wait_for_homescreen(timeout=15)
self._unlockScreen()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
if os.path.isfile(self.test_script):
@ -108,8 +112,12 @@ class B2GDesktopReftest(RefTest):
prefs = {}
# Turn off the locale picker screen
prefs["browser.firstrun.show.localepicker"] = False
prefs["b2g.system_startup_url"] = "app://test-container.gaiamobile.org/index.html"
prefs["b2g.system_manifest_url"] = "app://test-container.gaiamobile.org/manifest.webapp"
if not self.build_type == "mulet":
# FIXME: With Mulet we can't set this values since Gaia won't launch
prefs["b2g.system_startup_url"] = \
"app://test-container.gaiamobile.org/index.html"
prefs["b2g.system_manifest_url"] = \
"app://test-container.gaiamobile.org/manifest.webapp"
prefs["dom.ipc.tabs.disabled"] = False
prefs["dom.mozBrowserFramesEnabled"] = True
prefs["font.size.inflation.emPerLine"] = 0
@ -136,6 +144,9 @@ class B2GDesktopReftest(RefTest):
if not ignore_window_size:
args.extend(['--screen', '800x1000'])
if self.build_type == "mulet":
args += ['-chrome', 'chrome://b2g/content/shell.html']
return cmd, args
def _on_output(self, line):
@ -151,6 +162,20 @@ class B2GDesktopReftest(RefTest):
# kill process to get a stack
self.runner.stop(sig=signal.SIGABRT)
class MuletReftest(B2GDesktopReftest):
build_type = "mulet"
def _unlockScreen(self):
self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
self.marionette.import_script(os.path.abspath(
os.path.join(__file__, os.path.pardir, "gaia_lock_screen.js")))
self.marionette.switch_to_frame()
self.marionette.execute_async_script('GaiaLockScreen.unlock()')
def _wait_for_homescreen(self, timeout):
log.info("Waiting for home screen to load")
Wait(self.marionette, timeout).until(expected.element_present(
By.CSS_SELECTOR, '#homescreen[loading-state=false]'))
def run_desktop_reftests(parser, options, args):
marionette_args = {}
@ -159,7 +184,10 @@ def run_desktop_reftests(parser, options, args):
marionette_args['host'] = host
marionette_args['port'] = int(port)
reftest = B2GDesktopReftest(marionette_args)
if options.mulet:
reftest = MuletReftest(marionette_args)
else:
reftest = B2GDesktopReftest(marionette_args)
options = ReftestOptions.verifyCommonOptions(parser, options, reftest)
if options == None:

Просмотреть файл

@ -0,0 +1,90 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// NOTE: This code was forked from:
// https://github.com/mozilla-b2g/gaia/blob/master/tests/atoms/gaia_lock_screen.js
'use strict';
var GaiaLockScreen = {
unlock: function() {
let lockscreen = window.wrappedJSObject.lockScreen;
let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
let system = window.wrappedJSObject.System;
let obj = {'screen.timeout': 0};
setlock.set(obj);
window.wrappedJSObject.ScreenManager.turnScreenOn();
waitFor(
function() {
window.wrappedJSObject.dispatchEvent(
new window.wrappedJSObject.CustomEvent(
'lockscreen-request-unlock', {
detail: {
forcibly: true
}
}));
waitFor(
function() {
finish(system.locked);
},
function() {
return !system.locked;
}
);
},
function() {
return !!lockscreen;
}
);
},
lock: function() {
let lwm = window.wrappedJSObject.lockScreenWindowManager;
let lockscreen = window.wrappedJSObject.lockScreen;
let system = window.wrappedJSObject.System;
let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
let obj = {'screen.timeout': 0};
let waitLock = function() {
waitFor(
function() {
window.wrappedJSObject.dispatchEvent(
new window.wrappedJSObject.CustomEvent(
'lockscreen-request-lock', {
detail: {
forcibly: true
}
}));
waitFor(
function() {
finish(!system.locked);
},
function() {
return system.locked;
}
);
},
function() {
return !!lockscreen;
}
);
};
setlock.set(obj);
window.wrappedJSObject.ScreenManager.turnScreenOn();
// Need to open the window before we lock the lockscreen.
// This would only happen when someone directly call the lockscrene.lock.
// It's a bad pattern and would only for test.
lwm.openApp();
waitFor(function() {
waitLock();
}, function() {
return lwm.states.instance.isActive();
});
}
};

Просмотреть файл

@ -8,7 +8,6 @@ Runs the reftest test harness.
from optparse import OptionParser
import collections
import json
import multiprocessing
import os
import re
@ -16,7 +15,6 @@ import shutil
import signal
import subprocess
import sys
import tempfile
import threading
SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
@ -35,7 +33,6 @@ import mozinfo
import mozprocess
import mozprofile
import mozrunner
from mozrunner.utils import findInPath as which
here = os.path.abspath(os.path.dirname(__file__))

Просмотреть файл

@ -124,6 +124,10 @@ class B2GOptions(ReftestOptions):
dest="desktop",
help="Run the tests on a B2G desktop build")
defaults["desktop"] = False
self.add_option("--mulet", action="store_true",
dest="mulet",
help="Run the tests on a B2G desktop build")
defaults["mulet"] = False
self.add_option("--enable-oop", action="store_true",
dest="oop",
help="Run the tests out of process")
@ -620,7 +624,7 @@ def main(args=sys.argv[1:]):
parser = B2GOptions()
options, args = parser.parse_args(args)
if options.desktop:
if options.desktop or options.mulet:
return run_desktop_reftests(parser, options, args)
return run_remote_reftests(parser, options, args)

Просмотреть файл

@ -2,7 +2,7 @@
config = {
# testsuite options
"reftest_options": [
"--desktop", "--profile=%(gaia_profile)s",
"--mulet", "--profile=%(gaia_profile)s",
"--appname=%(application)s", "%(test_manifest)s"
],
"run_file_names": {