Merge lp:~diegosarmentero/ubuntuone-control-panel/mouse-events into lp:ubuntuone-control-panel
- mouse-events
- Merge into trunk
Proposed by
Diego Sarmentero
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | dobey | ||||
Approved revision: | 362 | ||||
Merged at revision: | 361 | ||||
Proposed branch: | lp:~diegosarmentero/ubuntuone-control-panel/mouse-events | ||||
Merge into: | lp:ubuntuone-control-panel | ||||
Diff against target: |
312 lines (+101/-19) 6 files modified
ubuntuone/controlpanel/gui/qt/share_file.py (+7/-5) ubuntuone/controlpanel/gui/qt/share_links.py (+23/-9) ubuntuone/controlpanel/gui/qt/share_links_search.py (+14/-3) ubuntuone/controlpanel/gui/qt/tests/test_share_file.py (+5/-2) ubuntuone/controlpanel/gui/qt/tests/test_share_links.py (+18/-0) ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py (+34/-0) |
||||
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-control-panel/mouse-events | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Approve | ||
Roberto Alsina (community) | Approve | ||
Review via email: mp+126544@code.launchpad.net |
Commit message
- Popup list accept mouse events (LP: #1056192).
Description of the change
To post a comment you must log in.
- 361. By Diego Sarmentero
-
merge
Revision history for this message
dobey (dobey) wrote : | # |
I am getting a lot of WARNING output to console, and some other debug info, along with a couple of AssertionErrors, when running this from your branch. Running the installed version of control-panel I have, doesn't do this.
review:
Needs Fixing
- 362. By Diego Sarmentero
-
merge
Revision history for this message
dobey (dobey) : | # |
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/share_file.py' | |||
2 | --- ubuntuone/controlpanel/gui/qt/share_file.py 2012-08-27 15:00:01 +0000 | |||
3 | +++ ubuntuone/controlpanel/gui/qt/share_file.py 2012-09-28 20:31:21 +0000 | |||
4 | @@ -20,6 +20,8 @@ | |||
5 | 20 | 20 | ||
6 | 21 | from PyQt4 import QtGui, QtCore | 21 | from PyQt4 import QtGui, QtCore |
7 | 22 | 22 | ||
8 | 23 | from ubuntuone.platform import expand_user | ||
9 | 24 | |||
10 | 23 | from ubuntuone.controlpanel import cache | 25 | from ubuntuone.controlpanel import cache |
11 | 24 | from ubuntuone.controlpanel.gui.qt.share_links_search import ( | 26 | from ubuntuone.controlpanel.gui.qt.share_links_search import ( |
12 | 25 | get_system_icon_for_filename, | 27 | get_system_icon_for_filename, |
13 | @@ -40,11 +42,12 @@ | |||
14 | 40 | super(ShareFileWidget, self).__init__(*args, **kwargs) | 42 | super(ShareFileWidget, self).__init__(*args, **kwargs) |
15 | 41 | self.ui = share_file_ui.Ui_Form() | 43 | self.ui = share_file_ui.Ui_Form() |
16 | 42 | self.ui.setupUi(self) | 44 | self.ui.setupUi(self) |
18 | 43 | self.file_path = file_path | 45 | full_path = expand_user(file_path.encode('utf-8')) |
19 | 46 | self.file_path = full_path.decode('utf-8') | ||
20 | 44 | 47 | ||
21 | 45 | self.ui.lbl_filename.setText(os.path.basename(file_path)) | 48 | self.ui.lbl_filename.setText(os.path.basename(file_path)) |
22 | 46 | self.ui.lbl_path.setText(file_path) | 49 | self.ui.lbl_path.setText(file_path) |
24 | 47 | icon = get_system_icon_for_filename(os.path.expanduser(file_path)) | 50 | icon = get_system_icon_for_filename(full_path) |
25 | 48 | pixmap = icon.pixmap(24) | 51 | pixmap = icon.pixmap(24) |
26 | 49 | self.ui.lbl_icon.setPixmap(pixmap) | 52 | self.ui.lbl_icon.setPixmap(pixmap) |
27 | 50 | 53 | ||
28 | @@ -53,11 +56,10 @@ | |||
29 | 53 | 56 | ||
30 | 54 | def open_file(self): | 57 | def open_file(self): |
31 | 55 | """Open the specified file.""" | 58 | """Open the specified file.""" |
33 | 56 | path = u'file://%s' % self.file_path | 59 | path = 'file://%s' % self.file_path |
34 | 57 | QtGui.QDesktopServices.openUrl(QtCore.QUrl(path)) | 60 | QtGui.QDesktopServices.openUrl(QtCore.QUrl(path)) |
35 | 58 | 61 | ||
36 | 59 | def disable_link(self, val): | 62 | def disable_link(self, val): |
37 | 60 | """Change the access of the file to Not Public.""" | 63 | """Change the access of the file to Not Public.""" |
40 | 61 | self.backend.change_public_access( | 64 | self.backend.change_public_access(self.file_path, False) |
39 | 62 | os.path.expanduser(self.file_path), False) | ||
41 | 63 | self.linkDisabled.emit() | 65 | self.linkDisabled.emit() |
42 | 64 | 66 | ||
43 | === modified file 'ubuntuone/controlpanel/gui/qt/share_links.py' | |||
44 | --- ubuntuone/controlpanel/gui/qt/share_links.py 2012-08-27 15:00:01 +0000 | |||
45 | +++ ubuntuone/controlpanel/gui/qt/share_links.py 2012-09-28 20:31:21 +0000 | |||
46 | @@ -21,6 +21,8 @@ | |||
47 | 21 | from PyQt4 import QtGui, QtCore | 21 | from PyQt4 import QtGui, QtCore |
48 | 22 | from twisted.internet.defer import inlineCallbacks | 22 | from twisted.internet.defer import inlineCallbacks |
49 | 23 | 23 | ||
50 | 24 | from ubuntuone.platform import expand_user | ||
51 | 25 | |||
52 | 24 | from ubuntuone.controlpanel.logger import setup_logging | 26 | from ubuntuone.controlpanel.logger import setup_logging |
53 | 25 | from ubuntuone.controlpanel.gui import ( | 27 | from ubuntuone.controlpanel.gui import ( |
54 | 26 | COPY_LINK, | 28 | COPY_LINK, |
55 | @@ -57,6 +59,7 @@ | |||
56 | 57 | logger = logger | 59 | logger = logger |
57 | 58 | _enhanced_line = None | 60 | _enhanced_line = None |
58 | 59 | home_dir = '' | 61 | home_dir = '' |
59 | 62 | _shared_files = {} | ||
60 | 60 | 63 | ||
61 | 61 | def _setup(self): | 64 | def _setup(self): |
62 | 62 | """Do some extra setupping for the UI.""" | 65 | """Do some extra setupping for the UI.""" |
63 | @@ -91,17 +94,26 @@ | |||
64 | 91 | @inlineCallbacks | 94 | @inlineCallbacks |
65 | 92 | def share_file(self, file_path): | 95 | def share_file(self, file_path): |
66 | 93 | """Clean the previous file share details and publish file_path.""" | 96 | """Clean the previous file share details and publish file_path.""" |
67 | 97 | file_path = unicode(file_path) | ||
68 | 94 | if self.ui.hbox_share_file.count() > 0: | 98 | if self.ui.hbox_share_file.count() > 0: |
69 | 95 | widget = self.ui.hbox_share_file.takeAt(0).widget() | 99 | widget = self.ui.hbox_share_file.takeAt(0).widget() |
70 | 96 | widget.close() | 100 | widget.close() |
79 | 97 | self.is_processing = True | 101 | full_path = expand_user(file_path.encode('utf-8')).decode('utf-8') |
80 | 98 | file_path = unicode(file_path) | 102 | if full_path not in self._shared_files: |
81 | 99 | share_file_widget = ShareFileWidget(file_path) | 103 | self.is_processing = True |
82 | 100 | self.ui.hbox_share_file.addWidget(share_file_widget) | 104 | share_file_widget = ShareFileWidget(file_path) |
83 | 101 | share_file_widget.linkDisabled.connect( | 105 | self.ui.hbox_share_file.addWidget(share_file_widget) |
84 | 102 | lambda: self.ui.line_copy_link.setText('')) | 106 | share_file_widget.linkDisabled.connect( |
85 | 103 | yield self.backend.change_public_access( | 107 | lambda: self.ui.line_copy_link.setText('')) |
86 | 104 | os.path.expanduser(file_path), True) | 108 | yield self.backend.change_public_access( |
87 | 109 | full_path, True) | ||
88 | 110 | else: | ||
89 | 111 | share_file_widget = ShareFileWidget(file_path) | ||
90 | 112 | self.ui.hbox_share_file.addWidget(share_file_widget) | ||
91 | 113 | share_file_widget.linkDisabled.connect( | ||
92 | 114 | lambda: self.ui.line_copy_link.setText('')) | ||
93 | 115 | self.ui.line_copy_link.setText(self._shared_files[full_path]) | ||
94 | 116 | self.ui.stacked_widget.setCurrentIndex(1) | ||
95 | 105 | 117 | ||
96 | 106 | def _file_shared(self, info): | 118 | def _file_shared(self, info): |
97 | 107 | """Receive the notification that the file has been published.""" | 119 | """Receive the notification that the file has been published.""" |
98 | @@ -135,17 +147,19 @@ | |||
99 | 135 | def _load_public_files(self, publicfiles): | 147 | def _load_public_files(self, publicfiles): |
100 | 136 | """Load the list of public files.""" | 148 | """Load the list of public files.""" |
101 | 137 | self.ui.tree_shared_files.clear() | 149 | self.ui.tree_shared_files.clear() |
102 | 150 | self._shared_files = {} | ||
103 | 138 | for pfile in publicfiles: | 151 | for pfile in publicfiles: |
104 | 139 | item = QtGui.QTreeWidgetItem() | 152 | item = QtGui.QTreeWidgetItem() |
105 | 140 | path = pfile['path'] | 153 | path = pfile['path'] |
106 | 141 | public_url = pfile['public_url'] | 154 | public_url = pfile['public_url'] |
107 | 155 | self._shared_files[path] = public_url | ||
108 | 142 | name = os.path.basename(path) | 156 | name = os.path.basename(path) |
109 | 143 | item.setText(FILE_NAME_COL, name) | 157 | item.setText(FILE_NAME_COL, name) |
110 | 144 | tooltip = path | 158 | tooltip = path |
111 | 145 | if tooltip.startswith(self.home_dir): | 159 | if tooltip.startswith(self.home_dir): |
112 | 146 | tooltip = tooltip.replace(self.home_dir, '~', 1) | 160 | tooltip = tooltip.replace(self.home_dir, '~', 1) |
113 | 147 | item.setToolTip(FILE_NAME_COL, tooltip) | 161 | item.setToolTip(FILE_NAME_COL, tooltip) |
115 | 148 | icon = get_system_icon_for_filename(path) | 162 | icon = get_system_icon_for_filename(path.encode('utf-8')) |
116 | 149 | item.setIcon(FILE_NAME_COL, icon) | 163 | item.setIcon(FILE_NAME_COL, icon) |
117 | 150 | 164 | ||
118 | 151 | self.ui.tree_shared_files.setColumnWidth(PUBLIC_LINK_COL, 300) | 165 | self.ui.tree_shared_files.setColumnWidth(PUBLIC_LINK_COL, 300) |
119 | 152 | 166 | ||
120 | === modified file 'ubuntuone/controlpanel/gui/qt/share_links_search.py' | |||
121 | --- ubuntuone/controlpanel/gui/qt/share_links_search.py 2012-09-14 20:23:13 +0000 | |||
122 | +++ ubuntuone/controlpanel/gui/qt/share_links_search.py 2012-09-28 20:31:21 +0000 | |||
123 | @@ -21,6 +21,8 @@ | |||
124 | 21 | from PyQt4 import QtGui, QtCore | 21 | from PyQt4 import QtGui, QtCore |
125 | 22 | from twisted.internet.defer import inlineCallbacks | 22 | from twisted.internet.defer import inlineCallbacks |
126 | 23 | 23 | ||
127 | 24 | from ubuntuone.platform import expand_user | ||
128 | 25 | |||
129 | 24 | from ubuntuone.controlpanel import cache | 26 | from ubuntuone.controlpanel import cache |
130 | 25 | from ubuntuone.controlpanel.logger import setup_logging | 27 | from ubuntuone.controlpanel.logger import setup_logging |
131 | 26 | 28 | ||
132 | @@ -29,7 +31,7 @@ | |||
133 | 29 | 31 | ||
134 | 30 | def get_system_icon_for_filename(file_path): | 32 | def get_system_icon_for_filename(file_path): |
135 | 31 | """Return the icon used for the system to represent this file.""" | 33 | """Return the icon used for the system to represent this file.""" |
137 | 32 | fileinfo = QtCore.QFileInfo(os.path.expanduser(file_path)) | 34 | fileinfo = QtCore.QFileInfo(expand_user(file_path)) |
138 | 33 | icon_provider = QtGui.QFileIconProvider() | 35 | icon_provider = QtGui.QFileIconProvider() |
139 | 34 | icon = icon_provider.icon(fileinfo) | 36 | icon = icon_provider.icon(fileinfo) |
140 | 35 | return icon | 37 | return icon |
141 | @@ -65,10 +67,19 @@ | |||
142 | 65 | QtCore.Qt.Key_Enter: self._key_return_pressed, | 67 | QtCore.Qt.Key_Enter: self._key_return_pressed, |
143 | 66 | } | 68 | } |
144 | 67 | 69 | ||
145 | 70 | self.popup.list_widget.itemPressed.connect(self._set_selected_item) | ||
146 | 71 | self.popup.list_widget.verticalScrollBar().valueChanged.connect( | ||
147 | 72 | self._scroll_fetch_more) | ||
148 | 68 | self.textChanged.connect(self.filter) | 73 | self.textChanged.connect(self.filter) |
149 | 69 | 74 | ||
150 | 70 | self._get_volumes_info() | 75 | self._get_volumes_info() |
151 | 71 | 76 | ||
152 | 77 | def _scroll_fetch_more(self, value): | ||
153 | 78 | """Fetch more items into the list on scroll.""" | ||
154 | 79 | if self.popup.list_widget.verticalScrollBar().maximum() == value: | ||
155 | 80 | filenames = self._get_filtered_list(self.temp_u1_files) | ||
156 | 81 | self.popup.fetch_more(filenames) | ||
157 | 82 | |||
158 | 72 | @inlineCallbacks | 83 | @inlineCallbacks |
159 | 73 | def _get_volumes_info(self): | 84 | def _get_volumes_info(self): |
160 | 74 | """Get the volumes info.""" | 85 | """Get the volumes info.""" |
161 | @@ -260,7 +271,7 @@ | |||
162 | 260 | file_widget = FileItem(file_) | 271 | file_widget = FileItem(file_) |
163 | 261 | self.list_widget.addItem(item) | 272 | self.list_widget.addItem(item) |
164 | 262 | self.list_widget.setItemWidget(item, file_widget) | 273 | self.list_widget.setItemWidget(item, file_widget) |
166 | 263 | icon = get_system_icon_for_filename(file_) | 274 | icon = get_system_icon_for_filename(file_.encode('utf-8')) |
167 | 264 | item.setIcon(icon) | 275 | item.setIcon(icon) |
168 | 265 | if file_items: | 276 | if file_items: |
169 | 266 | self.list_widget.setCurrentRow(0) | 277 | self.list_widget.setCurrentRow(0) |
170 | @@ -272,7 +283,7 @@ | |||
171 | 272 | file_widget = FileItem(file_) | 283 | file_widget = FileItem(file_) |
172 | 273 | self.list_widget.addItem(item) | 284 | self.list_widget.addItem(item) |
173 | 274 | self.list_widget.setItemWidget(item, file_widget) | 285 | self.list_widget.setItemWidget(item, file_widget) |
175 | 275 | icon = get_system_icon_for_filename(file_) | 286 | icon = get_system_icon_for_filename(file_.encode('utf-8')) |
176 | 276 | item.setIcon(icon) | 287 | item.setIcon(icon) |
177 | 277 | 288 | ||
178 | 278 | def showEvent(self, event): | 289 | def showEvent(self, event): |
179 | 279 | 290 | ||
180 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_share_file.py' | |||
181 | --- ubuntuone/controlpanel/gui/qt/tests/test_share_file.py 2012-08-28 00:32:41 +0000 | |||
182 | +++ ubuntuone/controlpanel/gui/qt/tests/test_share_file.py 2012-09-28 20:31:21 +0000 | |||
183 | @@ -20,6 +20,8 @@ | |||
184 | 20 | 20 | ||
185 | 21 | from PyQt4 import QtGui, QtCore | 21 | from PyQt4 import QtGui, QtCore |
186 | 22 | 22 | ||
187 | 23 | from ubuntuone.platform import expand_user | ||
188 | 24 | |||
189 | 23 | from ubuntuone.controlpanel.gui.qt import share_file as gui | 25 | from ubuntuone.controlpanel.gui.qt import share_file as gui |
190 | 24 | from ubuntuone.controlpanel.gui.qt.tests import ( | 26 | from ubuntuone.controlpanel.gui.qt.tests import ( |
191 | 25 | BaseTestCase, | 27 | BaseTestCase, |
192 | @@ -54,7 +56,7 @@ | |||
193 | 54 | self.patch(QtGui, "QDesktopServices", fake_desktop_service) | 56 | self.patch(QtGui, "QDesktopServices", fake_desktop_service) |
194 | 55 | self.ui.ui.btn_open.click() | 57 | self.ui.ui.btn_open.click() |
195 | 56 | 58 | ||
197 | 57 | expected = QtCore.QUrl(u'file://%s' % self.file_path) | 59 | expected = QtCore.QUrl('file://%s' % self.file_path) |
198 | 58 | self.assertEqual(expected, fake_desktop_service.opened_url) | 60 | self.assertEqual(expected, fake_desktop_service.opened_url) |
199 | 59 | 61 | ||
200 | 60 | def test_disable_link(self): | 62 | def test_disable_link(self): |
201 | @@ -71,6 +73,7 @@ | |||
202 | 71 | fake_change_access) | 73 | fake_change_access) |
203 | 72 | self.ui.ui.btn_disable.click() | 74 | self.ui.ui.btn_disable.click() |
204 | 73 | 75 | ||
206 | 74 | expected = [os.path.expanduser(self.file_path), False] | 76 | expected = [expand_user( |
207 | 77 | self.file_path.encode('utf-8')).decode('utf-8'), False] | ||
208 | 75 | self.assertEqual(data, expected) | 78 | self.assertEqual(data, expected) |
209 | 76 | self.assertEqual(self._called, ((), {})) | 79 | self.assertEqual(self._called, ((), {})) |
210 | 77 | 80 | ||
211 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_share_links.py' | |||
212 | --- ubuntuone/controlpanel/gui/qt/tests/test_share_links.py 2012-08-28 00:32:41 +0000 | |||
213 | +++ ubuntuone/controlpanel/gui/qt/tests/test_share_links.py 2012-09-28 20:31:21 +0000 | |||
214 | @@ -78,6 +78,24 @@ | |||
215 | 78 | self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 1) | 78 | self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 1) |
216 | 79 | self.assertFalse(self.ui.is_processing) | 79 | self.assertFalse(self.ui.is_processing) |
217 | 80 | 80 | ||
218 | 81 | def test_file_already_shared(self): | ||
219 | 82 | """Check the behavior of the widgets when there is a shared file.""" | ||
220 | 83 | data = [] | ||
221 | 84 | |||
222 | 85 | def fake_method(self, *args): | ||
223 | 86 | """Fake callback.""" | ||
224 | 87 | data.append((args)) | ||
225 | 88 | |||
226 | 89 | self.patch(self.ui.backend, "change_public_access", fake_method) | ||
227 | 90 | path = '/home/user/Ubuntu One/file1.txt' | ||
228 | 91 | shared = { | ||
229 | 92 | '/home/user/Ubuntu One/file1.txt': 'http://ubuntuone.com/asd123'} | ||
230 | 93 | self.ui._shared_files = shared | ||
231 | 94 | self.ui.share_file(path) | ||
232 | 95 | self.assertEqual(self.ui.ui.line_copy_link.text(), shared[path]) | ||
233 | 96 | self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 1) | ||
234 | 97 | self.assertEqual(data, []) | ||
235 | 98 | |||
236 | 81 | def test_open_in_browser(self): | 99 | def test_open_in_browser(self): |
237 | 82 | """Test the execution of open_in_browser.""" | 100 | """Test the execution of open_in_browser.""" |
238 | 83 | fake_desktop_service = FakeDesktopService() | 101 | fake_desktop_service = FakeDesktopService() |
239 | 84 | 102 | ||
240 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py' | |||
241 | --- ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py 2012-09-24 17:56:23 +0000 | |||
242 | +++ ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py 2012-09-28 20:31:21 +0000 | |||
243 | @@ -18,6 +18,7 @@ | |||
244 | 18 | 18 | ||
245 | 19 | import os | 19 | import os |
246 | 20 | 20 | ||
247 | 21 | from dirspec import utils | ||
248 | 21 | from twisted.internet import defer | 22 | from twisted.internet import defer |
249 | 22 | 23 | ||
250 | 23 | from ubuntuone.controlpanel.gui.tests import USER_HOME | 24 | from ubuntuone.controlpanel.gui.tests import USER_HOME |
251 | @@ -27,6 +28,7 @@ | |||
252 | 27 | 28 | ||
253 | 28 | # pylint: disable=W0212 | 29 | # pylint: disable=W0212 |
254 | 29 | 30 | ||
255 | 31 | |||
256 | 30 | class SearchBoxTestCase(BaseTestCase): | 32 | class SearchBoxTestCase(BaseTestCase): |
257 | 31 | """Test the qt control panel.""" | 33 | """Test the qt control panel.""" |
258 | 32 | 34 | ||
259 | @@ -36,6 +38,7 @@ | |||
260 | 36 | def setUp(self): | 38 | def setUp(self): |
261 | 37 | yield super(SearchBoxTestCase, self).setUp() | 39 | yield super(SearchBoxTestCase, self).setUp() |
262 | 38 | 40 | ||
263 | 41 | self.patch(utils, "user_home", USER_HOME) | ||
264 | 39 | self.patch(self.ui._thread_explore, "get_folder_info", | 42 | self.patch(self.ui._thread_explore, "get_folder_info", |
265 | 40 | self.fake_get_folder_info) | 43 | self.fake_get_folder_info) |
266 | 41 | self.patch(self.ui._thread_explore, "start", | 44 | self.patch(self.ui._thread_explore, "start", |
267 | @@ -52,6 +55,11 @@ | |||
268 | 52 | os.path.join(USER_HOME, 'blabla', 'iop'), | 55 | os.path.join(USER_HOME, 'blabla', 'iop'), |
269 | 53 | ] | 56 | ] |
270 | 54 | } | 57 | } |
271 | 58 | self._slot_item = None | ||
272 | 59 | |||
273 | 60 | def fake_slot(self, item): | ||
274 | 61 | """Fake function to be called when itemSelected is emitted.""" | ||
275 | 62 | self._slot_item = item | ||
276 | 55 | 63 | ||
277 | 56 | def fake_get_folder_info(self, folder): | 64 | def fake_get_folder_info(self, folder): |
278 | 57 | """Fake get_folder_info.""" | 65 | """Fake get_folder_info.""" |
279 | @@ -132,7 +140,33 @@ | |||
280 | 132 | self.ui._process_volumes_info([(0, 0, data1), (0, 0, data2)]) | 140 | self.ui._process_volumes_info([(0, 0, data1), (0, 0, data2)]) |
281 | 133 | self.ui.popup.list_widget.setCurrentRow(1) | 141 | self.ui.popup.list_widget.setCurrentRow(1) |
282 | 134 | current = self.ui.popup.list_widget.currentRow() | 142 | current = self.ui.popup.list_widget.currentRow() |
283 | 143 | self.ui.itemSelected.connect(self.fake_slot) | ||
284 | 135 | self.ui._key_return_pressed(current) | 144 | self.ui._key_return_pressed(current) |
285 | 145 | expected = unicode(self._slot_item).replace('~', USER_HOME) | ||
286 | 146 | self.assertEqual(expected, self.folder_info['folder2'][2]) | ||
287 | 147 | |||
288 | 148 | def test_mouse_click_pressed(self): | ||
289 | 149 | """Check the proper actions are executed when click is pressed.""" | ||
290 | 150 | data1 = [{'path': 'folder1'}] | ||
291 | 151 | data2 = [{'realpath': 'folder2'}] | ||
292 | 152 | self.ui._process_volumes_info([(0, 0, data1), (0, 0, data2)]) | ||
293 | 153 | self.ui.popup.list_widget.setCurrentRow(1) | ||
294 | 154 | current = self.ui.popup.list_widget.currentItem() | ||
295 | 155 | self.ui.itemSelected.connect(self.fake_slot) | ||
296 | 156 | self.ui.popup.list_widget.itemPressed.emit(current) | ||
297 | 157 | expected = unicode(self._slot_item).replace('~', USER_HOME) | ||
298 | 158 | self.assertEqual(expected, self.folder_info['folder2'][2]) | ||
299 | 159 | |||
300 | 160 | def test_mouse_scroll(self): | ||
301 | 161 | """Check that fetch_more is called when we reach the end of scroll.""" | ||
302 | 162 | data1 = [{'path': 'folder1'}] | ||
303 | 163 | data2 = [{'realpath': 'folder2'}] | ||
304 | 164 | self.ui._process_volumes_info([(0, 0, data1), (0, 0, data2)]) | ||
305 | 165 | self.patch(self.ui.popup, "fetch_more", self._set_called) | ||
306 | 166 | self.ui._scroll_fetch_more( | ||
307 | 167 | self.ui.popup.list_widget.verticalScrollBar().maximum()) | ||
308 | 168 | expected = (([],), {}) | ||
309 | 169 | self.assertEqual(expected, self._called) | ||
310 | 136 | 170 | ||
311 | 137 | def test_key_space_pressed(self): | 171 | def test_key_space_pressed(self): |
312 | 138 | """Check the proper actions are executed on key space pressed.""" | 172 | """Check the proper actions are executed on key space pressed.""" |
looks good!