Bug 1261019 - Part 1: Remove support for running marionette tests as apps; r=maja_zf

This commit is contained in:
Ehsan Akhgari 2016-09-30 00:36:39 -04:00
parent 7f30ef3465
commit 4c84e21df2
6 changed files with 12 additions and 77 deletions

View File

@ -431,7 +431,6 @@ class MarionetteTestCase(CommonTestCase):
self.methodName = methodName
self.filepath = filepath
self.testvars = kwargs.pop('testvars', None)
self.test_container = kwargs.pop('test_container', None)
CommonTestCase.__init__(self, methodName, **kwargs)
@classmethod
@ -514,7 +513,6 @@ class MarionetteJSTestCase(CommonTestCase):
self.jsFile = jsFile
self._marionette_weakref = marionette_weakref
self.marionette = None
self.test_container = kwargs.pop('test_container', None)
CommonTestCase.__init__(self, methodName)
@classmethod

View File

@ -759,54 +759,6 @@ class BaseMarionetteTestRunner(object):
kwargs['workspace'] = self.workspace_path
return kwargs
def launch_test_container(self):
if self.marionette.session is None:
self.marionette.start_session()
self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
result = self.marionette.execute_async_script("""
if((navigator.mozSettings == undefined) || (navigator.mozSettings == null) ||
(navigator.mozApps == undefined) || (navigator.mozApps == null)) {
marionetteScriptFinished(false);
return;
}
let setReq = navigator.mozSettings.createLock().set({'lockscreen.enabled': false});
setReq.onsuccess = function() {
let appName = 'Test Container';
let activeApp = window.wrappedJSObject.Service.currentApp;
// if the Test Container is already open then do nothing
if(activeApp.name === appName){
marionetteScriptFinished(true);
}
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 === appName) {
app.launch();
window.addEventListener('appopen', function apploadtime(){
window.removeEventListener('appopen', apploadtime);
marionetteScriptFinished(true);
});
return;
}
}
marionetteScriptFinished(false);
}
appsReq.onerror = function() {
marionetteScriptFinished(false);
}
}
setReq.onerror = function() {
marionetteScriptFinished(false);
}""", script_timeout=60000)
if not result:
raise Exception("Could not launch test container app")
def record_crash(self):
crash = True
try:
@ -975,7 +927,7 @@ setReq.onerror = function() {
rv.start()
return rv
def add_test(self, test, expected='pass', test_container=None):
def add_test(self, test, expected='pass'):
filepath = os.path.abspath(test)
if os.path.isdir(filepath):
@ -1026,20 +978,17 @@ setReq.onerror = function() {
raise IOError("test file: {} does not exist".format(i["path"]))
file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1]
test_container = None
self.add_test(i["path"], i["expected"], test_container)
self.add_test(i["path"], i["expected"])
return
self.tests.append({'filepath': filepath, 'expected': expected,
'test_container': test_container})
self.tests.append({'filepath': filepath, 'expected': expected})
def run_test(self, filepath, expected, test_container):
def run_test(self, filepath, expected):
testloader = unittest.TestLoader()
suite = unittest.TestSuite()
self.test_kwargs['expected'] = expected
self.test_kwargs['test_container'] = test_container
mod_name = os.path.splitext(os.path.split(filepath)[-1])[0]
for handler in self.test_handlers:
if handler.match(os.path.basename(filepath)):
@ -1058,9 +1007,6 @@ setReq.onerror = function() {
capabilities=self.capabilities,
result_callbacks=self.result_callbacks)
if test_container:
self.launch_test_container()
results = runner.run(suite)
self.results.append(results)
@ -1091,7 +1037,7 @@ setReq.onerror = function() {
random.shuffle(tests)
for test in tests:
self.run_test(test['filepath'], test['expected'], test['test_container'])
self.run_test(test['filepath'], test['expected'])
if self.record_crash():
break

View File

@ -244,8 +244,7 @@ def _check_crash_counts(has_crashed, runner, mock_marionette):
def test_increment_crash_count_in_run_test_set(runner, has_crashed,
mock_marionette):
fake_tests = [{'filepath': i,
'expected': 'pass',
'test_container': False} for i in 'abc']
'expected': 'pass'} for i in 'abc']
with patch.multiple(runner, run_test=DEFAULT, marionette=mock_marionette):
runner.run_test_set(fake_tests)
@ -268,7 +267,7 @@ def test_add_test_module(runner):
with patch('os.path.abspath', return_value=test) as abspath:
runner.add_test(test)
assert abspath.called
expected = {'filepath': test, 'expected': 'pass', 'test_container': None}
expected = {'filepath': test, 'expected': 'pass'}
assert expected in runner.tests
# add_test doesn't validate module names; 'bad_test.py' gets through
assert len(runner.tests) == 3

View File

@ -1,6 +1,5 @@
; marionette unit tests
[include:unit/unit-tests.ini]
test_container = true
; layout tests
[include:../../../../../layout/base/tests/marionette/manifest.ini]

View File

@ -675,7 +675,7 @@ class BaseSessionTestRunner(object):
rv.start()
return rv
def add_test(self, test, expected='pass', test_container=None):
def add_test(self, test, expected='pass'):
filepath = os.path.abspath(test)
if os.path.isdir(filepath):
@ -718,21 +718,19 @@ class BaseSessionTestRunner(object):
raise IOError("test file: {} does not exist".format(i["path"]))
file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1]
test_container = None
self.add_test(i["path"], i["expected"], test_container)
self.add_test(i["path"], i["expected"])
return
self.tests.append({'filepath': filepath, 'expected': expected, 'test_container': test_container})
self.tests.append({'filepath': filepath, 'expected': expected})
def run_test(self, filepath, expected, test_container):
def run_test(self, filepath, expected):
testloader = unittest.TestLoader()
suite = unittest.TestSuite()
self.test_kwargs['binary'] = self.bin
self.test_kwargs['expected'] = expected
self.test_kwargs['base_url'] = self.base_url
self.test_kwargs['test_container'] = test_container
mod_name = os.path.splitext(os.path.split(filepath)[-1])[0]
for handler in self.test_handlers:
if handler.match(os.path.basename(filepath)):
@ -749,9 +747,6 @@ class BaseSessionTestRunner(object):
result_callbacks=self.result_callbacks,
binary=self.bin)
if test_container:
self.launch_test_container()
results = runner.run(suite)
self.results.append(results)
@ -780,7 +775,7 @@ class BaseSessionTestRunner(object):
random.shuffle(tests)
for test in tests:
self.run_test(test['filepath'], test['expected'], test['test_container'])
self.run_test(test['filepath'], test['expected'])
def run_test_sets(self):
if len(self.tests) < 1:

View File

@ -417,7 +417,6 @@ class SessionTestCase(CommonTestCase):
self.methodName = methodName
self.filepath = filepath
self.testvars = kwargs.pop('testvars', None)
self.test_container = kwargs.pop('test_container', None)
CommonTestCase.__init__(self, methodName, **kwargs)
@classmethod
@ -473,7 +472,6 @@ class SessionJSTestCase(CommonTestCase):
assert(jsFile)
self.jsFile = jsFile
self.marionette = None
self.test_container = kwargs.pop('test_container', None)
CommonTestCase.__init__(self, methodName)
@classmethod