Merge lp:~diegosarmentero/ubuntuone-control-panel/new-share-design into lp:ubuntuone-control-panel

Proposed by Diego Sarmentero
Status: Merged
Approved by: dobey
Approved revision: 382
Merged at revision: 376
Proposed branch: lp:~diegosarmentero/ubuntuone-control-panel/new-share-design
Merge into: lp:ubuntuone-control-panel
Prerequisite: lp:~diegosarmentero/ubuntuone-control-panel/search-shared-files
Diff against target: 943 lines (+418/-114)
8 files modified
data/qt/images.qrc (+1/-0)
data/qt/share_links.ui (+175/-20)
data/qt/ubuntuone.qss (+1/-1)
ubuntuone/controlpanel/gui/__init__.py (+7/-1)
ubuntuone/controlpanel/gui/qt/share_links.py (+84/-15)
ubuntuone/controlpanel/gui/qt/share_links_search.py (+52/-32)
ubuntuone/controlpanel/gui/qt/tests/test_share_links.py (+51/-4)
ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py (+47/-41)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-control-panel/new-share-design
Reviewer Review Type Date Requested Status
dobey (community) Approve
Brian Curtin (community) Approve
Michał Karnicki (community) Approve
Review via email: mp+131397@code.launchpad.net

Commit message

- Implementing new share tab design (LP: #1065194, #1056194).

Description of the change

As this branch has as prerequisite: p:~diegosarmentero/ubuntuone-control-panel/search-shared-files

You will need to have ubuntuone-client up to date (with this change: https://code.launchpad.net/~diegosarmentero/ubuntuone-client/search-filter/+merge/130862) to test it IRL.

And now this works like this (with a few ui improves that are not included in the video):
http://youtu.be/x7b3Z2r7SRQ

If you see the following lint issue:
== Python Lint Notices ==

ubuntuone/controlpanel/sd_client/__init__.py:
    235: [E1101, SyncDaemonClient.search_files] Instance of 'SyncDaemonTool' has no 'search_files' member

You will need to add the u1-client branch mentioned to the path when running the tests.

To post a comment you must log in.
Revision history for this message
Michał Karnicki (karni) wrote :

Hardcoded value at
386 + self.ui.stacked_widget.setCurrentIndex(2)
could be replaced by a constant, that tells its meaning.

Hardcoded values at
515 + increment = 2 if current == 0 else 1
tell me little about what they mean. Unless this is obvious for Qt developers, fix with constants.

Quite a few constants in the tests make me think they are very sensitive to test data set changes.

Other than that, looks good.

review: Approve
Revision history for this message
Michał Karnicki (karni) :
review: Approve
Revision history for this message
Brian Curtin (brian.curtin) wrote :

420 + if len(results) > 0:

I think this if/else should go above the result iteration, not after it. If we have no results, do the hide, otherwise iterate over the results and then show them. It doesn't change the operation, it just reads a bit better IMO.

439 + def __init__(self, path, link, both_buttons=True, parent=None):

If we're adding an argument (both_buttons), shouldn't the new one go at the end?

I'm running IRL and tests on Windows right now.

review: Needs Fixing
Revision history for this message
Mike McCracken (mikemc) wrote :

This is a big improvement! I'd like to suggest that the string PUBLISH_THESE_FILES should be singular - you can only select one file to publish, right?
So "Publish these files" seems strange - maybe a better call to action is "Select a file to publish:" or something like that.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

I reported https://bugs.launchpad.net/ubuntuone-control-panel/+bug/1073660 while testing this, but it's unrelated to the functionality here.

Approved. Tests and IRL pass on Windows.

review: Approve
Revision history for this message
dobey (dobey) wrote :

I'm wondering if we should land this yet, as the changes in wording and such do present similar concerns as the ones I've raised on your other 2 related branches.

review: Needs Information
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0, Needs Fixing == 0, Needs Information == 0, Resubmit == 0, Pending == 0. Got: 2 Approve, 1 Needs Information.

Revision history for this message
dobey (dobey) wrote :

21 + <string>Search and Share files</string>
281 +SEARCH_FILES = _('Search and Share files')

These need to be sentence case ('share' should be lowercase). http://developer.gnome.org/hig-book/stable/design-text-labels.html.en#layout-capitalization

274 +PUBLISH_FILE = _('Publish file')
275 +PUBLISH_THESE_FILES = _('Select a file to publish:"')

Presumably we should not use the term 'publish' here.

684 + publicfiles = [
685 + {'path': '/home/file1', 'public_url': 'http:ubuntuone.com/asd123'},
686 + {'path': '/home/file2', 'public_url': 'http:ubuntuone.com/qwe456'},
687 + ]

744 + results = ['/home/file1', '/home/file2']

934 + items = [
935 + '/home/tester/file1',
936 + '/home/tester/file2',
937 + '/home/tester/file3',
938 + ]

Should these 3 sets of filenames in tests not be created with os.path.join() instead, for cross-platform happiness? Should it also not use the $HOME (the user_home from dirspec), here?

review: Needs Fixing
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> 21 + <string>Search and Share files</string>
> 281 +SEARCH_FILES = _('Search and Share files')
>
> These need to be sentence case ('share' should be lowercase).
> http://developer.gnome.org/hig-book/stable/design-text-labels.html.en#layout-
> capitalization

Fixed

>
> 274 +PUBLISH_FILE = _('Publish file')
> 275 +PUBLISH_THESE_FILES = _('Select a file to publish:"')
>
> Presumably we should not use the term 'publish' here.

Fixed

>
> 684 + publicfiles = [
> 685 + {'path': '/home/file1', 'public_url': 'http:ubuntuone.com/asd123'},
> 686 + {'path': '/home/file2', 'public_url': 'http:ubuntuone.com/qwe456'},
> 687 + ]
>
> 744 + results = ['/home/file1', '/home/file2']
>
> 934 + items = [
> 935 + '/home/tester/file1',
> 936 + '/home/tester/file2',
> 937 + '/home/tester/file3',
> 938 + ]
>
> Should these 3 sets of filenames in tests not be created with os.path.join()
> instead, for cross-platform happiness? Should it also not use the $HOME (the
> user_home from dirspec), here?

I don't see the need, they are just dummy values to see that the ui is loaded properly when that data structure is received.

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (164.2 KiB)

The attempt to merge lp:~diegosarmentero/ubuntuone-control-panel/new-share-design into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.

*** Running DBus test suite ***
ubuntuone.controlpanel.dbustests.test_dbus_service
  BaseTestCase
    runTest ... [OK]
  DBusServiceMainTestCase
    test_dbus_service_cant_register ... Control panel backend already running.
                                   [OK]
    test_dbus_service_main ... [OK]
  DBusServiceTestCase
    test_cant_register_twice ... [SKIPPED]
    test_dbus_busname_created ... [OK]
    test_error_handler_default ... [OK]
    test_error_handler_with_exception ... [OK]
    test_error_handler_with_failure ... [OK]
    test_error_handler_with_non_string_dict ... [OK]
    test_error_handler_with_string_dict ... [OK]
    test_register_service ... [OK]
  FileSyncTestCase
    test_file_sync_status_changed ... [OK]
    test_file_sync_status_disabled ... [OK]
    test_file_sync_status_disconnected ... [OK]
    test_file_sync_status_error ... [OK]
    test_file_sync_status_idle ... [OK]
    test_file_sync_status_starting ... [OK]
    test_file_sync_status_stopped ... [OK]
    test_file_sync_status_syncing ... [OK]
    test_file_sync_status_unknown ... [OK]
    test_status_changed_handler ... [OK]
    test_status_changed_handler_after_status_requested ... [OK]
    test_status_changed_handler_after_status_requested_twice ... [OK]
  OperationsAuthErrorTestCase
    test_account_info_returned ... [OK]
    test_change_device_settings ... [OK]
    test_change_replication_settings ... [OK]
    test_change_volume_settings ... [OK]
    test_connect_files ... [OK]
    test_devices_info_returned ... [OK]
    test_disable_files ... [OK]
    test_disconnect_files ... [OK]
    test_enable_files ... [OK]
    test_remove_device ... [OK]
    test_replications_info ... [OK]
    test_restart_files ... [OK]
...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (168.4 KiB)

The attempt to merge lp:~diegosarmentero/ubuntuone-control-panel/new-share-design into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.

*** Running DBus test suite ***
ubuntuone.controlpanel.dbustests.test_dbus_service
  BaseTestCase
    runTest ... [OK]
  DBusServiceMainTestCase
    test_dbus_service_cant_register ... Control panel backend already running.
                                   [OK]
    test_dbus_service_main ... [OK]
  DBusServiceTestCase
    test_cant_register_twice ... [SKIPPED]
    test_dbus_busname_created ... [OK]
    test_error_handler_default ... [OK]
    test_error_handler_with_exception ... [OK]
    test_error_handler_with_failure ... [OK]
    test_error_handler_with_non_string_dict ... [OK]
    test_error_handler_with_string_dict ... [OK]
    test_register_service ... [OK]
  FileSyncTestCase
    test_file_sync_status_changed ... [OK]
    test_file_sync_status_disabled ... [OK]
    test_file_sync_status_disconnected ... [OK]
    test_file_sync_status_error ... [OK]
    test_file_sync_status_idle ... [OK]
    test_file_sync_status_starting ... [OK]
    test_file_sync_status_stopped ... [OK]
    test_file_sync_status_syncing ... [OK]
    test_file_sync_status_unknown ... [OK]
    test_status_changed_handler ... [OK]
    test_status_changed_handler_after_status_requested ... [OK]
    test_status_changed_handler_after_status_requested_twice ... [OK]
  OperationsAuthErrorTestCase
    test_account_info_returned ... [OK]
    test_change_device_settings ... [OK]
    test_change_replication_settings ... [OK]
    test_change_volume_settings ... [OK]
    test_connect_files ... [OK]
    test_devices_info_returned ... [OK]
    test_disable_files ... [OK]
    test_disconnect_files ... [OK]
    test_enable_files ... [OK]
    test_remove_device ... [OK]
    test_replications_info ... [OK]
    test_restart_files ... [OK]
...

381. By Diego Sarmentero

merge

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

Fixed merge problem.

382. By Diego Sarmentero

fixing pep8 issues

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/qt/images.qrc'
2--- data/qt/images.qrc 2012-08-23 19:01:10 +0000
3+++ data/qt/images.qrc 2012-11-02 13:27:26 +0000
4@@ -26,6 +26,7 @@
5 <file>../twitter.png</file>
6 <file>../facebook.png</file>
7 <file>../delete_search.png</file>
8+ <file>../search.png</file>
9 <file>../Ubuntu-R.ttf</file>
10 <file>../Ubuntu-B.ttf</file>
11 <file>ubuntuone.qss</file>
12
13=== modified file 'data/qt/share_links.ui'
14--- data/qt/share_links.ui 2012-08-23 19:01:10 +0000
15+++ data/qt/share_links.ui 2012-11-02 13:27:26 +0000
16@@ -59,28 +59,73 @@
17 </font>
18 </property>
19 <property name="text">
20- <string>Search files</string>
21+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search and share files&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
22 </property>
23 </widget>
24 </item>
25 <item>
26- <widget class="SearchBox" name="line_search">
27- <property name="sizePolicy">
28- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
29- <horstretch>0</horstretch>
30- <verstretch>0</verstretch>
31- </sizepolicy>
32- </property>
33- <property name="maximumSize">
34- <size>
35- <width>400</width>
36- <height>16777215</height>
37- </size>
38- </property>
39- <property name="frame">
40- <bool>true</bool>
41- </property>
42- </widget>
43+ <layout class="QHBoxLayout" name="horizontalLayout_5">
44+ <property name="spacing">
45+ <number>0</number>
46+ </property>
47+ <item>
48+ <widget class="SearchBox" name="line_search">
49+ <property name="sizePolicy">
50+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
51+ <horstretch>0</horstretch>
52+ <verstretch>0</verstretch>
53+ </sizepolicy>
54+ </property>
55+ <property name="minimumSize">
56+ <size>
57+ <width>450</width>
58+ <height>0</height>
59+ </size>
60+ </property>
61+ <property name="maximumSize">
62+ <size>
63+ <width>400</width>
64+ <height>16777215</height>
65+ </size>
66+ </property>
67+ <property name="frame">
68+ <bool>true</bool>
69+ </property>
70+ </widget>
71+ </item>
72+ <item>
73+ <widget class="QPushButton" name="btn_search">
74+ <property name="sizePolicy">
75+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
76+ <horstretch>0</horstretch>
77+ <verstretch>0</verstretch>
78+ </sizepolicy>
79+ </property>
80+ <property name="maximumSize">
81+ <size>
82+ <width>24</width>
83+ <height>24</height>
84+ </size>
85+ </property>
86+ <property name="text">
87+ <string/>
88+ </property>
89+ </widget>
90+ </item>
91+ <item>
92+ <spacer name="horizontalSpacer_3">
93+ <property name="orientation">
94+ <enum>Qt::Horizontal</enum>
95+ </property>
96+ <property name="sizeHint" stdset="0">
97+ <size>
98+ <width>40</width>
99+ <height>20</height>
100+ </size>
101+ </property>
102+ </spacer>
103+ </item>
104+ </layout>
105 </item>
106 </layout>
107 </item>
108@@ -89,7 +134,7 @@
109 <property name="currentIndex">
110 <number>0</number>
111 </property>
112- <widget class="QWidget" name="page">
113+ <widget class="QWidget" name="page_public">
114 <layout class="QVBoxLayout" name="verticalLayout_4">
115 <property name="spacing">
116 <number>0</number>
117@@ -154,7 +199,7 @@
118 </item>
119 </layout>
120 </widget>
121- <widget class="QWidget" name="page_2">
122+ <widget class="QWidget" name="page_details">
123 <layout class="QVBoxLayout" name="verticalLayout_5">
124 <property name="spacing">
125 <number>0</number>
126@@ -303,6 +348,116 @@
127 </item>
128 </layout>
129 </widget>
130+ <widget class="QWidget" name="page_search">
131+ <layout class="QVBoxLayout" name="verticalLayout_8">
132+ <property name="spacing">
133+ <number>0</number>
134+ </property>
135+ <property name="margin">
136+ <number>0</number>
137+ </property>
138+ <item>
139+ <layout class="QHBoxLayout" name="horizontalLayout_2">
140+ <property name="spacing">
141+ <number>0</number>
142+ </property>
143+ <property name="leftMargin">
144+ <number>15</number>
145+ </property>
146+ <item>
147+ <widget class="QLabel" name="label_search_results">
148+ <property name="sizePolicy">
149+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
150+ <horstretch>0</horstretch>
151+ <verstretch>0</verstretch>
152+ </sizepolicy>
153+ </property>
154+ <property name="font">
155+ <font>
156+ <weight>75</weight>
157+ <bold>true</bold>
158+ </font>
159+ </property>
160+ <property name="text">
161+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search Results&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
162+ </property>
163+ </widget>
164+ </item>
165+ <item>
166+ <spacer name="horizontalSpacer_2">
167+ <property name="orientation">
168+ <enum>Qt::Horizontal</enum>
169+ </property>
170+ <property name="sizeType">
171+ <enum>QSizePolicy::Expanding</enum>
172+ </property>
173+ <property name="sizeHint" stdset="0">
174+ <size>
175+ <width>40</width>
176+ <height>0</height>
177+ </size>
178+ </property>
179+ </spacer>
180+ </item>
181+ <item>
182+ <widget class="QPushButton" name="back_to_file_list_2">
183+ <property name="text">
184+ <string>Back to file list</string>
185+ </property>
186+ </widget>
187+ </item>
188+ </layout>
189+ </item>
190+ <item>
191+ <widget class="QTreeWidget" name="tree_search_results">
192+ <property name="alternatingRowColors">
193+ <bool>true</bool>
194+ </property>
195+ <property name="indentation">
196+ <number>15</number>
197+ </property>
198+ <property name="rootIsDecorated">
199+ <bool>false</bool>
200+ </property>
201+ <attribute name="headerVisible">
202+ <bool>false</bool>
203+ </attribute>
204+ <attribute name="headerDefaultSectionSize">
205+ <number>250</number>
206+ </attribute>
207+ <attribute name="headerStretchLastSection">
208+ <bool>true</bool>
209+ </attribute>
210+ <column>
211+ <property name="text">
212+ <string notr="true">Filename</string>
213+ </property>
214+ </column>
215+ <column>
216+ <property name="text">
217+ <string notr="true">Actions</string>
218+ </property>
219+ </column>
220+ </widget>
221+ </item>
222+ <item>
223+ <widget class="QLabel" name="label_no_results">
224+ <property name="sizePolicy">
225+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
226+ <horstretch>0</horstretch>
227+ <verstretch>0</verstretch>
228+ </sizepolicy>
229+ </property>
230+ <property name="text">
231+ <string>You have no files with this name.</string>
232+ </property>
233+ <property name="indent">
234+ <number>20</number>
235+ </property>
236+ </widget>
237+ </item>
238+ </layout>
239+ </widget>
240 </widget>
241 </item>
242 </layout>
243
244=== modified file 'data/qt/ubuntuone.qss'
245--- data/qt/ubuntuone.qss 2012-10-12 19:38:02 +0000
246+++ data/qt/ubuntuone.qss 2012-11-02 13:27:26 +0000
247@@ -402,7 +402,7 @@
248 background-origin: margin;
249 }
250
251-QPushButton#back_to_file_list {
252+QPushButton#back_to_file_list, QPushButton#back_to_file_list_2 {
253 background: transparent;
254 border: none;
255 color: #dd4814;
256
257=== added file 'data/search.png'
258Binary files data/search.png 1970-01-01 00:00:00 +0000 and data/search.png 2012-11-02 13:27:26 +0000 differ
259=== modified file 'ubuntuone/controlpanel/gui/__init__.py'
260--- ubuntuone/controlpanel/gui/__init__.py 2012-10-23 19:26:30 +0000
261+++ ubuntuone/controlpanel/gui/__init__.py 2012-11-02 13:27:26 +0000
262@@ -232,18 +232,24 @@
263 NO_DEVICES = _('No devices to show.')
264 NO_FOLDERS = _('No folders to show.')
265 NO_PAIRING_RECORD = _('There is no Ubuntu One pairing record.')
266+NO_RESULTS = _('No results')
267+NO_RESULTS_LABEL = _('You have no files with this name.')
268 OPEN = _('Open')
269 OPEN_UBUNTU_ONE = _('Open Ubuntu One')
270 OPEN_UBUNTU_ONE_FOLDER = _('Open the Ubuntu One Folder')
271 PERCENTAGE_LABEL = _('%(percentage)s used')
272 PLEASE_WAIT = _('Please wait')
273 PROFILE_LABEL = _('Personal details')
274+SHARE_FILE = _('Share file')
275+SHARE_THESE_FILES = _('Select a file to share:')
276 QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).0f%%)')
277 REMOVE_BUTTON = _('Remove')
278 RECENT_TRANSFERS = _('Recent Transfers')
279 RESTORE_LABEL = _('Restore')
280-SEARCH_FILES = _('Search files')
281+SEARCH_FILES = _('Search and share files')
282 SELECT_FOLDERS = _('Select sync folders')
283+SEARCH_FOR = _('Search for: %s')
284+SEARCH_RESULTS = _('Search Results for "%s"')
285 SERVICES_BUTTON_TOOLTIP = _('Manage the sync services')
286 SERVICES_TITLE = _('Enable the sync services for this computer.')
287 SETTINGS_ALLOW_NOTIFICATIONS = _('Allow all notifications to this device')
288
289=== modified file 'ubuntuone/controlpanel/gui/qt/share_links.py'
290--- ubuntuone/controlpanel/gui/qt/share_links.py 2012-10-23 19:26:30 +0000
291+++ ubuntuone/controlpanel/gui/qt/share_links.py 2012-11-02 13:27:26 +0000
292@@ -27,7 +27,10 @@
293 from ubuntuone.controlpanel.gui import (
294 COPY_LINK,
295 OPEN,
296+ SHARE_FILE,
297+ NO_RESULTS_LABEL,
298 SEARCH_FILES,
299+ SEARCH_RESULTS,
300 SHARED_FILES,
301 )
302
303@@ -47,9 +50,14 @@
304 logger = setup_logging('qt.share_links')
305
306
307+# Table items index
308 FILE_NAME_COL = 0
309 PUBLIC_LINK_COL = 1
310 ACTIONS_COL = 2
311+# StackedLayout widgets index
312+SHARED_FILES_INDEX = 0
313+FILE_DETAILS_INDEX = 1
314+SEARCH_RESULTS_INDEX = 2
315
316
317 class ShareLinksPanel(UbuntuOneBin):
318@@ -67,12 +75,15 @@
319 self.home_dir = ''
320 self.ui.search_files_lbl.setText(SEARCH_FILES)
321 self.ui.shared_group.setTitle(SHARED_FILES)
322+ self.ui.btn_search.setIcon(QtGui.QIcon(":/search.png"))
323+ self.ui.label_no_results.setText(NO_RESULTS_LABEL)
324+ self.ui.label_no_results.hide()
325+ self.ui.page_search.layout().setAlignment(QtCore.Qt.AlignTop)
326
327 # Set enhanced line edits
328 self._enhanced_line = EnhancedLineEdit(self.ui.line_search,
329 self._line_close_btn, icon=":/delete_search.png",
330 style='enhanced_borderless')
331- self._enhanced_line.btn_operation.hide()
332 self.ui.line_search.popup.popupHidden.connect(
333 self._hide_line_btn_close_hide)
334 self.ui.line_search.popup.popupShown.connect(
335@@ -82,15 +93,19 @@
336
337 # Set cursor type
338 self.ui.back_to_file_list.setCursor(QtCore.Qt.PointingHandCursor)
339+ self.ui.back_to_file_list_2.setCursor(QtCore.Qt.PointingHandCursor)
340 self.ui.open_in_browser.setCursor(QtCore.Qt.PointingHandCursor)
341
342 self.ui.line_search.itemSelected.connect(self.share_file)
343+ self.ui.line_search.filesFound.connect(self._load_search_results)
344 self.ui.back_to_file_list.clicked.connect(self._move_to_main_list)
345+ self.ui.back_to_file_list_2.clicked.connect(self._move_to_main_list)
346 self.ui.open_in_browser.clicked.connect(self._open_in_browser)
347 self.ui.tree_shared_files.itemDoubleClicked.connect(
348 self._open_properties_selected_file)
349
350 self.get_public_files()
351+ self._enhanced_line.btn_operation.hide()
352
353 @inlineCallbacks
354 def share_file(self, file_path):
355@@ -118,6 +133,9 @@
356 """Open the file properties on double click."""
357 file_path = unicode(item.toolTip(FILE_NAME_COL))
358 full_path = expand_user(file_path.encode('utf-8')).decode('utf-8')
359+ if self.ui.hbox_share_file.count() > 0:
360+ widget = self.ui.hbox_share_file.takeAt(0).widget()
361+ widget.close()
362 self.open_file_properties(file_path, full_path)
363
364 def open_file_properties(self, file_path, full_path):
365@@ -127,13 +145,13 @@
366 share_file_widget.linkDisabled.connect(
367 lambda: self.ui.line_copy_link.setText(''))
368 self.ui.line_copy_link.setText(self._shared_files[full_path])
369- self.ui.stacked_widget.setCurrentIndex(1)
370+ self.ui.stacked_widget.setCurrentIndex(FILE_DETAILS_INDEX)
371
372 def _file_shared(self, info):
373 """Receive the notification that the file has been published."""
374 url = info.get("public_url")
375 self.ui.line_copy_link.setText(url)
376- self.ui.stacked_widget.setCurrentIndex(1)
377+ self.ui.stacked_widget.setCurrentIndex(FILE_DETAILS_INDEX)
378 self.is_processing = False
379
380 def _open_in_browser(self):
381@@ -148,7 +166,7 @@
382
383 def _move_to_main_list(self):
384 """Set the share files list as current widget."""
385- self.ui.stacked_widget.setCurrentIndex(0)
386+ self.ui.stacked_widget.setCurrentIndex(SHARED_FILES_INDEX)
387 self.get_public_files()
388
389 @inlineCallbacks
390@@ -190,12 +208,44 @@
391 label)
392
393 actions = ActionsButtons(path, public_url,
394- self.ui.tree_shared_files)
395+ parent=self.ui.tree_shared_files)
396 self.ui.tree_shared_files.setItemWidget(item, ACTIONS_COL, actions)
397 self.is_processing = False
398
399+ def _load_search_results(self, results, prefix):
400+ """Load the search results from the search box."""
401+ self.ui.tree_search_results.clear()
402+ self.ui.label_search_results.setText(SEARCH_RESULTS % prefix)
403+ if len(results) > 0:
404+ for result in results:
405+ item = QtGui.QTreeWidgetItem()
406+ name = os.path.basename(result)
407+ item.setText(FILE_NAME_COL, name)
408+ tooltip = result
409+ if tooltip.startswith(self.home_dir):
410+ tooltip = tooltip.replace(self.home_dir, '~', 1)
411+ item.setToolTip(FILE_NAME_COL, tooltip)
412+ icon = get_system_icon_for_filename(result.encode('utf-8'))
413+ item.setIcon(FILE_NAME_COL, icon)
414+ self.ui.tree_search_results.setColumnWidth(FILE_NAME_COL, 300)
415+
416+ item.setSizeHint(FILE_NAME_COL, QtCore.QSize(-1, 35))
417+ self.ui.tree_search_results.addTopLevelItem(item)
418+
419+ actions = ActionsResultsButtons(result, self.share_file,
420+ self.ui.tree_search_results)
421+ self.ui.tree_search_results.setItemWidget(item,
422+ PUBLIC_LINK_COL, actions)
423+ self.ui.tree_search_results.show()
424+ self.ui.label_no_results.hide()
425+ else:
426+ self.ui.tree_search_results.hide()
427+ self.ui.label_no_results.show()
428+ self.ui.stacked_widget.setCurrentIndex(SEARCH_RESULTS_INDEX)
429+
430 def _line_close_btn(self):
431 """Close button in the line edit was pressed, hide the popup."""
432+ self.ui.line_search.setText('')
433 self.ui.line_search.popup.hide()
434 self.ui.line_search.setFocus()
435
436@@ -211,23 +261,24 @@
437 class ActionsButtons(QtGui.QWidget):
438 """Widget that contains the open and copy link actions on the list."""
439
440- def __init__(self, path, link, parent=None):
441+ def __init__(self, path, link, parent=None, both_buttons=True):
442 super(ActionsButtons, self).__init__(parent)
443 self.path = path
444 self.link = link
445
446- hbox = QtGui.QHBoxLayout(self)
447+ self.hbox = QtGui.QHBoxLayout(self)
448+ self.hbox.addSpacerItem(QtGui.QSpacerItem(1, 0,
449+ QtGui.QSizePolicy.Expanding))
450+
451 btn_open = QtGui.QPushButton(OPEN)
452- btn_copy = QtGui.QPushButton(COPY_LINK)
453 btn_open.setObjectName('action_button')
454- btn_copy.setObjectName('action_button')
455- hbox.addSpacerItem(QtGui.QSpacerItem(1, 0,
456- QtGui.QSizePolicy.Expanding))
457- hbox.addWidget(btn_open)
458- hbox.addWidget(btn_copy)
459-
460+ self.hbox.addWidget(btn_open)
461 btn_open.clicked.connect(self.open)
462- btn_copy.clicked.connect(self.copy)
463+ if both_buttons:
464+ btn_copy = QtGui.QPushButton(COPY_LINK)
465+ btn_copy.setObjectName('action_button')
466+ self.hbox.addWidget(btn_copy)
467+ btn_copy.clicked.connect(self.copy)
468
469 def open(self):
470 """Open the file."""
471@@ -240,6 +291,24 @@
472 app.clipboard().setText(self.link)
473
474
475+class ActionsResultsButtons(ActionsButtons):
476+ """Widget that contains: open and publish actions on the results list."""
477+
478+ def __init__(self, path, publish_function=None, parent=None):
479+ super(ActionsResultsButtons, self).__init__(path, '', parent, False)
480+ self.publish_function = publish_function
481+
482+ btn_publish = QtGui.QPushButton(SHARE_FILE)
483+ btn_publish.setObjectName('action_button')
484+ self.hbox.addWidget(btn_publish)
485+ btn_publish.clicked.connect(self.publish_file)
486+
487+ def publish_file(self):
488+ """Publish the file specified."""
489+ if self.publish_function is not None:
490+ self.publish_function(self.path)
491+
492+
493 class EnhancedLineEdit(object):
494 """Add a button inside the QLineEdit received."""
495
496
497=== modified file 'ubuntuone/controlpanel/gui/qt/share_links_search.py'
498--- ubuntuone/controlpanel/gui/qt/share_links_search.py 2012-10-29 14:00:16 +0000
499+++ ubuntuone/controlpanel/gui/qt/share_links_search.py 2012-11-02 13:27:26 +0000
500@@ -25,10 +25,17 @@
501
502 from ubuntuone.controlpanel import cache
503 from ubuntuone.controlpanel.logger import setup_logging
504+from ubuntuone.controlpanel.gui import (
505+ NO_RESULTS,
506+ SEARCH_FOR,
507+ SHARE_THESE_FILES,
508+)
509
510 logger = setup_logging('qt.share_links_search')
511
512 HOME_DIR = ''
513+AVOID_SECOND_ITEM = 2
514+NORMAL_INCREMENT = 1
515
516
517 def get_system_icon_for_filename(file_path):
518@@ -45,6 +52,7 @@
519 """Search widget for the synced files."""
520
521 itemSelected = QtCore.pyqtSignal(unicode)
522+ filesFound = QtCore.pyqtSignal(list, unicode)
523
524 def __init__(self, parent=None):
525 super(SearchBox, self).__init__(parent)
526@@ -56,9 +64,6 @@
527 self.items_step = 20
528 self.prefix = ''
529 self._thread_explore = None
530- self._pre_key_event = {
531- QtCore.Qt.Key_Space: self._key_space_pressed,
532- }
533 self._post_key_event = {
534 QtCore.Qt.Key_Escape: lambda *args: self.popup.hide(),
535 QtCore.Qt.Key_Down: self._key_down_pressed,
536@@ -112,7 +117,7 @@
537 self.temp_u1_files = [filename for filename in self.temp_u1_files
538 if os.path.basename(filename).find(self.prefix) > -1]
539 files = self._get_filtered_list(self.temp_u1_files)
540- self.popup.load_items(files)
541+ self.popup.load_items(files, self.prefix)
542
543 def _get_filtered_list(self, filenames):
544 """Get pages of results."""
545@@ -121,34 +126,28 @@
546 files = [filename for filename in filenames[begin:self.items_per_page]]
547 return files
548
549- def _key_space_pressed(self):
550- """The user pressed the space key."""
551- item = self.popup.list_widget.currentItem()
552- if item is None:
553- return False
554- widget = self.popup.list_widget.itemWidget(item)
555- self.setText(widget.name)
556- self.popup.hide()
557- return True
558-
559- def _key_down_pressed(self, current):
560+ def _key_down_pressed(self, focus_index):
561 """The user pressed the down key."""
562 #While the current position is lower that the list size go to next
563- if current != self.popup.list_widget.count() - 1:
564+ if focus_index != self.popup.list_widget.count() - 1:
565+ list_offset = (AVOID_SECOND_ITEM if focus_index == 0 else
566+ NORMAL_INCREMENT)
567 self.popup.list_widget.setCurrentRow(
568- self.popup.list_widget.currentRow() + 1)
569+ self.popup.list_widget.currentRow() + list_offset)
570 #If the current position is greater than the amount of items in
571 #the list - 6, then try to fetch more items in the list.
572- if current >= (self.popup.list_widget.count() - 6):
573+ if focus_index >= (self.popup.list_widget.count() - 6):
574 filenames = self._get_filtered_list(self.temp_u1_files)
575 self.popup.fetch_more(filenames)
576
577- def _key_up_pressed(self, current):
578+ def _key_up_pressed(self, focus_index):
579 """The user pressed the up key."""
580 #while the current position is greater than 0, go to previous
581- if current > 0:
582+ if focus_index > 0:
583+ list_offset = (AVOID_SECOND_ITEM if focus_index == 2 else
584+ NORMAL_INCREMENT)
585 self.popup.list_widget.setCurrentRow(
586- self.popup.list_widget.currentRow() - 1)
587+ self.popup.list_widget.currentRow() - list_offset)
588
589 def _key_return_pressed(self, current):
590 """The user pressed the return key."""
591@@ -158,9 +157,6 @@
592
593 def keyPressEvent(self, event):
594 """Process the different behaviour for the keyPress event."""
595- if self._pre_key_event.get(event.key(), lambda: False)():
596- return
597-
598 super(SearchBox, self).keyPressEvent(event)
599 current = self.popup.list_widget.currentRow()
600 self._post_key_event.get(event.key(), lambda *args: None)(current)
601@@ -173,8 +169,11 @@
602 def _set_selected_item(self, item):
603 """Notify of the selected item."""
604 widget = self.popup.list_widget.itemWidget(item)
605- self.itemSelected.emit(widget.file_path)
606- self.setText('')
607+ if widget is not None:
608+ self.itemSelected.emit(widget.file_path)
609+ self.setText('')
610+ else:
611+ self.filesFound.emit(self.temp_u1_files, self.prefix)
612 self.popup.hide()
613
614 def moveEvent(self, event):
615@@ -242,14 +241,36 @@
616 """Set the proper style for the current and previous items."""
617 if current is not None:
618 widget = self.list_widget.itemWidget(current)
619- widget.set_selected()
620+ if widget is not None:
621+ widget.set_selected()
622 if previous is not None:
623 widget = self.list_widget.itemWidget(previous)
624- widget.set_not_selected()
625-
626- def load_items(self, file_items):
627+ if widget is not None:
628+ widget.set_not_selected()
629+
630+ def _add_special_item(self, text):
631+ """Add special items to the popup."""
632+ item = QtGui.QListWidgetItem(text)
633+ font = item.font()
634+ font.setBold(True)
635+ item.setSizeHint(QtCore.QSize(20, 30))
636+ item.setBackground(QtGui.QBrush(QtCore.Qt.lightGray))
637+ item.setForeground(QtGui.QBrush(QtCore.Qt.black))
638+ item.setFont(font)
639+ return item
640+
641+ def load_items(self, file_items, search_text):
642 """Load the initial items."""
643 self.list_widget.clear()
644+ # Search item
645+ self.list_widget.addItem(self._add_special_item(
646+ SEARCH_FOR % search_text))
647+ # Message item
648+ if len(file_items) > 0:
649+ message_publish = self._add_special_item(SHARE_THESE_FILES)
650+ else:
651+ message_publish = self._add_special_item(NO_RESULTS)
652+ self.list_widget.addItem(message_publish)
653 for file_ in file_items:
654 item = QtGui.QListWidgetItem("\n")
655 file_widget = FileItem(file_)
656@@ -257,8 +278,7 @@
657 self.list_widget.setItemWidget(item, file_widget)
658 icon = get_system_icon_for_filename(file_.encode('utf-8'))
659 item.setIcon(icon)
660- if file_items:
661- self.list_widget.setCurrentRow(0)
662+ self.list_widget.setCurrentRow(0)
663
664 def fetch_more(self, file_items):
665 """Add more items to the list on user scroll."""
666
667=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_share_links.py'
668--- ubuntuone/controlpanel/gui/qt/tests/test_share_links.py 2012-10-23 14:24:16 +0000
669+++ ubuntuone/controlpanel/gui/qt/tests/test_share_links.py 2012-11-02 13:27:26 +0000
670@@ -57,6 +57,7 @@
671 QtCore.Qt.PointingHandCursor)
672 self.assertEqual(self.ui.ui.back_to_file_list.cursor().shape(),
673 QtCore.Qt.PointingHandCursor)
674+ self.assertFalse(self.ui._enhanced_line.btn_operation.isVisible())
675
676 def test_share_file(self):
677 """Check that the state of the widgets on share_file."""
678@@ -76,6 +77,19 @@
679 self.assertEqual(len(data), 2)
680 self.assertEqual(data[0], self.ui._file_shared)
681
682+ def test_open_file_properties(self):
683+ """Check that we clean the Details Page before adding a new item."""
684+ publicfiles = [
685+ {'path': '/home/file1', 'public_url': 'http:ubuntuone.com/asd123'},
686+ {'path': '/home/file2', 'public_url': 'http:ubuntuone.com/qwe456'},
687+ ]
688+ self.ui._load_public_files(publicfiles)
689+ item = self.ui.ui.tree_shared_files.topLevelItem(0)
690+ self.ui.ui.tree_shared_files.itemDoubleClicked.emit(item, 0)
691+ self.assertEqual(self.ui.ui.hbox_share_file.count(), 1)
692+ self.ui.ui.tree_shared_files.itemDoubleClicked.emit(item, 0)
693+ self.assertEqual(self.ui.ui.hbox_share_file.count(), 1)
694+
695 def test_share_file_actions(self):
696 """Check the behaviour of share_file buttons."""
697 path = '/home/user/Ubuntu One/file1.txt'
698@@ -91,7 +105,8 @@
699 info = {'public_url': 'http://ubuntuone.com/asd123'}
700 self.ui._file_shared(info)
701 self.assertEqual(self.ui.ui.line_copy_link.text(), info['public_url'])
702- self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 1)
703+ self.assertEqual(self.ui.ui.stacked_widget.currentIndex(),
704+ gui.FILE_DETAILS_INDEX)
705 self.assertFalse(self.ui.is_processing)
706
707 def test_file_already_shared(self):
708@@ -109,7 +124,8 @@
709 self.ui._shared_files = shared
710 self.ui.share_file(path)
711 self.assertEqual(self.ui.ui.line_copy_link.text(), shared[path])
712- self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 1)
713+ self.assertEqual(self.ui.ui.stacked_widget.currentIndex(),
714+ gui.FILE_DETAILS_INDEX)
715 self.assertEqual(data, [])
716
717 def test_open_in_browser(self):
718@@ -133,7 +149,8 @@
719 def test_move_to_main_list(self):
720 """Test that the stacked widget shows the proper index."""
721 self.ui._move_to_main_list()
722- self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 0)
723+ self.assertEqual(self.ui.ui.stacked_widget.currentIndex(),
724+ gui.SHARED_FILES_INDEX)
725
726 def test_get_public_files(self):
727 """Test that the proper actions are executed on files requested.."""
728@@ -142,7 +159,8 @@
729 data.append)
730 self.ui.get_public_files()
731 self.assertTrue(self.ui.is_processing)
732- self.assertEqual(self.ui.ui.stacked_widget.currentIndex(), 0)
733+ self.assertEqual(self.ui.ui.stacked_widget.currentIndex(),
734+ gui.SHARED_FILES_INDEX)
735 self.assertEqual(self.ui.home_dir, USER_HOME)
736 self.assertEqual(len(data), 1)
737 self.assertEqual(data[0], self.ui._load_public_files)
738@@ -194,6 +212,35 @@
739 actions = self.ui.ui.tree_shared_files.itemWidget(item, 2)
740 self.assertIsInstance(actions, gui.ActionsButtons)
741
742+ def test_load_search_results(self):
743+ """Test if the list of public files is loaded properly."""
744+ results = ['/home/file1', '/home/file2']
745+ self.ui._load_search_results(results, 'file')
746+ item = self.ui.ui.tree_search_results.topLevelItem(0)
747+ self.assertEqual(item.text(0), os.path.basename('/home/file1'))
748+ self.assertEqual(item.toolTip(0), '/home/file1')
749+ actions = self.ui.ui.tree_search_results.itemWidget(item, 1)
750+ self.assertIsInstance(actions, gui.ActionsResultsButtons)
751+
752+ item = self.ui.ui.tree_search_results.topLevelItem(1)
753+ self.assertEqual(item.text(0), os.path.basename('/home/file2'))
754+ self.assertEqual(item.toolTip(0), '/home/file2')
755+ actions = self.ui.ui.tree_search_results.itemWidget(item, 1)
756+ self.assertIsInstance(actions, gui.ActionsResultsButtons)
757+
758+ self.assertEqual(self.ui.ui.label_search_results.text(),
759+ gui.SEARCH_RESULTS % 'file')
760+ self.assertTrue(self.ui.ui.tree_search_results.isVisible())
761+ self.assertFalse(self.ui.ui.label_no_results.isVisible())
762+
763+ def test_load_search_results_empty_list(self):
764+ """Test if the list of public files is loaded properly."""
765+ self.ui._load_search_results([], 'file')
766+ self.assertEqual(self.ui.ui.label_search_results.text(),
767+ gui.SEARCH_RESULTS % 'file')
768+ self.assertFalse(self.ui.ui.tree_search_results.isVisible())
769+ self.assertTrue(self.ui.ui.label_no_results.isVisible())
770+
771 def test_tree_item_clicked(self):
772 """Check if the proper info is displayed when the item is clicked."""
773 publicfiles = [
774
775=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py'
776--- ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py 2012-10-29 18:30:31 +0000
777+++ ubuntuone/controlpanel/gui/qt/tests/test_share_links_search.py 2012-11-02 13:27:26 +0000
778@@ -87,7 +87,7 @@
779 self.ui.temp_u1_files = self.ui.backend.search_files('')
780 self.ui.temp_u1_files = self.ui.temp_u1_files * 4
781 self.ui._load_items()
782- self.assertEqual(self.ui.popup.list_widget.count(), 20)
783+ self.assertEqual(self.ui.popup.list_widget.count(), 22)
784 self.ui.popup.list_widget.setCurrentRow(
785 self.ui.popup.list_widget.count() - 5)
786 current = self.ui.popup.list_widget.currentRow()
787@@ -120,7 +120,7 @@
788 self.ui.popup.setVisible(True)
789 self.ui.temp_u1_files = self.ui.backend.search_files('')
790 self.ui._load_items()
791- self.ui.popup.list_widget.setCurrentRow(1)
792+ self.ui.popup.list_widget.setCurrentRow(3)
793 current = self.ui.popup.list_widget.currentRow()
794 self.ui.itemSelected.connect(self.fake_slot)
795 self.ui._key_return_pressed(current)
796@@ -132,7 +132,7 @@
797 self.ui.temp_u1_files = self.ui.backend.search_files('')
798 self.ui.popup.setVisible(True)
799 self.ui._load_items()
800- self.ui.popup.list_widget.setCurrentRow(1)
801+ self.ui.popup.list_widget.setCurrentRow(3)
802 current = self.ui.popup.list_widget.currentItem()
803 self.ui.itemSelected.connect(self.fake_slot)
804 self.ui.popup.list_widget.itemPressed.emit(current)
805@@ -150,29 +150,6 @@
806 expected = (([],), {})
807 self.assertEqual(expected, self._called)
808
809- def test_key_space_pressed(self):
810- """Check the proper actions are executed on key space pressed."""
811- data = []
812-
813- def fake_set_text(text):
814- """fake setText."""
815- data.append(text)
816-
817- self.patch(self.ui, "setText", fake_set_text)
818- self.ui.popup.setVisible(True)
819- self.ui.temp_u1_files = self.ui.backend.search_files('')
820- self.ui._load_items()
821- self.ui.popup.list_widget.setCurrentRow(2)
822-
823- self.ui._key_space_pressed()
824- expected = [os.path.basename(self.files[2])]
825- self.assertEqual(expected, data)
826-
827- def test_key_space_pressed_without_selection(self):
828- """Check the proper actions are executed on key space pressed."""
829- self.ui.popup.list_widget.setCurrentItem(None)
830- self.assertFalse(self.ui._key_space_pressed())
831-
832 def test_process_volumes_info(self):
833 """Check that _process_volumes_info obtain the proper info."""
834 self.ui.temp_u1_files = self.ui.backend.search_files('')
835@@ -182,7 +159,7 @@
836 expected = self.files
837 expected.sort()
838 self.assertEqual(self.ui.temp_u1_files, expected)
839- self.assertEqual(self.ui.popup.list_widget.count(), 6)
840+ self.assertEqual(self.ui.popup.list_widget.count(), 8)
841
842 def test_filter(self):
843 """Check the results of the filter."""
844@@ -212,7 +189,7 @@
845 self.patch(self.ui.popup, "isVisible", lambda: True)
846 self.ui.temp_u1_files = self.ui.backend.search_files('')
847 self.ui._load_items()
848- self.ui.popup.list_widget.setCurrentRow(0)
849+ self.ui.popup.list_widget.setCurrentRow(2)
850 item = self.ui.popup.list_widget.currentItem()
851 self.ui._set_selected_item(item)
852 self.assertEqual(self._called,
853@@ -280,11 +257,11 @@
854 ]
855
856 self.assertEqual(self.ui.list_widget.count(), 0)
857- self.ui.load_items(items)
858- self.assertEqual(self.ui.list_widget.count(), 3)
859+ self.ui.load_items(items, '')
860+ self.assertEqual(self.ui.list_widget.count(), 5)
861 # Check that we erase the list on reload
862- self.ui.load_items(items)
863- self.assertEqual(self.ui.list_widget.count(), 3)
864+ self.ui.load_items(items, '')
865+ self.assertEqual(self.ui.list_widget.count(), 5)
866
867 def test_fetch_more(self):
868 """Tests that the items are loaded properly."""
869@@ -295,10 +272,10 @@
870 ]
871
872 self.assertEqual(self.ui.list_widget.count(), 0)
873- self.ui.load_items(items)
874- self.assertEqual(self.ui.list_widget.count(), 3)
875+ self.ui.load_items(items, '')
876+ self.assertEqual(self.ui.list_widget.count(), 5)
877 self.ui.fetch_more(items)
878- self.assertEqual(self.ui.list_widget.count(), 6)
879+ self.assertEqual(self.ui.list_widget.count(), 8)
880
881 def test_repaint_items(self):
882 """Check the style of the items change acording to the selection."""
883@@ -308,10 +285,11 @@
884 '/home/tester/file3',
885 ]
886
887- self.ui.load_items(items)
888- current = self.ui.list_widget.item(0)
889+ self.ui.load_items(items, '')
890+ self.ui.list_widget.setCurrentRow(2)
891+ current = self.ui.list_widget.item(2)
892 widget = self.ui.list_widget.itemWidget(current)
893- next_ = self.ui.list_widget.item(1)
894+ next_ = self.ui.list_widget.item(3)
895 widget2 = self.ui.list_widget.itemWidget(next_)
896 name = os.path.basename('/home/tester/file1')
897 style = self.text_style.format(name, '/home/tester/file1',
898@@ -322,10 +300,10 @@
899 self.assertEqual(widget.text(), style)
900 self.assertEqual(widget2.text(), style2)
901
902- self.ui.list_widget.setCurrentRow(1)
903- current = self.ui.list_widget.item(1)
904+ self.ui.list_widget.setCurrentRow(3)
905+ current = self.ui.list_widget.item(3)
906 widget = self.ui.list_widget.itemWidget(current)
907- previous = self.ui.list_widget.item(0)
908+ previous = self.ui.list_widget.item(2)
909 widget2 = self.ui.list_widget.itemWidget(previous)
910 name = os.path.basename('/home/tester/file2')
911 style = self.text_style.format(name, '/home/tester/file2',
912@@ -335,3 +313,31 @@
913 '#333333', 'grey')
914 self.assertEqual(widget.text(), style)
915 self.assertEqual(widget2.text(), style2)
916+
917+ def test_first_list_item(self):
918+ """Check that the first item in the popup has the proper string."""
919+ self.ui.load_items([], 'file')
920+ current = self.ui.list_widget.item(0)
921+ text = current.text()
922+ expected = gui.SEARCH_FOR % 'file'
923+ self.assertEqual(expected, text)
924+
925+ def test_second_list_item_for_empty_list(self):
926+ """Check that the second item in the popup has the proper string."""
927+ self.ui.load_items([], 'file')
928+ current = self.ui.list_widget.item(1)
929+ text = current.text()
930+ self.assertEqual(gui.NO_RESULTS, text)
931+
932+ def test_second_list_item(self):
933+ """Check that the second item in the popup has the proper string."""
934+ items = [
935+ '/home/tester/file1',
936+ '/home/tester/file2',
937+ '/home/tester/file3',
938+ ]
939+
940+ self.ui.load_items(items, 'file')
941+ current = self.ui.list_widget.item(1)
942+ text = current.text()
943+ self.assertEqual(gui.SHARE_THESE_FILES, text)

Subscribers

People subscribed via source and target branches