on xenial help sign in
Emit the correct role changed on count visible changed
93a098cMichael Zanetti
plugins/Unity/Launcher/launchermodel.cpp+1−1
@@ -365,7 +365,7 @@ void LauncherModel::countVisibleChanged(const QString &appId, bool countVisible)
365 if (idx >= 0) {
365 if (idx >= 0) {
366 LauncherItem *item = m_list.at(idx);
366 LauncherItem *item = m_list.at(idx);
367 item->setCountVisible(countVisible);
367 item->setCountVisible(countVisible);
368− QVector<int> changedRoles = {RoleCount};
368+ QVector<int> changedRoles = {RoleCountVisible};
369 if (countVisible && !item->alerting() && !item->focused()) {
369 if (countVisible && !item->alerting() && !item->focused()) {
370 changedRoles << RoleAlerting;
370 changedRoles << RoleAlerting;
371 item->setAlerting(true);
371 item->setAlerting(true);
tests/plugins/Unity/Launcher/launchermodeltest.cpp+21
@@ -492,6 +492,27 @@ private Q_SLOTS:
492 // Finally check, that the change to "count" implicitly also set the alerting-state to true
492 // Finally check, that the change to "count" implicitly also set the alerting-state to true
493 QVERIFY(launcherModel->get(index)->alerting() == true);
493 QVERIFY(launcherModel->get(index)->alerting() == true);
494
494
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+
495 // Focus the app, make sure the alert gets cleared
516 // Focus the app, make sure the alert gets cleared
496 appManager->focusApplication("abs-icon");
517 appManager->focusApplication("abs-icon");
497 QVERIFY(launcherModel->get(index)->alerting() == false);
518 QVERIFY(launcherModel->get(index)->alerting() == false);
tests/qmltests/Launcher/tst_Launcher.qml+15
@@ -203,6 +203,21 @@ Rectangle {
203 onClicked: LauncherModel.setAlerting(LauncherModel.get(parseInt(appIdEntryAlert.displayText)).appId, false)
203 onClicked: LauncherModel.setAlerting(LauncherModel.get(parseInt(appIdEntryAlert.displayText)).appId, false)
204 }
204 }
205 }
205 }
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+ }
206 }
221 }
207
222
208 SignalSpy {
223 SignalSpy {