bdd: Fix scrolling tests with QtWebEngine

Scrolling happens async with QtWebEngine, so we add a new log output
when the page was scrolled, and wait for that in various places.
This commit is contained in:
Florian Bruhin 2016-09-06 14:58:33 +02:00
parent f6392d730f
commit 85b3d08c66
6 changed files with 84 additions and 5 deletions

View File

@ -325,6 +325,12 @@ class AbstractScroller(QObject):
super().__init__(parent) super().__init__(parent)
self._tab = tab self._tab = tab
self._widget = None self._widget = None
self.perc_changed.connect(self._log_scroll_pos_change)
@pyqtSlot()
def _log_scroll_pos_change(self):
log.webview.vdebug("Scroll position changed to {}".format(
self.pos_px()))
def _init_widget(self, widget): def _init_widget(self, widget):
self._widget = widget self._widget = widget

View File

@ -526,6 +526,7 @@ def _get_scroll_values(quteproc):
@bdd.then(bdd.parsers.re(r"the page should be scrolled " @bdd.then(bdd.parsers.re(r"the page should be scrolled "
r"(?P<direction>horizontally|vertically)")) r"(?P<direction>horizontally|vertically)"))
def check_scrolled(request, quteproc, direction): def check_scrolled(request, quteproc, direction):
quteproc.wait_for(message='Scroll position changed to *')
x, y = _get_scroll_values(quteproc) x, y = _get_scroll_values(quteproc)
if direction == 'horizontally': if direction == 'horizontally':
assert x != 0 assert x != 0

View File

@ -8,40 +8,55 @@ Feature: Setting positional marks
Scenario: Setting and jumping to a local mark Scenario: Setting and jumping to a local mark
When I run :scroll-px 5 10 When I run :scroll-px 5 10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 10)" in the log
And I run :set-mark a And I run :set-mark a
And I run :scroll-px 0 20 And I run :scroll-px 0 20
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 30)" in the log
And I run :jump-mark a And I run :jump-mark a
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 10)" in the log
Then the page should be scrolled to 5 10 Then the page should be scrolled to 5 10
Scenario: Jumping back after jumping to a particular percentage Scenario: Jumping back after jumping to a particular percentage
When I run :scroll-px 10 20 When I run :scroll-px 10 20
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(10, 20)" in the log
And I run :scroll-perc 100 And I run :scroll-perc 100
And I wait for "Scroll position changed to *" in the log
And I run :jump-mark "'" And I run :jump-mark "'"
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(10, 20)" in the log
Then the page should be scrolled to 10 20 Then the page should be scrolled to 10 20
Scenario: Setting the same local mark on another page Scenario: Setting the same local mark on another page
When I run :scroll-px 5 10 When I run :scroll-px 5 10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 10)" in the log
And I run :set-mark a And I run :set-mark a
And I open data/marks.html And I open data/marks.html
And I run :scroll-px 0 20 And I run :scroll-px 0 20
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(0, 20)" in the log
And I run :set-mark a And I run :set-mark a
And I run :jump-mark a And I run :jump-mark a
Then the page should be scrolled to 0 20 Then the page should be scrolled to 0 20
Scenario: Jumping to a local mark after returning to a page Scenario: Jumping to a local mark after returning to a page
When I run :scroll-px 5 10 When I run :scroll-px 5 10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 10)" in the log
And I run :set-mark a And I run :set-mark a
And I run :scroll-px 0 20
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 30)" in the log
And I open data/numbers/1.txt And I open data/numbers/1.txt
And I run :set-mark a And I run :set-mark a
And I open data/marks.html And I open data/marks.html
And I run :jump-mark a And I run :jump-mark a
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 10)" in the log
Then the page should be scrolled to 5 10 Then the page should be scrolled to 5 10
Scenario: Setting and jumping to a global mark Scenario: Setting and jumping to a global mark
When I run :scroll-px 5 20 When I run :scroll-px 5 20
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 20)" in the log
And I run :set-mark A And I run :set-mark A
And I open data/numbers/1.txt And I open data/numbers/1.txt
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
And I run :jump-mark A And I run :jump-mark A
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(5, 20)" in the log
Then data/marks.html should be loaded Then data/marks.html should be loaded
And the page should be scrolled to 5 20 And the page should be scrolled to 5 20
@ -59,10 +74,13 @@ Feature: Setting positional marks
Scenario: Jumping to a local mark after changing fragments Scenario: Jumping to a local mark after changing fragments
When I open data/marks.html#top When I open data/marks.html#top
And I run :scroll 'top' And I run :scroll 'top'
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
And I run :scroll-px 10 10 And I run :scroll-px 10 10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(10, 10)" in the log
And I run :set-mark a And I run :set-mark a
When I open data/marks.html#bottom When I open data/marks.html#bottom
And I run :jump-mark a And I run :jump-mark a
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(10, 10)" in the log
Then the page should be scrolled to 10 10 Then the page should be scrolled to 10 10
@qtwebengine_todo: Does not emit loaded signal for fragments? @qtwebengine_todo: Does not emit loaded signal for fragments?
@ -70,23 +88,32 @@ Feature: Setting positional marks
When I hint with args "links normal" and follow s When I hint with args "links normal" and follow s
And I wait until data/marks.html#bottom is loaded And I wait until data/marks.html#bottom is loaded
And I run :jump-mark "'" And I run :jump-mark "'"
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should be scrolled to 0 0 Then the page should be scrolled to 0 0
Scenario: Jumping back after searching Scenario: Jumping back after searching
When I run :scroll-px 20 15 When I run :scroll-px 20 15
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(20, 15)" in the log
And I run :search Waldo And I run :search Waldo
And I wait for "Scroll position changed to *" in the log
And I run :jump-mark "'" And I run :jump-mark "'"
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(20, 15)" in the log
Then the page should be scrolled to 20 15 Then the page should be scrolled to 20 15
Scenario: Jumping back after search-next Scenario: Jumping back after search-next
When I run :search Grail When I run :search Grail
And I run :search-next And I run :search-next
And I wait for "Scroll position changed to *" in the log
And I run :jump-mark "'" And I run :jump-mark "'"
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should be scrolled to 0 0 Then the page should be scrolled to 0 0
Scenario: Hovering a hint does not set the ' mark Scenario: Hovering a hint does not set the ' mark
When I run :scroll-px 30 20 When I run :scroll-px 30 20
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(30, 20)" in the log
And I run :scroll-perc 0 And I run :scroll-perc 0
And I wait for "Scroll position changed to *" in the log
And I hint with args "links hover" and follow s And I hint with args "links hover" and follow s
And I run :jump-mark "'" And I run :jump-mark "'"
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(30, 20)" in the log
Then the page should be scrolled to 30 20 Then the page should be scrolled to 30 20

View File

@ -537,15 +537,20 @@ Feature: Various utility commands.
Given I open data/scroll/simple.html Given I open data/scroll/simple.html
And I run :tab-only And I run :tab-only
When I run :scroll down with count 3 When I run :scroll down with count 3
And I wait for "Scroll position changed to *" in the log
And I run :scroll up And I run :scroll up
And I wait for "Scroll position changed to *" in the log
And I run :repeat-command with count 2 And I run :repeat-command with count 2
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: :repeat-command with not-normal command inbetween Scenario: :repeat-command with not-normal command inbetween
Given I open data/scroll/simple.html Given I open data/scroll/simple.html
And I run :tab-only And I run :tab-only
When I run :scroll down with count 3 When I run :scroll down with count 3
And I wait for "Scroll position changed to *" in the log
And I run :scroll up And I run :scroll up
And I wait for "Scroll position changed to *" in the log
And I run :prompt-accept And I run :prompt-accept
And I run :repeat-command with count 2 And I run :repeat-command with count 2
Then the page should not be scrolled Then the page should not be scrolled

View File

@ -17,24 +17,32 @@ Feature: Scrolling
Scenario: Scrolling down and up Scenario: Scrolling down and up
When I run :scroll-px 10 0 When I run :scroll-px 10 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(10, 0)" in the log
And I run :scroll-px -10 0 And I run :scroll-px -10 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling right and left Scenario: Scrolling right and left
When I run :scroll-px 0 10 When I run :scroll-px 0 10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(0, 10)" in the log
And I run :scroll-px 0 -10 And I run :scroll-px 0 -10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling down and up with count Scenario: Scrolling down and up with count
When I run :scroll-px 0 10 with count 2 When I run :scroll-px 0 10 with count 2
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(0, 20)" in the log
When I run :scroll-px 0 -10 When I run :scroll-px 0 -10
When I run :scroll-px 0 -10 When I run :scroll-px 0 -10
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling left and right with count Scenario: Scrolling left and right with count
When I run :scroll-px 10 0 with count 2 When I run :scroll-px 10 0 with count 2
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint(20, 0)" in the log
When I run :scroll-px -10 0 When I run :scroll-px -10 0
When I run :scroll-px -10 0 When I run :scroll-px -10 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: :scroll-px with a very big value Scenario: :scroll-px with a very big value
@ -44,7 +52,7 @@ Feature: Scrolling
Scenario: :scroll-px on a page without scrolling Scenario: :scroll-px on a page without scrolling
When I open data/hello.txt When I open data/hello.txt
And I run :scroll-px 10 10 And I run :scroll-px 10 10
Then no crash should happen Then the page should not be scrolled
Scenario: :scroll-px with floats Scenario: :scroll-px with floats
# This used to be allowed, but doesn't make much sense. # This used to be allowed, but doesn't make much sense.
@ -60,7 +68,9 @@ Feature: Scrolling
Scenario: Scrolling down and up Scenario: Scrolling down and up
When I run :scroll down When I run :scroll down
And I wait for "Scroll position changed to *" in the log
And I run :scroll up And I run :scroll up
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling right Scenario: Scrolling right
@ -69,7 +79,9 @@ Feature: Scrolling
Scenario: Scrolling right and left Scenario: Scrolling right and left
When I run :scroll right When I run :scroll right
And I wait for "Scroll position changed to *" in the log
And I run :scroll left And I run :scroll left
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
# causes segfault with postEvent instead of sendEvent # causes segfault with postEvent instead of sendEvent
@ -83,7 +95,9 @@ Feature: Scrolling
Scenario: Scrolling with page down and page up Scenario: Scrolling with page down and page up
When I run :scroll page-down When I run :scroll page-down
And I wait for "Scroll position changed to *" in the log
And I run :scroll page-up And I run :scroll page-up
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling to bottom Scenario: Scrolling to bottom
@ -92,7 +106,9 @@ Feature: Scrolling
Scenario: Scrolling to bottom and to top Scenario: Scrolling to bottom and to top
When I run :scroll bottom When I run :scroll bottom
And I wait for "Scroll position changed to *" in the log
And I run :scroll top And I run :scroll top
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: :scroll with invalid argument Scenario: :scroll with invalid argument
@ -102,8 +118,10 @@ Feature: Scrolling
Scenario: Scrolling down and up with count Scenario: Scrolling down and up with count
When I run :scroll down with count 2 When I run :scroll down with count 2
And I wait for "Scroll position changed to *" in the log
And I run :scroll up And I run :scroll up
And I run :scroll up And I run :scroll up
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling right Scenario: Scrolling right
@ -112,13 +130,17 @@ Feature: Scrolling
Scenario: Scrolling right and left Scenario: Scrolling right and left
When I run :scroll right When I run :scroll right
And I wait for "Scroll position changed to *" in the log
And I run :scroll left And I run :scroll left
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling right and left with count Scenario: Scrolling right and left with count
When I run :scroll right with count 2 When I run :scroll right with count 2
And I wait for "Scroll position changed to *" in the log
And I run :scroll left And I run :scroll left
And I run :scroll left And I run :scroll left
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
@qtwebengine_skip: Causes memory leak... @qtwebengine_skip: Causes memory leak...
@ -127,11 +149,12 @@ Feature: Scrolling
# Make sure it doesn't hang # Make sure it doesn't hang
And I run :message-info "Still alive!" And I run :message-info "Still alive!"
Then the message "Still alive!" should be shown Then the message "Still alive!" should be shown
And "Scroll position changed to *" should be logged
Scenario: :scroll on a page without scrolling Scenario: :scroll on a page without scrolling
When I open data/hello.txt When I open data/hello.txt
And I run :scroll down And I run :scroll down
Then no crash should happen Then the page should not be scrolled
## :scroll-perc ## :scroll-perc
@ -141,7 +164,9 @@ Feature: Scrolling
Scenario: Scrolling to bottom and to top with :scroll-perc Scenario: Scrolling to bottom and to top with :scroll-perc
When I run :scroll-perc 100 When I run :scroll-perc 100
And I wait for "Scroll position changed to *" in the log
And I run :scroll-perc 0 And I run :scroll-perc 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling to middle with :scroll-perc Scenario: Scrolling to middle with :scroll-perc
@ -154,7 +179,9 @@ Feature: Scrolling
Scenario: Scrolling to middle and to top with :scroll-perc Scenario: Scrolling to middle and to top with :scroll-perc
When I run :scroll-perc 50 When I run :scroll-perc 50
And I wait for "Scroll position changed to *" in the log
And I run :scroll-perc 0 And I run :scroll-perc 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling to right with :scroll-perc Scenario: Scrolling to right with :scroll-perc
@ -163,7 +190,9 @@ Feature: Scrolling
Scenario: Scrolling to right and to left with :scroll-perc Scenario: Scrolling to right and to left with :scroll-perc
When I run :scroll-perc --horizontal 100 When I run :scroll-perc --horizontal 100
And I wait for "Scroll position changed to *" in the log
And I run :scroll-perc --horizontal 0 And I run :scroll-perc --horizontal 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling to middle (horizontally) with :scroll-perc Scenario: Scrolling to middle (horizontally) with :scroll-perc
@ -172,7 +201,9 @@ Feature: Scrolling
Scenario: Scrolling to middle and to left with :scroll-perc Scenario: Scrolling to middle and to left with :scroll-perc
When I run :scroll-perc --horizontal 50 When I run :scroll-perc --horizontal 50
And I wait for "Scroll position changed to *" in the log
And I run :scroll-perc --horizontal 0 And I run :scroll-perc --horizontal 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: :scroll-perc without argument Scenario: :scroll-perc without argument
@ -195,7 +226,7 @@ Feature: Scrolling
Scenario: :scroll-perc on a page without scrolling Scenario: :scroll-perc on a page without scrolling
When I open data/hello.txt When I open data/hello.txt
And I run :scroll-perc 20 And I run :scroll-perc 20
Then no crash should happen Then the page should not be scrolled
Scenario: :scroll-perc with count and argument Scenario: :scroll-perc with count and argument
When I run :scroll-perc 0 with count 50 When I run :scroll-perc 0 with count 50
@ -219,7 +250,9 @@ Feature: Scrolling
Scenario: Scrolling down and up with :scroll-page Scenario: Scrolling down and up with :scroll-page
When I run :scroll-page 0 1 When I run :scroll-page 0 1
And I wait for "Scroll position changed to *" in the log
And I run :scroll-page 0 -1 And I run :scroll-page 0 -1
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling right with :scroll-page Scenario: Scrolling right with :scroll-page
@ -232,18 +265,24 @@ Feature: Scrolling
Scenario: Scrolling right and left with :scroll-page Scenario: Scrolling right and left with :scroll-page
When I run :scroll-page 1 0 When I run :scroll-page 1 0
And I wait for "Scroll position changed to *" in the log
And I run :scroll-page -1 0 And I run :scroll-page -1 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
Scenario: Scrolling right and left with :scroll-page and count Scenario: Scrolling right and left with :scroll-page and count
When I run :scroll-page 1 0 with count 2 When I run :scroll-page 1 0 with count 2
And I wait for "Scroll position changed to *" in the log
And I run :scroll-page -1 0 And I run :scroll-page -1 0
And I wait for "Scroll position changed to *" in the log
And I run :scroll-page -1 0 And I run :scroll-page -1 0
And I wait for "Scroll position changed to PyQt5.QtCore.QPoint()" in the log
Then the page should not be scrolled Then the page should not be scrolled
@qtwebengine_todo: at_bottom is not implemented yet @qtwebengine_todo: at_bottom is not implemented yet
Scenario: :scroll-page with --bottom-navigate Scenario: :scroll-page with --bottom-navigate
When I run :scroll-perc 100 When I run :scroll-perc 100
And I wait for "Scroll position changed to *" in the log
And I run :scroll-page --bottom-navigate next 0 1 And I run :scroll-page --bottom-navigate next 0 1
Then data/hello2.txt should be loaded Then data/hello2.txt should be loaded
@ -259,4 +298,4 @@ Feature: Scrolling
Scenario: :scroll-page on a page without scrolling Scenario: :scroll-page on a page without scrolling
When I open data/hello.txt When I open data/hello.txt
And I run :scroll-page 1 1 And I run :scroll-page 1 1
Then no crash should happen Then the page should not be scrolled

View File

@ -262,7 +262,8 @@ class QuteProc(testprocess.Process):
def _default_args(self): def _default_args(self):
backend = 'webengine' if self.request.config.webengine else 'webkit' backend = 'webengine' if self.request.config.webengine else 'webkit'
return ['--debug', '--no-err-windows', '--temp-basedir', return ['--debug', '--no-err-windows', '--temp-basedir',
'--json-logging', '--backend', backend, 'about:blank'] '--json-logging', '--loglevel', 'vdebug',
'--backend', backend, 'about:blank']
def path_to_url(self, path, *, port=None, https=False): def path_to_url(self, path, *, port=None, https=False):
"""Get a URL based on a filename for the localhost webserver. """Get a URL based on a filename for the localhost webserver.