Ejemplo n.º 1
0
    def write_android_app_config(self):
        # geckoview supports having a local on-device config file; use this file
        # to tell the app to use the specified browser profile, as well as other opts
        # on-device: /data/local/tmp/com.yourcompany.yourapp-geckoview-config.yaml
        # https://mozilla.github.io/geckoview/tutorials/automation.html#configuration-file-format

        LOG.info("creating android app config.yml")

        yml_config_data = dict(
            args=[
                "--profile",
                self.remote_profile,
                "--allow-downgrade",
            ],
            env=dict(
                LOG_VERBOSE=1,
                R_LOG_LEVEL=6,
                MOZ_WEBRENDER=int(self.config["enable_webrender"]),
            ),
        )

        yml_name = "%s-geckoview-config.yaml" % self.config["binary"]
        yml_on_host = os.path.join(tempfile.mkdtemp(), yml_name)
        write_yml_file(yml_on_host, yml_config_data)
        yml_on_device = os.path.join("/data", "local", "tmp", yml_name)

        try:
            LOG.info("copying %s to device: %s" % (yml_on_host, yml_on_device))
            self.device.rm(yml_on_device, force=True, recursive=True)
            self.device.push(yml_on_host, yml_on_device)

        except Exception:
            LOG.critical("failed to push %s to device!" % yml_on_device)
            raise
Ejemplo n.º 2
0
def test_write_yml_file():
    yml_file = os.path.join(tempfile.mkdtemp(), 'utils.yaml')

    yml_data = dict(args=['--a', 'apple', '--b', 'banana'],
                    env=dict(LOG_VERBOSE=1))

    assert not os.path.exists(yml_file)
    write_yml_file(yml_file, yml_data)
    assert os.path.exists(yml_file)

    with open(yml_file, 'r') as yml_in:
        yml_loaded = yaml.load(yml_in)
        assert yml_loaded == yml_data
Ejemplo n.º 3
0
def test_write_yml_file():
    yml_file = os.path.join(tempfile.mkdtemp(), "utils.yaml")

    yml_data = dict(args=["--a", "apple", "--b", "banana"],
                    env=dict(LOG_VERBOSE=1))

    assert not os.path.exists(yml_file)
    write_yml_file(yml_file, yml_data)
    assert os.path.exists(yml_file)

    with open(yml_file, "r") as yml_in:
        yml_loaded = yaml.unsafe_load(yml_in)
        assert yml_loaded == yml_data