on xenial help sign in
Unify ScopeView and GenericScopeView

. Approved by PS Jenkins bot, Nick Dedekind.

commita5682baa5a0884668729b70dcd10c4e121ee7a19 authorAlbert Astals <albert.astals@canonical.com> dateTue 19 Nov 2013, 04:53 (13 years ago) parent7ef50f79f02dd3
8 files changed+81−192
Dash/GenericScopeView.qml+47−2 Dash/ScopeView.qml−65 tests/qmltests/CMakeLists.txt−1 tests/qmltests/Dash/qml/FakeScopeView.qml+3−69 tests/qmltests/Dash/tst_DashContent.qml+22−3 tests/qmltests/Dash/tst_GenericScopeView.qml+7 tests/qmltests/Dash/tst_ScopeView.qml−52 tests/utils/modules/Unity/Test/UnityTestCase.qml+2
Dash/GenericScopeView.qml+47−2
@@ -16,15 +16,60 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import Utils 0.1
20+import Unity 0.1
1921import "../Components"
2022import "../Components/ListItems" as ListItems
2123
22−ScopeView {
24+FocusScope {
2325 id: scopeView
26+
27+ property Scope scope
28+ property SortFilterProxyModel categories: categoryFilter
29+ property bool isCurrent
30+ property ListModel searchHistory
31+ property alias moving: categoryView.moving
32+
33+ signal endReached
34+ signal movementStarted
35+ signal positionedAtBeginning
36+
2437 readonly property alias previewShown: previewListView.onScreen
2538 property bool enableHeightBehaviorOnNextCreation: false
2639
27− moving: categoryView.moving
40+ // FIXME delay the search so that daemons have time to settle, note that
41+ // removing this will break ScopeView::test_changeScope
42+ onScopeChanged: {
43+ if (scope) {
44+ timer.restart();
45+ scope.activateApplication.connect(activateApp);
46+ }
47+ }
48+
49+ function activateApp(desktopFilePath) {
50+ shell.activateApplication(desktopFilePath);
51+ }
52+
53+ Binding {
54+ target: scope
55+ property: "isActive"
56+ value: isCurrent
57+ }
58+
59+ Timer {
60+ id: timer
61+ interval: 2000
62+ onTriggered: scope.searchQuery = ""
63+ }
64+
65+ SortFilterProxyModel {
66+ id: categoryFilter
67+ model: scope ? scope.categories : null
68+ dynamicSortFilter: true
69+ filterRole: Categories.RoleCount
70+ filterRegExp: /^0$/
71+ invertMatch: true
72+ }
2873
2974 onIsCurrentChanged: {
3075 pageHeader.resetSearch();
Dash/ScopeView.qmldeleted−65
@@ -1,65 +0,0 @@
1−/*
2− * Copyright (C) 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 Utils 0.1
19−import Unity 0.1
20−
21−FocusScope {
22− property Scope scope
23− property SortFilterProxyModel categories: categoryFilter
24− property bool isCurrent
25− property ListModel searchHistory
26− property bool moving: false
27−
28− signal endReached
29− signal movementStarted
30− signal positionedAtBeginning
31−
32− // FIXME delay the search so that daemons have time to settle, note that
33− // removing this will break ScopeView::test_changeScope
34− onScopeChanged: {
35− if (scope) {
36− timer.restart();
37− scope.activateApplication.connect(activateApp);
38− }
39− }
40−
41− function activateApp(desktopFilePath) {
42− shell.activateApplication(desktopFilePath);
43− }
44−
45− Binding {
46− target: scope
47− property: "isActive"
48− value: isCurrent
49− }
50−
51− Timer {
52− id: timer
53− interval: 2000
54− onTriggered: scope.searchQuery = ""
55− }
56−
57− SortFilterProxyModel {
58− id: categoryFilter
59− model: scope ? scope.categories : null
60− dynamicSortFilter: true
61− filterRole: Categories.RoleCount
62− filterRegExp: /^0$/
63− invertMatch: true
64− }
65−}
tests/qmltests/CMakeLists.txt−1
@@ -45,7 +45,6 @@ add_qml_test(Dash DashContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest
4545add_qml_test(Dash DashPreview)
4646add_qml_test(Dash GenericPreview)
4747add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
48−add_qml_test(Dash ScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
4948add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
5049 ${CMAKE_BINARY_DIR}/tests/mocks)
5150add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
tests/qmltests/Dash/qml/FakeScopeView.qml+3−69
@@ -19,14 +19,13 @@ import Unity 0.1
1919
2020import "../../../../Dash"
2121
22−ScopeView {
22+GenericScopeView {
2323 id: fakeScopeView
2424
2525 property alias backColor : back.color
26− moving: listView.moving
2726
2827 onEndReached: {
29− if (shell != undefined && shell.scopeStatus != undefined) {
28+ if (scope != undefined && shell != undefined && shell.scopeStatus != undefined) {
3029 shell.scopeStatus[scope.id].endReached++;
3130 }
3231 }
@@ -45,71 +44,6 @@ ScopeView {
4544 id: back
4645 anchors.fill: parent
4746 color: "grey"
48− }
49−
50− function randomBg()
51− {
52− var hex1=new Array("4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
53− var bg="#"+hex1[Math.floor(Math.random()*hex1.length)]+
54− hex1[Math.floor(Math.random()*hex1.length)]+
55− hex1[Math.floor(Math.random()*hex1.length)]+
56− hex1[Math.floor(Math.random()*hex1.length)]+
57− hex1[Math.floor(Math.random()*hex1.length)]+
58− hex1[Math.floor(Math.random()*hex1.length)]
59− return bg
60− }
61−
62−
63− ListView {
64− id: listView
65− anchors.fill: parent
66− model: scope ? scope.categories : null
67− orientation: ListView.Vertical
68−
69− delegate: Column {
70− id: column
71− width: listView.width
72− height: childrenRect.height
73−
74− Rectangle {
75− width: listView.width
76− height: units.gu(3)
77− color: randomBg()
78−
79− Text {
80− text: name
81− font.family: "Ubuntu"
82− font.weight: Font.Bold
83− font.pixelSize: 20
84− anchors.horizontalCenter: parent.horizontalCenter
85− }
86− }
87− GridView {
88− id: resultsGrid
89− model: results
90− cellWidth: units.gu(10); cellHeight: units.gu(10)
91− height: childrenRect.height
92− width: listView.width
93− interactive: false
94−
95− delegate: Component {
96− id: resultDelegate
97− Item {
98− width: resultsGrid.cellWidth; height: resultsGrid.cellHeight
99− Column {
100− anchors.verticalCenter: parent.verticalCenter
101− anchors.horizontalCenter: parent.horizontalCenter
102− Image {
103− width: units.gu(5)
104− height: units.gu(5)
105− source: icon
106− anchors.horizontalCenter: parent.horizontalCenter
107− }
108− Text { text: title; anchors.horizontalCenter: parent.horizontalCenter }
109− }
110− }
111− }
112− }
113− }
47+ z: -1
11448 }
11549}
tests/qmltests/Dash/tst_DashContent.qml+22−3
@@ -28,6 +28,18 @@ Item {
2828
2929 property ListModel searchHistory: ListModel {}
3030
31+ Item {
32+ // Fake. Make a few components less noisy
33+ id: greeter
34+ signal shownChanged
35+ }
36+
37+ Item {
38+ // Fake. Make a few components less noisy
39+ id: panel
40+ signal searchClicked
41+ }
42+
3143 property var scopeStatus: {
3244 'MockScope1': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
3345 'MockScope2': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
@@ -111,10 +123,17 @@ Item {
111123 clear_scope_status();
112124 dashContent.visible = true;
113125
114− scopesModel.clear();
115− // wait for dash to empty scopes.
116126 var dashContentList = findChild(dashContent, "dashContentList");
117127 verify(dashContentList != undefined);
128+ // TODO For Qt 5.2 remove this wait
129+ // and the tryCompare and see if it still crashes when
130+ // looping the test
131+ wait(1000);
132+ if (dashContentList.currentItem !== null) {
133+ tryCompare(dashContentList.currentItem, "moving", false);
134+ }
135+ scopesModel.clear();
136+ // wait for dash to empty scopes.
118137 tryCompare(dashContentList, "count", 0);
119138 }
120139
@@ -237,7 +256,7 @@ Item {
237256
238257 var startX = dashContentList.width/2;
239258 var startY = dashContentList.height/2;
240− touchFlick(dashContentList, startX, startY, startX, startY - units.gu(800));
259+ touchFlick(dashContentList, startX, startY, startX, startY - units.gu(80));
241260
242261 tryCompare(dashContentList.currentItem, "moving", true);
243262
tests/qmltests/Dash/tst_GenericScopeView.qml+7
@@ -190,6 +190,13 @@ Item {
190190
191191 closePreview();
192192 }
193+
194+ function test_changeScope() {
195+ genericScopeView.scope.searchQuery = "test"
196+ genericScopeView.scope = scopes.get(1)
197+ genericScopeView.scope = scopes.get(0)
198+ tryCompare(genericScopeView.scope, "searchQuery", "")
199+ }
193200 }
194201 }
195202}
tests/qmltests/Dash/tst_ScopeView.qmldeleted−52
@@ -1,52 +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 Unity 0.1
20−import ".."
21−import "../../../Dash"
22−import Ubuntu.Components 0.1
23−
24−Item {
25− width: units.gu(120)
26− height: units.gu(80)
27−
28− Scopes {
29− id: scopes
30− }
31−
32− ScopeView {
33− id: scopeView
34− anchors.fill: parent
35−
36− TestCase {
37− name: "ScopeView"
38− when: scopes.loaded
39−
40− function init() {
41− scopeView.scope = scopes.get(0)
42− }
43−
44− function test_changeScope() {
45− scopeView.scope.searchQuery = "test"
46− scopeView.scope = scopes.get(1)
47− scopeView.scope = scopes.get(0)
48− tryCompare(scopeView.scope, "searchQuery", "")
49− }
50− }
51− }
52−}
tests/utils/modules/Unity/Test/UnityTestCase.qml+2
@@ -214,6 +214,8 @@ TestCase {
214214
215215 // speed is in pixels/second
216216 function touchFlick(item, x, y, toX, toY, beginTouch, endTouch, speed, iterations) {
217+ // Make sure the item is rendered
218+ waitForRendering(item);
217219
218220 // Default to true for beginTouch if not present
219221 beginTouch = (beginTouch !== undefined) ? beginTouch : true