Merge lp:~mzanetti/unity8/fix-launcher-losing-apps into lp:unity8

Proposed by Michael Zanetti
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1704
Merged at revision: 1721
Proposed branch: lp:~mzanetti/unity8/fix-launcher-losing-apps
Merge into: lp:unity8
Diff against target: 93 lines (+64/-7)
2 files modified
plugins/Unity/Launcher/launchermodel.cpp (+7/-7)
tests/plugins/Unity/Launcher/launchermodeltest.cpp (+57/-0)
To merge this branch: bzr merge lp:~mzanetti/unity8/fix-launcher-losing-apps
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+254613@code.launchpad.net

Commit message

[Launcher] fix bug where an item would disappear even though the app is running

When an unpinned item is shown because of a count emblem notification, and
during that time the application is started, the old code wouldn't update
the app's "recent" state and so dropping it when the count emblem is cleared.

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.

no

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yes

 * Did you make sure that your branch does not contain spurious tags?

yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

n/a

 * If you changed the UI, has there been a design review?

n/a

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass?
Yes, up to what is expected of our autopilot tests nowadays

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/Unity/Launcher/launchermodel.cpp'
--- plugins/Unity/Launcher/launchermodel.cpp 2015-02-09 17:17:59 +0000
+++ plugins/Unity/Launcher/launchermodel.cpp 2015-03-30 17:42:43 +0000
@@ -468,14 +468,14 @@
468 return;468 return;
469 }469 }
470470
471 bool found = false;471 int itemIndex = findApplication(app->appId());
472 Q_FOREACH(LauncherItem *item, m_list) {472 if (itemIndex != -1) {
473 if (app->appId() == item->appId()) {473 LauncherItem *item = m_list.at(itemIndex);
474 found = true;474 if (!item->recent()) {
475 break;475 item->setRecent(true);
476 m_asAdapter->syncItems(m_list);
477 Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
476 }478 }
477 }
478 if (found) {
479 // Shall we paint some running/recent app highlight? If yes, do it here.479 // Shall we paint some running/recent app highlight? If yes, do it here.
480 } else {480 } else {
481 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);481 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
482482
=== modified file 'tests/plugins/Unity/Launcher/launchermodeltest.cpp'
--- tests/plugins/Unity/Launcher/launchermodeltest.cpp 2015-02-04 15:12:36 +0000
+++ tests/plugins/Unity/Launcher/launchermodeltest.cpp 2015-03-30 17:42:43 +0000
@@ -400,6 +400,63 @@
400 QCOMPARE(launcherModel->get(index)->count(), 55);400 QCOMPARE(launcherModel->get(index)->count(), 55);
401 }401 }
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
403 void testRefreshAfterDeletedDesktopFiles_data() {460 void testRefreshAfterDeletedDesktopFiles_data() {
404 QTest::addColumn<bool>("deleted");461 QTest::addColumn<bool>("deleted");
405 QTest::newRow("have .desktop files") << false;462 QTest::newRow("have .desktop files") << false;

Subscribers

People subscribed via source and target branches