示例#1
0
 def connectWIFI(self, wifiSettings):
     """
     Tries to connect to the wifi network
     """
     self._logger.info("Setting up wifi...")
     data = GaiaData(self.marionette)
     data.connect_to_wifi(wifiSettings)
     self._logger.info("WIFI ready!")
示例#2
0
 def connectWIFI(self, wifiSettings):
     """
     Tries to connect to the wifi network
     """
     self._logger.info("Setting up wifi...")
     data = GaiaData(self.marionette)
     data.connect_to_wifi(wifiSettings)
     self._logger.info("WIFI ready!")
示例#3
0
    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaData = GaiaData(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)
示例#4
0
 def __init__(self, app_name, app_id, device=False):
     self.device = device
     if self.device:
         call(['adb', 'forward', 'tcp:2828', 'tcp:2828'])
     self._app_name = app_name
     self._app_id = app_id
     self._marionette = Marionette()
     self._marionette.start_session()
     self._gaia_apps = GaiaApps(self._marionette)
     self._gaia_data = GaiaData(self._marionette)
     self._gaia_device = GaiaDevice(self._marionette)
     ''' Deprecated
示例#5
0
    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaData = GaiaData(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)
示例#6
0
class EidetickerB2GMixin(EidetickerMixin):
    """B2G-specific extensions to the eideticker mixin"""

    marionette = None

    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaData = GaiaData(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)

    def connectWIFI(self, wifiSettings):
        """
        Tries to connect to the wifi network
        """
        self._logger.info("Setting up wifi...")
        self.gaiaData.connect_to_wifi(wifiSettings)
        self._logger.info("WIFI ready!")

    def cleanup(self):
        self.removeDir('/data/local/storage/persistent')
        self.removeDir('/data/b2g/mozilla')
        for item in self.listFiles('/sdcard/'):
            self.removeDir('/'.join(['/sdcard', item]))

    def stopB2G(self):
        self._logger.info("Stopping B2G")

        if self.marionette and self.marionette.session:
            self.marionette.delete_session()
            self.marionette = None

        self.shellCheckOutput(['stop', 'b2g'])
        # Wait for a bit to make sure B2G has completely shut down.
        tries = 100
        while "b2g" in self.shellCheckOutput(['ps', 'b2g']) and tries > 0:
            tries -= 1
            time.sleep(0.1)
        if tries == 0:
            raise mozdevice.DMError("Could not kill b2g process")

    def startB2G(self):
        self._logger.info("Starting B2G")
        self.shellCheckOutput(['start', 'b2g'])
        self.setupMarionette()

        self.marionette.execute_async_script("""
window.addEventListener('mozbrowserloadend', function loaded(aEvent) {
if (aEvent.target.src.indexOf('ftu') != -1 || aEvent.target.src.indexOf('homescreen') != -1) {
window.removeEventListener('mozbrowserloadend', loaded);
marionetteScriptFinished();
}
});""",
                                             script_timeout=60000)

        # TODO: Remove this sleep when Bug 924912 is addressed
        time.sleep(5)

        # run the fake update checker
        FakeUpdateChecker(self.marionette).check_updates()

        # unlock device, so it doesn't go to sleep
        self._logger.info("Unlocking screen...")
        self.gaiaDevice.unlock()

        # turn off automatic brightness adjustments and set to 100%
        self.gaiaData.set_setting('screen.automatic-brightness', '')
        self.gaiaData.set_setting('screen.brightness', 1)

        # kill running apps so they don't interfere with the test
        self._logger.info("Killing all running apps...")
        self.gaiaApps.kill_all()

        # set correct orientation
        self._logger.info("Setting orientation")
        self.marionette.execute_script(
            "screen.mozLockOrientation('%s');" %
            self.deviceProperties['defaultOrientation'])

    def restartB2G(self):
        """
        Restarts the b2g process on the device.
        """
        self.stopB2G()
        self.startB2G()
示例#7
0
class EidetickerB2GMixin(EidetickerMixin):
    """B2G-specific extensions to the eideticker mixin"""

    marionette = None

    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaData = GaiaData(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)

    def connectWIFI(self, wifiSettings):
        """
        Tries to connect to the wifi network
        """
        self._logger.info("Setting up wifi...")
        self.gaiaData.connect_to_wifi(wifiSettings)
        self._logger.info("WIFI ready!")

    def cleanup(self):
        self.removeDir('/data/local/storage/persistent')
        self.removeDir('/data/b2g/mozilla')
        for item in self.listFiles('/sdcard/'):
            self.removeDir('/'.join(['/sdcard', item]))

    def stopB2G(self):
        self._logger.info("Stopping B2G")

        if self.marionette and self.marionette.session:
            self.marionette.delete_session()
            self.marionette = None

        self.shellCheckOutput(['stop', 'b2g'])
        # Wait for a bit to make sure B2G has completely shut down.
        tries = 100
        while "b2g" in self.shellCheckOutput(['ps', 'b2g']) and tries > 0:
            tries -= 1
            time.sleep(0.1)
        if tries == 0:
            raise mozdevice.DMError("Could not kill b2g process")

    def startB2G(self):
        self._logger.info("Starting B2G")
        self.shellCheckOutput(['start', 'b2g'])
        self.setupMarionette()

        self.marionette.execute_async_script("""
window.addEventListener('mozbrowserloadend', function loaded(aEvent) {
if (aEvent.target.src.indexOf('ftu') != -1 || aEvent.target.src.indexOf('homescreen') != -1) {
window.removeEventListener('mozbrowserloadend', loaded);
marionetteScriptFinished();
}
});""", script_timeout=60000)

        # TODO: Remove this sleep when Bug 924912 is addressed
        time.sleep(5)

        # run the fake update checker
        FakeUpdateChecker(self.marionette).check_updates()

        # unlock device, so it doesn't go to sleep
        self._logger.info("Unlocking screen...")
        self.gaiaDevice.unlock()

        # turn off automatic brightness adjustments and set to 100%
        self.gaiaData.set_setting('screen.automatic-brightness', '')
        self.gaiaData.set_setting('screen.brightness', 1)

        # kill running apps so they don't interfere with the test
        self._logger.info("Killing all running apps...")
        self.gaiaApps.kill_all()

        # set correct orientation
        self._logger.info("Setting orientation")
        self.marionette.execute_script("screen.mozLockOrientation('%s');" %
                                       self.deviceProperties['defaultOrientation'])

    def restartB2G(self):
        """
        Restarts the b2g process on the device.
        """
        self.stopB2G()
        self.startB2G()
示例#8
0
class EidetickerB2GMixin(EidetickerMixin):
    """B2G-specific extensions to the eideticker mixin"""

    marionette = None
    _devicePixelRatio = None

    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaData = GaiaData(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)
        self.gaiaCompat = GaiaCompat()

    def connectWIFI(self, wifiSettings):
        """
        Tries to connect to the wifi network
        """
        self._logger.info("Setting up wifi...")
        self.gaiaData.connect_to_wifi(wifiSettings)
        self._logger.info("WIFI ready!")

    def cleanup(self):
        self.removeDir('/data/local/storage/persistent')
        self.removeDir('/data/b2g/mozilla')
        for item in self.listFiles('/sdcard/'):
            self.removeDir('/'.join(['/sdcard', item]))

    def stopB2G(self):
        self._logger.info("Stopping B2G")

        if self.marionette and self.marionette.session:
            self.marionette.delete_session()
            self.marionette = None

        self.shellCheckOutput(['stop', 'b2g'])
        # Wait for a bit to make sure B2G has completely shut down.
        tries = 100
        while "b2g" in self.shellCheckOutput(['ps', 'b2g']) and tries > 0:
            tries -= 1
            time.sleep(0.1)
        if tries == 0:
            raise mozdevice.DMError("Could not kill b2g process")

    def startB2G(self):
        self._logger.info("Starting B2G")
        self.shellCheckOutput(['start', 'b2g'])
        self.setupMarionette()
        self.gaiaCompat.wait_for_b2g(self.marionette)

        # run the fake update checker
        self.gaiaCompat.supress_update_check(self.marionette)

        # unlock device, so it doesn't go to sleep
        self._logger.info("Unlocking screen...")
        self.gaiaDevice.unlock()

        # turn off automatic brightness adjustments and set to 100%
        self.gaiaData.set_setting('screen.automatic-brightness', '')
        self.gaiaData.set_setting('screen.brightness', 1)

        # kill running apps so they don't interfere with the test
        self._logger.info("Killing all running apps...")
        self.gaiaApps.kill_all()

        # set correct orientation
        self._logger.info("Setting orientation")
        self.marionette.execute_script(
            "screen.mozLockOrientation('%s');" %
            self.deviceProperties['defaultOrientation'])

    def restartB2G(self):
        """
        Restarts the b2g process on the device.
        """
        self.stopB2G()
        self.startB2G()

    @property
    def devicePixelRatio(self):
        if not self._devicePixelRatio:
            if self.marionette and self.marionette.session:
                self._devicePixelRatio = self.marionette.execute_script(
                    'return window.wrappedJSObject.devicePixelRatio;')
        return self._devicePixelRatio or 1
示例#9
0
class EidetickerB2GMixin(EidetickerMixin):
    """B2G-specific extensions to the eideticker mixin"""

    marionette = None
    _devicePixelRatio = None

    def setupMarionette(self):
        self.marionette = marionette.Marionette()
        self._logger.info("Waiting for Marionette...")
        self.marionette.wait_for_port()
        self._logger.info("Marionette ready, starting session")
        self.marionette.start_session()
        if 'b2g' not in self.marionette.session:
            raise mozdevice.DMError(
                "bad session value %s returned by start_session" %
                self.marionette.session)
        self.marionette.set_script_timeout(60000)
        self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, 10000)
        self._logger.info("Marionette ready!")

        self.b2gpopulate = B2GPopulate(self.marionette)
        self.gaiaApps = GaiaApps(self.marionette)
        self.gaiaData = GaiaData(self.marionette)
        self.gaiaDevice = GaiaDevice(self.marionette)
        self.gaiaCompat = GaiaCompat()

    def connectWIFI(self, wifiSettings):
        """
        Tries to connect to the wifi network
        """
        self._logger.info("Setting up wifi...")
        self.gaiaData.connect_to_wifi(wifiSettings)
        self._logger.info("WIFI ready!")

    def cleanup(self):
        self.removeDir('/data/local/storage/persistent')
        self.removeDir('/data/b2g/mozilla')
        for item in self.listFiles('/sdcard/'):
            self.removeDir('/'.join(['/sdcard', item]))

    def stopB2G(self):
        self._logger.info("Stopping B2G")

        if self.marionette and self.marionette.session:
            self.marionette.delete_session()
            self.marionette = None

        self.shellCheckOutput(['stop', 'b2g'])
        # Wait for a bit to make sure B2G has completely shut down.
        tries = 100
        while "b2g" in self.shellCheckOutput(['ps', 'b2g']) and tries > 0:
            tries -= 1
            time.sleep(0.1)
        if tries == 0:
            raise mozdevice.DMError("Could not kill b2g process")

    def startB2G(self):
        self._logger.info("Starting B2G")
        self.shellCheckOutput(['start', 'b2g'])
        self.setupMarionette()
        self.gaiaCompat.wait_for_b2g(self.marionette)

        # run the fake update checker
        self.gaiaCompat.supress_update_check(self.marionette)

        # unlock device, so it doesn't go to sleep
        self._logger.info("Unlocking screen...")
        self.gaiaDevice.unlock()

        # turn off automatic brightness adjustments and set to 100%
        self.gaiaData.set_setting('screen.automatic-brightness', '')
        self.gaiaData.set_setting('screen.brightness', 1)

        # kill running apps so they don't interfere with the test
        self._logger.info("Killing all running apps...")
        self.gaiaApps.kill_all()

        # set correct orientation
        self._logger.info("Setting orientation")
        self.marionette.execute_script("screen.mozLockOrientation('%s');" %
                                       self.deviceProperties['defaultOrientation'])

    def restartB2G(self):
        """
        Restarts the b2g process on the device.
        """
        self.stopB2G()
        self.startB2G()

    @property
    def devicePixelRatio(self):
        if not self._devicePixelRatio:
            if self.marionette and self.marionette.session:
                self._devicePixelRatio = self.marionette.execute_script(
                    'return window.wrappedJSObject.devicePixelRatio;')
        return self._devicePixelRatio or 1