Esempio n. 1
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)
        self.gaiaCompat = GaiaCompat()
Esempio n. 2
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)
        self.gaiaCompat = GaiaCompat()
Esempio n. 3
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
Esempio n. 4
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