on xenial help sign in
moar tests
commit4834324be344ddde662a2683efcbe1167fb9258b authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Dec 2015, 14:37 (11 years ago) parent91e4903
4 files changed+84
tests/mocks/GSettings.1.0/fake_gsettings.cpp+32 tests/mocks/GSettings.1.0/fake_gsettings.h+9 tests/qmltests/Launcher/tst_Launcher.qml+24 tests/qmltests/tst_Shell.qml+19
tests/mocks/GSettings.1.0/fake_gsettings.cpp+32
@@ -22,6 +22,7 @@ GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0;
2222
2323GSettingsControllerQml::GSettingsControllerQml()
2424 : m_usageMode("Staged")
25+ , m_autohideLauncher(false)
2526{
2627}
2728
@@ -88,6 +89,19 @@ void GSettingsControllerQml::setLifecycleExemptAppids(const QStringList &appIds)
8889 }
8990}
9091
92+bool GSettingsControllerQml::autohideLauncher() const
93+{
94+ return m_autohideLauncher;
95+}
96+
97+void GSettingsControllerQml::setAutohideLauncher(bool autohideLauncher)
98+{
99+ if (m_autohideLauncher != autohideLauncher) {
100+ m_autohideLauncher = autohideLauncher;
101+ Q_EMIT autohideLauncherChanged(autohideLauncher);
102+ }
103+}
104+
91105GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) {
92106}
93107
@@ -129,6 +143,8 @@ GSettingsQml::GSettingsQml(QObject *parent)
129143 this, &GSettingsQml::lockedOutTimeChanged);
130144 connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::lifecycleExemptAppidsChanged,
131145 this, &GSettingsQml::lifecycleExemptAppidsChanged);
146+ connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::autohideLauncherChanged,
147+ this, &GSettingsQml::autohideLauncherChanged);
132148}
133149
134150GSettingsSchemaQml * GSettingsQml::schema() const {
@@ -192,9 +208,25 @@ QStringList GSettingsQml::lifecycleExemptAppids() const
192208 }
193209}
194210
211+bool GSettingsQml::autohideLauncher() const
212+{
213+ if (m_schema->id() == "com.canonical.Unity8") {
214+ return GSettingsControllerQml::instance()->autohideLauncher();
215+ } else {
216+ return false;
217+ }
218+}
219+
195220void GSettingsQml::setLifecycleExemptAppids(const QStringList &appIds)
196221{
197222 if (m_schema->id() == "com.canonical.qtmir") {
198223 GSettingsControllerQml::instance()->setLifecycleExemptAppids(appIds);
199224 }
200225}
226+
227+void GSettingsQml::setAutohideLauncher(bool autohideLauncher)
228+{
229+ if (m_schema->id() == "com.canonical.Unity8") {
230+ GSettingsControllerQml::instance()->setAutohideLauncher(autohideLauncher);
231+ }
232+}
tests/mocks/GSettings.1.0/fake_gsettings.h+9
@@ -50,6 +50,7 @@ class GSettingsQml: public QObject
5050 Q_PROPERTY(QString usageMode READ usageMode WRITE setUsageMode NOTIFY usageModeChanged)
5151 Q_PROPERTY(qint64 lockedOutTime READ lockedOutTime WRITE setLockedOutTime NOTIFY lockedOutTimeChanged)
5252 Q_PROPERTY(QStringList lifecycleExemptAppids READ lifecycleExemptAppids WRITE setLifecycleExemptAppids NOTIFY lifecycleExemptAppidsChanged)
53+ Q_PROPERTY(bool autohideLauncher READ autohideLauncher WRITE setAutohideLauncher NOTIFY autohideLauncherChanged)
5354
5455public:
5556 GSettingsQml(QObject *parent = nullptr);
@@ -59,11 +60,13 @@ public:
5960 QString usageMode() const;
6061 qint64 lockedOutTime() const;
6162 QStringList lifecycleExemptAppids() const;
63+ bool autohideLauncher() const;
6264
6365 void setPictureUri(const QString &str);
6466 void setUsageMode(const QString &usageMode);
6567 void setLockedOutTime(qint64 timestamp);
6668 void setLifecycleExemptAppids(const QStringList &appIds);
69+ void setAutohideLauncher(bool autohideLauncher);
6770
6871Q_SIGNALS:
6972 void schemaChanged();
@@ -71,6 +74,7 @@ Q_SIGNALS:
7174 void usageModeChanged(const QString&);
7275 void lockedOutTimeChanged(qint64);
7376 void lifecycleExemptAppidsChanged(const QStringList &);
77+ void autohideLauncherChanged(bool);
7478
7579private:
7680 GSettingsSchemaQml* m_schema;
@@ -98,11 +102,15 @@ public:
98102 QStringList lifecycleExemptAppids() const;
99103 Q_INVOKABLE void setLifecycleExemptAppids(const QStringList &appIds);
100104
105+ bool autohideLauncher() const;
106+ Q_INVOKABLE void setAutohideLauncher(bool autohideLauncher);
107+
101108Q_SIGNALS:
102109 void pictureUriChanged(const QString&);
103110 void usageModeChanged(const QString&);
104111 void lockedOutTimeChanged(qint64 timestamp);
105112 void lifecycleExemptAppidsChanged(const QStringList&);
113+ void autohideLauncherChanged(bool autohideLauncher);
106114
107115private:
108116 GSettingsControllerQml();
@@ -111,6 +119,7 @@ private:
111119 QString m_usageMode;
112120 qint64 m_lockedOutTime;
113121 QStringList m_lifecycleExemptAppids;
122+ bool m_autohideLauncher;
114123
115124 static GSettingsControllerQml* s_controllerInstance;
116125 QList<GSettingsQml *> m_registeredGSettings;
tests/qmltests/Launcher/tst_Launcher.qml+24
@@ -1048,5 +1048,29 @@ Item {
10481048 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
10491049 compare(signalSpy.signalArguments[0][1], 2)
10501050 }
1051+
1052+ function test_hideNotWorkingWhenLockedOut_data() {
1053+ return [
1054+ {tag: "locked visible", locked: true},
1055+ {tag: "no locked visible", locked: false},
1056+ ]
1057+ }
1058+
1059+ function test_hideNotWorkingWhenLockedOut(data) {
1060+ launcher.lockedVisible = data.locked;
1061+ if (data.locked) {
1062+ tryCompare(launcher, "state", "visible");
1063+ } else {
1064+ tryCompare(launcher, "state", "");
1065+ }
1066+
1067+ launcher.hide();
1068+ waitForRendering(launcher);
1069+ if (data.locked) {
1070+ verify(launcher.state == "visible");
1071+ } else {
1072+ verify(launcher.state == "");
1073+ }
1074+ }
10511075 }
10521076}
tests/qmltests/tst_Shell.qml+19
@@ -2035,5 +2035,24 @@ Rectangle {
20352035 tryCompare(launcher, "state", "visible");
20362036 tryCompare(launcher, "focus", true)
20372037 }
2038+
2039+ function test_lockedOutLauncherShrinksStage() {
2040+ loadShell("desktop");
2041+ shell.usageScenario = "desktop";
2042+ waitForRendering(shell);
2043+
2044+ var appContainer = findChild(shell, "appContainer");
2045+ var launcher = findChild(shell, "launcher");
2046+
2047+ GSettingsController.setAutohideLauncher(true);
2048+ waitForRendering(shell)
2049+ var hiddenSize = appContainer.width;
2050+
2051+ GSettingsController.setAutohideLauncher(false);
2052+ waitForRendering(shell)
2053+ var shownSize = appContainer.width;
2054+
2055+ compare(shownSize + launcher.panelWidth, hiddenSize);
2056+ }
20382057 }
20392058}