Merge lp:~mhr3/libunity/pass-up-goto-uri into lp:libunity

Proposed by Michal Hruby on 2013-08-15
Status: Merged
Approved by: Alejandro J. Cura on 2013-08-15
Approved revision: 277
Merged at revision: 277
Proposed branch: lp:~mhr3/libunity/pass-up-goto-uri
Merge into: lp:libunity
Diff against target: 78 lines (+48/-1)
2 files modified
src/unity-scope-dbus-impl.vala (+5/-1)
test/vala/test-scope.vala (+43/-0)
To merge this branch: bzr merge lp:~mhr3/libunity/pass-up-goto-uri
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) 2013-08-15 Approve on 2013-08-15
PS Jenkins bot (community) continuous-integration Approve on 2013-08-15
Review via email: mp+180371@code.launchpad.net

Commit message

Properly pass goto_uri to activation response.

Description of the change

Properly pass goto_uri to activation response.

This will allow a preview action to let the shell open a URI that isn't the result URI.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Alejandro J. Cura (alecu) wrote :

Looks good, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-scope-dbus-impl.vala'
2--- src/unity-scope-dbus-impl.vala 2013-08-06 08:24:48 +0000
3+++ src/unity-scope-dbus-impl.vala 2013-08-15 15:56:16 +0000
4@@ -454,8 +454,12 @@
5 if (response == null)
6 response = new ActivationResponse (HandledType.NOT_HANDLED);
7
8- // FIXME: pass goto_uri ?
9 reply.uri = scope_result.uri;
10+ if (response.goto_uri != null)
11+ {
12+ var stripped = response.goto_uri.strip ();
13+ if (stripped != "") reply.uri = stripped;
14+ }
15 reply.handled = response.handled;
16 reply.hints = response.get_hints ();
17
18
19=== modified file 'test/vala/test-scope.vala'
20--- test/vala/test-scope.vala 2013-08-05 10:01:26 +0000
21+++ test/vala/test-scope.vala 2013-08-15 15:56:16 +0000
22@@ -114,6 +114,8 @@
23 Fixture.create<MasterScopeTester> (MasterScopeTester.test_master_results_invalidated));
24 Test.add_data_func ("/Unit/MasterScope/Activation",
25 Fixture.create<MasterScopeTester> (MasterScopeTester.test_master_activation));
26+ Test.add_data_func ("/Unit/MasterScope/OverriddenGotoUri",
27+ Fixture.create<MasterScopeTester> (MasterScopeTester.test_master_overridden_goto_uri));
28 Test.add_data_func ("/Unit/MasterScope/Sorting/Ascending",
29 Fixture.create<MasterScopeTester> (MasterScopeTester.test_master_sorting_asc));
30 Test.add_data_func ("/Unit/MasterScope/Sorting/Descending",
31@@ -1768,6 +1770,47 @@
32 assert (activated_scopes.length == 3);
33 }
34
35+ public void test_master_overridden_goto_uri ()
36+ {
37+ // we need channel first
38+ Dee.SerializableModel model;
39+ var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT,
40+ out model);
41+ ScopeTester.perform_search (proxy, channel_id, "", null, model);
42+ assert (model.get_n_rows () == 3);
43+
44+ // NOTE: the order of the results is not defined, so result1 will not
45+ // necesarily belong to child_scopes[0]
46+ var iter = model.get_first_iter ();
47+ var result = model.get_row (iter, null);
48+ var uri = result[Unity.Internal.ResultColumn.URI].get_string ();
49+ int scope_index = "childscope_1" in uri ? 0 : ("childscope_2" in uri ? 1 : 2);
50+ child_scopes[scope_index].set_activate_func((result, metadata, act_id) =>
51+ {
52+ return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED,
53+ "test://overridden_uri");
54+ });
55+
56+ var ml = new MainLoop ();
57+ ActivationReplyRaw? reply = null;
58+ proxy.activate.begin (channel_id, result,
59+ Unity.Protocol.ActionType.ACTIVATE_RESULT,
60+ new HashTable<string, Variant> (null, null), null,
61+ (obj, res) =>
62+ {
63+ try
64+ {
65+ reply = proxy.activate.end (res);
66+ }
67+ catch (Error err) { assert_not_reached (); }
68+ ml.quit ();
69+ });
70+ assert (run_with_timeout (ml));
71+
72+ assert (reply != null);
73+ assert (reply.uri == "test://overridden_uri");
74+ }
75+
76 public void test_master_sorting_asc ()
77 {
78 results_per_scope = 100;

Subscribers

People subscribed via source and target branches