on xenial help sign in
add a testcase for the drawer, implement reveal by edge push
commitac953e92795f040d58e083c48c8b30c8a68407a9 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Nov 2016, 13:02 (10 years ago) parentd64982f
5 files changed+148−8
qml/Launcher/Drawer.qml+4−5 qml/Launcher/Launcher.qml+9−2 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Launcher/tst_Drawer.qml+133 tests/qmltests/Launcher/tst_Launcher.qml+1−1
qml/Launcher/Drawer.qml+4−5
@@ -131,22 +131,21 @@ FocusScope {
131131
132132 Component {
133133 id: debugComponent
134− ListView {
134+ GridView {
135135 anchors.fill: parent
136136 topMargin: units.gu(1)
137137 bottomMargin: units.gu(1)
138− spacing: units.gu(1)
138+// spacing: units.gu(1)
139139 clip: true
140140
141+
141142 model: sortProxyModel
142143// model: AppDrawerProxyModel {
143144// source: sortProxyModel
144145// group: AppDrawerProxyModel.GroupByAToZ
145146// sortBy: AppDrawerProxyModel.SortByAToZ
146147// }
147− delegate: Label {
148− text: model.letter + " - " + model.name
149− }
148+ delegate: drawerDelegateComponent
150149 }
151150 }
152151
qml/Launcher/Launcher.qml+9−2
@@ -137,7 +137,7 @@ FocusScope {
137137 }
138138
139139 function pushEdge(amount) {
140− if (root.state === "") {
140+ if (root.state === "" || root.state == "visible") {
141141 edgeBarrier.push(amount);
142142 }
143143 }
@@ -325,7 +325,13 @@ FocusScope {
325325 edge: Qt.LeftEdge
326326 target: parent
327327 enabled: root.available
328− onPassed: { root.switchToNextState("visibleTemporary"); }
328+ onProgressChanged: {
329+ if (progress > .5 && root.state != "visibleTemporary" && root.state != "drawer" && root.state != "visible") {
330+ root.switchToNextState("visibleTemporary");
331+ }
332+ }
333+ onPassed: { root.switchToNextState("drawer"); }
334+
329335 material: Component {
330336 Item {
331337 Rectangle {
@@ -354,6 +360,7 @@ FocusScope {
354360
355361 Drawer {
356362 id: drawer
363+ objectName: "drawer"
357364 anchors {
358365 top: parent.top
359366 topMargin: root.topPanelHeight
tests/qmltests/CMakeLists.txt+1
@@ -71,6 +71,7 @@ add_unity8_qmltest(Greeter Infographics)
7171add_unity8_qmltest(Greeter NarrowView)
7272add_unity8_qmltest(Greeter WideView)
7373add_unity8_qmltest(Launcher Launcher)
74+add_unity8_qmltest(Launcher Drawer)
7475add_unity8_qmltest(Notifications Notifications)
7576add_unity8_qmltest(Notifications VisualSnapDecisionsQueue)
7677add_unity8_qmltest(Notifications OptionToggle)
tests/qmltests/Launcher/tst_Drawer.qmlnew file+133
@@ -0,0 +1,133 @@
1+/*
2+ * Copyright 2013-2016 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.4
18+import QtQuick.Layouts 1.1
19+import Ubuntu.Components 1.3
20+import ".."
21+import "../../../qml/Launcher"
22+import Unity.Launcher 0.1
23+import Utils 0.1 // For EdgeBarrierSettings
24+import Unity.Test 0.1
25+
26+StyledItem {
27+ id: root
28+ theme.name: "Ubuntu.Components.Themes.SuruDark"
29+
30+ width: units.gu(140)
31+ height: units.gu(70)
32+ Rectangle {
33+ anchors.fill: parent
34+ color: UbuntuColors.graphite // something neither white nor black
35+ }
36+
37+ Launcher {
38+ id: launcher
39+ x: 0
40+ y: 0
41+ width: units.gu(40)
42+ height: root.height
43+
44+ lockedVisible: lockedVisibleCheckBox.checked
45+
46+ Component.onCompleted: {
47+ launcher.focus = true
48+ edgeBarrierControls.target = testCase.findChild(this, "edgeBarrierController");
49+ }
50+ }
51+
52+ ColumnLayout {
53+ anchors { bottom: parent.bottom; right: parent.right; margins: units.gu(1) }
54+ spacing: units.gu(1)
55+ width: childrenRect.width
56+
57+ RowLayout {
58+ CheckBox {
59+ id: lockedVisibleCheckBox
60+ checked: false
61+ }
62+ Label {
63+ text: "Launcher always visible"
64+ }
65+ }
66+
67+ Slider {
68+ id: widthSlider
69+ Layout.fillWidth: true
70+ minimumValue: 6
71+ maximumValue: 12
72+ value: 10
73+ }
74+
75+ MouseTouchEmulationCheckbox {}
76+
77+ EdgeBarrierControls {
78+ id: edgeBarrierControls
79+ text: "Drag here to pull out launcher"
80+ onDragged: { launcher.pushEdge(amount); }
81+ }
82+ }
83+
84+ UnityTestCase {
85+ id: testCase
86+ when: windowShown
87+
88+ function dragDrawerIntoView() {
89+ var startX = launcher.dragAreaWidth/2;
90+ var startY = launcher.height/2;
91+ touchFlick(launcher,
92+ startX, startY,
93+ startX+units.gu(35), startY);
94+
95+ var drawer = findChild(launcher, "drawer");
96+ verify(!!drawer);
97+
98+ // wait until it gets fully extended
99+ // a tryCompare doesn't work since
100+ // compare(-0.000005917593600024418, 0);
101+ // is true and in this case we want exactly 0 or will have pain later on
102+ tryCompareFunction( function(){ return drawer.x === 0; }, true );
103+ tryCompare(launcher, "state", "drawer");
104+ }
105+
106+ function revealByEdgePush() {
107+ // Place the mouse against the window/screen edge and push beyond the barrier threshold
108+ mouseMove(root, 1, root.height / 2);
109+ launcher.pushEdge(EdgeBarrierSettings.pushThreshold * 1.1);
110+
111+ var panel = findChild(launcher, "launcherPanel");
112+ verify(!!panel);
113+
114+ // wait until it gets fully extended
115+ tryCompare(panel, "x", 0);
116+ tryCompare(launcher, "state", "drawer");
117+ }
118+
119+ function init() {
120+ launcher.hide();
121+ var drawer = findChild(launcher, "drawer");
122+ tryCompare(drawer, "x", -drawer.width);
123+ }
124+
125+ function test_revealByEdgeDrag() {
126+ dragDrawerIntoView();
127+ }
128+
129+ function test_revealByEdgePush() {
130+ revealByEdgePush();
131+ }
132+ }
133+}
tests/qmltests/Launcher/tst_Launcher.qml+1−1
@@ -308,7 +308,7 @@ Rectangle {
308308 function revealByEdgePush() {
309309 // Place the mouse against the window/screen edge and push beyond the barrier threshold
310310 mouseMove(root, 1, root.height / 2);
311− launcher.pushEdge(EdgeBarrierSettings.pushThreshold * 1.1);
311+ launcher.pushEdge(EdgeBarrierSettings.pushThreshold * .6);
312312
313313 var panel = findChild(launcher, "launcherPanel");
314314 verify(!!panel);