Merge lp:~mhr3/libunity/scope-result-in-python into lp:libunity
- scope-result-in-python
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 281 |
Merged at revision: | 276 |
Proposed branch: | lp:~mhr3/libunity/scope-result-in-python |
Merge into: | lp:libunity |
Diff against target: |
318 lines (+163/-41) 11 files modified
bindings/python/Unity.py (+50/-37) configure.ac (+1/-1) debian/changelog (+6/-0) debian/libunity9.symbols (+1/-0) extras/Makefile.am (+2/-2) src/Makefile.am (+1/-0) src/unity-scope-interface.vala (+31/-0) test/python/Makefile.am (+1/-1) test/python/container-ownership.py (+12/-0) test/python/scope-result.py (+28/-0) test/vala/test-scope-base.vala (+30/-0) |
To merge this branch: | bzr merge lp:~mhr3/libunity/scope-result-in-python |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Paweł Stołowski (community) | Approve | ||
Review via email: mp+180158@code.launchpad.net |
Commit message
Implement new ScopeResult.
Description of the change
Add a few regression tests and implement new ScopeResult.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:280
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Paweł Stołowski (stolowski) wrote : | # |
193 + // careful here, using dark corners of vala compiler to not copy everything
194 + ScopeResult real_result = ScopeResult ();
195 + unowned ScopeResult result = real_result;
...
205 + return result;
This looks suspicious... since real_result is freed on return, are you sure we're actually returning reference of a valid object? I've never been to dark corners of valac ;)
Michal Hruby (mhr3) wrote : | # |
> 193 + // careful here, using dark corners of vala compiler to not copy
> everything
> 194 + ScopeResult real_result = ScopeResult ();
> 195 + unowned ScopeResult result = real_result;
> ...
> 205 + return result;
>
> This looks suspicious... since real_result is freed on return, are you sure
> we're actually returning reference of a valid object? I've never been to dark
> corners of valac ;)
Yes, the result is copied before returning (as with any other variable when you assign unowned var to owned one). The comment refers to the real_result vs result, if the variant.get() call used "out real_result.xyz", vala generates some crazy scary code with ~10 copies of the ScopeResult.
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://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:280
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 281. By Michal Hruby
-
Don't require overrides when running python tests
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:281
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'bindings/python/Unity.py' | |||
2 | --- bindings/python/Unity.py 2013-04-17 10:41:45 +0000 | |||
3 | +++ bindings/python/Unity.py 2013-08-15 07:56:46 +0000 | |||
4 | @@ -50,49 +50,62 @@ | |||
5 | 50 | if len(args) > 0: | 50 | if len(args) > 0: |
6 | 51 | Unity.ResultSet.add_result(self, *args) | 51 | Unity.ResultSet.add_result(self, *args) |
7 | 52 | elif len(kwargs) > 0: | 52 | elif len(kwargs) > 0: |
45 | 53 | uri = None | 53 | result = kwargs_to_result_variant(**kwargs) |
9 | 54 | icon = None | ||
10 | 55 | category = 0 | ||
11 | 56 | result_type = 0 | ||
12 | 57 | mimetype = None | ||
13 | 58 | title = None | ||
14 | 59 | comment = None | ||
15 | 60 | dnd_uri = None | ||
16 | 61 | metadata = {} | ||
17 | 62 | |||
18 | 63 | for col_name, value in kwargs.items(): | ||
19 | 64 | if col_name == "uri": uri = value | ||
20 | 65 | elif col_name == "icon": icon = value | ||
21 | 66 | elif col_name == "category": category = value | ||
22 | 67 | elif col_name == "result_type": result_type = value | ||
23 | 68 | elif col_name == "mimetype": mimetype = value | ||
24 | 69 | elif col_name == "title": title = value | ||
25 | 70 | elif col_name == "comment": comment = value | ||
26 | 71 | elif col_name == "dnd_uri": dnd_uri = value | ||
27 | 72 | else: | ||
28 | 73 | if isinstance(value, GLib.Variant): | ||
29 | 74 | metadata[col_name] = value | ||
30 | 75 | elif isinstance(value, str): | ||
31 | 76 | metadata[col_name] = GLib.Variant("s", value) | ||
32 | 77 | elif isinstance(value, int): | ||
33 | 78 | metadata[col_name] = GLib.Variant("i", value) | ||
34 | 79 | elif sys.version_info < (3, 0, 0): | ||
35 | 80 | # unicode is not defined in py3 | ||
36 | 81 | if isinstance(value, unicode): | ||
37 | 82 | metadata[col_name] = GLib.Variant("s", value) | ||
38 | 83 | |||
39 | 84 | |||
40 | 85 | result = GLib.Variant("(ssuussssa{sv})", (uri, icon, category, | ||
41 | 86 | result_type, mimetype, | ||
42 | 87 | title, comment, dnd_uri, | ||
43 | 88 | metadata)) | ||
44 | 89 | |||
46 | 90 | Unity.ResultSet.add_result_from_variant(self, result) | 54 | Unity.ResultSet.add_result_from_variant(self, result) |
47 | 91 | 55 | ||
48 | 92 | 56 | ||
49 | 57 | def kwargs_to_result_variant(**kwargs): | ||
50 | 58 | uri = None | ||
51 | 59 | icon = "" | ||
52 | 60 | category = 0 | ||
53 | 61 | result_type = 0 | ||
54 | 62 | mimetype = None | ||
55 | 63 | title = None | ||
56 | 64 | comment = "" | ||
57 | 65 | dnd_uri = None | ||
58 | 66 | metadata = {} | ||
59 | 67 | |||
60 | 68 | for col_name, value in kwargs.items(): | ||
61 | 69 | if col_name == "uri": uri = value | ||
62 | 70 | elif col_name == "icon": icon = value | ||
63 | 71 | elif col_name == "category": category = value | ||
64 | 72 | elif col_name == "result_type": result_type = value | ||
65 | 73 | elif col_name == "mimetype": mimetype = value | ||
66 | 74 | elif col_name == "title": title = value | ||
67 | 75 | elif col_name == "comment": comment = value | ||
68 | 76 | elif col_name == "dnd_uri": dnd_uri = value | ||
69 | 77 | else: | ||
70 | 78 | if isinstance(value, GLib.Variant): | ||
71 | 79 | metadata[col_name] = value | ||
72 | 80 | elif isinstance(value, str): | ||
73 | 81 | metadata[col_name] = GLib.Variant("s", value) | ||
74 | 82 | elif isinstance(value, int): | ||
75 | 83 | metadata[col_name] = GLib.Variant("i", value) | ||
76 | 84 | elif sys.version_info < (3, 0, 0): | ||
77 | 85 | # unicode is not defined in py3 | ||
78 | 86 | if isinstance(value, unicode): | ||
79 | 87 | metadata[col_name] = GLib.Variant("s", value) | ||
80 | 88 | |||
81 | 89 | |||
82 | 90 | result = GLib.Variant("(ssuussssa{sv})", (uri, icon, category, | ||
83 | 91 | result_type, mimetype, | ||
84 | 92 | title, comment, dnd_uri, | ||
85 | 93 | metadata)) | ||
86 | 94 | return result | ||
87 | 95 | |||
88 | 96 | |||
89 | 97 | def scope_result_create(*args, **kwargs): | ||
90 | 98 | if len(kwargs) > 0: | ||
91 | 99 | result = kwargs_to_result_variant(**kwargs) | ||
92 | 100 | return Unity.ScopeResult.create_from_variant(result) | ||
93 | 101 | return original_scope_result_create(*args) | ||
94 | 102 | |||
95 | 103 | |||
96 | 93 | ScopeSearchBase = override(ScopeSearchBase) | 104 | ScopeSearchBase = override(ScopeSearchBase) |
97 | 94 | __all__.append('ScopeSearchBase') | 105 | __all__.append('ScopeSearchBase') |
98 | 95 | ResultPreviewer = override(ResultPreviewer) | 106 | ResultPreviewer = override(ResultPreviewer) |
99 | 96 | __all__.append('ResultPreviewer') | 107 | __all__.append('ResultPreviewer') |
100 | 97 | ResultSet = override(ResultSet) | 108 | ResultSet = override(ResultSet) |
101 | 98 | __all__.append('ResultSet') | 109 | __all__.append('ResultSet') |
102 | 110 | original_scope_result_create = Unity.ScopeResult.create | ||
103 | 111 | Unity.ScopeResult.create = scope_result_create | ||
104 | 99 | 112 | ||
105 | === modified file 'configure.ac' | |||
106 | --- configure.ac 2013-08-01 10:22:39 +0000 | |||
107 | +++ configure.ac 2013-08-15 07:56:46 +0000 | |||
108 | @@ -1,5 +1,5 @@ | |||
109 | 1 | # When releasing also remember to update the soname as instructed below | 1 | # When releasing also remember to update the soname as instructed below |
111 | 2 | AC_INIT(libunity, 7.0.10) | 2 | AC_INIT(libunity, 7.0.11) |
112 | 3 | 3 | ||
113 | 4 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) | 4 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) |
114 | 5 | AM_CONFIG_HEADER(config.h) | 5 | AM_CONFIG_HEADER(config.h) |
115 | 6 | 6 | ||
116 | === modified file 'debian/changelog' | |||
117 | --- debian/changelog 2013-08-09 11:50:54 +0000 | |||
118 | +++ debian/changelog 2013-08-15 07:56:46 +0000 | |||
119 | @@ -1,3 +1,9 @@ | |||
120 | 1 | libunity (7.0.11-0ubuntu1) UNRELEASED; urgency=low | ||
121 | 2 | |||
122 | 3 | * Added new ScopeResult.create_from_variant | ||
123 | 4 | |||
124 | 5 | -- Michal Hruby <michal.hruby@canonical.com> Wed, 14 Aug 2013 17:04:10 +0200 | ||
125 | 6 | |||
126 | 1 | libunity (7.0.10+13.10.20130809.1-0ubuntu1) saucy; urgency=low | 7 | libunity (7.0.10+13.10.20130809.1-0ubuntu1) saucy; urgency=low |
127 | 2 | 8 | ||
128 | 3 | [ Michal Hruby ] | 9 | [ Michal Hruby ] |
129 | 4 | 10 | ||
130 | === modified file 'debian/libunity9.symbols' | |||
131 | --- debian/libunity9.symbols 2013-08-06 07:39:12 +0000 | |||
132 | +++ debian/libunity9.symbols 2013-08-15 07:56:46 +0000 | |||
133 | @@ -596,6 +596,7 @@ | |||
134 | 596 | unity_scope_loader_new@Base 7.0.7+13.10.20130703 | 596 | unity_scope_loader_new@Base 7.0.7+13.10.20130703 |
135 | 597 | unity_scope_result_copy@Base 7.0.0daily13.05.31ubuntu.unity.next | 597 | unity_scope_result_copy@Base 7.0.0daily13.05.31ubuntu.unity.next |
136 | 598 | unity_scope_result_create@Base 7.0.0daily13.05.31ubuntu.unity.next | 598 | unity_scope_result_create@Base 7.0.0daily13.05.31ubuntu.unity.next |
137 | 599 | unity_scope_result_create_from_variant@Base 0replaceme | ||
138 | 599 | unity_scope_result_destroy@Base 7.0.0daily13.05.31ubuntu.unity.next | 600 | unity_scope_result_destroy@Base 7.0.0daily13.05.31ubuntu.unity.next |
139 | 600 | unity_scope_result_dup@Base 7.0.0daily13.05.31ubuntu.unity.next | 601 | unity_scope_result_dup@Base 7.0.0daily13.05.31ubuntu.unity.next |
140 | 601 | unity_scope_result_free@Base 7.0.0daily13.05.31ubuntu.unity.next | 602 | unity_scope_result_free@Base 7.0.0daily13.05.31ubuntu.unity.next |
141 | 602 | 603 | ||
142 | === modified file 'extras/Makefile.am' | |||
143 | --- extras/Makefile.am 2013-02-27 18:19:03 +0000 | |||
144 | +++ extras/Makefile.am 2013-08-15 07:56:46 +0000 | |||
145 | @@ -82,8 +82,8 @@ | |||
146 | 82 | 82 | ||
147 | 83 | libunity_extras_la_vala.stamp: $(libunity_extras_la_VALASOURCES) | 83 | libunity_extras_la_vala.stamp: $(libunity_extras_la_VALASOURCES) |
148 | 84 | $(AM_V_GEN) $(VALAC) $(libunity_extras_la_VALAFLAGS) $^ | 84 | $(AM_V_GEN) $(VALAC) $(libunity_extras_la_VALAFLAGS) $^ |
151 | 85 | @sed -i -e 's/<namespace name="UnityExtras" version="@GIR_VERSION@" c:prefix="Unity">/<namespace name="UnityExtras" version="@GIR_VERSION@" c:prefix="Unity" shared-library="libunity-extras.so.@LIBUNITY_LT_CURRENT@">/g' UnityExtras-@GIR_VERSION@.gir | 85 | @sed -i -e 's/<namespace name="UnityExtras" version="@GIR_VERSION@" c:prefix="Unity">/<namespace name="UnityExtras" version="@GIR_VERSION@" c:prefix="UnityExtras" shared-library="libunity-extras.so.@LIBUNITY_LT_CURRENT@">/g' UnityExtras-@GIR_VERSION@.gir |
152 | 86 | @sed -i -e 's/"Extras/"/;s/"extras_/"/' UnityExtras-@GIR_VERSION@.gir | 86 | @sed -i -e 's/"Extras/"/g;s/"extras_/"/' UnityExtras-@GIR_VERSION@.gir |
153 | 87 | @sed -i -e 's/<parameter name="scope_creation_cb" transfer-ownership="none"/<parameter name="scope_creation_cb" transfer-ownership="none" scope="call"/' UnityExtras-@GIR_VERSION@.gir | 87 | @sed -i -e 's/<parameter name="scope_creation_cb" transfer-ownership="none"/<parameter name="scope_creation_cb" transfer-ownership="none" scope="call"/' UnityExtras-@GIR_VERSION@.gir |
154 | 88 | @touch $@ | 88 | @touch $@ |
155 | 89 | 89 | ||
156 | 90 | 90 | ||
157 | === modified file 'src/Makefile.am' | |||
158 | --- src/Makefile.am 2013-07-23 15:56:18 +0000 | |||
159 | +++ src/Makefile.am 2013-08-15 07:56:46 +0000 | |||
160 | @@ -149,6 +149,7 @@ | |||
161 | 149 | @sed -i -e 's/<namespace name="Unity" version="@GIR_VERSION@" c:prefix="Unity">/<namespace name="Unity" version="@GIR_VERSION@" c:prefix="Unity" shared-library="libunity.so.@LIBUNITY_LT_CURRENT@">/g' Unity-@GIR_VERSION@.gir | 149 | @sed -i -e 's/<namespace name="Unity" version="@GIR_VERSION@" c:prefix="Unity">/<namespace name="Unity" version="@GIR_VERSION@" c:prefix="Unity" shared-library="libunity.so.@LIBUNITY_LT_CURRENT@">/g' Unity-@GIR_VERSION@.gir |
162 | 150 | @sed -i -e 's/emit_preview_ready/preview_ready/g' Unity-@GIR_VERSION@.gir | 150 | @sed -i -e 's/emit_preview_ready/preview_ready/g' Unity-@GIR_VERSION@.gir |
163 | 151 | @sed -i -e 's/<parameter name="async_callback" transfer-ownership="none" /<parameter name="async_callback" transfer-ownership="none" scope="async" /g' Unity-@GIR_VERSION@.gir | 151 | @sed -i -e 's/<parameter name="async_callback" transfer-ownership="none" /<parameter name="async_callback" transfer-ownership="none" scope="async" /g' Unity-@GIR_VERSION@.gir |
164 | 152 | @sed -i -e 's/<record name="ScopeResult">/<record name="ScopeResult" c:type="UnityScopeResult" glib:type-name="UnityScopeResult" glib:get-type="unity_scope_result_get_type">/;s/<record name="SearchContext">/<record name="SearchContext" c:type="UnitySearchContext" glib:type-name="UnitySearchContext" glib:get-type="unity_search_context_get_type">/' Unity-@GIR_VERSION@.gir | ||
165 | 152 | @touch $@ | 153 | @touch $@ |
166 | 153 | 154 | ||
167 | 154 | BUILT_SOURCES += libunity_la_vala.stamp | 155 | BUILT_SOURCES += libunity_la_vala.stamp |
168 | 155 | 156 | ||
169 | === modified file 'src/unity-scope-interface.vala' | |||
170 | --- src/unity-scope-interface.vala 2013-07-22 14:02:05 +0000 | |||
171 | +++ src/unity-scope-interface.vala 2013-08-15 07:56:46 +0000 | |||
172 | @@ -154,6 +154,37 @@ | |||
173 | 154 | 154 | ||
174 | 155 | return result; | 155 | return result; |
175 | 156 | } | 156 | } |
176 | 157 | |||
177 | 158 | /** | ||
178 | 159 | * Create a new ScopeResult from a tuple variant | ||
179 | 160 | * | ||
180 | 161 | * This method will create a new heap-allocated ScopeResult. | ||
181 | 162 | * It is primarily meant for low-level language bindings. | ||
182 | 163 | */ | ||
183 | 164 | public static ScopeResult? create_from_variant (Variant variant) | ||
184 | 165 | { | ||
185 | 166 | const string EXPECTED_SIG = "(ssuussssa{sv})"; | ||
186 | 167 | if (variant.get_type_string () != EXPECTED_SIG) | ||
187 | 168 | { | ||
188 | 169 | warning ("Incorrect variant signature, expected \"%s\", got \"%s\"", | ||
189 | 170 | EXPECTED_SIG, variant.get_type_string ()); | ||
190 | 171 | return null; | ||
191 | 172 | } | ||
192 | 173 | Variant dict; | ||
193 | 174 | // careful here, using dark corners of vala compiler to not copy everything | ||
194 | 175 | ScopeResult real_result = ScopeResult (); | ||
195 | 176 | unowned ScopeResult result = real_result; | ||
196 | 177 | |||
197 | 178 | variant.get ("(&s&suu&s&s&s&s@a{sv})", | ||
198 | 179 | out result.uri, out result.icon_hint, out result.category, | ||
199 | 180 | out result.result_type, out result.mimetype, out result.title, | ||
200 | 181 | out result.comment, out result.dnd_uri, out dict); | ||
201 | 182 | |||
202 | 183 | HashTable<string, Variant> metadata = (HashTable<string, Variant>) dict; | ||
203 | 184 | result.metadata = metadata; | ||
204 | 185 | |||
205 | 186 | return result; | ||
206 | 187 | } | ||
207 | 157 | } | 188 | } |
208 | 158 | 189 | ||
209 | 159 | public abstract class Cancellable: Object | 190 | public abstract class Cancellable: Object |
210 | 160 | 191 | ||
211 | === modified file 'test/python/Makefile.am' | |||
212 | --- test/python/Makefile.am 2012-10-26 14:42:43 +0000 | |||
213 | +++ test/python/Makefile.am 2013-08-15 07:56:46 +0000 | |||
214 | @@ -1,6 +1,6 @@ | |||
215 | 1 | include $(top_srcdir)/Makefile.decl | 1 | include $(top_srcdir)/Makefile.decl |
216 | 2 | 2 | ||
218 | 3 | TESTS = bug-1062331.py extras.py | 3 | TESTS = bug-1062331.py extras.py container-ownership.py scope-result.py |
219 | 4 | TEST_EXTENSIONS = .py | 4 | TEST_EXTENSIONS = .py |
220 | 5 | 5 | ||
221 | 6 | # gtester doesn't care about our TESTS_ENVIRONMENT, so can't use it | 6 | # gtester doesn't care about our TESTS_ENVIRONMENT, so can't use it |
222 | 7 | 7 | ||
223 | === added file 'test/python/container-ownership.py' | |||
224 | --- test/python/container-ownership.py 1970-01-01 00:00:00 +0000 | |||
225 | +++ test/python/container-ownership.py 2013-08-15 07:56:46 +0000 | |||
226 | @@ -0,0 +1,12 @@ | |||
227 | 1 | #!/usr/bin/python | ||
228 | 2 | from gi.repository import Unity, Gio | ||
229 | 3 | |||
230 | 4 | category_set = Unity.CategorySet.new() | ||
231 | 5 | cat = Unity.Category.new("example", "Example", Gio.ThemedIcon.new("test"), Unity.CategoryRenderer.DEFAULT) | ||
232 | 6 | category_set.add(cat) | ||
233 | 7 | cat = Unity.Category.new("another", "Another", Gio.ThemedIcon.new("test"), Unity.CategoryRenderer.GRID) | ||
234 | 8 | category_set.add(cat) | ||
235 | 9 | cat_list = category_set.get_categories() | ||
236 | 10 | #if the binding is broken there'll be double free | ||
237 | 11 | del cat_list | ||
238 | 12 | del category_set | ||
239 | 0 | 13 | ||
240 | === added file 'test/python/scope-result.py' | |||
241 | --- test/python/scope-result.py 1970-01-01 00:00:00 +0000 | |||
242 | +++ test/python/scope-result.py 2013-08-15 07:56:46 +0000 | |||
243 | @@ -0,0 +1,28 @@ | |||
244 | 1 | #!/usr/bin/python | ||
245 | 2 | from gi.repository import Unity, GLib | ||
246 | 3 | |||
247 | 4 | class TestResultSet(Unity.ResultSet): | ||
248 | 5 | def __init__(self): | ||
249 | 6 | Unity.ResultSet.__init__(self) | ||
250 | 7 | self.results = [] | ||
251 | 8 | |||
252 | 9 | def do_add_result(self, result): | ||
253 | 10 | assert(result.uri == "file:///foo") | ||
254 | 11 | assert(result.title == "Title") | ||
255 | 12 | assert(len(result.metadata) > 0) | ||
256 | 13 | assert("whatever" in result.metadata) | ||
257 | 14 | # bug in pygi? copy() shouldn't be needed | ||
258 | 15 | self.results.append(result.copy()) | ||
259 | 16 | |||
260 | 17 | rs = TestResultSet() | ||
261 | 18 | # overrides are not installed when running tests, so don't use add_result | ||
262 | 19 | variant = GLib.Variant('(ssuussssa{sv})', ("file:///foo", "file:///", 0, 0, | ||
263 | 20 | "text/plain", "Title", "", | ||
264 | 21 | "file:///foo", {'whatever': GLib.Variant("s", "foo")})) | ||
265 | 22 | rs.add_result_from_variant(variant) | ||
266 | 23 | |||
267 | 24 | saved_result = rs.results[0] | ||
268 | 25 | assert(saved_result.uri == "file:///foo") | ||
269 | 26 | assert(saved_result.title == "Title") | ||
270 | 27 | assert(len(saved_result.metadata) > 0) | ||
271 | 28 | assert("whatever" in saved_result.metadata) | ||
272 | 0 | 29 | ||
273 | === modified file 'test/vala/test-scope-base.vala' | |||
274 | --- test/vala/test-scope-base.vala 2013-07-23 13:23:06 +0000 | |||
275 | +++ test/vala/test-scope-base.vala 2013-08-15 07:56:46 +0000 | |||
276 | @@ -32,6 +32,8 @@ | |||
277 | 32 | Fixture.create<AbstractScopeTester> (AbstractScopeTester.test_add_variant_result)); | 32 | Fixture.create<AbstractScopeTester> (AbstractScopeTester.test_add_variant_result)); |
278 | 33 | GLib.Test.add_data_func ("/Unit/Cancellable/GetGCancellable", | 33 | GLib.Test.add_data_func ("/Unit/Cancellable/GetGCancellable", |
279 | 34 | Fixture.create<CancellableTester> (CancellableTester.test_get_gcancellable)); | 34 | Fixture.create<CancellableTester> (CancellableTester.test_get_gcancellable)); |
280 | 35 | GLib.Test.add_data_func ("/Unit/ScopeResult/CreateFromVariant", | ||
281 | 36 | Fixture.create<ScopeResultTester> (ScopeResultTester.test_create_from_variant)); | ||
282 | 35 | } | 37 | } |
283 | 36 | 38 | ||
284 | 37 | class AbstractScopeTester: Object, Fixture | 39 | class AbstractScopeTester: Object, Fixture |
285 | @@ -205,5 +207,33 @@ | |||
286 | 205 | assert (cancellable.get_gcancellable () is GLib.Cancellable); | 207 | assert (cancellable.get_gcancellable () is GLib.Cancellable); |
287 | 206 | } | 208 | } |
288 | 207 | } | 209 | } |
289 | 210 | |||
290 | 211 | class ScopeResultTester: Object, Fixture | ||
291 | 212 | { | ||
292 | 213 | public void test_create_from_variant () | ||
293 | 214 | { | ||
294 | 215 | var metadata_ht = new HashTable<string, Variant> (str_hash, str_equal); | ||
295 | 216 | metadata_ht["foo"] = new Variant.int32 (32); | ||
296 | 217 | metadata_ht["bar"] = new Variant.string ("qoo"); | ||
297 | 218 | Variant metadata = metadata_ht; | ||
298 | 219 | var variant = new Variant ("(ssuussss@a{sv})", | ||
299 | 220 | "test://", "unknown", | ||
300 | 221 | 0, Unity.ResultType.PERSONAL, | ||
301 | 222 | "text/html", "Test", "comment", | ||
302 | 223 | "test://", metadata); | ||
303 | 224 | |||
304 | 225 | var scope_result = Unity.ScopeResult.create_from_variant (variant); | ||
305 | 226 | assert (scope_result.uri == "test://"); | ||
306 | 227 | assert (scope_result.icon_hint == "unknown"); | ||
307 | 228 | assert (scope_result.category == 0); | ||
308 | 229 | assert (scope_result.result_type == Unity.ResultType.PERSONAL); | ||
309 | 230 | assert (scope_result.mimetype == "text/html"); | ||
310 | 231 | assert (scope_result.title == "Test"); | ||
311 | 232 | assert (scope_result.comment == "comment"); | ||
312 | 233 | assert (scope_result.dnd_uri == scope_result.uri); | ||
313 | 234 | assert (scope_result.metadata.size () == 2); | ||
314 | 235 | assert (scope_result.metadata["bar"].get_string () == "qoo"); | ||
315 | 236 | } | ||
316 | 237 | } | ||
317 | 208 | } | 238 | } |
318 | 209 | } | 239 | } |
FAILED: Continuous integration, rev:279 jenkins. qa.ubuntu. com/job/ libunity- ci/92/ jenkins. qa.ubuntu. com/job/ libunity- saucy-amd64- ci/77/console jenkins. qa.ubuntu. com/job/ libunity- saucy-armhf- ci/77/console jenkins. qa.ubuntu. com/job/ libunity- saucy-i386- ci/77/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ libunity- ci/92/rebuild
http://