本文整理汇总了Python中marionette_driver.marionette.Marionette.wait_for_port方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.wait_for_port方法的具体用法?Python Marionette.wait_for_port怎么用?Python Marionette.wait_for_port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.marionette.Marionette
的用法示例。
在下文中一共展示了Marionette.wait_for_port方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: B2GDesktopReftest
# 需要导入模块: from marionette_driver.marionette import Marionette [as 别名]
# 或者: from marionette_driver.marionette.Marionette import wait_for_port [as 别名]
class B2GDesktopReftest(RefTest):
build_type = "desktop"
marionette = None
def __init__(self, marionette_args):
RefTest.__init__(self)
self.last_test = os.path.basename(__file__)
self.marionette_args = marionette_args
self.profile = None
self.runner = None
self.test_script = os.path.join(here, 'b2g_start_script.js')
self.timeout = None
def run_marionette_script(self):
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=300)
self._unlockScreen()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
if os.path.isfile(self.test_script):
f = open(self.test_script, 'r')
self.test_script = f.read()
f.close()
self.marionette.execute_script(self.test_script)
def run_tests(self, tests, options):
manifests = self.resolver.resolveManifests(options, tests)
self.profile = self.create_profile(options, manifests,
profile_to_clone=options.profile)
env = self.buildBrowserEnv(options, self.profile.profile)
kp_kwargs = { 'processOutputLine': [self._on_output],
'onTimeout': [self._on_timeout],
'kill_on_timeout': False }
if not options.debugger:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
self.timeout = options.timeout + 30.0
log.info("%s | Running tests: start.", os.path.basename(__file__))
cmd, args = self.build_command_line(options.app,
ignore_window_size=options.ignoreWindowSize,
browser_arg=options.browser_arg)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd,
cmdargs=args,
env=env,
process_class=ProcessHandler,
process_args=kp_kwargs,
symbols_path=options.symbolsPath)
status = 0
try:
self.runner.start(outputTimeout=self.timeout)
log.info("%s | Application pid: %d",
os.path.basename(__file__),
self.runner.process_handler.pid)
# kick starts the reftest harness
self.run_marionette_script()
status = self.runner.wait()
finally:
self.runner.check_for_crashes(test_name=self.last_test)
self.runner.cleanup()
if status > 0:
log.testFail("%s | application terminated with exit code %s",
self.last_test, status)
elif status < 0:
log.info("%s | application killed with signal %s",
self.last_test, -status)
log.info("%s | Running tests: end.", os.path.basename(__file__))
return status
def create_profile(self, options, manifests, profile_to_clone=None):
profile = RefTest.createReftestProfile(self, options, manifests,
profile_to_clone=profile_to_clone)
prefs = {}
# Turn off the locale picker screen
prefs["browser.firstrun.show.localepicker"] = False
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"
# Make sure we disable system updates
prefs["app.update.enabled"] = False
prefs["app.update.url"] = ""
prefs["app.update.url.override"] = ""
# Disable webapp updates
#.........这里部分代码省略.........
示例2: MuletReftest
# 需要导入模块: from marionette_driver.marionette import Marionette [as 别名]
# 或者: from marionette_driver.marionette.Marionette import wait_for_port [as 别名]
class MuletReftest(RefTest):
build_type = "mulet"
marionette = None
def __init__(self, marionette_args):
RefTest.__init__(self)
self.last_test = os.path.basename(__file__)
self.marionette_args = marionette_args
self.profile = None
self.runner = None
self.test_script = os.path.join(here, 'b2g_start_script.js')
self.timeout = None
def run_marionette_script(self):
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=300)
self._unlockScreen()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
if os.path.isfile(self.test_script):
f = open(self.test_script, 'r')
self.test_script = f.read()
f.close()
self.marionette.execute_script(self.test_script)
def run_tests(self, tests, options):
manifests = self.resolver.resolveManifests(options, tests)
self.profile = self.create_profile(options, manifests,
profile_to_clone=options.profile)
env = self.buildBrowserEnv(options, self.profile.profile)
self._populate_logger(options)
outputHandler = OutputHandler(self.log, options.utilityPath, symbolsPath=options.symbolsPath)
kp_kwargs = { 'processOutputLine': [outputHandler],
'onTimeout': [self._on_timeout],
'kill_on_timeout': False }
if not options.debugger:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
self.timeout = options.timeout + 30.0
self.log.info("%s | Running tests: start." % os.path.basename(__file__))
cmd, args = self.build_command_line(options.app,
ignore_window_size=options.ignoreWindowSize,
browser_arg=options.browser_arg)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd,
cmdargs=args,
env=env,
process_class=ProcessHandler,
process_args=kp_kwargs,
symbols_path=options.symbolsPath)
status = 0
try:
self.runner.start(outputTimeout=self.timeout)
self.log.info("%s | Application pid: %d" % (
os.path.basename(__file__),
self.runner.process_handler.pid))
# kick starts the reftest harness
self.run_marionette_script()
status = self.runner.wait()
finally:
self.runner.check_for_crashes(test_name=self.last_test)
self.runner.cleanup()
if status > 0:
self.log.testFail("%s | application terminated with exit code %s" % (
self.last_test, status))
elif status < 0:
self.log.info("%s | application killed with signal %s" % (
self.last_test, -status))
self.log.info("%s | Running tests: end." % os.path.basename(__file__))
return status
def create_profile(self, options, manifests, profile_to_clone=None):
profile = RefTest.createReftestProfile(self, options, manifests,
profile_to_clone=profile_to_clone)
prefs = {}
# Turn off the locale picker screen
prefs["browser.firstrun.show.localepicker"] = False
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"
# Make sure we disable system updates
#.........这里部分代码省略.........