on xenial help sign in
Extended qmltest for Launcher to verify the implicit alerting when count and countVisible of an item change.
commit8d68a0ee3c202c9007732920eed06800b87a9b6e authorMirco Müller <mirco.mueller@canonical.com> dateThu 2 Jul 2015, 15:42 (11 years ago) parenteb1bd3b
3 files changed+40
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+20 tests/mocks/Unity/Launcher/MockLauncherModel.h+2 tests/qmltests/Launcher/tst_Launcher.qml+18
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+20
@@ -246,6 +246,26 @@ void MockLauncherModel::emitHint()
246246 Q_EMIT hint();
247247}
248248
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+
249269unity::shell::application::ApplicationManagerInterface *MockLauncherModel::applicationManager() const
250270{
251271 return nullptr;
tests/mocks/Unity/Launcher/MockLauncherModel.h+2
@@ -55,6 +55,8 @@ public:
5555
5656 // For testing
5757 Q_INVOKABLE void emitHint();
58+ Q_INVOKABLE void setCount(const QString &appId, int count);
59+ Q_INVOKABLE void setCountVisible(const QString &appId, bool countVisible);
5860
5961Q_SIGNALS:
6062 void quickListTriggered(const QString &appId, int index);
tests/qmltests/Launcher/tst_Launcher.qml+18
@@ -759,5 +759,23 @@ Item {
759759 waitForWiggleToStop(appIcon5)
760760 tryCompare(appIcon5, "wiggling", false, 1000, "appId #1 should not be wiggling")
761761 }
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+ }
762780 }
763781}