Commit Graph

2121 Commits

Author SHA1 Message Date
Florian Bruhin
f5d7605ae0 Add a :scroll-to-anchor command
Fixes #2784
2018-03-19 19:18:33 +01:00
Florian Bruhin
460bd86579 Initial attempt at using the tab API for tests/unit/javascript 2018-03-19 18:18:21 +01:00
Florian Bruhin
bee04a1eec Wait until runner is finished in test_custom_env
This seems to at least lead to less warnings when running the test.
2018-03-19 11:43:08 +01:00
Florian Bruhin
232fd19422 Fix unit tests after refactoring 2018-03-19 09:53:35 +01:00
Florian Bruhin
1b84bbd61d Refactor initialization of internal JavaScript
- Initialize JavaScript in webenginesettings.py instead of webenginetab.py
- Move JavaScript snippet into a .js file
- Make sure scripts can be re-run and do nothing if already run.
- Run scripts on DocumentCreation *and* DocumentReady. Closes #3717.
- Give each script an unique name for debugging.
- Also make custom stylesheets work on chrome:// pages
2018-03-19 09:14:55 +01:00
Michal Siedlaczek
f9e702bae5 Warn about malformed dictionaries 2018-03-16 11:28:45 -04:00
gammelon
f57e47c742 Separate tests for _get_search_url 2018-03-16 11:42:51 +01:00
Florian Bruhin
1d25b212d5 Add missing qapp fixtures to tests
See #3723
2018-03-15 09:06:40 +01:00
Florian Bruhin
84c7c37e8e Swap Control/Meta back on macOS
Fixes #3697

(cherry picked from commit fd9e7bed7fd9842eac22ed304a094a92cc953577)
2018-03-14 19:40:56 +01:00
Florian Bruhin
c0fdf19756 Merge remote-tracking branch 'origin/pr/3704' 2018-03-14 08:06:24 +01:00
Florian Bruhin
b88ac51d25 Fall back to non-keypad keys without any keypad bindings
Fixes #3701
2018-03-13 14:40:54 +01:00
Ryan Roden-Corrent
73517f0a51 Fix test_backup_error.
- Need caplog at level error
- Rename test to be unique
2018-03-13 08:50:34 -04:00
Ryan Roden-Corrent
27966c94a6 Fix up editor backup patch.
- Use qutebrowser-editor-backup as the backup file prefix
- Consistently use message.error instead of cmdexc
- Improve test coverage for the backup function
- Fix lint errors in the unit test code
2018-03-13 07:34:18 -04:00
Florian Bruhin
c590648077 Merge remote-tracking branch 'origin/pr/3613' 2018-03-13 08:39:36 +01:00
Florian Bruhin
14d6e737fa Merge remote-tracking branch 'origin/pr/3606' 2018-03-13 07:37:57 +01:00
Ryan Roden-Corrent
38bb3673db Preserve a backup if editor callback fails.
Currently the editor deletes its temp file whenever editing is finished.
With this patch, the file will not be deleted if the editor callback
encounters an exception.

One example is if the tab containing the edited element is closed. The
editor errors with "Edited element vanished", but with this patch it
will also print "Backup at ..." so the user does not lose their work.

Resolves #1596.

Supersedes #3641, using the cleaner approach started in #1677.
2018-03-12 08:34:50 -04:00
gammelon
455f6b8a70 Fix blank lines 2018-03-12 12:37:52 +01:00
Florian Bruhin
8c5b7bcd03 Fix lint 2018-03-12 08:51:36 +01:00
Florian Bruhin
9941812127 Normalize keys read from the config
This makes sure the internal bindings.commands object only contains normalized
key sequences.

Fixes #3699
2018-03-12 08:00:56 +01:00
Florian Bruhin
990c0707f4 Make from_obj() work for List/Dict configtypes
We can't easily make it work for ListOrValue as we don't know which of both we
get at this point.
2018-03-12 08:00:18 +01:00
Florian Bruhin
b6e29d8eae Be explicit about expected output in test 2018-03-11 14:35:15 +01:00
Roman Bogorodskiy
d0342bffc4 Show version for POSIX OSes
For POSIX OSes other than Linux and macOS set OS Version to
platform.uname() instead of showing 'OS Version: ?'.
2018-03-11 13:28:53 +04:00
Johannes Wegener
cf4e472461 add basic completion to file dialog 2018-03-09 16:21:57 +01:00
gammelon
0ce94dae1c forgot one bit 2018-03-09 15:55:40 +01:00
gammelon
7e3c966afe rewrite tests 2018-03-09 15:52:03 +01:00
Florian Bruhin
ebb373ccad Make sure keys with modifiers get handled as special 2018-03-09 09:04:28 +01:00
Florian Bruhin
66b06ed84c Add first tests for HintKeyParser 2018-03-09 07:38:16 +01:00
Florian Bruhin
482b622b1b Fix handling of empty bindings without breaking :unbind
1899e313fd as a fix for #3631 broke :unbind, as
the config system treats None and '' equally.

Instead, allow None/'' again, but just handle it as "no binding".
2018-03-08 11:42:27 +01:00
Florian Bruhin
d5c04318b2 Fix test/lint 2018-03-08 06:41:15 +01:00
Florian Bruhin
9b9d7647a4 Show the keystring correctly when entering a count 2018-03-07 22:47:31 +01:00
Florian Bruhin
514138aad2 Allow to bind numbers in keybindings
This mostly reverts 4ef5db1bc4 for #1966, but
fixes #3684 by allowing numbers to be bound again. If the user wants to bind
numbers instead of using them for a count, why not let them.
2018-03-07 22:37:10 +01:00
Florian Bruhin
34815f5cf8 Make bindings.default only settable in autoconfig.yml
Fixes #3131
2018-03-07 18:30:44 +01:00
Florian Bruhin
8a60855b88 Fix lint 2018-03-06 21:44:37 +01:00
Florian Bruhin
0d94c17edc Apply key_mappings to KeySequences correctly
Fixes #3678
2018-03-06 21:39:57 +01:00
Florian Bruhin
db7ccb0434 Update config tests for pattern changes 2018-03-06 13:26:22 +01:00
Florian Bruhin
257753841b Allow lightweight URL patterns without a scheme
See #3622
2018-03-06 10:33:55 +01:00
Florian Bruhin
7fc53ae78a Make path optional in URL patterns
See #3622
2018-03-06 09:45:06 +01:00
Florian Bruhin
8c0bca90d3 Merge remote-tracking branch 'origin/pr/3456' 2018-03-06 09:32:39 +01:00
Florian Bruhin
0e2a39da2a Fix tests for keyboard parsing change 2018-03-06 07:39:41 +01:00
Florian Bruhin
41dfa29648 Improve parsing of invalid keys
This should handle "<>" and "\x1f" correctly.
2018-03-06 06:29:38 +01:00
Florian Bruhin
7a9f8fda72 Get rid of unnecessary lambda 2018-03-05 23:07:03 +01:00
Florian Bruhin
2b84ea9dbe Make sure we have plain keys/modifiers where needed 2018-03-05 23:01:24 +01:00
Florian Bruhin
0ee7fac727 Update test_init_unknown/test_init_invalid for KeyboardModifierMask
-1 & Qt.KeyboardModifierMask == Qt.Key_unknown
2018-03-05 22:56:58 +01:00
Florian Bruhin
8deb38e22d Add test for :bind completion with invalid binding 2018-03-05 22:21:57 +01:00
Florian Bruhin
29fdd1acc4 Make sure all keyboard modifiers are handled correctly
This handles Qt.KeypadModifier (Num+...) correctly, adds tests for converting
modifiers to strings, and strips Qt.GroupSwitchModifier as QKeySequence doesn't
know about it.

Fixes #3675
2018-03-05 22:11:26 +01:00
Florian Bruhin
333a37ffb2 Fix old macOS-specific test code 2018-03-05 18:30:34 +01:00
gammelon
a730290d40 Use QUrl for parsing, add tests 2018-03-05 16:32:41 +01:00
Florian Bruhin
d1854eddaf Handle invalid keys coming from Qt
When pressing a key which doesn't exist as Qt.Key, we don't get Qt.Key_unknown
like we'd expect, but we get 0x0 instead...

Let's add that as a new "nil" key (to not conflict with None/unknown/zero/...)
and handle it appropriately.

This can be reproduced by doing:
setxkbmap -layout us,gr -option grp:alt_shift_toggle
and pressing Alt-Shift/Shift-Alt.
2018-03-05 15:42:52 +01:00
Florian Bruhin
52c280ec12 Add unit tests for BaseKeyParser.handle with dry_run=True 2018-03-05 15:33:56 +01:00
Florian Bruhin
67b4502fdb Fix test_version without cssutils 2018-03-05 11:36:50 +01:00
Florian Bruhin
cc5da4d1fe Fix test_modeman.py 2018-03-05 11:08:21 +01:00
Florian Bruhin
b4a2352833 Cache HTML/JS resource files when starting
This mostly reverts 9edc5a665e (see #1362).
Fixes #1943
2018-03-05 09:08:06 +01:00
Florian Bruhin
274f2a9d19 Rename eventFilter methods in modeman 2018-03-05 06:36:01 +01:00
Florian Bruhin
4ef5db1bc4 Disallow numbers in keybindings
Fixes #1966
2018-03-04 23:17:51 +01:00
Florian Bruhin
155a1901c0 Merge branch 'keys' 2018-03-04 22:50:41 +01:00
Florian Bruhin
88a5c8d29d Make sure bindings with umlauts work
See #303
2018-03-04 22:38:33 +01:00
Florian Bruhin
e2f17c4be1 Always prefer exact over partial matches 2018-03-04 21:45:46 +01:00
Florian Bruhin
0967b6abd2 Fix handling of </> keys 2018-03-04 20:40:16 +01:00
Florian Bruhin
d8bfe23c0d Fix lint 2018-03-04 20:21:58 +01:00
Florian Bruhin
f85e69ec77 Refactor other keyinput tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
2be7db29ed 100% coverage for keyinput.keyutils 2018-03-04 20:21:58 +01:00
Florian Bruhin
8da878c77c Make KeySequence.matchs() work correctly 2018-03-04 20:21:58 +01:00
Florian Bruhin
866c758660 Add more KeySequence tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
fb7c75a090 Improve keyutils tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
3c9e8ff9ab Test and fix keyutils._parse_keystring 2018-03-04 20:21:58 +01:00
Florian Bruhin
7f8508a367 Change the way Space keybindings are handled
Using it as " " in a keystring won't work anymore, but instead <Space> and
<Shift-Space> does.
2018-03-04 20:21:58 +01:00
Florian Bruhin
da60d11b24 Refactor keyutils tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
b3834835ed Bring back keyutils.is_modifier() and modifier handling
Turns out when we press yY, we get three events:

Qt.Key_Y, Qt.NoModifier
Qt.Key_Shift, Qt.ShiftModifier
Qt.Key_Y, Qt.ShiftModifier

If we don't ignore the second one, our keychain will be interrupted by the Shift
keypress.
2018-03-04 20:21:58 +01:00
Florian Bruhin
e306e2dadb Improve and fix test_is_printable 2018-03-04 20:21:58 +01:00
Fritz Reichwald
d9a88e139c Test for modifiers and corner case 0xFF 2018-03-04 20:21:58 +01:00
Florian Bruhin
3a11a24be0 Fix modifier handling
We don't want to show <Shift-Shift>, but <Ctrl-Shift> should still work
correctly.
2018-03-04 20:21:58 +01:00
Florian Bruhin
7cb781cc92 Simplify handling of modifier-only keys
Now that we don't rely on str(KeyInfo) being empty anywhere, there's no reason
to return an empty string for only-modifier keypresses anymore.

While those keys can't be bound (QKeySequence('Shift') == Qt.Key_unknown)
there's also no reason to explicitly ignore them.
2018-03-04 20:21:57 +01:00
Florian Bruhin
693178c8ee Refactor KeyInfo.__str__
This removes the special handling for macOS, but this is hopefully not needed
anymore as we don't compare strings.
2018-03-04 20:21:57 +01:00
Florian Bruhin
af6e5b1838 Fix lint 2018-03-04 20:21:57 +01:00
Florian Bruhin
fac8d72d8c Capitalize Escape in TestFullscreenNotification 2018-03-04 20:21:57 +01:00
Florian Bruhin
a57fc5c746 Refactor keyutils tests involving all keys 2018-03-04 20:21:57 +01:00
Florian Bruhin
4223e2f85d Check all keys against QTest::keyToAscii 2018-03-04 20:21:57 +01:00
Fritz Reichwald
d28c323074 Add printable and ismodifier test 2018-03-04 20:21:57 +01:00
Florian Bruhin
934d586286 Fix handling of Shift-Tab aka. Backtab 2018-03-04 20:21:57 +01:00
Florian Bruhin
63e05e12ba Fix lint and tests 2018-03-04 20:21:57 +01:00
Florian Bruhin
2ca15d7667 Add tests for lower-/uppercase text 2018-03-04 20:20:31 +01:00
Florian Bruhin
8c87040cb6 Improve IDs for qt_key fixture 2018-03-04 20:20:31 +01:00
Florian Bruhin
0b6d2c2b0a Make all key names work 2018-03-04 20:20:30 +01:00
Florian Bruhin
601e56d2fa Make test_keyutils work 2018-03-04 20:20:30 +01:00
Florian Bruhin
8f479407a0 key_data: Update key names to reflect reality
Generated by:

import key_data
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QKeySequence

for key in key_data.KEYS:
    attr = key.attribute
    member = getattr(Qt, 'Key_' + attr, None)
    if member is None:
        continue
    name = QKeySequence(member).toString()
    if name != attr:
        try:
            print("    Key('{}', '{}')".format(attr, name))
        except UnicodeEncodeError:
            print("    Key('{}', '{}')  # FIXME".format(attr, name.encode('unicode-escape').decode('ascii')))
    else:
        print()
2018-03-04 20:20:30 +01:00
Florian Bruhin
f714be0ff7 Initial tests on all Qt keys 2018-03-04 20:20:30 +01:00
Florian Bruhin
19512e988b Expose less from keyutils publicly 2018-03-04 20:20:30 +01:00
Florian Bruhin
fdc2458657 Fix test_split_count after _handle_key merge 2018-03-04 20:20:30 +01:00
Florian Bruhin
c3485821c7 Adjust copyright 2018-03-04 20:20:30 +01:00
Jimmy
7dab8335e2 Greasemonkey: handle downloads that complete fast
When `@require`ing local files (with the `file://` scheme) the
greasemonkey manager was not catching the DownloadItem.finished signal
because it was being emitted before it had managed to connect.

I didn't see this happening while testing with files that should have
been in cache but I wouldn't be surprised.

I had to change the download mock to be able to give it the appearance
of asynchronicity. Now when using it one must set download.successful
appropriately before firing download.finished. I also added a list of
downloads to the stub so a test could enumerate them in case the
unit-under-test didn't have a reference to them.
2018-03-03 15:02:43 +13:00
Jimmy
919fe45813 Greasemonkey: Add test for @require support.
There's is a lot of asserts in that one test but it tests everything.
2018-03-03 15:02:42 +13:00
Jimmy
fa1ac8d93c Move download_stub to helpers/fixtures
I am adding support for downloading dependant assets in
browser/greasemonkey and want to mock the download manager for testing.
2018-03-03 15:02:42 +13:00
Jimmy
cba93954cd Allow download_stub test fixture to handle file targets. 2018-03-03 13:14:49 +13:00
Florian Bruhin
be7a21eb56 Make sure the backend is set in test_webenginesettings.py 2018-03-02 07:00:09 +01:00
Florian Bruhin
067be7aaa2 Simplify mock checks 2018-03-02 06:33:56 +01:00
Florian Bruhin
fb7fa0cb49 Merge remote-tracking branch 'origin/pr/3652' 2018-03-02 06:31:00 +01:00
Ryan Roden-Corrent
d5e30fd728 Don't crash first completion update with min_chars.
When min_chars is nonzero, if the first command that opens the
completion has < min_chars on the word under the cursor, it triggers a
check for a condition where last_cursor_pos is None.

By setting last_cursor_pos=-1 we ensure that the completer always
updates the first time it is opened, and that there is never a check
against None.

This adds a test for the min_chars feature.

Resolves #3635.
2018-03-01 22:07:53 -05:00
Ryan Roden-Corrent
2965f954ba Resolve empty completion.timestamp_format crash.
Resolves #3628.
2018-03-01 07:54:20 -05:00
Florian Bruhin
f3aaa1084a Migrate spell tests to unittests 2018-02-28 08:08:23 +01:00
Florian Bruhin
5eb340d481 Add missing tests for completions 2018-02-27 15:55:00 +01:00
Florian Bruhin
5a5873d4ee Rename KeyConfig._prepare to ._validate 2018-02-27 14:16:41 +01:00
Florian Bruhin
49d297f7bf Fix tests for parsing KeySequences 2018-02-27 14:10:55 +01:00
Florian Bruhin
244590f49d Handle unknown keys with :bind/:unbind 2018-02-27 13:09:48 +01:00
Florian Bruhin
88b5007457 Consolidate invalid :bind/:unbind tests 2018-02-27 13:02:32 +01:00
Florian Bruhin
8090d3e289 Handle invalid keys in config.py 2018-02-27 13:02:32 +01:00
Florian Bruhin
898f5c50c4 Add a test for utils.chunk 2018-02-27 13:02:32 +01:00
Florian Bruhin
ec3ad8a969 Get rid of _warn_on_keychains and _supports_chains 2018-02-27 13:02:32 +01:00
Florian Bruhin
ba012c6ba8 Get rid of BaseKeyparser.Type 2018-02-27 13:01:41 +01:00
Florian Bruhin
362f923f06 Fix lint 2018-02-27 09:34:55 +01:00
Florian Bruhin
1ba61bbcbe Fix test_modeparsers 2018-02-27 09:22:01 +01:00
Florian Bruhin
911b2daebf Fix test_keyutils 2018-02-27 09:07:20 +01:00
Florian Bruhin
5a03d31f6f More test_basekeyparser fixes 2018-02-27 08:53:28 +01:00
Florian Bruhin
9e27f2b3e7 Initial attempts at fixing test_basekeyparser 2018-02-27 08:48:16 +01:00
Florian Bruhin
1e8f72dfe6 Adjust test_configtypes 2018-02-27 08:10:54 +01:00
Florian Bruhin
f40f4082ba Validate configtypes.Key correctly 2018-02-27 07:56:34 +01:00
Florian Bruhin
612387633d Adjust test_configfiles 2018-02-27 07:53:29 +01:00
Florian Bruhin
214e750c69 Adjust test_configcommands.py 2018-02-27 07:51:07 +01:00
Florian Bruhin
49f8bc3d63 Use KeySequences correctly in test_config.py 2018-02-27 07:37:55 +01:00
Florian Bruhin
fa29a0b686 Expect capitalized bindings in test_models 2018-02-27 06:58:39 +01:00
Florian Bruhin
8416e97c6c Fix type which is stubbed in test_models 2018-02-27 06:50:57 +01:00
Florian Bruhin
53fb5af99c Paste version information privately 2018-02-26 23:09:55 +01:00
Florian Bruhin
321d5c5d20 Merge branch 'master' into keys 2018-02-25 21:25:12 +01:00
Florian Bruhin
52b5492c6a Merge branch 'per-url' 2018-02-25 19:44:51 +01:00
Florian Bruhin
abf4d10d5b Add a test for :set -p with a pattern 2018-02-25 19:33:27 +01:00
Florian Bruhin
3956f81e73 Refactor websettings
This refactors the whole web(kit|engine|) settings mess a bit so there's a
Web(Kit|Engine)Settings object for (non-static) settings set on a
QWeb(Engine)Settings object in Qt. Everything else is set on module-level a bit
less declaratively.

The whole inheritance mess is gone, and we can now also construct a
Web(Kit|Engine)Settings object for a given tab.

Fixes #2701
2018-02-23 09:51:28 +01:00
Florian Bruhin
49ead32f13 Update urlmatch tests for Chromium changes
See:
0ab1294c92%5E%21/
https://bugs.chromium.org/p/chromium/issues/detail?id=812543
2018-02-23 06:31:49 +01:00
Florian Bruhin
13bd4dd05d Clean up version.pastebin_url in pbclient fixture 2018-02-21 10:49:42 +01:00
Florian Bruhin
2fbc7b4e1d Merge remote-tracking branch 'origin/pr/3594' 2018-02-21 10:15:27 +01:00
Florian Bruhin
ea6a5de374 Update FIXMEs 2018-02-20 23:28:11 +01:00
Florian Bruhin
0d4e20c395 Whitelist config options which support URL patterns 2018-02-20 23:26:22 +01:00
Florian Bruhin
6c5876a494 Fix tests broken by urlmatch trailing slash change 2018-02-20 23:08:09 +01:00
Florian Bruhin
18848315f5 urlmatch: Make it possible to leave off trailing slash 2018-02-20 22:45:16 +01:00
Florian Bruhin
17b235b523 Add error handling for parsing patterns from YAML 2018-02-20 22:29:21 +01:00
Florian Bruhin
46aeb25e7e Fix lint 2018-02-20 20:55:42 +01:00
Florian Bruhin
439d51875f Add config.pattern() 2018-02-20 20:54:26 +01:00
Florian Bruhin
3ade923edb Add basic pattern support for config.py 2018-02-20 18:43:42 +01:00
Florian Bruhin
a3dfec20c1 Rename --url to --pattern 2018-02-20 17:56:47 +01:00
Florian Bruhin
9685445559 Fix issues with Python 3.5 2018-02-20 17:56:47 +01:00
Florian Bruhin
e482c76874 YamlConfig: Refuse to read a newer config version 2018-02-20 17:08:28 +01:00
Florian Bruhin
03114ccf51 Migrate YAML config files in old format 2018-02-20 16:14:06 +01:00
Florian Bruhin
ae73215724 Fix lint 2018-02-20 12:30:41 +01:00
Florian Bruhin
b9bb515b3b Add missing configfiles tests 2018-02-20 12:30:41 +01:00
Florian Bruhin
9c42d87e7d Add missing configutils test 2018-02-20 12:30:34 +01:00
Florian Bruhin
05017c83d6 Add more config tests 2018-02-20 12:30:34 +01:00
Florian Bruhin
36f3e54e1d Finish configutils tests 2018-02-20 12:30:34 +01:00
Florian Bruhin
63c77a4d76 urlmatch: Fix equality with non-UrlPattern types 2018-02-20 12:30:34 +01:00
Florian Bruhin
685e3ffcfe Fix and test UrlPattern/configutils.Values stringification 2018-02-20 12:30:34 +01:00
Florian Bruhin
145a21449b configutils: Add first tests 2018-02-20 12:30:34 +01:00
Florian Bruhin
5978b7b35f config: Improve tests for non-existent options 2018-02-19 22:09:54 +01:00
Florian Bruhin
463320b599 Make test_config.py work 2018-02-19 22:09:54 +01:00