Merge lp:~mikemc/ubuntuone-control-panel/fix-close-popup into lp:ubuntuone-control-panel

Proposed by Mike McCracken
Status: Merged
Approved by: Roberto Alsina
Approved revision: 403
Merged at revision: 401
Proposed branch: lp:~mikemc/ubuntuone-control-panel/fix-close-popup
Merge into: lp:ubuntuone-control-panel
Diff against target: 129 lines (+61/-3)
4 files modified
ubuntuone/controlpanel/gui/qt/controlpanel.py (+5/-0)
ubuntuone/controlpanel/gui/qt/share_links.py (+6/-1)
ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py (+42/-2)
ubuntuone/controlpanel/gui/qt/tests/test_share_links.py (+8/-0)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-control-panel/fix-close-popup
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
dobey (community) Approve
Review via email: mp+152782@code.launchpad.net

Commit message

- Work around Qt issue where search files popup frame was not hidden after switching to another tab. (LP: #1152388)

Description of the change

- Work around Qt issue where search files popup frame was not hidden after switching to another tab. (LP: #1152388)

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

Testable?

review: Needs Information
401. By Mike McCracken

- Add new test for Qt connections set up inside ControlPanel's init. Requires patching before testcase setUp, so duplicates some code from UbuntuOneBinTestCase.

402. By Mike McCracken

update copyrights

403. By Mike McCracken

add test for hiding popup in handle_current_tab_changed

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py'
2--- ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-10-18 21:45:05 +0000
3+++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2013-03-12 20:03:19 +0000
4@@ -79,6 +79,11 @@
5 self.ui.tab_widget.setTabText(
6 self.ui.tab_widget.indexOf(self.ui.share_links_tab),
7 MAIN_SHARE_LINKS_TAB)
8+
9+ # Workaround for bug LP: 1152388
10+ handler = self.ui.share_links_tab.handle_current_tab_changed
11+ self.ui.tab_widget.currentChanged.connect(handler)
12+
13 self.ui.tab_widget.setTabText(
14 self.ui.tab_widget.indexOf(self.ui.devices_tab), MAIN_DEVICES_TAB)
15 self.ui.tab_widget.setTabText(
16
17=== modified file 'ubuntuone/controlpanel/gui/qt/share_links.py'
18--- ubuntuone/controlpanel/gui/qt/share_links.py 2012-11-02 17:15:15 +0000
19+++ ubuntuone/controlpanel/gui/qt/share_links.py 2013-03-12 20:03:19 +0000
20@@ -1,6 +1,6 @@
21 # -*- coding: utf-8 *-*
22
23-# Copyright 2012 Canonical Ltd.
24+# Copyright 2012-2013 Canonical Ltd.
25 #
26 # This program is free software: you can redistribute it and/or modify it
27 # under the terms of the GNU General Public License version 3, as published
28@@ -107,6 +107,11 @@
29 self.get_public_files()
30 self._enhanced_line.btn_operation.hide()
31
32+ def handle_current_tab_changed(self, index):
33+ """Workaround for bug LP: 1152388"""
34+ self.ui.line_search.clearFocus()
35+ self.ui.line_search.popup.hide()
36+
37 @inlineCallbacks
38 def share_file(self, file_path):
39 """Clean the previous file share details and publish file_path."""
40
41=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py'
42--- ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2012-10-17 07:21:28 +0000
43+++ ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2013-03-12 20:03:19 +0000
44@@ -1,6 +1,6 @@
45 # -*- coding: utf-8 -*-
46 #
47-# Copyright 2011-2012 Canonical Ltd.
48+# Copyright 2011-2013 Canonical Ltd.
49 #
50 # This program is free software: you can redistribute it and/or modify it
51 # under the terms of the GNU General Public License version 3, as published
52@@ -19,10 +19,17 @@
53 from __future__ import division
54
55 from twisted.internet import defer
56+from PyQt4 import QtCore
57+
58+from ubuntuone.controlpanel import backend, cache
59+from ubuntuone.controlpanel.tests import TestCase
60+from mock import call, Mock
61+
62+from ubuntuone.controlpanel.gui.qt import share_links
63
64 from ubuntuone.controlpanel.gui.qt import controlpanel as gui
65 from ubuntuone.controlpanel.gui.qt.tests import (
66- SAMPLE_ACCOUNT_INFO, SAMPLE_NAME,
67+ FakedControlPanelBackend, SAMPLE_ACCOUNT_INFO, SAMPLE_NAME,
68 )
69 from ubuntuone.controlpanel.gui.qt.tests.test_ubuntuonebin import (
70 UbuntuOneBinTestCase,
71@@ -204,6 +211,39 @@
72 self.ui.ui.wizard.pages[self.ui.ui.wizard.license_page])
73
74
75+class ControlPanelConnectionTestCase(TestCase):
76+ """Test qt signal connections from controlpanel."""
77+
78+ @defer.inlineCallbacks
79+ def setUp(self):
80+ cache.Cache._shared_objects = {}
81+ yield super(ControlPanelConnectionTestCase, self).setUp()
82+ self.patch(backend, 'ControlBackend', FakedControlPanelBackend)
83+
84+ self.mock_handler = Mock(name='handle_current_tab_changed')
85+ self.patch(share_links.ShareLinksPanel, 'handle_current_tab_changed',
86+ self.mock_handler)
87+
88+ self.ui = gui.ControlPanel()
89+ self.ui.show()
90+ self.addCleanup(self.ui.hide)
91+ #self.addCleanup(self.ui.deleteLater)
92+ self.addCleanup(QtCore.QCoreApplication.instance().processEvents)
93+
94+ if getattr(self.ui, 'backend', None) is not None:
95+ self.addCleanup(self.ui.backend._called.clear)
96+
97+ def test_popup_hides_when_switching_tab(self):
98+ """Test that the share_links_tab gets the signal for changed tabs"""
99+ folders_index = self.ui.ui.tab_widget.indexOf(self.ui.ui.folders_tab)
100+ share_index = self.ui.ui.tab_widget.indexOf(self.ui.ui.share_links_tab)
101+ self.ui.ui.tab_widget.setCurrentIndex(share_index)
102+ self.ui.ui.tab_widget.setCurrentIndex(folders_index)
103+
104+ self.assertEqual(self.mock_handler.mock_calls,
105+ [call(share_index), call(folders_index)])
106+
107+
108 class ExternalLinkButtonsTestCase(ControlPanelTestCase):
109 """The link in the go-to-web buttons are correct."""
110
111
112=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_share_links.py'
113--- ubuntuone/controlpanel/gui/qt/tests/test_share_links.py 2012-11-02 17:15:15 +0000
114+++ ubuntuone/controlpanel/gui/qt/tests/test_share_links.py 2013-03-12 20:03:19 +0000
115@@ -254,6 +254,14 @@
116 os.path.basename(file_path))
117 self.assertEqual(widget.ui.lbl_path.text(), file_path)
118
119+ def test_hide_popup_on_tab_changed(self):
120+ """Test that the popup is hidden by the tab changed signal."""
121+
122+ self.ui.ui.line_search.popup.show()
123+ self.ui.handle_current_tab_changed(0)
124+ self.assertFalse(self.ui.ui.line_search.popup.isVisible())
125+ self.assertFalse(self.ui.ui.line_search.hasFocus())
126+
127
128 class ActionsButtonsTestCase(BaseTestCase):
129 """Test the Actions Buttons."""

Subscribers

People subscribed via source and target branches