Exemplo n.º 1
0
    def test_init(self, backend, qapp, tmpdir, monkeypatch, cleanup_init):
        if backend == usertypes.Backend.QtWebKit:
            pytest.importorskip('PyQt5.QtWebKitWidgets')
        else:
            assert backend == usertypes.Backend.QtWebEngine

        monkeypatch.setattr(history.objects, 'backend', backend)
        history.init(qapp)
        hist = objreg.get('web-history')
        assert hist.parent() is qapp

        try:
            from PyQt5.QtWebKit import QWebHistoryInterface
        except ImportError:
            QWebHistoryInterface = None

        if backend == usertypes.Backend.QtWebKit:
            default_interface = QWebHistoryInterface.defaultInterface()
            assert default_interface._history is hist
        else:
            assert backend == usertypes.Backend.QtWebEngine
            if QWebHistoryInterface is None:
                default_interface = None
            else:
                default_interface = QWebHistoryInterface.defaultInterface()
            # For this to work, nothing can ever have called
            # setDefaultInterface before (so we need to test webengine before
            # webkit)
            assert default_interface is None
Exemplo n.º 2
0
def test_init(backend, qapp, tmpdir, monkeypatch, cleanup_init):
    if backend == usertypes.Backend.QtWebKit:
        pytest.importorskip('PyQt5.QtWebKitWidgets')
    else:
        assert backend == usertypes.Backend.QtWebEngine

    monkeypatch.setattr(history.objects, 'backend', backend)
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp

    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
    except ImportError:
        QWebHistoryInterface = None

    if backend == usertypes.Backend.QtWebKit:
        default_interface = QWebHistoryInterface.defaultInterface()
        assert default_interface._history is hist
    else:
        assert backend == usertypes.Backend.QtWebEngine
        if QWebHistoryInterface is None:
            default_interface = None
        else:
            default_interface = QWebHistoryInterface.defaultInterface()
        # For this to work, nothing can ever have called setDefaultInterface
        # before (so we need to test webengine before webkit)
        assert default_interface is None
Exemplo n.º 3
0
def test_init(backend, qapp, tmpdir, monkeypatch, fake_save_manager,
              fake_args):
    if backend == 'webkit':
        pytest.importorskip('PyQt5.QtWebKitWidgets')

    fake_args.backend = backend
    monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp

    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
    except ImportError:
        QWebHistoryInterface = None

    if backend == 'webkit':
        default_interface = QWebHistoryInterface.defaultInterface()
        assert default_interface._history is hist
    else:
        assert backend == 'webengine'
        if QWebHistoryInterface is None:
            default_interface = None
        else:
            default_interface = QWebHistoryInterface.defaultInterface()
        # For this to work, nothing can ever have called setDefaultInterface
        # before (so we need to test webengine before webkit)
        assert default_interface is None

    assert fake_save_manager.add_saveable.called
    objreg.delete('web-history')
Exemplo n.º 4
0
def test_init(backend, qapp, tmpdir, monkeypatch, fake_save_manager,
              fake_args):
    if backend == 'webkit':
        pytest.importorskip('PyQt5.QtWebKitWidgets')

    fake_args.backend = backend
    monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp

    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
    except ImportError:
        QWebHistoryInterface = None

    if backend == 'webkit':
        default_interface = QWebHistoryInterface.defaultInterface()
        assert default_interface._history is hist
    else:
        assert backend == 'webengine'
        if QWebHistoryInterface is None:
            default_interface = None
        else:
            default_interface = QWebHistoryInterface.defaultInterface()
        # For this to work, nothing can ever have called setDefaultInterface
        # before (so we need to test webengine before webkit)
        assert default_interface is None

    assert fake_save_manager.add_saveable.called
    objreg.delete('web-history')
Exemplo n.º 5
0
def debug_cache_stats():
    """Print LRU cache stats."""
    prefix_info = configdata.is_valid_prefix.cache_info()
    # pylint: disable=protected-access
    render_stylesheet_info = config._render_stylesheet.cache_info()
    # pylint: enable=protected-access

    history_info = None
    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
        interface = QWebHistoryInterface.defaultInterface()
        if interface is not None:
            history_info = interface.historyContains.cache_info()
    except ImportError:
        pass

    tabbed_browser = objreg.get('tabbed-browser',
                                scope='window',
                                window='last-focused')
    # pylint: disable=protected-access
    tab_bar = tabbed_browser.widget.tabBar()
    tabbed_browser_info = tab_bar._minimum_tab_size_hint_helper.cache_info()

    str_validation_info = (
        configtypes.BaseType._basic_str_validation_cache.cache_info())
    # pylint: enable=protected-access

    log.misc.info('is_valid_prefix: {}'.format(prefix_info))
    log.misc.info('_render_stylesheet: {}'.format(render_stylesheet_info))
    log.misc.info('history: {}'.format(history_info))
    log.misc.info('tab width cache: {}'.format(tabbed_browser_info))
    log.misc.info('str validation cache: {}'.format(str_validation_info))
Exemplo n.º 6
0
def debug_cache_stats():
    """Print LRU cache stats."""
    prefix_info = configdata.is_valid_prefix.cache_info()
    # pylint: disable=protected-access
    render_stylesheet_info = config._render_stylesheet.cache_info()
    # pylint: enable=protected-access

    history_info = None
    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
        interface = QWebHistoryInterface.defaultInterface()
        if interface is not None:
            history_info = interface.historyContains.cache_info()
    except ImportError:
        pass

    tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                window='last-focused')
    # pylint: disable=protected-access
    tab_bar = tabbed_browser.tabBar()
    tabbed_browser_info = tab_bar._minimum_tab_size_hint_helper.cache_info()
    # pylint: enable=protected-access

    log.misc.debug('is_valid_prefix: {}'.format(prefix_info))
    log.misc.debug('_render_stylesheet: {}'.format(render_stylesheet_info))
    log.misc.debug('history: {}'.format(history_info))
    log.misc.debug('tab width cache: {}'.format(tabbed_browser_info))
Exemplo n.º 7
0
def test_init(qapp, tmpdir, monkeypatch, fake_save_manager):
    monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp
    assert QWebHistoryInterface.defaultInterface()._history is hist
    assert fake_save_manager.add_saveable.called
Exemplo n.º 8
0
def test_init(qapp, tmpdir, monkeypatch, fake_save_manager):
    monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp
    assert QWebHistoryInterface.defaultInterface()._history is hist
    assert fake_save_manager.add_saveable.called
    objreg.delete('web-history')
Exemplo n.º 9
0
def debug_cache_stats():
    """Print LRU cache stats."""
    config_info = objreg.get('config').get.cache_info()
    style_info = style.get_stylesheet.cache_info()
    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
        interface = QWebHistoryInterface.defaultInterface()
        history_info = interface.historyContains.cache_info()
    except ImportError:
        history_info = None
    log.misc.debug('config: {}'.format(config_info))
    log.misc.debug('style: {}'.format(style_info))
    log.misc.debug('history: {}'.format(history_info))
Exemplo n.º 10
0
def debug_cache_stats():
    """Print LRU cache stats."""
    prefix_info = configdata.is_valid_prefix.cache_info()
    # pylint: disable=protected-access
    render_stylesheet_info = config._render_stylesheet.cache_info()
    try:
        from PyQt5.QtWebKit import QWebHistoryInterface
        interface = QWebHistoryInterface.defaultInterface()
        history_info = interface.historyContains.cache_info()
    except ImportError:
        history_info = None

    log.misc.debug('is_valid_prefix: {}'.format(prefix_info))
    log.misc.debug('_render_stylesheet: {}'.format(render_stylesheet_info))
    log.misc.debug('history: {}'.format(history_info))
Exemplo n.º 11
0
def test_init(backend, qapp, tmpdir, monkeypatch, fake_save_manager,
              fake_args):
    fake_args.backend = backend
    monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp
    default_interface = QWebHistoryInterface.defaultInterface()

    if backend == 'webkit':
        assert default_interface._history is hist
    else:
        assert backend == 'webengine'
        # For this to work, nothing can ever have called setDefaultInterface
        # before (so we need to test webengine before webkit)
        assert default_interface is None

    assert fake_save_manager.add_saveable.called
    objreg.delete('web-history')
Exemplo n.º 12
0
def test_init(backend, qapp, tmpdir, monkeypatch, fake_save_manager,
              fake_args):
    fake_args.backend = backend
    monkeypatch.setattr(history.standarddir, 'data', lambda: str(tmpdir))
    history.init(qapp)
    hist = objreg.get('web-history')
    assert hist.parent() is qapp
    default_interface = QWebHistoryInterface.defaultInterface()

    if backend == 'webkit':
        assert default_interface._history is hist
    else:
        assert backend == 'webengine'
        # For this to work, nothing can ever have called setDefaultInterface
        # before (so we need to test webengine before webkit)
        assert default_interface is None

    assert fake_save_manager.add_saveable.called
    objreg.delete('web-history')