on xenial help sign in
Another test that works on old files
commitd7ec8968bf7d0e47b1179bc41a2febbf82df21c6 authorAlbert Astals <albert.astals@canonical.com> dateMon 24 Feb 2014, 16:26 (13 years ago) parent854d060
2 files changed−145
tests/qmltests/CMakeLists.txt−2 tests/qmltests/Dash/tst_FilterGrids.qml−143
tests/qmltests/CMakeLists.txt−2
@@ -43,8 +43,6 @@ add_qml_test(Dash Card)
4343add_qml_test(Dash CardHeader)
4444add_qml_test(Dash CardTool)
4545add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
46−add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
47− ${CMAKE_BINARY_DIR}/tests/mocks)
4846add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
4947 ${CMAKE_BINARY_DIR}/tests/mocks
5048 ${CMAKE_BINARY_DIR}/plugins)
tests/qmltests/Dash/tst_FilterGrids.qmldeleted−143
@@ -1,143 +0,0 @@
1−/*
2− * Copyright 2013 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import "../../../qml/Dash/Video"
20−import Ubuntu.Components.ListItems 0.1 as ListItem
21−import Ubuntu.Components 0.1
22−import Unity.Test 0.1 as UT
23−import "../"
24−
25−Rectangle {
26− id: shell
27− width: gridRect.width + controls.width
28− height: units.gu(50)
29− color: "white"
30−
31− Column {
32− id: controls
33− width: units.gu(30)
34− height: parent.height
35− anchors.top: parent.top
36− anchors.right: parent.right
37− spacing: units.gu(1)
38− Label {
39− id: spyLabel
40− color: "blue"
41− text: "Clicked item: [none]"
42− anchors {left: parent.left; right: parent.right; margins: units.gu(1) }
43− }
44− Repeater {
45− model: testCase.test_clicked_signal_data()
46− Button {
47− anchors {left: parent.left; right: parent.right; margins: units.gu(1) }
48− text: testCase.test_clicked_signal_data()[index].tag
49− onClicked: gridLoader.source = "../../../qml/Dash/" + testCase.test_clicked_signal_data()[index].component
50− }
51− }
52− }
53−
54− ListModel {
55− id: fakeModel
56− ListElement { icon: "../../graphics/clock.png"; title: "Item0"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
57− ListElement { icon: "../../graphics/clock.png"; title: "Item1"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
58− ListElement { icon: "../../graphics/clock.png"; title: "Item2"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
59− ListElement { icon: "../../graphics/clock.png"; title: "Item3"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
60− ListElement { icon: "../../graphics/clock.png"; title: "Item4"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
61− ListElement { icon: "../../graphics/clock.png"; title: "Item5"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
62− ListElement { icon: "../../graphics/clock.png"; title: "Item6"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
63− ListElement { icon: "../../graphics/clock.png"; title: "Item7"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
64− ListElement { icon: "../../graphics/clock.png"; title: "Item8"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
65− ListElement { icon: "../../graphics/clock.png"; title: "Item9"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
66− ListElement { icon: "../../graphics/clock.png"; title: "Item10"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
67− ListElement { icon: "../../graphics/clock.png"; title: "Item11"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
68− ListElement { icon: "../../graphics/clock.png"; title: "Item12"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
69− ListElement { icon: "../../graphics/clock.png"; title: "Item13"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
70− ListElement { icon: "../../graphics/clock.png"; title: "Item14"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
71− ListElement { icon: "../../graphics/clock.png"; title: "Item15"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
72− ListElement { icon: "../../graphics/clock.png"; title: "Item16"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
73− ListElement { icon: "../../graphics/clock.png"; title: "Item17"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
74− ListElement { icon: "../../graphics/clock.png"; title: "Item18"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
75− ListElement { icon: "../../graphics/clock.png"; title: "Item19"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
76− }
77−
78− Rectangle {
79− id: gridRect
80− width: units.gu(50)
81− height: parent.height
82− color: "grey"
83− anchors.top: parent.top
84− anchors.left: parent.left
85−
86− Loader {
87− id: gridLoader
88− anchors.fill: parent
89−
90− onProgressChanged: {
91− if (progress == 1) {
92− item.model = fakeModel
93− }
94− }
95− }
96−
97− Connections {
98− target: gridLoader.item
99− onClicked: spyLabel.text = "Clicked index: " + index
100− }
101− }
102−
103− UT.UnityTestCase {
104− id: testCase
105− name: "FilterGrids"
106− when: windowShown
107−
108− function test_clicked_signal_data() {
109− return [
110− {tag: "VideoFilterGrid", component: "Video/VideoFilterGrid.qml"},
111− {tag: "MusicFilterGrid", component: "Music/MusicFilterGrid.qml"}
112− ]
113− }
114−
115− function test_clicked_signal(data) {
116− gridLoader.source = "";
117− gridLoader.source = "../../../qml/Dash/" + data.component;
118−
119− // Wait until the FilterGrid is loaded by the loader
120− tryCompare(gridLoader, "status", Loader.Ready);
121−
122− // Wait until the GridView inside the model has finished rendering
123− var gridView = findChild(gridLoader, "responsiveGridViewGrid");
124− gridView.forceLayout();
125− waitForRendering(gridView);
126−
127− // Click item 1
128− var tile1 = findChild(gridLoader.item, "delegate1");
129− verify(tile1 !== undefined, "delegate1 wasn't found");
130− clickedSpy.clear()
131− mouseClick(tile1, tile1.width/2, tile1.height/2);
132−
133− // Check emission of clicked() signal with the according index as argument
134− compare(clickedSpy.signalArguments[0][0], 1, "Clicked index is not the same as the one actually clicked")
135− }
136− }
137−
138− SignalSpy {
139− id: clickedSpy
140− signalName: "clicked"
141− target: gridLoader.item
142− }
143−}