on xenial help sign in
Test for right-edge drag with no running apps
commitb087b7cf57f2ad16d794e8b7dbae921f98c87232 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 16 Jul 2013, 20:29 (13 years ago) parentb74dfe0
4 files changed+85−2
Shell.qml+1 tests/mocks/Ubuntu/Application/ApplicationManager.cpp+6−2 tests/qmltests/CMakeLists.txt+3 tests/qmltests/tst_Shell.qml+75
Shell.qml+1
@@ -159,6 +159,7 @@ FocusScope {
159159
160160 Dash {
161161 id: dash
162+ objectName: "dash"
162163
163164 available: !greeter.shown && !lockscreen.shown
164165 hides: [stages, launcher, panel.indicators]
tests/mocks/Ubuntu/Application/ApplicationManager.cpp+6−2
@@ -37,8 +37,6 @@ ApplicationManager::ApplicationManager(QObject *parent)
3737 , m_sideStage(0)
3838{
3939 buildListOfAvailableApplications();
40− createMainStageComponent();
41− createSideStageComponent();
4240}
4341
4442ApplicationManager::~ApplicationManager()
@@ -403,6 +401,9 @@ void ApplicationManager::createMainStageComponent()
403401
404402void ApplicationManager::createMainStage()
405403{
404+ if (!m_mainStageComponent)
405+ createMainStageComponent();
406+
406407 // The assumptions I make here really should hold.
407408 QQuickView *quickView =
408409 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
@@ -437,6 +438,9 @@ void ApplicationManager::createSideStageComponent()
437438
438439void ApplicationManager::createSideStage()
439440{
441+ if (!m_sideStageComponent)
442+ createSideStageComponent();
443+
440444 // The assumptions I make here really should hold.
441445 QQuickView *quickView =
442446 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
tests/qmltests/CMakeLists.txt+3
@@ -25,6 +25,9 @@ add_qml_test(utils/Unity/Test UnityTest)
2525set(qmltest_DEFAULT_TARGETS qmluitests)
2626set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
2727set(qmltest_DEFAULT_PROPERTIES "")
28+
29+add_qml_test(. Shell IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
30+ ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
2831add_manual_qml_test(Components DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
2932add_qml_test(Components DraggingArea)
3033add_qml_test(Components FilterGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
tests/qmltests/tst_Shell.qmlnew file+75
@@ -0,0 +1,75 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Daniel d'Andrada <daniel.dandrada@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+import QtQuick 2.0
21+import QtTest 1.0
22+import Unity.Test 0.1 as UT
23+
24+import "../.."
25+
26+Shell {
27+ id: shell
28+ UT.UnityTestCase {
29+ name: "Shell"
30+ when: windowShown
31+
32+ function initTestCase() {
33+ // swipe away the greeter/lockscreen
34+ var touchX = shell.width - (shell.edgeSize / 2);
35+ var touchY = shell.height / 2;
36+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
37+
38+ var dash = findChild(shell, "dash");
39+ // wait until the animation has finished
40+ tryCompare(dash, "contentScale", 1.0);
41+ tryCompare(dash, "opacity", 1.0);
42+ }
43+
44+ /*
45+ Perform a right-edge drag when the Dash is being show and there are
46+ no running/minimized apps to be restored.
47+
48+ The expected behavior is that an animation should be played to hint the
49+ user that his right-edge drag gesture has been successfully recognized
50+ but there is no application to be brought to foreground.
51+ */
52+ function test_rightEdgeDragWithNoRunningApps() {
53+ var touchX = shell.width - (shell.edgeSize / 2);
54+ var touchY = shell.height / 2;
55+
56+ var dash = findChild(shell, "dash");
57+ // check that dash has normal scale and opacity
58+ compare(dash.contentScale, 1.0);
59+ compare(dash.opacity, 1.0);
60+
61+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
62+ true /* beginTouch */, false /* endTouch */);
63+
64+ // check that Dash has been scaled down and had its opacity reduced
65+ tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
66+ tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
67+
68+ touchRelease(shell, shell.width * 0.1, touchY);
69+
70+ // and now everything should have gone back to normal
71+ tryCompare(dash, "contentScale", 1.0);
72+ tryCompare(dash, "opacity", 1.0);
73+ }
74+ }
75+}