From 9799c30c2b84bb018916212ac051e65b19b76c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Mon, 15 Feb 2016 23:31:49 +0100 Subject: [PATCH] hints: add precision tests for different zoom levels --- qutebrowser/browser/hints.py | 10 ++++++++-- tests/integration/data/hints/link.html | 7 +++++++ tests/integration/features/hints.feature | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 12cd16651..e3619110d 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -472,9 +472,15 @@ class HintManager(QObject): rect = self._get_first_rectangle(elem) pos = rect.center() + # fix coordinates according to zoom level + zoom = elem.webFrame().zoomFactor() + if not config.get('ui', 'zoom-text-only'): + pos.setX(pos.x() * zoom) + pos.setY(pos.y() * zoom) + action = "Hovering" if context.target == Target.hover else "Clicking" - log.hints.debug("{} on '{}' at position {}".format( - action, elem.debug_text(), pos)) + log.hints.debug("{} on '{}' at position {} (zoom = {})".format( + action, elem.debug_text(), pos, zoom)) self.start_hinting.emit(target_mapping[context.target]) if context.target in [Target.tab, Target.tab_fg, Target.tab_bg, diff --git a/tests/integration/data/hints/link.html b/tests/integration/data/hints/link.html index 2dc96b280..8075cc821 100644 --- a/tests/integration/data/hints/link.html +++ b/tests/integration/data/hints/link.html @@ -50,5 +50,12 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +
+

Test precision with different zoom levels:

+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +
+
diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index 15b694945..c8cc8b77d 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -41,3 +41,21 @@ Feature: Using hints And I run :hint links normal And I run :follow-hint g Then data/hello.txt should be loaded + + Scenario: Following a link with zoom 125%. + When I open data/hints/link.html + And I run :zoom 125 + And I run :hint links normal + And I run :follow-hint h + And I run :zoom 100 + Then data/hello.txt should be loaded + + Scenario: Following a link with zoom 125% and zoom-text-only == True. + When I open data/hints/link.html + And I run :set ui zoom-text-only true + And I run :zoom 125 + And I run :hint links normal + And I run :follow-hint h + And I run :zoom 100 + And I run :set ui zoom-text-only false + Then data/hello.txt should be loaded