mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset db18074e2a25 to correct bug number
This commit is contained in:
parent
bd92c31a0f
commit
2f06cba411
@ -2,3 +2,46 @@
|
||||
# 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/.
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
class B2GInstance(object):
|
||||
|
||||
def __init__(self, host, port, b2gbin):
|
||||
self.marionette_host = host
|
||||
self.marionette_port = port
|
||||
self.b2gbin = b2gbin
|
||||
self.proc = None
|
||||
|
||||
def start(self):
|
||||
if not os.getenv('GAIA'):
|
||||
raise Exception("GAIA environment variable must be set to your gaia directory")
|
||||
args = [self.b2gbin, '-profile', os.path.join(os.getenv('GAIA'), "profile")]
|
||||
self.proc = subprocess.Popen(args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
def close(self):
|
||||
self.proc.terminate()
|
||||
|
||||
def wait_for_port(self, timeout=300):
|
||||
assert(self.marionette_port)
|
||||
starttime = datetime.datetime.now()
|
||||
while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect((self.marionette_host, self.marionette_port))
|
||||
data = sock.recv(16)
|
||||
sock.close()
|
||||
if '"from"' in data:
|
||||
return True
|
||||
except:
|
||||
import traceback
|
||||
print traceback.format_exc()
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
import datetime
|
||||
import socket
|
||||
import time
|
||||
from mozrunner import Runner
|
||||
|
||||
|
||||
class GeckoInstance(object):
|
||||
|
||||
def __init__(self, host, port, bin, profile):
|
||||
self.marionette_host = host
|
||||
self.marionette_port = port
|
||||
self.bin = bin
|
||||
self.profile = profile
|
||||
self.runner = None
|
||||
|
||||
def start(self):
|
||||
profile = self.profile
|
||||
if not profile:
|
||||
prefs = {"dom.allow_XUL_XBL_for_file": True,
|
||||
"marionette.defaultPrefs.enabled": True,
|
||||
"marionette.defaultPrefs.port": 2828}
|
||||
profile = {"preferences": prefs, "restore":False}
|
||||
print "starting runner"
|
||||
self.runner = Runner.create(binary=self.bin, profile_args=profile, cmdargs=['-no-remote'])
|
||||
self.runner.start()
|
||||
|
||||
def close(self):
|
||||
self.runner.stop()
|
||||
self.runner.cleanup()
|
||||
|
||||
def wait_for_port(self, timeout=3000):
|
||||
assert(self.marionette_port)
|
||||
starttime = datetime.datetime.now()
|
||||
while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect((self.marionette_host, self.marionette_port))
|
||||
data = sock.recv(16)
|
||||
print "closing socket"
|
||||
sock.close()
|
||||
if '"from"' in data:
|
||||
print "got data"
|
||||
time.sleep(5)
|
||||
return True
|
||||
except:
|
||||
import traceback
|
||||
print traceback.format_exc()
|
||||
time.sleep(1)
|
||||
return False
|
@ -7,7 +7,7 @@ import socket
|
||||
from client import MarionetteClient
|
||||
from errors import *
|
||||
from emulator import Emulator
|
||||
from geckoinstance import GeckoInstance
|
||||
from b2ginstance import B2GInstance
|
||||
|
||||
class HTMLElement(object):
|
||||
|
||||
@ -70,13 +70,12 @@ class Marionette(object):
|
||||
CONTEXT_CHROME = 'chrome'
|
||||
CONTEXT_CONTENT = 'content'
|
||||
|
||||
def __init__(self, host='localhost', port=2828, bin=None, profile=None,
|
||||
def __init__(self, host='localhost', port=2828, b2gbin=False,
|
||||
emulator=None, emulatorBinary=None, connectToRunningEmulator=False,
|
||||
homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
|
||||
self.host = host
|
||||
self.port = self.local_port = port
|
||||
self.bin = bin
|
||||
self.profile = profile
|
||||
self.b2gbin = b2gbin
|
||||
self.session = None
|
||||
self.window = None
|
||||
self.emulator = None
|
||||
@ -86,11 +85,10 @@ class Marionette(object):
|
||||
self.noWindow = noWindow
|
||||
self.logcat_dir = logcat_dir
|
||||
|
||||
if bin:
|
||||
self.instance = GeckoInstance(host=self.host, port=self.port,
|
||||
bin=self.bin, profile=self.profile)
|
||||
self.instance.start()
|
||||
assert(self.instance.wait_for_port())
|
||||
if b2gbin:
|
||||
self.b2ginstance = B2GInstance(host=self.host, port=self.port, b2gbin=self.b2gbin)
|
||||
self.b2ginstance.start()
|
||||
assert(self.b2ginstance.wait_for_port())
|
||||
if emulator:
|
||||
self.emulator = Emulator(homedir=homedir,
|
||||
noWindow=self.noWindow,
|
||||
@ -112,8 +110,8 @@ class Marionette(object):
|
||||
def __del__(self):
|
||||
if self.emulator:
|
||||
self.emulator.close()
|
||||
if self.bin:
|
||||
self.instance.close()
|
||||
if self.b2gbin:
|
||||
self.b2ginstance.close()
|
||||
for qemu in self.extra_emulators:
|
||||
qemu.emulator.close()
|
||||
|
||||
|
@ -135,15 +135,14 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
|
||||
class MarionetteTestRunner(object):
|
||||
|
||||
def __init__(self, address=None, emulator=None, emulatorBinary=None, homedir=None,
|
||||
bin=None, profile=None, autolog=False, revision=None, es_server=None,
|
||||
b2gbin=None, autolog=False, revision=None, es_server=None,
|
||||
rest_server=None, logger=None, testgroup="marionette",
|
||||
noWindow=False, logcat_dir=None):
|
||||
self.address = address
|
||||
self.emulator = emulator
|
||||
self.emulatorBinary = emulatorBinary
|
||||
self.homedir = homedir
|
||||
self.bin = bin
|
||||
self.profile = profile
|
||||
self.b2gbin = b2gbin
|
||||
self.autolog = autolog
|
||||
self.testgroup = testgroup
|
||||
self.revision = revision
|
||||
@ -188,16 +187,7 @@ class MarionetteTestRunner(object):
|
||||
|
||||
def start_marionette(self):
|
||||
assert(self.baseurl is not None)
|
||||
if self.bin:
|
||||
if self.address:
|
||||
host, port = self.address.split(':')
|
||||
else:
|
||||
host = 'localhost'
|
||||
port = 2828
|
||||
self.marionette = Marionette(host=host, port=int(port),
|
||||
bin=self.bin, profile=self.profile,
|
||||
baseurl=self.baseurl)
|
||||
elif self.address:
|
||||
if self.address:
|
||||
host, port = self.address.split(':')
|
||||
if self.emulator:
|
||||
self.marionette = Marionette(host=host, port=int(port),
|
||||
@ -205,6 +195,11 @@ class MarionetteTestRunner(object):
|
||||
homedir=self.homedir,
|
||||
baseurl=self.baseurl,
|
||||
logcat_dir=self.logcat_dir)
|
||||
if self.b2gbin:
|
||||
self.marionette = Marionette(host=host,
|
||||
port=int(port),
|
||||
b2gbin=self.b2gbin,
|
||||
baseurl=self.baseurl)
|
||||
else:
|
||||
self.marionette = Marionette(host=host,
|
||||
port=int(port),
|
||||
@ -217,7 +212,7 @@ class MarionetteTestRunner(object):
|
||||
noWindow=self.noWindow,
|
||||
logcat_dir=self.logcat_dir)
|
||||
else:
|
||||
raise Exception("must specify binary, address or emulator")
|
||||
raise Exception("must specify address or emulator")
|
||||
|
||||
def post_to_autolog(self, elapsedtime):
|
||||
self.logger.info('posting results to autolog')
|
||||
@ -272,9 +267,7 @@ class MarionetteTestRunner(object):
|
||||
|
||||
def run_test(self, test, testtype):
|
||||
if not self.httpd:
|
||||
print "starting httpd"
|
||||
self.start_httpd()
|
||||
|
||||
if not self.marionette:
|
||||
self.start_marionette()
|
||||
|
||||
@ -397,11 +390,8 @@ if __name__ == "__main__":
|
||||
"tests from .ini files.")
|
||||
parser.add_option('--homedir', dest='homedir', action='store',
|
||||
help='home directory of emulator files')
|
||||
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',
|
||||
help='profile to use when launching the gecko process. If not '
|
||||
'passed, then a profile will be constructed and used.')
|
||||
parser.add_option('--b2gbin', dest='b2gbin', action='store',
|
||||
help='b2g executable')
|
||||
|
||||
options, tests = parser.parse_args()
|
||||
|
||||
@ -409,9 +399,9 @@ if __name__ == "__main__":
|
||||
parser.print_usage()
|
||||
parser.exit()
|
||||
|
||||
if not options.emulator and not options.address and not options.bin:
|
||||
if not options.emulator and not options.address:
|
||||
parser.print_usage()
|
||||
print "must specify --binary, --emulator or --address"
|
||||
print "must specify --emulator or --address"
|
||||
parser.exit()
|
||||
|
||||
# default to storing logcat output for emulator runs
|
||||
@ -423,8 +413,7 @@ if __name__ == "__main__":
|
||||
emulatorBinary=options.emulatorBinary,
|
||||
homedir=options.homedir,
|
||||
logcat_dir=options.logcat_dir,
|
||||
bin=options.bin,
|
||||
profile=options.profile,
|
||||
b2gbin=options.b2gbin,
|
||||
noWindow=options.noWindow,
|
||||
revision=options.revision,
|
||||
testgroup=options.testgroup,
|
||||
|
Loading…
Reference in New Issue
Block a user