Merge branch 'artur-shaik-caret_mode_windows_osx'

This commit is contained in:
Florian Bruhin 2015-12-02 06:24:42 +01:00
commit e64f64e456
5 changed files with 24 additions and 59 deletions

View File

@ -151,9 +151,9 @@ Contributors, sorted by the number of commits in descending order:
* Claude * Claude
* meles5 * meles5
* Patric Schmitz * Patric Schmitz
* Artur Shaik
* Nathan Isom * Nathan Isom
* Austin Anderson * Austin Anderson
* Artur Shaik
* Thorsten Wißmann * Thorsten Wißmann
* Alexey "Averrin" Nabrodov * Alexey "Averrin" Nabrodov
* ZDarian * ZDarian

View File

@ -11,8 +11,6 @@ markers =
not_xvfb: Tests which can't be run with Xvfb. not_xvfb: Tests which can't be run with Xvfb.
frozen: Tests which can only be run if sys.frozen is True. frozen: Tests which can only be run if sys.frozen is True.
integration: Tests which test a bigger portion of code, run without coverage. integration: Tests which test a bigger portion of code, run without coverage.
xfail_issue1142_osx: https://github.com/The-Compiler/qutebrowser/issues/1142 (OS X)
xfail_issue1142_windows: https://github.com/The-Compiler/qutebrowser/issues/1142 (Windows)
flakes-ignore = flakes-ignore =
UnusedImport UnusedImport
UnusedVariable UnusedVariable

View File

@ -21,6 +21,7 @@
import os import os
import os.path import os.path
import sys
import shlex import shlex
import posixpath import posixpath
import functools import functools
@ -1486,11 +1487,16 @@ class CommandDispatcher:
""" """
webview = self._current_widget() webview = self._current_widget()
if not webview.selection_enabled: if not webview.selection_enabled:
act = QWebPage.MoveToNextWord act = [QWebPage.MoveToNextWord]
if sys.platform == 'win32':
act.append(QWebPage.MoveToPreviousChar)
else: else:
act = QWebPage.SelectNextWord act = [QWebPage.SelectNextWord]
if sys.platform == 'win32':
act.append(QWebPage.SelectPreviousChar)
for _ in range(count): for _ in range(count):
webview.triggerPageAction(act) for a in act:
webview.triggerPageAction(a)
@cmdutils.register(instance='command-dispatcher', hide=True, @cmdutils.register(instance='command-dispatcher', hide=True,
modes=[KeyMode.caret], scope='window', count='count') modes=[KeyMode.caret], scope='window', count='count')
@ -1502,9 +1508,13 @@ class CommandDispatcher:
""" """
webview = self._current_widget() webview = self._current_widget()
if not webview.selection_enabled: if not webview.selection_enabled:
act = [QWebPage.MoveToNextWord, QWebPage.MoveToNextChar] act = [QWebPage.MoveToNextWord]
if sys.platform != 'win32':
act.append(QWebPage.MoveToNextChar)
else: else:
act = [QWebPage.SelectNextWord, QWebPage.SelectNextChar] act = [QWebPage.SelectNextWord]
if sys.platform != 'win32':
act.append(QWebPage.SelectNextChar)
for _ in range(count): for _ in range(count):
for a in act: for a in act:
webview.triggerPageAction(a) webview.triggerPageAction(a)
@ -1557,10 +1567,10 @@ class CommandDispatcher:
""" """
webview = self._current_widget() webview = self._current_widget()
if not webview.selection_enabled: if not webview.selection_enabled:
act = [QWebPage.MoveToEndOfBlock, QWebPage.MoveToNextLine, act = [QWebPage.MoveToNextLine,
QWebPage.MoveToStartOfBlock] QWebPage.MoveToStartOfBlock]
else: else:
act = [QWebPage.SelectEndOfBlock, QWebPage.SelectNextLine, act = [QWebPage.SelectNextLine,
QWebPage.SelectStartOfBlock] QWebPage.SelectStartOfBlock]
for _ in range(count): for _ in range(count):
for a in act: for a in act:
@ -1576,10 +1586,10 @@ class CommandDispatcher:
""" """
webview = self._current_widget() webview = self._current_widget()
if not webview.selection_enabled: if not webview.selection_enabled:
act = [QWebPage.MoveToStartOfBlock, QWebPage.MoveToPreviousLine, act = [QWebPage.MoveToPreviousLine,
QWebPage.MoveToStartOfBlock] QWebPage.MoveToStartOfBlock]
else: else:
act = [QWebPage.SelectStartOfBlock, QWebPage.SelectPreviousLine, act = [QWebPage.SelectPreviousLine,
QWebPage.SelectStartOfBlock] QWebPage.SelectStartOfBlock]
for _ in range(count): for _ in range(count):
for a in act: for a in act:
@ -1595,10 +1605,10 @@ class CommandDispatcher:
""" """
webview = self._current_widget() webview = self._current_widget()
if not webview.selection_enabled: if not webview.selection_enabled:
act = [QWebPage.MoveToEndOfBlock, QWebPage.MoveToNextLine, act = [QWebPage.MoveToNextLine,
QWebPage.MoveToEndOfBlock] QWebPage.MoveToEndOfBlock]
else: else:
act = [QWebPage.SelectEndOfBlock, QWebPage.SelectNextLine, act = [QWebPage.SelectNextLine,
QWebPage.SelectEndOfBlock] QWebPage.SelectEndOfBlock]
for _ in range(count): for _ in range(count):
for a in act: for a in act:
@ -1614,11 +1624,9 @@ class CommandDispatcher:
""" """
webview = self._current_widget() webview = self._current_widget()
if not webview.selection_enabled: if not webview.selection_enabled:
act = [QWebPage.MoveToStartOfBlock, QWebPage.MoveToPreviousLine, act = [QWebPage.MoveToPreviousLine, QWebPage.MoveToEndOfBlock]
QWebPage.MoveToEndOfBlock]
else: else:
act = [QWebPage.SelectStartOfBlock, QWebPage.SelectPreviousLine, act = [QWebPage.SelectPreviousLine, QWebPage.SelectEndOfBlock]
QWebPage.SelectEndOfBlock]
for _ in range(count): for _ in range(count):
for a in act: for a in act:
webview.triggerPageAction(a) webview.triggerPageAction(a)

View File

@ -18,7 +18,6 @@ Feature: Caret mode
four five six four five six
vier fünf sechs vier fünf sechs
@xfail_issue1142_windows
Scenario: Moving to end and to start of document Scenario: Moving to end and to start of document
When I run :move-to-end-of-document When I run :move-to-end-of-document
And I run :move-to-start-of-document And I run :move-to-start-of-document
@ -49,7 +48,6 @@ Feature: Caret mode
one two three one two three
eins zwei drei eins zwei drei
@xfail_issue1142_osx
Scenario: Moving back to the end of previous block (with selection) Scenario: Moving back to the end of previous block (with selection)
When I run :move-to-end-of-next-block with count 2 When I run :move-to-end-of-next-block with count 2
And I run :toggle-selection And I run :toggle-selection
@ -61,7 +59,6 @@ Feature: Caret mode
four five six four five six
@xfail_issue1142_windows
Scenario: Moving back to the end of previous block Scenario: Moving back to the end of previous block
When I run :move-to-end-of-next-block with count 2 When I run :move-to-end-of-next-block with count 2
And I run :move-to-end-of-prev-block And I run :move-to-end-of-prev-block
@ -80,7 +77,6 @@ Feature: Caret mode
four five six four five six
@xfail_issue1142_windows
Scenario: Moving back to the start of previous block Scenario: Moving back to the start of previous block
When I run :move-to-end-of-next-block with count 2 When I run :move-to-end-of-next-block with count 2
And I run :move-to-start-of-prev-block And I run :move-to-start-of-prev-block
@ -89,14 +85,12 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "eins " Then the clipboard should contain "eins "
@xfail_issue1142_osx
Scenario: Moving to the start of next block (with selection) Scenario: Moving to the start of next block (with selection)
When I run :toggle-selection When I run :toggle-selection
And I run :move-to-start-of-next-block And I run :move-to-start-of-next-block
And I yank the selected text And I yank the selected text
Then the clipboard should contain "one two three\n" Then the clipboard should contain "one two three\n"
@xfail_issue1142_windows
Scenario: Moving to the start of next block Scenario: Moving to the start of next block
When I run :move-to-start-of-next-block When I run :move-to-start-of-next-block
And I run :toggle-selection And I run :toggle-selection
@ -125,7 +119,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "one two three\n" Then the clipboard should contain "one two three\n"
@xfail_issue1142_windows
Scenario: Moving to end and to start of line Scenario: Moving to end and to start of line
When I run :move-to-end-of-line When I run :move-to-end-of-line
And I run :move-to-start-of-line And I run :move-to-start-of-line
@ -158,14 +151,12 @@ Feature: Caret mode
# word # word
@xfail_issue1142_windows
Scenario: Selecting a word Scenario: Selecting a word
When I run :toggle-selection When I run :toggle-selection
And I run :move-to-end-of-word And I run :move-to-end-of-word
And I yank the selected text And I yank the selected text
Then the clipboard should contain "one" Then the clipboard should contain "one"
@xfail_issue1142_windows
Scenario: Moving to end and selecting a word Scenario: Moving to end and selecting a word
When I run :move-to-end-of-word When I run :move-to-end-of-word
And I run :toggle-selection And I run :toggle-selection
@ -173,7 +164,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain " two" Then the clipboard should contain " two"
@xfail_issue1142_windows
Scenario: Moving to next word and selecting a word Scenario: Moving to next word and selecting a word
When I run :move-to-next-word When I run :move-to-next-word
And I run :toggle-selection And I run :toggle-selection
@ -181,7 +171,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "two" Then the clipboard should contain "two"
@xfail_issue1142_windows
Scenario: Moving to next word and selecting until next word Scenario: Moving to next word and selecting until next word
When I run :move-to-next-word When I run :move-to-next-word
And I run :toggle-selection And I run :toggle-selection
@ -189,7 +178,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "two " Then the clipboard should contain "two "
@xfail_issue1142_windows
Scenario: Moving to previous word and selecting a word Scenario: Moving to previous word and selecting a word
When I run :move-to-end-of-word When I run :move-to-end-of-word
And I run :toggle-selection And I run :toggle-selection
@ -197,7 +185,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "one" Then the clipboard should contain "one"
@xfail_issue1142_windows
Scenario: Moving to previous word Scenario: Moving to previous word
When I run :move-to-end-of-word When I run :move-to-end-of-word
And I run :move-to-prev-word And I run :move-to-prev-word
@ -221,7 +208,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "n" Then the clipboard should contain "n"
@xfail_issue1142_windows
Scenario: Selecting previous char Scenario: Selecting previous char
When I run :move-to-end-of-word When I run :move-to-end-of-word
And I run :toggle-selection And I run :toggle-selection
@ -229,7 +215,6 @@ Feature: Caret mode
And I yank the selected text And I yank the selected text
Then the clipboard should contain "e" Then the clipboard should contain "e"
@xfail_issue1142_windows
Scenario: Moving to previous char Scenario: Moving to previous char
When I run :move-to-end-of-word When I run :move-to-end-of-word
And I run :move-to-prev-char And I run :move-to-prev-char
@ -244,7 +229,6 @@ Feature: Caret mode
When I run :yank-selected When I run :yank-selected
Then the message "Nothing to yank" should be shown. Then the message "Nothing to yank" should be shown.
@xfail_issue1142_windows
Scenario: :yank-selected message Scenario: :yank-selected message
When I run :toggle-selection When I run :toggle-selection
And I run :move-to-end-of-word And I run :move-to-end-of-word
@ -265,7 +249,6 @@ Feature: Caret mode
Then the message "3 chars yanked to primary selection" should be shown. Then the message "3 chars yanked to primary selection" should be shown.
And the primary selection should contain "one" And the primary selection should contain "one"
@xfail_issue1142_windows
Scenario: :yank-selected with --keep Scenario: :yank-selected with --keep
When I run :toggle-selection When I run :toggle-selection
And I run :move-to-end-of-word And I run :move-to-end-of-word

View File

@ -19,9 +19,7 @@
"""Steps for bdd-like tests.""" """Steps for bdd-like tests."""
import os
import re import re
import sys
import time import time
import json import json
import os.path import os.path
@ -47,28 +45,6 @@ def _clipboard_mode(qapp, what):
raise AssertionError raise AssertionError
def pytest_collection_modifyitems(items):
"""Handle markers for xfail caret tests on OS X/Windows.
See https://github.com/The-Compiler/qutebrowser/issues/1142
We need to do this this way because we can't use markers with arguments
inside feature files.
"""
osx_xfail_marker = pytest.mark.xfail(
sys.platform == 'darwin',
reason='https://github.com/The-Compiler/qutebrowser/issues/1142')
windows_xfail_marker = pytest.mark.xfail(
os.name == 'nt',
reason='https://github.com/The-Compiler/qutebrowser/issues/1142')
for item in items:
if item.get_marker('xfail_issue1142_osx'):
item.add_marker(osx_xfail_marker)
if item.get_marker('xfail_issue1142_windows'):
item.add_marker(windows_xfail_marker)
## Given ## Given