on xenial help sign in
add a testcase for the drawer, implement reveal by edge push
ac953e9Michael Zanetti
qml/Launcher/Drawer.qml+4−5
@@ -131,22 +131,21 @@ FocusScope {
131
131
132 Component {
132 Component {
133 id: debugComponent
133 id: debugComponent
134− ListView {
134+ GridView {
135 anchors.fill: parent
135 anchors.fill: parent
136 topMargin: units.gu(1)
136 topMargin: units.gu(1)
137 bottomMargin: units.gu(1)
137 bottomMargin: units.gu(1)
138− spacing: units.gu(1)
138+// spacing: units.gu(1)
139 clip: true
139 clip: true
140
140
141+
141 model: sortProxyModel
142 model: sortProxyModel
142// model: AppDrawerProxyModel {
143// model: AppDrawerProxyModel {
143// source: sortProxyModel
144// source: sortProxyModel
144// group: AppDrawerProxyModel.GroupByAToZ
145// group: AppDrawerProxyModel.GroupByAToZ
145// sortBy: AppDrawerProxyModel.SortByAToZ
146// sortBy: AppDrawerProxyModel.SortByAToZ
146// }
147// }
147− delegate: Label {
148+ delegate: drawerDelegateComponent
148− text: model.letter + " - " + model.name
149− }
150 }
149 }
151 }
150 }
152
151
qml/Launcher/Launcher.qml+9−2
@@ -137,7 +137,7 @@ FocusScope {
137 }
137 }
138
138
139 function pushEdge(amount) {
139 function pushEdge(amount) {
140− if (root.state === "") {
140+ if (root.state === "" || root.state == "visible") {
141 edgeBarrier.push(amount);
141 edgeBarrier.push(amount);
142 }
142 }
143 }
143 }
@@ -325,7 +325,13 @@ FocusScope {
325 edge: Qt.LeftEdge
325 edge: Qt.LeftEdge
326 target: parent
326 target: parent
327 enabled: root.available
327 enabled: root.available
328+ onProgressChanged: {
329+ if (progress > .5 && root.state != "visibleTemporary" && root.state != "drawer" && root.state != "visible") {
330+ root.switchToNextState("visibleTemporary");
331+ }
332+ }
328− onPassed: { root.switchToNextState("visibleTemporary"); }
333+ onPassed: { root.switchToNextState("drawer"); }
334+
329 material: Component {
335 material: Component {
330 Item {
336 Item {
331 Rectangle {
337 Rectangle {
@@ -354,6 +360,7 @@ FocusScope {
354
360
355 Drawer {
361 Drawer {
356 id: drawer
362 id: drawer
363+ objectName: "drawer"
357 anchors {
364 anchors {
358 top: parent.top
365 top: parent.top
359 topMargin: root.topPanelHeight
366 topMargin: root.topPanelHeight
tests/qmltests/CMakeLists.txt+1
@@ -71,6 +71,7 @@ add_unity8_qmltest(Greeter Infographics)
71add_unity8_qmltest(Greeter NarrowView)
71add_unity8_qmltest(Greeter NarrowView)
72add_unity8_qmltest(Greeter WideView)
72add_unity8_qmltest(Greeter WideView)
73add_unity8_qmltest(Launcher Launcher)
73add_unity8_qmltest(Launcher Launcher)
74+add_unity8_qmltest(Launcher Drawer)
74add_unity8_qmltest(Notifications Notifications)
75add_unity8_qmltest(Notifications Notifications)
75add_unity8_qmltest(Notifications VisualSnapDecisionsQueue)
76add_unity8_qmltest(Notifications VisualSnapDecisionsQueue)
76add_unity8_qmltest(Notifications OptionToggle)
77add_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 {
308 function revealByEdgePush() {
308 function revealByEdgePush() {
309 // Place the mouse against the window/screen edge and push beyond the barrier threshold
309 // Place the mouse against the window/screen edge and push beyond the barrier threshold
310 mouseMove(root, 1, root.height / 2);
310 mouseMove(root, 1, root.height / 2);
311− launcher.pushEdge(EdgeBarrierSettings.pushThreshold * 1.1);
311+ launcher.pushEdge(EdgeBarrierSettings.pushThreshold * .6);
312
312
313 var panel = findChild(launcher, "launcherPanel");
313 var panel = findChild(launcher, "launcherPanel");
314 verify(!!panel);
314 verify(!!panel);