Merge lp:~mhr3/libunity/scope-tests-fixes into lp:libunity

Proposed by Michal Hruby
Status: Merged
Approved by: James Henstridge
Approved revision: 221
Merged at revision: 221
Proposed branch: lp:~mhr3/libunity/scope-tests-fixes
Merge into: lp:libunity
Diff against target: 190 lines (+52/-62)
1 file modified
test/vala/test-scope.vala (+52/-62)
To merge this branch: bzr merge lp:~mhr3/libunity/scope-tests-fixes
Reviewer Review Type Date Requested Status
James Henstridge Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+166613@code.launchpad.net

Commit message

A couple of fixes to the scope tests.

Description of the change

Properly fix the possible hanging of the search and preview methods (which tried to acquire the default MainContext from a non-main thread).
Also fix a couple of compiler warnings.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/vala/test-scope.vala'
2--- test/vala/test-scope.vala 2013-05-23 11:49:58 +0000
3+++ test/vala/test-scope.vala 2013-05-30 23:44:26 +0000
4@@ -180,21 +180,8 @@
5
6 public override void run ()
7 {
8- var ml = new MainLoop ();
9- // simulating async search
10+ // careful this is running in separate thread
11 owner.search (this);
12- Idle.add (() => { ml.quit (); return false; });
13- ml.run ();
14- }
15-
16- /* FIXME: workaround for problem with default implementation of run_async
17- that occasionally misbehaves; shouldn't be needed anymore once we
18- determine the root cause.
19- */
20- public override void run_async (Unity.ScopeSearchBaseCallback async_callback)
21- {
22- run ();
23- async_callback (this);
24 }
25 }
26
27@@ -209,24 +196,10 @@
28
29 public override Unity.AbstractPreview? run ()
30 {
31- var ml = new MainLoop ();
32- // simulating async search
33+ // careful this is running in separate thread
34 var preview = owner.preview (this);
35- Idle.add (() => { ml.quit (); return false; });
36- ml.run ();
37-
38 return preview;
39 }
40-
41- /* FIXME: workaround for problem with default implementation of run_async
42- that occasionally misbehaves; shouldn't be needed anymore once we
43- determine the root cause.
44- */
45- public override void run_async (Unity.AbstractPreviewCallback async_callback)
46- {
47- var preview = run ();
48- async_callback (this, preview);
49- }
50 }
51
52 class TestScope: Unity.AbstractScope
53@@ -310,7 +283,7 @@
54 }
55
56 private Unity.ScopeDBusConnector connector;
57- public void export ()
58+ public void export () throws Error
59 {
60 connector = new Unity.ScopeDBusConnector (this);
61 connector.export ();
62@@ -366,7 +339,11 @@
63 public void test_scope_proxy ()
64 {
65 scope = new TestScope (DBUS_PATH);
66- scope.export ();
67+ try
68+ {
69+ scope.export ();
70+ }
71+ catch (Error err) { assert_not_reached (); }
72
73 var proxy = acquire_test_proxy ();
74 assert (proxy != null);
75@@ -452,24 +429,32 @@
76 null,
77 (obj, res) =>
78 {
79- channel_id = proxy.open_channel.end (res, out real_model);
80- if (wait_for_synchronization && real_model is Dee.SharedModel)
81+ try
82 {
83- var shared_model = real_model as Dee.SharedModel;
84- signals += new SignalWrapper (shared_model,
85- shared_model.notify["synchronized"].connect (() =>
86+ channel_id = proxy.open_channel.end (res, out real_model);
87+ if (wait_for_synchronization && real_model is Dee.SharedModel)
88+ {
89+ var shared_model = real_model as Dee.SharedModel;
90+ signals += new SignalWrapper (shared_model,
91+ shared_model.notify["synchronized"].connect (() =>
92+ {
93+ ml.quit ();
94+ }));
95+ if (shared_model.is_synchronized ()) ml.quit ();
96+ }
97+ else
98 {
99 ml.quit ();
100- }));
101- if (shared_model.is_synchronized ()) ml.quit ();
102+ }
103 }
104- else
105+ catch (Error err)
106 {
107 ml.quit ();
108 }
109 });
110
111 assert (run_with_timeout (ml));
112+ assert (channel_id != null);
113 signals = {};
114 model = real_model as Dee.SerializableModel;
115 return channel_id;
116@@ -481,7 +466,11 @@
117 proxy.close_channel.begin (channel_id, null,
118 (obj, res) =>
119 {
120- proxy.close_channel.end (res);
121+ try
122+ {
123+ proxy.close_channel.end (res);
124+ }
125+ catch (Error err) { /* silently ignore */ }
126 ml.quit ();
127 });
128
129@@ -997,31 +986,31 @@
130 try
131 {
132 master_scope.export ();
133+
134+ // init child scopes
135+ ChildScope child_scope;
136+ child_scope = new ChildScope ("/com/canonical/unity/scope/childscope_1",
137+ "test_masterscope-childscope_1.scope");
138+ child_scope.filters = filters; // set filters for one child scope
139+ child_scope.search_changed.connect (child_search_handler);
140+ child_scope.export ();
141+ child_scopes += child_scope;
142+
143+ child_scope = new ChildScope ("/com/canonical/unity/scope/childscope_2",
144+ "test_masterscope-childscope_2.scope");
145+ child_scope.search_changed.connect (child_search_handler);
146+ child_scope.export ();
147+ child_scopes += child_scope;
148+
149+ // this one has GlobalSearches=false
150+ child_scope = new ChildScope ("/com/canonical/unity/scope/childscope_3",
151+ "test_masterscope-childscope_3.scope");
152+ child_scope.search_changed.connect (child_search_handler);
153+ child_scope.export ();
154+ child_scopes += child_scope;
155 }
156 catch (Error err) { assert_not_reached (); }
157
158- // init child scopes
159- ChildScope child_scope;
160- child_scope = new ChildScope ("/com/canonical/unity/scope/childscope_1",
161- "test_masterscope-childscope_1.scope");
162- child_scope.filters = filters; // set filters for one child scope
163- child_scope.search_changed.connect (child_search_handler);
164- child_scope.export ();
165- child_scopes += child_scope;
166-
167- child_scope = new ChildScope ("/com/canonical/unity/scope/childscope_2",
168- "test_masterscope-childscope_2.scope");
169- child_scope.search_changed.connect (child_search_handler);
170- child_scope.export ();
171- child_scopes += child_scope;
172-
173- // this one has GlobalSearches=false
174- child_scope = new ChildScope ("/com/canonical/unity/scope/childscope_3",
175- "test_masterscope-childscope_3.scope");
176- child_scope.search_changed.connect (child_search_handler);
177- child_scope.export ();
178- child_scopes += child_scope;
179-
180 proxy = ScopeInitTester.acquire_test_proxy (MASTER_SCOPE_DBUS_PATH);
181 assert (proxy != null);
182 }
183@@ -1488,6 +1477,7 @@
184
185 var reply_dict = ScopeTester.push_results (proxy, channel_id, "foo", "test_masterscope-pushed.scope", pushed_model, {"1211"}, model);
186
187+ assert (reply_dict != null);
188 assert (model.get_n_rows () == 1);
189 var iter = model.get_first_iter ();
190 assert (model.get_string (iter, 0) == "remote:foo");

Subscribers

People subscribed via source and target branches