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
1=== modified file 'plugins/Unity/Launcher/launchermodel.cpp'
2--- plugins/Unity/Launcher/launchermodel.cpp 2015-02-09 17:17:59 +0000
3+++ plugins/Unity/Launcher/launchermodel.cpp 2015-03-30 17:42:43 +0000
4@@ -468,14 +468,14 @@
5 return;
6 }
7
8- bool found = false;
9- Q_FOREACH(LauncherItem *item, m_list) {
10- if (app->appId() == item->appId()) {
11- found = true;
12- break;
13+ int itemIndex = findApplication(app->appId());
14+ if (itemIndex != -1) {
15+ LauncherItem *item = m_list.at(itemIndex);
16+ if (!item->recent()) {
17+ item->setRecent(true);
18+ m_asAdapter->syncItems(m_list);
19+ Q_EMIT dataChanged(index(itemIndex), index(itemIndex), QVector<int>() << RoleRecent);
20 }
21- }
22- if (found) {
23 // Shall we paint some running/recent app highlight? If yes, do it here.
24 } else {
25 LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), this);
26
27=== modified file 'tests/plugins/Unity/Launcher/launchermodeltest.cpp'
28--- tests/plugins/Unity/Launcher/launchermodeltest.cpp 2015-02-04 15:12:36 +0000
29+++ tests/plugins/Unity/Launcher/launchermodeltest.cpp 2015-03-30 17:42:43 +0000
30@@ -400,6 +400,63 @@
31 QCOMPARE(launcherModel->get(index)->count(), 55);
32 }
33
34+ void testCountEmblemAddsRemovesItem_data() {
35+ QTest::addColumn<bool>("isPinned");
36+ QTest::addColumn<bool>("isRunning");
37+ QTest::addColumn<bool>("startWhenVisible");
38+ QTest::newRow("not pinned, not running") << false << false << false;
39+ QTest::newRow("pinned, not running") << true << false << false;
40+ QTest::newRow("not pinned, not running, starting from notification") << false << false << true;
41+ QTest::newRow("pinned, not running, starting from notification") << true << false << true;
42+ QTest::newRow("not pinned, running") << false << true << false;
43+ QTest::newRow("pinned, running") << true << true << false;
44+ }
45+
46+ void testCountEmblemAddsRemovesItem() {
47+ QFETCH(bool, isPinned);
48+ QFETCH(bool, isRunning);
49+ QFETCH(bool, startWhenVisible);
50+
51+ // Make sure item is here as expected after init() and that count is not visible
52+ int index = launcherModel->findApplication("abs-icon");
53+ QCOMPARE(index == -1, false);
54+ QCOMPARE(launcherModel->get(index)->countVisible(), false);
55+
56+ // Pin if we need to
57+ if (isPinned) {
58+ launcherModel->pin("abs-icon");
59+ }
60+ QCOMPARE(launcherModel->get(0)->pinned(), isPinned);
61+
62+ // Stop it if we need to
63+ if (!isRunning) {
64+ appManager->stopApplication("abs-icon");
65+ }
66+ QCOMPARE(launcherModel->findApplication("abs-icon") >= 0, isRunning || isPinned);
67+
68+
69+ // set the count emblem to visible
70+ QDBusInterface interface("com.canonical.Unity.Launcher", "/com/canonical/Unity/Launcher/abs_2Dicon", "org.freedesktop.DBus.Properties");
71+ interface.call("Set", "com.canonical.Unity.Launcher.Item", "count", QVariant::fromValue(QDBusVariant(55)));
72+ interface.call("Set", "com.canonical.Unity.Launcher.Item", "countVisible", QVariant::fromValue(QDBusVariant(true)));
73+
74+ // Make sure item is here and that count is visible
75+ index = launcherModel->findApplication("abs-icon");
76+ QCOMPARE(index == -1, false);
77+ QCOMPARE(launcherModel->get(index)->countVisible(), true);
78+
79+ if (!isRunning && startWhenVisible) {
80+ appManager->addApplication(new MockApp("abs-icon"));
81+ }
82+
83+ // Hide count emblem again
84+ interface.call("Set", "com.canonical.Unity.Launcher.Item", "countVisible", QVariant::fromValue(QDBusVariant(false)));
85+
86+ // Make sure item is shown/hidden as expected
87+ index = launcherModel->findApplication("abs-icon");
88+ QCOMPARE(index == -1, !isRunning && !isPinned && !startWhenVisible);
89+ }
90+
91 void testRefreshAfterDeletedDesktopFiles_data() {
92 QTest::addColumn<bool>("deleted");
93 QTest::newRow("have .desktop files") << false;

Subscribers

People subscribed via source and target branches