on xenial help sign in
fixed stage not saving
commit102194a011bb381d238f792dfa4e4cbe796b8bb0 authorNick Dedekind <nick.dedekind@canonical.com> dateThu 5 May 2016, 14:04 (10 years ago) parenta9dba38
4 files changed+44−5
qml/Stages/TabletStage.qml+3−3 tests/mocks/Utils/windowstatestorage.cpp+1 tests/mocks/Utils/windowstatestorage.h+3 tests/qmltests/Stages/tst_TabletStage.qml+37−2
qml/Stages/TabletStage.qml+3−3
@@ -752,7 +752,7 @@ AbstractStage {
752752
753753 readonly property bool wantsMainStage: stage == ApplicationInfoInterface.MainStage
754754
755− readonly property bool isDash: model.application.appId == "unity8-dash"
755+ readonly property bool isDash: application.appId == "unity8-dash"
756756
757757 onFocusChanged: {
758758 if (focus && !spreadRepeater.startingUp) {
@@ -768,7 +768,7 @@ AbstractStage {
768768 onFocusRequested: spreadTile.focus = true;
769769 }
770770 Connections {
771− target: model.application
771+ target: spreadTile.application
772772 onFocusRequested: {
773773 if (!model.surface) {
774774 // when an app has no surfaces, we assume there's only one entry representing it:
@@ -844,7 +844,7 @@ AbstractStage {
844844 _constructing = false;
845845 }
846846 Component.onDestruction: {
847− WindowStateStorage.saveStage(model.application.appId, stage);
847+ WindowStateStorage.saveStage(application.appId, stage);
848848 }
849849
850850 function refreshStage() {
tests/mocks/Utils/windowstatestorage.cpp+1
@@ -50,6 +50,7 @@ QRect WindowStateStorage::getGeometry(const QString &windowId, const QRect &defa
5050void WindowStateStorage::saveStage(const QString &appId, int stage)
5151{
5252 m_stage[appId] = stage;
53+ Q_EMIT stageSaved(appId, stage);
5354}
5455
5556int WindowStateStorage::getStage(const QString &appId) const
tests/mocks/Utils/windowstatestorage.h+3
@@ -45,6 +45,9 @@ public:
4545Q_SIGNALS:
4646 void geometryChanged(const QVariantMap& geometry);
4747
48+ // For testing.
49+ void stageSaved(const QString& appId, int stage);
50+
4851private:
4952 void setGeometry(const QVariantMap& geometry);
5053 QVariantMap geometry() const;
tests/qmltests/Stages/tst_TabletStage.qml+37−2
@@ -129,6 +129,12 @@ Rectangle {
129129 }
130130 }
131131
132+ SignalSpy {
133+ id: stageSaver
134+ target: WindowStateStorage
135+ signalName: "stageSaved"
136+ }
137+
132138 UnityTestCase {
133139 id: testCase
134140 name: "TabletStage"
@@ -138,6 +144,7 @@ Rectangle {
138144 property Item sideStage: tabletStage ? findChild(tabletStage, "sideStage") : null
139145
140146 function init() {
147+ stageSaver.clear();
141148 tabletStageLoader.active = true;
142149 tryCompare(tabletStageLoader, "status", Loader.Ready);
143150
@@ -510,7 +517,35 @@ Rectangle {
510517 tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
511518 }
512519
513− function test_loadSideStageByDragginFromMainStage() {
520+ function test_applicationSavesLastStage_data() {
521+ return [
522+ { tag: "MainStage", stage: ApplicationInfoInterface.MainStage},
523+ { tag: "SideStage", stage: ApplicationInfoInterface.SideStage},
524+ ];
525+ }
526+
527+ function test_applicationSavesLastStage(data) {
528+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage);
529+ stageSaver.clear();
530+
531+ var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
532+ verify(stagesPriv);
533+
534+ tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
535+ tryCompare(stagesPriv, "sideStageAppId", "");
536+
537+ var webbrowserSurfaceId = topSurfaceList.nextId;
538+ webbrowserCheckBox.checked = true;
539+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
540+
541+ webbrowserCheckBox.checked = false;
542+
543+ tryCompare(stageSaver, "count", 1);
544+ compare(stageSaver.signalArguments[0][0], "webbrowser-app")
545+ compare(stageSaver.signalArguments[0][1], data.stage)
546+ }
547+
548+ function test_loadSideStageByDraggingFromMainStage() {
514549 sideStage.showNow();
515550 var webbrowserSurfaceId = topSurfaceList.nextId;
516551 webbrowserCheckBox.checked = true;
@@ -538,7 +573,7 @@ Rectangle {
538573 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
539574 }
540575
541− function test_unloadSideStageByDragginFromStageStage() {
576+ function test_unloadSideStageByDraggingFromStageStage() {
542577 sideStage.showNow();
543578 WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
544579 var webbrowserSurfaceId = topSurfaceList.nextId;