Merge lp:~mhr3/unity/fix-scope-tests into lp:unity
- fix-scope-tests
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3435 |
Proposed branch: | lp:~mhr3/unity/fix-scope-tests |
Merge into: | lp:unity |
Diff against target: |
1005 lines (+115/-613) 11 files modified
debian/control (+2/-1) tests/CMakeLists.txt (+2/-4) tests/dummy-dbus-test-runner.sh (+0/-62) tests/test_categories.cpp (+20/-17) tests/test_scope_impl.c (+30/-449) tests/test_scope_impl.h (+6/-36) tests/test_scope_proxy.cpp (+3/-3) tests/test_service_main.cpp (+16/-12) tests/test_service_model.cpp (+19/-5) tests/test_service_scope.cpp (+13/-21) tests/test_service_scope.h (+4/-3) |
To merge this branch: | bzr merge lp:~mhr3/unity/fix-scope-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Marco Trevisan (Treviño) | Approve | ||
Review via email: mp+174447@code.launchpad.net |
Commit message
Fix scope-related tests.
Description of the change
Fix scope-related tests.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
This is awesome, thanks!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3425
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:2426
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3426
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3426
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3427
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3428
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3429
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3430
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
You would probably merge this against lp:~3v1n0/unity/gdbus-interface-fix-ref-unref at this point, also what about continuing using the crafted dbus launch script?
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3431
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michal Hruby (mhr3) wrote : | # |
> You would probably merge this against lp:~3v1n0/unity/gdbus-interface-fix-ref-
> unref at this point, also what about continuing using the crafted dbus launch
> script?
Looks like CI is fine with the dbus-test-runner, so I'd rather keep it, afterall it has some nice features that the script doesn't (like the timeout, clear separation of what's coming from the server and the client, waiting for a name before starting a task...)
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Looks great, thanks!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Michal Hruby (mhr3) wrote : | # |
Disabled the TestCategoriesC
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3432
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3433
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3434
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
So unfortunately the new libdee is not in the local repo that jenkins is using for building this during CI, so we have to wait until it reaches the daily ppa... :(
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3434
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Michal Hruby (mhr3) wrote : | # |
> So unfortunately the new libdee is not in the local repo that jenkins is using
> for building this during CI, so we have to wait until it reaches the daily
> ppa... :(
Seems it's released now, let's try again.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2013-07-15 10:00:58 +0000 |
3 | +++ debian/control 2013-07-19 11:30:33 +0000 |
4 | @@ -5,6 +5,7 @@ |
5 | Build-Depends: cmake, |
6 | compiz-dev (>= 1:0.9.9~daily13.01.25bzr3586), |
7 | debhelper (>= 9.0.0~), |
8 | + dbus-test-runner, |
9 | dh-migrations, |
10 | dh-translations (>= 94), |
11 | google-mock (>= 1.6.0+svn437), |
12 | @@ -18,7 +19,7 @@ |
13 | libcairo2-dev, |
14 | libcompizconfig0-dev (>= 1:0.9.9~daily12.12.05-0ubuntu2), |
15 | libdbusmenu-glib-dev (>= 0.3.91), |
16 | - libdee-dev (>= 1.0.0), |
17 | + libdee-dev (>= 1.2.6), |
18 | libgee-dev (>= 0.5.0), |
19 | libgeis-dev (>= 2.0.10), |
20 | libgl1-mesa-dri, |
21 | |
22 | === modified file 'tests/CMakeLists.txt' |
23 | --- tests/CMakeLists.txt 2013-07-12 19:37:48 +0000 |
24 | +++ tests/CMakeLists.txt 2013-07-19 11:30:33 +0000 |
25 | @@ -353,7 +353,6 @@ |
26 | set (TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/tests) |
27 | set (TEST_RESULT_XML ${TEST_RESULT_DIR}/test-results.xml) |
28 | set (TEST_RESULT_HTML ${TEST_RESULT_DIR}/test-results.html) |
29 | -set (DUMMY_DBUS_TEST_RUNNER ${CMAKE_CURRENT_SOURCE_DIR}/dummy-dbus-test-runner.sh) |
30 | set (DUMMY_XORG_TEST_RUNNER ${CMAKE_CURRENT_SOURCE_DIR}/dummy-xorg-test-runner.sh) |
31 | if (ENABLE_X_SUPPORT) |
32 | set (GTEST_TEST_COMMAND ./test-gtest --gtest_output=xml:./test-gtest.xml) |
33 | @@ -361,13 +360,12 @@ |
34 | endif (ENABLE_X_SUPPORT) |
35 | set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless --gtest_output=xml:./test-gtest-xless.xml) |
36 | set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow --gtest_output=xml:./test-gtest-slow.xml) |
37 | -set (GTEST_TEST_COMMAND_DBUS ${DUMMY_DBUS_TEST_RUNNER} ./test-gtest-service ./test-gtest-dbus --gtest_output=xml:./test-gtest-dbus.xml) |
38 | +set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --max-wait=300 --task ./test-gtest-service --task-name test-service --task=./test-gtest-dbus --task-name=test-dbus --wait-for=com.canonical.Unity.Test.Scope --parameter=--gtest_output=xml:./test-gtest-dbus.xml --parameter=--gtest_filter=-TestCategoriesChanging*) |
39 | |
40 | set (TEST_COMMAND_XLESS |
41 | ${GTEST_TEST_COMMAND_XLESS} |
42 | && ${GTEST_TEST_COMMAND_GESTURES} |
43 | - && ${GTEST_TEST_COMMAND_DBUS} --gtest_filter=-TestScope* |
44 | - && echo "Warning, TestScope* DBus test cases are disabled!!") |
45 | + && ${GTEST_TEST_COMMAND_DBUS}) |
46 | |
47 | set (TEST_COMMAND |
48 | ${GTEST_TEST_COMMAND} |
49 | |
50 | === removed file 'tests/dummy-dbus-test-runner.sh' |
51 | --- tests/dummy-dbus-test-runner.sh 2013-07-11 02:01:58 +0000 |
52 | +++ tests/dummy-dbus-test-runner.sh 1970-01-01 00:00:00 +0000 |
53 | @@ -1,62 +0,0 @@ |
54 | -#!/bin/bash |
55 | -# Copyright (C) 2013 Canonical Ltd |
56 | -# |
57 | -# This program is free software: you can redistribute it and/or modify |
58 | -# it under the terms of the GNU General Public License version 3 as |
59 | -# published by the Free Software Foundation. |
60 | -# |
61 | -# This program is distributed in the hope that it will be useful, |
62 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
63 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
64 | -# GNU General Public License for more details. |
65 | -# |
66 | -# You should have received a copy of the GNU General Public License |
67 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
68 | -# |
69 | -# Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
70 | - |
71 | -function check_command() |
72 | -{ |
73 | - local binary=$(which $1) |
74 | - |
75 | - if [ -z "$binary" ]; then |
76 | - if [ -z "$1" ]; then |
77 | - echo "Invalid $2 submitted" |
78 | - elif [ ! -x "$1" ]; then |
79 | - echo "The provided $1 is not executable" |
80 | - fi |
81 | - |
82 | - exit 1 |
83 | - fi |
84 | -} |
85 | - |
86 | -check_command "$1" "service" |
87 | -service=$1 |
88 | -for p in $(pidof $(basename $service)); do kill $p; done |
89 | - |
90 | -shift |
91 | -check_command "$1" "test" |
92 | -binary=$1 |
93 | - |
94 | -dbusfile=$(mktemp -t dummy.dbus.sh.XXXXXXXX) |
95 | -dbus-launch --sh-syntax > $dbusfile |
96 | -source $dbusfile |
97 | - |
98 | -function do_cleanup() |
99 | -{ |
100 | - if [ -n "$service_pid" ] && (kill -0 $service_pid &> /dev/null); then kill $service_pid; fi |
101 | - kill $DBUS_SESSION_BUS_PID |
102 | - rm $dbusfile |
103 | -} |
104 | - |
105 | -trap "do_cleanup; exit 1" SIGHUP SIGINT SIGSEGV SIGTERM |
106 | - |
107 | -$service &> /dev/null & |
108 | -service_pid=$! |
109 | - |
110 | -shift |
111 | -$binary $@ |
112 | -ret_val=$? |
113 | - |
114 | -do_cleanup |
115 | -exit $ret_val |
116 | |
117 | === modified file 'tests/test_categories.cpp' |
118 | --- tests/test_categories.cpp 2013-07-10 16:01:34 +0000 |
119 | +++ tests/test_categories.cpp 2013-07-19 11:30:33 +0000 |
120 | @@ -12,8 +12,6 @@ |
121 | namespace |
122 | { |
123 | |
124 | -static const string swarm_name = "com.canonical.test.categoriesmodel"; |
125 | -static const string swarm_name_changing = "com.canonical.test.categoriesmodel_changing"; |
126 | static const unsigned int n_rows = 5; |
127 | |
128 | static void WaitForSynchronize(Categories& model) |
129 | @@ -25,7 +23,17 @@ |
130 | { |
131 | TestCategories() |
132 | { |
133 | - model.swarm_name = swarm_name; |
134 | + model.swarm_name = "com.canonical.test.categoriesmodel"; |
135 | + } |
136 | + |
137 | + Categories model; |
138 | +}; |
139 | + |
140 | +struct TestCategoriesChanging : testing::Test |
141 | +{ |
142 | + TestCategoriesChanging() |
143 | + { |
144 | + model.swarm_name = "com.canonical.test.categoriesmodel_changing"; |
145 | } |
146 | |
147 | Categories model; |
148 | @@ -33,7 +41,7 @@ |
149 | |
150 | TEST_F(TestCategories, TestConstruction) |
151 | { |
152 | - EXPECT_EQ(model.swarm_name(), swarm_name); |
153 | + EXPECT_EQ(model.swarm_name(), "com.canonical.test.categoriesmodel"); |
154 | } |
155 | |
156 | TEST_F(TestCategories, TestSignalProxyAdded) |
157 | @@ -122,42 +130,38 @@ |
158 | } |
159 | |
160 | // We're testing the model's ability to store and retrieve random pointers |
161 | -TEST_F(TestCategories, TestOnRowChanged) |
162 | +TEST_F(TestCategoriesChanging, TestOnRowChanged) |
163 | { |
164 | - model.swarm_name = swarm_name_changing; |
165 | WaitForSynchronize(model); |
166 | |
167 | unsigned changed = 0; |
168 | model.category_changed.connect([&changed] (Category const&) { ++changed; }); |
169 | - Utils::WaitUntil([&changed] { return changed == 1; }, true, 2, "Did not detect row change from "+swarm_name_changing+"."); |
170 | + Utils::WaitUntil([&changed] { return changed == 1; }, true, 2, "Did not detect row change."); |
171 | } |
172 | |
173 | |
174 | // We're testing the model's ability to store and retrieve random pointers |
175 | -TEST_F(TestCategories, TestOnRowAdded) |
176 | +TEST_F(TestCategoriesChanging, TestOnRowAdded) |
177 | { |
178 | - model.swarm_name = swarm_name_changing; |
179 | WaitForSynchronize(model); |
180 | |
181 | unsigned added = 0; |
182 | model.category_added.connect([&added] (Category const&) { ++added;}); |
183 | - Utils::WaitUntil([&added] { return added == 1; }, true, 2, "Did not detect row add "+swarm_name_changing+"."); |
184 | + Utils::WaitUntil([&added] { return added == 1; }, true, 2, "Did not detect row add."); |
185 | } |
186 | |
187 | // We're testing the model's ability to store and retrieve random pointers |
188 | -TEST_F(TestCategories, TestOnRowRemoved) |
189 | +TEST_F(TestCategoriesChanging, TestOnRowRemoved) |
190 | { |
191 | - model.swarm_name = swarm_name_changing; |
192 | WaitForSynchronize(model); |
193 | |
194 | unsigned removed = 0; |
195 | model.category_removed.connect([&removed] (Category const&) { ++removed; }); |
196 | - Utils::WaitUntil([&removed] { return removed == 1; }, true, 2, "Did not detect row removal "+swarm_name_changing+"."); |
197 | + Utils::WaitUntil([&removed] { return removed == 1; }, true, 2, "Did not detect row removal."); |
198 | } |
199 | |
200 | -TEST_F(TestCategories, TestCategoryCopy) |
201 | +TEST_F(TestCategoriesChanging, TestCategoryCopy) |
202 | { |
203 | - model.swarm_name = swarm_name_changing; |
204 | WaitForSynchronize(model); |
205 | |
206 | Category category = model.RowAtIndex(0); |
207 | @@ -170,9 +174,8 @@ |
208 | EXPECT_EQ(category.index(), category_2.index()); |
209 | } |
210 | |
211 | -TEST_F(TestCategories, TestCategoryEqual) |
212 | +TEST_F(TestCategoriesChanging, TestCategoryEqual) |
213 | { |
214 | - model.swarm_name = swarm_name_changing; |
215 | WaitForSynchronize(model); |
216 | |
217 | Category category = model.RowAtIndex(0); |
218 | |
219 | === modified file 'tests/test_scope_impl.c' |
220 | --- tests/test_scope_impl.c 2013-03-27 17:26:54 +0000 |
221 | +++ tests/test_scope_impl.c 2013-07-19 11:30:33 +0000 |
222 | @@ -24,195 +24,7 @@ |
223 | |
224 | #define TEST_DBUS_NAME "com.canonical.Unity.Test.Scope" |
225 | |
226 | -#define _g_object_unref_safe(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) |
227 | -#define _g_free_safe(var) (var = (g_free (var), NULL)) |
228 | - |
229 | -/* ------------------ Test Searcher ---------------------- */ |
230 | - |
231 | -#define TEST_TYPE_SEARCHER (test_searcher_get_type ()) |
232 | -#define TEST_SCOPE_SEARCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_SEARCHER, TestSearcher)) |
233 | -#define TEST_SEARCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_SEARCHER, TestSearcherClass)) |
234 | -#define TEST_IS_SEARCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_SEARCHER)) |
235 | -#define TEST_IS_SEARCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_SEARCHER)) |
236 | -#define TEST_SEARCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SEARCHER, TestSearcherClass)) |
237 | - |
238 | -typedef struct _TestSearcher TestSearcher; |
239 | -typedef struct _TestSearcherClass TestSearcherClass; |
240 | -typedef struct _TestSearcherPrivate TestSearcherPrivate; |
241 | - |
242 | -struct _TestSearcher { |
243 | - UnityScopeSearchBase parent_instance; |
244 | - TestSearcherPrivate * priv; |
245 | -}; |
246 | - |
247 | -struct _TestSearcherClass { |
248 | - UnityScopeSearchBaseClass parent_class; |
249 | -}; |
250 | - |
251 | -struct _TestSearcherPrivate { |
252 | - TestScope* _owner; |
253 | -}; |
254 | - |
255 | -typedef struct _SearcherRunData SearcherRunData; |
256 | - |
257 | -G_DEFINE_TYPE(TestSearcher, test_searcher, UNITY_TYPE_SCOPE_SEARCH_BASE); |
258 | - |
259 | -#define TEST_SEARCHER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_TYPE_SEARCHER, TestSearcherPrivate)) |
260 | -enum { |
261 | - TEST_SEARCHER_DUMMY_PROPERTY, |
262 | - TEST_SEARCHER_OWNER |
263 | -}; |
264 | - |
265 | -static TestSearcher* test_searcher_new (TestScope* scope); |
266 | -static void test_searcher_run (UnityScopeSearchBase* base); |
267 | -static TestScope* test_searcher_get_owner (TestSearcher* self); |
268 | -static void test_searcher_set_owner (TestSearcher* self, TestScope* value); |
269 | -static void test_searcher_finalize (GObject* obj); |
270 | -static void test_searcher_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); |
271 | -static void test_searcher_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); |
272 | - |
273 | -static TestSearcher* test_searcher_new (TestScope* scope) |
274 | -{ |
275 | - return (TestSearcher*) g_object_new (TEST_TYPE_SEARCHER, "owner", scope, NULL); |
276 | -} |
277 | - |
278 | -static TestScope* test_searcher_get_owner (TestSearcher* self) |
279 | -{ |
280 | - g_return_val_if_fail (self != NULL, NULL); |
281 | - return self->priv->_owner; |
282 | -} |
283 | - |
284 | -static void test_searcher_set_owner (TestSearcher* self, TestScope* value) |
285 | -{ |
286 | - g_return_if_fail (self != NULL); |
287 | - self->priv->_owner = value; |
288 | - g_object_notify ((GObject *) self, "owner"); |
289 | -} |
290 | - |
291 | -static void test_searcher_class_init (TestSearcherClass * klass) |
292 | -{ |
293 | - g_type_class_add_private (klass, sizeof (TestSearcherPrivate)); |
294 | - UNITY_SCOPE_SEARCH_BASE_CLASS (klass)->run = test_searcher_run; |
295 | - G_OBJECT_CLASS (klass)->get_property = test_searcher_get_property; |
296 | - G_OBJECT_CLASS (klass)->set_property = test_searcher_set_property; |
297 | - G_OBJECT_CLASS (klass)->finalize = test_searcher_finalize; |
298 | - g_object_class_install_property (G_OBJECT_CLASS (klass), TEST_SEARCHER_OWNER, g_param_spec_object ("owner", "owner", "owner", TEST_TYPE_SCOPE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); |
299 | -} |
300 | - |
301 | -static void test_searcher_init(TestSearcher* self) |
302 | -{ |
303 | - self->priv = TEST_SEARCHER_GET_PRIVATE (self); |
304 | -} |
305 | - |
306 | -static void test_searcher_finalize (GObject* obj) |
307 | -{ |
308 | - TestSearcher * self; |
309 | - self = TEST_SCOPE_SEARCHER (obj); |
310 | - G_OBJECT_CLASS (test_searcher_parent_class)->finalize (obj); |
311 | -} |
312 | - |
313 | -static void test_searcher_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) |
314 | -{ |
315 | - TestSearcher * self; |
316 | - self = TEST_SCOPE_SEARCHER (object); |
317 | - switch (property_id) { |
318 | - case TEST_SEARCHER_OWNER: |
319 | - g_value_set_object (value, test_searcher_get_owner (self)); |
320 | - break; |
321 | - default: |
322 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
323 | - break; |
324 | - } |
325 | -} |
326 | - |
327 | -static void test_searcher_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) |
328 | -{ |
329 | - TestSearcher * self; |
330 | - self = TEST_SCOPE_SEARCHER (object); |
331 | - switch (property_id) { |
332 | - case TEST_SEARCHER_OWNER: |
333 | - test_searcher_set_owner (self, g_value_get_object (value)); |
334 | - break; |
335 | - default: |
336 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
337 | - break; |
338 | - } |
339 | -} |
340 | - |
341 | -struct _SearcherRunData |
342 | -{ |
343 | - int _ref_count_; |
344 | - TestSearcher * self; |
345 | - GMainLoop* ml; |
346 | - UnityScopeSearchBaseCallback async_callback; |
347 | - void* async_callback_target; |
348 | -}; |
349 | - |
350 | -static SearcherRunData* run_data_ref (SearcherRunData* data) |
351 | -{ |
352 | - g_atomic_int_inc (&data->_ref_count_); |
353 | - return data; |
354 | -} |
355 | - |
356 | -static void run_data_unref (void * _userdata_) |
357 | -{ |
358 | - SearcherRunData* data; |
359 | - data = (SearcherRunData*) _userdata_; |
360 | - if (g_atomic_int_dec_and_test (&data->_ref_count_)) |
361 | - { |
362 | - TestSearcher* self; |
363 | - self = data->self; |
364 | - g_main_loop_unref (data->ml); |
365 | - g_object_unref (self); |
366 | - g_slice_free (SearcherRunData, data); |
367 | - } |
368 | -} |
369 | - |
370 | -static gboolean test_searcher_main_loop_func (gpointer data) |
371 | -{ |
372 | - SearcherRunData* search_data; |
373 | - search_data = (SearcherRunData*) data; |
374 | - |
375 | - TestSearcher* self; |
376 | - self = search_data->self; |
377 | - UNITY_SCOPE_SEARCH_BASE_GET_CLASS (self)->run(UNITY_SCOPE_SEARCH_BASE (self)); |
378 | - |
379 | - search_data->async_callback (UNITY_SCOPE_SEARCH_BASE (self), search_data->async_callback_target); |
380 | - g_main_loop_quit (search_data->ml); |
381 | - return FALSE; |
382 | -} |
383 | - |
384 | -static void test_searcher_run (UnityScopeSearchBase* base) |
385 | -{ |
386 | - TestSearcher* self; |
387 | - self = TEST_SCOPE_SEARCHER (base); |
388 | - |
389 | - g_signal_emit_by_name (self->priv->_owner, "search", base); |
390 | -} |
391 | - |
392 | -/* ------------------ Test Result Previewer ---------------------- */ |
393 | - |
394 | -#define TEST_TYPE_RESULT_PREVIEWER (test_result_previewer_get_type ()) |
395 | -#define TEST_RESULT_PREVIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_RESULT_PREVIEWER, TestResultPreviewer)) |
396 | -#define TEST_RESULT_PREVIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_RESULT_PREVIEWER, TestResultPreviewerClass)) |
397 | -#define TEST_IS_RESULT_PREVIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_RESULT_PREVIEWER)) |
398 | -#define TEST_IS_RESULT_PREVIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_RESULT_PREVIEWER)) |
399 | -#define TEST_RESULT_PREVIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_RESULT_PREVIEWER, TestResultPreviewerClass)) |
400 | - |
401 | -typedef struct _TestResultPreviewer TestResultPreviewer; |
402 | -typedef struct _TestResultPreviewerClass TestResultPreviewerClass; |
403 | - |
404 | -struct _TestResultPreviewer { |
405 | - UnityResultPreviewer parent_instance; |
406 | -}; |
407 | - |
408 | -struct _TestResultPreviewerClass { |
409 | - UnityResultPreviewerClass parent_class; |
410 | -}; |
411 | - |
412 | -G_DEFINE_TYPE(TestResultPreviewer, test_result_previewer, UNITY_TYPE_RESULT_PREVIEWER); |
413 | - |
414 | -static UnityAbstractPreview* test_result_previewer_run(UnityResultPreviewer* self) |
415 | +static UnityAbstractPreview* test_scope_preview(UnityResultPreviewer* self, gpointer user_data) |
416 | { |
417 | UnityAbstractPreview* preview; |
418 | UnityPreviewAction* action; |
419 | @@ -222,172 +34,17 @@ |
420 | unity_preview_add_action(UNITY_PREVIEW (preview), action); |
421 | |
422 | action = unity_preview_action_new ("action2", "Action 2", NULL); |
423 | - // GHashTable* hints = unity_preview_action_get_hints(action); |
424 | - |
425 | unity_preview_add_action(UNITY_PREVIEW (preview), action); |
426 | |
427 | return preview; |
428 | } |
429 | |
430 | -static void test_result_previewer_class_init(TestResultPreviewerClass* klass) |
431 | -{ |
432 | - UNITY_RESULT_PREVIEWER_CLASS (klass)->run = test_result_previewer_run; |
433 | -} |
434 | - |
435 | -static void test_result_previewer_init(TestResultPreviewer* self) |
436 | -{ |
437 | -} |
438 | - |
439 | -TestResultPreviewer* test_result_previewer_new () |
440 | -{ |
441 | - return (TestResultPreviewer*) g_object_new (TEST_TYPE_RESULT_PREVIEWER, NULL); |
442 | -} |
443 | - |
444 | -/* ------------------ Test Scope ---------------------- */ |
445 | - |
446 | -#define TEST_SCOPE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_TYPE_SCOPE, TestScopePrivate)) |
447 | - |
448 | -G_DEFINE_TYPE(TestScope, test_scope, UNITY_TYPE_ABSTRACT_SCOPE); |
449 | - |
450 | -struct _TestScopePrivate |
451 | -{ |
452 | - gchar* _dbus_path; |
453 | - UnityScopeDBusConnector* _connector; |
454 | - UnityCategorySet* _categories; |
455 | - UnityFilterSet* _filters; |
456 | -}; |
457 | - |
458 | -enum { |
459 | - TEST_SCOPE_DUMMY_PROPERTY, |
460 | - TEST_SCOPE_DBUS_PATH |
461 | -}; |
462 | - |
463 | -static UnityScopeSearchBase* test_scope_create_search_for_query(UnityAbstractScope* self, UnitySearchContext* search_context); |
464 | -static UnityResultPreviewer* test_scope_create_previewer(UnityAbstractScope* self, UnityScopeResult* _result_, UnitySearchMetadata* metadata); |
465 | -static UnityCategorySet* test_scope_get_categories(UnityAbstractScope* self); |
466 | -static UnityFilterSet* test_scope_get_filters(UnityAbstractScope* self); |
467 | -static UnitySchema* test_scope_get_schema(UnityAbstractScope* self); |
468 | -static gchar* test_scope_get_search_hint(UnityAbstractScope* self); |
469 | -static gchar* test_scope_get_group_name(UnityAbstractScope* self); |
470 | -static gchar* test_scope_get_unique_name(UnityAbstractScope* self); |
471 | -static UnityActivationResponse* test_scope_activate(UnityAbstractScope* self, UnityScopeResult* _result_, UnitySearchMetadata* metadata, const gchar* action_id); |
472 | -static void test_scope_set_dbus_path (TestScope* self, const gchar* value); |
473 | -static const gchar* test_scope_get_dbus_path (TestScope* self); |
474 | - |
475 | -static void test_scope_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); |
476 | -static void test_scope_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); |
477 | -static void g_cclosure_user_marshal_OBJECT__STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data); |
478 | - |
479 | -static void test_scope_class_init(TestScopeClass* klass) |
480 | -{ |
481 | - g_type_class_add_private (klass, sizeof (TestScopePrivate)); |
482 | - |
483 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->create_search_for_query = test_scope_create_search_for_query; |
484 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->create_previewer = test_scope_create_previewer; |
485 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_categories = test_scope_get_categories; |
486 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_filters = test_scope_get_filters; |
487 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_schema = test_scope_get_schema; |
488 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_search_hint = test_scope_get_search_hint; |
489 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_group_name = test_scope_get_group_name; |
490 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_unique_name = test_scope_get_unique_name; |
491 | - UNITY_ABSTRACT_SCOPE_CLASS (klass)->activate = test_scope_activate; |
492 | - G_OBJECT_CLASS (klass)->get_property = test_scope_get_property; |
493 | - G_OBJECT_CLASS (klass)->set_property = test_scope_set_property; |
494 | - |
495 | - g_object_class_install_property (G_OBJECT_CLASS (klass), TEST_SCOPE_DBUS_PATH, g_param_spec_string ("dbus-path", "dbus-path", "dbus-path", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); |
496 | - g_signal_new ("search", TEST_TYPE_SCOPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, UNITY_TYPE_SCOPE_SEARCH_BASE); |
497 | - g_signal_new ("activate_uri", TEST_TYPE_SCOPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_OBJECT__STRING, UNITY_TYPE_ACTIVATION_RESPONSE, 1, G_TYPE_STRING); |
498 | -} |
499 | - |
500 | -static void test_scope_init(TestScope* self) |
501 | -{ |
502 | - self->priv = TEST_SCOPE_GET_PRIVATE (self); |
503 | - |
504 | - self->priv->_dbus_path = NULL; |
505 | - self->priv->_connector = NULL; |
506 | - self->priv->_categories = NULL; |
507 | - self->priv->_filters = NULL; |
508 | -} |
509 | - |
510 | -static void test_scope_finalize (GObject* obj) |
511 | -{ |
512 | - TestScope * self; |
513 | - self = G_TYPE_CHECK_INSTANCE_CAST (obj, TEST_TYPE_SCOPE, TestScope); |
514 | - _g_free_safe (self->priv->_dbus_path); |
515 | - _g_object_unref_safe (self->priv->_connector); |
516 | - _g_object_unref_safe (self->priv->_categories); |
517 | - G_OBJECT_CLASS (test_scope_parent_class)->finalize (obj); |
518 | -} |
519 | - |
520 | -static void test_scope_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) |
521 | -{ |
522 | - TestScope * self; |
523 | - self = G_TYPE_CHECK_INSTANCE_CAST (object, TEST_TYPE_SCOPE, TestScope); |
524 | - switch (property_id) |
525 | - { |
526 | - case TEST_SCOPE_DBUS_PATH: |
527 | - g_value_set_string (value, test_scope_get_dbus_path (self)); |
528 | - break; |
529 | - default: |
530 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
531 | - break; |
532 | - } |
533 | -} |
534 | - |
535 | -static void test_scope_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) |
536 | -{ |
537 | - TestScope * self; |
538 | - self = G_TYPE_CHECK_INSTANCE_CAST (object, TEST_TYPE_SCOPE, TestScope); |
539 | - switch (property_id) { |
540 | - case TEST_SCOPE_DBUS_PATH: |
541 | - test_scope_set_dbus_path (self, g_value_get_string (value)); |
542 | - break; |
543 | - default: |
544 | - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
545 | - break; |
546 | - } |
547 | -} |
548 | - |
549 | -static UnityScopeSearchBase* test_scope_create_search_for_query(UnityAbstractScope* base, UnitySearchContext* search_context) |
550 | -{ |
551 | - UnityScopeSearchBase* searcher; |
552 | - TestScope* scope; |
553 | - scope = (TestScope*) base; |
554 | - searcher = (UnityScopeSearchBase*) test_searcher_new (scope); |
555 | - |
556 | - UnitySearchContext ctx; |
557 | - ctx = *search_context; |
558 | - unity_scope_search_base_set_search_context (searcher, &ctx); |
559 | - return searcher; |
560 | -} |
561 | - |
562 | -static UnityResultPreviewer* test_scope_create_previewer(UnityAbstractScope* self, UnityScopeResult* result, UnitySearchMetadata* metadata) |
563 | -{ |
564 | - UnityResultPreviewer* previewer; |
565 | - previewer = UNITY_RESULT_PREVIEWER (test_result_previewer_new()); |
566 | - unity_scope_result_copy(result, &previewer->result); |
567 | - return previewer; |
568 | -} |
569 | - |
570 | -static UnityCategorySet* test_scope_get_categories(UnityAbstractScope* base) |
571 | -{ |
572 | - TestScope* self; |
573 | - self = G_TYPE_CHECK_INSTANCE_CAST (base, TEST_TYPE_SCOPE, TestScope); |
574 | - g_return_if_fail (self != NULL); |
575 | - |
576 | - return self->priv->_categories; |
577 | -} |
578 | - |
579 | -static UnityFilterSet* test_scope_get_filters(UnityAbstractScope* base) |
580 | -{ |
581 | - TestScope* self; |
582 | - self = G_TYPE_CHECK_INSTANCE_CAST (base, TEST_TYPE_SCOPE, TestScope); |
583 | - g_return_if_fail (self != NULL); |
584 | - |
585 | - return self->priv->_filters; |
586 | -} |
587 | - |
588 | -static UnitySchema* test_scope_get_schema(UnityAbstractScope* self) |
589 | +static UnityActivationResponse* test_scope_activate(UnityScopeResult* result, UnitySearchMetadata* metadata, const gchar* action_id, gpointer data) |
590 | +{ |
591 | + return unity_activation_response_new (UNITY_HANDLED_TYPE_HIDE_DASH, ""); |
592 | +} |
593 | + |
594 | +static UnitySchema* test_scope_get_schema(void) |
595 | { |
596 | UnitySchema* schema = unity_schema_new (); |
597 | unity_schema_add_field (schema, "required_string", "s", UNITY_SCHEMA_FIELD_TYPE_REQUIRED); |
598 | @@ -396,102 +53,26 @@ |
599 | return schema; |
600 | } |
601 | |
602 | -static gchar* test_scope_get_search_hint(UnityAbstractScope* self) |
603 | -{ |
604 | - return g_strdup ("Search hint"); |
605 | -} |
606 | - |
607 | -static gchar* test_scope_get_group_name(UnityAbstractScope* self) |
608 | -{ |
609 | - return g_strdup (TEST_DBUS_NAME); |
610 | -} |
611 | - |
612 | -static gchar* test_scope_get_unique_name(UnityAbstractScope* base) |
613 | -{ |
614 | - TestScope * self; |
615 | - self = (TestScope*) base; |
616 | - return g_strdup (self->priv->_dbus_path); |
617 | -} |
618 | - |
619 | -static UnityActivationResponse* test_scope_activate(UnityAbstractScope* self, UnityScopeResult* result, UnitySearchMetadata* metadata, const gchar* action_id) |
620 | -{ |
621 | - UnityActivationResponse* response = NULL; |
622 | - g_signal_emit_by_name (self, "activate-uri", result->uri, &response); |
623 | - return response; |
624 | -} |
625 | - |
626 | -static const gchar* test_scope_get_dbus_path (TestScope* self) |
627 | -{ |
628 | - g_return_val_if_fail (self != NULL, NULL); |
629 | - return self->priv->_dbus_path; |
630 | -} |
631 | - |
632 | -static void test_scope_set_dbus_path (TestScope* self, const gchar* value) |
633 | -{ |
634 | - g_return_if_fail (self != NULL); |
635 | - _g_free_safe (self->priv->_dbus_path); |
636 | - self->priv->_dbus_path = g_strdup (value);; |
637 | - g_object_notify ((GObject *) self, "dbus-path"); |
638 | -} |
639 | - |
640 | -static void g_cclosure_user_marshal_OBJECT__STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) |
641 | -{ |
642 | - typedef gpointer (*GMarshalFunc_OBJECT__STRING) (gpointer data1, const char* arg_1, gpointer data2); |
643 | - register GMarshalFunc_OBJECT__STRING callback; |
644 | - register GCClosure * cc; |
645 | - register gpointer data1; |
646 | - register gpointer data2; |
647 | - gpointer v_return; |
648 | - cc = (GCClosure *) closure; |
649 | - g_return_if_fail (return_value != NULL); |
650 | - g_return_if_fail (n_param_values == 2); |
651 | - if (G_CCLOSURE_SWAP_DATA (closure)) { |
652 | - data1 = closure->data; |
653 | - data2 = param_values->data[0].v_pointer; |
654 | - } else { |
655 | - data1 = param_values->data[0].v_pointer; |
656 | - data2 = closure->data; |
657 | - } |
658 | - callback = (GMarshalFunc_OBJECT__STRING) (marshal_data ? marshal_data : cc->callback); |
659 | - v_return = callback (data1, g_value_get_string (param_values + 1), data2); |
660 | - g_value_take_object (return_value, v_return); |
661 | -} |
662 | - |
663 | -TestScope* test_scope_new (const gchar* dbus_path) |
664 | -{ |
665 | - return (TestScope*) g_object_new (TEST_TYPE_SCOPE, "dbus-path", dbus_path, NULL); |
666 | -} |
667 | - |
668 | -void test_scope_set_categories(TestScope* self, UnityCategorySet* categories) |
669 | -{ |
670 | - g_return_if_fail (self != NULL); |
671 | - |
672 | - g_object_ref(categories); |
673 | - self->priv->_categories = categories; |
674 | -} |
675 | - |
676 | -void test_scope_set_filters(TestScope* self, UnityFilterSet* filters) |
677 | -{ |
678 | - g_return_if_fail (self != NULL); |
679 | - |
680 | - g_object_ref(filters); |
681 | - self->priv->_filters = filters; |
682 | -} |
683 | - |
684 | -void test_scope_export (TestScope* self, GError** error) |
685 | -{ |
686 | - UnityScopeDBusConnector* connector; |
687 | - g_return_if_fail (self != NULL); |
688 | - |
689 | - connector = unity_scope_dbus_connector_new ((UnityAbstractScope*) self); |
690 | - _g_object_unref_safe (self->priv->_connector); |
691 | - self->priv->_connector = connector; |
692 | - unity_scope_dbus_connector_export (connector, error); |
693 | -} |
694 | - |
695 | -void test_scope_unexport (TestScope* self) |
696 | -{ |
697 | - g_return_if_fail (self != NULL); |
698 | - g_return_if_fail (self->priv->_connector != NULL); |
699 | - unity_scope_dbus_connector_unexport (self->priv->_connector); |
700 | -} |
701 | \ No newline at end of file |
702 | +UnityAbstractScope* test_scope_new (const gchar* dbus_path, |
703 | + UnityCategorySet* category_set, |
704 | + UnityFilterSet* filter_set, |
705 | + UnitySimpleScopeSearchRunFunc search_func, |
706 | + gpointer data) |
707 | +{ |
708 | + UnitySimpleScope *scope = unity_simple_scope_new (); |
709 | + |
710 | + unity_simple_scope_set_unique_name (scope, dbus_path); |
711 | + unity_simple_scope_set_group_name (scope, TEST_DBUS_NAME); |
712 | + unity_simple_scope_set_search_hint (scope, "Search hint"); |
713 | + |
714 | + unity_simple_scope_set_category_set (scope, category_set); |
715 | + unity_simple_scope_set_filter_set (scope, filter_set); |
716 | + unity_simple_scope_set_schema (scope, test_scope_get_schema ()); |
717 | + |
718 | + unity_simple_scope_set_search_func (scope, search_func, data, NULL); |
719 | + unity_simple_scope_set_preview_func (scope, test_scope_preview, NULL, NULL); |
720 | + unity_simple_scope_set_activate_func (scope, test_scope_activate, NULL, NULL); |
721 | + |
722 | + return UNITY_ABSTRACT_SCOPE (scope); |
723 | +} |
724 | + |
725 | |
726 | === modified file 'tests/test_scope_impl.h' |
727 | --- tests/test_scope_impl.h 2013-03-13 10:31:19 +0000 |
728 | +++ tests/test_scope_impl.h 2013-07-19 11:30:33 +0000 |
729 | @@ -25,42 +25,12 @@ |
730 | |
731 | G_BEGIN_DECLS |
732 | |
733 | -#define TEST_TYPE_SCOPE (test_scope_get_type ()) |
734 | -#define TEST_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_SCOPE, TestScope)) |
735 | -#define TEST_IS_SCOPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_SCOPE)) |
736 | -#define TEST_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_SCOPE, TestScopeClass)) |
737 | -#define TEST_IS_SCOPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_SCOPE)) |
738 | -#define TEST_SCOPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SCOPE, TestScopeClass)) |
739 | - |
740 | -typedef struct _TestScope TestScope; |
741 | -typedef struct _TestScopeClass TestScopeClass; |
742 | -typedef struct _TestScopePrivate TestScopePrivate; |
743 | - |
744 | -struct _TestScope |
745 | -{ |
746 | - UnityAbstractScope parent_instance; |
747 | - |
748 | - /* instance members */ |
749 | - TestScopePrivate * priv; |
750 | -}; |
751 | - |
752 | -struct _TestScopeClass |
753 | -{ |
754 | - UnityAbstractScopeClass parent_class; |
755 | - |
756 | - /* class members */ |
757 | -}; |
758 | - |
759 | -/* used by TEST_TYPE_SCOPE */ |
760 | -GType test_scope_get_type (void); |
761 | - |
762 | -TestScope* test_scope_new (const gchar* dbus_path); |
763 | - |
764 | -void test_scope_set_categories(TestScope* self, UnityCategorySet* categories); |
765 | -void test_scope_set_filters(TestScope* self, UnityFilterSet* filters); |
766 | -void test_scope_export (TestScope* self, GError** error); |
767 | -void test_scope_unexport (TestScope* self); |
768 | +UnityAbstractScope* test_scope_new (const gchar* dbus_path, |
769 | + UnityCategorySet* category_set, |
770 | + UnityFilterSet* filter_set, |
771 | + UnitySimpleScopeSearchRunFunc search_func, |
772 | + gpointer user_data); |
773 | |
774 | G_END_DECLS |
775 | |
776 | -#endif /* _TEST_SCOPE_IMPL_H_ */ |
777 | \ No newline at end of file |
778 | +#endif /* _TEST_SCOPE_IMPL_H_ */ |
779 | |
780 | === modified file 'tests/test_scope_proxy.cpp' |
781 | --- tests/test_scope_proxy.cpp 2013-07-09 18:56:00 +0000 |
782 | +++ tests/test_scope_proxy.cpp 2013-07-19 11:30:33 +0000 |
783 | @@ -59,7 +59,7 @@ |
784 | |
785 | TEST(TestScopeProxy, ConnectionFail) |
786 | { |
787 | - ScopeProxyInterface::Ptr scope_proxy(new ScopeProxy(ScopeData::Ptr(new MockScopeData("fail", "this.is.a.fail.test", "this/is/a/fail/test")))); |
788 | + ScopeProxyInterface::Ptr scope_proxy(new ScopeProxy(ScopeData::Ptr(new MockScopeData("fail", "this.is.a.fail.test", "/this/is/a/fail/test")))); |
789 | scope_proxy->ConnectProxy(); |
790 | |
791 | Utils::WaitForTimeoutMSec(1000); |
792 | @@ -180,7 +180,7 @@ |
793 | |
794 | TEST(TestScopeProxy, SearchFail) |
795 | { |
796 | - ScopeProxyInterface::Ptr scope_proxy(new ScopeProxy(ScopeData::Ptr(new MockScopeData("fail", "this.is.a.fail.test", "this/is/a/fail/test")))); |
797 | + ScopeProxyInterface::Ptr scope_proxy(new ScopeProxy(ScopeData::Ptr(new MockScopeData("fail", "this.is.a.fail.test", "/this/is/a/fail/test")))); |
798 | // Auto-connect on search |
799 | |
800 | bool search_ok = false; |
801 | @@ -262,7 +262,7 @@ |
802 | activate_callback, |
803 | nullptr); |
804 | |
805 | - Utils::WaitUntilMSec(activated_return, 3, "Failed to activate"); |
806 | + Utils::WaitUntil(activated_return, 3, "Failed to activate"); |
807 | } |
808 | |
809 | TEST(TestScopeProxy, Preview) |
810 | |
811 | === modified file 'tests/test_service_main.cpp' |
812 | --- tests/test_service_main.cpp 2013-07-17 18:03:19 +0000 |
813 | +++ tests/test_service_main.cpp 2013-07-19 11:30:33 +0000 |
814 | @@ -1,5 +1,6 @@ |
815 | #include <Nux/Nux.h> |
816 | #include <NuxCore/Logger.h> |
817 | +#include <unity.h> |
818 | |
819 | #include "test_service_scope.h" |
820 | #include "test_service_model.h" |
821 | @@ -44,8 +45,6 @@ |
822 | return 1; |
823 | } |
824 | |
825 | - auto loop = g_main_loop_new(NULL, FALSE); |
826 | - |
827 | nux::NuxInitialize(0); |
828 | // Slightly higher as we're more likely to test things we know will fail |
829 | nux::logging::configure_logging("<root>=error"); |
830 | @@ -53,24 +52,29 @@ |
831 | // but you can still change it if you're debugging ;) |
832 | nux::logging::configure_logging(::getenv("UNITY_TEST_LOG_SEVERITY")); |
833 | |
834 | + service::Hud hud; |
835 | + service::GDBus gdbus; |
836 | + service::Panel panel; |
837 | + service::Model model; |
838 | + service::Scope scope(scope_id ? scope_id: "testscope1"); |
839 | + |
840 | + // all the services might have requested dbus names, let's consider |
841 | + // the controller name a "primary" name and we'll wait for it before running |
842 | + // the actual dbus tests (since the other names were requested before this |
843 | + // one they should be acquired before this one) |
844 | glib::DBusServer controller("com.canonical.Unity.Test"); |
845 | controller.AddObjects(introspection_xml, "/com/canonical/unity/test/controller"); |
846 | auto obj = controller.GetObjects().front(); |
847 | - obj->SetMethodsCallsHandler([loop] (std::string const& method, GVariant*) { |
848 | + obj->SetMethodsCallsHandler([] (std::string const& method, GVariant*) { |
849 | if (method == "Exit") |
850 | - g_main_loop_quit(loop); |
851 | + unity_scope_dbus_connector_quit(); |
852 | |
853 | return static_cast<GVariant*>(nullptr); |
854 | }); |
855 | |
856 | - service::Hud hud; |
857 | - service::GDBus gdbus; |
858 | - service::Panel panel; |
859 | - service::Model model; |
860 | - service::Scope scope(scope_id ? scope_id: "testscope1"); |
861 | - |
862 | - g_main_loop_run(loop); |
863 | - g_main_loop_unref(loop); |
864 | + // scope equivalent of running the main loop, needed as this also requests |
865 | + // a dbus name the scope uses |
866 | + unity_scope_dbus_connector_run(); |
867 | |
868 | if (scope_id) g_free(scope_id); |
869 | |
870 | |
871 | === modified file 'tests/test_service_model.cpp' |
872 | --- tests/test_service_model.cpp 2013-07-10 18:22:32 +0000 |
873 | +++ tests/test_service_model.cpp 2013-07-19 11:30:33 +0000 |
874 | @@ -8,12 +8,26 @@ |
875 | namespace service |
876 | { |
877 | |
878 | +static DeeModel* create_read_only_model(const char* name) |
879 | +{ |
880 | + // A shared model with the LEADER_WRITABLE flag will ignore any change |
881 | + // requests from the peers |
882 | + glib::Object<DeePeer> peer(dee_peer_new(name)); |
883 | + glib::Object<DeeModel> backend(dee_sequence_model_new()); |
884 | + auto access_mode = DEE_SHARED_MODEL_ACCESS_MODE_LEADER_WRITABLE; |
885 | + return DEE_MODEL (g_object_new (DEE_TYPE_SHARED_MODEL, |
886 | + "peer", peer.RawPtr(), |
887 | + "back-end", backend.RawPtr(), |
888 | + "access-mode", access_mode, |
889 | + NULL)); |
890 | +} |
891 | + |
892 | Model::Model() |
893 | - : model_(dee_shared_model_new("com.canonical.test.model")) |
894 | - , results_model_(dee_shared_model_new("com.canonical.test.resultsmodel")) |
895 | - , categories_model_(dee_shared_model_new("com.canonical.test.categoriesmodel")) |
896 | - , categories_changing_model_(dee_shared_model_new("com.canonical.test.categoriesmodel_changing")) |
897 | - , tracks_model_(dee_shared_model_new("com.canonical.test.tracks")) |
898 | + : model_(create_read_only_model("com.canonical.test.model")) |
899 | + , results_model_(create_read_only_model("com.canonical.test.resultsmodel")) |
900 | + , categories_model_(create_read_only_model("com.canonical.test.categoriesmodel")) |
901 | + , categories_changing_model_(create_read_only_model("com.canonical.test.categoriesmodel_changing")) |
902 | + , tracks_model_(create_read_only_model("com.canonical.test.tracks")) |
903 | { |
904 | PopulateTestModel(); |
905 | PopulateResultsModel(); |
906 | |
907 | === modified file 'tests/test_service_scope.cpp' |
908 | --- tests/test_service_scope.cpp 2013-03-13 10:31:19 +0000 |
909 | +++ tests/test_service_scope.cpp 2013-07-19 11:30:33 +0000 |
910 | @@ -43,21 +43,20 @@ |
911 | "cat1", |
912 | "cat2" }; |
913 | |
914 | -static UnityActivationResponse* on_activate_uri(TestScope* scope, const char* uri, Scope* self); |
915 | -static void on_scope_search (TestScope* scope, UnityScopeSearchBase* search_ctx, Scope* self); |
916 | +static void on_scope_search (UnityScopeSearchBase* search_ctx, gpointer user_data); |
917 | |
918 | Scope::Scope(std::string const& scope_id) |
919 | -: scope_(test_scope_new (("/com/canonical/unity/scope/"+scope_id).c_str())) |
920 | { |
921 | - AddCategories(); |
922 | - AddFilters(); |
923 | - |
924 | - g_signal_connect(scope_, "activate-uri", G_CALLBACK(on_activate_uri), this); |
925 | - g_signal_connect(scope_, "search", G_CALLBACK(on_scope_search), this); |
926 | + scope_ = test_scope_new (("/com/canonical/unity/scope/"+scope_id).c_str(), |
927 | + CreateCategories(), |
928 | + CreateFilters(), |
929 | + on_scope_search, |
930 | + NULL); |
931 | |
932 | /* Export */ |
933 | GError* error = NULL; |
934 | - test_scope_export(scope_, &error); |
935 | + connector_ = unity_scope_dbus_connector_new (scope_); |
936 | + unity_scope_dbus_connector_export (connector_, &error); |
937 | if (error) |
938 | { |
939 | g_error ("Unable to export Scope: %s", error->message); |
940 | @@ -70,7 +69,7 @@ |
941 | g_signal_handlers_disconnect_by_data(scope_, this); |
942 | } |
943 | |
944 | -void Scope::AddCategories() |
945 | +UnityCategorySet* Scope::CreateCategories() |
946 | { |
947 | UnityCategorySet* categories; |
948 | GIcon *icon; |
949 | @@ -96,11 +95,10 @@ |
950 | g_free(title); |
951 | } |
952 | |
953 | - test_scope_set_categories(scope_, categories); |
954 | - g_object_unref (categories); |
955 | + return categories; |
956 | } |
957 | |
958 | -void Scope::AddFilters() |
959 | +UnityFilterSet* Scope::CreateFilters() |
960 | { |
961 | UnityFilterSet *filters = NULL; |
962 | UnityFilter *filter; |
963 | @@ -159,20 +157,14 @@ |
964 | unity_filter_set_add (filters, filter); |
965 | g_object_unref(filter); |
966 | |
967 | - test_scope_set_filters(scope_, filters); |
968 | - g_object_unref (filters); |
969 | -} |
970 | - |
971 | -static UnityActivationResponse* on_activate_uri(TestScope* scope, const char* uri, Scope* self) |
972 | -{ |
973 | - return unity_activation_response_new(UNITY_HANDLED_TYPE_HIDE_DASH, ""); |
974 | + return filters; |
975 | } |
976 | |
977 | static void _g_variant_unref0_ (gpointer var) { |
978 | if (var) g_variant_unref ((GVariant*)var); |
979 | } |
980 | |
981 | -static void on_scope_search (TestScope* scope, UnityScopeSearchBase* search_base, Scope* self) |
982 | +static void on_scope_search (UnityScopeSearchBase* search_base, gpointer self) |
983 | { |
984 | UnitySearchContext* search_ctx; |
985 | search_ctx = search_base->search_context; |
986 | |
987 | === modified file 'tests/test_service_scope.h' |
988 | --- tests/test_service_scope.h 2013-03-13 10:31:19 +0000 |
989 | +++ tests/test_service_scope.h 2013-07-19 11:30:33 +0000 |
990 | @@ -35,11 +35,12 @@ |
991 | ~Scope(); |
992 | |
993 | private: |
994 | - void AddCategories(); |
995 | - void AddFilters(); |
996 | + UnityCategorySet* CreateCategories(); |
997 | + UnityFilterSet* CreateFilters(); |
998 | |
999 | private: |
1000 | - glib::Object<TestScope> scope_; |
1001 | + glib::Object<UnityAbstractScope> scope_; |
1002 | + glib::Object<UnityScopeDBusConnector> connector_; |
1003 | }; |
1004 | |
1005 | } |
could you also re-enable te tests from tests/CMake so that the CI will check them as well? :)