on xenial help sign in
Add a test for the carousel showing the preview when being clicked
3be0560Albert Astals
Dash/Generic/GenericCarousel.qml+1
@@ -28,6 +28,7 @@ DashCarousel {
28
28
29 BaseCarouselDelegate {
29 BaseCarouselDelegate {
30 id: item
30 id: item
31+ objectName: "carouselDelegate"
31
32
32 UbuntuShape {
33 UbuntuShape {
33 anchors.fill: parent
34 anchors.fill: parent
tests/mocks/Unity/fake_scope.cpp+1−1
@@ -204,7 +204,7 @@ DeeModel* create_categories_model(unsigned category_count) {
204 std::to_string(i).c_str(),
204 std::to_string(i).c_str(),
205 ("Category "+std::to_string(i)).c_str(),
205 ("Category "+std::to_string(i)).c_str(),
206 "gtk-apply",
206 "gtk-apply",
207− "grid",
207+ i % 2 == 0 ? "grid" : "carousel",
208 hints);
208 hints);
209 }
209 }
210 return category_model;
210 return category_model;
tests/qmltests/Dash/tst_GenericScopeView.qml+29
@@ -222,6 +222,35 @@ Item {
222 genericScopeView.scope = scopes.get(0)
222 genericScopeView.scope = scopes.get(0)
223 tryCompare(genericScopeView.scope, "searchQuery", "")
223 tryCompare(genericScopeView.scope, "searchQuery", "")
224 }
224 }
225+
226+ function test_showPreviewCarousel() {
227+ tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != undefined; }, true);
228+ var tile = findChild(genericScopeView, "carouselDelegate");
229+ mouseClick(tile, tile.width / 2, tile.height / 2);
230+ var openEffect = findChild(genericScopeView, "openEffect");
231+ tryCompare(openEffect, "gap", 1);
232+
233+ // check for it opening successfully
234+ var previewListView = findChild(genericScopeView, "previewListView");
235+ var currentPreviewItem = findChild(genericScopeView, "previewLoader0");
236+ tryCompareFunction(function() {
237+ var parts = currentPreviewItem.source.toString().split("/");
238+ var name = parts[parts.length - 1];
239+ return name == "DashPreviewPlaceholder.qml";
240+ },
241+ true);
242+ tryCompareFunction(function() {
243+ var parts = currentPreviewItem.source.toString().split("/");
244+ var name = parts[parts.length - 1];
245+ return name == "GenericPreview.qml";
246+ },
247+ true);
248+ tryCompare(currentPreviewItem, "progress", 1);
249+ tryCompare(previewListView, "open", true);
250+
251+ closePreview();
252+ tryCompare(previewListView, "open", false);
253+ }
225 }
254 }
226 }
255 }
227}
256}