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')
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
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')
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
def init(history): """Initialize the QWebHistoryInterface. Args: history: The WebHistory object. """ interface = WebHistoryInterface(history, parent=history) QWebHistoryInterface.setDefaultInterface(interface)
def init(history): """Initialize the QWebHistoryInterface. Args: history: The WebHistory object. """ interface = WebHistoryInterface(history, parent=history) QWebHistoryInterface.setDefaultInterface(interface)
def hist_interface(): entry = history.Entry(atime=0, url=QUrl('http://www.example.com/'), title='example') history_dict = {'http://www.example.com/': entry} fake_hist = FakeWebHistory(history_dict) interface = history.WebHistoryInterface(fake_hist) QWebHistoryInterface.setDefaultInterface(interface) yield QWebHistoryInterface.setDefaultInterface(None)
def init(parent=None): """Initialize the web history. Args: parent: The parent to use for WebHistory. """ history = WebHistory(parent) objreg.register("web-history", history) QWebHistoryInterface.setDefaultInterface(history)
def hist_interface(): entry = history.Entry(atime=0, url=QUrl('http://www.example.com/'), title='example') history_dict = {'http://www.example.com/': entry} fake_hist = FakeWebHistory(history_dict) interface = history.WebHistoryInterface(fake_hist) QWebHistoryInterface.setDefaultInterface(interface) yield QWebHistoryInterface.setDefaultInterface(None)
def init(parent=None): """Initialize the web history. Args: parent: The parent to use for WebHistory. """ history = WebHistory(parent) objreg.register('web-history', history) QWebHistoryInterface.setDefaultInterface(history)
def cleanup_init(self): # prevent test_init from leaking state yield if history.web_history is not None: history.web_history.setParent(None) history.web_history = None try: from PyQt5.QtWebKit import QWebHistoryInterface QWebHistoryInterface.setDefaultInterface(None) except ImportError: pass
def init(parent=None): """Initialize the web history. Args: parent: The parent to use for WebHistory. """ history = WebHistory(hist_dir=standarddir.data(), hist_name='history', parent=parent) objreg.register('web-history', history) interface = WebHistoryInterface(history, parent=history) QWebHistoryInterface.setDefaultInterface(interface)
def init(parent=None): """Initialize the web history. Args: parent: The parent to use for WebHistory. """ history = WebHistory(hist_dir=standarddir.data(), hist_name='history', parent=parent) objreg.register('web-history', history) interface = WebHistoryInterface(history, parent=history) QWebHistoryInterface.setDefaultInterface(interface)
def cleanup_init(): # prevent test_init from leaking state yield hist = objreg.get('web-history', None) if hist is not None: hist.setParent(None) objreg.delete('web-history') try: from PyQt5.QtWebKit import QWebHistoryInterface QWebHistoryInterface.setDefaultInterface(None) except ImportError: pass
def cleanup_init(self): # prevent test_init from leaking state yield web_history = objreg.get('web-history', None) if web_history is not None: web_history.setParent(None) objreg.delete('web-history') try: from PyQt5.QtWebKit import QWebHistoryInterface QWebHistoryInterface.setDefaultInterface(None) except ImportError: pass
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))
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))
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
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')
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))
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))
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')
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')
def init(): """Initialize the web history.""" history = WebHistory() objreg.register('web-history', history) QWebHistoryInterface.setDefaultInterface(history)