Bug 858290 - Need to enable focusmanager.testmode for tests run against B2G desktop builds. r=jgriffin

This commit is contained in:
Dave Hunt 2013-04-06 09:46:29 +01:00
parent 31c8062c25
commit 56513a7a16
3 changed files with 45 additions and 16 deletions

View File

@ -7,6 +7,10 @@ from mozrunner import Runner
class GeckoInstance(object):
required_prefs = {"marionette.defaultPrefs.enabled": True,
"marionette.defaultPrefs.port": 2828,
"browser.warnOnQuit": False}
def __init__(self, host, port, bin, profile):
self.marionette_host = host
self.marionette_port = port
@ -15,18 +19,25 @@ class GeckoInstance(object):
self.runner = None
def start(self):
profile = self.profile
if not profile:
prefs = {"marionette.defaultPrefs.enabled": True,
"marionette.defaultPrefs.port": 2828,
"browser.warnOnQuit": False}
profile = {"preferences": prefs, "restore":False}
profile_path = self.profile
profile_args = {"preferences": self.required_prefs}
if not profile_path:
profile_args["restore"] = False
else:
profile = {"profile": profile}
profile_args["profile"] = profile_path
print "starting runner"
self.runner = Runner.create(binary=self.bin, profile_args=profile, cmdargs=['-no-remote'])
self.runner = Runner.create(binary=self.bin,
profile_args=profile_args,
cmdargs=['-no-remote'])
self.runner.start()
def close(self):
self.runner.stop()
self.runner.cleanup()
class B2GDesktopInstance(GeckoInstance):
required_prefs = {"focusmanager.testmode": True}
apps = {'b2gdesktop': B2GDesktopInstance}

View File

@ -13,7 +13,7 @@ from application_cache import ApplicationCache
from keys import Keys
from errors import *
from emulator import Emulator
from geckoinstance import GeckoInstance
import geckoinstance
class HTMLElement(object):
@ -167,13 +167,14 @@ class Marionette(object):
TIMEOUT_SCRIPT = 'script'
TIMEOUT_PAGE = 'page load'
def __init__(self, host='localhost', port=2828, bin=None, profile=None,
emulator=None, sdcard=None, emulatorBinary=None,
def __init__(self, host='localhost', port=2828, app=None, bin=None,
profile=None, emulator=None, sdcard=None, emulatorBinary=None,
emulatorImg=None, emulator_res=None, gecko_path=None,
connectToRunningEmulator=False, homedir=None, baseurl=None,
noWindow=False, logcat_dir=None, busybox=None, symbols_path=None):
self.host = host
self.port = self.local_port = port
self.app = app
self.bin = bin
self.instance = None
self.profile = profile
@ -193,8 +194,17 @@ class Marionette(object):
if not Marionette.is_port_available(port, host=self.host):
ex_msg = "%s:%d is unavailable." % (self.host, port)
raise MarionetteException(message=ex_msg)
self.instance = GeckoInstance(host=self.host, port=self.port,
bin=self.bin, profile=self.profile)
if app:
# select instance class for the given app
try:
instance_class = geckoinstance.apps[app]
except KeyError:
msg = 'Application "%s" unknown (should be one of %s)'
raise NotImplementedError(msg % (app, geckoinstance.apps.keys()))
else:
instance_class = geckoinstance.GeckoInstance
self.instance = instance_class(host=self.host, port=self.port,
bin=self.bin, profile=self.profile)
self.instance.start()
assert(self.wait_for_port())

View File

@ -183,7 +183,7 @@ class MarionetteTestRunner(object):
def __init__(self, address=None, emulator=None, emulatorBinary=None,
emulatorImg=None, emulator_res='480x800', homedir=None,
bin=None, profile=None, autolog=False, revision=None,
app=None, bin=None, profile=None, autolog=False, revision=None,
es_server=None, rest_server=None, logger=None,
testgroup="marionette", noWindow=False, logcat_dir=None,
xml_output=None, repeat=0, perf=False, perfserv=None,
@ -195,6 +195,7 @@ class MarionetteTestRunner(object):
self.emulatorImg = emulatorImg
self.emulator_res = emulator_res
self.homedir = homedir
self.app = app
self.bin = bin
self.profile = profile
self.autolog = autolog
@ -274,8 +275,11 @@ class MarionetteTestRunner(object):
else:
host = 'localhost'
port = 2828
self.marionette = Marionette(host=host, port=int(port),
bin=self.bin, profile=self.profile,
self.marionette = Marionette(host=host,
port=int(port),
app=self.app,
bin=self.bin,
profile=self.profile,
baseurl=self.baseurl)
elif self.address:
host, port = self.address.split(':')
@ -620,6 +624,9 @@ def parse_options():
"tests from .ini files.")
parser.add_option('--homedir', dest='homedir', action='store',
help='home directory of emulator files')
parser.add_option('--app', dest='app', action='store',
default=None,
help='application to use')
parser.add_option('--binary', dest='bin', action='store',
help='gecko executable to launch before running the test')
parser.add_option('--profile', dest='profile', action='store',
@ -691,6 +698,7 @@ def startTestRunner(runner_class, options, tests):
emulator_res=options.emulator_res,
homedir=options.homedir,
logcat_dir=options.logcat_dir,
app=options.app,
bin=options.bin,
profile=options.profile,
noWindow=options.noWindow,