BDD: Wait until hints are ready after hinting

With QtWebEngine, hinting happens async, so we need to wait for
"hints: ..." in the log before we can actually follow a hint.
This commit is contained in:
Florian Bruhin 2016-08-18 17:21:50 +02:00
parent d7110069bb
commit 745614e45d
7 changed files with 73 additions and 87 deletions

View File

@ -309,6 +309,20 @@ def fill_clipboard_multiline(quteproc, httpbin, what, content):
fill_clipboard(quteproc, httpbin, what, textwrap.dedent(content))
@bdd.when(bdd.parsers.parse('I hint with args "{args}"'))
def hint(quteproc, args):
quteproc.send_cmd(':hint {}'.format(args))
quteproc.wait_for(message='hints: *')
@bdd.when(bdd.parsers.parse('I hint with args "{args}" and follow {letter}'))
def hint_and_follow(quteproc, args, letter):
args = args.replace('(testdata)', utils.abs_datapath())
quteproc.send_cmd(':hint {}'.format(args))
quteproc.wait_for(message='hints: *')
quteproc.send_cmd(':follow-hint {}'.format(letter))
## Then

View File

@ -7,8 +7,7 @@ Feature: Downloading things from a website.
Scenario: Downloading which redirects with closed tab (issue 889)
When I set tabs -> last-close to blank
And I open data/downloads/issue889.html
And I run :hint links download
And I run :follow-hint a
And I hint with args "links download" and follow a
And I run :tab-close
And I wait for "* Handling redirect" in the log
Then no crash should happen
@ -16,8 +15,7 @@ Feature: Downloading things from a website.
Scenario: Downloading with error in closed tab (issue 889)
When I set tabs -> last-close to blank
And I open data/downloads/issue889.html
And I run :hint links download
And I run :follow-hint s
And I hint with args "links download" and follow s
And I run :tab-close
And I wait for the error "Download error: * - server replied: NOT FOUND"
And I run :download-retry
@ -28,8 +26,7 @@ Feature: Downloading things from a website.
When I set completion -> download-path-suggestion to filename
And I set storage -> prompt-download-directory to true
And I open data/downloads/issue1243.html
And I run :hint links download
And I run :follow-hint a
And I hint with args "links download" and follow a
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='qutebrowser-download' mode=<PromptMode.download: 5> text='Save file to:'>, *" in the log
Then the error "Download error: No handler found for qute://!" should be shown
@ -37,8 +34,7 @@ Feature: Downloading things from a website.
When I set completion -> download-path-suggestion to filename
And I set storage -> prompt-download-directory to true
And I open data/downloads/issue1214.html
And I run :hint links download
And I run :follow-hint a
And I hint with args "links download" and follow a
And I wait for "Asking question <qutebrowser.utils.usertypes.Question default='binary blob' mode=<PromptMode.download: 5> text='Save file to:'>, *" in the log
And I run :leave-mode
Then no crash should happen

View File

@ -6,24 +6,21 @@ Feature: Using hints
Scenario: Using :follow-hint with an invalid index.
When I open data/hints/html/simple.html
And I run :hint links normal
And I run :follow-hint xyz
And I hint with args "links normal" and follow xyz
Then the error "No hint xyz!" should be shown
### Opening in current or new tab
Scenario: Following a hint and force to open in current tab.
When I open data/hints/link_blank.html
And I run :hint links current
And I run :follow-hint a
And I hint with args "links current" and follow a
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/hello.txt (active)
Scenario: Following a hint and allow to open in new tab.
When I open data/hints/link_blank.html
And I run :hint links normal
And I run :follow-hint a
And I hint with args "links normal" and follow a
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/hints/link_blank.html
@ -32,74 +29,65 @@ Feature: Using hints
Scenario: Following a hint to link with sub-element and force to open in current tab.
When I open data/hints/link_span.html
And I run :tab-close
And I run :hint links current
And I run :follow-hint a
And I hint with args "links current" and follow a
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/hello.txt (active)
Scenario: Entering and leaving hinting mode (issue 1464)
When I open data/hints/html/simple.html
And I run :hint
And I hint with args "all"
And I run :fake-key -g <Esc>
Then no crash should happen
Scenario: Using :hint spawn with flags and -- (issue 797)
When I open data/hints/html/simple.html
And I run :hint -- all spawn -v echo
And I run :follow-hint a
And I hint with args "-- all spawn -v echo" and follow a
Then the message "Command exited successfully." should be shown
Scenario: Using :hint spawn with flags (issue 797)
When I open data/hints/html/simple.html
And I run :hint all spawn -v echo
And I run :follow-hint a
And I hint with args "all spawn -v echo" and follow a
Then the message "Command exited successfully." should be shown
Scenario: Using :hint spawn with flags and --rapid (issue 797)
When I open data/hints/html/simple.html
And I run :hint --rapid all spawn -v echo
And I run :follow-hint a
And I hint with args "--rapid all spawn -v echo" and follow a
Then the message "Command exited successfully." should be shown
@posix
Scenario: Using :hint spawn with flags passed to the command (issue 797)
When I open data/hints/html/simple.html
And I run :hint --rapid all spawn -v echo -e foo
And I run :follow-hint a
And I hint with args "--rapid all spawn -v echo -e foo" and follow a
Then the message "Command exited successfully." should be shown
Scenario: Using :hint run
When I open data/hints/html/simple.html
And I run :hint all run message-info {hint-url}
And I run :follow-hint a
And I hint with args "all run message-info {hint-url}" and follow a
Then the message "http://localhost:(port)/data/hello.txt" should be shown
Scenario: Using :hint fill
When I open data/hints/html/simple.html
And I run :hint all fill :message-info {hint-url}
And I run :follow-hint a
And I hint with args "all fill :message-info {hint-url}" and follow a
And I press the key "<Enter>"
Then the message "http://localhost:(port)/data/hello.txt" should be shown
@posix
Scenario: Using :hint userscript
When I open data/hints/html/simple.html
And I run :hint all userscript (testdata)/userscripts/echo_hint_text
And I run :follow-hint a
And I hint with args "all userscript (testdata)/userscripts/echo_hint_text" and follow a
Then the message "Follow me!" should be shown
Scenario: Yanking to primary selection without it being supported (#1336)
When selection is not supported
And I run :debug-set-fake-clipboard
And I open data/hints/html/simple.html
And I run :hint links yank-primary
And I run :follow-hint a
And I hint with args "links yank-primary" and follow a
Then the clipboard should contain "http://localhost:(port)/data/hello.txt"
Scenario: Using hint --rapid to hit multiple buttons
When I open data/hints/buttons.html
And I run :hint --rapid
And I hint with args "--rapid"
And I run :follow-hint s
And I run :follow-hint d
And I run :follow-hint f
@ -109,20 +97,17 @@ Feature: Using hints
Scenario: Using :hint run with a URL containing spaces
When I open data/hints/html/with_spaces.html
And I run :hint all run message-info {hint-url}
And I run :follow-hint a
And I hint with args "all run message-info {hint-url}" and follow a
Then the message "http://localhost:(port)/data/hello.txt" should be shown
Scenario: Clicking an invalid link
When I open data/invalid_link.html
And I run :hint all
And I run :follow-hint a
And I hint with args "all" and follow a
Then the error "Invalid link clicked - *" should be shown
Scenario: Hinting inputs without type
When I open data/hints/input.html
And I run :hint inputs
And I run :follow-hint a
And I hint with args "inputs" and follow a
And I wait for "Entering mode KeyMode.insert (reason: click)" in the log
And I run :leave-mode
# The actual check is already done above
@ -132,31 +117,26 @@ Feature: Using hints
Scenario: Using :follow-hint inside an iframe
When I open data/hints/iframe.html
And I run :hint links normal
And I run :follow-hint a
And I hint with args "links normal" and follow a
Then "navigation request: url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged
### FIXME currenly skipped, see https://github.com/The-Compiler/qutebrowser/issues/1525
@xfail_norun
Scenario: Using :follow-hint inside a scrolled iframe
When I open data/hints/iframe_scroll.html
And I run :hint all normal
And I run :follow-hint a
And I hint with args "all normal" and follow a
And I run :scroll bottom
And I run :hint links normal
And I run :follow-hint a
And I hint wht args "links normal" and follow a
Then "navigation request: url http://localhost:*/data/hello2.txt, type NavigationTypeLinkClicked, *" should be logged
Scenario: Opening a link inside a specific iframe
When I open data/hints/iframe_target.html
And I run :hint links normal
And I run :follow-hint a
And I hint with args "links normal" and follow a
Then "navigation request: url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged
Scenario: Opening a link with specific target frame in a new tab
When I open data/hints/iframe_target.html
And I run :hint links tab
And I run :follow-hint a
And I hint with args "links tab" and follow a
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/hints/iframe_target.html
@ -169,7 +149,7 @@ Feature: Using hints
And I set hints -> mode to number
And I run :bind --force , message-error "This should not happen"
And I open data/hints/html/simple.html
And I run :hint all
And I hint with args "all"
And I press the key "f"
And I wait until data/hello.txt is loaded
And I press the key ","
@ -182,7 +162,7 @@ Feature: Using hints
And I set hints -> mode to number
And I run :bind --force , message-info "Keypress worked!"
And I open data/hints/html/simple.html
And I run :hint all
And I hint with args "all"
And I press the key "f"
And I wait until data/hello.txt is loaded
And I press the key ","
@ -193,9 +173,8 @@ Feature: Using hints
Scenario: Hinting with a too short dictionary
When I open data/hints/short_dict.html
And I set hints -> mode to word
And I run :hint
# Test letter fallback
And I run :follow-hint d
And I hint with args "all" and follow d
Then the error "Not enough words in the dictionary." should be shown
And data/numbers/5.txt should be loaded
@ -205,7 +184,7 @@ Feature: Using hints
Scenario: Renumbering hints when filtering
When I open data/hints/number.html
And I set hints -> mode to number
And I run :hint all
And I hint with args "all"
And I press the key "s"
And I run :follow-hint 1
Then data/numbers/7.txt should be loaded
@ -214,7 +193,7 @@ Feature: Using hints
Scenario: Keeping hint filter in rapid mode
When I open data/hints/number.html
And I set hints -> mode to number
And I run :hint all tab-bg --rapid
And I hint with args "all tab-bg --rapid"
And I press the key "t"
And I run :follow-hint 0
And I run :follow-hint 1
@ -225,7 +204,7 @@ Feature: Using hints
Scenario: Keeping hints filter when using backspace
When I open data/hints/issue1186.html
And I set hints -> mode to number
And I run :hint all
And I hint with args "all"
And I press the key "x"
And I press the key "0"
And I press the key "<Backspace>"
@ -238,7 +217,7 @@ Feature: Using hints
And I set hints -> mode to number
And I set hints -> auto-follow to unique-match
And I set hints -> auto-follow-timeout to 0
And I run :hint all
And I hint with args "all"
And I press the keys "ten pos"
Then data/numbers/11.txt should be loaded
@ -246,15 +225,14 @@ Feature: Using hints
When I open data/hints/number.html
And I set hints -> mode to number
And I set hints -> scatter to true
And I run :hint all
And I run :follow-hint 00
And I hint with args "all" and follow 00
Then data/numbers/1.txt should be loaded
# https://github.com/The-Compiler/qutebrowser/issues/1559
Scenario: Filtering all hints in number mode
When I open data/hints/number.html
And I set hints -> mode to number
And I run :hint all
And I hint with args "all"
And I press the key "2"
And I wait for "Leaving mode KeyMode.hint (reason: all filtered)" in the log
Then no crash should happen
@ -263,16 +241,15 @@ Feature: Using hints
Scenario: Using rapid number hinting twice
When I open data/hints/number.html
And I set hints -> mode to number
And I run :hint --rapid
And I hint with args "--rapid"
And I run :leave-mode
And I run :hint --rapid
And I run :follow-hint 00
And I hint with args "--rapid" and follow 00
Then data/numbers/1.txt should be loaded
Scenario: Using a specific hints mode
When I open data/hints/number.html
And I set hints -> mode to letter
And I run :hint --mode number all
And I hint with args "--mode number all"
And I press the key "s"
And I run :follow-hint 1
Then data/numbers/7.txt should be loaded
@ -283,7 +260,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to letter
And I set hints -> auto-follow to always
And I run :hint
And I hint with args "all"
Then data/hello.txt should be loaded
# unique-match is actually the same as full-match in letter mode
@ -291,7 +268,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to letter
And I set hints -> auto-follow to unique-match
And I run :hint
And I hint with args "all"
And I press the key "a"
Then data/hello.txt should be loaded
@ -299,7 +276,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to letter
And I set hints -> auto-follow to full-match
And I run :hint
And I hint with args "all"
And I press the key "a"
Then data/hello.txt should be loaded
@ -307,7 +284,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to letter
And I set hints -> auto-follow to never
And I run :hint
And I hint with args "all"
And I press the key "a"
Then "Leaving mode KeyMode.hint (reason: followed)" should not be logged
@ -315,7 +292,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to letter
And I set hints -> auto-follow to never
And I run :hint
And I hint with args "all"
And I press the key "a"
And I press the key "<Enter>"
Then data/hello.txt should be loaded
@ -324,14 +301,14 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to number
And I set hints -> auto-follow to always
And I run :hint
And I hint with args "all"
Then data/hello.txt should be loaded
Scenario: Using hints -> auto-follow == 'unique-match' in number mode
When I open data/hints/html/simple.html
And I set hints -> mode to number
And I set hints -> auto-follow to unique-match
And I run :hint
And I hint with args "all"
And I press the key "f"
Then data/hello.txt should be loaded
@ -339,7 +316,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to number
And I set hints -> auto-follow to full-match
And I run :hint
And I hint with args "all"
# this actually presses the keys one by one
And I press the key "follow me!"
Then data/hello.txt should be loaded
@ -348,7 +325,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to number
And I set hints -> auto-follow to never
And I run :hint
And I hint with args "all"
# this actually presses the keys one by one
And I press the key "follow me!"
Then "Leaving mode KeyMode.hint (reason: followed)" should not be logged
@ -357,7 +334,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to number
And I set hints -> auto-follow to never
And I run :hint
And I hint with args "all"
# this actually presses the keys one by one
And I press the key "follow me!"
And I press the key "<Enter>"
@ -367,14 +344,14 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to word
And I set hints -> auto-follow to always
And I run :hint
And I hint with args "all"
Then data/hello.txt should be loaded
Scenario: Using hints -> auto-follow == 'unique-match' in word mode
When I open data/hints/html/simple.html
And I set hints -> mode to word
And I set hints -> auto-follow to unique-match
And I run :hint
And I hint with args "all"
# the link gets "hello" as the hint
And I press the key "h"
Then data/hello.txt should be loaded
@ -383,7 +360,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to word
And I set hints -> auto-follow to full-match
And I run :hint
And I hint with args "all"
# this actually presses the keys one by one
And I press the key "hello"
Then data/hello.txt should be loaded
@ -392,7 +369,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to word
And I set hints -> auto-follow to never
And I run :hint
And I hint with args "all"
# this actually presses the keys one by one
And I press the key "hello"
Then "Leaving mode KeyMode.hint (reason: followed)" should not be logged
@ -401,7 +378,7 @@ Feature: Using hints
When I open data/hints/html/simple.html
And I set hints -> mode to word
And I set hints -> auto-follow to never
And I run :hint
And I hint with args "all"
# this actually presses the keys one by one
And I press the key "hello"
And I press the key "<Enter>"

View File

@ -65,8 +65,7 @@ Feature: Setting positional marks
Then the page should be scrolled to 10 10
Scenario: Jumping back after following a link
When I run :hint links normal
And I run :follow-hint s
When I hint with args "links normal" and follow s
And I wait until data/marks.html#bottom is loaded
And I run :jump-mark "'"
Then the page should be scrolled to 0 0
@ -86,7 +85,6 @@ Feature: Setting positional marks
Scenario: Hovering a hint does not set the ' mark
When I run :scroll-px 30 20
And I run :scroll-perc 0
And I run :hint links hover
And I run :follow-hint s
And I hint with args "links hover" and follow s
And I run :jump-mark "'"
Then the page should be scrolled to 30 20

View File

@ -515,7 +515,7 @@ Feature: Various utility commands.
Scenario: :repeat-command with mode-switching command
Given I open data/hints/link_blank.html
And I run :tab-only
When I run :hint
When I hint with args "all"
And I run :leave-mode
And I run :repeat-command
And I run :follow-hint a

View File

@ -794,8 +794,7 @@ Feature: Tab management
Scenario: opening links with tabs->background-tabs true
When I set tabs -> background-tabs to true
And I open data/hints/html/simple.html
And I run :hint all tab
And I run :follow-hint a
And I hint with args "all tab" and follow a
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/hints/html/simple.html (active)

View File

@ -52,6 +52,7 @@ def test_insert_mode(file_name, elem_id, source, input_text, auto_insert,
quteproc.send_cmd(':insert-text {clipboard}')
quteproc.send_cmd(':hint all')
quteproc.wait_for(message='hints: *')
quteproc.send_cmd(':follow-hint a')
quteproc.wait_for(message='Clicked editable element!')
quteproc.send_cmd(':enter-mode caret')
@ -76,6 +77,7 @@ def test_auto_leave_insert_mode(quteproc):
quteproc.press_keys('abcd')
quteproc.send_cmd(':hint all')
quteproc.wait_for(message='hints: *')
# Select the disabled input box to leave insert mode
quteproc.send_cmd(':follow-hint s')