Merge lp:~michihenning/unity-scopes-api/qt-coverage-2 into lp:unity-scopes-api
- qt-coverage-2
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~michihenning/unity-scopes-api/qt-coverage-2 |
Merge into: | lp:unity-scopes-api |
Prerequisite: | lp:~michihenning/unity-scopes-api/qt-coverage |
Diff against target: |
2121 lines (+393/-860) (has conflicts) 42 files modified
CTestCustom.cmake.in (+6/-0) HACKING (+36/-0) debian/libunity-scopes-qt.symbols (+0/-1) include/unity/scopes/ScopeBase.h (+4/-6) include/unity/scopes/qt/QActionMetadata.h (+0/-1) include/unity/scopes/qt/QPreviewQueryBase.h (+0/-1) include/unity/scopes/qt/QPreviewReply.h (+0/-1) include/unity/scopes/qt/QResult.h (+0/-1) include/unity/scopes/qt/QScopeBase.h (+12/-15) include/unity/scopes/qt/QScopeBaseAPI.h (+0/-5) include/unity/scopes/qt/QSearchMetadata.h (+0/-1) include/unity/scopes/qt/QSearchQueryBase.h (+0/-1) include/unity/scopes/qt/QSearchReply.h (+0/-1) include/unity/scopes/qt/internal/QActionMetadataImpl.h (+5/-71) include/unity/scopes/qt/internal/QCategorisedResultImpl.h (+1/-22) include/unity/scopes/qt/internal/QCategoryImpl.h (+0/-27) include/unity/scopes/qt/internal/QColumnLayoutImpl.h (+2/-45) include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h (+0/-13) include/unity/scopes/qt/internal/QPreviewReplyImpl.h (+3/-32) include/unity/scopes/qt/internal/QPreviewWidgetImpl.h (+1/-110) include/unity/scopes/qt/internal/QResultImpl.h (+0/-155) include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h (+4/-37) include/unity/scopes/qt/internal/QScopeBaseImpl.h (+1/-9) include/unity/scopes/qt/internal/QScopeVariant.h (+0/-4) include/unity/scopes/qt/internal/QSearchMetadataImpl.h (+2/-89) include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h (+0/-26) include/unity/scopes/qt/internal/QSearchReplyImpl.h (+1/-80) include/unity/scopes/qt/internal/QUtils.h (+0/-4) src/scopes/qt/QActionMetadata.cpp (+1/-1) src/scopes/qt/QPreviewWidget.cpp (+1/-1) src/scopes/qt/QResult.cpp (+1/-6) src/scopes/qt/internal/QResultImpl.cpp (+5/-46) src/scopes/qt/internal/QScopeBaseAPIImpl.cpp (+13/-22) test/gtest/scopes/qt/qt-bindings/CMakeLists.txt (+19/-0) test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp (+116/-0) test/gtest/scopes/qt/qt-bindings/QMockScope.h (+12/-6) test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp (+3/-3) test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp (+117/-0) test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp (+10/-10) test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h (+3/-3) test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp (+12/-2) test/headers/CMakeLists.txt (+2/-2) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~michihenning/unity-scopes-api/qt-coverage-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Unity Team | Pending | ||
Review via email: mp+250719@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-02-27.
Commit message
Improved documentation in HACKING.
Fixed incorrect path in CMakeLists.txt for the header tests.
Added suppressions for header compilation tests for valgrind for qt and utility namespaces.
Fixed leak in QPreviewQueryBa
Fixed leak in QScopeBaseAPIImpl.
Style fixes. Doc fixes.
Fixed race condition in mock scope.
Removed QScopeBaseAPIImpl constructor for tests and added tests to use the real constructor.
Added QPreviewWidget coverage.
Removed unnecessary friend declarations.
Fixed leak in QActionMetadata and QPreviewWidget constructors.
Stripped doc comments from internal headers.
Removed unnecessary QResult default constructor.
Added coverage for QResult and QResultImpl.
Fixed segfault in QResultImpl.
Fixed symbols file.
Description of the change
Improved documentation in HACKING.
Fixed incorrect path in CMakeLists.txt for the header tests.
Added suppressions for header compilation tests for valgrind for qt and utility namespaces.
Fixed leak in QPreviewQueryBa
Fixed leak in QScopeBaseAPIImpl.
Style fixes. Doc fixes.
Fixed race condition in mock scope.
Removed QScopeBaseAPIImpl constructor for tests and added tests to use the real constructor.
Added QPreviewWidget coverage.
Removed unnecessary friend declarations.
Fixed leak in QActionMetadata and QPreviewWidget constructors.
Stripped doc comments from internal headers.
Removed unnecessary QResult default constructor.
Added coverage for QResult and QResultImpl.
Fixed segfault in QResultImpl.
Fixed symbols file.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:338
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:338
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:338
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 339. By Michi Henning
-
Added coverage for result. Fixed segfault caused by incorrect QResultImpl constructor.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:339
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 340. By Michi Henning
-
Fixed whitespace.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:340
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:340
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
Preview Diff
1 | === modified file 'CTestCustom.cmake.in' |
2 | --- CTestCustom.cmake.in 2014-07-25 05:54:44 +0000 |
3 | +++ CTestCustom.cmake.in 2015-02-25 12:37:38 +0000 |
4 | @@ -12,8 +12,14 @@ |
5 | stand-alone-unity-scopes-headers |
6 | stand-alone-unity-scopes-internal-headers |
7 | stand-alone-unity-scopes-testing-headers |
8 | + stand-alone-unity-scopes-utility-headers |
9 | + stand-alone-unity-scopes-utility-internal-headers |
10 | + stand-alone-unity-scopes-qt-headers |
11 | + stand-alone-unity-scopes-qt-internal-headers |
12 | clean-public-unity-scopes-headers |
13 | clean-public-unity-scopes-testing-headers |
14 | + clean-public-unity-scopes-utility-headers |
15 | + clean-public-unity-scopes-qt-headers |
16 | IsolatedScopeBenchmark # Runs too slowly and crashes valgrind 3.10.0 with g++-4.9 |
17 | copyright |
18 | whitespace) |
19 | |
20 | === modified file 'HACKING' |
21 | --- HACKING 2015-01-27 09:38:24 +0000 |
22 | +++ HACKING 2015-02-25 12:37:38 +0000 |
23 | @@ -49,6 +49,31 @@ |
24 | |
25 | $ make valgrind |
26 | |
27 | +It doesn't make sense for some tests to run them with valgrind. For |
28 | +example, the header compilation tests don't need valgrind because |
29 | +we'd just be testing that Python doesn't leak. There are also some |
30 | +tests that run too slow and time out under valgrind and, occasionally, |
31 | +valgrind crashes for a particular test. |
32 | + |
33 | +There are two ways to suppress tests: |
34 | + |
35 | +You can add a test name to CTestCustom.cmake.in to suppress that |
36 | +test completely. That makes sense for the header compilation tests, |
37 | +for example. |
38 | + |
39 | +If a specific test case in a test program causes a valgrind problem, |
40 | +you can selectively disable a section of code like this: |
41 | + |
42 | + #include <valgrind/valgrind.h> |
43 | + |
44 | + if (!RUNNING_ON_VALGRIND) |
45 | + { |
46 | + // Code here crashes valgrind... |
47 | + } |
48 | + |
49 | +That way, the test will still be run as part of the normal "make test" |
50 | +target, but will be ommitted when running "make valgrind". |
51 | + |
52 | Coverage |
53 | -------- |
54 | |
55 | @@ -143,6 +168,17 @@ |
56 | |
57 | $ TSAN_OPTIONS="suppressions=../tsan-suppress" make test |
58 | |
59 | +If a test runs too slowly under address sanitizer, you can |
60 | +hide a section of code from address sanitzer with: |
61 | + |
62 | +#if defined(__has_feature) |
63 | + #if !__has_feature(address_sanitizer) |
64 | + |
65 | + // Code here takes forever under address sanitizer... |
66 | + |
67 | + #endif |
68 | +#endif |
69 | + |
70 | Updating symbols file |
71 | --------------------- |
72 | |
73 | |
74 | === modified file 'debian/libunity-scopes-qt.symbols' |
75 | --- debian/libunity-scopes-qt.symbols 2015-02-25 12:37:37 +0000 |
76 | +++ debian/libunity-scopes-qt.symbols 2015-02-25 12:37:38 +0000 |
77 | @@ -191,7 +191,6 @@ |
78 | (c++)"unity::scopes::qt::QResult::operator=(unity::scopes::qt::QResult&&)@Base" 0.6.13+15.04.20150205.1 |
79 | (c++)"unity::scopes::qt::QResult::operator=(unity::scopes::qt::QResult const&)@Base" 0.6.13+15.04.20150205.1 |
80 | (c++)"unity::scopes::qt::QResult::~QResult()@Base" 0.6.13+15.04.20150205.1 |
81 | - (c++)"unity::scopes::qt::QResult::QResult()@Base" 0.6.13+15.04.20150205.1 |
82 | (c++)"unity::scopes::qt::QResult::QResult(QMap<QString, QVariant> const&)@Base" 0.6.13+15.04.20150205.1 |
83 | (c++)"unity::scopes::qt::QResult::QResult(unity::scopes::qt::internal::QResultImpl*)@Base" 0.6.13+15.04.20150205.1 |
84 | (c++)"unity::scopes::qt::QResult::QResult(unity::scopes::qt::QResult&&)@Base" 0.6.13+15.04.20150205.1 |
85 | |
86 | === modified file 'include/unity/scopes/ScopeBase.h' |
87 | --- include/unity/scopes/ScopeBase.h 2015-01-26 08:10:59 +0000 |
88 | +++ include/unity/scopes/ScopeBase.h 2015-02-25 12:37:38 +0000 |
89 | @@ -104,8 +104,7 @@ |
90 | - a create function that must return a pointer to the derived instance |
91 | - a destroy function that is passed the pointer returned by the create function |
92 | |
93 | -Typically, the create and destroy functions will simply call `new` and `delete`, respectively. (However, |
94 | -there is no requirement that the derived class instance must be heap-allocated.) |
95 | +Typically, the create and destroy functions will simply call `new` and `delete`, respectively. |
96 | If the create function throws an exception, the destroy function will not be called. If the create function returns |
97 | NULL, the destroy function _will_ be called with NULL as its argument. |
98 | |
99 | @@ -116,13 +115,13 @@ |
100 | unity::scopes::ScopeBase* |
101 | UNITY_SCOPE_CREATE_FUNCTION() |
102 | { |
103 | - return new MyScope; // Example only, heap-allocation is not mandatory |
104 | + return new MyScope; |
105 | } |
106 | |
107 | void |
108 | UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope) |
109 | { |
110 | - delete scope; // Example only, heap-allocation is not mandatory |
111 | + delete scope; |
112 | } |
113 | ~~~ |
114 | |
115 | @@ -376,8 +375,7 @@ |
116 | /** |
117 | \brief The function called by the scopes run time to initialize the scope. |
118 | It must return a pointer to an instance derived from `ScopeBase`. The returned |
119 | -instance need not be heap-allocated, but must remain in scope until the |
120 | -destroy function is called by the scopes run time. |
121 | +instance must remain in scope until the destroy function is called by the scopes run time. |
122 | |
123 | If this function throws an exception, the destroy function will _not_ be called. If this function returns NULL, |
124 | the destroy function _will_ be called with NULL as its argument. |
125 | |
126 | === modified file 'include/unity/scopes/qt/QActionMetadata.h' |
127 | --- include/unity/scopes/qt/QActionMetadata.h 2015-02-25 12:37:37 +0000 |
128 | +++ include/unity/scopes/qt/QActionMetadata.h 2015-02-25 12:37:38 +0000 |
129 | @@ -140,7 +140,6 @@ |
130 | QActionMetadata(internal::QActionMetadataImpl* impl); |
131 | |
132 | std::unique_ptr<internal::QActionMetadataImpl> p; |
133 | - friend class internal::QActionMetadataImpl; |
134 | friend class internal::QPreviewQueryBaseImpl; |
135 | friend class QPreviewQueryBaseAPI; |
136 | /// @endcond |
137 | |
138 | === modified file 'include/unity/scopes/qt/QPreviewQueryBase.h' |
139 | --- include/unity/scopes/qt/QPreviewQueryBase.h 2015-02-25 12:37:37 +0000 |
140 | +++ include/unity/scopes/qt/QPreviewQueryBase.h 2015-02-25 12:37:38 +0000 |
141 | @@ -128,7 +128,6 @@ |
142 | void init(QPreviewQueryBaseAPI* query_api); |
143 | |
144 | std::unique_ptr<internal::QPreviewQueryBaseImpl> p; |
145 | - friend class internal::QPreviewQueryBaseImpl; |
146 | friend class QPreviewQueryBaseAPI; |
147 | /// @endcond |
148 | }; |
149 | |
150 | === modified file 'include/unity/scopes/qt/QPreviewReply.h' |
151 | --- include/unity/scopes/qt/QPreviewReply.h 2015-02-25 12:37:37 +0000 |
152 | +++ include/unity/scopes/qt/QPreviewReply.h 2015-02-25 12:37:38 +0000 |
153 | @@ -98,7 +98,6 @@ |
154 | |
155 | private: |
156 | std::unique_ptr<internal::QPreviewReplyImpl> p; |
157 | - friend class internal::QPreviewReplyImpl; |
158 | friend class QPreviewQueryBaseAPI; |
159 | /// @endcond |
160 | }; |
161 | |
162 | === modified file 'include/unity/scopes/qt/QResult.h' |
163 | --- include/unity/scopes/qt/QResult.h 2015-02-25 12:37:37 +0000 |
164 | +++ include/unity/scopes/qt/QResult.h 2015-02-25 12:37:38 +0000 |
165 | @@ -67,7 +67,6 @@ |
166 | UNITY_DEFINES_PTRS(QResult); |
167 | /// @endcond |
168 | |
169 | - QResult(); |
170 | /**@name Copy and assignment |
171 | Copy and assignment (move and non-move versions) have the usual value semantics. |
172 | */ |
173 | |
174 | === modified file 'include/unity/scopes/qt/QScopeBase.h' |
175 | --- include/unity/scopes/qt/QScopeBase.h 2015-02-25 12:37:37 +0000 |
176 | +++ include/unity/scopes/qt/QScopeBase.h 2015-02-25 12:37:38 +0000 |
177 | @@ -54,7 +54,7 @@ |
178 | \brief Base class for a scope implementation. |
179 | |
180 | Scopes are accessed by the scopes run time as a shared library (one library per scope). |
181 | -Each scope must implement a class that derives from ScopeBase, for example: |
182 | +Each scope must implement a class that derives from QScopeBase, for example: |
183 | |
184 | ~~~ |
185 | #include <unity/scopes/qt/QScopeBase.h> |
186 | @@ -65,9 +65,8 @@ |
187 | MyScope(); |
188 | virtual ~MyScope(); |
189 | |
190 | - virtual void start(QString const& scope_id); // Optional |
191 | + virtual void start(QString const& scope_id); // Optional |
192 | virtual void stop(); // Optional |
193 | - virtual void run(); // Optional |
194 | // ... |
195 | }; |
196 | ~~~ |
197 | @@ -76,8 +75,6 @@ |
198 | - a create function that must return a pointer to the derived instance |
199 | - a destroy function that is passed the pointer returned by the create function |
200 | |
201 | -Typically, the create and destroy functions will simply call `new` and `delete`, respectively. (However, |
202 | -there is no requirement that the derived class instance must be heap-allocated.) |
203 | If the create function throws an exception, the destroy function will not be called. If the create function returns |
204 | NULL, the destroy function _will_ be called with NULL as its argument. |
205 | |
206 | @@ -86,8 +83,9 @@ |
207 | |
208 | ~~~ |
209 | |
210 | -// You must provide a function that creates your own scope |
211 | -// That function must have no parameters and return a pointer to QScopeBase |
212 | +// You must provide a function that creates your scope on the heap and |
213 | +// pass this function to the QScopeBaseAPI constructor. |
214 | + |
215 | unity::scopes::qt::QScopeBase *create_my_scope() |
216 | { |
217 | return new MyScope(); |
218 | @@ -96,23 +94,23 @@ |
219 | unity::scopes::ScopeBase* |
220 | UNITY_SCOPE_CREATE_FUNCTION() |
221 | { |
222 | - // Initialize scope. This line is mandatory, you should pass your creation scope function to |
223 | - // the class QScopeBaseAPI, which will instantiate your class in the correct Qt Thread. |
224 | + // You must return a dynamically allocated QScopeBaseAPI instance here. |
225 | + // In turn, that instance calls your creation function to instantiate |
226 | + // your scope in the correct Qt thread. |
227 | return new QScopeBaseAPI(create_my_scope); |
228 | } |
229 | |
230 | +// The runtime, once it has stopped your scope, calls the destroy function. |
231 | + |
232 | void |
233 | UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope) |
234 | { |
235 | + delete scope; |
236 | } |
237 | ~~~ |
238 | |
239 | After the scopes run time has obtained a pointer to the class instance from the create function, it calls start(), |
240 | -which allows the scope to initialize itself. This is followed by a call to run(). |
241 | -All calls to the methods of this class will be done from the main QThread. |
242 | - |
243 | -The scope implementation, if it does not return from run(), is expected to return from run() in response to a |
244 | -call to stop() in a timely manner. |
245 | +which allows the scope to initialize itself. |
246 | */ |
247 | class QScopeBase : public QObject |
248 | { |
249 | @@ -149,7 +147,6 @@ |
250 | |
251 | private: |
252 | std::unique_ptr<internal::QScopeBaseImpl> p; |
253 | - friend class internal::QScopeBaseImpl; |
254 | }; |
255 | |
256 | } // namespace qt |
257 | |
258 | === modified file 'include/unity/scopes/qt/QScopeBaseAPI.h' |
259 | --- include/unity/scopes/qt/QScopeBaseAPI.h 2015-02-25 12:37:37 +0000 |
260 | +++ include/unity/scopes/qt/QScopeBaseAPI.h 2015-02-25 12:37:38 +0000 |
261 | @@ -52,10 +52,6 @@ |
262 | /** |
263 | * Defines the lifecycle of scope plugin, and acts as a factory |
264 | * for Query and Preview objects. |
265 | - * |
266 | - * Note that the #preview and #search methods are each called on |
267 | - * different threads, so some form of interlocking is required |
268 | - * if shared data structures are used. |
269 | */ |
270 | class QScopeBaseAPI : public unity::scopes::ScopeBase |
271 | { |
272 | @@ -109,7 +105,6 @@ |
273 | private: |
274 | /// @cond |
275 | std::unique_ptr<internal::QScopeBaseAPIImpl> p; |
276 | - friend class internal::QScopeBaseAPIImpl; |
277 | /// @endcond |
278 | }; |
279 | |
280 | |
281 | === modified file 'include/unity/scopes/qt/QSearchMetadata.h' |
282 | --- include/unity/scopes/qt/QSearchMetadata.h 2015-02-25 12:37:37 +0000 |
283 | +++ include/unity/scopes/qt/QSearchMetadata.h 2015-02-25 12:37:38 +0000 |
284 | @@ -164,7 +164,6 @@ |
285 | private: |
286 | /// @cond |
287 | std::unique_ptr<internal::QSearchMetadataImpl> p; |
288 | - friend class internal::QSearchMetadataImpl; |
289 | /// @endcond |
290 | }; |
291 | |
292 | |
293 | === modified file 'include/unity/scopes/qt/QSearchQueryBase.h' |
294 | --- include/unity/scopes/qt/QSearchQueryBase.h 2015-02-25 12:37:37 +0000 |
295 | +++ include/unity/scopes/qt/QSearchQueryBase.h 2015-02-25 12:37:38 +0000 |
296 | @@ -156,7 +156,6 @@ |
297 | void init(QSearchQueryBaseAPI* query_api); |
298 | |
299 | std::unique_ptr<internal::QSearchQueryBaseImpl> p; |
300 | - friend class internal::QSearchQueryBaseImpl; |
301 | friend class QSearchQueryBaseAPI; |
302 | ///@endcond |
303 | }; |
304 | |
305 | === modified file 'include/unity/scopes/qt/QSearchReply.h' |
306 | --- include/unity/scopes/qt/QSearchReply.h 2015-02-25 12:37:37 +0000 |
307 | +++ include/unity/scopes/qt/QSearchReply.h 2015-02-25 12:37:38 +0000 |
308 | @@ -157,7 +157,6 @@ |
309 | QSearchReply(unity::scopes::SearchReplyProxy& reply, QObject* parent = 0); |
310 | |
311 | std::unique_ptr<internal::QSearchReplyImpl> p; |
312 | - friend class internal::QSearchReplyImpl; |
313 | friend class QSearchQueryBaseAPI; |
314 | }; |
315 | |
316 | |
317 | === modified file 'include/unity/scopes/qt/internal/QActionMetadataImpl.h' |
318 | --- include/unity/scopes/qt/internal/QActionMetadataImpl.h 2015-02-06 00:12:18 +0000 |
319 | +++ include/unity/scopes/qt/internal/QActionMetadataImpl.h 2015-02-25 12:37:38 +0000 |
320 | @@ -43,92 +43,26 @@ |
321 | |
322 | class QPreviewQueryBaseImpl; |
323 | |
324 | -/** |
325 | -\brief Metadata passed to scopes for preview and activation. |
326 | -\see unity::scopes::ScopeBase::preview, unity::scopes::ScopeBase::activate, unity::scopes::ScopeBase::perform_action |
327 | -*/ |
328 | class QActionMetadataImpl |
329 | { |
330 | public: |
331 | - /// @cond |
332 | UNITY_DEFINES_PTRS(QActionMetadataImpl); |
333 | |
334 | + QActionMetadataImpl(QString const& locale, QString const& form_factor); |
335 | ~QActionMetadataImpl(); |
336 | - /// @endcond |
337 | - |
338 | - /** |
339 | - \brief Create ActionMetadata with the given locale and form factor. |
340 | - \param locale locale string, eg. en_EN |
341 | - \param form_factor form factor name, e.g. phone, desktop, phone-version etc. |
342 | - */ |
343 | - QActionMetadataImpl(QString const& locale, QString const& form_factor); |
344 | - |
345 | - /** |
346 | - \brief Attach arbitrary data to this ActionMetadata. |
347 | - \param data The data value to attach. |
348 | - */ |
349 | - void set_scope_data(QVariant const& data); |
350 | - |
351 | - /** |
352 | - \brief Get data attached to this ActionMetadata. |
353 | - \return The attached data, or QVariant::null. |
354 | - */ |
355 | - QVariant scope_data() const; |
356 | - |
357 | - /**@name Copy and assignment |
358 | - Copy and assignment operators (move and non-move versions) have the usual value semantics. |
359 | - */ |
360 | - //{@ |
361 | + |
362 | QActionMetadataImpl(QActionMetadataImpl const& other); |
363 | QActionMetadataImpl(QActionMetadataImpl&&); |
364 | |
365 | QActionMetadataImpl& operator=(QActionMetadataImpl const& other); |
366 | QActionMetadataImpl& operator=(QActionMetadataImpl&&); |
367 | - //@} |
368 | - |
369 | - /** |
370 | - \brief Sets a hint. |
371 | - |
372 | - \param key The name of the hint. |
373 | - \param value Hint value |
374 | - */ |
375 | + |
376 | + void set_scope_data(QVariant const& data); |
377 | + QVariant scope_data() const; |
378 | void set_hint(QString const& key, QVariant const& value); |
379 | - |
380 | - /** |
381 | - \brief Get all hints. |
382 | - |
383 | - \return Hints dictionary. |
384 | - \throws unity::NotFoundException if no hints are available. |
385 | - */ |
386 | QVariantMap hints() const; |
387 | - |
388 | - /** |
389 | - \brief Check if this SearchMetadata has a hint. |
390 | - \param key The hint name. |
391 | - \return True if the hint is set.QScopeVariant |
392 | - */ |
393 | bool contains_hint(QString const& key) const; |
394 | - |
395 | - /** |
396 | - \brief Returns a reference to a hint. |
397 | - |
398 | - This method can be used to read or set hints. Setting a value of an existing hint overwrites |
399 | - its previous value. |
400 | - Referencing a non-existing hint automatically creates it with a default value of QVariant::Type::Null. |
401 | - \param key The name of the hint. |
402 | - \return A reference to the hint. |
403 | - */ |
404 | QScopeVariant& operator[](QString const& key); |
405 | - |
406 | - /** |
407 | - \brief Returns a const reference to a hint. |
408 | - |
409 | - This method can be used for read-only access to hints. |
410 | - Referencing a non-existing hint throws unity::InvalidArgumentException. |
411 | - \param key The name of the hint. |
412 | - \return A const reference to the hint. |
413 | - \throws unity::NotFoundException if no hint with the given name exists. |
414 | - */ |
415 | QVariant const& value(QString const& key) const; |
416 | |
417 | private: |
418 | |
419 | === modified file 'include/unity/scopes/qt/internal/QCategorisedResultImpl.h' |
420 | --- include/unity/scopes/qt/internal/QCategorisedResultImpl.h 2015-01-20 13:59:36 +0000 |
421 | +++ include/unity/scopes/qt/internal/QCategorisedResultImpl.h 2015-02-25 12:37:38 +0000 |
422 | @@ -48,37 +48,16 @@ |
423 | class QCategorisedResultImpl : public QResultImpl |
424 | { |
425 | public: |
426 | - /// @cond |
427 | UNITY_DEFINES_PTRS(QCategorisedResultImpl); |
428 | - /// @endcond |
429 | - /** |
430 | - \brief Creates a CategorisedResult with given category, |
431 | - with all base attributes initially empty. |
432 | - \param category The category for the result. |
433 | - */ |
434 | + |
435 | explicit QCategorisedResultImpl(QCategory::SCPtr category); |
436 | |
437 | - /**@name Copy and assignment |
438 | - Copy and assignment operators (move and non-move versions) have the usual value semantics. |
439 | - */ |
440 | - //{@ |
441 | QCategorisedResultImpl(QCategorisedResultImpl const& other); |
442 | QCategorisedResultImpl& operator=(QCategorisedResultImpl const& other); |
443 | QCategorisedResultImpl(QCategorisedResultImpl&&); |
444 | QCategorisedResultImpl& operator=(QCategorisedResultImpl&&); |
445 | - //@} |
446 | |
447 | - /** |
448 | - \brief Updates the category of this result. |
449 | - \param category The category for the result. |
450 | - */ |
451 | void set_category(QCategory::SCPtr category); |
452 | - |
453 | - /** |
454 | - \brief Return category of this result. |
455 | - Get the category instance this result belongs to. |
456 | - \return The category instance. |
457 | - */ |
458 | QCategory::SCPtr category() const; |
459 | |
460 | private: |
461 | |
462 | === modified file 'include/unity/scopes/qt/internal/QCategoryImpl.h' |
463 | --- include/unity/scopes/qt/internal/QCategoryImpl.h 2015-02-06 00:12:18 +0000 |
464 | +++ include/unity/scopes/qt/internal/QCategoryImpl.h 2015-02-25 12:37:38 +0000 |
465 | @@ -47,46 +47,19 @@ |
466 | class QCategoryImpl |
467 | { |
468 | public: |
469 | - /// @cond |
470 | NONCOPYABLE(QCategoryImpl); |
471 | UNITY_DEFINES_PTRS(QCategoryImpl); |
472 | |
473 | QCategoryImpl(unity::scopes::Category::SCPtr category); |
474 | |
475 | virtual ~QCategoryImpl(); |
476 | - /// @endcond |
477 | |
478 | - /** |
479 | - \brief Get identifier of this Category |
480 | - \return The category identifier. |
481 | - */ |
482 | QString id() const; |
483 | - |
484 | - /** |
485 | - \brief Get title of this Category |
486 | - \return The category title. |
487 | - */ |
488 | QString title() const; |
489 | - |
490 | - /** |
491 | - \brief Get icon of this Category |
492 | - \return The category icon. |
493 | - */ |
494 | QString icon() const; |
495 | - |
496 | - /** |
497 | - \brief Query to perform when this category is expanded |
498 | - \return The expansion query or nullptr. |
499 | - */ |
500 | CannedQuery::SCPtr query() const; |
501 | - |
502 | - /** |
503 | - \brief Get renderer template of this Category |
504 | - \return The category renderer template. |
505 | - */ |
506 | CategoryRenderer const& renderer_template() const; |
507 | |
508 | - // @cond |
509 | QVariantMap serialize() const; |
510 | |
511 | static std::shared_ptr<QCategory> create(unity::scopes::Category::SCPtr category); |
512 | |
513 | === modified file 'include/unity/scopes/qt/internal/QColumnLayoutImpl.h' |
514 | --- include/unity/scopes/qt/internal/QColumnLayoutImpl.h 2015-02-06 00:12:18 +0000 |
515 | +++ include/unity/scopes/qt/internal/QColumnLayoutImpl.h 2015-02-25 12:37:38 +0000 |
516 | @@ -46,65 +46,22 @@ |
517 | class QColumnLayoutImpl |
518 | { |
519 | public: |
520 | - /// @cond |
521 | UNITY_DEFINES_PTRS(QColumnLayoutImpl); |
522 | - /// @endcond |
523 | |
524 | - /** |
525 | - \brief Creates a layout definition that expects num_of_columns columns to be added with ColumnLayout::add_column. |
526 | - \param num_of_columns The number of columns for the layout. |
527 | - \throws unity::InvalidArgumentException for an invalid number of columns. |
528 | - */ |
529 | explicit QColumnLayoutImpl(int num_of_columns); |
530 | + ~QColumnLayoutImpl(); |
531 | |
532 | - /**@name Copy and assignment |
533 | - Copy and assignment operators (move and non-move versions) have the usual value semantics. |
534 | - */ |
535 | - //{@ |
536 | QColumnLayoutImpl(QColumnLayoutImpl const& other); |
537 | QColumnLayoutImpl(QColumnLayoutImpl&&); |
538 | QColumnLayoutImpl& operator=(QColumnLayoutImpl const& other); |
539 | QColumnLayoutImpl& operator=(QColumnLayoutImpl&&); |
540 | - //@} |
541 | - |
542 | - /// @cond |
543 | - ~QColumnLayoutImpl(); |
544 | - /// @endcond |
545 | - |
546 | - /** |
547 | - \brief Adds a new column and assigns widgets to it. |
548 | - |
549 | - ColumnLayout expects exactly the number of columns passed to the constructor to be created with the |
550 | - add_column method. |
551 | - \throws unity::LogicException if an attempt is made to add more columns than specified in the constructor. |
552 | - \throws unity::LogicException from \link unity::scopes::PreviewReply::register_layout\endlink if a layout |
553 | - has fewer columns than specified in the constructor. |
554 | - */ |
555 | + |
556 | void add_column(QVector<QString> widget_ids); |
557 | - |
558 | - /** |
559 | - \brief Get the current number of columns in this layout. |
560 | - \return The number of columns added with add_column(). |
561 | - */ |
562 | int size() const noexcept; |
563 | - |
564 | - /** |
565 | - \brief Get the number of columns expected by this layout as specified in the constructor. |
566 | - \return The number of columns expected by this layout. |
567 | - */ |
568 | int number_of_columns() const noexcept; |
569 | - |
570 | - /** |
571 | - \brief Retrieve the list of widgets for given column. |
572 | - \param index The index of a column. |
573 | - \return The widget identifiers for the given column index. |
574 | - \throws unity::InvalidArgumentException if the index is invalid. |
575 | - */ |
576 | QVector<QString> column(int index) const; |
577 | |
578 | - /// @cond |
579 | QVariantMap serialize() const; |
580 | - /// @endcond |
581 | |
582 | // added for testing purposes |
583 | static unity::scopes::qt::QColumnLayout create(QColumnLayoutImpl* internal); |
584 | |
585 | === modified file 'include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h' |
586 | --- include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h 2015-01-20 13:59:36 +0000 |
587 | +++ include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h 2015-02-25 12:37:38 +0000 |
588 | @@ -46,26 +46,13 @@ |
589 | class QPreviewQueryBaseImpl |
590 | { |
591 | public: |
592 | - /// @cond |
593 | NONCOPYABLE(QPreviewQueryBaseImpl); |
594 | UNITY_DEFINES_PTRS(QPreviewQueryBaseImpl); |
595 | - /// @endcond |
596 | |
597 | QPreviewQueryBaseImpl(); |
598 | ~QPreviewQueryBaseImpl() = default; |
599 | |
600 | - /** |
601 | - \brief Get result for this preview request. |
602 | - \throws unity::LogicException if result was not initialized (the default ctor was used). |
603 | - \return result |
604 | - */ |
605 | QResult result() const; |
606 | - |
607 | - /** |
608 | - \brief Get metadata for this preview request. |
609 | - \return search metadata |
610 | - \throws unity::LogicException if preview metadata was not initialized (the default ctor was used). |
611 | - */ |
612 | QActionMetadata action_metadata() const; |
613 | |
614 | protected: |
615 | |
616 | === modified file 'include/unity/scopes/qt/internal/QPreviewReplyImpl.h' |
617 | --- include/unity/scopes/qt/internal/QPreviewReplyImpl.h 2015-02-06 00:12:18 +0000 |
618 | +++ include/unity/scopes/qt/internal/QPreviewReplyImpl.h 2015-02-25 12:37:38 +0000 |
619 | @@ -48,49 +48,20 @@ |
620 | namespace internal |
621 | { |
622 | |
623 | -/** |
624 | -\brief Allows the results of a preview to be sent to the preview requester. |
625 | -*/ |
626 | - |
627 | class QPreviewReplyImpl |
628 | { |
629 | public: |
630 | - /// @cond |
631 | NONCOPYABLE(QPreviewReplyImpl); |
632 | UNITY_DEFINES_PTRS(QPreviewReplyImpl); |
633 | - /// @endcond |
634 | - /** |
635 | - \brief Registers a list of column layouts for the current preview. |
636 | - |
637 | - Layouts must be registered before pushing a unity::scopes::PreviewWidgetList, and must be |
638 | - registered only once. |
639 | - \return True if the query is still alive, false if the query failed or was cancelled. |
640 | - \throws unity::LogicException register_layout() is called more than once. |
641 | - */ |
642 | + |
643 | + virtual ~QPreviewReplyImpl(); |
644 | + |
645 | bool register_layout(QColumnLayoutList const& layouts); |
646 | - |
647 | - /** |
648 | - \brief Sends widget definitions to the sender of the preview query. |
649 | - |
650 | - This method can be called mutiple times to send widgets in stages. |
651 | - \return True if the query is still alive, false if the query failed or was cancelled. |
652 | - */ |
653 | bool push(QPreviewWidgetList const& widget_list); |
654 | - |
655 | - /** |
656 | - \brief Sends data for a preview widget attribute. |
657 | - \return True if the query is still alive, false if the query failed or was cancelled. |
658 | - */ |
659 | bool push(QString const& key, QVariant const& value); |
660 | |
661 | - /// @cond |
662 | - virtual ~QPreviewReplyImpl(); |
663 | - /// @endcond |
664 | - |
665 | protected: |
666 | - /// @cond |
667 | QPreviewReplyImpl(unity::scopes::PreviewReplyProxy& reply); |
668 | - /// @endcond |
669 | |
670 | private: |
671 | PreviewReplyProxy api_reply_; |
672 | |
673 | === modified file 'include/unity/scopes/qt/internal/QPreviewWidgetImpl.h' |
674 | --- include/unity/scopes/qt/internal/QPreviewWidgetImpl.h 2015-02-06 00:12:18 +0000 |
675 | +++ include/unity/scopes/qt/internal/QPreviewWidgetImpl.h 2015-02-25 12:37:38 +0000 |
676 | @@ -39,9 +39,6 @@ |
677 | |
678 | class QPreviewWidget; |
679 | |
680 | -/*! \typedef QPreviewWidgetList |
681 | -\brief List of preview widgets (see unity::scopes::qt::QPreviewWidget) |
682 | -*/ |
683 | typedef QList<QPreviewWidget> QPreviewWidgetList; |
684 | |
685 | namespace internal |
686 | @@ -52,135 +49,29 @@ |
687 | class QPreviewWidgetImpl |
688 | { |
689 | public: |
690 | - /// @cond |
691 | UNITY_DEFINES_PTRS(QPreviewWidgetImpl); |
692 | - /// @endcond |
693 | |
694 | - /** |
695 | - \brief Create an empty widget definition with a specific id and type. |
696 | - \param id The unique widget identifier. |
697 | - \param widget_type The type of the widget. |
698 | - */ |
699 | QPreviewWidgetImpl(QString const& id, QString const& widget_type); |
700 | - |
701 | - /** |
702 | - \brief Create a widget from a JSON definition. |
703 | - |
704 | - The JSON definition must be a dictionary that includes widget "id" and all the values of attributes required by |
705 | - desired |
706 | - \link previewwidgets widget type\endlink. For example, a definition of image widget may look as follows: |
707 | - \code{.cpp} |
708 | - PreviewWidget img(R"({"id": "img", "type": "image", "source": "http://imageuri"})"); |
709 | - \endcode |
710 | - |
711 | - For cases where attribute mappings are to be used instead of direct values, they need to be enclosed in the |
712 | - "components" dictionary, e.g. |
713 | - \code{.cpp} |
714 | - PreviewWidget img(R"({"id": "img", "type": "image", "components": { "source": "screenshot-url" } })"); |
715 | - \endcode |
716 | - (this example assumes "screenshot-url" value is either available in the result object that's being previewed, or it |
717 | - will be pushed with |
718 | - unity::scopes::PreviewReply::push() method) |
719 | - |
720 | - \note It is recommended to create widgets via unity::scopes::PreviewWidget(QString const&, QString const&) |
721 | - constructor |
722 | - and unity::scopes::PreviewWidget::add_attribute_value() / unity::scopes::PreviewWidget::add_attribute_mapping() |
723 | - methods, |
724 | - rather than via JSON definition. |
725 | - |
726 | - \param definition The JSON definition. |
727 | - */ |
728 | QPreviewWidgetImpl(QString const& definition); |
729 | + virtual ~QPreviewWidgetImpl(); |
730 | |
731 | - /**@name Copy and assignment |
732 | - Copy and assignment operators (move and non-move versions) have the usual value semantics. |
733 | - */ |
734 | - //{@ |
735 | QPreviewWidgetImpl(QPreviewWidgetImpl const& other); |
736 | QPreviewWidgetImpl(QPreviewWidgetImpl&& other); |
737 | - virtual ~QPreviewWidgetImpl(); |
738 | |
739 | QPreviewWidgetImpl& operator=(QPreviewWidgetImpl const& other); |
740 | QPreviewWidgetImpl& operator=(QPreviewWidgetImpl&& other); |
741 | - //@} |
742 | |
743 | - /** |
744 | - \brief Adds an attribute definition and its value. |
745 | - \param key The name of the attribute. |
746 | - \param value The value of the attribute. |
747 | - */ |
748 | void add_attribute_value(QString const& key, QVariant const& value); |
749 | - |
750 | - /** |
751 | - \brief Adds an attribute definition using a component mapping. |
752 | - |
753 | - If an attribute value is either not known, or the value is already present |
754 | - in a result field, this method creates a mapping between the attribute |
755 | - name and given the field name. |
756 | - |
757 | - If an attribute value is not known, the scope is expected to push the attribute value using |
758 | - unity::scopes::PreviewReply::push(); otherwise, the value is automatically |
759 | - mapped from the result. |
760 | - */ |
761 | void add_attribute_mapping(QString const& key, QString const& field_name); |
762 | - |
763 | - /** |
764 | - \brief Adds a widget into expandable widget. |
765 | - |
766 | - Adds a widget into this widget, which needs to be of 'expandable' type. This method throws |
767 | - if adding a widget into any other widget type. Also, adding an 'expandable' widget into |
768 | - another 'expandable' is not allowed. |
769 | - |
770 | - \throws unity::LogicException if type of this widget is other than 'expandable', or when |
771 | - adding 'expandable' to 'expandable'. |
772 | - */ |
773 | void add_widget(QPreviewWidget const& widget); |
774 | - |
775 | - /** |
776 | - \brief Get the identifier of this widget. |
777 | - \return The widget identifier. |
778 | - */ |
779 | QString id() const; |
780 | - |
781 | - /** |
782 | - \brief Get type name of this widget. |
783 | - \return The widget type. |
784 | - */ |
785 | QString widget_type() const; |
786 | - |
787 | - /** |
788 | - \brief Get the components of this widget. |
789 | - |
790 | - The returned map is a dictionary of (key, field name) pairs, as defined by calls to add_attribute_mapping(). |
791 | - \return The components map. |
792 | - */ |
793 | QMap<QString, QString> attribute_mappings() const; |
794 | - |
795 | - /** |
796 | - \brief Get the attributes of this widget. |
797 | - |
798 | - The returned map is a dictionary of (key, value) pairs, as defined by calls to add_attribute_value(). |
799 | - \return The attribute map. |
800 | - */ |
801 | QVariantMap attribute_values() const; |
802 | - |
803 | - /** |
804 | - \brief Get widgets of 'expandable' widget. |
805 | - |
806 | - Returns the list of widget attached to this widget, which must be of 'expandable' type. This list is |
807 | - always empty for other widget types. |
808 | - */ |
809 | QPreviewWidgetList widgets() const; |
810 | - |
811 | - /** |
812 | - \brief Get a JSON representation of this widget. |
813 | - \return The JSON string. |
814 | - */ |
815 | QString data() const; |
816 | |
817 | - /// @cond |
818 | QVariantMap serialize() const; |
819 | - /// @endcond |
820 | |
821 | private: |
822 | std::unique_ptr<PreviewWidget> api_widget_; |
823 | |
824 | === modified file 'include/unity/scopes/qt/internal/QResultImpl.h' |
825 | --- include/unity/scopes/qt/internal/QResultImpl.h 2015-02-06 00:12:18 +0000 |
826 | +++ include/unity/scopes/qt/internal/QResultImpl.h 2015-02-25 12:37:38 +0000 |
827 | @@ -54,192 +54,37 @@ |
828 | class QResultImpl |
829 | { |
830 | public: |
831 | - /// @cond |
832 | UNITY_DEFINES_PTRS(QResultImpl); |
833 | - /// @endcond |
834 | |
835 | - /**@name Copy and assignment |
836 | - Copy and assignment (move and non-move versions) have the usual value semantics. |
837 | - */ |
838 | - //{@ |
839 | QResultImpl(unity::scopes::Result const& other); |
840 | QResultImpl(QResultImpl const& other); |
841 | |
842 | QResultImpl& operator=(QResultImpl const& other); |
843 | QResultImpl& operator=(QResultImpl&&); |
844 | - //@} |
845 | |
846 | - /** |
847 | - Destructor. |
848 | - */ |
849 | virtual ~QResultImpl(); |
850 | |
851 | - /** |
852 | - \brief Stores a Result inside this Result instance. |
853 | - |
854 | - This method is meant to be used by aggregator scopes which want to modify results they receive, but want |
855 | - to keep a copy of the original result so that they can be correctly handled by the original scopes |
856 | - who created them when it comes to activation or previews. |
857 | - Scopes middleware will automatically pass the correct inner stored result to the activation or preview request |
858 | - handler |
859 | - of a scope which created it. |
860 | - \param other The original result to store within this result. |
861 | - \param intercept_activation True if this scope should receive activation and preview requests. |
862 | - */ |
863 | void store(QResult const& other, bool intercept_activation = false); |
864 | - |
865 | - /** |
866 | - \brief Check if this Result instance has a stored result. |
867 | - \return True if there is a stored result |
868 | - */ |
869 | bool has_stored_result() const; |
870 | - |
871 | - /** |
872 | - \brief Get a stored result. |
873 | - \return stored result |
874 | - \throws unity::InvalidArgumentException if no result was stored in this Result instance. |
875 | - */ |
876 | QResult retrieve() const; |
877 | - |
878 | - /** |
879 | - \brief Set the "uri" attribute of this result. |
880 | - */ |
881 | void set_uri(QString const& uri); |
882 | - |
883 | - /** |
884 | - \brief Set the "title" attribute of this result. |
885 | - |
886 | - Equivalent to calling `result["title"] = title;` |
887 | - */ |
888 | void set_title(QString const& title); |
889 | - /** |
890 | - \brief Set the "art" attribute of this result. |
891 | - |
892 | - Equivalent to calling `result["art"] = image;` |
893 | - */ |
894 | void set_art(QString const& image); |
895 | - |
896 | - /** |
897 | - \brief Set the "dnd_uri" attribute of this result. |
898 | - |
899 | - Equivalent to calling `result["dnd_uri"] = dnd_uri;` |
900 | - */ |
901 | void set_dnd_uri(QString const& dnd_uri); |
902 | - |
903 | - /** |
904 | - \brief Indicates to the receiver that this scope should intercept activation requests for this result. |
905 | - |
906 | - By default, a scope receives preview requests for the results it creates, but does not receive activation |
907 | - requests (they are handled directly by the shell). |
908 | - Intercepting activation implies intercepting preview requests as well; this is important for scopes that |
909 | - forward results from other scopes and call set_intercept_activation() on these scopes. |
910 | - A scope that sets intercept activation flag for a result should re-implement ScopeBase::activate() |
911 | - and provide an implementation of ActivationQueryBase that handles the actual activation. |
912 | - If not called, the result will be activated directly by the Unity shell whithout involving the scope, |
913 | - assuming an appropriate URI schema handler is present on the system. |
914 | - */ |
915 | void set_intercept_activation(); |
916 | - |
917 | - /** |
918 | - \brief Check if this result should be activated directly by the shell |
919 | - because the scope doesn't handle activation of this result. |
920 | - \return True if this result needs to be activated directly. |
921 | - */ |
922 | bool direct_activation() const; |
923 | - |
924 | - /** |
925 | - \brief Get the proxy of a scope that handles activation and preview of this result. |
926 | - |
927 | - The proxy is available only when receiving this result from a scope, otherwise |
928 | - this method throws LogicException. Activation requests should be sent to a scope |
929 | - returned by this method only if direct_activation() is false. |
930 | - \return The scope proxy. |
931 | - */ |
932 | ScopeProxy target_scope_proxy() const; |
933 | - |
934 | - /** |
935 | - \brief Returns reference of a Result attribute. |
936 | - |
937 | - This method can be used to read or initialize both standard ("uri", "title", "art", "dnd_uri") |
938 | - and custom metadata attributes. Referencing a non-existing attribute automatically creates |
939 | - it with a default value of Variant::Type::Null. |
940 | - \param key The name of the attribute. |
941 | - \return A reference to the attribute. |
942 | - \throws unity::Invalidargument if no attribute with the given name exists. |
943 | - */ |
944 | QVariant& operator[](QString const& key); |
945 | - |
946 | - /** |
947 | - \brief Returns a const reference to a Result attribute. |
948 | - |
949 | - This method can be used for read-only access to both standard ("uri", "title", "art", "dnd_uri") |
950 | - and custom metadata attributes. Referencing a non-existing attribute throws unity::InvalidArgumentException. |
951 | - \param key The name of the attribute. |
952 | - \return A const reference to the attribute. |
953 | - \throws unity::Invalidargument if no attribute with the given name exists. |
954 | - */ |
955 | QVariant const& operator[](QString const& key) const; |
956 | - |
957 | - /** |
958 | - \brief Get the "uri" property of this Result. |
959 | - |
960 | - This method returns an empty string if this attribute is not of type Variant::Type::String (e.g. it was set with |
961 | - operator[]). |
962 | - \return The value of "uri" or the empty string. |
963 | - */ |
964 | QString uri() const noexcept; |
965 | - |
966 | - /** |
967 | - \brief Get the "title" property of this Result. |
968 | - |
969 | - This method returns an empty string if this attribute is not of type Variant::Type::String (e.g. it was set with |
970 | - operator[]). |
971 | - \return The value of "title" or the empty string. |
972 | - */ |
973 | QString title() const noexcept; |
974 | - |
975 | - /** |
976 | - \brief Get the "art" property of this Result. |
977 | - |
978 | - This method returns an empty string if this attribute is not of type Variant::Type::String (e.g. it was set with |
979 | - operator[]). |
980 | - \return The value of "art" or the empty string. |
981 | - */ |
982 | QString art() const noexcept; |
983 | - |
984 | - /** |
985 | - \brief Get the "dnd_uri" property of this Result. |
986 | - |
987 | - This method returns an empty string if this attribute is not of type Variant::Type::String type (e.g. it was set |
988 | - with operator[]). |
989 | - \return The value of "dnd_uri" or the empty string. |
990 | - */ |
991 | QString dnd_uri() const noexcept; |
992 | - |
993 | - /** |
994 | - \brief Check if this Result has an attribute. |
995 | - \param key The attribute name. |
996 | - \return True if the attribute is set. |
997 | - */ |
998 | bool contains(QString const& key) const; |
999 | - |
1000 | - /** |
1001 | - \brief Get the value of an attribute. |
1002 | - |
1003 | - \param key The attribute name. |
1004 | - \return The attribute value. |
1005 | - \throws unity::InvalidArgumentException if given attribute hasn't been set. |
1006 | - */ |
1007 | QVariant const& value(QString const& key) const; |
1008 | - |
1009 | - /** |
1010 | - \brief Returns a dictionary of all attributes of this Result instance. |
1011 | - \return All base attributes and custom attributes set with add_metadata(). |
1012 | - */ |
1013 | QVariantMap serialize() const; |
1014 | |
1015 | protected: |
1016 | - /// @cond |
1017 | explicit QResultImpl(const QVariantMap& variant_map); |
1018 | explicit QResultImpl(internal::QResultImpl* impl); |
1019 | explicit QResultImpl(unity::scopes::Result* api_result); |
1020 | |
1021 | === modified file 'include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h' |
1022 | --- include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h 2015-02-25 12:37:37 +0000 |
1023 | +++ include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h 2015-02-25 12:37:38 +0000 |
1024 | @@ -52,62 +52,29 @@ |
1025 | { |
1026 | Q_OBJECT |
1027 | public: |
1028 | - /// @cond |
1029 | using FactoryFunc = std::function<QScopeBase*()>; |
1030 | |
1031 | NONCOPYABLE(QScopeBaseAPIImpl); |
1032 | UNITY_DEFINES_PTRS(QScopeBaseAPIImpl); |
1033 | |
1034 | - QScopeBaseAPIImpl(QScopeBase& qtscope, QObject* parent = 0); |
1035 | - QScopeBaseAPIImpl(FactoryFunc const& creator, QObject* parent = 0); |
1036 | + QScopeBaseAPIImpl(FactoryFunc const& creator); |
1037 | virtual ~QScopeBaseAPIImpl(); |
1038 | |
1039 | bool event(QEvent* e) override; |
1040 | - /// @endcond |
1041 | - |
1042 | - /** |
1043 | - \brief Called by the scopes run time after the create function completes. |
1044 | - |
1045 | - If start() throws an exception, stop() will _not_ be called. |
1046 | - |
1047 | - The call to start() is made by the same thread that calls the create function. |
1048 | - |
1049 | - \param scope_id The name of the scope as defined by the scope's configuration file. |
1050 | - */ |
1051 | void start(std::string const& scope_id); |
1052 | - |
1053 | - /** |
1054 | - \brief Called by the scopes run time when the scope should shut down. |
1055 | - |
1056 | - A scope should deallocate as many resources as possible when stop() is called, for example, |
1057 | - deallocate any caches and close network connections. In addition, if the scope implements run() |
1058 | - and did not return from run(), it must return from run() in response to the call to stop(). |
1059 | - |
1060 | - Exceptions from stop() are ignored. |
1061 | - |
1062 | - The call to stop() is made by the same thread that calls the create function and start(). |
1063 | - */ |
1064 | void stop(); |
1065 | - |
1066 | - /** |
1067 | - * Called each time a new preview is requested |
1068 | - */ |
1069 | unity::scopes::PreviewQueryBase::UPtr preview(const unity::scopes::Result&, const unity::scopes::ActionMetadata&); |
1070 | - |
1071 | - /** |
1072 | - * Called each time a new query is requested |
1073 | - */ |
1074 | unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const& q, |
1075 | unity::scopes::SearchMetadata const&); |
1076 | |
1077 | protected: |
1078 | - void startQtThread(); |
1079 | + void start_qt_thread(); |
1080 | |
1081 | std::shared_ptr<QCoreApplication> qtapp_; |
1082 | std::unique_ptr<std::thread> qtthread_; |
1083 | std::atomic<bool> qtapp_ready_; |
1084 | - |
1085 | - QScopeBase* qtscope_impl_; |
1086 | + std::atomic<bool> qtapp_stopped_; |
1087 | + std::unique_ptr<QScopeBase> qtscope_impl_; |
1088 | |
1089 | FactoryFunc qtscope_creator_; |
1090 | }; |
1091 | |
1092 | === modified file 'include/unity/scopes/qt/internal/QScopeBaseImpl.h' |
1093 | --- include/unity/scopes/qt/internal/QScopeBaseImpl.h 2015-01-20 13:59:36 +0000 |
1094 | +++ include/unity/scopes/qt/internal/QScopeBaseImpl.h 2015-02-25 12:37:38 +0000 |
1095 | @@ -38,21 +38,13 @@ |
1096 | class QScopeBaseImpl |
1097 | { |
1098 | public: |
1099 | - /// @cond |
1100 | NONCOPYABLE(QScopeBaseImpl); |
1101 | UNITY_DEFINES_PTRS(QScopeBaseImpl); |
1102 | |
1103 | QScopeBaseImpl() = default; |
1104 | virtual ~QScopeBaseImpl() = default; |
1105 | - /// @endcond |
1106 | - /** |
1107 | - * Called once at startup |
1108 | - */ |
1109 | + |
1110 | virtual void start(std::string const&); |
1111 | - |
1112 | - /** |
1113 | - * Called at shutdown |
1114 | - */ |
1115 | virtual void stop(); |
1116 | }; |
1117 | |
1118 | |
1119 | === modified file 'include/unity/scopes/qt/internal/QScopeVariant.h' |
1120 | --- include/unity/scopes/qt/internal/QScopeVariant.h 2015-02-06 00:12:18 +0000 |
1121 | +++ include/unity/scopes/qt/internal/QScopeVariant.h 2015-02-25 12:37:38 +0000 |
1122 | @@ -45,7 +45,6 @@ |
1123 | class QScopeVariant : public QVariant |
1124 | { |
1125 | public: |
1126 | - // explicit QScopeVariant() noexcept; |
1127 | virtual ~QScopeVariant(); |
1128 | |
1129 | QScopeVariant(QScopeVariant const& other); |
1130 | @@ -65,9 +64,6 @@ |
1131 | std::string get_string() const; |
1132 | |
1133 | private: |
1134 | - /** |
1135 | - \brief Creates a Variant instance that stores the supplied integer. |
1136 | - */ |
1137 | explicit QScopeVariant(Variant* val) noexcept; |
1138 | |
1139 | void setInternalVariant(Variant* val); |
1140 | |
1141 | === modified file 'include/unity/scopes/qt/internal/QSearchMetadataImpl.h' |
1142 | --- include/unity/scopes/qt/internal/QSearchMetadataImpl.h 2015-02-06 00:12:18 +0000 |
1143 | +++ include/unity/scopes/qt/internal/QSearchMetadataImpl.h 2015-02-25 12:37:38 +0000 |
1144 | @@ -45,114 +45,27 @@ |
1145 | class QSearchMetadataImpl |
1146 | { |
1147 | public: |
1148 | - /// @cond |
1149 | UNITY_DEFINES_PTRS(QSearchMetadataImpl); |
1150 | - /// @endcond |
1151 | |
1152 | - /** |
1153 | - \brief Create SearchMetadata with the given locale and form factor. |
1154 | - \param locale locale string, eg. en_EN |
1155 | - \param form_factor form factor name, e.g. phone, desktop, phone-version etc. |
1156 | - */ |
1157 | QSearchMetadataImpl(QString const& locale, QString const& form_factor); |
1158 | - |
1159 | - /** |
1160 | - \brief Create SearchMetadata with the given cardinality, locale, and form factor. |
1161 | - \param cardinality maximum number of search results |
1162 | - \param locale locale string, eg. en_EN |
1163 | - \param form_factor form factor name, e.g. phone, desktop, phone-version etc. |
1164 | - */ |
1165 | QSearchMetadataImpl(int cardinality, QString const& locale, QString const& form_factor); |
1166 | + ~QSearchMetadataImpl(); |
1167 | |
1168 | - /**@name Copy and assignment |
1169 | - Copy and assignment operators (move and non-move versions) have the usual value semantics. |
1170 | - */ |
1171 | - //{@ |
1172 | QSearchMetadataImpl(QSearchMetadataImpl const& other); |
1173 | QSearchMetadataImpl(QSearchMetadataImpl&&); |
1174 | |
1175 | QSearchMetadataImpl& operator=(QSearchMetadataImpl const& other); |
1176 | QSearchMetadataImpl& operator=(QSearchMetadataImpl&&); |
1177 | - //@} |
1178 | - |
1179 | - /// @cond |
1180 | - ~QSearchMetadataImpl(); |
1181 | - /// @endcond |
1182 | - |
1183 | - /** |
1184 | - \brief Set cardinality. |
1185 | - \param cardinality The maximum number of search results. |
1186 | - */ |
1187 | + |
1188 | void set_cardinality(int cardinality); |
1189 | - |
1190 | - /** |
1191 | - \brief Get cardinality. |
1192 | - \return The maxmium number of search results, or 0 for no limit. |
1193 | - */ |
1194 | int cardinality() const; |
1195 | - |
1196 | - /** |
1197 | - \brief Set location. |
1198 | - \param location Location data. |
1199 | - */ |
1200 | void set_location(Location const& location); |
1201 | - |
1202 | - /** |
1203 | - \brief Get location. |
1204 | - \return Location data representing the current location, including attributes such as city and country. |
1205 | - \throws unity::NotFoundException if no location data is available. |
1206 | - */ |
1207 | Location location() const; |
1208 | - |
1209 | - /** |
1210 | - \brief Does the SearchMetadata have a location. |
1211 | - \return True if there is a location property. |
1212 | - */ |
1213 | bool has_location() const; |
1214 | - |
1215 | - /** |
1216 | - \brief Sets a hint. |
1217 | - |
1218 | - \param key The name of the hint. |
1219 | - \param value Hint value |
1220 | - */ |
1221 | void set_hint(QString const& key, QVariant const& value); |
1222 | - |
1223 | - /** |
1224 | - \brief Get all hints. |
1225 | - |
1226 | - \return Hints dictionary. |
1227 | - \throws unity::NotFoundException if no hints are available. |
1228 | - */ |
1229 | QVariantMap hints() const; |
1230 | - |
1231 | - /** |
1232 | - \brief Check if this SearchMetadata has a hint. |
1233 | - \param key The hint name. |
1234 | - \return True if the hint is set. |
1235 | - */ |
1236 | bool contains_hint(QString const& key) const; |
1237 | - |
1238 | - /** |
1239 | - \brief Returns a reference to a hint. |
1240 | - |
1241 | - This method can be used to read or set hints. Setting a value of an existing hint overwrites |
1242 | - its previous value. |
1243 | - Referencing a non-existing hint automatically creates it with a default value of Variant::Type::Null. |
1244 | - \param key The name of the hint. |
1245 | - \return A reference to the hint. |
1246 | - */ |
1247 | QScopeVariant& operator[](QString const& key); |
1248 | - |
1249 | - /** |
1250 | - \brief Returns a const reference to a hint. |
1251 | - |
1252 | - This method can be used for read-only access to hints. |
1253 | - Referencing a non-existing hint throws unity::InvalidArgumentException. |
1254 | - \param key The name of the hint. |
1255 | - \return A const reference to the hint. |
1256 | - \throws unity::NotFoundException if no hint with the given name exists. |
1257 | - */ |
1258 | QVariant const& value(QString const& key) const; |
1259 | |
1260 | private: |
1261 | |
1262 | === modified file 'include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h' |
1263 | --- include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h 2015-02-02 07:46:12 +0000 |
1264 | +++ include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h 2015-02-25 12:37:38 +0000 |
1265 | @@ -50,41 +50,15 @@ |
1266 | friend QSearchQueryBase; |
1267 | |
1268 | public: |
1269 | - /// @cond |
1270 | NONCOPYABLE(QSearchQueryBaseImpl); |
1271 | UNITY_DEFINES_PTRS(QSearchQueryBaseImpl); |
1272 | - /// @endcond |
1273 | |
1274 | QSearchQueryBaseImpl(); |
1275 | ~QSearchQueryBaseImpl() = default; |
1276 | |
1277 | - /** |
1278 | - \brief Get a canned query for this search request. |
1279 | - |
1280 | - \return The canned query. |
1281 | - \throws unity::LogicException if the canned query was not initialized (was default-constructed). |
1282 | - */ |
1283 | QCannedQuery query() const; |
1284 | - |
1285 | - /** |
1286 | - \brief Get metadata for this search request. |
1287 | - \return The search metadata. |
1288 | - \throws unity::LogicException if search metadata was not initialized (was default-constructed). |
1289 | - */ |
1290 | unity::scopes::SearchMetadata search_metadata() const; |
1291 | |
1292 | - /** @name Subquery methods |
1293 | - The subsearch() methods are for use by aggregating scopes. |
1294 | - When an aggregator passes a query to its child scopes, it should |
1295 | - use subsearch() instead of the normal Scope::search() |
1296 | - that would be called by a client. subsearch() takes care |
1297 | - of automatically forwarding query cancellation to child scopes. |
1298 | - This means that there is no need for an aggregating scope to |
1299 | - explicitly forward cancellation to child scopes |
1300 | - when its QueryBase::cancelled() method is called by the scopes |
1301 | - run time. |
1302 | - */ |
1303 | - //{@ |
1304 | QueryCtrlProxy subsearch(ScopeProxy const& scope, |
1305 | std::string const& query_string, |
1306 | SearchListenerBase::SPtr const& reply); |
1307 | |
1308 | === modified file 'include/unity/scopes/qt/internal/QSearchReplyImpl.h' |
1309 | --- include/unity/scopes/qt/internal/QSearchReplyImpl.h 2015-02-02 07:46:12 +0000 |
1310 | +++ include/unity/scopes/qt/internal/QSearchReplyImpl.h 2015-02-25 12:37:38 +0000 |
1311 | @@ -52,96 +52,17 @@ |
1312 | friend class unity::scopes::qt::QSearchReply; |
1313 | |
1314 | public: |
1315 | - /// @cond |
1316 | NONCOPYABLE(QSearchReplyImpl); |
1317 | UNITY_DEFINES_PTRS(QSearchReplyImpl); |
1318 | - /// @endcond |
1319 | - /** |
1320 | - \brief Destroys a QSearchReplyImpl. |
1321 | - */ |
1322 | + |
1323 | virtual ~QSearchReplyImpl(); |
1324 | - |
1325 | - /** |
1326 | - \brief Register departments for the current search reply and provide the current department. |
1327 | - |
1328 | - Departments are optional. If scope supports departments, it is expected to register departments on every search as |
1329 | - follows: |
1330 | - |
1331 | - <ul> |
1332 | - <li>create a Department node for current department and attach to it a list of its subdepartments (unless current |
1333 | - department is a leaf department) using |
1334 | - unity::scopes::Department::set_subdepartments() method. For every subdepartment on the list set |
1335 | - "has_subdepartments" flag if applicable. |
1336 | - <li>provide an alternate label for current department with unity::scopes::Department::set_alternate_label(). |
1337 | - <li>create a Department node for parent of current department (if applicable - not when in root department), and |
1338 | - attach current Department node to it with |
1339 | - unity::scopes::Department::set_subdepartments() method. |
1340 | - <li>register the parent department with unity::scopes::SearchReply::register_departments(). |
1341 | - </ul> |
1342 | - |
1343 | - For example, assuming the user is visiting a "History" department in "Books", and "History" has sub-departments |
1344 | - such as "World War Two" and "Ancient", the code |
1345 | - that registers departments for current search in "History" may look like this: |
1346 | - \code{.cpp} |
1347 | - unity::scopes::Department::SPtr books = move(unity::scopes::Department::create("books", query, "Books")); // the |
1348 | - parent of "History" |
1349 | - unity::scopes::Department::SPtr history = move(unity::scopes::Department::create("history", query, "History")); |
1350 | - unity::scopes::DepartmentList history_depts({ |
1351 | - move(unity::scopes::Department::create("ww2", query, "World War Two")), |
1352 | - move(unity::scopes::Department::create("ancient", query, "Ancient"))}); |
1353 | - history->set_subdepartments(history_depts); |
1354 | - books->set_subdepartments({history}); |
1355 | - reply->register_departments(books); |
1356 | - \endcode |
1357 | - |
1358 | - Current department should be the department returned by unity::scopes::CannedQuery::department_id(). Empty |
1359 | - department id denotes |
1360 | - the root deparment. |
1361 | - |
1362 | - \param parent The parent department of current department, or current one if visiting root department. |
1363 | - \throws unity::LogicException if departments are invalid (nullptr passed, current department not present in the |
1364 | - parent's tree, duplicated department ids present in the tree). |
1365 | - */ |
1366 | virtual void register_departments(QDepartment::SCPtr const& parent); |
1367 | - |
1368 | - /** |
1369 | - \brief Register new category and send it to the source of the query. |
1370 | - |
1371 | - \param id The identifier of the category |
1372 | - \param title The title of the category |
1373 | - \param icon The icon of the category |
1374 | - \param renderer_template The renderer template to be used for results in this category |
1375 | - |
1376 | - \return The category instance |
1377 | - \throws unity::scopes::InvalidArgumentException if category with that id has already been registered. |
1378 | - */ |
1379 | QCategory::SCPtr register_category( |
1380 | QString const& id, |
1381 | QString const& title, |
1382 | QString const& icon, |
1383 | unity::scopes::CategoryRenderer const& renderer_template = unity::scopes::CategoryRenderer()); |
1384 | - |
1385 | - /** |
1386 | - \brief Sends a single result to the source of a query. |
1387 | - |
1388 | - Any calls to push() after finished() was called are ignored. |
1389 | - \return The return value is true if the result was accepted, false otherwise. |
1390 | - A false return value can be due to finished() having been called earlier, |
1391 | - or the client that sent the query having cancelled that query. The return |
1392 | - value is false also if the query has a cardinality limit and is reached |
1393 | - or exceeded. (The return value is false for the last valid push and |
1394 | - subsequent pushes.) |
1395 | - */ |
1396 | bool push(QCategorisedResult const& result); |
1397 | - |
1398 | - /** |
1399 | - \brief Informs the source of a query that the query was terminated due to an error. |
1400 | - |
1401 | - Multiple calls to error() and calls to finished() after error() was called are ignored. |
1402 | - \param ex An exception_ptr indicating the cause of the error. If ex is a `std::exception`, |
1403 | - the return value of `what()` is made available to the query source. Otherwise, |
1404 | - the query source receives `"unknown exception"`. |
1405 | - */ |
1406 | void error(std::exception_ptr ex); |
1407 | |
1408 | protected: |
1409 | |
1410 | === modified file 'include/unity/scopes/qt/internal/QUtils.h' |
1411 | --- include/unity/scopes/qt/internal/QUtils.h 2015-02-25 12:37:37 +0000 |
1412 | +++ include/unity/scopes/qt/internal/QUtils.h 2015-02-25 12:37:38 +0000 |
1413 | @@ -18,10 +18,6 @@ |
1414 | |
1415 | #pragma once |
1416 | |
1417 | -#ifndef _ENABLE_QT_EXPERIMENTAL_ |
1418 | -#error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file. |
1419 | -#endif |
1420 | - |
1421 | #pragma GCC diagnostic push |
1422 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
1423 | #include <QtCore/QVariant> |
1424 | |
1425 | === modified file 'src/scopes/qt/QActionMetadata.cpp' |
1426 | --- src/scopes/qt/QActionMetadata.cpp 2015-01-26 15:25:30 +0000 |
1427 | +++ src/scopes/qt/QActionMetadata.cpp 2015-02-25 12:37:38 +0000 |
1428 | @@ -32,7 +32,7 @@ |
1429 | } |
1430 | |
1431 | QActionMetadata::QActionMetadata(internal::QActionMetadataImpl* impl) |
1432 | - : p(new internal::QActionMetadataImpl(*impl)) |
1433 | + : p(impl) |
1434 | { |
1435 | } |
1436 | |
1437 | |
1438 | === modified file 'src/scopes/qt/QPreviewWidget.cpp' |
1439 | --- src/scopes/qt/QPreviewWidget.cpp 2015-01-20 14:14:26 +0000 |
1440 | +++ src/scopes/qt/QPreviewWidget.cpp 2015-02-25 12:37:38 +0000 |
1441 | @@ -104,7 +104,7 @@ |
1442 | } |
1443 | |
1444 | QPreviewWidget::QPreviewWidget(internal::QPreviewWidgetImpl* widget) |
1445 | - : p(new internal::QPreviewWidgetImpl(*widget)) |
1446 | + : p(widget) |
1447 | { |
1448 | } |
1449 | /// @endcond |
1450 | |
1451 | === modified file 'src/scopes/qt/QResult.cpp' |
1452 | --- src/scopes/qt/QResult.cpp 2015-02-25 12:37:37 +0000 |
1453 | +++ src/scopes/qt/QResult.cpp 2015-02-25 12:37:38 +0000 |
1454 | @@ -24,11 +24,6 @@ |
1455 | using namespace unity::scopes::qt; |
1456 | |
1457 | /// @cond |
1458 | -QResult::QResult() |
1459 | - : p(new internal::QResultImpl(QVariantMap())) |
1460 | -{ |
1461 | -} |
1462 | - |
1463 | QResult::QResult(internal::QResultImpl* impl) |
1464 | : p(impl) |
1465 | { |
1466 | @@ -123,7 +118,7 @@ |
1467 | |
1468 | QVariant const& QResult::operator[](QString const& key) const |
1469 | { |
1470 | - return p->value(key); |
1471 | + return (*static_cast<internal::QResultImpl const*>(p.get()))[key]; |
1472 | } |
1473 | |
1474 | QString QResult::uri() const noexcept |
1475 | |
1476 | === modified file 'src/scopes/qt/internal/QResultImpl.cpp' |
1477 | --- src/scopes/qt/internal/QResultImpl.cpp 2015-02-25 12:37:37 +0000 |
1478 | +++ src/scopes/qt/internal/QResultImpl.cpp 2015-02-25 12:37:38 +0000 |
1479 | @@ -28,61 +28,19 @@ |
1480 | using namespace unity::scopes::qt; |
1481 | using namespace unity::scopes::qt::internal; |
1482 | |
1483 | -namespace unity |
1484 | -{ |
1485 | - |
1486 | -namespace scopes |
1487 | -{ |
1488 | - |
1489 | -namespace qt |
1490 | -{ |
1491 | - |
1492 | -namespace internal |
1493 | +namespace |
1494 | { |
1495 | |
1496 | class APIResult : public Result |
1497 | { |
1498 | public: |
1499 | - APIResult(APIResult const& other) |
1500 | - : Result(other){}; |
1501 | - |
1502 | - APIResult(APIResult&&) = default; |
1503 | - |
1504 | - APIResult& operator=(APIResult const& other) |
1505 | - { |
1506 | - if (this != &other) |
1507 | - { |
1508 | - *this = other; |
1509 | - } |
1510 | - return *this; |
1511 | - } |
1512 | - |
1513 | - APIResult& operator=(APIResult&&) = default; |
1514 | - |
1515 | APIResult(const QVariantMap& variant_map) |
1516 | - : Result(qvariantmap_to_variantmap(variant_map)){}; |
1517 | - |
1518 | - static VariantMap getValidEmptyMap() |
1519 | + : Result(qvariantmap_to_variantmap(variant_map)) |
1520 | { |
1521 | - VariantMap retMap; |
1522 | - VariantMap emptyMap; |
1523 | - VariantMap attrsMap; |
1524 | - |
1525 | - attrsMap["uri"] = Variant(std::string()); |
1526 | - retMap["internal"] = emptyMap; |
1527 | - retMap["attrs"] = attrsMap; |
1528 | - |
1529 | - return retMap; |
1530 | } |
1531 | }; |
1532 | |
1533 | -} // namespace internal |
1534 | - |
1535 | -} // namespace qt |
1536 | - |
1537 | -} // namespace scopes |
1538 | - |
1539 | -} // namespace unity |
1540 | +} // namespace |
1541 | |
1542 | QResultImpl::QResultImpl(unity::scopes::Result* api_result) |
1543 | : api_result_(api_result) |
1544 | @@ -95,8 +53,9 @@ |
1545 | } |
1546 | |
1547 | QResultImpl::QResultImpl(internal::QResultImpl* impl) |
1548 | - : api_result_(impl->api_result_.get()) |
1549 | { |
1550 | + impl->sync_values(); |
1551 | + api_result_.reset(new Result(*(impl->api_result_))); |
1552 | } |
1553 | |
1554 | QResultImpl::QResultImpl(QResultImpl const& other) |
1555 | |
1556 | === modified file 'src/scopes/qt/internal/QScopeBaseAPIImpl.cpp' |
1557 | --- src/scopes/qt/internal/QScopeBaseAPIImpl.cpp 2015-02-25 12:37:37 +0000 |
1558 | +++ src/scopes/qt/internal/QScopeBaseAPIImpl.cpp 2015-02-25 12:37:38 +0000 |
1559 | @@ -78,16 +78,10 @@ |
1560 | |
1561 | } // namespace unity |
1562 | |
1563 | -QScopeBaseAPIImpl::QScopeBaseAPIImpl(QScopeBase& qtscope, QObject* parent) |
1564 | - : QObject(parent) |
1565 | - , qtapp_ready_(false) |
1566 | - , qtscope_impl_(&qtscope) |
1567 | -{ |
1568 | -} |
1569 | - |
1570 | -QScopeBaseAPIImpl::QScopeBaseAPIImpl(FactoryFunc const& creator, QObject* parent) |
1571 | - : QObject(parent) |
1572 | - , qtapp_ready_(false) |
1573 | +QScopeBaseAPIImpl::QScopeBaseAPIImpl(FactoryFunc const& creator) |
1574 | + : QObject(nullptr) |
1575 | + , qtapp_ready_(false) |
1576 | + , qtapp_stopped_(false) |
1577 | , qtscope_impl_(nullptr) |
1578 | , qtscope_creator_(creator) |
1579 | { |
1580 | @@ -109,11 +103,8 @@ |
1581 | case Start: |
1582 | // create the client's scope in the |
1583 | // Qt main thread |
1584 | - if (!qtscope_impl_) |
1585 | - { |
1586 | - qtscope_impl_ = qtscope_creator_(); |
1587 | - assert(qtscope_impl_); |
1588 | - } |
1589 | + qtscope_impl_.reset(qtscope_creator_()); |
1590 | + assert(qtscope_impl_); |
1591 | // Move the user's scope to the Qt main thread |
1592 | qtscope_impl_->moveToThread(qtapp_->thread()); |
1593 | |
1594 | @@ -132,15 +123,14 @@ |
1595 | return true; |
1596 | } |
1597 | |
1598 | -void QScopeBaseAPIImpl::start(std::string const& scope_id) |
1599 | +void QScopeBaseAPIImpl::start(string const& scope_id) |
1600 | { |
1601 | // start the QT thread |
1602 | // TODO change to make_unique when using C++14 |
1603 | - qtthread_ = std::unique_ptr<std::thread>(new std::thread(&QScopeBaseAPIImpl::startQtThread, this)); |
1604 | + qtthread_ = unique_ptr<std::thread>(new std::thread(&QScopeBaseAPIImpl::start_qt_thread, this)); |
1605 | while (!qtapp_ready_) |
1606 | { |
1607 | - std::chrono::milliseconds dura(10); |
1608 | - std::this_thread::sleep_for(dura); |
1609 | + this_thread::sleep_for(chrono::milliseconds(10)); |
1610 | } |
1611 | |
1612 | // Move this class to the Qt main thread |
1613 | @@ -153,7 +143,7 @@ |
1614 | |
1615 | void QScopeBaseAPIImpl::stop() |
1616 | { |
1617 | - // Post event to initialize the object in the Qt thread |
1618 | + // Post event to stop the object in the Qt thread |
1619 | qtapp_->postEvent(this, new StopEvent()); |
1620 | } |
1621 | |
1622 | @@ -176,16 +166,17 @@ |
1623 | return sc::SearchQueryBase::UPtr(query_api); |
1624 | } |
1625 | |
1626 | -void QScopeBaseAPIImpl::startQtThread() |
1627 | +void QScopeBaseAPIImpl::start_qt_thread() |
1628 | { |
1629 | if (!QCoreApplication::instance()) |
1630 | { |
1631 | int argc = 0; |
1632 | char* argv = NULL; |
1633 | - qtapp_ = std::make_shared<QCoreApplication>(argc, &argv); |
1634 | + qtapp_ = make_shared<QCoreApplication>(argc, &argv); |
1635 | qtapp_ready_ = true; |
1636 | qtapp_->exec(); |
1637 | // delete QtCoreApplication in the same thread it was created |
1638 | qtapp_.reset(); |
1639 | + qtapp_stopped_ = true; |
1640 | } |
1641 | } |
1642 | |
1643 | === modified file 'test/gtest/scopes/qt/qt-bindings/CMakeLists.txt' |
1644 | --- test/gtest/scopes/qt/qt-bindings/CMakeLists.txt 2015-02-25 12:37:37 +0000 |
1645 | +++ test/gtest/scopes/qt/qt-bindings/CMakeLists.txt 2015-02-25 12:37:38 +0000 |
1646 | @@ -222,3 +222,22 @@ |
1647 | qt5_use_modules(QScopeCreation_test Core) |
1648 | |
1649 | add_test(QScopeCreation QScopeCreation_test) |
1650 | + |
1651 | +################################################### |
1652 | + |
1653 | +add_executable( |
1654 | + QPreviewWidget_test |
1655 | + QPreviewWidget_test.cpp) |
1656 | + |
1657 | +target_link_libraries( |
1658 | + QPreviewWidget_test |
1659 | + ${LIBGTEST} |
1660 | + ${TESTLIBS_QT} |
1661 | + ${TESTLIBS}) |
1662 | + |
1663 | +find_package(Qt5Core REQUIRED) |
1664 | +include_directories(${Qt5Core_INCLUDE_DIRS}) |
1665 | + |
1666 | +qt5_use_modules(QPreviewWidget_test Core) |
1667 | + |
1668 | +add_test(QPreviewWidget QPreviewWidget_test) |
1669 | |
1670 | === modified file 'test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp' |
1671 | --- test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp 2015-02-25 12:37:37 +0000 |
1672 | +++ test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp 2015-02-25 12:37:38 +0000 |
1673 | @@ -23,11 +23,15 @@ |
1674 | |
1675 | #include <unity/scopes/qt/internal/QCategorisedResultImpl.h> |
1676 | #include <unity/scopes/qt/internal/QCategoryImpl.h> |
1677 | +#include <unity/scopes/qt/internal/QUtils.h> |
1678 | |
1679 | +#include <unity/scopes/CategorisedResult.h> |
1680 | #include <unity/scopes/Category.h> |
1681 | #include <unity/scopes/CategoryRenderer.h> |
1682 | #include <unity/scopes/internal/CategoryRegistry.h> |
1683 | |
1684 | +#include <unity/UnityExceptions.h> |
1685 | + |
1686 | using namespace unity::scopes; |
1687 | using namespace unity::scopes::internal; |
1688 | using namespace unity::scopes::qt; |
1689 | @@ -106,3 +110,115 @@ |
1690 | EXPECT_EQ("2", ri1.category()->id()); |
1691 | } |
1692 | } |
1693 | + |
1694 | +// Tests for QResult base class |
1695 | + |
1696 | +TEST(QCategorisedResult, QResult) |
1697 | +{ |
1698 | + std::shared_ptr<QCategory const> out_cat = QCategorisedResult_test::create_category("1"); |
1699 | + std::shared_ptr<QCategory const> in_cat = QCategorisedResult_test::create_category("2"); |
1700 | + |
1701 | + QCategorisedResult out_result(out_cat); |
1702 | + out_result.set_uri("test_uri1"); |
1703 | + out_result.set_title("title1"); |
1704 | + out_result.set_art("art1"); |
1705 | + out_result.set_dnd_uri("dnd_uri1"); |
1706 | + out_result["key"] = "value"; |
1707 | + EXPECT_EQ("test_uri1", out_result.uri()); |
1708 | + EXPECT_EQ("title1", out_result.title()); |
1709 | + EXPECT_EQ("art1", out_result.art()); |
1710 | + EXPECT_EQ("dnd_uri1", out_result.dnd_uri()); |
1711 | + EXPECT_TRUE(out_result.contains("key")); |
1712 | + EXPECT_EQ("value", out_result.value("key")); |
1713 | + try |
1714 | + { |
1715 | + out_result.target_scope_proxy(); |
1716 | + FAIL(); |
1717 | + } |
1718 | + catch (unity::LogicException const& e) |
1719 | + { |
1720 | + EXPECT_STREQ("unity::LogicException: Result::target_scope_proxy(): undefined target scope", e.what()); |
1721 | + } |
1722 | + |
1723 | + EXPECT_TRUE(out_result.direct_activation()); |
1724 | + out_result.set_intercept_activation(); |
1725 | + EXPECT_FALSE(out_result.direct_activation()); |
1726 | + |
1727 | + // TODO: No way to get JSON from Qvariant at the moment. |
1728 | + std::string json = Variant(qt::internal::qvariantmap_to_variantmap(out_result.serialize())).serialize_json(); |
1729 | + std::string expected = std::string(R"({"attrs":{"art":"art1","dnd_uri":"dnd_uri1","key":"value","title":"title1","uri":"test_uri1"},"internal":{"cat_id":"1","flags":1}})") + "\n"; |
1730 | + EXPECT_EQ(expected, json); |
1731 | + |
1732 | + QCategorisedResult in_result(in_cat); |
1733 | + in_result.set_uri("test_uri2"); |
1734 | + in_result.set_title("title2"); |
1735 | + |
1736 | + EXPECT_FALSE(out_result.has_stored_result()); |
1737 | + out_result.store(in_result); |
1738 | + EXPECT_TRUE(out_result.has_stored_result()); |
1739 | + |
1740 | + QResult r = out_result.retrieve(); |
1741 | + EXPECT_EQ(in_result.uri(), r.uri()); // TODO: Can't use in_result == r here because retrive() slices the class :-( |
1742 | + // That's a flaw in the underlying API |
1743 | + QResult const qvc(out_result); |
1744 | + EXPECT_EQ("value", qvc["key"]); |
1745 | + |
1746 | + // Copy and assignment |
1747 | + |
1748 | + { |
1749 | + QResult c(out_result); |
1750 | + EXPECT_EQ("title1", c.title()); |
1751 | + } |
1752 | + |
1753 | + { |
1754 | + QResult c(out_result); |
1755 | + c = in_result; |
1756 | + EXPECT_EQ("title2", c.title()); |
1757 | + c = c; |
1758 | + EXPECT_EQ("title2", c.title()); |
1759 | + } |
1760 | + |
1761 | + { |
1762 | + CategoryRegistry reg; |
1763 | + CategoryRenderer rdr; |
1764 | + auto cat = reg.register_category("1", "title", "icon", nullptr, rdr); |
1765 | + CategorisedResult result(cat); |
1766 | + result.set_title("t"); |
1767 | + |
1768 | + // QResult construction from Result is protected. |
1769 | + struct Tester : public QResult |
1770 | + { |
1771 | + Tester(Result const& result) |
1772 | + : QResult(result) |
1773 | + { |
1774 | + } |
1775 | + }; |
1776 | + |
1777 | + Tester t(result); |
1778 | + EXPECT_EQ("t", t.title()); |
1779 | + |
1780 | + // QResultImpl construction from QResultImpl* is protected. |
1781 | + struct ImplTester : public qt::internal::QResultImpl |
1782 | + { |
1783 | + ImplTester(QResultImpl* qri) |
1784 | + : QResultImpl(qri) |
1785 | + { |
1786 | + } |
1787 | + |
1788 | + ImplTester(Result const& r) |
1789 | + : QResultImpl(r) |
1790 | + { |
1791 | + EXPECT_EQ("t", r.title()); |
1792 | + qt::internal::QResultImpl* qrip = new QResultImpl(r); |
1793 | + EXPECT_EQ("t", qrip->title()); |
1794 | + |
1795 | + // This is the real test to see that this constructor works |
1796 | + ImplTester copy(qrip); |
1797 | + EXPECT_EQ("t", copy.title()); |
1798 | + delete qrip; |
1799 | + } |
1800 | + }; |
1801 | + |
1802 | + ImplTester it(result); |
1803 | + } |
1804 | +} |
1805 | |
1806 | === modified file 'test/gtest/scopes/qt/qt-bindings/QMockScope.h' |
1807 | --- test/gtest/scopes/qt/qt-bindings/QMockScope.h 2015-02-25 12:37:37 +0000 |
1808 | +++ test/gtest/scopes/qt/qt-bindings/QMockScope.h 2015-02-25 12:37:38 +0000 |
1809 | @@ -24,16 +24,19 @@ |
1810 | |
1811 | #include <QtCore/QThread> |
1812 | |
1813 | +#include <mutex> |
1814 | + |
1815 | class QScopeMock : public QScope |
1816 | { |
1817 | public: |
1818 | QScopeMock() |
1819 | : QScope() |
1820 | - , qt_thread(nullptr){}; |
1821 | + , qt_thread_(nullptr){}; |
1822 | |
1823 | - void setQtThread(QThread* thread) |
1824 | + void set_qt_thread(QThread* thread) |
1825 | { |
1826 | - qt_thread = thread; |
1827 | + std::lock_guard<std::mutex> lock(mutex_); |
1828 | + qt_thread_ = thread; |
1829 | } |
1830 | |
1831 | MOCK_METHOD1(start, void(QString const&)); |
1832 | @@ -41,17 +44,20 @@ |
1833 | virtual unity::scopes::qt::QPreviewQueryBase::UPtr preview(const unity::scopes::qt::QResult&, |
1834 | const unity::scopes::qt::QActionMetadata&) override |
1835 | { |
1836 | - EXPECT_EQ(QThread::currentThread(), qt_thread); |
1837 | + std::lock_guard<std::mutex> lock(mutex_); |
1838 | + EXPECT_EQ(QThread::currentThread(), qt_thread_); |
1839 | return unity::scopes::qt::QPreviewQueryBase::UPtr(new QPreview()); |
1840 | } |
1841 | |
1842 | virtual unity::scopes::qt::QSearchQueryBase::UPtr search(unity::scopes::CannedQuery const&, |
1843 | unity::scopes::SearchMetadata const&) override |
1844 | { |
1845 | - EXPECT_EQ(QThread::currentThread(), qt_thread); |
1846 | + std::lock_guard<std::mutex> lock(mutex_); |
1847 | + EXPECT_EQ(QThread::currentThread(), qt_thread_); |
1848 | return unity::scopes::qt::QSearchQueryBase::UPtr(new QQuery()); |
1849 | } |
1850 | |
1851 | protected: |
1852 | - QThread* qt_thread; |
1853 | + QThread* qt_thread_; |
1854 | + std::mutex mutex_; |
1855 | }; |
1856 | |
1857 | === modified file 'test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp' |
1858 | --- test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp 2015-02-25 12:37:37 +0000 |
1859 | +++ test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp 2015-02-25 12:37:38 +0000 |
1860 | @@ -138,10 +138,10 @@ |
1861 | { |
1862 | QScope scope; |
1863 | |
1864 | - unity::scopes::internal::ResultImpl* resultImpl = new unity::scopes::internal::ResultImpl(); |
1865 | - resultImpl->set_uri("test_uri"); |
1866 | + unity::scopes::internal::ResultImpl resultImpl; |
1867 | + resultImpl.set_uri("test_uri"); |
1868 | |
1869 | - unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl->serialize()); |
1870 | + unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl.serialize()); |
1871 | |
1872 | unity::scopes::CannedQuery query("scopeA", "query", "department"); |
1873 | unity::scopes::ActionMetadata metadata("en", "phone"); |
1874 | |
1875 | === added file 'test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp' |
1876 | --- test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp 1970-01-01 00:00:00 +0000 |
1877 | +++ test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp 2015-02-25 12:37:38 +0000 |
1878 | @@ -0,0 +1,117 @@ |
1879 | +/* |
1880 | + * Copyright (C) 2015 Canonical Ltd |
1881 | + * |
1882 | + * This program is free software: you can redistribute it and/or modify |
1883 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1884 | + * published by the Free Software Foundation. |
1885 | + * |
1886 | + * This program is distributed in the hope that it will be useful, |
1887 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1888 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1889 | + * GNU Lesser General Public License for more details. |
1890 | + * |
1891 | + * You should have received a copy of the GNU Lesser General Public License |
1892 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1893 | + * |
1894 | + * Authored by: Michi Henning <michi.henning@canonical.com> |
1895 | + */ |
1896 | + |
1897 | +#include <gtest/gtest.h> |
1898 | + |
1899 | +#include <unity/scopes/qt/QPreviewWidget.h> |
1900 | +#include <unity/scopes/qt/internal/QPreviewWidgetImpl.h> |
1901 | + |
1902 | +using namespace unity::scopes::qt; |
1903 | + |
1904 | +TEST(QPreviewWidget, bindings) |
1905 | +{ |
1906 | + { |
1907 | + QPreviewWidget qpw("id", "video"); |
1908 | + |
1909 | + EXPECT_EQ("id", qpw.id()); |
1910 | + EXPECT_EQ("video", qpw.widget_type()); |
1911 | + } |
1912 | + |
1913 | + { |
1914 | + QPreviewWidget qpw(R"({"id": "img", "type": "image", "components": { "source": "screenshot-url" } })"); |
1915 | + |
1916 | + EXPECT_EQ("img", qpw.id()); |
1917 | + EXPECT_EQ("image", qpw.widget_type()); |
1918 | + |
1919 | + auto am = qpw.attribute_mappings(); |
1920 | + ASSERT_EQ(1, am.size()); |
1921 | + EXPECT_EQ("screenshot-url", am.value("source")); |
1922 | + |
1923 | + auto av = qpw.attribute_values(); |
1924 | + ASSERT_EQ(0, av.size()); |
1925 | + |
1926 | + auto widgets = qpw.widgets(); |
1927 | + ASSERT_EQ(0, widgets.size()); |
1928 | + |
1929 | + QPreviewWidget qpw2(qpw); |
1930 | + |
1931 | + EXPECT_EQ("img", qpw2.id()); |
1932 | + EXPECT_EQ("image", qpw2.widget_type()); |
1933 | + |
1934 | + QPreviewWidget qpw3("xxx", "audio"); |
1935 | + qpw3 = qpw2; |
1936 | + EXPECT_EQ("img", qpw3.id()); |
1937 | + EXPECT_EQ("image", qpw3.widget_type()); |
1938 | + |
1939 | + qpw3 = qpw3; |
1940 | + EXPECT_EQ("img", qpw3.id()); |
1941 | + EXPECT_EQ("image", qpw3.widget_type()); |
1942 | + |
1943 | + QPreviewWidget parent_widget("parent", "expandable"); |
1944 | + parent_widget.add_widget(qpw); |
1945 | + widgets = parent_widget.widgets(); |
1946 | + ASSERT_EQ(1, widgets.size()); |
1947 | + EXPECT_EQ("img", widgets.at(0).id()); |
1948 | + |
1949 | + qpw.add_attribute_value("key", "value"); |
1950 | + av = qpw.attribute_values(); |
1951 | + ASSERT_EQ(1, av.size()); |
1952 | + EXPECT_EQ("value", av.value("key")); |
1953 | + |
1954 | + qpw.add_attribute_mapping("attr", "field"); |
1955 | + am = qpw.attribute_mappings(); |
1956 | + ASSERT_EQ(2, am.size()); |
1957 | + EXPECT_EQ("field", am.value("attr")); |
1958 | + } |
1959 | + |
1960 | + { |
1961 | + QString data = R"({"components":{"source":"screenshot-url"},"id":"img","key":"value","type":"image"})"; |
1962 | + QPreviewWidget qpw(data); |
1963 | + EXPECT_EQ(data + "\n", qpw.data()); // Underlying scopes API appends a newline |
1964 | + |
1965 | + auto vm = qpw.serialize(); |
1966 | + ASSERT_EQ(4, vm.size()); |
1967 | + EXPECT_EQ("img", vm.value("id")); |
1968 | + EXPECT_EQ("image", vm.value("type")); |
1969 | + auto attrs = vm.value("attributes").toMap(); |
1970 | + ASSERT_EQ(1, attrs.size()); |
1971 | + EXPECT_EQ("value", attrs.value("key").toString()); |
1972 | + auto components = vm.value("components").toMap(); |
1973 | + ASSERT_EQ(1, components.size()); |
1974 | + EXPECT_EQ("screenshot-url", components.value("source").toString()); |
1975 | + } |
1976 | + |
1977 | + { |
1978 | + internal::QPreviewWidgetImpl i("id", "audio"); |
1979 | + EXPECT_EQ("id", i.id()); |
1980 | + EXPECT_EQ("audio", i.widget_type()); |
1981 | + |
1982 | + internal::QPreviewWidgetImpl i2(i); |
1983 | + EXPECT_EQ("id", i2.id()); |
1984 | + EXPECT_EQ("audio", i2.widget_type()); |
1985 | + |
1986 | + internal::QPreviewWidgetImpl i3("xxx", "video"); |
1987 | + i = i3; |
1988 | + EXPECT_EQ("xxx", i.id()); |
1989 | + EXPECT_EQ("video", i.widget_type()); |
1990 | + |
1991 | + i = i; |
1992 | + EXPECT_EQ("xxx", i.id()); |
1993 | + EXPECT_EQ("video", i.widget_type()); |
1994 | + } |
1995 | +} |
1996 | |
1997 | === modified file 'test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp' |
1998 | --- test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp 2015-02-25 12:37:37 +0000 |
1999 | +++ test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp 2015-02-25 12:37:38 +0000 |
2000 | @@ -35,33 +35,33 @@ |
2001 | |
2002 | TEST(TestSetup, bindings) |
2003 | { |
2004 | - QScopeMock scope; |
2005 | + QScopeMock* scope = new QScopeMock; |
2006 | |
2007 | // construct the QSearchQueryBaseAPIMock |
2008 | - QScopeBaseAPIMock api_scope(scope); |
2009 | + QScopeBaseAPIMock api_scope([scope]{ return scope; }); |
2010 | |
2011 | // verify that the event method is called for start event |
2012 | - EXPECT_CALL(scope, start(_)).Times(Exactly(1)); |
2013 | + EXPECT_CALL(*scope, start(_)).Times(Exactly(1)); |
2014 | api_scope.start("test_scope"); |
2015 | |
2016 | - QThread* qt_thread = api_scope.getQtAppThread(); |
2017 | - scope.setQtThread(qt_thread); |
2018 | + QThread* qt_thread = api_scope.get_qt_app_thread(); |
2019 | + scope->set_qt_thread(qt_thread); |
2020 | |
2021 | - auto CheckThread = [qt_thread]() -> void |
2022 | + auto check_thread = [qt_thread]() -> void |
2023 | { |
2024 | EXPECT_EQ(qt_thread, QThread::currentThread()); |
2025 | }; |
2026 | |
2027 | - unity::scopes::internal::ResultImpl* resultImpl = new unity::scopes::internal::ResultImpl(); |
2028 | - resultImpl->set_uri("test_uri"); |
2029 | + unity::scopes::internal::ResultImpl resultImpl; |
2030 | + resultImpl.set_uri("test_uri"); |
2031 | |
2032 | - unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl->serialize()); |
2033 | + unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl.serialize()); |
2034 | |
2035 | unity::scopes::CannedQuery query("scopeA", "query", "department"); |
2036 | unity::scopes::ActionMetadata action_metadata("en", "phone"); |
2037 | |
2038 | // verify that the event method is called for stop event and |
2039 | // that the thread is the Qt thread |
2040 | - EXPECT_CALL(scope, stop()).Times(Exactly(1)).WillOnce(Invoke(CheckThread)); |
2041 | + EXPECT_CALL(*scope, stop()).Times(Exactly(1)).WillOnce(Invoke(check_thread)); |
2042 | api_scope.stop(); |
2043 | } |
2044 | |
2045 | === modified file 'test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h' |
2046 | --- test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h 2015-02-25 12:37:37 +0000 |
2047 | +++ test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h 2015-02-25 12:37:38 +0000 |
2048 | @@ -29,14 +29,14 @@ |
2049 | class QScopeBaseAPIMock : public unity::scopes::qt::internal::QScopeBaseAPIImpl |
2050 | { |
2051 | public: |
2052 | - QScopeBaseAPIMock(unity::scopes::qt::QScopeBase& qtscope, QObject* parent = 0) |
2053 | - : unity::scopes::qt::internal::QScopeBaseAPIImpl(qtscope, parent) |
2054 | + QScopeBaseAPIMock(QScopeBaseAPIImpl::FactoryFunc const& creator) |
2055 | + : unity::scopes::qt::internal::QScopeBaseAPIImpl(creator) |
2056 | { |
2057 | } |
2058 | |
2059 | virtual ~QScopeBaseAPIMock() = default; |
2060 | |
2061 | - QThread* getQtAppThread() |
2062 | + QThread* get_qt_app_thread() |
2063 | { |
2064 | return qtapp_->thread(); |
2065 | } |
2066 | |
2067 | === modified file 'test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp' |
2068 | --- test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp 2015-02-25 12:37:37 +0000 |
2069 | +++ test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp 2015-02-25 12:37:38 +0000 |
2070 | @@ -43,8 +43,8 @@ |
2071 | class QScopeBaseAPIImplTest : public QScopeBaseAPIImpl |
2072 | { |
2073 | public: |
2074 | - QScopeBaseAPIImplTest(FactoryFunc const& creator, QObject* parent = 0) |
2075 | - : QScopeBaseAPIImpl(creator, parent) |
2076 | + QScopeBaseAPIImplTest(FactoryFunc const& creator) |
2077 | + : QScopeBaseAPIImpl(creator) |
2078 | { |
2079 | } |
2080 | |
2081 | @@ -52,6 +52,11 @@ |
2082 | { |
2083 | return qtapp_->thread(); |
2084 | } |
2085 | + |
2086 | + bool qtapp_stopped() |
2087 | + { |
2088 | + return qtapp_stopped_; |
2089 | + } |
2090 | }; |
2091 | |
2092 | QScopeBase* create_my_scope() |
2093 | @@ -85,4 +90,9 @@ |
2094 | |
2095 | // stop the Qt application |
2096 | impl.stop(); |
2097 | + |
2098 | + while (!impl.qtapp_stopped()) |
2099 | + { |
2100 | + std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
2101 | + } |
2102 | } |
2103 | |
2104 | === modified file 'test/headers/CMakeLists.txt' |
2105 | --- test/headers/CMakeLists.txt 2015-02-05 14:57:01 +0000 |
2106 | +++ test/headers/CMakeLists.txt 2015-02-25 12:37:38 +0000 |
2107 | @@ -5,7 +5,7 @@ |
2108 | set(root_inc_dir ${CMAKE_SOURCE_DIR}/include) |
2109 | |
2110 | set(subdirs |
2111 | - unity/scopes/ |
2112 | + unity/scopes |
2113 | unity/scopes/qt |
2114 | unity/scopes/testing |
2115 | unity/scopes/utility |
2116 | @@ -56,4 +56,4 @@ |
2117 | |
2118 | add_test(cleanincludes ${CMAKE_CURRENT_SOURCE_DIR}/includechecker.py ${CMAKE_SOURCE_DIR}/include) |
2119 | add_test(noglobalincludes ${CMAKE_CURRENT_SOURCE_DIR}/check_global_usage.py |
2120 | -${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include) |
2121 | + ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include) |
PASSED: Continuous integration, rev:338 jenkins. qa.ubuntu. com/job/ unity-scopes- api-ci/ 590/ jenkins. qa.ubuntu. com/job/ unity-scopes- api-vivid- amd64-ci/ 124 jenkins. qa.ubuntu. com/job/ unity-scopes- api-vivid- armhf-ci/ 115 jenkins. qa.ubuntu. com/job/ unity-scopes- api-vivid- armhf-ci/ 115/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ unity-scopes- api-vivid- i386-ci/ 116
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- scopes- api-ci/ 590/rebuild
http://