on xenial help sign in
Emit the correct role changed on count visible changed
commit93a098ced33eea1c2cccf207c56542c159cd3e70 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 7 Jul 2016, 18:18 (10 years ago) parent91a714d
3 files changed+37−1
plugins/Unity/Launcher/launchermodel.cpp+1−1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+21 tests/qmltests/Launcher/tst_Launcher.qml+15
plugins/Unity/Launcher/launchermodel.cpp+1−1
@@ -365,7 +365,7 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
365365 if (idx >= 0) {
366366 LauncherItem *item = m_list.at(idx);
367367 item->setCountVisible(countVisible);
368− QVector<int> changedRoles = {RoleCount};
368+ QVector<int> changedRoles = {RoleCountVisible};
369369 if (countVisible && !item->alerting() && !item->focused()) {
370370 changedRoles << RoleAlerting;
371371 item->setAlerting(true);
tests/plugins/Unity/Launcher/launchermodeltest.cpp+21
@@ -492,6 +492,27 @@ private Q_SLOTS:
492492 // Finally check, that the change to "count" implicitly also set the alerting-state to true
493493 QVERIFY(launcherModel->get(index)->alerting() == true);
494494
495+ // Check if the launcher emitted the changed signals
496+ QCOMPARE(spy.count(), 2);
497+
498+ QVariantList countEmissionArgs = spy.takeFirst();
499+ QCOMPARE(countEmissionArgs.at(0).value<QModelIndex>().row(), index);
500+ QCOMPARE(countEmissionArgs.at(1).value<QModelIndex>().row(), index);
501+ QVector<int> roles = countEmissionArgs.at(2).value<QVector<int> >();
502+ QCOMPARE(roles.first(), (int)LauncherModel::RoleCount);
503+
504+ QVariantList countVisibleEmissionArgs = spy.takeFirst();
505+ QCOMPARE(countVisibleEmissionArgs.at(0).value<QModelIndex>().row(), index);
506+ QCOMPARE(countVisibleEmissionArgs.at(1).value<QModelIndex>().row(), index);
507+ roles = countVisibleEmissionArgs.at(2).value<QVector<int> >();
508+ QVERIFY(roles.contains(LauncherModel::RoleCountVisible));
509+ QVERIFY(roles.contains(LauncherModel::RoleAlerting));
510+
511+ // Check if the values match
512+ QCOMPARE(launcherModel->get(index)->countVisible(), true);
513+ QCOMPARE(launcherModel->get(index)->count(), 55);
514+ QCOMPARE(launcherModel->get(index)->alerting(), true);
515+
495516 // Focus the app, make sure the alert gets cleared
496517 appManager->focusApplication("abs-icon");
497518 QVERIFY(launcherModel->get(index)->alerting() == false);
tests/qmltests/Launcher/tst_Launcher.qml+15
@@ -203,6 +203,21 @@ Rectangle {
203203 onClicked: LauncherModel.setAlerting(LauncherModel.get(parseInt(appIdEntryAlert.displayText)).appId, false)
204204 }
205205 }
206+
207+ Row {
208+ spacing: units.gu(1)
209+ Button {
210+ text: "Toggle count visible"
211+ onClicked: {
212+ var item = LauncherModel.get(parseInt(appIdEntryCountVisible.displayText))
213+ LauncherModel.setCountVisible(item.appId, !item.countVisible)
214+ }
215+ }
216+ TextField {
217+ id: appIdEntryCountVisible
218+ text: "0"
219+ }
220+ }
206221 }
207222
208223 SignalSpy {