on xenial help sign in
more tests
commit94ab11511b2793ecb3b9a382038508423d216038 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Nov 2016, 15:09 (10 years ago) parentac953e9
4 files changed+100−33
plugins/Unity/Launcher/appdrawermodel.cpp+1 qml/Launcher/Drawer.qml+6 qml/Launcher/Launcher.qml+32−29 tests/qmltests/Launcher/tst_Drawer.qml+61−4
plugins/Unity/Launcher/appdrawermodel.cpp+1
@@ -21,6 +21,7 @@ AppDrawerModel::AppDrawerModel(QObject *parent):
2121
2222int AppDrawerModel::rowCount(const QModelIndex &parent) const
2323{
24+ Q_UNUSED(parent)
2425 return m_list.count();
2526}
2627
qml/Launcher/Drawer.qml+6
@@ -94,6 +94,11 @@ FocusScope {
9494 default: return debugComponent;
9595 }
9696 }
97+ Binding {
98+ target: listLoader.item || null
99+ property: "objectName"
100+ value: "drawerItemList"
101+ }
97102 }
98103
99104 MouseArea {
@@ -260,6 +265,7 @@ FocusScope {
260265 AbstractButton {
261266 width: GridView.view.cellWidth
262267 height: units.gu(10)
268+ objectName: "drawerItem_" + model.appId
263269
264270 onClicked: root.applicationSelected(model.appId)
265271
qml/Launcher/Launcher.qml+32−29
@@ -320,34 +320,6 @@ FocusScope {
320320 }
321321 }
322322
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−
351323 BackgroundBlur {
352324 id: backgroundBlur
353325 anchors.fill: parent
@@ -371,7 +343,10 @@ FocusScope {
371343 panelWidth: panel.width
372344 visible: x > -width
373345
374− onApplicationSelected: root.launcherApplicationSelected(appId)
346+ onApplicationSelected: {
347+ root.launcherApplicationSelected(appId)
348+ root.hide();
349+ }
375350
376351 Keys.onEscapePressed: {
377352 switchToNextState("");
@@ -465,6 +440,34 @@ FocusScope {
465440 }
466441 }
467442
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+
468471 SwipeArea {
469472 id: dragArea
470473 objectName: "launcherDragArea"
tests/qmltests/Launcher/tst_Drawer.qml+61−4
@@ -43,6 +43,11 @@ StyledItem {
4343
4444 lockedVisible: lockedVisibleCheckBox.checked
4545
46+ property string lastSelectedApplication
47+ onLauncherApplicationSelected: {
48+ lastSelectedApplication = appId
49+ }
50+
4651 Component.onCompleted: {
4752 launcher.focus = true
4853 edgeBarrierControls.target = testCase.findChild(this, "edgeBarrierController");
@@ -105,18 +110,24 @@ StyledItem {
105110
106111 function revealByEdgePush() {
107112 // 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);
108116 mouseMove(root, 1, root.height / 2);
117+
109118 launcher.pushEdge(EdgeBarrierSettings.pushThreshold * 1.1);
110119
111− var panel = findChild(launcher, "launcherPanel");
112− verify(!!panel);
120+ var drawer = findChild(launcher, "drawer");
121+ verify(!!drawer);
113122
114123 // wait until it gets fully extended
115− tryCompare(panel, "x", 0);
124+ tryCompare(drawer, "x", 0);
116125 tryCompare(launcher, "state", "drawer");
117126 }
118127
119128 function init() {
129+ launcher.lastSelectedApplication = "";
130+ launcher.lockedVisible = false;
120131 launcher.hide();
121132 var drawer = findChild(launcher, "drawer");
122133 tryCompare(drawer, "x", -drawer.width);
@@ -126,8 +137,54 @@ StyledItem {
126137 dragDrawerIntoView();
127138 }
128139
129− function test_revealByEdgePush() {
140+ function test_revealByEdgePush_data() {
141+ return [
142+ { tag: "autohide launcher", autohide: true },
143+ { tag: "locked launcher", autohide: false }
144+ ]
145+ }
146+
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+
130155 revealByEdgePush();
131156 }
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+ }
132189 }
133190}