Exemplo n.º 1
0
 def test_disable_gpu(self, config_stub, monkeypatch, parser):
     monkeypatch.setattr(configinit.objects, 'backend',
                         usertypes.Backend.QtWebEngine)
     config_stub.val.qt.force_software_rendering = 'chromium'
     parsed = parser.parse_args([])
     expected = [sys.argv[0], '--disable-gpu']
     assert configinit.qt_args(parsed) == expected
Exemplo n.º 2
0
    def test_canvas_reading(self, config_stub, monkeypatch, parser,
                            canvas_reading, added):
        monkeypatch.setattr(configinit.objects, 'backend',
                            usertypes.Backend.QtWebEngine)

        config_stub.val.content.canvas_reading = canvas_reading
        parsed = parser.parse_args([])
        args = configinit.qt_args(parsed)
        assert ('--disable-reading-from-canvas' in args) == added
Exemplo n.º 3
0
 def test_shared_workers(self, config_stub, monkeypatch, parser, backend,
                         expected):
     monkeypatch.setattr(configinit.qtutils,
                         'version_check',
                         lambda version, compiled=False: False)
     monkeypatch.setattr(configinit.objects, 'backend', backend)
     parsed = parser.parse_args([])
     args = configinit.qt_args(parsed)
     assert ('--disable-shared-workers' in args) == expected
Exemplo n.º 4
0
 def test_qt_both(self, config_stub, parser):
     """Test commandline with a Qt argument and flag."""
     args = parser.parse_args(
         ['--qt-arg', 'stylesheet', 'foobar', '--qt-flag', 'reverse'])
     qt_args = configinit.qt_args(args)
     assert qt_args[0] == sys.argv[0]
     assert '--reverse' in qt_args
     assert '--stylesheet' in qt_args
     assert 'foobar' in qt_args
Exemplo n.º 5
0
    def test_autoplay(self, config_stub, monkeypatch, parser, new_version,
                      autoplay, added):
        monkeypatch.setattr(configinit.objects, 'backend',
                            usertypes.Backend.QtWebEngine)
        config_stub.val.content.autoplay = autoplay
        monkeypatch.setattr(configinit.qtutils,
                            'version_check',
                            lambda version, compiled=False: new_version)

        parsed = parser.parse_args([])
        args = configinit.qt_args(parsed)
        assert ('--autoplay-policy=user-gesture-required' in args) == added
Exemplo n.º 6
0
    def test_referer(self, config_stub, monkeypatch, parser, referer, arg):
        monkeypatch.setattr(configinit.objects, 'backend',
                            usertypes.Backend.QtWebEngine)

        config_stub.val.content.headers.referer = referer
        parsed = parser.parse_args([])
        args = configinit.qt_args(parsed)

        if arg is None:
            assert '--no-referrers' not in args
            assert '--reduced-referrer-granularity' not in args
        else:
            assert arg in args
Exemplo n.º 7
0
    def test_low_end_device_mode(self, config_stub, monkeypatch, parser,
                                 low_end_device_mode, arg):
        monkeypatch.setattr(configinit.objects, 'backend',
                            usertypes.Backend.QtWebEngine)

        config_stub.val.qt.low_end_device_mode = low_end_device_mode
        parsed = parser.parse_args([])
        args = configinit.qt_args(parsed)

        if arg is None:
            assert '--enable-low-end-device-mode' not in args
            assert '--disable-low-end-device-mode' not in args
        else:
            assert arg in args
Exemplo n.º 8
0
    def test_webrtc(self, config_stub, monkeypatch, parser, policy, arg):
        monkeypatch.setattr(configinit.objects, 'backend',
                            usertypes.Backend.QtWebEngine)
        config_stub.val.content.webrtc_ip_handling_policy = policy

        parsed = parser.parse_args([])
        args = configinit.qt_args(parsed)

        if arg is None:
            assert not any(
                a.startswith('--force-webrtc-ip-handling-policy=')
                for a in args)
        else:
            assert arg in args
Exemplo n.º 9
0
    def test_process_model(self, config_stub, monkeypatch, parser,
                           process_model, added):
        monkeypatch.setattr(configinit.objects, 'backend',
                            usertypes.Backend.QtWebEngine)

        config_stub.val.qt.process_model = process_model
        parsed = parser.parse_args([])
        args = configinit.qt_args(parsed)

        if added:
            assert '--' + process_model in args
        else:
            assert '--process-per-site' not in args
            assert '--single-process' not in args
            assert '--process-per-site-instance' not in args
            assert '--process-per-tab' not in args
Exemplo n.º 10
0
    def test_in_process_stack_traces(self, monkeypatch, parser, backend,
                                     version_check, debug_flag, expected):
        monkeypatch.setattr(configinit.qtutils,
                            'version_check',
                            lambda version, compiled=False: version_check)
        monkeypatch.setattr(configinit.objects, 'backend', backend)
        parsed = parser.parse_args(
            ['--debug-flag', 'stack'] if debug_flag else [])
        args = configinit.qt_args(parsed)

        if expected is None:
            assert '--disable-in-process-stack-traces' not in args
            assert '--enable-in-process-stack-traces' not in args
        elif expected:
            assert '--disable-in-process-stack-traces' not in args
            assert '--enable-in-process-stack-traces' in args
        else:
            assert '--disable-in-process-stack-traces' in args
            assert '--enable-in-process-stack-traces' not in args
Exemplo n.º 11
0
    def __init__(self, args):
        """Constructor.

        Args:
            Argument namespace from argparse.
        """
        self._last_focus_object = None

        qt_args = configinit.qt_args(args)
        log.init.debug("Qt arguments: {}, based on {}".format(qt_args, args))
        super().__init__(qt_args)

        log.init.debug("Initializing application...")

        self._args = args
        objreg.register('args', args)
        objreg.register('app', self)

        self.launch_time = datetime.datetime.now()
        self.focusObjectChanged.connect(self.on_focus_object_changed)
        self.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
Exemplo n.º 12
0
 def test_chromium_debug(self, monkeypatch, parser, flags, expected):
     monkeypatch.setattr(configinit.objects, 'backend',
                         usertypes.Backend.QtWebEngine)
     parsed = parser.parse_args(flags)
     assert configinit.qt_args(parsed) == [sys.argv[0]] + expected
Exemplo n.º 13
0
 def test_with_settings(self, config_stub, parser):
     parsed = parser.parse_args(['--qt-flag', 'foo'])
     config_stub.val.qt.args = ['bar']
     assert configinit.qt_args(parsed) == [sys.argv[0], '--foo', '--bar']
Exemplo n.º 14
0
 def test_qt_args(self, config_stub, args, expected, parser):
     """Test commandline with no Qt arguments given."""
     parsed = parser.parse_args(args)
     assert configinit.qt_args(parsed) == expected