Merge lp:~dobey/ubuntuone-control-panel/update-4-0 into lp:ubuntuone-control-panel/stable-4-0
- update-4-0
- Merge into stable-4-0
Proposed by
dobey
Status: | Merged |
---|---|
Approved by: | dobey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 328 |
Proposed branch: | lp:~dobey/ubuntuone-control-panel/update-4-0 |
Merge into: | lp:ubuntuone-control-panel/stable-4-0 |
Diff against target: |
463 lines (+118/-97) 7 files modified
bin/ubuntuone-control-panel-qt (+1/-1) data/qt/images.qrc (+1/-0) run-tests (+32/-7) ubuntuone/controlpanel/gui/qt/folders.py (+28/-12) ubuntuone/controlpanel/gui/qt/main/__init__.py (+5/-5) ubuntuone/controlpanel/gui/qt/main/twisted_main.py (+1/-1) ubuntuone/controlpanel/gui/qt/tests/test_folders.py (+50/-71) |
To merge this branch: | bzr merge lp:~dobey/ubuntuone-control-panel/update-4-0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mike McCracken (community) | Approve | ||
Review via email: mp+111291@code.launchpad.net |
Commit message
[Mike McCracken]
- Use qt4reactor on Darwin. (LP: #1013820)
- Make run-tests script work on Darwin. (LP: #1010211)
[Roberto Alsina]
- Enable folder list sorting (Fixes LP:1006385).
[Diego Sarmentero]
- Using suggested_path to server path comparisons (LP: #1004603).
Description of the change
To post a comment you must log in.
- 328. By Diego Sarmentero
-
[Mike McCracken]
- Use qt4reactor on Darwin. (LP: #1013820)
- Make run-tests script work on Darwin. (LP: #1010211)[Roberto Alsina]
- Enable folder list sorting (Fixes LP:1006385).
[Diego Sarmentero]
- Using suggested_path to server path comparisons (LP: #1004603).
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/ubuntuone-control-panel-qt' | |||
2 | --- bin/ubuntuone-control-panel-qt 2012-03-01 17:47:54 +0000 | |||
3 | +++ bin/ubuntuone-control-panel-qt 2012-06-20 19:10:48 +0000 | |||
4 | @@ -22,7 +22,7 @@ | |||
5 | 22 | import signal | 22 | import signal |
6 | 23 | import sys | 23 | import sys |
7 | 24 | 24 | ||
9 | 25 | if sys.platform == 'win32': | 25 | if sys.platform in ('win32', 'darwin'): |
10 | 26 | import qt4reactor | 26 | import qt4reactor |
11 | 27 | qt4reactor.install() | 27 | qt4reactor.install() |
12 | 28 | 28 | ||
13 | 29 | 29 | ||
14 | === added file 'data/audio-x-generic.png' | |||
15 | 30 | Binary files data/audio-x-generic.png 1970-01-01 00:00:00 +0000 and data/audio-x-generic.png 2012-06-20 19:10:48 +0000 differ | 30 | Binary files data/audio-x-generic.png 1970-01-01 00:00:00 +0000 and data/audio-x-generic.png 2012-06-20 19:10:48 +0000 differ |
16 | === modified file 'data/qt/images.qrc' | |||
17 | --- data/qt/images.qrc 2012-05-14 21:05:08 +0000 | |||
18 | +++ data/qt/images.qrc 2012-06-20 19:10:48 +0000 | |||
19 | @@ -1,5 +1,6 @@ | |||
20 | 1 | <RCC> | 1 | <RCC> |
21 | 2 | <qresource prefix="/"> | 2 | <qresource prefix="/"> |
22 | 3 | <file>../audio-x-generic.png</file> | ||
23 | 3 | <file>../banner.png</file> | 4 | <file>../banner.png</file> |
24 | 4 | <file>../computer.png</file> | 5 | <file>../computer.png</file> |
25 | 5 | <file>../external_icon_dark_grey.png</file> | 6 | <file>../external_icon_dark_grey.png</file> |
26 | 6 | 7 | ||
27 | === modified file 'run-tests' | |||
28 | --- run-tests 2012-04-25 13:35:35 +0000 | |||
29 | +++ run-tests 2012-06-20 19:10:48 +0000 | |||
30 | @@ -19,8 +19,9 @@ | |||
31 | 19 | QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests, ubuntuone/controlpanel/gui/qt/uniqueapp/tests" | 19 | QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests, ubuntuone/controlpanel/gui/qt/uniqueapp/tests" |
32 | 20 | DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests | 20 | DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests |
33 | 21 | WINDOWS_TESTS=test_windows.py | 21 | WINDOWS_TESTS=test_windows.py |
34 | 22 | LINUX_TESTS=test_linux.py | ||
35 | 23 | DARWIN_TESTS=test_darwin.py | ||
36 | 22 | 24 | ||
37 | 23 | set -e | ||
38 | 24 | 25 | ||
39 | 25 | if [ $# -ne 0 ]; then | 26 | if [ $# -ne 0 ]; then |
40 | 26 | # run specific module given by the caller | 27 | # run specific module given by the caller |
41 | @@ -31,7 +32,7 @@ | |||
42 | 31 | fi | 32 | fi |
43 | 32 | 33 | ||
44 | 33 | style_check() { | 34 | style_check() { |
46 | 34 | u1lint --ignore ubuntuone/controlpanel/gui/qt/ui | 35 | $u1lint --ignore ubuntuone/controlpanel/gui/qt/ui |
47 | 35 | if [ -x `which pep8` ]; then | 36 | if [ -x `which pep8` ]; then |
48 | 36 | pep8 --exclude '.svn,CVS,.bzr,.hg,.git,*_ui.py,*_rc.py' --repeat . bin/* | 37 | pep8 --exclude '.svn,CVS,.bzr,.hg,.git,*_ui.py,*_rc.py' --repeat . bin/* |
49 | 37 | else | 38 | else |
50 | @@ -45,15 +46,39 @@ | |||
51 | 45 | XVFB_CMDLINE="$XVFB -a" | 46 | XVFB_CMDLINE="$XVFB -a" |
52 | 46 | fi | 47 | fi |
53 | 47 | 48 | ||
54 | 49 | # now fail on errors, after we tried to find xvfb: | ||
55 | 50 | set -e | ||
56 | 51 | |||
57 | 52 | SYSNAME=`uname -s` | ||
58 | 53 | |||
59 | 54 | if [ "$SYSNAME" == "Darwin" ]; then | ||
60 | 55 | u1trial="python $u1trial" | ||
61 | 56 | u1lint="python $u1lint" | ||
62 | 57 | IGNORE_FILES="$WINDOWS_TESTS, $LINUX_TESTS" | ||
63 | 58 | IGNORE_DBUS="-p $DBUS_TESTS_PATH" | ||
64 | 59 | echo "*** Skipping DBus test suite ***" | ||
65 | 60 | REACTOR=qt4 | ||
66 | 61 | PYTHONPATH=$PYTHONPATH:../ubuntu-sso-client:../ubuntuone-client:../ubuntuone-storage-protocol:. | ||
67 | 62 | else | ||
68 | 63 | # Linux: | ||
69 | 64 | if [ "x$XVFB_CMDLINE" == "x" ]; then | ||
70 | 65 | echo "WARNING: Could not find xvfb-run, prepare for visual spam." | ||
71 | 66 | fi | ||
72 | 67 | u1trial=u1trial | ||
73 | 68 | u1lint=u1lint | ||
74 | 69 | IGNORE_FILES="$WINDOWS_TESTS, $DARWIN_TESTS" | ||
75 | 70 | IGNORE_DBUS="" | ||
76 | 71 | echo "*** Running DBus test suite ***" | ||
77 | 72 | $u1trial --reactor=glib "$DBUS_TESTS_PATH" | ||
78 | 73 | REACTOR=gi | ||
79 | 74 | fi | ||
80 | 75 | |||
81 | 48 | echo "*** Running test suite for ""$MODULE"" ***" | 76 | echo "*** Running test suite for ""$MODULE"" ***" |
86 | 49 | u1trial --reactor=gi -p "$DBUS_TESTS_PATH, $QT_TESTS_PATH" -i "$WINDOWS_TESTS" "$MODULE" | 77 | $u1trial --reactor=$REACTOR -p "$DBUS_TESTS_PATH, $QT_TESTS_PATH" -i "$IGNORE_FILES" "$MODULE" |
83 | 50 | |||
84 | 51 | echo "*** Running DBus test suite ***" | ||
85 | 52 | u1trial --reactor=glib "$DBUS_TESTS_PATH" | ||
87 | 53 | 78 | ||
88 | 54 | echo "*** Running QT test suite for ""$MODULE"" ***" | 79 | echo "*** Running QT test suite for ""$MODULE"" ***" |
89 | 55 | ./setup.py build | 80 | ./setup.py build |
91 | 56 | $XVFB_CMDLINE u1trial -i "$WINDOWS_TESTS" --reactor=qt4 --gui "$MODULE" | 81 | $XVFB_CMDLINE $u1trial $IGNORE_DBUS -i "$IGNORE_FILES" --reactor=qt4 --gui "$MODULE" |
92 | 57 | rm -rf _trial_temp | 82 | rm -rf _trial_temp |
93 | 58 | rm -rf build | 83 | rm -rf build |
94 | 59 | 84 | ||
95 | 60 | 85 | ||
96 | === modified file 'ubuntuone/controlpanel/gui/qt/folders.py' | |||
97 | --- ubuntuone/controlpanel/gui/qt/folders.py 2012-05-14 18:50:12 +0000 | |||
98 | +++ ubuntuone/controlpanel/gui/qt/folders.py 2012-06-20 19:10:48 +0000 | |||
99 | @@ -80,10 +80,15 @@ | |||
100 | 80 | 80 | ||
101 | 81 | def _process_name(name): | 81 | def _process_name(name): |
102 | 82 | """Tweak 'name' with a translatable music folder name.""" | 82 | """Tweak 'name' with a translatable music folder name.""" |
104 | 83 | if name == MUSIC_REAL_PATH: | 83 | if name.startswith('~/'): |
105 | 84 | suggested = name[2:] | ||
106 | 85 | else: | ||
107 | 86 | suggested = name | ||
108 | 87 | |||
109 | 88 | if suggested == MUSIC_REAL_PATH: | ||
110 | 84 | result = MUSIC_DISPLAY_NAME | 89 | result = MUSIC_DISPLAY_NAME |
111 | 85 | else: | 90 | else: |
113 | 86 | result = name | 91 | result = suggested |
114 | 87 | return result | 92 | return result |
115 | 88 | 93 | ||
116 | 89 | 94 | ||
117 | @@ -132,6 +137,9 @@ | |||
118 | 132 | headers.setResizeMode(SUBSCRIPTION_COL, headers.ResizeToContents) | 137 | headers.setResizeMode(SUBSCRIPTION_COL, headers.ResizeToContents) |
119 | 133 | headers.setResizeMode(EXPLORE_COL, headers.ResizeToContents) | 138 | headers.setResizeMode(EXPLORE_COL, headers.ResizeToContents) |
120 | 134 | 139 | ||
121 | 140 | self.ui.folders.setSortingEnabled(True) | ||
122 | 141 | self.ui.folders.sortByColumn(FOLDER_NAME_COL, QtCore.Qt.AscendingOrder) | ||
123 | 142 | |||
124 | 135 | self.ui.share_publish_button.setText(FOLDERS_MANAGE_LABEL) | 143 | self.ui.share_publish_button.setText(FOLDERS_MANAGE_LABEL) |
125 | 136 | self.ui.share_publish_button.uri = MANAGE_FILES_LINK | 144 | self.ui.share_publish_button.uri = MANAGE_FILES_LINK |
126 | 137 | QtGui.QApplication.instance().focusChanged.connect(self.focus_changed) | 145 | QtGui.QApplication.instance().focusChanged.connect(self.focus_changed) |
127 | @@ -203,7 +211,8 @@ | |||
128 | 203 | child.volume_path = volume['path'] | 211 | child.volume_path = volume['path'] |
129 | 204 | child.volume_id = volume['volume_id'] | 212 | child.volume_id = volume['volume_id'] |
130 | 205 | 213 | ||
132 | 206 | name = _process_name(volume[u'display_name']) | 214 | name = _process_name(volume.get(u'suggested_path', |
133 | 215 | volume[u'display_name'])) | ||
134 | 207 | child.setText(FOLDER_NAME_COL, name) | 216 | child.setText(FOLDER_NAME_COL, name) |
135 | 208 | child.setToolTip(FOLDER_NAME_COL, name) | 217 | child.setToolTip(FOLDER_NAME_COL, name) |
136 | 209 | child.setToolTip(EXPLORE_COL, FOLDERS_COLUMN_EXPLORE) | 218 | child.setToolTip(EXPLORE_COL, FOLDERS_COLUMN_EXPLORE) |
137 | @@ -505,21 +514,25 @@ | |||
138 | 505 | for volume in volumes: | 514 | for volume in volumes: |
139 | 506 | if (volume[u'type'] == self.backend.FOLDER_TYPE and | 515 | if (volume[u'type'] == self.backend.FOLDER_TYPE and |
140 | 507 | bool(volume['subscribed'])): | 516 | bool(volume['subscribed'])): |
142 | 508 | folders.append((volume['path'], volume['volume_id'])) | 517 | suggested = volume.get(u'suggested_path', |
143 | 518 | volume[u'display_name']) | ||
144 | 519 | folders.append((volume['path'], volume['volume_id'], | ||
145 | 520 | suggested)) | ||
146 | 509 | 521 | ||
147 | 510 | # add local folders only if they are valid | 522 | # add local folders only if they are valid |
148 | 511 | for folder in default_folders(user_home=self.user_home): | 523 | for folder in default_folders(user_home=self.user_home): |
149 | 512 | is_valid = yield self.backend.validate_path_for_folder(folder) | 524 | is_valid = yield self.backend.validate_path_for_folder(folder) |
150 | 513 | if is_valid: | 525 | if is_valid: |
152 | 514 | folders.append((folder, None)) | 526 | folders.append((folder, None, None)) |
153 | 515 | 527 | ||
154 | 516 | # always clear the items dict first, since clearing the folders | 528 | # always clear the items dict first, since clearing the folders |
155 | 517 | # list will trigger "underlying C/C++ object has been deleted" | 529 | # list will trigger "underlying C/C++ object has been deleted" |
156 | 518 | self.items.clear() | 530 | self.items.clear() |
157 | 519 | self.ui.folders.clear() | 531 | self.ui.folders.clear() |
158 | 520 | 532 | ||
161 | 521 | for path, volume_id in folders: | 533 | for path, volume_id, suggested in folders: |
162 | 522 | self.add_folder(folder_path=path, volume_id=volume_id) | 534 | self.add_folder(folder_path=path, volume_id=volume_id, |
163 | 535 | suggested=suggested) | ||
164 | 523 | 536 | ||
165 | 524 | if folders and not self.timer.isActive(): | 537 | if folders and not self.timer.isActive(): |
166 | 525 | self.timer.start(2000) | 538 | self.timer.start(2000) |
167 | @@ -552,20 +565,23 @@ | |||
168 | 552 | self.changesApplied.emit() | 565 | self.changesApplied.emit() |
169 | 553 | 566 | ||
170 | 554 | @handle_errors(logger=logger) | 567 | @handle_errors(logger=logger) |
172 | 555 | def add_folder(self, folder_path, volume_id=None): | 568 | def add_folder(self, folder_path, volume_id=None, suggested=None): |
173 | 556 | """Add a folder to the list.""" | 569 | """Add a folder to the list.""" |
174 | 557 | if folder_path in self.items: | 570 | if folder_path in self.items: |
175 | 558 | logger.warning('LocalFoldersPanel: already have an item for %r.', | 571 | logger.warning('LocalFoldersPanel: already have an item for %r.', |
176 | 559 | folder_path) | 572 | folder_path) |
177 | 560 | return | 573 | return |
178 | 561 | 574 | ||
180 | 562 | if self.user_home is None: | 575 | if suggested is None: |
181 | 563 | logger.warning('LocalFoldersPanel: user home is None! ' | 576 | logger.warning('LocalFoldersPanel: user home is None! ' |
182 | 564 | 'paths will not be pretty.') | 577 | 'paths will not be pretty.') |
186 | 565 | display_name = folder_path | 578 | if self.user_home is None: |
187 | 566 | else: | 579 | user_home = '' |
188 | 567 | user_home = self.user_home + os.path.sep | 580 | else: |
189 | 581 | user_home = self.user_home + os.path.sep | ||
190 | 568 | display_name = _process_name(folder_path.replace(user_home, '')) | 582 | display_name = _process_name(folder_path.replace(user_home, '')) |
191 | 583 | else: | ||
192 | 584 | display_name = _process_name(suggested) | ||
193 | 569 | 585 | ||
194 | 570 | item = FolderItem([display_name, ""], path=folder_path, | 586 | item = FolderItem([display_name, ""], path=folder_path, |
195 | 571 | queue=self.queue, volume_id=volume_id) | 587 | queue=self.queue, volume_id=volume_id) |
196 | 572 | 588 | ||
197 | === modified file 'ubuntuone/controlpanel/gui/qt/main/__init__.py' | |||
198 | --- ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-05-14 22:27:07 +0000 | |||
199 | +++ ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-06-20 19:10:48 +0000 | |||
200 | @@ -29,12 +29,12 @@ | |||
201 | 29 | from ubuntuone.controlpanel.gui.qt.uniqueapp import UniqueApplication | 29 | from ubuntuone.controlpanel.gui.qt.uniqueapp import UniqueApplication |
202 | 30 | 30 | ||
203 | 31 | # Invalid name "source", pylint: disable=C0103 | 31 | # Invalid name "source", pylint: disable=C0103 |
207 | 32 | if sys.platform == 'win32': | 32 | if sys.platform in ('win32', 'darwin'): |
208 | 33 | from ubuntuone.controlpanel.gui.qt.main import windows | 33 | from ubuntuone.controlpanel.gui.qt.main import twisted_main |
209 | 34 | source = windows | 34 | source = twisted_main |
210 | 35 | else: | 35 | else: |
213 | 36 | from ubuntuone.controlpanel.gui.qt.main import linux | 36 | from ubuntuone.controlpanel.gui.qt.main import dbus_main |
214 | 37 | source = linux | 37 | source = dbus_main |
215 | 38 | # pylint: enable=C0103 | 38 | # pylint: enable=C0103 |
216 | 39 | 39 | ||
217 | 40 | 40 | ||
218 | 41 | 41 | ||
219 | === renamed file 'ubuntuone/controlpanel/gui/qt/main/linux.py' => 'ubuntuone/controlpanel/gui/qt/main/dbus_main.py' | |||
220 | === renamed file 'ubuntuone/controlpanel/gui/qt/main/windows.py' => 'ubuntuone/controlpanel/gui/qt/main/twisted_main.py' | |||
221 | --- ubuntuone/controlpanel/gui/qt/main/windows.py 2012-04-05 14:52:55 +0000 | |||
222 | +++ ubuntuone/controlpanel/gui/qt/main/twisted_main.py 2012-06-20 19:10:48 +0000 | |||
223 | @@ -14,7 +14,7 @@ | |||
224 | 14 | # You should have received a copy of the GNU General Public License along | 14 | # You should have received a copy of the GNU General Public License along |
225 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
226 | 16 | 16 | ||
228 | 17 | """Main method to be used on windows.""" | 17 | """Main method to be used on platforms without dbus.""" |
229 | 18 | 18 | ||
230 | 19 | from PyQt4 import QtGui | 19 | from PyQt4 import QtGui |
231 | 20 | 20 | ||
232 | 21 | 21 | ||
233 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_folders.py' | |||
234 | --- ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2012-05-14 18:50:12 +0000 | |||
235 | +++ ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2012-06-20 19:10:48 +0000 | |||
236 | @@ -24,7 +24,7 @@ | |||
237 | 24 | import shutil | 24 | import shutil |
238 | 25 | import sys | 25 | import sys |
239 | 26 | 26 | ||
241 | 27 | from PyQt4 import QtGui | 27 | from PyQt4 import QtCore, QtGui |
242 | 28 | from twisted.internet import defer | 28 | from twisted.internet import defer |
243 | 29 | from ubuntuone.devtools.handlers import MementoHandler | 29 | from ubuntuone.devtools.handlers import MementoHandler |
244 | 30 | from ubuntuone.devtools.testcases import skipIfOS | 30 | from ubuntuone.devtools.testcases import skipIfOS |
245 | @@ -37,6 +37,7 @@ | |||
246 | 37 | FAKE_VOLUMES_ONLY_ROOT_INFO, | 37 | FAKE_VOLUMES_ONLY_ROOT_INFO, |
247 | 38 | MUSIC_FOLDER, MUSIC_PATH, ROOT, USER_HOME, | 38 | MUSIC_FOLDER, MUSIC_PATH, ROOT, USER_HOME, |
248 | 39 | ) | 39 | ) |
249 | 40 | from ubuntuone.controlpanel.gui import MUSIC_REAL_PATH | ||
250 | 40 | from ubuntuone.controlpanel.gui.qt import folders as gui | 41 | from ubuntuone.controlpanel.gui.qt import folders as gui |
251 | 41 | from ubuntuone.controlpanel.gui.qt.tests import ( | 42 | from ubuntuone.controlpanel.gui.qt.tests import ( |
252 | 42 | BaseTestCase, | 43 | BaseTestCase, |
253 | @@ -243,28 +244,21 @@ | |||
254 | 243 | 244 | ||
255 | 244 | def test_process_info(self): | 245 | def test_process_info(self): |
256 | 245 | """The volumes info is processed when ready.""" | 246 | """The volumes info is processed when ready.""" |
257 | 247 | folders = self.ui.ui.folders | ||
258 | 246 | self.ui.process_info(FAKE_VOLUMES_INFO) | 248 | self.ui.process_info(FAKE_VOLUMES_INFO) |
259 | 247 | folders = self.ui.ui.folders | ||
260 | 248 | |||
261 | 249 | root = folders.invisibleRootItem() | 249 | root = folders.invisibleRootItem() |
262 | 250 | self.assertEqual(len(FAKE_VOLUMES_INFO), root.childCount()) | 250 | self.assertEqual(len(FAKE_VOLUMES_INFO), root.childCount()) |
263 | 251 | 251 | ||
264 | 252 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) | ||
265 | 253 | for name, _, volumes in FAKE_VOLUMES_INFO: | 252 | for name, _, volumes in FAKE_VOLUMES_INFO: |
266 | 254 | name = _build_name(name) | 253 | name = _build_name(name) |
272 | 255 | 254 | items = folders.findItems(name, QtCore.Qt.MatchFixedString | |
273 | 256 | # get first child, matching "My Folders" | 255 | | QtCore.Qt.MatchCaseSensitive | QtCore.Qt.MatchRecursive, |
274 | 257 | item = treeiter.value() | 256 | gui.FOLDER_NAME_COL) |
275 | 258 | self.assertFalse(item.is_empty) | 257 | self.assertEqual(1, len(items)) |
276 | 259 | 258 | item = items[0] | |
277 | 260 | self.assert_folder_group_header_correct(item, name) | 259 | self.assert_folder_group_header_correct(item, name) |
278 | 261 | |||
279 | 262 | self.assertEqual(len(volumes), item.childCount()) | 260 | self.assertEqual(len(volumes), item.childCount()) |
285 | 263 | sorted_vols = sorted(volumes, key=operator.itemgetter('path')) | 261 | for volume in volumes: |
281 | 264 | for volume in sorted_vols: | ||
282 | 265 | treeiter += 1 | ||
283 | 266 | item = treeiter.value() # get child folder | ||
284 | 267 | self.assertTrue(item is not None) | ||
286 | 268 | 262 | ||
287 | 269 | name = volume['path'].replace(USER_HOME + os.path.sep, '') | 263 | name = volume['path'].replace(USER_HOME + os.path.sep, '') |
288 | 270 | expected_path = volume['path'] | 264 | expected_path = volume['path'] |
289 | @@ -277,12 +271,14 @@ | |||
290 | 277 | else: | 271 | else: |
291 | 278 | icon_name = gui.SHARE_ICON_NAME | 272 | icon_name = gui.SHARE_ICON_NAME |
292 | 279 | 273 | ||
293 | 274 | items = folders.findItems(name, QtCore.Qt.MatchFixedString | | ||
294 | 275 | QtCore.Qt.MatchCaseSensitive | QtCore.Qt.MatchRecursive, | ||
295 | 276 | gui.FOLDER_NAME_COL) | ||
296 | 277 | self.assertEqual(1, len(items)) | ||
297 | 278 | item = items[0] | ||
298 | 280 | self.assert_folder_row_correct(item, name, icon_name, volume, | 279 | self.assert_folder_row_correct(item, name, icon_name, volume, |
299 | 281 | tweaked_path=expected_path) | 280 | tweaked_path=expected_path) |
300 | 282 | 281 | ||
301 | 283 | treeiter += 1 | ||
302 | 284 | item = treeiter.value() | ||
303 | 285 | |||
304 | 286 | def test_process_info_clears_the_list(self): | 282 | def test_process_info_clears_the_list(self): |
305 | 287 | """The old volumes info is cleared before updated.""" | 283 | """The old volumes info is cleared before updated.""" |
306 | 288 | self.ui.process_info(FAKE_VOLUMES_INFO) | 284 | self.ui.process_info(FAKE_VOLUMES_INFO) |
307 | @@ -304,9 +300,10 @@ | |||
308 | 304 | 300 | ||
309 | 305 | child_index = 0 | 301 | child_index = 0 |
310 | 306 | root = self.ui.ui.folders.invisibleRootItem() | 302 | root = self.ui.ui.folders.invisibleRootItem() |
314 | 307 | for name, _, _ in FAKE_VOLUMES_NO_FREE_SPACE_INFO: | 303 | names = [_build_name(name) for name, _, _ in |
315 | 308 | name = _build_name(name) | 304 | FAKE_VOLUMES_NO_FREE_SPACE_INFO] |
316 | 309 | 305 | names.sort(key=lambda x: x.lower()) | |
317 | 306 | for name in names: | ||
318 | 310 | item = root.child(child_index) | 307 | item = root.child(child_index) |
319 | 311 | self.assertFalse(item.is_empty) | 308 | self.assertFalse(item.is_empty) |
320 | 312 | self.assert_folder_group_header_correct(item, name) | 309 | self.assert_folder_group_header_correct(item, name) |
321 | @@ -413,34 +410,23 @@ | |||
322 | 413 | """Ensure that the inner widgets are in the correct tab order.""" | 410 | """Ensure that the inner widgets are in the correct tab order.""" |
323 | 414 | self.ui.process_info(FAKE_VOLUMES_INFO) | 411 | self.ui.process_info(FAKE_VOLUMES_INFO) |
324 | 415 | folders = self.ui.ui.folders | 412 | folders = self.ui.ui.folders |
325 | 416 | |||
326 | 417 | widget = self.ui.ui.folders.nextInFocusChain() | 413 | widget = self.ui.ui.folders.nextInFocusChain() |
327 | 418 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) | 414 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) |
332 | 419 | for name, _, volumes in FAKE_VOLUMES_INFO: | 415 | while treeiter.value(): |
333 | 420 | item = treeiter.value() | 416 | if treeiter.value().parent() is None: # Top-levels |
330 | 421 | sorted_vols = sorted(volumes, key=operator.itemgetter('path')) | ||
331 | 422 | for volume in sorted_vols: | ||
334 | 423 | treeiter += 1 | 417 | treeiter += 1 |
353 | 424 | item = treeiter.value() # get child folder | 418 | continue |
354 | 425 | 419 | if self.ui.remote_folders: | |
355 | 426 | name = volume['path'].replace(USER_HOME + os.path.sep, '') | 420 | self.assertIsInstance(widget, QtGui.QCheckBox) |
356 | 427 | if volume['type'] == self.ui.backend.SHARE_TYPE: | 421 | # ROOT volume has no checkbox |
357 | 428 | name = volume['name'] | 422 | elif treeiter.value().text(1) or self.ui.remote_folders: |
358 | 429 | self.assertEqual(unicode(item.text(gui.FOLDER_NAME_COL)), name) | 423 | self.assertIsInstance(widget, QtGui.QPushButton) |
359 | 430 | 424 | else: | |
360 | 431 | actual_name = unicode(self.ui.widget_items[widget].text(0)) | 425 | self.assertIsInstance(widget, QtGui.QCheckBox) |
361 | 432 | if volume['type'] != self.ui.backend.ROOT_TYPE: | 426 | widget = widget.nextInFocusChain() |
362 | 433 | self.assertIsInstance(widget, QtGui.QCheckBox) | 427 | self.assertIsInstance(widget, QtGui.QPushButton) |
363 | 434 | self.assertEqual(actual_name, name) | 428 | widget = widget.nextInFocusChain() |
346 | 435 | widget = widget.nextInFocusChain() | ||
347 | 436 | |||
348 | 437 | if not self.ui.remote_folders: | ||
349 | 438 | self.assertIsInstance(widget, QtGui.QPushButton) | ||
350 | 439 | self.assertEqual(actual_name, name) | ||
351 | 440 | widget = widget.nextInFocusChain() | ||
352 | 441 | |||
364 | 442 | treeiter += 1 | 429 | treeiter += 1 |
365 | 443 | item = treeiter.value() | ||
366 | 444 | 430 | ||
367 | 445 | def test_widget_dict(self): | 431 | def test_widget_dict(self): |
368 | 446 | """Ensure the widget_items dictionary is full.""" | 432 | """Ensure the widget_items dictionary is full.""" |
369 | @@ -994,13 +980,17 @@ | |||
370 | 994 | def assert_folder_added(self, path, volume_id=None, item=None): | 980 | def assert_folder_added(self, path, volume_id=None, item=None): |
371 | 995 | """A entry for 'path' was added to the folder list.""" | 981 | """A entry for 'path' was added to the folder list.""" |
372 | 996 | folders = self.ui.ui.folders | 982 | folders = self.ui.ui.folders |
373 | 997 | if item is None: # grab the last one added | ||
374 | 998 | item = folders.topLevelItem(folders.topLevelItemCount() - 1) | ||
375 | 999 | 983 | ||
376 | 1000 | if path == MUSIC_PATH: | 984 | if path == MUSIC_PATH: |
377 | 1001 | display_name = gui.MUSIC_DISPLAY_NAME | 985 | display_name = gui.MUSIC_DISPLAY_NAME |
378 | 1002 | else: | 986 | else: |
379 | 1003 | display_name = path.replace(USER_HOME + os.path.sep, '') | 987 | display_name = path.replace(USER_HOME + os.path.sep, '') |
380 | 988 | if item is None: # search for it | ||
381 | 989 | items = folders.findItems(display_name, | ||
382 | 990 | QtCore.Qt.MatchFixedString | QtCore.Qt.MatchCaseSensitive, | ||
383 | 991 | gui.FOLDER_NAME_COL) | ||
384 | 992 | self.assertEqual(len(items), 1) | ||
385 | 993 | item = items[0] | ||
386 | 1004 | self.assertEqual(display_name, | 994 | self.assertEqual(display_name, |
387 | 1005 | unicode(item.text(gui.LOCAL_SUBSCRIPTION_COL))) | 995 | unicode(item.text(gui.LOCAL_SUBSCRIPTION_COL))) |
388 | 1006 | 996 | ||
389 | @@ -1093,10 +1083,6 @@ | |||
390 | 1093 | # the following will execute update_sizes once | 1083 | # the following will execute update_sizes once |
391 | 1094 | # will fill in all the path sizes for the already added folders | 1084 | # will fill in all the path sizes for the already added folders |
392 | 1095 | self.timer.timeout.emit() | 1085 | self.timer.timeout.emit() |
393 | 1096 | |||
394 | 1097 | folders = self.ui.ui.folders | ||
395 | 1098 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) | ||
396 | 1099 | |||
397 | 1100 | volumes = [] | 1086 | volumes = [] |
398 | 1101 | for _, _, vols in volumes_info: | 1087 | for _, _, vols in volumes_info: |
399 | 1102 | volumes.extend(vols) | 1088 | volumes.extend(vols) |
400 | @@ -1107,28 +1093,14 @@ | |||
401 | 1107 | not bool(volume['subscribed'])): | 1093 | not bool(volume['subscribed'])): |
402 | 1108 | # non-folders or unsubscribed should not appear in the tree | 1094 | # non-folders or unsubscribed should not appear in the tree |
403 | 1109 | continue | 1095 | continue |
404 | 1110 | |||
405 | 1111 | item = treeiter.value() | ||
406 | 1112 | self.assertTrue(item is not None) | ||
407 | 1113 | self.assert_folder_added(volume['path'], | 1096 | self.assert_folder_added(volume['path'], |
413 | 1114 | volume_id=volume['volume_id'], item=item) | 1097 | volume_id=volume['volume_id']) |
409 | 1115 | |||
410 | 1116 | treeiter += 1 | ||
411 | 1117 | item = treeiter.value() | ||
412 | 1118 | |||
414 | 1119 | for folder in gui.default_folders(USER_HOME): | 1098 | for folder in gui.default_folders(USER_HOME): |
415 | 1120 | valid = yield self.validate_path(folder) | 1099 | valid = yield self.validate_path(folder) |
416 | 1121 | if not valid: | 1100 | if not valid: |
417 | 1122 | continue # invalid folders should not appear in the tree | 1101 | continue # invalid folders should not appear in the tree |
427 | 1123 | 1102 | self.assert_folder_added(folder, volume_id=None, item=None) | |
428 | 1124 | item = treeiter.value() | 1103 | |
420 | 1125 | self.assertTrue(item is not None) | ||
421 | 1126 | self.assert_folder_added(folder, volume_id=None, item=item) | ||
422 | 1127 | |||
423 | 1128 | treeiter += 1 | ||
424 | 1129 | item = treeiter.value() | ||
425 | 1130 | |||
426 | 1131 | self.assertTrue(item is None) | ||
429 | 1132 | self.assert_space_header_correct(ACCOUNT_INFO['quota_used']) | 1104 | self.assert_space_header_correct(ACCOUNT_INFO['quota_used']) |
430 | 1133 | 1105 | ||
431 | 1134 | @defer.inlineCallbacks | 1106 | @defer.inlineCallbacks |
432 | @@ -1219,13 +1191,13 @@ | |||
433 | 1219 | class LocalFoldersPanelAddFolderTestCase(BaseLocalFoldersPanelTestCase): | 1191 | class LocalFoldersPanelAddFolderTestCase(BaseLocalFoldersPanelTestCase): |
434 | 1220 | """Test suite for the add_folder method from LocalFoldersPanel.""" | 1192 | """Test suite for the add_folder method from LocalFoldersPanel.""" |
435 | 1221 | 1193 | ||
437 | 1222 | def test_folder_is_added(self, folder_path=None): | 1194 | def test_folder_is_added(self, folder_path=None, suggested=None): |
438 | 1223 | """Adding a folder adds it to the folder list.""" | 1195 | """Adding a folder adds it to the folder list.""" |
439 | 1224 | former_count = self.ui.ui.folders.topLevelItemCount() | 1196 | former_count = self.ui.ui.folders.topLevelItemCount() |
440 | 1225 | 1197 | ||
441 | 1226 | if folder_path is None: | 1198 | if folder_path is None: |
442 | 1227 | folder_path = self.path | 1199 | folder_path = self.path |
444 | 1228 | self.ui.add_folder(folder_path) | 1200 | self.ui.add_folder(folder_path, suggested=suggested) |
445 | 1229 | 1201 | ||
446 | 1230 | new_count = self.ui.ui.folders.topLevelItemCount() | 1202 | new_count = self.ui.ui.folders.topLevelItemCount() |
447 | 1231 | self.assertEqual(new_count, former_count + 1) | 1203 | self.assertEqual(new_count, former_count + 1) |
448 | @@ -1233,7 +1205,14 @@ | |||
449 | 1233 | 1205 | ||
450 | 1234 | def test_add_music_folder_adds_the_folder(self): | 1206 | def test_add_music_folder_adds_the_folder(self): |
451 | 1235 | """Adding the purchased music folder adds it to the folder list.""" | 1207 | """Adding the purchased music folder adds it to the folder list.""" |
453 | 1236 | self.test_folder_is_added(folder_path=MUSIC_PATH) | 1208 | self.test_folder_is_added(folder_path=MUSIC_PATH, |
454 | 1209 | suggested=MUSIC_REAL_PATH) | ||
455 | 1210 | |||
456 | 1211 | def test_add_music_folder_adds_the_folder_with_suggested_path(self): | ||
457 | 1212 | """Adding the purchased music folder adds it to the folder list.""" | ||
458 | 1213 | suggested_path = '~/' + MUSIC_REAL_PATH | ||
459 | 1214 | self.test_folder_is_added(folder_path=MUSIC_PATH, | ||
460 | 1215 | suggested=suggested_path) | ||
461 | 1237 | 1216 | ||
462 | 1238 | def test_do_not_add_twice(self): | 1217 | def test_do_not_add_twice(self): |
463 | 1239 | """The same folder will not be added twice.""" | 1218 | """The same folder will not be added twice.""" |
Looks OK to me.