Merge lp:~uriboni/camera-app/share-multiple-items into lp:camera-app/staging
- share-multiple-items
- Merge into staging
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Florian Boucault | ||||
Approved revision: | 670 | ||||
Merged at revision: | 665 | ||||
Proposed branch: | lp:~uriboni/camera-app/share-multiple-items | ||||
Merge into: | lp:camera-app/staging | ||||
Diff against target: |
396 lines (+243/-20) 8 files modified
GalleryView.qml (+1/-3) PhotogridView.qml (+30/-4) UnableShareDialog.qml (+34/-0) camera-app.qml (+1/-1) debian/control (+3/-0) tests/autopilot/camera_app/tests/test_gallery_view.py (+85/-11) tests/unittests/CMakeLists.txt (+1/-1) tests/unittests/tst_PhotogridView.qml (+88/-0) |
||||
To merge this branch: | bzr merge lp:~uriboni/camera-app/share-multiple-items | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Florian Boucault (community) | Needs Fixing | ||
Review via email: mp+287895@code.launchpad.net |
Commit message
Allow sharing multiple files, except if they are mixed content
Description of the change
Allow sharing multiple files, except if they are mixed content
Florian Boucault (fboucault) wrote : | # |
In some cases when selecting 3 photos camera thinks I have mixed type contents. The function selectedFilesMi
Florian Boucault (fboucault) wrote : | # |
Going to messaging app and trying to share pictures via the camera app: unable to tick more than 1 picture. Without this patch, it works fine.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:662
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 663. By Ugo Riboni
-
Fix and simplify mixed media detection, add unit tests for it
- 664. By Ugo Riboni
-
Use single selection mode only in grid view if the content hub explicitly asks for it
- 665. By Ugo Riboni
-
Filter the grid view according to the content type requested by content hub
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:663
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:665
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 666. By Ugo Riboni
-
Allow unit tests to find c++ plugin when run out of tree
- 667. By Ugo Riboni
-
Fix PEP8 issue
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:667
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 668. By Ugo Riboni
-
Add build dependencies needed for unit tests
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:668
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 669. By Ugo Riboni
-
Merge parent branch
- 670. By Ugo Riboni
-
Fix flake8 errors
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:668
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'GalleryView.qml' | |||
2 | --- GalleryView.qml 2016-02-23 11:46:52 +0000 | |||
3 | +++ GalleryView.qml 2016-03-10 12:11:22 +0000 | |||
4 | @@ -35,7 +35,7 @@ | |||
5 | 35 | StorageLocations.removableStorageVideosLocation] | 35 | StorageLocations.removableStorageVideosLocation] |
6 | 36 | typeFilters: !main.contentExportMode ? [ "image", "video" ] | 36 | typeFilters: !main.contentExportMode ? [ "image", "video" ] |
7 | 37 | : [MimeTypeMapper.contentTypeToMimeType(main.transferContentType)] | 37 | : [MimeTypeMapper.contentTypeToMimeType(main.transferContentType)] |
9 | 38 | singleSelectionOnly: main.transfer.selectionType === ContentTransfer.Single | 38 | singleSelectionOnly: main.contentExportMode && main.transfer.selectionType === ContentTransfer.Single |
10 | 39 | } | 39 | } |
11 | 40 | 40 | ||
12 | 41 | property bool gridMode: main.contentExportMode | 41 | property bool gridMode: main.contentExportMode |
13 | @@ -58,7 +58,6 @@ | |||
14 | 58 | 58 | ||
15 | 59 | function exitUserSelectionMode() { | 59 | function exitUserSelectionMode() { |
16 | 60 | model.clearSelection(); | 60 | model.clearSelection(); |
17 | 61 | model.singleSelectionOnly = true; | ||
18 | 62 | userSelectionMode = false; | 61 | userSelectionMode = false; |
19 | 63 | } | 62 | } |
20 | 64 | 63 | ||
21 | @@ -97,7 +96,6 @@ | |||
22 | 97 | onPhotoPressAndHold: { | 96 | onPhotoPressAndHold: { |
23 | 98 | if (!galleryView.userSelectionMode) { | 97 | if (!galleryView.userSelectionMode) { |
24 | 99 | galleryView.userSelectionMode = true; | 98 | galleryView.userSelectionMode = true; |
25 | 100 | model.singleSelectionOnly = false; | ||
26 | 101 | model.toggleSelected(index); | 99 | model.toggleSelected(index); |
27 | 102 | } | 100 | } |
28 | 103 | } | 101 | } |
29 | 104 | 102 | ||
30 | === modified file 'PhotogridView.qml' | |||
31 | --- PhotogridView.qml 2016-03-03 14:12:26 +0000 | |||
32 | +++ PhotogridView.qml 2016-03-10 12:11:22 +0000 | |||
33 | @@ -40,11 +40,14 @@ | |||
34 | 40 | Action { | 40 | Action { |
35 | 41 | text: i18n.tr("Share") | 41 | text: i18n.tr("Share") |
36 | 42 | iconName: "share" | 42 | iconName: "share" |
38 | 43 | enabled: model.selectedFiles.length <= 1 | 43 | enabled: model.selectedFiles.length > 0 |
39 | 44 | onTriggered: { | 44 | onTriggered: { |
43 | 45 | if (model.selectedFiles.length > 0) { | 45 | // Display a warning message if we are attempting to share mixed |
44 | 46 | var dialog = PopupUtils.open(sharePopoverComponent) | 46 | // content, as the framework does not properly support this |
45 | 47 | dialog.parent = photogridView | 47 | if (selectionContainsMixedMedia()) { |
46 | 48 | PopupUtils.open(unableShareDialogComponent).parent = photogridView; | ||
47 | 49 | } else { | ||
48 | 50 | PopupUtils.open(sharePopoverComponent).parent = photogridView; | ||
49 | 48 | } | 51 | } |
50 | 49 | } | 52 | } |
51 | 50 | }, | 53 | }, |
52 | @@ -60,6 +63,19 @@ | |||
53 | 60 | } | 63 | } |
54 | 61 | ] | 64 | ] |
55 | 62 | 65 | ||
56 | 66 | function selectionContainsMixedMedia() { | ||
57 | 67 | var selection = model.selectedFiles; | ||
58 | 68 | var lastType = model.get(selection[0], "fileType"); | ||
59 | 69 | for (var i = 1; i < selection.length; i++) { | ||
60 | 70 | var type = model.get(selection[i], "fileType"); | ||
61 | 71 | if (type !== lastType) { | ||
62 | 72 | return true; | ||
63 | 73 | } | ||
64 | 74 | lastType = type; | ||
65 | 75 | } | ||
66 | 76 | return false; | ||
67 | 77 | } | ||
68 | 78 | |||
69 | 63 | function showPhotoAtIndex(index) { | 79 | function showPhotoAtIndex(index) { |
70 | 64 | gridView.positionViewAtIndex(index, GridView.Center); | 80 | gridView.positionViewAtIndex(index, GridView.Center); |
71 | 65 | } | 81 | } |
72 | @@ -170,6 +186,7 @@ | |||
73 | 170 | visible: inSelectionMode | 186 | visible: inSelectionMode |
74 | 171 | 187 | ||
75 | 172 | Icon { | 188 | Icon { |
76 | 189 | objectName: "mediaItemCheckBox" | ||
77 | 173 | anchors.centerIn: parent | 190 | anchors.centerIn: parent |
78 | 174 | width: parent.width * 0.8 | 191 | width: parent.width * 0.8 |
79 | 175 | height: parent.height * 0.8 | 192 | height: parent.height * 0.8 |
80 | @@ -235,4 +252,13 @@ | |||
81 | 235 | onVisibleChanged: photogridView.toggleHeader() | 252 | onVisibleChanged: photogridView.toggleHeader() |
82 | 236 | } | 253 | } |
83 | 237 | } | 254 | } |
84 | 255 | |||
85 | 256 | Component { | ||
86 | 257 | id: unableShareDialogComponent | ||
87 | 258 | UnableShareDialog { | ||
88 | 259 | objectName: "unableShareDialog" | ||
89 | 260 | onVisibleChanged: photogridView.toggleHeader() | ||
90 | 261 | } | ||
91 | 262 | } | ||
92 | 263 | |||
93 | 238 | } | 264 | } |
94 | 239 | 265 | ||
95 | === added file 'UnableShareDialog.qml' | |||
96 | --- UnableShareDialog.qml 1970-01-01 00:00:00 +0000 | |||
97 | +++ UnableShareDialog.qml 2016-03-10 12:11:22 +0000 | |||
98 | @@ -0,0 +1,34 @@ | |||
99 | 1 | /* | ||
100 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
101 | 3 | * | ||
102 | 4 | * This program is free software: you can redistribute it and/or modify | ||
103 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
104 | 6 | * published by the Free Software Foundation. | ||
105 | 7 | * | ||
106 | 8 | * This program is distributed in the hope that it will be useful, | ||
107 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
108 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
109 | 11 | * GNU General Public License for more details. | ||
110 | 12 | * | ||
111 | 13 | * You should have received a copy of the GNU General Public License | ||
112 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
113 | 15 | */ | ||
114 | 16 | |||
115 | 17 | import QtQuick 2.4 | ||
116 | 18 | import Ubuntu.Components 1.3 | ||
117 | 19 | import Ubuntu.Components.Popups 1.3 | ||
118 | 20 | |||
119 | 21 | Dialog { | ||
120 | 22 | id: dialog | ||
121 | 23 | objectName: "unableShareDialog" | ||
122 | 24 | |||
123 | 25 | title: i18n.tr("Unable to share") | ||
124 | 26 | text: i18n.tr("Unable to share photos and videos at the same time") | ||
125 | 27 | |||
126 | 28 | Button { | ||
127 | 29 | objectName: "unableShareDialogOk" | ||
128 | 30 | text: i18n.tr("Ok") | ||
129 | 31 | color: UbuntuColors.orange | ||
130 | 32 | onClicked: PopupUtils.close(dialog); | ||
131 | 33 | } | ||
132 | 34 | } | ||
133 | 0 | 35 | ||
134 | === modified file 'camera-app.qml' | |||
135 | --- camera-app.qml 2016-03-08 14:42:51 +0000 | |||
136 | +++ camera-app.qml 2016-03-10 12:11:22 +0000 | |||
137 | @@ -282,7 +282,7 @@ | |||
138 | 282 | 282 | ||
139 | 283 | property bool contentExportMode: transfer !== null | 283 | property bool contentExportMode: transfer !== null |
140 | 284 | property var transfer: null | 284 | property var transfer: null |
142 | 285 | property var transferContentType: ContentType.Pictures | 285 | property var transferContentType: transfer ? transfer.contentType : "image" |
143 | 286 | 286 | ||
144 | 287 | function exportContent(urls) { | 287 | function exportContent(urls) { |
145 | 288 | if (!main.transfer) return; | 288 | if (!main.transfer) return; |
146 | 289 | 289 | ||
147 | === modified file 'debian/control' | |||
148 | --- debian/control 2015-07-31 02:23:54 +0000 | |||
149 | +++ debian/control 2016-03-10 12:11:22 +0000 | |||
150 | @@ -13,11 +13,14 @@ | |||
151 | 13 | qtbase5-dev, | 13 | qtbase5-dev, |
152 | 14 | qtdeclarative5-dev, | 14 | qtdeclarative5-dev, |
153 | 15 | qml-module-qtquick2, | 15 | qml-module-qtquick2, |
154 | 16 | qml-module-qtpositioning, | ||
155 | 16 | qml-module-qttest, | 17 | qml-module-qttest, |
156 | 17 | qtdeclarative5-ubuntu-ui-toolkit-plugin, | 18 | qtdeclarative5-ubuntu-ui-toolkit-plugin, |
157 | 18 | qtdeclarative5-unity-action-plugin (>= 1.1.0), | 19 | qtdeclarative5-unity-action-plugin (>= 1.1.0), |
158 | 19 | qtdeclarative5-usermetrics0.1, | 20 | qtdeclarative5-usermetrics0.1, |
159 | 20 | qtdeclarative5-ubuntu-content1, | 21 | qtdeclarative5-ubuntu-content1, |
160 | 22 | qtdeclarative5-ubuntu-thumbnailer0.1, | ||
161 | 23 | qtdeclarative5-ubuntu-ui-extras0.2, | ||
162 | 21 | qtmultimedia5-dev, | 24 | qtmultimedia5-dev, |
163 | 22 | libusermetricsinput1-dev, | 25 | libusermetricsinput1-dev, |
164 | 23 | gettext, | 26 | gettext, |
165 | 24 | 27 | ||
166 | === modified file 'tests/autopilot/camera_app/tests/test_gallery_view.py' | |||
167 | --- tests/autopilot/camera_app/tests/test_gallery_view.py 2016-03-02 14:35:50 +0000 | |||
168 | +++ tests/autopilot/camera_app/tests/test_gallery_view.py 2016-03-10 12:11:22 +0000 | |||
169 | @@ -35,16 +35,21 @@ | |||
170 | 35 | self.assertThat(slideshow_view.visible, Eventually(Equals(False))) | 35 | self.assertThat(slideshow_view.visible, Eventually(Equals(False))) |
171 | 36 | self.assertThat(photogrid_view.visible, Eventually(Equals(True))) | 36 | self.assertThat(photogrid_view.visible, Eventually(Equals(True))) |
172 | 37 | 37 | ||
175 | 38 | def select_first_photo(self): | 38 | def select_media(self, index=0): |
176 | 39 | # select the first photo | 39 | # select the photo with index, default to the first one |
177 | 40 | gallery = self.main_window.get_gallery() | 40 | gallery = self.main_window.get_gallery() |
185 | 41 | photo = gallery.wait_select_single(objectName="mediaItem0") | 41 | photo = gallery.wait_select_single(objectName="mediaItem" + str(index)) |
186 | 42 | self.pointing_device.move_to_object(photo) | 42 | checkbox = photo.wait_select_single(objectName="mediaItemCheckBox") |
187 | 43 | 43 | ||
188 | 44 | # do a long press to enter Multiselection mode | 44 | self.pointing_device.move_to_object(checkbox) |
189 | 45 | self.pointing_device.press() | 45 | |
190 | 46 | sleep(1) | 46 | if checkbox.visible: |
191 | 47 | self.pointing_device.release() | 47 | self.click() |
192 | 48 | else: | ||
193 | 49 | # do a long press to enter Multiselection mode | ||
194 | 50 | self.pointing_device.press() | ||
195 | 51 | sleep(1) | ||
196 | 52 | self.pointing_device.release() | ||
197 | 48 | 53 | ||
198 | 49 | 54 | ||
199 | 50 | class TestCameraGalleryView(CameraAppTestCase, TestCameraGalleryViewMixin): | 55 | class TestCameraGalleryView(CameraAppTestCase, TestCameraGalleryViewMixin): |
200 | @@ -186,7 +191,7 @@ | |||
201 | 186 | def test_delete_photo_from_multiselection(self): | 191 | def test_delete_photo_from_multiselection(self): |
202 | 187 | self.main_window.swipe_to_gallery(self) | 192 | self.main_window.swipe_to_gallery(self) |
203 | 188 | self.move_from_slideshow_to_photogrid() | 193 | self.move_from_slideshow_to_photogrid() |
205 | 189 | self.select_first_photo() | 194 | self.select_media() |
206 | 190 | 195 | ||
207 | 191 | # open actions drawer | 196 | # open actions drawer |
208 | 192 | gallery = self.main_window.get_gallery() | 197 | gallery = self.main_window.get_gallery() |
209 | @@ -211,7 +216,7 @@ | |||
210 | 211 | def test_multiselection_mode(self): | 216 | def test_multiselection_mode(self): |
211 | 212 | self.main_window.swipe_to_gallery(self) | 217 | self.main_window.swipe_to_gallery(self) |
212 | 213 | self.move_from_slideshow_to_photogrid() | 218 | self.move_from_slideshow_to_photogrid() |
214 | 214 | self.select_first_photo() | 219 | self.select_media() |
215 | 215 | 220 | ||
216 | 216 | # exit the multiselection mode | 221 | # exit the multiselection mode |
217 | 217 | gallery = self.main_window.get_gallery() | 222 | gallery = self.main_window.get_gallery() |
218 | @@ -224,3 +229,72 @@ | |||
219 | 224 | 229 | ||
220 | 225 | self.assertThat(slideshow_view.visible, Eventually(Equals(False))) | 230 | self.assertThat(slideshow_view.visible, Eventually(Equals(False))) |
221 | 226 | self.assertThat(photogrid_view.visible, Eventually(Equals(True))) | 231 | self.assertThat(photogrid_view.visible, Eventually(Equals(True))) |
222 | 232 | |||
223 | 233 | |||
224 | 234 | class TestCameraGalleryViewWithPhotosAndVideo( | ||
225 | 235 | TestCameraGalleryViewMixin, CameraAppTestCase): | ||
226 | 236 | """Tests the camera gallery view with two photos and a video""" | ||
227 | 237 | |||
228 | 238 | def setUp(self): | ||
229 | 239 | self.delete_all_media() | ||
230 | 240 | self.add_sample_photo() | ||
231 | 241 | self.add_sample_video() | ||
232 | 242 | |||
233 | 243 | super(TestCameraGalleryViewWithPhotosAndVideo, self).setUp() | ||
234 | 244 | self.assertThat( | ||
235 | 245 | self.main_window.get_qml_view().visible, Eventually(Equals(True))) | ||
236 | 246 | |||
237 | 247 | def tearDown(self): | ||
238 | 248 | super(TestCameraGalleryViewWithPhotosAndVideo, self).tearDown() | ||
239 | 249 | |||
240 | 250 | def verify_share_state(self, expectedState, close=True): | ||
241 | 251 | # open actions drawer | ||
242 | 252 | gallery = self.main_window.get_gallery() | ||
243 | 253 | opt = gallery.wait_select_single(objectName="additionalActionsButton") | ||
244 | 254 | self.pointing_device.move_to_object(opt) | ||
245 | 255 | self.pointing_device.click() | ||
246 | 256 | |||
247 | 257 | # verify expected state | ||
248 | 258 | share = gallery.wait_select_single(objectName="actionButtonShare") | ||
249 | 259 | self.assertThat(share.enabled, Eventually(Equals(expectedState))) | ||
250 | 260 | |||
251 | 261 | if (close): | ||
252 | 262 | # close actions drawer | ||
253 | 263 | self.pointing_device.move_to_object(opt) | ||
254 | 264 | self.pointing_device.click() | ||
255 | 265 | else: | ||
256 | 266 | return share | ||
257 | 267 | |||
258 | 268 | """Tests share button enable or disabled correctly in multiselection""" | ||
259 | 269 | def test_multiselection_share_enabled(self): | ||
260 | 270 | self.main_window.swipe_to_gallery(self) | ||
261 | 271 | self.move_from_slideshow_to_photogrid() | ||
262 | 272 | |||
263 | 273 | # Verify options button disabled until we select something | ||
264 | 274 | gallery = self.main_window.get_gallery() | ||
265 | 275 | opt = gallery.wait_select_single(objectName="additionalActionsButton") | ||
266 | 276 | self.assertThat(opt.visible, Eventually(Equals(False))) | ||
267 | 277 | |||
268 | 278 | # Verify that if we select one photo options and share are enabled | ||
269 | 279 | self.select_media(0) | ||
270 | 280 | self.assertThat(opt.visible, Eventually(Equals(True))) | ||
271 | 281 | self.verify_share_state(True) | ||
272 | 282 | |||
273 | 283 | # Verify that it stays enabled with mixed media selected | ||
274 | 284 | self.select_media(1) | ||
275 | 285 | self.verify_share_state(True) | ||
276 | 286 | |||
277 | 287 | """Tests sharing with mixed media generates a warning dialog""" | ||
278 | 288 | def test_no_share_mixed_media(self): | ||
279 | 289 | self.main_window.swipe_to_gallery(self) | ||
280 | 290 | self.move_from_slideshow_to_photogrid() | ||
281 | 291 | |||
282 | 292 | self.select_media(0) | ||
283 | 293 | self.select_media(1) | ||
284 | 294 | share = self.verify_share_state(True, close=False) | ||
285 | 295 | |||
286 | 296 | self.pointing_device.move_to_object(share) | ||
287 | 297 | self.pointing_device.click() | ||
288 | 298 | |||
289 | 299 | gallery = self.main_window.get_gallery() | ||
290 | 300 | gallery.wait_select_single(objectName="unableShareDialog") | ||
291 | 227 | 301 | ||
292 | === modified file 'tests/unittests/CMakeLists.txt' | |||
293 | --- tests/unittests/CMakeLists.txt 2016-02-26 15:24:03 +0000 | |||
294 | +++ tests/unittests/CMakeLists.txt 2016-03-10 12:11:22 +0000 | |||
295 | @@ -7,7 +7,7 @@ | |||
296 | 7 | add_executable(tst_QmlTests tst_QmlTests.cpp) | 7 | add_executable(tst_QmlTests tst_QmlTests.cpp) |
297 | 8 | qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest) | 8 | qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest) |
298 | 9 | target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES}) | 9 | target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES}) |
300 | 10 | add_test(tst_QmlTests ${XVFB_RUN_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests -import ${CMAKE_SOURCE_DIR}) | 10 | add_test(tst_QmlTests ${XVFB_RUN_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests -import ${CMAKE_SOURCE_DIR} -import ${CMAKE_BINARY_DIR}) |
301 | 11 | 11 | ||
302 | 12 | # copy qml test files to build dir | 12 | # copy qml test files to build dir |
303 | 13 | file(GLOB qmlTestFiles RELATIVE ${CMAKE_SOURCE_DIR}/tests/unittests/ *qml) | 13 | file(GLOB qmlTestFiles RELATIVE ${CMAKE_SOURCE_DIR}/tests/unittests/ *qml) |
304 | 14 | 14 | ||
305 | === added file 'tests/unittests/tst_PhotogridView.qml' | |||
306 | --- tests/unittests/tst_PhotogridView.qml 1970-01-01 00:00:00 +0000 | |||
307 | +++ tests/unittests/tst_PhotogridView.qml 2016-03-10 12:11:22 +0000 | |||
308 | @@ -0,0 +1,88 @@ | |||
309 | 1 | /* | ||
310 | 2 | * Copyright 2016 Canonical Ltd. | ||
311 | 3 | * | ||
312 | 4 | * This program is free software; you can redistribute it and/or modify | ||
313 | 5 | * it under the terms of the GNU General Public License as published by | ||
314 | 6 | * the Free Software Foundation; version 3. | ||
315 | 7 | * | ||
316 | 8 | * This program is distributed in the hope that it will be useful, | ||
317 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
318 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
319 | 11 | * GNU General Public License for more details. | ||
320 | 12 | * | ||
321 | 13 | * You should have received a copy of the GNU General Public License | ||
322 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
323 | 15 | * | ||
324 | 16 | */ | ||
325 | 17 | |||
326 | 18 | import QtQuick 2.4 | ||
327 | 19 | import QtTest 1.0 | ||
328 | 20 | import "../../" | ||
329 | 21 | import "../../.." //Needed for out of source build | ||
330 | 22 | |||
331 | 23 | TestCase { | ||
332 | 24 | name: "PhotogridView" | ||
333 | 25 | |||
334 | 26 | function test_mixedMediaSelection_data() { | ||
335 | 27 | return [ | ||
336 | 28 | { // one item only | ||
337 | 29 | isMixedMedia: false, | ||
338 | 30 | listItems: [ | ||
339 | 31 | { fileType: "image", selected: true, fileURL: "" } | ||
340 | 32 | ] | ||
341 | 33 | }, | ||
342 | 34 | { // mixed media but only non-mixed selected | ||
343 | 35 | isMixedMedia: false, | ||
344 | 36 | listItems: [ | ||
345 | 37 | { fileType: "video", selected: false, fileURL: "" }, | ||
346 | 38 | { fileType: "image", selected: true, fileURL: "" }, | ||
347 | 39 | { fileType: "image", selected: true, fileURL: "" } | ||
348 | 40 | ] | ||
349 | 41 | }, | ||
350 | 42 | { // mixed media | ||
351 | 43 | isMixedMedia: true, | ||
352 | 44 | listItems: [ | ||
353 | 45 | { fileType: "video", selected: true, fileURL: "" }, | ||
354 | 46 | { fileType: "image", selected: true, fileURL: "" }, | ||
355 | 47 | { fileType: "image", selected: true, fileURL: "" } | ||
356 | 48 | ] | ||
357 | 49 | }, | ||
358 | 50 | ]; | ||
359 | 51 | } | ||
360 | 52 | |||
361 | 53 | function test_mixedMediaSelection(data) { | ||
362 | 54 | list.clear() | ||
363 | 55 | list.data = data.listItems; | ||
364 | 56 | for (var i = 0; i < data.listItems.length; i++) { | ||
365 | 57 | list.append(data.listItems[i]); | ||
366 | 58 | } | ||
367 | 59 | list.updateSelectedFiles(); | ||
368 | 60 | grid.model = list | ||
369 | 61 | compare(grid.selectionContainsMixedMedia(), data.isMixedMedia, "Mixed media not detected correctly") | ||
370 | 62 | } | ||
371 | 63 | |||
372 | 64 | ListModel { | ||
373 | 65 | id: list | ||
374 | 66 | property var data | ||
375 | 67 | property var selectedFiles: [] | ||
376 | 68 | function updateSelectedFiles() { | ||
377 | 69 | // need to re-assign entire list due to the way list properties work in QML | ||
378 | 70 | var selected = []; | ||
379 | 71 | for (var i = 0; i < list.count; i++) { | ||
380 | 72 | if (list.data[i].selected) selected.push(i); | ||
381 | 73 | } | ||
382 | 74 | list.selectedFiles = selected; | ||
383 | 75 | } | ||
384 | 76 | function get(i, key) { | ||
385 | 77 | return list.data[i][key]; | ||
386 | 78 | } | ||
387 | 79 | } | ||
388 | 80 | |||
389 | 81 | PhotogridView { | ||
390 | 82 | id: grid | ||
391 | 83 | width: 600 | ||
392 | 84 | height: 800 | ||
393 | 85 | inView: true | ||
394 | 86 | inSelectionMode: true | ||
395 | 87 | } | ||
396 | 88 | } |
code in PhotogridView. qml/onTriggered could be written in a clearer way, for example:
onTriggered: { ixedTypes( )) { open(unableShar eDialogComponen t).parent = photogridView; open(sharePopov erComponent) .parent = photogridView;
if (selectedFilesM
PopupUtils.
} else {
PopupUtils.
}
}