Merge lp:~mvo/unity/usc-launcher-fix-982921 into lp:unity

Proposed by Michael Vogt
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: no longer in the source branch.
Merged at revision: 2346
Proposed branch: lp:~mvo/unity/usc-launcher-fix-982921
Merge into: lp:unity
Diff against target: 79 lines (+37/-9)
3 files modified
manual-tests/SoftwareCenter.txt (+16/-0)
plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp (+20/-9)
plugins/unityshell/src/SoftwareCenterLauncherIcon.h (+1/-0)
To merge this branch: bzr merge lp:~mvo/unity/usc-launcher-fix-982921
Reviewer Review Type Date Requested Status
Michael Vogt (community) Needs Resubmitting
Tim Penhey (community) Approve
Review via email: mp+102257@code.launchpad.net

Commit message

Check for "exit_state" on the install-finished signal from aptdaemon (LP: #982921) and remove launcher icon again on failure.

Description of the change

This branch adds a check for the "exit_state" of the install-finished signal from aptdaemon for the
software-center launcher integration and removes the launcher again if we get something other than
"exit-success". This fixes #982921.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) :
review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

@Tim, @Michael: I would like to see tests on that one before approving :)

Revision history for this message
Michael Vogt (mvo) wrote :

Hey Didier,

I'm not familiar with untiy much, so pardon my ignorance. But I could not find a existing test for the SoftwareCenterLauncherIcon or the dbus signal(s) that are used for it. If you could point me towards that
I can see how to add a test.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Hey Michael.

Rev 2183 is definitively what you want to look for.
The autopilot test (autopilot is controling the session graphically) is in test/autopilot/autopilot/tests/test_launcher.py: test_software_center_add_icon()

Maybe Thomi who is the most familiar for autopilot can cook something really quick and easily though?

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi everyone,

Short answer: Testing this is tricky.

Long answer: Testing this is tricky. The software center launcher icon is tightly coupled to the apt daemon dbus protocol, which makes it hard to test from autopilot. In fact, even writing unit tests for this is tricky. What we need to do is to decouple the code that handles the launcher icon from the notion of a data source for the icon. This will allow us to create a fake data source in a unit test and feed it whatever input we like. However, looking at the code, I suspect that's not going to be the end of the issues - the SCLauncherIcon also depends on the Launcher for several things, and a couple of other classes as well. With some refactoring we can fix all this, but it's a reasonable amount of work.

If this is a really high priority I can have a look at it (dropping the tasks I'm currently on), but it's not likely to be done before tomorrow lunchtime.

What's the deadline on this?

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

@Thomi: I'm happy to merge it if Michael adds a manual test to ensure that we don't loose the idea of getting it automatically tested later on.

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, I added a manual test now. Sorry about the needed refactor for a proper fix but this was just a drive-by-fix by me.

review: Needs Resubmitting
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'manual-tests/SoftwareCenter.txt'
2--- manual-tests/SoftwareCenter.txt 1970-01-01 00:00:00 +0000
3+++ manual-tests/SoftwareCenter.txt 2012-04-26 08:10:23 +0000
4@@ -0,0 +1,16 @@
5+The SoftwareCenter Launcher Integration cancel
6+----------------------------------------------
7+
8+Setup:
9+#. Open software-center
10+
11+Actions:
12+#. Click on install on a big application like wesnoth
13+#. Verify that the icon "flies" into the launcher
14+#. Wait until the "In Progress" appears in the toplevel toolbar of s-c
15+#. Click on the "In Progress" button in the toolbar
16+#. Click on the "cancel" button of the install of the application
17+
18+Expected Result:
19+ The icon is removed from the launcher again after the download was
20+ canceled.
21
22=== modified file 'plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp'
23--- plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp 2012-03-28 21:03:59 +0000
24+++ plugins/unityshell/src/SoftwareCenterLauncherIcon.cpp 2012-04-26 08:10:23 +0000
25@@ -46,15 +46,7 @@
26 {
27
28 aptdaemon_trans_.Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged));
29- aptdaemon_trans_.Connect("Finished", [&] (GVariant *)
30- {
31- tooltip_text = BamfName();
32- SetQuirk(QUIRK_PROGRESS, false);
33- SetQuirk(QUIRK_URGENT, true);
34- SetProgress(0.0f);
35- finished_ = true;
36- needs_urgent_ = true;
37- });
38+ aptdaemon_trans_.Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished));
39
40 SetIconType(TYPE_APPLICATION);
41 icon_name = icon_path;
42@@ -130,6 +122,25 @@
43 SetQuirk(QUIRK_STARTING, false);
44 }
45
46+void SoftwareCenterLauncherIcon::OnFinished(GVariant *params)
47+{
48+ glib::String exit_state;
49+ g_variant_get_child(params, 0, "s", &exit_state);
50+
51+ if (exit_state.Str() == "exit-success")
52+ {
53+ tooltip_text = BamfName();
54+ SetQuirk(QUIRK_PROGRESS, false);
55+ SetQuirk(QUIRK_URGENT, true);
56+ SetProgress(0.0f);
57+ finished_ = true;
58+ needs_urgent_ = true;
59+ } else {
60+ // failure condition, remove icon again
61+ UnStick();
62+ }
63+};
64+
65 void SoftwareCenterLauncherIcon::OnPropertyChanged(GVariant* params)
66 {
67 gint32 progress;
68
69=== modified file 'plugins/unityshell/src/SoftwareCenterLauncherIcon.h'
70--- plugins/unityshell/src/SoftwareCenterLauncherIcon.h 2012-03-28 02:42:13 +0000
71+++ plugins/unityshell/src/SoftwareCenterLauncherIcon.h 2012-04-26 08:10:23 +0000
72@@ -51,6 +51,7 @@
73
74 private:
75 void OnPropertyChanged(GVariant* params);
76+ void OnFinished(GVariant *params);
77 void OnDragAnimationFinished();
78
79 glib::DBusProxy aptdaemon_trans_;