Exemple #1
0
    def launch_firefox_android_app(self, test_name):
        self.log.info("starting %s" % self.config['app'])

        extra_args = [
            "-profile", self.device_profile, "--es", "env0", "LOG_VERBOSE=1",
            "--es", "env1", "R_LOG_LEVEL=6"
        ]

        try:
            # make sure the android app is not already running
            self.device.stop_application(self.config['binary'])

            if self.config['app'] == "fennec":
                self.device.launch_fennec(self.config['binary'],
                                          extra_args=extra_args,
                                          url='about:blank',
                                          fail_if_running=False)
            else:
                self.device.launch_activity(self.config['binary'],
                                            self.config['activity'],
                                            self.config['intent'],
                                            extra_args=extra_args,
                                            url='about:blank',
                                            e10s=True,
                                            fail_if_running=False)
        except Exception as e:
            self.log.error("Exception launching %s" % self.config['binary'])
            self.log.error("Exception: %s %s" % (type(e).__name__, str(e)))
            if self.config['power_test']:
                finish_android_power_test(self, test_name)
            raise

        # give our control server the device and app info
        self.control_server.device = self.device
        self.control_server.app_name = self.config['binary']
Exemple #2
0
    def run_test(self, test, timeout):
        # tests will be run warm (i.e. NO browser restart between page-cycles)
        # unless otheriwse specified in the test INI by using 'cold = true'
        try:

            if self.config["power_test"]:
                # gather OS baseline data
                init_android_power_test(self)
                LOG.info("Running OS baseline, pausing for 1 minute...")
                time.sleep(60)
                LOG.info("Finishing baseline...")
                finish_android_power_test(self,
                                          "os-baseline",
                                          os_baseline=True)

                # initialize for the test
                init_android_power_test(self)

            if test.get("cold", False) is True:
                self.__run_test_cold(test, timeout)
            else:
                self.__run_test_warm(test, timeout)

        except SignalHandlerException:
            self.device.stop_application(self.config["binary"])
            if self.config['power_test']:
                enable_charging(self.device)

        finally:
            if self.config["power_test"]:
                finish_android_power_test(self, test["name"])
Exemple #3
0
    def launch_firefox_android_app(self, test_name):
        LOG.info("starting %s" % self.config["app"])

        try:
            # make sure the android app is not already running
            self.device.stop_application(self.config["binary"])

            # command line 'extra' args not used with geckoview apps; instead we use
            # an on-device config.yml file (see write_android_app_config)

            self.device.launch_application(
                self.config["binary"],
                self.config["activity"],
                self.config["intent"],
                extras=None,
                url="about:blank",
                fail_if_running=False,
            )

            # Check if app has started and it's running
            if not self.process_exists:
                raise Exception(
                    "Error launching %s. App did not start properly!" %
                    self.config["binary"])
            self.app_launched = True
        except Exception as e:
            LOG.error("Exception launching %s" % self.config["binary"])
            LOG.error("Exception: %s %s" % (type(e).__name__, str(e)))
            if self.config["power_test"]:
                finish_android_power_test(self, test_name)
            raise

        # give our control server the device and app info
        self.control_server.device = self.device
        self.control_server.app_name = self.config["binary"]
Exemple #4
0
    def launch_firefox_android_app(self, test_name):
        LOG.info("starting %s" % self.config["app"])

        extra_args = [
            "-profile",
            self.remote_profile,
            "--es",
            "env0",
            "LOG_VERBOSE=1",
            "--es",
            "env1",
            "R_LOG_LEVEL=6",
            "--es",
            "env2",
            "MOZ_WEBRENDER=%d" % self.config["enable_webrender"],
        ]

        try:
            # make sure the android app is not already running
            self.device.stop_application(self.config["binary"])

            if self.config["app"] == "fennec":
                self.device.launch_fennec(
                    self.config["binary"],
                    extra_args=extra_args,
                    url="about:blank",
                    fail_if_running=False,
                )
            else:

                # command line 'extra' args not used with geckoview apps; instead we use
                # an on-device config.yml file (see write_android_app_config)

                self.device.launch_application(
                    self.config["binary"],
                    self.config["activity"],
                    self.config["intent"],
                    extras=None,
                    url="about:blank",
                    fail_if_running=False,
                )

            # Check if app has started and it's running
            if not self.device.process_exist(self.config["binary"]):
                raise Exception(
                    "Error launching %s. App did not start properly!" %
                    self.config["binary"])
            self.app_launched = True
        except Exception as e:
            LOG.error("Exception launching %s" % self.config["binary"])
            LOG.error("Exception: %s %s" % (type(e).__name__, str(e)))
            if self.config["power_test"]:
                finish_android_power_test(self, test_name)
            raise

        # give our control server the device and app info
        self.control_server.device = self.device
        self.control_server.app_name = self.config["binary"]
Exemple #5
0
def test_androidos_baseline_power():
    if not os.getenv("MOZ_UPLOAD_DIR"):
        os.environ["MOZ_UPLOAD_DIR"] = tempfile.mkdtemp()

    with mock.patch("mozdevice.adb.ADBDevice") as device:
        with mock.patch(
                "control_server.RaptorControlServer") as control_server:
            # Override the shell output with sample CPU usage details
            filepath = os.path.abspath(os.path.dirname(__file__)) + "/files/"
            f = open(filepath + "batterystats-android-8.txt", "r")
            batterystats_return_value = f.read()

            # Multiple shell output calls are performed
            # and only those with non-None output are required
            device.shell_output.return_value = None
            device.shell_output.side_effect = [
                None,
                None,
                "Test value",
                "Test value",
                batterystats_return_value,
                "8.0.0",
            ]

            device._verbose = True
            device.version = 8

            # Create a control server
            control_server.power_test = True
            control_server.test_name = "gve-pytest"
            control_server.device = device
            control_server.app_name = "org.mozilla.geckoview_example"
            web_extension = WebExtensionAndroid(
                "geckoview", "org.mozilla.geckoview_example", power_test=True)
            web_extension.device = device
            web_extension.config["power_test"] = True
            web_extension.control_server = control_server

            # Expected OS baseline calculation result
            os_baseline_data = {
                "type": "power",
                "test": "gve-pytest",
                "unit": "mAh",
                "values": {
                    "cpu": float(10.786654),
                    "wifi": float(2.26132),
                    "screen": float(51.66),
                    "proportional": float(11.294805199999999),
                },
            }

            # Verify the response contains our expected calculations
            power.finish_android_power_test(web_extension,
                                            "gve-pytest",
                                            os_baseline=True)

            assert web_extension.os_baseline_data == os_baseline_data
Exemple #6
0
    def run_test(self, test, timeout=None):
        # tests will be run warm (i.e. NO browser restart between page-cycles)
        # unless otheriwse specified in the test INI by using 'cold = true'
        try:
            if test.get('cold', False) is True:
                self.run_test_cold(test, timeout)
            else:
                self.run_test_warm(test, timeout)

        except SignalHandlerException:
            self.device.stop_application(self.config['binary'])

        finally:
            if self.config['power_test']:
                finish_android_power_test(self, test['name'])

            self.run_test_teardown()
Exemple #7
0
def test_android7_power():
    if not os.getenv("MOZ_UPLOAD_DIR"):
        os.environ["MOZ_UPLOAD_DIR"] = tempfile.mkdtemp()

    with mock.patch("mozdevice.adb.ADBDevice") as device:
        with mock.patch(
                "control_server.RaptorControlServer") as control_server:
            # Override the shell output with sample CPU usage details
            filepath = os.path.abspath(os.path.dirname(__file__)) + "/files/"
            f = open(filepath + "batterystats-android-7.txt", "r")
            batterystats_return_value = f.read()

            # Multiple shell output calls are performed
            # and only those with non-None output are required
            device.shell_output.return_value = None
            device.shell_output.side_effect = [
                None,
                None,
                "Test value",
                "Test value",
                batterystats_return_value,
                "7.0.0",
            ]

            device._verbose = True
            device.version = 7

            # Create a control server
            control_server.power_test = True
            control_server.test_name = "gve-pytest"
            control_server.device = device
            control_server.app_name = "org.mozilla.geckoview_example"
            web_extension = WebExtensionAndroid(
                "geckoview", "org.mozilla.geckoview_example", power_test=True)
            web_extension.device = device
            web_extension.config["power_test"] = True
            web_extension.control_server = control_server
            web_extension.power_test_time = 20  # minutes
            web_extension.os_baseline_data = {
                "type": "power",
                "test": "gve-pytest",
                "unit": "mAh",
                "values": {
                    "cpu": float(5),
                    "wifi": float(5),
                    "screen": float(5)
                },
            }

            # Verify the response contains our expected calculations
            # (no proportional measure on android 7)
            power_data = {
                "type": "power",
                "test": "gve-pytest",
                "unit": "mAh",
                "values": {
                    "cpu": float(14.5),
                    "wifi": float(0.132),
                    "screen": float(70.7),
                },
            }

            pc_data = {
                "type": "power",
                "test": "gve-pytest-%change",
                "unit": "%",
                "values": {
                    "cpu": float(14.5),
                    "wifi": float(0.132000000000005),
                    "screen": float(70.70000000000002),
                },
            }

            power.finish_android_power_test(web_extension, "gve-pytest")

            control_server.submit_supporting_data.assert_has_calls([
                mock.call(power_data),
                mock.call(pc_data),
                mock.call(web_extension.os_baseline_data),
            ])