Bug 1275608 - [mozrunner] Remove wait_for_system_message from Emulator; r?ahal draft
authorMaja Frydrychowicz <mjzffr@gmail.com>
Wed, 25 May 2016 11:53:25 -0400
changeset 370933 26661b880a73e5f522e5eeaff5dab261cfe6d34d
parent 370909 fd985ed46ae441ede84b789a476d30a8428217c7
child 521861 36fd2a378988d984d2a242f7f36bf28ae420052f
push id19180
push usermjzffr@gmail.com
push dateWed, 25 May 2016 15:54:02 +0000
reviewersahal
bugs1275608
milestone49.0a1
Bug 1275608 - [mozrunner] Remove wait_for_system_message from Emulator; r?ahal This code is no longer used by Marionette client or elsewhere. MozReview-Commit-ID: 4lx9CN7XIeH
testing/mozbase/mozrunner/mozrunner/devices/emulator.py
testing/mozbase/mozrunner/mozrunner/utils.py
--- a/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
+++ b/testing/mozbase/mozrunner/mozrunner/devices/emulator.py
@@ -12,17 +12,16 @@ import tempfile
 import time
 
 from mozprocess import ProcessHandler
 
 from .base import Device
 from .emulator_battery import EmulatorBattery
 from .emulator_geo import EmulatorGeo
 from .emulator_screen import EmulatorScreen
-from ..utils import uses_marionette
 from ..errors import TimeoutException
 
 class ArchContext(object):
     def __init__(self, arch, context, binary=None):
         kernel = os.path.join(context.homedir, 'prebuilts', 'qemu-kernel', '%s', '%s')
         sysdir = os.path.join(context.homedir, 'out', 'target', 'product', '%s')
         if arch == 'x86':
             self.binary = os.path.join(context.bindir, 'emulator-x86')
@@ -170,47 +169,16 @@ class Emulator(Device):
         if self.proc:
             self.proc.kill()
             self.proc = None
 
         # Remove temporary files
         self.userdata.close()
         shutil.rmtree(self.tmpdir)
 
-    # TODO this function is B2G specific and shouldn't live here
-    @uses_marionette
-    def wait_for_system_message(self, marionette):
-        marionette.set_script_timeout(45000)
-        # Telephony API's won't be available immediately upon emulator
-        # boot; we have to wait for the syste-message-listener-ready
-        # message before we'll be able to use them successfully.  See
-        # bug 792647.
-        print 'waiting for system-message-listener-ready...'
-        try:
-            marionette.execute_async_script("""
-waitFor(
-    function() { marionetteScriptFinished(true); },
-    function() { return isSystemMessageListenerReady(); }
-);
-            """)
-        except:
-            # Look for ScriptTimeoutException this way to avoid a
-            # dependency on the marionette python client.
-            exc_name = sys.exc_info()[0].__name__
-            if exc_name != 'ScriptTimeoutException':
-                raise
-
-            print 'timed out'
-            # We silently ignore the timeout if it occurs, since
-            # isSystemMessageListenerReady() isn't available on
-            # older emulators.  45s *should* be enough of a delay
-            # to allow telephony API's to work.
-            pass
-        print '...done'
-
     def _get_telnet_response(self, command=None):
         output = []
         assert(self.telnet)
         if command is not None:
             self.telnet.write('%s\n' % command)
         while True:
             line = self.telnet.read_until('\n')
             output.append(line.rstrip())
--- a/testing/mozbase/mozrunner/mozrunner/utils.py
+++ b/testing/mozbase/mozrunner/mozrunner/utils.py
@@ -69,37 +69,16 @@ if __name__ == '__main__':
 def _find_marionette_in_args(*args, **kwargs):
     try:
         m = [a for a in args + tuple(kwargs.values()) if hasattr(a, 'session')][0]
     except IndexError:
         print("Can only apply decorator to function using a marionette object")
         raise
     return m
 
-def uses_marionette(func):
-    """Decorator which creates a marionette session and deletes it
-    afterwards if one doesn't already exist.
-    """
-    @wraps(func)
-    def _(*args, **kwargs):
-        m = _find_marionette_in_args(*args, **kwargs)
-        delete_session = False
-        if not m.session:
-            delete_session = True
-            m.start_session()
-
-        m.set_context(m.CONTEXT_CHROME)
-        ret = func(*args, **kwargs)
-
-        if delete_session:
-            m.delete_session()
-
-        return ret
-    return _
-
 
 def _raw_log():
     import logging
     return logging.getLogger(__name__)
 
 
 def test_environment(xrePath, env=None, crashreporter=True, debugger=False,
                      dmdPath=None, lsanPath=None, log=None):