@@ -400,6 +400,63 @@ private Q_SLOTS:
400400 QCOMPARE(launcherModel->get(index)->count(), 55);
401401 }
402402
403+ void testCountEmblemAddsRemovesItem_data() {
404+ QTest::addColumn<bool>("isPinned");
405+ QTest::addColumn<bool>("isRunning");
406+ QTest::addColumn<bool>("startWhenVisible");
407+ QTest::newRow("not pinned, not running") << false << false << false;
408+ QTest::newRow("pinned, not running") << true << false << false;
409+ QTest::newRow("not pinned, not running, starting from notification") << false << false << true;
410+ QTest::newRow("pinned, not running, starting from notification") << true << false << true;
411+ QTest::newRow("not pinned, running") << false << true << false;
412+ QTest::newRow("pinned, running") << true << true << false;
413+ }
414+
415+ void testCountEmblemAddsRemovesItem() {
416+ QFETCH(bool, isPinned);
417+ QFETCH(bool, isRunning);
418+ QFETCH(bool, startWhenVisible);
419+
420+ // Make sure item is here as expected after init() and that count is not visible
421+ int index = launcherModel->findApplication("abs-icon");
422+ QCOMPARE(index == -1, false);
423+ QCOMPARE(launcherModel->get(index)->countVisible(), false);
424+
425+ // Pin if we need to
426+ if (isPinned) {
427+ launcherModel->pin("abs-icon");
428+ }
429+ QCOMPARE(launcherModel->get(0)->pinned(), isPinned);
430+
431+ // Stop it if we need to
432+ if (!isRunning) {
433+ appManager->stopApplication("abs-icon");
434+ }
435+ QCOMPARE(launcherModel->findApplication("abs-icon") >= 0, isRunning || isPinned);
436+
437+
438+ // set the count emblem to visible
439+ QDBusInterface interface("com.canonical.Unity.Launcher", "/com/canonical/Unity/Launcher/abs_2Dicon", "org.freedesktop.DBus.Properties");
440+ interface.call("Set", "com.canonical.Unity.Launcher.Item", "count", QVariant::fromValue(QDBusVariant(55)));
441+ interface.call("Set", "com.canonical.Unity.Launcher.Item", "countVisible", QVariant::fromValue(QDBusVariant(true)));
442+
443+ // Make sure item is here and that count is visible
444+ index = launcherModel->findApplication("abs-icon");
445+ QCOMPARE(index == -1, false);
446+ QCOMPARE(launcherModel->get(index)->countVisible(), true);
447+
448+ if (!isRunning && startWhenVisible) {
449+ appManager->addApplication(new MockApp("abs-icon"));
450+ }
451+
452+ // Hide count emblem again
453+ interface.call("Set", "com.canonical.Unity.Launcher.Item", "countVisible", QVariant::fromValue(QDBusVariant(false)));
454+
455+ // Make sure item is shown/hidden as expected
456+ index = launcherModel->findApplication("abs-icon");
457+ QCOMPARE(index == -1, !isRunning && !isPinned && !startWhenVisible);
458+ }
459+
403460 void testRefreshAfterDeletedDesktopFiles_data() {
404461 QTest::addColumn<bool>("deleted");
405462 QTest::newRow("have .desktop files") << false;