on xenial help sign in
more tests
94ab115Michael Zanetti
plugins/Unity/Launcher/appdrawermodel.cpp+1
@@ -21,6 +21,7 @@ AppDrawerModel::AppDrawerModel(QObject *parent):
21
21
22int AppDrawerModel::rowCount(const QModelIndex &parent) const
22int AppDrawerModel::rowCount(const QModelIndex &parent) const
23{
23{
24+ Q_UNUSED(parent)
24 return m_list.count();
25 return m_list.count();
25}
26}
26
27
qml/Launcher/Drawer.qml+6
@@ -94,6 +94,11 @@ FocusScope {
94 default: return debugComponent;
94 default: return debugComponent;
95 }
95 }
96 }
96 }
97+ Binding {
98+ target: listLoader.item || null
99+ property: "objectName"
100+ value: "drawerItemList"
101+ }
97 }
102 }
98
103
99 MouseArea {
104 MouseArea {
@@ -260,6 +265,7 @@ FocusScope {
260 AbstractButton {
265 AbstractButton {
261 width: GridView.view.cellWidth
266 width: GridView.view.cellWidth
262 height: units.gu(10)
267 height: units.gu(10)
268+ objectName: "drawerItem_" + model.appId
263
269
264 onClicked: root.applicationSelected(model.appId)
270 onClicked: root.applicationSelected(model.appId)
265
271
qml/Launcher/Launcher.qml+32−29
@@ -320,34 +320,6 @@ FocusScope {
320 }
320 }
321 }
321 }
322
322
323− EdgeBarrier {
324− id: edgeBarrier
325− edge: Qt.LeftEdge
326− target: parent
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− }
333− onPassed: { root.switchToNextState("drawer"); }
334−
335− material: Component {
336− Item {
337− Rectangle {
338− width: parent.height
339− height: parent.width
340− rotation: -90
341− anchors.centerIn: parent
342− gradient: Gradient {
343− GradientStop { position: 0.0; color: Qt.rgba(panel.color.r, panel.color.g, panel.color.b, .5)}
344− GradientStop { position: 1.0; color: Qt.rgba(panel.color.r,panel.color.g,panel.color.b,0)}
345− }
346− }
347− }
348− }
349− }
350−
351 BackgroundBlur {
323 BackgroundBlur {
352 id: backgroundBlur
324 id: backgroundBlur
353 anchors.fill: parent
325 anchors.fill: parent
@@ -371,7 +343,10 @@ FocusScope {
371 panelWidth: panel.width
343 panelWidth: panel.width
372 visible: x > -width
344 visible: x > -width
373
345
346+ onApplicationSelected: {
374− onApplicationSelected: root.launcherApplicationSelected(appId)
347+ root.launcherApplicationSelected(appId)
348+ root.hide();
349+ }
375
350
376 Keys.onEscapePressed: {
351 Keys.onEscapePressed: {
377 switchToNextState("");
352 switchToNextState("");
@@ -465,6 +440,34 @@ FocusScope {
465 }
440 }
466 }
441 }
467
442
443+ EdgeBarrier {
444+ id: edgeBarrier
445+ edge: Qt.LeftEdge
446+ target: parent
447+ enabled: root.available
448+ onProgressChanged: {
449+ if (progress > .5 && root.state != "visibleTemporary" && root.state != "drawer" && root.state != "visible") {
450+ root.switchToNextState("visibleTemporary");
451+ }
452+ }
453+ onPassed: { root.switchToNextState("drawer"); }
454+
455+ material: Component {
456+ Item {
457+ Rectangle {
458+ width: parent.height
459+ height: parent.width
460+ rotation: -90
461+ anchors.centerIn: parent
462+ gradient: Gradient {
463+ GradientStop { position: 0.0; color: Qt.rgba(panel.color.r, panel.color.g, panel.color.b, .5)}
464+ GradientStop { position: 1.0; color: Qt.rgba(panel.color.r,panel.color.g,panel.color.b,0)}
465+ }
466+ }
467+ }
468+ }
469+ }
470+
468 SwipeArea {
471 SwipeArea {
469 id: dragArea
472 id: dragArea
470 objectName: "launcherDragArea"
473 objectName: "launcherDragArea"
tests/qmltests/Launcher/tst_Drawer.qml+61−4
@@ -43,6 +43,11 @@ StyledItem {
43
43
44 lockedVisible: lockedVisibleCheckBox.checked
44 lockedVisible: lockedVisibleCheckBox.checked
45
45
46+ property string lastSelectedApplication
47+ onLauncherApplicationSelected: {
48+ lastSelectedApplication = appId
49+ }
50+
46 Component.onCompleted: {
51 Component.onCompleted: {
47 launcher.focus = true
52 launcher.focus = true
48 edgeBarrierControls.target = testCase.findChild(this, "edgeBarrierController");
53 edgeBarrierControls.target = testCase.findChild(this, "edgeBarrierController");
@@ -105,18 +110,24 @@ StyledItem {
105
110
106 function revealByEdgePush() {
111 function revealByEdgePush() {
107 // Place the mouse against the window/screen edge and push beyond the barrier threshold
112 // Place the mouse against the window/screen edge and push beyond the barrier threshold
113+ // If the mouse did not move between two revealByEdgePush(), we need it to move out the
114+ // area to make sure we're not just accumulating to the previous push
115+ mouseMove(root, root.width, root.height / 2);
108 mouseMove(root, 1, root.height / 2);
116 mouseMove(root, 1, root.height / 2);
117+
109 launcher.pushEdge(EdgeBarrierSettings.pushThreshold * 1.1);
118 launcher.pushEdge(EdgeBarrierSettings.pushThreshold * 1.1);
110
119
111− var panel = findChild(launcher, "launcherPanel");
120+ var drawer = findChild(launcher, "drawer");
112− verify(!!panel);
121+ verify(!!drawer);
113
122
114 // wait until it gets fully extended
123 // wait until it gets fully extended
115− tryCompare(panel, "x", 0);
124+ tryCompare(drawer, "x", 0);
116 tryCompare(launcher, "state", "drawer");
125 tryCompare(launcher, "state", "drawer");
117 }
126 }
118
127
119 function init() {
128 function init() {
129+ launcher.lastSelectedApplication = "";
130+ launcher.lockedVisible = false;
120 launcher.hide();
131 launcher.hide();
121 var drawer = findChild(launcher, "drawer");
132 var drawer = findChild(launcher, "drawer");
122 tryCompare(drawer, "x", -drawer.width);
133 tryCompare(drawer, "x", -drawer.width);
@@ -126,8 +137,54 @@ StyledItem {
126 dragDrawerIntoView();
137 dragDrawerIntoView();
127 }
138 }
128
139
140+ function test_revealByEdgePush_data() {
141+ return [
142+ { tag: "autohide launcher", autohide: true },
143+ { tag: "locked launcher", autohide: false }
144+ ]
145+ }
146+
129− function test_revealByEdgePush() {
147+ function test_revealByEdgePush(data) {
148+ launcher.lockedVisible = !data.autohide;
149+
150+ var panel = findChild(launcher, "launcherPanel");
151+ tryCompare(panel, "x", data.autohide ? -panel.width : 0);
152+ tryCompare(launcher, "state", data.autohide ? "" : "visible");
153+ waitForRendering(launcher)
154+
130 revealByEdgePush();
155 revealByEdgePush();
131 }
156 }
157+
158+ function test_hideByDraggingDrawer() {
159+ dragDrawerIntoView();
160+
161+ var drawer = findChild(launcher, "drawer");
162+
163+ mouseFlick(drawer, drawer.width - units.gu(1), drawer.height / 2, drawer.width - units.gu(12), drawer.height / 2);
164+
165+ tryCompare(launcher, "state", "");
166+ }
167+
168+ function test_hideByClickingOutside() {
169+ dragDrawerIntoView();
170+
171+ var drawer = findChild(launcher, "drawer");
172+
173+ mouseClick(root, drawer.width + units.gu(1), root.height / 2);
174+
175+ tryCompare(launcher, "state", "");
176+ }
177+
178+ function test_launchAppFromDrawer() {
179+ dragDrawerIntoView();
180+
181+ var drawerList = findChild(launcher, "drawerItemList");
182+ var dialerApp = findChild(drawerList, "drawerItem_dialer-app");
183+ mouseClick(dialerApp, dialerApp.width / 2, dialerApp.height / 2);
184+
185+ tryCompare(launcher, "lastSelectedApplication", "dialer-app");
186+
187+ tryCompare(launcher, "state", "");
188+ }
132 }
189 }
133}
190}