Merge lp://staging/~sinzui/bzr-gtk/ui-factory into lp://staging/bzr-gtk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Jelmer Vernooij | ||||
Approved revision: | 781 | ||||
Merged at revision: | 780 | ||||
Proposed branch: | lp://staging/~sinzui/bzr-gtk/ui-factory | ||||
Merge into: | lp://staging/bzr-gtk | ||||
Diff against target: |
873 lines (+582/-110) 4 files modified
setup.py (+41/-24) tests/__init__.py (+51/-19) tests/test_ui.py (+375/-0) ui.py (+115/-67) |
||||
To merge this branch: | bzr merge lp://staging/~sinzui/bzr-gtk/ui-factory | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij (community) | Approve | ||
Review via email:
|
Description of the change
Add GtkUIFactory implementations and missing tests.
This branch was extracted from my effort to guarantee that the progress bar
shows when I use gpush.
-------
RULES
* Add tests for all the implemented classes and specifically GtkUIFactory.
* Add ._progress_
needed to update the progress widget.
* Add the message, warning, and error dialogs.
* Maybe update the Confirmation dialog to extend MessageDialog?
* ADDENDUM: Let me run just one test module!
LINT
added:
tests/
modified:
setup.py
tests/
ui.py
TEST
./setup.py check
or
./setup.py check -m test_ui
IMPLEMENTATION
I was frustrated running the whole suite which takes 18 seconds on my
computer. I updated the test runner code to use existing 'discover'
option to run the whole suite, or accept a single module as an arg. The
ui tests complete in 0.107s on my computer.
setup.py
tests/
I First added tests for the existing classes. I have never used this
many mocks in a test suite before, they definitely make the tests fast,
though I thought I might have used too many. I tried removing a few but
the tests could become may times slower or just never complete without
forcing the Gtk.main_loop to run.
tests/
I then added test for new methods and refactored some of the code.
* I extracted the main_iteration code in one method to a decorator
function that I used on several progress bar methods to ensure
the UI updates immediately.
* I added the Info, Warning, and Error dialogs and refactored PromptDialog
to extend Gtk.MessageDialog. This provides an icon with the text
message, as well a guarantees that the spacing and layout conforms
to Gnome HIG.
* After I extracted the main_loop iteration rules from update(), changed
self.fraction to fraction because nothing used it. I changed the error
to a ValueError because it can only be caused by insane inputs.
* I extracted the common progress window and panel methods to
ProgressConta
tests to that used a similar mixin to verify their function.
* I updated ProgressPanel to GtkBox since GtkHBox is deprecated.
* I added show_user_warning, which is almost identical to the TextUI
implementation.
* I added ._progress_
the gpush progress bar show sooner and update more often.
ui.py
tests/
This is *really* nice. Thanks, Curtis!