on xenial help sign in
Extended qmltest for Launcher to verify the implicit alerting when count and countVisible of an item change.
8d68a0eMirco Müller
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+20
@@ -246,6 +246,26 @@ void MockLauncherModel::emitHint()
246 Q_EMIT hint();
246 Q_EMIT hint();
247}
247}
248
248
249+void MockLauncherModel::setCount(const QString &appId, int count)
250+{
251+ int index = findApp(appId);
252+ if (index >= 0) {
253+ m_list.at(index)->setCount(count);
254+ QModelIndex modelIndex = this->index(index);
255+ Q_EMIT dataChanged(modelIndex, modelIndex);
256+ }
257+}
258+
259+void MockLauncherModel::setCountVisible(const QString &appId, bool countVisible)
260+{
261+ int index = findApp(appId);
262+ if (index >= 0) {
263+ m_list.at(index)->setCountVisible(countVisible);
264+ QModelIndex modelIndex = this->index(index);
265+ Q_EMIT dataChanged(modelIndex, modelIndex);
266+ }
267+}
268+
249unity::shell::application::ApplicationManagerInterface *MockLauncherModel::applicationManager() const
269unity::shell::application::ApplicationManagerInterface *MockLauncherModel::applicationManager() const
250{
270{
251 return nullptr;
271 return nullptr;
tests/mocks/Unity/Launcher/MockLauncherModel.h+2
@@ -55,6 +55,8 @@ public:
55
55
56 // For testing
56 // For testing
57 Q_INVOKABLE void emitHint();
57 Q_INVOKABLE void emitHint();
58+ Q_INVOKABLE void setCount(const QString &appId, int count);
59+ Q_INVOKABLE void setCountVisible(const QString &appId, bool countVisible);
58
60
59Q_SIGNALS:
61Q_SIGNALS:
60 void quickListTriggered(const QString &appId, int index);
62 void quickListTriggered(const QString &appId, int index);
tests/qmltests/Launcher/tst_Launcher.qml+18
@@ -759,5 +759,23 @@ Item {
759 waitForWiggleToStop(appIcon5)
759 waitForWiggleToStop(appIcon5)
760 tryCompare(appIcon5, "wiggling", false, 1000, "appId #1 should not be wiggling")
760 tryCompare(appIcon5, "wiggling", false, 1000, "appId #1 should not be wiggling")
761 }
761 }
762+
763+ function test_alertViaCountAndCountVisible() {
764+ dragLauncherIntoView();
765+ var appIcon1 = findChild(launcher, "launcherDelegate1")
766+ var oldCount = LauncherModel.get(1).count
767+ LauncherModel.setCount(LauncherModel.get(1).appId, 42)
768+ tryCompare(appIcon1, "wiggling", false, 1000, "appId #1 should be still")
769+ LauncherModel.setCountVisible(LauncherModel.get(1).appId, 1)
770+ tryCompare(appIcon1, "wiggling", true, 1000, "appId #1 should not be still")
771+ LauncherModel.setAlerting(LauncherModel.get(1).appId, false)
772+ waitForWiggleToStop(appIcon1)
773+ LauncherModel.setCount(LauncherModel.get(1).appId, 4711)
774+ tryCompare(appIcon1, "wiggling", true, 1000, "appId #1 should not be still")
775+ LauncherModel.setAlerting(LauncherModel.get(1).appId, false)
776+ waitForWiggleToStop(appIcon1)
777+ LauncherModel.setCountVisible(LauncherModel.get(1).appId, 0)
778+ LauncherModel.setCount(LauncherModel.get(1).appId, oldCount)
779+ }
762 }
780 }
763}
781}