Commit Graph

280 Commits

Author SHA1 Message Date
Marshall Lochbaum
e4cec43cf4 Add quick-complete to completion widget tests 2016-08-20 01:27:39 -04:00
Marshall Lochbaum
2db0ec8b6d Fix test_completion_show name and docstring 2016-08-20 01:13:32 -04:00
Marshall Lochbaum
64d53e4cf9 Add unit test for completion show 2016-08-20 01:01:38 -04:00
Marshall Lochbaum
08b348be50 Merge branch 'master' into auto-open-fixes 2016-08-19 22:50:26 -04:00
Ryan Roden-Corrent
7b3839b44b Focus completion by category.
Implement `completion-item-focus next-category` and
`completion-item-focus prev-category` to jump through completions by
category rather than by item.

Resolves #1567.
2016-08-15 07:14:28 -04:00
Florian Bruhin
f3c32308d3 Merge branch 'complete-hidden-commands' of https://github.com/rcorre/qutebrowser into rcorre-complete-hidden-commands 2016-08-10 15:38:46 +02:00
Florian Bruhin
ad5008152c Move browser.webkit.history to browser.history 2016-08-10 14:45:52 +02:00
Ryan Roden-Corrent
0c43ca9f09 Don't sort command completions in models.
The sortfilter already handles sorting, there is no reason to pre-sort
the entries in the model.
2016-08-10 06:58:34 -04:00
Ryan Roden-Corrent
97a971624b Show bindings for aliases in completion.
Command completions for `:bind` and `:` will now show bindings for
aliases. The binding is only included if it is bound to that alias, not
if it is bound to the command the alias points to.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
709470fbe6 Clean up miscmodels and test_models.
- Split up a long conditional into multiple variables.
- Fix a small typo in a related test.
- Remove a trailing comma from an argument list.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
8dbc368d08 Refactor duplicate code for command completion.
Consolidate the logic used to generate the command completion category
into one place. This is shared by CommandCompletionModel,
HelpCompletionModel, and BindCompletionModel.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
0ea61d5f15 Show hidden commands in completion for :bind.
There is a fair amount of duplicate code around command completion that
could probably be refactored.

Resolves #1707.
2016-08-10 06:56:44 -04:00
Ryan Roden-Corrent
dd9470af94 Show hidden commands in help completion.
Hidden commands are not shown in command completion as they typically
would not be run directly. However, a user might still might like to see
help for them if, for example, they are writing a script or creating a
binding.

Addresses #1707.
2016-08-10 06:55:46 -04:00
Marshall Lochbaum
8da8441623 Merge auto-open option into show 2016-08-09 13:11:32 -04:00
Marshall Lochbaum
d98c81c9d6 Correct widget behavior when there is no completion 2016-08-09 13:03:38 -04:00
Florian Bruhin
fb3da578c5 Fix lint 2016-08-09 17:28:14 +02:00
Marshall Lochbaum
80db69904d Move auto-open handling to CompletionView from Completer 2016-08-08 16:56:11 -04:00
Ryan Roden-Corrent
7038db6b17 Combine completion-item-{prev,next}.
- Use a single command completion-item-focus with a next/prev argument.
- Add a rule to translate old configs.
- Regenerate the docs.

See #1095.
2016-08-08 07:37:53 -04:00
Florian Bruhin
26e0383d45 Merge branch 'refactor_command_completion' of https://github.com/rcorre/qutebrowser into rcorre-refactor_command_completion 2016-08-07 11:29:50 +02:00
Ryan Roden-Corrent
66358e5b0f Remove usertypes.Completion.empty.
Completion.empty existed to fill a slot in the old Command.completions
interface if the first positional arg had no completions but the second
did, as is the case for the `bind` command. Now that
`Command.completions` is replaced by `Command.get_pos_arg_info`, this
is no longer needed.
2016-08-06 12:01:09 -04:00
Ryan Roden-Corrent
c792ffda67 Remove Command.completion.
Command completion types are now identified by ArgInfo, so just use
that directly and cut out the middle-man. This shouldn't change any
completion behavior.

Adds a test for get_pos_arg_info to test_cmdutils.

Modifies test_completer to test the use of get_pos_arg_info. Instead of
using FakeCommand, real Command objects are used, to validate that the
Completer works with the real Command interface. This also cleans out
some test cases that were testing things already covered by other cases.
2016-08-06 11:59:04 -04:00
Ryan Roden-Corrent
3e1409b1f5 Dedupe code in test_sortfilter.
Add helper functions to create and parse completion models, as this was
repeated in many tests.
2016-08-05 08:47:52 -04:00
Ryan Roden-Corrent
ed69ef86ab Unit test CompletionFilterModel.sort. 2016-08-05 08:29:29 -04:00
Ryan Roden-Corrent
83b621b0e6 Test CompletionFilterModel.set_pattern.
This is a more rigorous test than filterAcceptsRow as it tests behavior
with multiple columns and different sort settings. In addition, it
tests intelligentLessThan which is not tested in the filterAcceptsRow
test (as lessThan is never called if there is only 1 item to filter).
2016-08-05 07:20:31 -04:00
Ryan Roden-Corrent
8e7002db7a Test CompletionFilterModel.count 2016-08-05 07:20:31 -04:00
Ryan Roden-Corrent
f19b818b58 Test CompletionFilterModel.set_source_model 2016-08-05 07:20:31 -04:00
Ryan Roden-Corrent
b13153aa77 Test CompletionFilterModel.first/last. 2016-08-05 07:20:31 -04:00
Ryan Roden-Corrent
a393adc6c7 Don't crash completion with auto-open/show False.
If both are false, the selectionModel may be None.
In this case, don't try to move the index.
Resolves #1722.
2016-08-01 22:36:04 -04:00
Ryan Roden-Corrent
6e2d78b826 Don't crash on tab with no completions.
first_item and last_item return an invalid index when there are no
items in the completion, and the completionwidget will throw on an
invalid index. However, setting an invalid index on the selection view
is fine, so just remove the assertion.

Resolves #1731.
2016-08-01 22:16:55 -04:00
Florian Bruhin
693210920c Fix completion widget unit tests 2016-08-01 16:29:47 +02:00
Florian Bruhin
62f9161d03 Merge branch 'completer_tests' of https://github.com/rcorre/qutebrowser into rcorre-completer_tests 2016-08-01 16:02:53 +02:00
Ryan Roden-Corrent
fbadc5e668 Remove second arg from on_selection_changed.
The deselected argument was unused, so remove it from the signal and
the slot.
2016-07-29 08:48:24 -04:00
Florian Bruhin
c40059715a Fix long line 2016-07-29 10:43:53 +02:00
Florian Bruhin
cffe2281b1 Use qtmodeltester for completion model tests
See http://pytest-qt.readthedocs.io/en/latest/modeltester.html
See #1702
2016-07-29 10:26:55 +02:00
Ryan Roden-Corrent
dd827332c0 Clean up unused imports from completion refactor. 2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
f31e890862 Move completion_item_{next,prev} to CompletionView.
These commands are more closely tied to the CompletionView than
Completer. This removes the need for an extra signal tying the
CompletionView to the Completer.

The call to _open_completion_if_needed was moved to
on_selection_changed, as this will already be called when a new item is
selected.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
ffc5a42d04 Don't use objreg to get CompletionView.
The CompletionView is the parent of the Completer, so there's no need
to use objreg to get it.
See #640.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
b9cf9d180b Decouple Completer and CompletionView.
Rather than having a CompletionView instantiate and register a
Completer, instantiate both in MainWindow. The CompletionView is the
parent of the Completer, and communicates by emitting
selection_changed, meaning it no longer needs to contain a reference to
the Completer.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
d836fcb118 Code review for completion tests.
- clean up docstring typos
- use _ to name an unused loop variable
- parent the filter model to avoid an issue with disposal
- use mocker.patch instead of monkeypatch to mock Completer creation
- use is instead of == to compare by identity
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
415ad7a638 Unit test completion view. 2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
a740f99607 Register the fake statusbar command in objreg.
The CompletionView looks in objreg for 'status-cmd', so move it from a
private fixture in test_completer to a public fixture that handles
objreg registration/deletion.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
e5da179ebf Limit the public interface of Completer.
Only schedule_completion_update and selection_changed are used
externally, so mark the rest of the API as private.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
aedf5b930a Test Completer.schedule_completion_update.
update_completion is only used internally, so instead test the real
public entry point which is schedule_completion_update.

This required mocking out QTimer to fire immediately so the test didn't
have to do flaky artificial delays.
2016-07-28 12:20:24 -04:00
Florian Bruhin
e36123735b Use a fixture for FakeWebTab
We need to make sure qapp and tab_registry are available everywhere the
FakeWebTab class is used.
2016-07-10 16:57:02 +02:00
Florian Bruhin
2befebaf3a Don't use properties for AbstractTab
Otherwise exceptions in there could be hidden by Python/PyQt.

Some places are not changed yet, as there are also other renames in the
next commits.
2016-07-08 10:05:46 +02:00
Florian Bruhin
4e5a7a891e tests: Use FakeWebTab for stubbing 2016-07-07 18:32:52 +02:00
Ryan Roden-Corrent
6c2c9438a7 More completer unit test cases. 2016-07-04 19:06:00 -04:00
Ryan Roden-Corrent
4c9417ac6e Use helper method for cmd prompt text testing.
In test_completer, introduce two helper methods to reduce duplicate
code for handling fake cmd prompt text that uses '|' as a placeholder.
2016-07-04 12:31:56 -04:00
Ryan Roden-Corrent
27d635a394 Test selection_changed, not change_completed_part.
For the Completer unit tests:
Although `change_completed_part` looks like a public method, it was
only used internally. Test the externally-used method
`selection_changed` instead.
2016-07-04 08:22:21 -04:00
Ryan Roden-Corrent
a6a8bf9304 Clean up test_completer further.
Based on code review:
- Use qtbot.waitSignal to test a signal firing
- Use pytest.mark.xfail for an expected test failure
- Ensure there are 2 newlines between module-level functions
2016-07-04 07:36:31 -04:00
Ryan Roden-Corrent
68e373df44 Use QLineEdit as a base for FakeStatusbarCommand.
Reduces the amount of mocking and keeps it more true to the original.
2016-07-03 23:06:36 -04:00
Ryan Roden-Corrent
7f690c3f3f More unit test coverage for Completer.
Test completion_item{next,prev} and change_completed_part.
2016-07-03 22:58:09 -04:00
Ryan Roden-Corrent
9bfff1c685 Test more cases for completer.update_completion. 2016-07-03 17:18:16 -04:00
Ryan Roden-Corrent
13e8ed53d6 Clean up completer unit test.
Based on code review:

    - import modules, not classes
    - use methods, not lambdas for the mock command prompt class
    - use None rather than Mock for DUMB_SORT
    - autouse two fixtures and remove them from test signatures
2016-07-03 17:18:16 -04:00
Ryan Roden-Corrent
07edcce697 Unit test Completer.update_completion.
Validate update_completion sets the completions widget's model
correctly based on the command text.
2016-07-02 12:25:55 -04:00
Florian Bruhin
a3b0e7c1cb Fix indent 2016-07-01 14:38:18 +02:00
Ryan Roden-Corrent
d45acb0388 Eliminate FakeSettingSection/Value.
Don't really need to mock these out for tests as the real classes are
simple enough.
2016-06-30 20:12:44 -04:00
Ryan Roden-Corrent
94ec712ea8 Really clean up Qt view in completion tests.
Missed a spot.
2016-06-30 20:12:04 -04:00
Ryan Roden-Corrent
4178f73ed9 Move utility functions to top of test_completion.
Just a style change.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
849706e310 Clean up Qt view used in completion tests.
Add the view created during the tests to qtot so it gets cleaned up
after the test exits.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
ee59b133c0 Don't bother mocking a history entry.
Use webkit.history.Entry in tests instead of FakeHistoryEntry.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
d6012ad95c Test delete_cur_item more cleanly.
Reduce duplicate code by mocking out a QTreeView around the model and
setting its index.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
9d49f5a57d Test tab completion with multiple tabbed browsers. 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
b6652ad6bc Test completion quickmark/bookmark deletion.
Validate that quickmarks and bookmarks can be deleted from the url
completion menu.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
409de10fb4 Unit test delete_cur_item for tab completion model. 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
8321c1a90f Unit test setting value completion 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
f5b1019d4d Unit test config option completion.
Had to add the `raw` parameter to ConfigStub.get as the setting option
completion model passes this argument explicitly (although the docs say
only raw=True is supported).
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
5255a71bc5 Unit test setting section completion. 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
16f043034f Unit test tab (buffer) completion.
This involved adding a few stubs as well as expanding the FakeWebView.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
610f9b7068 Unit test session completion 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
baf8d00a20 Unit test url/quickmark/bookmark completion.
This also adds a few more stubs/fakes to mock out the
quickmark-manager, bookmark-manager, and web-history objects.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
b037ec489f Add unit tests for help completion.
Also adds a FakeConfigSection stub for stubbing out configdata.DATA.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
555bdb75b5 Add unit test for CommandCompletionModel.
This establishes a pattern that can probably be used to test any of the
completion models.

See #999.
2016-06-30 07:26:02 -04:00
Florian Bruhin
ddc1f803c0 Clean up assertion 2016-05-08 20:01:35 +02:00
Florian Bruhin
f49cc4e901 Only keep contain tests 2016-05-08 19:57:59 +02:00
Florian Bruhin
65ed878dcf Update copyright 2016-05-08 19:57:18 +02:00
Florian Bruhin
fdb28e4c71 Add test_sortfilter from #950 2016-05-08 19:56:41 +02:00
Florian Bruhin
5311576c34 Check pep257 via flake8.
We'll still keep the pydocstyle environment though until flake8-pep257 adds
support for that:

https://github.com/Robpol86/flake8-pep257/issues/6
2016-02-10 19:18:47 +01:00
Florian Bruhin
a5f2ac5f03 Adjust copyright years. 2016-01-04 07:12:39 +01:00
Florian Bruhin
2c5269acd6 Reorganize tests directory. 2015-08-18 20:19:02 +02:00