on xenial help sign in
merge prereq
commit5e3a45c3cd081a5cf5eff0aa1bdeb191d3954f63 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 24 Jul 2014, 12:08 (12 years ago) parent5a00e00463e322
11 files changed+115−49
qml/Components/InputMethod.qml−12 qml/Panel/Indicators.qml+1 qml/Shell.qml+5−2 tests/mocks/Unity/Application/Application.qmltypes−2 tests/mocks/Unity/Application/ApplicationInfo.cpp+3−2 tests/mocks/Unity/Application/ApplicationManager.cpp+7−10 tests/mocks/Unity/Application/ApplicationManager.h+4−8 tests/mocks/Unity/Application/MirSurfaceItem.h+1−1 tests/mocks/Unity/Application/SurfaceManager.cpp+10−5 tests/mocks/Unity/Application/SurfaceManager.h+3 tests/qmltests/tst_Shell.qml+81−7
qml/Components/InputMethod.qml−12
@@ -62,18 +62,6 @@ Item {
6262 }
6363 ]
6464
65− Connections {
66− target: surface
67− ignoreUnknownSignals: true // don't wanna spam the log when surface is null
68− onStateChanged: {
69− if (state == MirSurfaceItem.Minimized) {
70− root.hide();
71− } else if (state == MirSurfaceItem.Maximized) {
72− root.show();
73− }
74− }
75− }
76−
7765 onSurfaceChanged: {
7866 if (surface) {
7967 surface.parent = root;
qml/Panel/Indicators.qml+1
@@ -37,6 +37,7 @@ Showable {
3737 readonly property int lockThreshold: openedHeight / 2
3838 property bool fullyOpened: height == openedHeight
3939 property bool partiallyOpened: height > panelHeight && !fullyOpened
40+ property bool fullyClosed: height <= panelHeight
4041 property bool contentEnabled: true
4142 property bool initalizeItem: true
4243 readonly property alias content: menuContent
qml/Shell.qml+5−2
@@ -115,7 +115,8 @@ Item {
115115 anchors.fill: parent
116116
117117 // Whether the underlay is fully covered by opaque UI elements.
118− property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
118+ property bool fullyCovered: (panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth)
119+ || stages.fullyShown || greeterWrapper.fullyShown
119120 visible: !fullyCovered
120121
121122 Image {
@@ -345,7 +346,7 @@ Item {
345346 Binding {
346347 target: applicationsDisplayLoader.item
347348 property: "interactive"
348− value: !greeter.shown && !lockscreen.shown
349+ value: !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed
349350 }
350351 Binding {
351352 target: applicationsDisplayLoader.item
@@ -357,6 +358,7 @@ Item {
357358
358359 InputMethod {
359360 id: inputMethod
361+ objectName: "inputMethod"
360362 anchors { fill: parent; topMargin: panel.panelHeight }
361363 z: notifications.useModal || panel.indicators.shown ? overlay.z + 1 : overlay.z - 1
362364 }
@@ -473,6 +475,7 @@ Item {
473475 StandardAnimation {}
474476 }
475477
478+ property bool fullyShown: showProgress === 1.0
476479 readonly property real showProgress: MathUtils.clamp((1 - x/width) + greeter.showProgress - 1, 0, 1)
477480 onShowProgressChanged: if (LightDM.Greeter.promptless && showProgress === 0) greeter.login()
478481
tests/mocks/Unity/Application/Application.qmltypes−2
@@ -102,8 +102,6 @@ Module {
102102 "ForceMainStage": 1
103103 }
104104 }
105− Property { name: "keyboardHeight"; type: "int"; isReadonly: true }
106− Property { name: "keyboardVisible"; type: "bool"; isReadonly: true }
107105 Property { name: "sideStageWidth"; type: "int"; isReadonly: true }
108106 Property { name: "stageHint"; type: "StageHint"; isReadonly: true }
109107 Property { name: "formFactorHint"; type: "FormFactorHint"; isReadonly: true }
tests/mocks/Unity/Application/ApplicationInfo.cpp+3−2
@@ -91,11 +91,12 @@ void ApplicationInfo::createSurface()
9191void ApplicationInfo::destroySurface()
9292{
9393 if (!m_surface) return;
94+
95+ SurfaceManager::singleton()->unregisterSurface(m_surface);
96+
9497 MirSurfaceItem* oldSurface = m_surface;
9598 m_surface = nullptr;
96−
9799 Q_EMIT surfaceChanged(nullptr);
98− SurfaceManager::singleton()->unregisterSurface(m_surface);
99100 oldSurface->deleteLater();
100101}
101102
tests/mocks/Unity/Application/ApplicationManager.cpp+7−10
@@ -118,6 +118,7 @@ void ApplicationManager::add(ApplicationInfo *application) {
118118 endInsertRows();
119119 Q_EMIT applicationAdded(application->appId());
120120 Q_EMIT countChanged();
121+ if (count() == 1) Q_EMIT emptyChanged(isEmpty()); // was empty but not anymore
121122 Q_EMIT focusRequested(application->appId());
122123
123124 connect(application, &ApplicationInfo::surfaceChanged, this, [application, this]() {
@@ -135,6 +136,7 @@ void ApplicationManager::remove(ApplicationInfo *application) {
135136 endRemoveRows();
136137 Q_EMIT applicationRemoved(application->appId());
137138 Q_EMIT countChanged();
139+ if (isEmpty()) Q_EMIT emptyChanged(isEmpty());
138140 }
139141 disconnect(application, &ApplicationInfo::surfaceChanged, this, 0);
140142}
@@ -153,16 +155,6 @@ void ApplicationManager::move(int from, int to) {
153155 }
154156}
155157
156−int ApplicationManager::keyboardHeight() const
157−{
158− return 0;
159−}
160−
161−bool ApplicationManager::keyboardVisible() const
162−{
163− return false;
164−}
165−
166158int ApplicationManager::sideStageWidth() const
167159{
168160 return 0;
@@ -601,3 +593,8 @@ void ApplicationManager::setRightMargin(int rightMargin)
601593 generateQmlStrings(app);
602594 }
603595}
596+
597+bool ApplicationManager::isEmpty() const
598+{
599+ return m_runningApplications.isEmpty();
600+}
tests/mocks/Unity/Application/ApplicationManager.h+4−8
@@ -36,8 +36,7 @@ class ApplicationManager : public ApplicationManagerInterface {
3636 Q_ENUMS(FavoriteApplication)
3737 Q_FLAGS(ExecFlags)
3838
39− Q_PROPERTY(int keyboardHeight READ keyboardHeight NOTIFY keyboardHeightChanged)
40− Q_PROPERTY(bool keyboardVisible READ keyboardVisible NOTIFY keyboardVisibleChanged)
39+ Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
4140
4241 Q_PROPERTY(int sideStageWidth READ sideStageWidth)
4342 Q_PROPERTY(StageHint stageHint READ stageHint)
@@ -78,8 +77,6 @@ class ApplicationManager : public ApplicationManagerInterface {
7877 };
7978 Q_DECLARE_FLAGS(ExecFlags, Flag)
8079
81− int keyboardHeight() const;
82− bool keyboardVisible() const;
8380 int sideStageWidth() const;
8481 StageHint stageHint() const;
8582 FormFactorHint formFactorHint() const;
@@ -114,11 +111,12 @@ class ApplicationManager : public ApplicationManagerInterface {
114111
115112 QModelIndex findIndex(ApplicationInfo* application);
116113
114+ bool isEmpty() const;
115+
117116 Q_SIGNALS:
118− void keyboardHeightChanged();
119− void keyboardVisibleChanged();
120117 void focusRequested(FavoriteApplication favoriteApplication);
121118 void focusRequested(const QString &appId);
119+ void emptyChanged(bool empty);
122120
123121 private:
124122 void add(ApplicationInfo *application);
@@ -130,8 +128,6 @@ class ApplicationManager : public ApplicationManagerInterface {
130128 void createMainStage();
131129 void createSideStageComponent();
132130 void createSideStage();
133− int m_keyboardHeight;
134− bool m_keyboardVisible;
135131 bool m_suspended;
136132 QList<ApplicationInfo*> m_runningApplications;
137133 QList<ApplicationInfo*> m_availableApplications;
tests/mocks/Unity/Application/MirSurfaceItem.h+1−1
@@ -62,7 +62,7 @@ public:
6262 State state() const { return m_state; }
6363 QString name() const { return m_name; }
6464
65− void setState(State newState);
65+ Q_INVOKABLE void setState(State newState);
6666
6767 Q_INVOKABLE void release() {}
6868
tests/mocks/Unity/Application/SurfaceManager.cpp+10−5
@@ -52,11 +52,7 @@ void SurfaceManager::unregisterSurface(MirSurfaceItem *surface)
5252
5353void SurfaceManager::showInputMethod()
5454{
55− if (!m_virtualKeyboard) {
56− m_virtualKeyboard = new VirtualKeyboard(MirSurfaceItem::Minimized);
57− Q_EMIT surfaceCreated(m_virtualKeyboard);
58− }
59− m_virtualKeyboard->setState(MirSurfaceItem::Restored);
55+ inputMethodSurface()->setState(MirSurfaceItem::Restored);
6056}
6157
6258void SurfaceManager::hideInputMethod()
@@ -65,3 +61,12 @@ void SurfaceManager::hideInputMethod()
6561 m_virtualKeyboard->setState(MirSurfaceItem::Minimized);
6662 }
6763}
64+
65+MirSurfaceItem *SurfaceManager::inputMethodSurface()
66+{
67+ if (!m_virtualKeyboard) {
68+ m_virtualKeyboard = new VirtualKeyboard(MirSurfaceItem::Minimized);
69+ Q_EMIT surfaceCreated(m_virtualKeyboard);
70+ }
71+ return m_virtualKeyboard;
72+}
tests/mocks/Unity/Application/SurfaceManager.h+3
@@ -34,6 +34,9 @@ public:
3434 void registerSurface(MirSurfaceItem *surface);
3535 void unregisterSurface(MirSurfaceItem *surface);
3636
37+ // To be used in the tests
38+ Q_INVOKABLE MirSurfaceItem *inputMethodSurface();
39+
3740Q_SIGNALS:
3841 void countChanged();
3942 void surfaceCreated(MirSurfaceItem *surface);
tests/qmltests/tst_Shell.qml+81−7
@@ -354,6 +354,58 @@ Item {
354354 verify(itemIsOnScreen(dashApps));
355355 }
356356
357+ function test_showInputMethod() {
358+ var item = findChild(shell, "inputMethod");
359+ var surface = SurfaceManager.inputMethodSurface();
360+
361+ surface.setState(MirSurfaceItem.Minimized);
362+ tryCompare(item, "visible", false);
363+
364+ surface.setState(MirSurfaceItem.Restored);
365+ tryCompare(item, "visible", true);
366+
367+ surface.setState(MirSurfaceItem.Minimized);
368+ tryCompare(item, "visible", false);
369+
370+ surface.setState(MirSurfaceItem.Maximized);
371+ tryCompare(item, "visible", true);
372+
373+ surface.setState(MirSurfaceItem.Minimized);
374+ tryCompare(item, "visible", false);
375+ }
376+
377+ function test_surfaceLosesFocusWhilePanelIsOpen() {
378+ var app = ApplicationManager.startApplication("dialer-app");
379+ // wait until the app is fully loaded (ie, real surface replaces splash screen)
380+ tryCompareFunction(function() { return app.surface != null }, true);
381+
382+ tryCompare(app.surface, "focus", true);
383+
384+ // Drag the indicators panel half-open
385+ var touchX = shell.width / 2;
386+ var indicators = findChild(shell, "indicators");
387+ touchFlick(indicators,
388+ touchX /* fromX */, indicators.panelHeight * 0.5 /* fromY */,
389+ touchX /* toX */, shell.height * 0.5 /* toY */,
390+ true /* beginTouch */, false /* endTouch */);
391+ verify(indicators.partiallyOpened);
392+
393+ tryCompare(app.surface, "focus", false);
394+
395+ // And finish getting it open
396+ touchFlick(indicators,
397+ touchX /* fromX */, shell.height * 0.5 /* fromY */,
398+ touchX /* toX */, shell.height * 0.9 /* toY */,
399+ false /* beginTouch */, true /* endTouch */);
400+ tryCompare(indicators, "fullyOpened", true);
401+
402+ tryCompare(app.surface, "focus", false);
403+
404+ dragToCloseIndicatorsPanel();
405+
406+ tryCompare(app.surface, "focus", true);
407+ }
408+
357409 // Wait for the whole UI to settle down
358410 function waitForUIToSettle() {
359411 waitUntilApplicationWindowIsFullyHidden();
@@ -361,6 +413,18 @@ Item {
361413 tryCompare(dashContentList, "moving", false);
362414 }
363415
416+ function dragToCloseIndicatorsPanel() {
417+ var indicators = findChild(shell, "indicators");
418+
419+ var touchStartX = shell.width / 2;
420+ var touchStartY = shell.height - (indicators.panelHeight * 0.5);
421+ touchFlick(shell,
422+ touchStartX, touchStartY,
423+ touchStartX, shell.height * 0.1);
424+
425+ tryCompare(indicators, "fullyClosed", true);
426+ }
427+
364428 function dragLauncherIntoView() {
365429 var launcherPanel = findChild(shell, "launcherPanel");
366430 verify(launcherPanel.x = - launcherPanel.width);
@@ -485,7 +549,7 @@ Item {
485549 {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
486550 {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
487551 {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
488− {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: true},
552+ {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: false},
489553 ]
490554 }
491555
@@ -515,14 +579,24 @@ Item {
515579 }
516580
517581 function test_focusRequestedHidesGreeter() {
518− var greeter = findChild(shell, "greeter")
582+ var greeter = findChild(shell, "greeter");
519583
520− greeter.show()
521− tryCompare(greeter, "showProgress", 1)
584+ var app = ApplicationManager.startApplication("dialer-app");
585+ // wait until the app is fully loaded (ie, real surface replaces splash screen)
586+ tryCompareFunction(function() { return app.surface != null }, true);
522587
523− ApplicationManager.focusRequested("notes-app")
524− tryCompare(greeter, "showProgress", 0)
525− waitUntilApplicationWindowIsFullyVisible()
588+ // Minimize the application we just launched
589+ swipeFromLeftEdge(units.gu(27));
590+
591+ // Wait for the whole UI to settle down
592+ waitUntilApplicationWindowIsFullyHidden();
593+
594+ greeter.show();
595+ tryCompare(greeter, "showProgress", 1);
596+
597+ // The main point of this test
598+ ApplicationManager.requestFocusApplication("dialer-app");
599+ tryCompare(greeter, "showProgress", 0);
526600 }
527601
528602 function test_showGreeterDBusCall() {