Merge lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp

Proposed by Azaziah
Status: Superseded
Proposed branch: lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick
Merge into: lp:openlp
Diff against target: 85 lines (+37/-5)
2 files modified
openlp/plugins/bibles/lib/mediaitem.py (+17/-4)
tests/functional/openlp_plugins/bibles/test_mediaitem.py (+20/-1)
To merge this branch: bzr merge lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick
Reviewer Review Type Date Requested Status
Raoul Snyman Pending
Tim Bentley Pending
Review via email: mp+303474@code.launchpad.net

This proposal supersedes a proposal from 2016-08-19.

This proposal has been superseded by a proposal from 2016-08-20.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Looks OK but needs tests!

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Please see my comments.

review: Needs Fixing
Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Tests? The rest looks good though

review: Needs Fixing
2698. By Azaziah

- Renamed test title from x_test to test_x

2699. By Azaziah

- Fixed the test

2700. By Azaziah

- Combined some <strong> tags in expection dialogue.
- Added new line to the end of the test.

2701. By Azaziah

- Merged trunk on 9.9.16

2702. By Azaziah

- Fixed a bug where web bible's trigger traceback in search while typing.

2703. By Azaziah

- Added param: to Lock toggle button

2704. By Azaziah

- Merged trunk on 16.9.16

2705. By Azaziah

- Added a test for toggle lock button
- Removed give focus to Select bookname on Select tab, may be confusing.

2706. By Azaziah

- Added two new tests for lock button toggle.

2707. By Azaziah

- The checking for not_called_once does not work apparently, fails in jenkins but passes in nosetests.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
2--- openlp/plugins/bibles/lib/mediaitem.py 2016-08-10 18:31:33 +0000
3+++ openlp/plugins/bibles/lib/mediaitem.py 2016-08-20 19:00:29 +0000
4@@ -254,8 +254,8 @@
5 self.quickStyleComboBox.activated.connect(self.on_quick_style_combo_box_changed)
6 self.advancedStyleComboBox.activated.connect(self.on_advanced_style_combo_box_changed)
7 # Buttons
8- self.advancedClearButton.clicked.connect(self.on_clear_button)
9- self.quickClearButton.clicked.connect(self.on_clear_button)
10+ self.advancedClearButton.clicked.connect(self.on_advanced_clear_button_clicked)
11+ self.quickClearButton.clicked.connect(self.on_clear_button_clicked)
12 self.advancedSearchButton.clicked.connect(self.on_advanced_search_button)
13 self.quickSearchButton.clicked.connect(self.on_quick_search_button)
14 # Other stuff
15@@ -548,19 +548,32 @@
16 self.advancedTab.setVisible(True)
17 self.advanced_book_combo_box.setFocus()
18
19- def on_clear_button(self):
20+ def on_clear_button_clicked(self):
21 # Clear the list, then set the "No search Results" message, then clear the text field and give it focus.
22 self.list_view.clear()
23 self.check_search_result()
24 self.quick_search_edit.clear()
25 self.quick_search_edit.setFocus()
26
27+ def on_advanced_clear_button_clicked(self):
28+ # The same as the on_clear_button_clicked, but gives focus to Book name field in "Select" (advanced).
29+ self.list_view.clear()
30+ self.check_search_result()
31+ self.advanced_book_combo_box.setFocus()
32+
33 def on_lock_button_toggled(self, checked):
34- self.quick_search_edit.setFocus()
35+ """
36+ Toggle the lock button, if Search tab is used, set focus to search field, if Select tab is used,
37+ give focus to Bible book name field.
38+ """
39 if checked:
40 self.sender().setIcon(self.lock_icon)
41 else:
42 self.sender().setIcon(self.unlock_icon)
43+ if self.quickTab.isVisible():
44+ self.quick_search_edit.setFocus()
45+ else:
46+ self.advanced_book_combo_box.setFocus()
47
48 def on_quick_style_combo_box_changed(self):
49 self.settings.layout_style = self.quickStyleComboBox.currentIndex()
50
51=== modified file 'tests/functional/openlp_plugins/bibles/test_mediaitem.py'
52--- tests/functional/openlp_plugins/bibles/test_mediaitem.py 2016-06-14 21:55:37 +0000
53+++ tests/functional/openlp_plugins/bibles/test_mediaitem.py 2016-08-20 19:00:29 +0000
54@@ -114,7 +114,7 @@
55 self.assertEqual(self.media_item.search_results, {})
56 self.assertEqual(self.media_item.second_search_results, {})
57
58- def on_quick_search_button_general_test(self):
59+ def test_on_quick_search_button_general(self):
60 """
61 Test that general things, which should be called on all Quick searches are called.
62 """
63@@ -150,3 +150,22 @@
64 self.assertEqual(2, self.media_item.quickSearchButton.setEnabled.call_count, 'Disable and Enable the button')
65 self.assertEqual(1, self.media_item.check_search_result.call_count, 'Check results Should had been called once')
66 self.assertEqual(1, self.app.set_normal_cursor.call_count, 'Normal cursor should had been called once')
67+
68+ def test_on_clear_button_clicked(self):
69+ """
70+ Test that the on_clear_button_clicked works properly. (Used by Bible search tab)
71+ """
72+
73+ # GIVEN: Mocked list_view, check_search_results & quick_search_edit.
74+ self.media_item.list_view = MagicMock()
75+ self.media_item.check_search_result = MagicMock()
76+ self.media_item.quick_search_edit = MagicMock()
77+
78+ # WHEN: on_clear_button_clicked is called
79+ self.media_item.on_clear_button_clicked()
80+
81+ # THEN: Search result should be reset and search field should receive focus.
82+ self.assertEqual(1, self.media_item.list_view.clear.call_count, 'List_view.clear should had been called once.')
83+ self.assertEqual(1, self.media_item.check_search_result.call_count, 'Check results Should had been called once')
84+ self.assertEqual(1, self.media_item.quick_search_edit.clear.call_count, 'Should had been called once')
85+ self.assertEqual(1, self.media_item.quick_search_edit.setFocus.call_count, 'Should had been called once')