diff --git a/qutebrowser/browser/tab.py b/qutebrowser/browser/tab.py index b5492b0d2..c8d2279b8 100644 --- a/qutebrowser/browser/tab.py +++ b/qutebrowser/browser/tab.py @@ -21,10 +21,12 @@ import itertools -from PyQt5.QtCore import pyqtSignal +from PyQt5.QtCore import pyqtSignal, QUrl from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QWidget, QLayout +from qutebrowser.utils import utils + tab_id_gen = itertools.count(0) @@ -111,3 +113,8 @@ class AbstractTab(QWidget): def openurl(self, url): raise NotImplementedError + + def __repr__(self): + url = utils.elide(self.cur_url.toDisplayString(QUrl.EncodeUnicode), + 100) + return utils.get_repr(self, tab_id=self.tab_id, url=url) diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index b209dfb94..33531fe90 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -202,21 +202,22 @@ class QuteProc(testprocess.Process): self._log(log_line) start_okay_message_load = ( - "load status for : LoadStatus.success") + "load status for : LoadStatus.success") start_okay_message_focus = ( "Focus object changed: " - "") + "") if (log_line.category == 'ipc' and log_line.message.startswith("Listening as ")): self._ipc_socket = log_line.message.split(' ', maxsplit=2)[2] elif (log_line.category == 'webview' and - log_line.message == start_okay_message_load): + testutils.pattern_match(pattern=start_okay_message_load, + value=log_line.message)): self._is_ready('load') elif (log_line.category == 'misc' and - log_line.message == start_okay_message_focus): + testutils.pattern_match(pattern=start_okay_message_focus, + value=log_line.message)): self._is_ready('focus') elif (log_line.category == 'init' and log_line.module == 'standarddir' and @@ -291,8 +292,7 @@ class QuteProc(testprocess.Process): # Try to complain about the most common mistake when accidentally # loading external resources. is_ddg_load = testutils.pattern_match( - pattern="load status for : *", + pattern="load status for <* tab_id=* url='*duckduckgo*'>: *", value=msg.message) return msg.loglevel > logging.INFO or is_js_error or is_ddg_load @@ -442,8 +442,7 @@ class QuteProc(testprocess.Process): assert url pattern = re.compile( - r"(load status for " - r": LoadStatus\.{load_status}|fetch: " r"PyQt5\.QtCore\.QUrl\('{url}'\) -> .*)".format( load_status=re.escape(load_status), url=re.escape(url))) diff --git a/tests/unit/mainwindow/statusbar/test_progress.py b/tests/unit/mainwindow/statusbar/test_progress.py index b90c0814c..8a12379f3 100644 --- a/tests/unit/mainwindow/statusbar/test_progress.py +++ b/tests/unit/mainwindow/statusbar/test_progress.py @@ -24,8 +24,8 @@ from collections import namedtuple import pytest -from qutebrowser.browser.webkit import webview from qutebrowser.mainwindow.statusbar.progress import Progress +from qutebrowser.utils import usertypes @pytest.fixture @@ -60,11 +60,11 @@ Tab = namedtuple('Tab', 'progress load_status') @pytest.mark.parametrize('tab, expected_visible', [ - (Tab(15, webview.LoadStatus.loading), True), - (Tab(100, webview.LoadStatus.success), False), - (Tab(100, webview.LoadStatus.error), False), - (Tab(100, webview.LoadStatus.warn), False), - (Tab(100, webview.LoadStatus.none), False), + (Tab(15, usertypes.LoadStatus.loading), True), + (Tab(100, usertypes.LoadStatus.success), False), + (Tab(100, usertypes.LoadStatus.error), False), + (Tab(100, usertypes.LoadStatus.warn), False), + (Tab(100, usertypes.LoadStatus.none), False), ]) def test_tab_changed(progress_widget, tab, expected_visible): """Test that progress widget value and visibility state match expectations. diff --git a/tests/unit/mainwindow/statusbar/test_url.py b/tests/unit/mainwindow/statusbar/test_url.py index 67c0dea7a..31b1e4db4 100644 --- a/tests/unit/mainwindow/statusbar/test_url.py +++ b/tests/unit/mainwindow/statusbar/test_url.py @@ -23,7 +23,7 @@ import pytest import collections -from qutebrowser.browser.webkit import webview +from qutebrowser.utils import usertypes from qutebrowser.mainwindow.statusbar import url @@ -105,12 +105,12 @@ def test_set_hover_url_encoded(url_widget, url_text, expected): @pytest.mark.parametrize('status, expected', [ - (webview.LoadStatus.success, url.UrlType.success), - (webview.LoadStatus.success_https, url.UrlType.success_https), - (webview.LoadStatus.error, url.UrlType.error), - (webview.LoadStatus.warn, url.UrlType.warn), - (webview.LoadStatus.loading, url.UrlType.normal), - (webview.LoadStatus.none, url.UrlType.normal) + (usertypes.LoadStatus.success, url.UrlType.success), + (usertypes.LoadStatus.success_https, url.UrlType.success_https), + (usertypes.LoadStatus.error, url.UrlType.error), + (usertypes.LoadStatus.warn, url.UrlType.warn), + (usertypes.LoadStatus.loading, url.UrlType.normal), + (usertypes.LoadStatus.none, url.UrlType.normal) ]) def test_on_load_status_changed(url_widget, status, expected): """Test text when status is changed.""" @@ -141,15 +141,15 @@ def test_on_tab_changed(url_widget, tab_widget, load_status, url_text): @pytest.mark.parametrize('url_text, load_status, expected_status', [ - ('http://abc123.com/this/awesome/url.html', webview.LoadStatus.success, + ('http://abc123.com/this/awesome/url.html', usertypes.LoadStatus.success, url.UrlType.success), - ('https://supersecret.gov/nsa/files.txt', webview.LoadStatus.success_https, + ('https://supersecret.gov/nsa/files.txt', usertypes.LoadStatus.success_https, url.UrlType.success_https), - ('Th1$ i$ n0t @ n0rm@L uRL! P@n1c! <-->', webview.LoadStatus.error, + ('Th1$ i$ n0t @ n0rm@L uRL! P@n1c! <-->', usertypes.LoadStatus.error, url.UrlType.error), - ('http://www.qutebrowser.org/CONTRIBUTING.html', webview.LoadStatus.loading, + ('http://www.qutebrowser.org/CONTRIBUTING.html', usertypes.LoadStatus.loading, url.UrlType.normal), - ('www.whatisthisurl.com', webview.LoadStatus.warn, url.UrlType.warn) + ('www.whatisthisurl.com', usertypes.LoadStatus.warn, url.UrlType.warn) ]) def test_normal_url(url_widget, url_text, load_status, expected_status): url_widget.set_url(url_text)