Merge lp:~michihenning/unity-scopes-api/qt-coverage-2 into lp:unity-scopes-api/devel

Proposed by Michi Henning
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 340
Merged at revision: 562
Proposed branch: lp:~michihenning/unity-scopes-api/qt-coverage-2
Merge into: lp:unity-scopes-api/devel
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
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Paweł Stołowski (community) Approve
Review via email: mp+251200@code.launchpad.net

This proposal supersedes a proposal from 2015-02-24.

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 QPreviewQueryBaseAPI test.
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 QPreviewQueryBaseAPI test.
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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good! I've no clue what the conflict in debian changelog is... +1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CTestCustom.cmake.in'
--- CTestCustom.cmake.in 2014-07-25 05:54:44 +0000
+++ CTestCustom.cmake.in 2015-02-27 03:36:41 +0000
@@ -12,8 +12,14 @@
12 stand-alone-unity-scopes-headers12 stand-alone-unity-scopes-headers
13 stand-alone-unity-scopes-internal-headers13 stand-alone-unity-scopes-internal-headers
14 stand-alone-unity-scopes-testing-headers14 stand-alone-unity-scopes-testing-headers
15 stand-alone-unity-scopes-utility-headers
16 stand-alone-unity-scopes-utility-internal-headers
17 stand-alone-unity-scopes-qt-headers
18 stand-alone-unity-scopes-qt-internal-headers
15 clean-public-unity-scopes-headers19 clean-public-unity-scopes-headers
16 clean-public-unity-scopes-testing-headers20 clean-public-unity-scopes-testing-headers
21 clean-public-unity-scopes-utility-headers
22 clean-public-unity-scopes-qt-headers
17 IsolatedScopeBenchmark # Runs too slowly and crashes valgrind 3.10.0 with g++-4.923 IsolatedScopeBenchmark # Runs too slowly and crashes valgrind 3.10.0 with g++-4.9
18 copyright24 copyright
19 whitespace)25 whitespace)
2026
=== modified file 'HACKING'
--- HACKING 2015-01-27 09:38:24 +0000
+++ HACKING 2015-02-27 03:36:41 +0000
@@ -49,6 +49,31 @@
4949
50 $ make valgrind50 $ make valgrind
5151
52It doesn't make sense for some tests to run them with valgrind. For
53example, the header compilation tests don't need valgrind because
54we'd just be testing that Python doesn't leak. There are also some
55tests that run too slow and time out under valgrind and, occasionally,
56valgrind crashes for a particular test.
57
58There are two ways to suppress tests:
59
60You can add a test name to CTestCustom.cmake.in to suppress that
61test completely. That makes sense for the header compilation tests,
62for example.
63
64If a specific test case in a test program causes a valgrind problem,
65you can selectively disable a section of code like this:
66
67 #include <valgrind/valgrind.h>
68
69 if (!RUNNING_ON_VALGRIND)
70 {
71 // Code here crashes valgrind...
72 }
73
74That way, the test will still be run as part of the normal "make test"
75target, but will be ommitted when running "make valgrind".
76
52Coverage77Coverage
53--------78--------
5479
@@ -143,6 +168,17 @@
143168
144 $ TSAN_OPTIONS="suppressions=../tsan-suppress" make test169 $ TSAN_OPTIONS="suppressions=../tsan-suppress" make test
145170
171If a test runs too slowly under address sanitizer, you can
172hide a section of code from address sanitzer with:
173
174#if defined(__has_feature)
175 #if !__has_feature(address_sanitizer)
176
177 // Code here takes forever under address sanitizer...
178
179 #endif
180#endif
181
146Updating symbols file182Updating symbols file
147---------------------183---------------------
148184
149185
=== modified file 'debian/libunity-scopes-qt.symbols'
--- debian/libunity-scopes-qt.symbols 2015-02-27 03:36:41 +0000
+++ debian/libunity-scopes-qt.symbols 2015-02-27 03:36:41 +0000
@@ -191,7 +191,6 @@
191 (c++)"unity::scopes::qt::QResult::operator=(unity::scopes::qt::QResult&&)@Base" 0.6.13+15.04.20150205.1191 (c++)"unity::scopes::qt::QResult::operator=(unity::scopes::qt::QResult&&)@Base" 0.6.13+15.04.20150205.1
192 (c++)"unity::scopes::qt::QResult::operator=(unity::scopes::qt::QResult const&)@Base" 0.6.13+15.04.20150205.1192 (c++)"unity::scopes::qt::QResult::operator=(unity::scopes::qt::QResult const&)@Base" 0.6.13+15.04.20150205.1
193 (c++)"unity::scopes::qt::QResult::~QResult()@Base" 0.6.13+15.04.20150205.1193 (c++)"unity::scopes::qt::QResult::~QResult()@Base" 0.6.13+15.04.20150205.1
194 (c++)"unity::scopes::qt::QResult::QResult()@Base" 0.6.13+15.04.20150205.1
195 (c++)"unity::scopes::qt::QResult::QResult(QMap<QString, QVariant> const&)@Base" 0.6.13+15.04.20150205.1194 (c++)"unity::scopes::qt::QResult::QResult(QMap<QString, QVariant> const&)@Base" 0.6.13+15.04.20150205.1
196 (c++)"unity::scopes::qt::QResult::QResult(unity::scopes::qt::internal::QResultImpl*)@Base" 0.6.13+15.04.20150205.1195 (c++)"unity::scopes::qt::QResult::QResult(unity::scopes::qt::internal::QResultImpl*)@Base" 0.6.13+15.04.20150205.1
197 (c++)"unity::scopes::qt::QResult::QResult(unity::scopes::qt::QResult&&)@Base" 0.6.13+15.04.20150205.1196 (c++)"unity::scopes::qt::QResult::QResult(unity::scopes::qt::QResult&&)@Base" 0.6.13+15.04.20150205.1
198197
=== modified file 'include/unity/scopes/ScopeBase.h'
--- include/unity/scopes/ScopeBase.h 2015-01-26 08:10:59 +0000
+++ include/unity/scopes/ScopeBase.h 2015-02-27 03:36:41 +0000
@@ -104,8 +104,7 @@
104 - a create function that must return a pointer to the derived instance104 - a create function that must return a pointer to the derived instance
105 - a destroy function that is passed the pointer returned by the create function105 - a destroy function that is passed the pointer returned by the create function
106106
107Typically, the create and destroy functions will simply call `new` and `delete`, respectively. (However,107Typically, the create and destroy functions will simply call `new` and `delete`, respectively.
108there is no requirement that the derived class instance must be heap-allocated.)
109If the create function throws an exception, the destroy function will not be called. If the create function returns108If the create function throws an exception, the destroy function will not be called. If the create function returns
110NULL, the destroy function _will_ be called with NULL as its argument.109NULL, the destroy function _will_ be called with NULL as its argument.
111110
@@ -116,13 +115,13 @@
116unity::scopes::ScopeBase*115unity::scopes::ScopeBase*
117UNITY_SCOPE_CREATE_FUNCTION()116UNITY_SCOPE_CREATE_FUNCTION()
118{117{
119 return new MyScope; // Example only, heap-allocation is not mandatory118 return new MyScope;
120}119}
121120
122void121void
123UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope)122UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope)
124{123{
125 delete scope; // Example only, heap-allocation is not mandatory124 delete scope;
126}125}
127~~~126~~~
128127
@@ -376,8 +375,7 @@
376/**375/**
377\brief The function called by the scopes run time to initialize the scope.376\brief The function called by the scopes run time to initialize the scope.
378It must return a pointer to an instance derived from `ScopeBase`. The returned377It must return a pointer to an instance derived from `ScopeBase`. The returned
379instance need not be heap-allocated, but must remain in scope until the378instance must remain in scope until the destroy function is called by the scopes run time.
380destroy function is called by the scopes run time.
381379
382If this function throws an exception, the destroy function will _not_ be called. If this function returns NULL,380If this function throws an exception, the destroy function will _not_ be called. If this function returns NULL,
383the destroy function _will_ be called with NULL as its argument.381the destroy function _will_ be called with NULL as its argument.
384382
=== modified file 'include/unity/scopes/qt/QActionMetadata.h'
--- include/unity/scopes/qt/QActionMetadata.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QActionMetadata.h 2015-02-27 03:36:41 +0000
@@ -140,7 +140,6 @@
140 QActionMetadata(internal::QActionMetadataImpl* impl);140 QActionMetadata(internal::QActionMetadataImpl* impl);
141141
142 std::unique_ptr<internal::QActionMetadataImpl> p;142 std::unique_ptr<internal::QActionMetadataImpl> p;
143 friend class internal::QActionMetadataImpl;
144 friend class internal::QPreviewQueryBaseImpl;143 friend class internal::QPreviewQueryBaseImpl;
145 friend class QPreviewQueryBaseAPI;144 friend class QPreviewQueryBaseAPI;
146 /// @endcond145 /// @endcond
147146
=== modified file 'include/unity/scopes/qt/QPreviewQueryBase.h'
--- include/unity/scopes/qt/QPreviewQueryBase.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QPreviewQueryBase.h 2015-02-27 03:36:41 +0000
@@ -128,7 +128,6 @@
128 void init(QPreviewQueryBaseAPI* query_api);128 void init(QPreviewQueryBaseAPI* query_api);
129129
130 std::unique_ptr<internal::QPreviewQueryBaseImpl> p;130 std::unique_ptr<internal::QPreviewQueryBaseImpl> p;
131 friend class internal::QPreviewQueryBaseImpl;
132 friend class QPreviewQueryBaseAPI;131 friend class QPreviewQueryBaseAPI;
133 /// @endcond132 /// @endcond
134};133};
135134
=== modified file 'include/unity/scopes/qt/QPreviewReply.h'
--- include/unity/scopes/qt/QPreviewReply.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QPreviewReply.h 2015-02-27 03:36:41 +0000
@@ -98,7 +98,6 @@
9898
99private:99private:
100 std::unique_ptr<internal::QPreviewReplyImpl> p;100 std::unique_ptr<internal::QPreviewReplyImpl> p;
101 friend class internal::QPreviewReplyImpl;
102 friend class QPreviewQueryBaseAPI;101 friend class QPreviewQueryBaseAPI;
103 /// @endcond102 /// @endcond
104};103};
105104
=== modified file 'include/unity/scopes/qt/QResult.h'
--- include/unity/scopes/qt/QResult.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QResult.h 2015-02-27 03:36:41 +0000
@@ -67,7 +67,6 @@
67 UNITY_DEFINES_PTRS(QResult);67 UNITY_DEFINES_PTRS(QResult);
68 /// @endcond68 /// @endcond
6969
70 QResult();
71 /**@name Copy and assignment70 /**@name Copy and assignment
72 Copy and assignment (move and non-move versions) have the usual value semantics.71 Copy and assignment (move and non-move versions) have the usual value semantics.
73 */72 */
7473
=== modified file 'include/unity/scopes/qt/QScopeBase.h'
--- include/unity/scopes/qt/QScopeBase.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QScopeBase.h 2015-02-27 03:36:41 +0000
@@ -54,7 +54,7 @@
54\brief Base class for a scope implementation.54\brief Base class for a scope implementation.
5555
56Scopes are accessed by the scopes run time as a shared library (one library per scope).56Scopes are accessed by the scopes run time as a shared library (one library per scope).
57Each scope must implement a class that derives from ScopeBase, for example:57Each scope must implement a class that derives from QScopeBase, for example:
5858
59~~~59~~~
60#include <unity/scopes/qt/QScopeBase.h>60#include <unity/scopes/qt/QScopeBase.h>
@@ -65,9 +65,8 @@
65 MyScope();65 MyScope();
66 virtual ~MyScope();66 virtual ~MyScope();
6767
68 virtual void start(QString const& scope_id); // Optional68 virtual void start(QString const& scope_id); // Optional
69 virtual void stop(); // Optional69 virtual void stop(); // Optional
70 virtual void run(); // Optional
71 // ...70 // ...
72};71};
73~~~72~~~
@@ -76,8 +75,6 @@
76 - a create function that must return a pointer to the derived instance75 - a create function that must return a pointer to the derived instance
77 - a destroy function that is passed the pointer returned by the create function76 - a destroy function that is passed the pointer returned by the create function
7877
79Typically, the create and destroy functions will simply call `new` and `delete`, respectively. (However,
80there is no requirement that the derived class instance must be heap-allocated.)
81If the create function throws an exception, the destroy function will not be called. If the create function returns78If the create function throws an exception, the destroy function will not be called. If the create function returns
82NULL, the destroy function _will_ be called with NULL as its argument.79NULL, the destroy function _will_ be called with NULL as its argument.
8380
@@ -86,8 +83,9 @@
8683
87~~~84~~~
8885
89// You must provide a function that creates your own scope86// You must provide a function that creates your scope on the heap and
90// That function must have no parameters and return a pointer to QScopeBase87// pass this function to the QScopeBaseAPI constructor.
88
91unity::scopes::qt::QScopeBase *create_my_scope()89unity::scopes::qt::QScopeBase *create_my_scope()
92{90{
93 return new MyScope();91 return new MyScope();
@@ -96,23 +94,23 @@
96unity::scopes::ScopeBase*94unity::scopes::ScopeBase*
97UNITY_SCOPE_CREATE_FUNCTION()95UNITY_SCOPE_CREATE_FUNCTION()
98{96{
99 // Initialize scope. This line is mandatory, you should pass your creation scope function to97 // You must return a dynamically allocated QScopeBaseAPI instance here.
100 // the class QScopeBaseAPI, which will instantiate your class in the correct Qt Thread.98 // In turn, that instance calls your creation function to instantiate
99 // your scope in the correct Qt thread.
101 return new QScopeBaseAPI(create_my_scope);100 return new QScopeBaseAPI(create_my_scope);
102}101}
103102
103// The runtime, once it has stopped your scope, calls the destroy function.
104
104void105void
105UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope)106UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope)
106{107{
108 delete scope;
107}109}
108~~~110~~~
109111
110After the scopes run time has obtained a pointer to the class instance from the create function, it calls start(),112After the scopes run time has obtained a pointer to the class instance from the create function, it calls start(),
111which allows the scope to initialize itself. This is followed by a call to run().113which allows the scope to initialize itself.
112All calls to the methods of this class will be done from the main QThread.
113
114The scope implementation, if it does not return from run(), is expected to return from run() in response to a
115call to stop() in a timely manner.
116*/114*/
117class QScopeBase : public QObject115class QScopeBase : public QObject
118{116{
@@ -149,7 +147,6 @@
149147
150private:148private:
151 std::unique_ptr<internal::QScopeBaseImpl> p;149 std::unique_ptr<internal::QScopeBaseImpl> p;
152 friend class internal::QScopeBaseImpl;
153};150};
154151
155} // namespace qt152} // namespace qt
156153
=== modified file 'include/unity/scopes/qt/QScopeBaseAPI.h'
--- include/unity/scopes/qt/QScopeBaseAPI.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QScopeBaseAPI.h 2015-02-27 03:36:41 +0000
@@ -52,10 +52,6 @@
52/**52/**
53 * Defines the lifecycle of scope plugin, and acts as a factory53 * Defines the lifecycle of scope plugin, and acts as a factory
54 * for Query and Preview objects.54 * for Query and Preview objects.
55 *
56 * Note that the #preview and #search methods are each called on
57 * different threads, so some form of interlocking is required
58 * if shared data structures are used.
59 */55 */
60class QScopeBaseAPI : public unity::scopes::ScopeBase56class QScopeBaseAPI : public unity::scopes::ScopeBase
61{57{
@@ -109,7 +105,6 @@
109private:105private:
110 /// @cond106 /// @cond
111 std::unique_ptr<internal::QScopeBaseAPIImpl> p;107 std::unique_ptr<internal::QScopeBaseAPIImpl> p;
112 friend class internal::QScopeBaseAPIImpl;
113 /// @endcond108 /// @endcond
114};109};
115110
116111
=== modified file 'include/unity/scopes/qt/QSearchMetadata.h'
--- include/unity/scopes/qt/QSearchMetadata.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QSearchMetadata.h 2015-02-27 03:36:41 +0000
@@ -164,7 +164,6 @@
164private:164private:
165 /// @cond165 /// @cond
166 std::unique_ptr<internal::QSearchMetadataImpl> p;166 std::unique_ptr<internal::QSearchMetadataImpl> p;
167 friend class internal::QSearchMetadataImpl;
168 /// @endcond167 /// @endcond
169};168};
170169
171170
=== modified file 'include/unity/scopes/qt/QSearchQueryBase.h'
--- include/unity/scopes/qt/QSearchQueryBase.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QSearchQueryBase.h 2015-02-27 03:36:41 +0000
@@ -156,7 +156,6 @@
156 void init(QSearchQueryBaseAPI* query_api);156 void init(QSearchQueryBaseAPI* query_api);
157157
158 std::unique_ptr<internal::QSearchQueryBaseImpl> p;158 std::unique_ptr<internal::QSearchQueryBaseImpl> p;
159 friend class internal::QSearchQueryBaseImpl;
160 friend class QSearchQueryBaseAPI;159 friend class QSearchQueryBaseAPI;
161 ///@endcond160 ///@endcond
162};161};
163162
=== modified file 'include/unity/scopes/qt/QSearchReply.h'
--- include/unity/scopes/qt/QSearchReply.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/QSearchReply.h 2015-02-27 03:36:41 +0000
@@ -157,7 +157,6 @@
157 QSearchReply(unity::scopes::SearchReplyProxy& reply, QObject* parent = 0);157 QSearchReply(unity::scopes::SearchReplyProxy& reply, QObject* parent = 0);
158158
159 std::unique_ptr<internal::QSearchReplyImpl> p;159 std::unique_ptr<internal::QSearchReplyImpl> p;
160 friend class internal::QSearchReplyImpl;
161 friend class QSearchQueryBaseAPI;160 friend class QSearchQueryBaseAPI;
162};161};
163162
164163
=== modified file 'include/unity/scopes/qt/internal/QActionMetadataImpl.h'
--- include/unity/scopes/qt/internal/QActionMetadataImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QActionMetadataImpl.h 2015-02-27 03:36:41 +0000
@@ -43,92 +43,26 @@
4343
44class QPreviewQueryBaseImpl;44class QPreviewQueryBaseImpl;
4545
46/**
47\brief Metadata passed to scopes for preview and activation.
48\see unity::scopes::ScopeBase::preview, unity::scopes::ScopeBase::activate, unity::scopes::ScopeBase::perform_action
49*/
50class QActionMetadataImpl46class QActionMetadataImpl
51{47{
52public:48public:
53 /// @cond
54 UNITY_DEFINES_PTRS(QActionMetadataImpl);49 UNITY_DEFINES_PTRS(QActionMetadataImpl);
5550
51 QActionMetadataImpl(QString const& locale, QString const& form_factor);
56 ~QActionMetadataImpl();52 ~QActionMetadataImpl();
57 /// @endcond53
58
59 /**
60 \brief Create ActionMetadata with the given locale and form factor.
61 \param locale locale string, eg. en_EN
62 \param form_factor form factor name, e.g. phone, desktop, phone-version etc.
63 */
64 QActionMetadataImpl(QString const& locale, QString const& form_factor);
65
66 /**
67 \brief Attach arbitrary data to this ActionMetadata.
68 \param data The data value to attach.
69 */
70 void set_scope_data(QVariant const& data);
71
72 /**
73 \brief Get data attached to this ActionMetadata.
74 \return The attached data, or QVariant::null.
75 */
76 QVariant scope_data() const;
77
78 /**@name Copy and assignment
79 Copy and assignment operators (move and non-move versions) have the usual value semantics.
80 */
81 //{@
82 QActionMetadataImpl(QActionMetadataImpl const& other);54 QActionMetadataImpl(QActionMetadataImpl const& other);
83 QActionMetadataImpl(QActionMetadataImpl&&);55 QActionMetadataImpl(QActionMetadataImpl&&);
8456
85 QActionMetadataImpl& operator=(QActionMetadataImpl const& other);57 QActionMetadataImpl& operator=(QActionMetadataImpl const& other);
86 QActionMetadataImpl& operator=(QActionMetadataImpl&&);58 QActionMetadataImpl& operator=(QActionMetadataImpl&&);
87 //@}59
8860 void set_scope_data(QVariant const& data);
89 /**61 QVariant scope_data() const;
90 \brief Sets a hint.
91
92 \param key The name of the hint.
93 \param value Hint value
94 */
95 void set_hint(QString const& key, QVariant const& value);62 void set_hint(QString const& key, QVariant const& value);
96
97 /**
98 \brief Get all hints.
99
100 \return Hints dictionary.
101 \throws unity::NotFoundException if no hints are available.
102 */
103 QVariantMap hints() const;63 QVariantMap hints() const;
104
105 /**
106 \brief Check if this SearchMetadata has a hint.
107 \param key The hint name.
108 \return True if the hint is set.QScopeVariant
109 */
110 bool contains_hint(QString const& key) const;64 bool contains_hint(QString const& key) const;
111
112 /**
113 \brief Returns a reference to a hint.
114
115 This method can be used to read or set hints. Setting a value of an existing hint overwrites
116 its previous value.
117 Referencing a non-existing hint automatically creates it with a default value of QVariant::Type::Null.
118 \param key The name of the hint.
119 \return A reference to the hint.
120 */
121 QScopeVariant& operator[](QString const& key);65 QScopeVariant& operator[](QString const& key);
122
123 /**
124 \brief Returns a const reference to a hint.
125
126 This method can be used for read-only access to hints.
127 Referencing a non-existing hint throws unity::InvalidArgumentException.
128 \param key The name of the hint.
129 \return A const reference to the hint.
130 \throws unity::NotFoundException if no hint with the given name exists.
131 */
132 QVariant const& value(QString const& key) const;66 QVariant const& value(QString const& key) const;
13367
134private:68private:
13569
=== modified file 'include/unity/scopes/qt/internal/QCategorisedResultImpl.h'
--- include/unity/scopes/qt/internal/QCategorisedResultImpl.h 2015-01-20 13:59:36 +0000
+++ include/unity/scopes/qt/internal/QCategorisedResultImpl.h 2015-02-27 03:36:41 +0000
@@ -48,37 +48,16 @@
48class QCategorisedResultImpl : public QResultImpl48class QCategorisedResultImpl : public QResultImpl
49{49{
50public:50public:
51 /// @cond
52 UNITY_DEFINES_PTRS(QCategorisedResultImpl);51 UNITY_DEFINES_PTRS(QCategorisedResultImpl);
53 /// @endcond52
54 /**
55 \brief Creates a CategorisedResult with given category,
56 with all base attributes initially empty.
57 \param category The category for the result.
58 */
59 explicit QCategorisedResultImpl(QCategory::SCPtr category);53 explicit QCategorisedResultImpl(QCategory::SCPtr category);
6054
61 /**@name Copy and assignment
62 Copy and assignment operators (move and non-move versions) have the usual value semantics.
63 */
64 //{@
65 QCategorisedResultImpl(QCategorisedResultImpl const& other);55 QCategorisedResultImpl(QCategorisedResultImpl const& other);
66 QCategorisedResultImpl& operator=(QCategorisedResultImpl const& other);56 QCategorisedResultImpl& operator=(QCategorisedResultImpl const& other);
67 QCategorisedResultImpl(QCategorisedResultImpl&&);57 QCategorisedResultImpl(QCategorisedResultImpl&&);
68 QCategorisedResultImpl& operator=(QCategorisedResultImpl&&);58 QCategorisedResultImpl& operator=(QCategorisedResultImpl&&);
69 //@}
7059
71 /**
72 \brief Updates the category of this result.
73 \param category The category for the result.
74 */
75 void set_category(QCategory::SCPtr category);60 void set_category(QCategory::SCPtr category);
76
77 /**
78 \brief Return category of this result.
79 Get the category instance this result belongs to.
80 \return The category instance.
81 */
82 QCategory::SCPtr category() const;61 QCategory::SCPtr category() const;
8362
84private:63private:
8564
=== modified file 'include/unity/scopes/qt/internal/QCategoryImpl.h'
--- include/unity/scopes/qt/internal/QCategoryImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QCategoryImpl.h 2015-02-27 03:36:41 +0000
@@ -47,46 +47,19 @@
47class QCategoryImpl47class QCategoryImpl
48{48{
49public:49public:
50 /// @cond
51 NONCOPYABLE(QCategoryImpl);50 NONCOPYABLE(QCategoryImpl);
52 UNITY_DEFINES_PTRS(QCategoryImpl);51 UNITY_DEFINES_PTRS(QCategoryImpl);
5352
54 QCategoryImpl(unity::scopes::Category::SCPtr category);53 QCategoryImpl(unity::scopes::Category::SCPtr category);
5554
56 virtual ~QCategoryImpl();55 virtual ~QCategoryImpl();
57 /// @endcond
5856
59 /**
60 \brief Get identifier of this Category
61 \return The category identifier.
62 */
63 QString id() const;57 QString id() const;
64
65 /**
66 \brief Get title of this Category
67 \return The category title.
68 */
69 QString title() const;58 QString title() const;
70
71 /**
72 \brief Get icon of this Category
73 \return The category icon.
74 */
75 QString icon() const;59 QString icon() const;
76
77 /**
78 \brief Query to perform when this category is expanded
79 \return The expansion query or nullptr.
80 */
81 CannedQuery::SCPtr query() const;60 CannedQuery::SCPtr query() const;
82
83 /**
84 \brief Get renderer template of this Category
85 \return The category renderer template.
86 */
87 CategoryRenderer const& renderer_template() const;61 CategoryRenderer const& renderer_template() const;
8862
89 // @cond
90 QVariantMap serialize() const;63 QVariantMap serialize() const;
9164
92 static std::shared_ptr<QCategory> create(unity::scopes::Category::SCPtr category);65 static std::shared_ptr<QCategory> create(unity::scopes::Category::SCPtr category);
9366
=== modified file 'include/unity/scopes/qt/internal/QColumnLayoutImpl.h'
--- include/unity/scopes/qt/internal/QColumnLayoutImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QColumnLayoutImpl.h 2015-02-27 03:36:41 +0000
@@ -46,65 +46,22 @@
46class QColumnLayoutImpl46class QColumnLayoutImpl
47{47{
48public:48public:
49 /// @cond
50 UNITY_DEFINES_PTRS(QColumnLayoutImpl);49 UNITY_DEFINES_PTRS(QColumnLayoutImpl);
51 /// @endcond
5250
53 /**
54 \brief Creates a layout definition that expects num_of_columns columns to be added with ColumnLayout::add_column.
55 \param num_of_columns The number of columns for the layout.
56 \throws unity::InvalidArgumentException for an invalid number of columns.
57 */
58 explicit QColumnLayoutImpl(int num_of_columns);51 explicit QColumnLayoutImpl(int num_of_columns);
52 ~QColumnLayoutImpl();
5953
60 /**@name Copy and assignment
61 Copy and assignment operators (move and non-move versions) have the usual value semantics.
62 */
63 //{@
64 QColumnLayoutImpl(QColumnLayoutImpl const& other);54 QColumnLayoutImpl(QColumnLayoutImpl const& other);
65 QColumnLayoutImpl(QColumnLayoutImpl&&);55 QColumnLayoutImpl(QColumnLayoutImpl&&);
66 QColumnLayoutImpl& operator=(QColumnLayoutImpl const& other);56 QColumnLayoutImpl& operator=(QColumnLayoutImpl const& other);
67 QColumnLayoutImpl& operator=(QColumnLayoutImpl&&);57 QColumnLayoutImpl& operator=(QColumnLayoutImpl&&);
68 //@}58
69
70 /// @cond
71 ~QColumnLayoutImpl();
72 /// @endcond
73
74 /**
75 \brief Adds a new column and assigns widgets to it.
76
77 ColumnLayout expects exactly the number of columns passed to the constructor to be created with the
78 add_column method.
79 \throws unity::LogicException if an attempt is made to add more columns than specified in the constructor.
80 \throws unity::LogicException from \link unity::scopes::PreviewReply::register_layout\endlink if a layout
81 has fewer columns than specified in the constructor.
82 */
83 void add_column(QVector<QString> widget_ids);59 void add_column(QVector<QString> widget_ids);
84
85 /**
86 \brief Get the current number of columns in this layout.
87 \return The number of columns added with add_column().
88 */
89 int size() const noexcept;60 int size() const noexcept;
90
91 /**
92 \brief Get the number of columns expected by this layout as specified in the constructor.
93 \return The number of columns expected by this layout.
94 */
95 int number_of_columns() const noexcept;61 int number_of_columns() const noexcept;
96
97 /**
98 \brief Retrieve the list of widgets for given column.
99 \param index The index of a column.
100 \return The widget identifiers for the given column index.
101 \throws unity::InvalidArgumentException if the index is invalid.
102 */
103 QVector<QString> column(int index) const;62 QVector<QString> column(int index) const;
10463
105 /// @cond
106 QVariantMap serialize() const;64 QVariantMap serialize() const;
107 /// @endcond
10865
109 // added for testing purposes66 // added for testing purposes
110 static unity::scopes::qt::QColumnLayout create(QColumnLayoutImpl* internal);67 static unity::scopes::qt::QColumnLayout create(QColumnLayoutImpl* internal);
11168
=== modified file 'include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h'
--- include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h 2015-01-20 13:59:36 +0000
+++ include/unity/scopes/qt/internal/QPreviewQueryBaseImpl.h 2015-02-27 03:36:41 +0000
@@ -46,26 +46,13 @@
46class QPreviewQueryBaseImpl46class QPreviewQueryBaseImpl
47{47{
48public:48public:
49 /// @cond
50 NONCOPYABLE(QPreviewQueryBaseImpl);49 NONCOPYABLE(QPreviewQueryBaseImpl);
51 UNITY_DEFINES_PTRS(QPreviewQueryBaseImpl);50 UNITY_DEFINES_PTRS(QPreviewQueryBaseImpl);
52 /// @endcond
5351
54 QPreviewQueryBaseImpl();52 QPreviewQueryBaseImpl();
55 ~QPreviewQueryBaseImpl() = default;53 ~QPreviewQueryBaseImpl() = default;
5654
57 /**
58 \brief Get result for this preview request.
59 \throws unity::LogicException if result was not initialized (the default ctor was used).
60 \return result
61 */
62 QResult result() const;55 QResult result() const;
63
64 /**
65 \brief Get metadata for this preview request.
66 \return search metadata
67 \throws unity::LogicException if preview metadata was not initialized (the default ctor was used).
68 */
69 QActionMetadata action_metadata() const;56 QActionMetadata action_metadata() const;
7057
71protected:58protected:
7259
=== modified file 'include/unity/scopes/qt/internal/QPreviewReplyImpl.h'
--- include/unity/scopes/qt/internal/QPreviewReplyImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QPreviewReplyImpl.h 2015-02-27 03:36:41 +0000
@@ -48,49 +48,20 @@
48namespace internal48namespace internal
49{49{
5050
51/**
52\brief Allows the results of a preview to be sent to the preview requester.
53*/
54
55class QPreviewReplyImpl51class QPreviewReplyImpl
56{52{
57public:53public:
58 /// @cond
59 NONCOPYABLE(QPreviewReplyImpl);54 NONCOPYABLE(QPreviewReplyImpl);
60 UNITY_DEFINES_PTRS(QPreviewReplyImpl);55 UNITY_DEFINES_PTRS(QPreviewReplyImpl);
61 /// @endcond56
62 /**57 virtual ~QPreviewReplyImpl();
63 \brief Registers a list of column layouts for the current preview.58
64
65 Layouts must be registered before pushing a unity::scopes::PreviewWidgetList, and must be
66 registered only once.
67 \return True if the query is still alive, false if the query failed or was cancelled.
68 \throws unity::LogicException register_layout() is called more than once.
69 */
70 bool register_layout(QColumnLayoutList const& layouts);59 bool register_layout(QColumnLayoutList const& layouts);
71
72 /**
73 \brief Sends widget definitions to the sender of the preview query.
74
75 This method can be called mutiple times to send widgets in stages.
76 \return True if the query is still alive, false if the query failed or was cancelled.
77 */
78 bool push(QPreviewWidgetList const& widget_list);60 bool push(QPreviewWidgetList const& widget_list);
79
80 /**
81 \brief Sends data for a preview widget attribute.
82 \return True if the query is still alive, false if the query failed or was cancelled.
83 */
84 bool push(QString const& key, QVariant const& value);61 bool push(QString const& key, QVariant const& value);
8562
86 /// @cond
87 virtual ~QPreviewReplyImpl();
88 /// @endcond
89
90protected:63protected:
91 /// @cond
92 QPreviewReplyImpl(unity::scopes::PreviewReplyProxy& reply);64 QPreviewReplyImpl(unity::scopes::PreviewReplyProxy& reply);
93 /// @endcond
9465
95private:66private:
96 PreviewReplyProxy api_reply_;67 PreviewReplyProxy api_reply_;
9768
=== modified file 'include/unity/scopes/qt/internal/QPreviewWidgetImpl.h'
--- include/unity/scopes/qt/internal/QPreviewWidgetImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QPreviewWidgetImpl.h 2015-02-27 03:36:41 +0000
@@ -39,9 +39,6 @@
3939
40class QPreviewWidget;40class QPreviewWidget;
4141
42/*! \typedef QPreviewWidgetList
43\brief List of preview widgets (see unity::scopes::qt::QPreviewWidget)
44*/
45typedef QList<QPreviewWidget> QPreviewWidgetList;42typedef QList<QPreviewWidget> QPreviewWidgetList;
4643
47namespace internal44namespace internal
@@ -52,135 +49,29 @@
52class QPreviewWidgetImpl49class QPreviewWidgetImpl
53{50{
54public:51public:
55 /// @cond
56 UNITY_DEFINES_PTRS(QPreviewWidgetImpl);52 UNITY_DEFINES_PTRS(QPreviewWidgetImpl);
57 /// @endcond
5853
59 /**
60 \brief Create an empty widget definition with a specific id and type.
61 \param id The unique widget identifier.
62 \param widget_type The type of the widget.
63 */
64 QPreviewWidgetImpl(QString const& id, QString const& widget_type);54 QPreviewWidgetImpl(QString const& id, QString const& widget_type);
65
66 /**
67 \brief Create a widget from a JSON definition.
68
69 The JSON definition must be a dictionary that includes widget "id" and all the values of attributes required by
70 desired
71 \link previewwidgets widget type\endlink. For example, a definition of image widget may look as follows:
72 \code{.cpp}
73 PreviewWidget img(R"({"id": "img", "type": "image", "source": "http://imageuri"})");
74 \endcode
75
76 For cases where attribute mappings are to be used instead of direct values, they need to be enclosed in the
77 "components" dictionary, e.g.
78 \code{.cpp}
79 PreviewWidget img(R"({"id": "img", "type": "image", "components": { "source": "screenshot-url" } })");
80 \endcode
81 (this example assumes "screenshot-url" value is either available in the result object that's being previewed, or it
82 will be pushed with
83 unity::scopes::PreviewReply::push() method)
84
85 \note It is recommended to create widgets via unity::scopes::PreviewWidget(QString const&, QString const&)
86 constructor
87 and unity::scopes::PreviewWidget::add_attribute_value() / unity::scopes::PreviewWidget::add_attribute_mapping()
88 methods,
89 rather than via JSON definition.
90
91 \param definition The JSON definition.
92 */
93 QPreviewWidgetImpl(QString const& definition);55 QPreviewWidgetImpl(QString const& definition);
56 virtual ~QPreviewWidgetImpl();
9457
95 /**@name Copy and assignment
96 Copy and assignment operators (move and non-move versions) have the usual value semantics.
97 */
98 //{@
99 QPreviewWidgetImpl(QPreviewWidgetImpl const& other);58 QPreviewWidgetImpl(QPreviewWidgetImpl const& other);
100 QPreviewWidgetImpl(QPreviewWidgetImpl&& other);59 QPreviewWidgetImpl(QPreviewWidgetImpl&& other);
101 virtual ~QPreviewWidgetImpl();
10260
103 QPreviewWidgetImpl& operator=(QPreviewWidgetImpl const& other);61 QPreviewWidgetImpl& operator=(QPreviewWidgetImpl const& other);
104 QPreviewWidgetImpl& operator=(QPreviewWidgetImpl&& other);62 QPreviewWidgetImpl& operator=(QPreviewWidgetImpl&& other);
105 //@}
10663
107 /**
108 \brief Adds an attribute definition and its value.
109 \param key The name of the attribute.
110 \param value The value of the attribute.
111 */
112 void add_attribute_value(QString const& key, QVariant const& value);64 void add_attribute_value(QString const& key, QVariant const& value);
113
114 /**
115 \brief Adds an attribute definition using a component mapping.
116
117 If an attribute value is either not known, or the value is already present
118 in a result field, this method creates a mapping between the attribute
119 name and given the field name.
120
121 If an attribute value is not known, the scope is expected to push the attribute value using
122 unity::scopes::PreviewReply::push(); otherwise, the value is automatically
123 mapped from the result.
124 */
125 void add_attribute_mapping(QString const& key, QString const& field_name);65 void add_attribute_mapping(QString const& key, QString const& field_name);
126
127 /**
128 \brief Adds a widget into expandable widget.
129
130 Adds a widget into this widget, which needs to be of 'expandable' type. This method throws
131 if adding a widget into any other widget type. Also, adding an 'expandable' widget into
132 another 'expandable' is not allowed.
133
134 \throws unity::LogicException if type of this widget is other than 'expandable', or when
135 adding 'expandable' to 'expandable'.
136 */
137 void add_widget(QPreviewWidget const& widget);66 void add_widget(QPreviewWidget const& widget);
138
139 /**
140 \brief Get the identifier of this widget.
141 \return The widget identifier.
142 */
143 QString id() const;67 QString id() const;
144
145 /**
146 \brief Get type name of this widget.
147 \return The widget type.
148 */
149 QString widget_type() const;68 QString widget_type() const;
150
151 /**
152 \brief Get the components of this widget.
153
154 The returned map is a dictionary of (key, field name) pairs, as defined by calls to add_attribute_mapping().
155 \return The components map.
156 */
157 QMap<QString, QString> attribute_mappings() const;69 QMap<QString, QString> attribute_mappings() const;
158
159 /**
160 \brief Get the attributes of this widget.
161
162 The returned map is a dictionary of (key, value) pairs, as defined by calls to add_attribute_value().
163 \return The attribute map.
164 */
165 QVariantMap attribute_values() const;70 QVariantMap attribute_values() const;
166
167 /**
168 \brief Get widgets of 'expandable' widget.
169
170 Returns the list of widget attached to this widget, which must be of 'expandable' type. This list is
171 always empty for other widget types.
172 */
173 QPreviewWidgetList widgets() const;71 QPreviewWidgetList widgets() const;
174
175 /**
176 \brief Get a JSON representation of this widget.
177 \return The JSON string.
178 */
179 QString data() const;72 QString data() const;
18073
181 /// @cond
182 QVariantMap serialize() const;74 QVariantMap serialize() const;
183 /// @endcond
18475
185private:76private:
186 std::unique_ptr<PreviewWidget> api_widget_;77 std::unique_ptr<PreviewWidget> api_widget_;
18778
=== modified file 'include/unity/scopes/qt/internal/QResultImpl.h'
--- include/unity/scopes/qt/internal/QResultImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QResultImpl.h 2015-02-27 03:36:41 +0000
@@ -54,192 +54,37 @@
54class QResultImpl54class QResultImpl
55{55{
56public:56public:
57 /// @cond
58 UNITY_DEFINES_PTRS(QResultImpl);57 UNITY_DEFINES_PTRS(QResultImpl);
59 /// @endcond
6058
61 /**@name Copy and assignment
62 Copy and assignment (move and non-move versions) have the usual value semantics.
63 */
64 //{@
65 QResultImpl(unity::scopes::Result const& other);59 QResultImpl(unity::scopes::Result const& other);
66 QResultImpl(QResultImpl const& other);60 QResultImpl(QResultImpl const& other);
6761
68 QResultImpl& operator=(QResultImpl const& other);62 QResultImpl& operator=(QResultImpl const& other);
69 QResultImpl& operator=(QResultImpl&&);63 QResultImpl& operator=(QResultImpl&&);
70 //@}
7164
72 /**
73 Destructor.
74 */
75 virtual ~QResultImpl();65 virtual ~QResultImpl();
7666
77 /**
78 \brief Stores a Result inside this Result instance.
79
80 This method is meant to be used by aggregator scopes which want to modify results they receive, but want
81 to keep a copy of the original result so that they can be correctly handled by the original scopes
82 who created them when it comes to activation or previews.
83 Scopes middleware will automatically pass the correct inner stored result to the activation or preview request
84 handler
85 of a scope which created it.
86 \param other The original result to store within this result.
87 \param intercept_activation True if this scope should receive activation and preview requests.
88 */
89 void store(QResult const& other, bool intercept_activation = false);67 void store(QResult const& other, bool intercept_activation = false);
90
91 /**
92 \brief Check if this Result instance has a stored result.
93 \return True if there is a stored result
94 */
95 bool has_stored_result() const;68 bool has_stored_result() const;
96
97 /**
98 \brief Get a stored result.
99 \return stored result
100 \throws unity::InvalidArgumentException if no result was stored in this Result instance.
101 */
102 QResult retrieve() const;69 QResult retrieve() const;
103
104 /**
105 \brief Set the "uri" attribute of this result.
106 */
107 void set_uri(QString const& uri);70 void set_uri(QString const& uri);
108
109 /**
110 \brief Set the "title" attribute of this result.
111
112 Equivalent to calling `result["title"] = title;`
113 */
114 void set_title(QString const& title);71 void set_title(QString const& title);
115 /**
116 \brief Set the "art" attribute of this result.
117
118 Equivalent to calling `result["art"] = image;`
119 */
120 void set_art(QString const& image);72 void set_art(QString const& image);
121
122 /**
123 \brief Set the "dnd_uri" attribute of this result.
124
125 Equivalent to calling `result["dnd_uri"] = dnd_uri;`
126 */
127 void set_dnd_uri(QString const& dnd_uri);73 void set_dnd_uri(QString const& dnd_uri);
128
129 /**
130 \brief Indicates to the receiver that this scope should intercept activation requests for this result.
131
132 By default, a scope receives preview requests for the results it creates, but does not receive activation
133 requests (they are handled directly by the shell).
134 Intercepting activation implies intercepting preview requests as well; this is important for scopes that
135 forward results from other scopes and call set_intercept_activation() on these scopes.
136 A scope that sets intercept activation flag for a result should re-implement ScopeBase::activate()
137 and provide an implementation of ActivationQueryBase that handles the actual activation.
138 If not called, the result will be activated directly by the Unity shell whithout involving the scope,
139 assuming an appropriate URI schema handler is present on the system.
140 */
141 void set_intercept_activation();74 void set_intercept_activation();
142
143 /**
144 \brief Check if this result should be activated directly by the shell
145 because the scope doesn't handle activation of this result.
146 \return True if this result needs to be activated directly.
147 */
148 bool direct_activation() const;75 bool direct_activation() const;
149
150 /**
151 \brief Get the proxy of a scope that handles activation and preview of this result.
152
153 The proxy is available only when receiving this result from a scope, otherwise
154 this method throws LogicException. Activation requests should be sent to a scope
155 returned by this method only if direct_activation() is false.
156 \return The scope proxy.
157 */
158 ScopeProxy target_scope_proxy() const;76 ScopeProxy target_scope_proxy() const;
159
160 /**
161 \brief Returns reference of a Result attribute.
162
163 This method can be used to read or initialize both standard ("uri", "title", "art", "dnd_uri")
164 and custom metadata attributes. Referencing a non-existing attribute automatically creates
165 it with a default value of Variant::Type::Null.
166 \param key The name of the attribute.
167 \return A reference to the attribute.
168 \throws unity::Invalidargument if no attribute with the given name exists.
169 */
170 QVariant& operator[](QString const& key);77 QVariant& operator[](QString const& key);
171
172 /**
173 \brief Returns a const reference to a Result attribute.
174
175 This method can be used for read-only access to both standard ("uri", "title", "art", "dnd_uri")
176 and custom metadata attributes. Referencing a non-existing attribute throws unity::InvalidArgumentException.
177 \param key The name of the attribute.
178 \return A const reference to the attribute.
179 \throws unity::Invalidargument if no attribute with the given name exists.
180 */
181 QVariant const& operator[](QString const& key) const;78 QVariant const& operator[](QString const& key) const;
182
183 /**
184 \brief Get the "uri" property of this Result.
185
186 This method returns an empty string if this attribute is not of type Variant::Type::String (e.g. it was set with
187 operator[]).
188 \return The value of "uri" or the empty string.
189 */
190 QString uri() const noexcept;79 QString uri() const noexcept;
191
192 /**
193 \brief Get the "title" property of this Result.
194
195 This method returns an empty string if this attribute is not of type Variant::Type::String (e.g. it was set with
196 operator[]).
197 \return The value of "title" or the empty string.
198 */
199 QString title() const noexcept;80 QString title() const noexcept;
200
201 /**
202 \brief Get the "art" property of this Result.
203
204 This method returns an empty string if this attribute is not of type Variant::Type::String (e.g. it was set with
205 operator[]).
206 \return The value of "art" or the empty string.
207 */
208 QString art() const noexcept;81 QString art() const noexcept;
209
210 /**
211 \brief Get the "dnd_uri" property of this Result.
212
213 This method returns an empty string if this attribute is not of type Variant::Type::String type (e.g. it was set
214 with operator[]).
215 \return The value of "dnd_uri" or the empty string.
216 */
217 QString dnd_uri() const noexcept;82 QString dnd_uri() const noexcept;
218
219 /**
220 \brief Check if this Result has an attribute.
221 \param key The attribute name.
222 \return True if the attribute is set.
223 */
224 bool contains(QString const& key) const;83 bool contains(QString const& key) const;
225
226 /**
227 \brief Get the value of an attribute.
228
229 \param key The attribute name.
230 \return The attribute value.
231 \throws unity::InvalidArgumentException if given attribute hasn't been set.
232 */
233 QVariant const& value(QString const& key) const;84 QVariant const& value(QString const& key) const;
234
235 /**
236 \brief Returns a dictionary of all attributes of this Result instance.
237 \return All base attributes and custom attributes set with add_metadata().
238 */
239 QVariantMap serialize() const;85 QVariantMap serialize() const;
24086
241protected:87protected:
242 /// @cond
243 explicit QResultImpl(const QVariantMap& variant_map);88 explicit QResultImpl(const QVariantMap& variant_map);
244 explicit QResultImpl(internal::QResultImpl* impl);89 explicit QResultImpl(internal::QResultImpl* impl);
245 explicit QResultImpl(unity::scopes::Result* api_result);90 explicit QResultImpl(unity::scopes::Result* api_result);
24691
=== modified file 'include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h'
--- include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/internal/QScopeBaseAPIImpl.h 2015-02-27 03:36:41 +0000
@@ -52,62 +52,29 @@
52{52{
53 Q_OBJECT53 Q_OBJECT
54public:54public:
55 /// @cond
56 using FactoryFunc = std::function<QScopeBase*()>;55 using FactoryFunc = std::function<QScopeBase*()>;
5756
58 NONCOPYABLE(QScopeBaseAPIImpl);57 NONCOPYABLE(QScopeBaseAPIImpl);
59 UNITY_DEFINES_PTRS(QScopeBaseAPIImpl);58 UNITY_DEFINES_PTRS(QScopeBaseAPIImpl);
6059
61 QScopeBaseAPIImpl(QScopeBase& qtscope, QObject* parent = 0);60 QScopeBaseAPIImpl(FactoryFunc const& creator);
62 QScopeBaseAPIImpl(FactoryFunc const& creator, QObject* parent = 0);
63 virtual ~QScopeBaseAPIImpl();61 virtual ~QScopeBaseAPIImpl();
6462
65 bool event(QEvent* e) override;63 bool event(QEvent* e) override;
66 /// @endcond
67
68 /**
69 \brief Called by the scopes run time after the create function completes.
70
71 If start() throws an exception, stop() will _not_ be called.
72
73 The call to start() is made by the same thread that calls the create function.
74
75 \param scope_id The name of the scope as defined by the scope's configuration file.
76 */
77 void start(std::string const& scope_id);64 void start(std::string const& scope_id);
78
79 /**
80 \brief Called by the scopes run time when the scope should shut down.
81
82 A scope should deallocate as many resources as possible when stop() is called, for example,
83 deallocate any caches and close network connections. In addition, if the scope implements run()
84 and did not return from run(), it must return from run() in response to the call to stop().
85
86 Exceptions from stop() are ignored.
87
88 The call to stop() is made by the same thread that calls the create function and start().
89 */
90 void stop();65 void stop();
91
92 /**
93 * Called each time a new preview is requested
94 */
95 unity::scopes::PreviewQueryBase::UPtr preview(const unity::scopes::Result&, const unity::scopes::ActionMetadata&);66 unity::scopes::PreviewQueryBase::UPtr preview(const unity::scopes::Result&, const unity::scopes::ActionMetadata&);
96
97 /**
98 * Called each time a new query is requested
99 */
100 unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const& q,67 unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const& q,
101 unity::scopes::SearchMetadata const&);68 unity::scopes::SearchMetadata const&);
10269
103protected:70protected:
104 void startQtThread();71 void start_qt_thread();
10572
106 std::shared_ptr<QCoreApplication> qtapp_;73 std::shared_ptr<QCoreApplication> qtapp_;
107 std::unique_ptr<std::thread> qtthread_;74 std::unique_ptr<std::thread> qtthread_;
108 std::atomic<bool> qtapp_ready_;75 std::atomic<bool> qtapp_ready_;
10976 std::atomic<bool> qtapp_stopped_;
110 QScopeBase* qtscope_impl_;77 std::unique_ptr<QScopeBase> qtscope_impl_;
11178
112 FactoryFunc qtscope_creator_;79 FactoryFunc qtscope_creator_;
113};80};
11481
=== modified file 'include/unity/scopes/qt/internal/QScopeBaseImpl.h'
--- include/unity/scopes/qt/internal/QScopeBaseImpl.h 2015-01-20 13:59:36 +0000
+++ include/unity/scopes/qt/internal/QScopeBaseImpl.h 2015-02-27 03:36:41 +0000
@@ -38,21 +38,13 @@
38class QScopeBaseImpl38class QScopeBaseImpl
39{39{
40public:40public:
41 /// @cond
42 NONCOPYABLE(QScopeBaseImpl);41 NONCOPYABLE(QScopeBaseImpl);
43 UNITY_DEFINES_PTRS(QScopeBaseImpl);42 UNITY_DEFINES_PTRS(QScopeBaseImpl);
4443
45 QScopeBaseImpl() = default;44 QScopeBaseImpl() = default;
46 virtual ~QScopeBaseImpl() = default;45 virtual ~QScopeBaseImpl() = default;
47 /// @endcond46
48 /**
49 * Called once at startup
50 */
51 virtual void start(std::string const&);47 virtual void start(std::string const&);
52
53 /**
54 * Called at shutdown
55 */
56 virtual void stop();48 virtual void stop();
57};49};
5850
5951
=== modified file 'include/unity/scopes/qt/internal/QScopeVariant.h'
--- include/unity/scopes/qt/internal/QScopeVariant.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QScopeVariant.h 2015-02-27 03:36:41 +0000
@@ -45,7 +45,6 @@
45class QScopeVariant : public QVariant45class QScopeVariant : public QVariant
46{46{
47public:47public:
48 // explicit QScopeVariant() noexcept;
49 virtual ~QScopeVariant();48 virtual ~QScopeVariant();
5049
51 QScopeVariant(QScopeVariant const& other);50 QScopeVariant(QScopeVariant const& other);
@@ -65,9 +64,6 @@
65 std::string get_string() const;64 std::string get_string() const;
6665
67private:66private:
68 /**
69 \brief Creates a Variant instance that stores the supplied integer.
70 */
71 explicit QScopeVariant(Variant* val) noexcept;67 explicit QScopeVariant(Variant* val) noexcept;
7268
73 void setInternalVariant(Variant* val);69 void setInternalVariant(Variant* val);
7470
=== modified file 'include/unity/scopes/qt/internal/QSearchMetadataImpl.h'
--- include/unity/scopes/qt/internal/QSearchMetadataImpl.h 2015-02-06 00:12:18 +0000
+++ include/unity/scopes/qt/internal/QSearchMetadataImpl.h 2015-02-27 03:36:41 +0000
@@ -45,114 +45,27 @@
45class QSearchMetadataImpl45class QSearchMetadataImpl
46{46{
47public:47public:
48 /// @cond
49 UNITY_DEFINES_PTRS(QSearchMetadataImpl);48 UNITY_DEFINES_PTRS(QSearchMetadataImpl);
50 /// @endcond
5149
52 /**
53 \brief Create SearchMetadata with the given locale and form factor.
54 \param locale locale string, eg. en_EN
55 \param form_factor form factor name, e.g. phone, desktop, phone-version etc.
56 */
57 QSearchMetadataImpl(QString const& locale, QString const& form_factor);50 QSearchMetadataImpl(QString const& locale, QString const& form_factor);
58
59 /**
60 \brief Create SearchMetadata with the given cardinality, locale, and form factor.
61 \param cardinality maximum number of search results
62 \param locale locale string, eg. en_EN
63 \param form_factor form factor name, e.g. phone, desktop, phone-version etc.
64 */
65 QSearchMetadataImpl(int cardinality, QString const& locale, QString const& form_factor);51 QSearchMetadataImpl(int cardinality, QString const& locale, QString const& form_factor);
52 ~QSearchMetadataImpl();
6653
67 /**@name Copy and assignment
68 Copy and assignment operators (move and non-move versions) have the usual value semantics.
69 */
70 //{@
71 QSearchMetadataImpl(QSearchMetadataImpl const& other);54 QSearchMetadataImpl(QSearchMetadataImpl const& other);
72 QSearchMetadataImpl(QSearchMetadataImpl&&);55 QSearchMetadataImpl(QSearchMetadataImpl&&);
7356
74 QSearchMetadataImpl& operator=(QSearchMetadataImpl const& other);57 QSearchMetadataImpl& operator=(QSearchMetadataImpl const& other);
75 QSearchMetadataImpl& operator=(QSearchMetadataImpl&&);58 QSearchMetadataImpl& operator=(QSearchMetadataImpl&&);
76 //@}59
77
78 /// @cond
79 ~QSearchMetadataImpl();
80 /// @endcond
81
82 /**
83 \brief Set cardinality.
84 \param cardinality The maximum number of search results.
85 */
86 void set_cardinality(int cardinality);60 void set_cardinality(int cardinality);
87
88 /**
89 \brief Get cardinality.
90 \return The maxmium number of search results, or 0 for no limit.
91 */
92 int cardinality() const;61 int cardinality() const;
93
94 /**
95 \brief Set location.
96 \param location Location data.
97 */
98 void set_location(Location const& location);62 void set_location(Location const& location);
99
100 /**
101 \brief Get location.
102 \return Location data representing the current location, including attributes such as city and country.
103 \throws unity::NotFoundException if no location data is available.
104 */
105 Location location() const;63 Location location() const;
106
107 /**
108 \brief Does the SearchMetadata have a location.
109 \return True if there is a location property.
110 */
111 bool has_location() const;64 bool has_location() const;
112
113 /**
114 \brief Sets a hint.
115
116 \param key The name of the hint.
117 \param value Hint value
118 */
119 void set_hint(QString const& key, QVariant const& value);65 void set_hint(QString const& key, QVariant const& value);
120
121 /**
122 \brief Get all hints.
123
124 \return Hints dictionary.
125 \throws unity::NotFoundException if no hints are available.
126 */
127 QVariantMap hints() const;66 QVariantMap hints() const;
128
129 /**
130 \brief Check if this SearchMetadata has a hint.
131 \param key The hint name.
132 \return True if the hint is set.
133 */
134 bool contains_hint(QString const& key) const;67 bool contains_hint(QString const& key) const;
135
136 /**
137 \brief Returns a reference to a hint.
138
139 This method can be used to read or set hints. Setting a value of an existing hint overwrites
140 its previous value.
141 Referencing a non-existing hint automatically creates it with a default value of Variant::Type::Null.
142 \param key The name of the hint.
143 \return A reference to the hint.
144 */
145 QScopeVariant& operator[](QString const& key);68 QScopeVariant& operator[](QString const& key);
146
147 /**
148 \brief Returns a const reference to a hint.
149
150 This method can be used for read-only access to hints.
151 Referencing a non-existing hint throws unity::InvalidArgumentException.
152 \param key The name of the hint.
153 \return A const reference to the hint.
154 \throws unity::NotFoundException if no hint with the given name exists.
155 */
156 QVariant const& value(QString const& key) const;69 QVariant const& value(QString const& key) const;
15770
158private:71private:
15972
=== modified file 'include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h'
--- include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h 2015-02-02 07:46:12 +0000
+++ include/unity/scopes/qt/internal/QSearchQueryBaseImpl.h 2015-02-27 03:36:41 +0000
@@ -50,41 +50,15 @@
50 friend QSearchQueryBase;50 friend QSearchQueryBase;
5151
52public:52public:
53 /// @cond
54 NONCOPYABLE(QSearchQueryBaseImpl);53 NONCOPYABLE(QSearchQueryBaseImpl);
55 UNITY_DEFINES_PTRS(QSearchQueryBaseImpl);54 UNITY_DEFINES_PTRS(QSearchQueryBaseImpl);
56 /// @endcond
5755
58 QSearchQueryBaseImpl();56 QSearchQueryBaseImpl();
59 ~QSearchQueryBaseImpl() = default;57 ~QSearchQueryBaseImpl() = default;
6058
61 /**
62 \brief Get a canned query for this search request.
63
64 \return The canned query.
65 \throws unity::LogicException if the canned query was not initialized (was default-constructed).
66 */
67 QCannedQuery query() const;59 QCannedQuery query() const;
68
69 /**
70 \brief Get metadata for this search request.
71 \return The search metadata.
72 \throws unity::LogicException if search metadata was not initialized (was default-constructed).
73 */
74 unity::scopes::SearchMetadata search_metadata() const;60 unity::scopes::SearchMetadata search_metadata() const;
7561
76 /** @name Subquery methods
77 The subsearch() methods are for use by aggregating scopes.
78 When an aggregator passes a query to its child scopes, it should
79 use subsearch() instead of the normal Scope::search()
80 that would be called by a client. subsearch() takes care
81 of automatically forwarding query cancellation to child scopes.
82 This means that there is no need for an aggregating scope to
83 explicitly forward cancellation to child scopes
84 when its QueryBase::cancelled() method is called by the scopes
85 run time.
86 */
87 //{@
88 QueryCtrlProxy subsearch(ScopeProxy const& scope,62 QueryCtrlProxy subsearch(ScopeProxy const& scope,
89 std::string const& query_string,63 std::string const& query_string,
90 SearchListenerBase::SPtr const& reply);64 SearchListenerBase::SPtr const& reply);
9165
=== modified file 'include/unity/scopes/qt/internal/QSearchReplyImpl.h'
--- include/unity/scopes/qt/internal/QSearchReplyImpl.h 2015-02-02 07:46:12 +0000
+++ include/unity/scopes/qt/internal/QSearchReplyImpl.h 2015-02-27 03:36:41 +0000
@@ -52,96 +52,17 @@
52 friend class unity::scopes::qt::QSearchReply;52 friend class unity::scopes::qt::QSearchReply;
5353
54public:54public:
55 /// @cond
56 NONCOPYABLE(QSearchReplyImpl);55 NONCOPYABLE(QSearchReplyImpl);
57 UNITY_DEFINES_PTRS(QSearchReplyImpl);56 UNITY_DEFINES_PTRS(QSearchReplyImpl);
58 /// @endcond57
59 /**
60 \brief Destroys a QSearchReplyImpl.
61 */
62 virtual ~QSearchReplyImpl();58 virtual ~QSearchReplyImpl();
63
64 /**
65 \brief Register departments for the current search reply and provide the current department.
66
67 Departments are optional. If scope supports departments, it is expected to register departments on every search as
68 follows:
69
70 <ul>
71 <li>create a Department node for current department and attach to it a list of its subdepartments (unless current
72 department is a leaf department) using
73 unity::scopes::Department::set_subdepartments() method. For every subdepartment on the list set
74 "has_subdepartments" flag if applicable.
75 <li>provide an alternate label for current department with unity::scopes::Department::set_alternate_label().
76 <li>create a Department node for parent of current department (if applicable - not when in root department), and
77 attach current Department node to it with
78 unity::scopes::Department::set_subdepartments() method.
79 <li>register the parent department with unity::scopes::SearchReply::register_departments().
80 </ul>
81
82 For example, assuming the user is visiting a "History" department in "Books", and "History" has sub-departments
83 such as "World War Two" and "Ancient", the code
84 that registers departments for current search in "History" may look like this:
85 \code{.cpp}
86 unity::scopes::Department::SPtr books = move(unity::scopes::Department::create("books", query, "Books")); // the
87 parent of "History"
88 unity::scopes::Department::SPtr history = move(unity::scopes::Department::create("history", query, "History"));
89 unity::scopes::DepartmentList history_depts({
90 move(unity::scopes::Department::create("ww2", query, "World War Two")),
91 move(unity::scopes::Department::create("ancient", query, "Ancient"))});
92 history->set_subdepartments(history_depts);
93 books->set_subdepartments({history});
94 reply->register_departments(books);
95 \endcode
96
97 Current department should be the department returned by unity::scopes::CannedQuery::department_id(). Empty
98 department id denotes
99 the root deparment.
100
101 \param parent The parent department of current department, or current one if visiting root department.
102 \throws unity::LogicException if departments are invalid (nullptr passed, current department not present in the
103 parent's tree, duplicated department ids present in the tree).
104 */
105 virtual void register_departments(QDepartment::SCPtr const& parent);59 virtual void register_departments(QDepartment::SCPtr const& parent);
106
107 /**
108 \brief Register new category and send it to the source of the query.
109
110 \param id The identifier of the category
111 \param title The title of the category
112 \param icon The icon of the category
113 \param renderer_template The renderer template to be used for results in this category
114
115 \return The category instance
116 \throws unity::scopes::InvalidArgumentException if category with that id has already been registered.
117 */
118 QCategory::SCPtr register_category(60 QCategory::SCPtr register_category(
119 QString const& id,61 QString const& id,
120 QString const& title,62 QString const& title,
121 QString const& icon,63 QString const& icon,
122 unity::scopes::CategoryRenderer const& renderer_template = unity::scopes::CategoryRenderer());64 unity::scopes::CategoryRenderer const& renderer_template = unity::scopes::CategoryRenderer());
123
124 /**
125 \brief Sends a single result to the source of a query.
126
127 Any calls to push() after finished() was called are ignored.
128 \return The return value is true if the result was accepted, false otherwise.
129 A false return value can be due to finished() having been called earlier,
130 or the client that sent the query having cancelled that query. The return
131 value is false also if the query has a cardinality limit and is reached
132 or exceeded. (The return value is false for the last valid push and
133 subsequent pushes.)
134 */
135 bool push(QCategorisedResult const& result);65 bool push(QCategorisedResult const& result);
136
137 /**
138 \brief Informs the source of a query that the query was terminated due to an error.
139
140 Multiple calls to error() and calls to finished() after error() was called are ignored.
141 \param ex An exception_ptr indicating the cause of the error. If ex is a `std::exception`,
142 the return value of `what()` is made available to the query source. Otherwise,
143 the query source receives `"unknown exception"`.
144 */
145 void error(std::exception_ptr ex);66 void error(std::exception_ptr ex);
14667
147protected:68protected:
14869
=== modified file 'include/unity/scopes/qt/internal/QUtils.h'
--- include/unity/scopes/qt/internal/QUtils.h 2015-02-27 03:36:41 +0000
+++ include/unity/scopes/qt/internal/QUtils.h 2015-02-27 03:36:41 +0000
@@ -18,10 +18,6 @@
1818
19#pragma once19#pragma once
2020
21#ifndef _ENABLE_QT_EXPERIMENTAL_
22#error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file.
23#endif
24
25#pragma GCC diagnostic push21#pragma GCC diagnostic push
26#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"22#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
27#include <QtCore/QVariant>23#include <QtCore/QVariant>
2824
=== modified file 'src/scopes/qt/QActionMetadata.cpp'
--- src/scopes/qt/QActionMetadata.cpp 2015-01-26 15:25:30 +0000
+++ src/scopes/qt/QActionMetadata.cpp 2015-02-27 03:36:41 +0000
@@ -32,7 +32,7 @@
32}32}
3333
34QActionMetadata::QActionMetadata(internal::QActionMetadataImpl* impl)34QActionMetadata::QActionMetadata(internal::QActionMetadataImpl* impl)
35 : p(new internal::QActionMetadataImpl(*impl))35 : p(impl)
36{36{
37}37}
3838
3939
=== modified file 'src/scopes/qt/QPreviewWidget.cpp'
--- src/scopes/qt/QPreviewWidget.cpp 2015-01-20 14:14:26 +0000
+++ src/scopes/qt/QPreviewWidget.cpp 2015-02-27 03:36:41 +0000
@@ -104,7 +104,7 @@
104}104}
105105
106QPreviewWidget::QPreviewWidget(internal::QPreviewWidgetImpl* widget)106QPreviewWidget::QPreviewWidget(internal::QPreviewWidgetImpl* widget)
107 : p(new internal::QPreviewWidgetImpl(*widget))107 : p(widget)
108{108{
109}109}
110/// @endcond110/// @endcond
111111
=== modified file 'src/scopes/qt/QResult.cpp'
--- src/scopes/qt/QResult.cpp 2015-02-27 03:36:41 +0000
+++ src/scopes/qt/QResult.cpp 2015-02-27 03:36:41 +0000
@@ -24,11 +24,6 @@
24using namespace unity::scopes::qt;24using namespace unity::scopes::qt;
2525
26/// @cond26/// @cond
27QResult::QResult()
28 : p(new internal::QResultImpl(QVariantMap()))
29{
30}
31
32QResult::QResult(internal::QResultImpl* impl)27QResult::QResult(internal::QResultImpl* impl)
33 : p(impl)28 : p(impl)
34{29{
@@ -123,7 +118,7 @@
123118
124QVariant const& QResult::operator[](QString const& key) const119QVariant const& QResult::operator[](QString const& key) const
125{120{
126 return p->value(key);121 return (*static_cast<internal::QResultImpl const*>(p.get()))[key];
127}122}
128123
129QString QResult::uri() const noexcept124QString QResult::uri() const noexcept
130125
=== modified file 'src/scopes/qt/internal/QResultImpl.cpp'
--- src/scopes/qt/internal/QResultImpl.cpp 2015-02-27 03:36:41 +0000
+++ src/scopes/qt/internal/QResultImpl.cpp 2015-02-27 03:36:41 +0000
@@ -28,61 +28,19 @@
28using namespace unity::scopes::qt;28using namespace unity::scopes::qt;
29using namespace unity::scopes::qt::internal;29using namespace unity::scopes::qt::internal;
3030
31namespace unity31namespace
32{
33
34namespace scopes
35{
36
37namespace qt
38{
39
40namespace internal
41{32{
4233
43class APIResult : public Result34class APIResult : public Result
44{35{
45public:36public:
46 APIResult(APIResult const& other)
47 : Result(other){};
48
49 APIResult(APIResult&&) = default;
50
51 APIResult& operator=(APIResult const& other)
52 {
53 if (this != &other)
54 {
55 *this = other;
56 }
57 return *this;
58 }
59
60 APIResult& operator=(APIResult&&) = default;
61
62 APIResult(const QVariantMap& variant_map)37 APIResult(const QVariantMap& variant_map)
63 : Result(qvariantmap_to_variantmap(variant_map)){};38 : Result(qvariantmap_to_variantmap(variant_map))
64
65 static VariantMap getValidEmptyMap()
66 {39 {
67 VariantMap retMap;
68 VariantMap emptyMap;
69 VariantMap attrsMap;
70
71 attrsMap["uri"] = Variant(std::string());
72 retMap["internal"] = emptyMap;
73 retMap["attrs"] = attrsMap;
74
75 return retMap;
76 }40 }
77};41};
7842
79} // namespace internal43} // namespace
80
81} // namespace qt
82
83} // namespace scopes
84
85} // namespace unity
8644
87QResultImpl::QResultImpl(unity::scopes::Result* api_result)45QResultImpl::QResultImpl(unity::scopes::Result* api_result)
88 : api_result_(api_result)46 : api_result_(api_result)
@@ -95,8 +53,9 @@
95}53}
9654
97QResultImpl::QResultImpl(internal::QResultImpl* impl)55QResultImpl::QResultImpl(internal::QResultImpl* impl)
98 : api_result_(impl->api_result_.get())
99{56{
57 impl->sync_values();
58 api_result_.reset(new Result(*(impl->api_result_)));
100}59}
10160
102QResultImpl::QResultImpl(QResultImpl const& other)61QResultImpl::QResultImpl(QResultImpl const& other)
10362
=== modified file 'src/scopes/qt/internal/QScopeBaseAPIImpl.cpp'
--- src/scopes/qt/internal/QScopeBaseAPIImpl.cpp 2015-02-27 03:36:41 +0000
+++ src/scopes/qt/internal/QScopeBaseAPIImpl.cpp 2015-02-27 03:36:41 +0000
@@ -78,16 +78,10 @@
7878
79} // namespace unity79} // namespace unity
8080
81QScopeBaseAPIImpl::QScopeBaseAPIImpl(QScopeBase& qtscope, QObject* parent)81QScopeBaseAPIImpl::QScopeBaseAPIImpl(FactoryFunc const& creator)
82 : QObject(parent)82 : QObject(nullptr)
83 , qtapp_ready_(false)83 , qtapp_ready_(false)
84 , qtscope_impl_(&qtscope)84 , qtapp_stopped_(false)
85{
86}
87
88QScopeBaseAPIImpl::QScopeBaseAPIImpl(FactoryFunc const& creator, QObject* parent)
89 : QObject(parent)
90 , qtapp_ready_(false)
91 , qtscope_impl_(nullptr)85 , qtscope_impl_(nullptr)
92 , qtscope_creator_(creator)86 , qtscope_creator_(creator)
93{87{
@@ -109,11 +103,8 @@
109 case Start:103 case Start:
110 // create the client's scope in the104 // create the client's scope in the
111 // Qt main thread105 // Qt main thread
112 if (!qtscope_impl_)106 qtscope_impl_.reset(qtscope_creator_());
113 {107 assert(qtscope_impl_);
114 qtscope_impl_ = qtscope_creator_();
115 assert(qtscope_impl_);
116 }
117 // Move the user's scope to the Qt main thread108 // Move the user's scope to the Qt main thread
118 qtscope_impl_->moveToThread(qtapp_->thread());109 qtscope_impl_->moveToThread(qtapp_->thread());
119110
@@ -132,15 +123,14 @@
132 return true;123 return true;
133}124}
134125
135void QScopeBaseAPIImpl::start(std::string const& scope_id)126void QScopeBaseAPIImpl::start(string const& scope_id)
136{127{
137 // start the QT thread128 // start the QT thread
138 // TODO change to make_unique when using C++14129 // TODO change to make_unique when using C++14
139 qtthread_ = std::unique_ptr<std::thread>(new std::thread(&QScopeBaseAPIImpl::startQtThread, this));130 qtthread_ = unique_ptr<std::thread>(new std::thread(&QScopeBaseAPIImpl::start_qt_thread, this));
140 while (!qtapp_ready_)131 while (!qtapp_ready_)
141 {132 {
142 std::chrono::milliseconds dura(10);133 this_thread::sleep_for(chrono::milliseconds(10));
143 std::this_thread::sleep_for(dura);
144 }134 }
145135
146 // Move this class to the Qt main thread136 // Move this class to the Qt main thread
@@ -153,7 +143,7 @@
153143
154void QScopeBaseAPIImpl::stop()144void QScopeBaseAPIImpl::stop()
155{145{
156 // Post event to initialize the object in the Qt thread146 // Post event to stop the object in the Qt thread
157 qtapp_->postEvent(this, new StopEvent());147 qtapp_->postEvent(this, new StopEvent());
158}148}
159149
@@ -176,16 +166,17 @@
176 return sc::SearchQueryBase::UPtr(query_api);166 return sc::SearchQueryBase::UPtr(query_api);
177}167}
178168
179void QScopeBaseAPIImpl::startQtThread()169void QScopeBaseAPIImpl::start_qt_thread()
180{170{
181 if (!QCoreApplication::instance())171 if (!QCoreApplication::instance())
182 {172 {
183 int argc = 0;173 int argc = 0;
184 char* argv = NULL;174 char* argv = NULL;
185 qtapp_ = std::make_shared<QCoreApplication>(argc, &argv);175 qtapp_ = make_shared<QCoreApplication>(argc, &argv);
186 qtapp_ready_ = true;176 qtapp_ready_ = true;
187 qtapp_->exec();177 qtapp_->exec();
188 // delete QtCoreApplication in the same thread it was created178 // delete QtCoreApplication in the same thread it was created
189 qtapp_.reset();179 qtapp_.reset();
180 qtapp_stopped_ = true;
190 }181 }
191}182}
192183
=== modified file 'test/gtest/scopes/qt/qt-bindings/CMakeLists.txt'
--- test/gtest/scopes/qt/qt-bindings/CMakeLists.txt 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/CMakeLists.txt 2015-02-27 03:36:41 +0000
@@ -222,3 +222,22 @@
222qt5_use_modules(QScopeCreation_test Core)222qt5_use_modules(QScopeCreation_test Core)
223223
224add_test(QScopeCreation QScopeCreation_test)224add_test(QScopeCreation QScopeCreation_test)
225
226###################################################
227
228add_executable(
229 QPreviewWidget_test
230 QPreviewWidget_test.cpp)
231
232target_link_libraries(
233 QPreviewWidget_test
234 ${LIBGTEST}
235 ${TESTLIBS_QT}
236 ${TESTLIBS})
237
238find_package(Qt5Core REQUIRED)
239include_directories(${Qt5Core_INCLUDE_DIRS})
240
241qt5_use_modules(QPreviewWidget_test Core)
242
243add_test(QPreviewWidget QPreviewWidget_test)
225244
=== modified file 'test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp'
--- test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/QCategorisedResult_test.cpp 2015-02-27 03:36:41 +0000
@@ -23,11 +23,15 @@
2323
24#include <unity/scopes/qt/internal/QCategorisedResultImpl.h>24#include <unity/scopes/qt/internal/QCategorisedResultImpl.h>
25#include <unity/scopes/qt/internal/QCategoryImpl.h>25#include <unity/scopes/qt/internal/QCategoryImpl.h>
26#include <unity/scopes/qt/internal/QUtils.h>
2627
28#include <unity/scopes/CategorisedResult.h>
27#include <unity/scopes/Category.h>29#include <unity/scopes/Category.h>
28#include <unity/scopes/CategoryRenderer.h>30#include <unity/scopes/CategoryRenderer.h>
29#include <unity/scopes/internal/CategoryRegistry.h>31#include <unity/scopes/internal/CategoryRegistry.h>
3032
33#include <unity/UnityExceptions.h>
34
31using namespace unity::scopes;35using namespace unity::scopes;
32using namespace unity::scopes::internal;36using namespace unity::scopes::internal;
33using namespace unity::scopes::qt;37using namespace unity::scopes::qt;
@@ -106,3 +110,115 @@
106 EXPECT_EQ("2", ri1.category()->id());110 EXPECT_EQ("2", ri1.category()->id());
107 }111 }
108}112}
113
114// Tests for QResult base class
115
116TEST(QCategorisedResult, QResult)
117{
118 std::shared_ptr<QCategory const> out_cat = QCategorisedResult_test::create_category("1");
119 std::shared_ptr<QCategory const> in_cat = QCategorisedResult_test::create_category("2");
120
121 QCategorisedResult out_result(out_cat);
122 out_result.set_uri("test_uri1");
123 out_result.set_title("title1");
124 out_result.set_art("art1");
125 out_result.set_dnd_uri("dnd_uri1");
126 out_result["key"] = "value";
127 EXPECT_EQ("test_uri1", out_result.uri());
128 EXPECT_EQ("title1", out_result.title());
129 EXPECT_EQ("art1", out_result.art());
130 EXPECT_EQ("dnd_uri1", out_result.dnd_uri());
131 EXPECT_TRUE(out_result.contains("key"));
132 EXPECT_EQ("value", out_result.value("key"));
133 try
134 {
135 out_result.target_scope_proxy();
136 FAIL();
137 }
138 catch (unity::LogicException const& e)
139 {
140 EXPECT_STREQ("unity::LogicException: Result::target_scope_proxy(): undefined target scope", e.what());
141 }
142
143 EXPECT_TRUE(out_result.direct_activation());
144 out_result.set_intercept_activation();
145 EXPECT_FALSE(out_result.direct_activation());
146
147 // TODO: No way to get JSON from Qvariant at the moment.
148 std::string json = Variant(qt::internal::qvariantmap_to_variantmap(out_result.serialize())).serialize_json();
149 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";
150 EXPECT_EQ(expected, json);
151
152 QCategorisedResult in_result(in_cat);
153 in_result.set_uri("test_uri2");
154 in_result.set_title("title2");
155
156 EXPECT_FALSE(out_result.has_stored_result());
157 out_result.store(in_result);
158 EXPECT_TRUE(out_result.has_stored_result());
159
160 QResult r = out_result.retrieve();
161 EXPECT_EQ(in_result.uri(), r.uri()); // TODO: Can't use in_result == r here because retrive() slices the class :-(
162 // That's a flaw in the underlying API
163 QResult const qvc(out_result);
164 EXPECT_EQ("value", qvc["key"]);
165
166 // Copy and assignment
167
168 {
169 QResult c(out_result);
170 EXPECT_EQ("title1", c.title());
171 }
172
173 {
174 QResult c(out_result);
175 c = in_result;
176 EXPECT_EQ("title2", c.title());
177 c = c;
178 EXPECT_EQ("title2", c.title());
179 }
180
181 {
182 CategoryRegistry reg;
183 CategoryRenderer rdr;
184 auto cat = reg.register_category("1", "title", "icon", nullptr, rdr);
185 CategorisedResult result(cat);
186 result.set_title("t");
187
188 // QResult construction from Result is protected.
189 struct Tester : public QResult
190 {
191 Tester(Result const& result)
192 : QResult(result)
193 {
194 }
195 };
196
197 Tester t(result);
198 EXPECT_EQ("t", t.title());
199
200 // QResultImpl construction from QResultImpl* is protected.
201 struct ImplTester : public qt::internal::QResultImpl
202 {
203 ImplTester(QResultImpl* qri)
204 : QResultImpl(qri)
205 {
206 }
207
208 ImplTester(Result const& r)
209 : QResultImpl(r)
210 {
211 EXPECT_EQ("t", r.title());
212 qt::internal::QResultImpl* qrip = new QResultImpl(r);
213 EXPECT_EQ("t", qrip->title());
214
215 // This is the real test to see that this constructor works
216 ImplTester copy(qrip);
217 EXPECT_EQ("t", copy.title());
218 delete qrip;
219 }
220 };
221
222 ImplTester it(result);
223 }
224}
109225
=== modified file 'test/gtest/scopes/qt/qt-bindings/QMockScope.h'
--- test/gtest/scopes/qt/qt-bindings/QMockScope.h 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/QMockScope.h 2015-02-27 03:36:41 +0000
@@ -24,16 +24,19 @@
2424
25#include <QtCore/QThread>25#include <QtCore/QThread>
2626
27#include <mutex>
28
27class QScopeMock : public QScope29class QScopeMock : public QScope
28{30{
29public:31public:
30 QScopeMock()32 QScopeMock()
31 : QScope()33 : QScope()
32 , qt_thread(nullptr){};34 , qt_thread_(nullptr){};
3335
34 void setQtThread(QThread* thread)36 void set_qt_thread(QThread* thread)
35 {37 {
36 qt_thread = thread;38 std::lock_guard<std::mutex> lock(mutex_);
39 qt_thread_ = thread;
37 }40 }
3841
39 MOCK_METHOD1(start, void(QString const&));42 MOCK_METHOD1(start, void(QString const&));
@@ -41,17 +44,20 @@
41 virtual unity::scopes::qt::QPreviewQueryBase::UPtr preview(const unity::scopes::qt::QResult&,44 virtual unity::scopes::qt::QPreviewQueryBase::UPtr preview(const unity::scopes::qt::QResult&,
42 const unity::scopes::qt::QActionMetadata&) override45 const unity::scopes::qt::QActionMetadata&) override
43 {46 {
44 EXPECT_EQ(QThread::currentThread(), qt_thread);47 std::lock_guard<std::mutex> lock(mutex_);
48 EXPECT_EQ(QThread::currentThread(), qt_thread_);
45 return unity::scopes::qt::QPreviewQueryBase::UPtr(new QPreview());49 return unity::scopes::qt::QPreviewQueryBase::UPtr(new QPreview());
46 }50 }
4751
48 virtual unity::scopes::qt::QSearchQueryBase::UPtr search(unity::scopes::CannedQuery const&,52 virtual unity::scopes::qt::QSearchQueryBase::UPtr search(unity::scopes::CannedQuery const&,
49 unity::scopes::SearchMetadata const&) override53 unity::scopes::SearchMetadata const&) override
50 {54 {
51 EXPECT_EQ(QThread::currentThread(), qt_thread);55 std::lock_guard<std::mutex> lock(mutex_);
56 EXPECT_EQ(QThread::currentThread(), qt_thread_);
52 return unity::scopes::qt::QSearchQueryBase::UPtr(new QQuery());57 return unity::scopes::qt::QSearchQueryBase::UPtr(new QQuery());
53 }58 }
5459
55protected:60protected:
56 QThread* qt_thread;61 QThread* qt_thread_;
62 std::mutex mutex_;
57};63};
5864
=== modified file 'test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp'
--- test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/QPreviewQueryBaseAPI_test.cpp 2015-02-27 03:36:41 +0000
@@ -138,10 +138,10 @@
138{138{
139 QScope scope;139 QScope scope;
140140
141 unity::scopes::internal::ResultImpl* resultImpl = new unity::scopes::internal::ResultImpl();141 unity::scopes::internal::ResultImpl resultImpl;
142 resultImpl->set_uri("test_uri");142 resultImpl.set_uri("test_uri");
143143
144 unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl->serialize());144 unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl.serialize());
145145
146 unity::scopes::CannedQuery query("scopeA", "query", "department");146 unity::scopes::CannedQuery query("scopeA", "query", "department");
147 unity::scopes::ActionMetadata metadata("en", "phone");147 unity::scopes::ActionMetadata metadata("en", "phone");
148148
=== added file 'test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp'
--- test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp 1970-01-01 00:00:00 +0000
+++ test/gtest/scopes/qt/qt-bindings/QPreviewWidget_test.cpp 2015-02-27 03:36:41 +0000
@@ -0,0 +1,117 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Michi Henning <michi.henning@canonical.com>
17 */
18
19#include <gtest/gtest.h>
20
21#include <unity/scopes/qt/QPreviewWidget.h>
22#include <unity/scopes/qt/internal/QPreviewWidgetImpl.h>
23
24using namespace unity::scopes::qt;
25
26TEST(QPreviewWidget, bindings)
27{
28 {
29 QPreviewWidget qpw("id", "video");
30
31 EXPECT_EQ("id", qpw.id());
32 EXPECT_EQ("video", qpw.widget_type());
33 }
34
35 {
36 QPreviewWidget qpw(R"({"id": "img", "type": "image", "components": { "source": "screenshot-url" } })");
37
38 EXPECT_EQ("img", qpw.id());
39 EXPECT_EQ("image", qpw.widget_type());
40
41 auto am = qpw.attribute_mappings();
42 ASSERT_EQ(1, am.size());
43 EXPECT_EQ("screenshot-url", am.value("source"));
44
45 auto av = qpw.attribute_values();
46 ASSERT_EQ(0, av.size());
47
48 auto widgets = qpw.widgets();
49 ASSERT_EQ(0, widgets.size());
50
51 QPreviewWidget qpw2(qpw);
52
53 EXPECT_EQ("img", qpw2.id());
54 EXPECT_EQ("image", qpw2.widget_type());
55
56 QPreviewWidget qpw3("xxx", "audio");
57 qpw3 = qpw2;
58 EXPECT_EQ("img", qpw3.id());
59 EXPECT_EQ("image", qpw3.widget_type());
60
61 qpw3 = qpw3;
62 EXPECT_EQ("img", qpw3.id());
63 EXPECT_EQ("image", qpw3.widget_type());
64
65 QPreviewWidget parent_widget("parent", "expandable");
66 parent_widget.add_widget(qpw);
67 widgets = parent_widget.widgets();
68 ASSERT_EQ(1, widgets.size());
69 EXPECT_EQ("img", widgets.at(0).id());
70
71 qpw.add_attribute_value("key", "value");
72 av = qpw.attribute_values();
73 ASSERT_EQ(1, av.size());
74 EXPECT_EQ("value", av.value("key"));
75
76 qpw.add_attribute_mapping("attr", "field");
77 am = qpw.attribute_mappings();
78 ASSERT_EQ(2, am.size());
79 EXPECT_EQ("field", am.value("attr"));
80 }
81
82 {
83 QString data = R"({"components":{"source":"screenshot-url"},"id":"img","key":"value","type":"image"})";
84 QPreviewWidget qpw(data);
85 EXPECT_EQ(data + "\n", qpw.data()); // Underlying scopes API appends a newline
86
87 auto vm = qpw.serialize();
88 ASSERT_EQ(4, vm.size());
89 EXPECT_EQ("img", vm.value("id"));
90 EXPECT_EQ("image", vm.value("type"));
91 auto attrs = vm.value("attributes").toMap();
92 ASSERT_EQ(1, attrs.size());
93 EXPECT_EQ("value", attrs.value("key").toString());
94 auto components = vm.value("components").toMap();
95 ASSERT_EQ(1, components.size());
96 EXPECT_EQ("screenshot-url", components.value("source").toString());
97 }
98
99 {
100 internal::QPreviewWidgetImpl i("id", "audio");
101 EXPECT_EQ("id", i.id());
102 EXPECT_EQ("audio", i.widget_type());
103
104 internal::QPreviewWidgetImpl i2(i);
105 EXPECT_EQ("id", i2.id());
106 EXPECT_EQ("audio", i2.widget_type());
107
108 internal::QPreviewWidgetImpl i3("xxx", "video");
109 i = i3;
110 EXPECT_EQ("xxx", i.id());
111 EXPECT_EQ("video", i.widget_type());
112
113 i = i;
114 EXPECT_EQ("xxx", i.id());
115 EXPECT_EQ("video", i.widget_type());
116 }
117}
0118
=== modified file 'test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp'
--- test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIImpl_test.cpp 2015-02-27 03:36:41 +0000
@@ -35,33 +35,33 @@
3535
36TEST(TestSetup, bindings)36TEST(TestSetup, bindings)
37{37{
38 QScopeMock scope;38 QScopeMock* scope = new QScopeMock;
3939
40 // construct the QSearchQueryBaseAPIMock40 // construct the QSearchQueryBaseAPIMock
41 QScopeBaseAPIMock api_scope(scope);41 QScopeBaseAPIMock api_scope([scope]{ return scope; });
4242
43 // verify that the event method is called for start event43 // verify that the event method is called for start event
44 EXPECT_CALL(scope, start(_)).Times(Exactly(1));44 EXPECT_CALL(*scope, start(_)).Times(Exactly(1));
45 api_scope.start("test_scope");45 api_scope.start("test_scope");
4646
47 QThread* qt_thread = api_scope.getQtAppThread();47 QThread* qt_thread = api_scope.get_qt_app_thread();
48 scope.setQtThread(qt_thread);48 scope->set_qt_thread(qt_thread);
4949
50 auto CheckThread = [qt_thread]() -> void50 auto check_thread = [qt_thread]() -> void
51 {51 {
52 EXPECT_EQ(qt_thread, QThread::currentThread());52 EXPECT_EQ(qt_thread, QThread::currentThread());
53 };53 };
5454
55 unity::scopes::internal::ResultImpl* resultImpl = new unity::scopes::internal::ResultImpl();55 unity::scopes::internal::ResultImpl resultImpl;
56 resultImpl->set_uri("test_uri");56 resultImpl.set_uri("test_uri");
5757
58 unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl->serialize());58 unity::scopes::Result result = unity::scopes::internal::ResultImpl::create_result(resultImpl.serialize());
5959
60 unity::scopes::CannedQuery query("scopeA", "query", "department");60 unity::scopes::CannedQuery query("scopeA", "query", "department");
61 unity::scopes::ActionMetadata action_metadata("en", "phone");61 unity::scopes::ActionMetadata action_metadata("en", "phone");
6262
63 // verify that the event method is called for stop event and63 // verify that the event method is called for stop event and
64 // that the thread is the Qt thread64 // that the thread is the Qt thread
65 EXPECT_CALL(scope, stop()).Times(Exactly(1)).WillOnce(Invoke(CheckThread));65 EXPECT_CALL(*scope, stop()).Times(Exactly(1)).WillOnce(Invoke(check_thread));
66 api_scope.stop();66 api_scope.stop();
67}67}
6868
=== modified file 'test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h'
--- test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/QScopeBaseAPIMock.h 2015-02-27 03:36:41 +0000
@@ -29,14 +29,14 @@
29class QScopeBaseAPIMock : public unity::scopes::qt::internal::QScopeBaseAPIImpl29class QScopeBaseAPIMock : public unity::scopes::qt::internal::QScopeBaseAPIImpl
30{30{
31public:31public:
32 QScopeBaseAPIMock(unity::scopes::qt::QScopeBase& qtscope, QObject* parent = 0)32 QScopeBaseAPIMock(QScopeBaseAPIImpl::FactoryFunc const& creator)
33 : unity::scopes::qt::internal::QScopeBaseAPIImpl(qtscope, parent)33 : unity::scopes::qt::internal::QScopeBaseAPIImpl(creator)
34 {34 {
35 }35 }
3636
37 virtual ~QScopeBaseAPIMock() = default;37 virtual ~QScopeBaseAPIMock() = default;
3838
39 QThread* getQtAppThread()39 QThread* get_qt_app_thread()
40 {40 {
41 return qtapp_->thread();41 return qtapp_->thread();
42 }42 }
4343
=== modified file 'test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp'
--- test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp 2015-02-27 03:36:41 +0000
+++ test/gtest/scopes/qt/qt-bindings/QScopeCreation_test.cpp 2015-02-27 03:36:41 +0000
@@ -43,8 +43,8 @@
43class QScopeBaseAPIImplTest : public QScopeBaseAPIImpl43class QScopeBaseAPIImplTest : public QScopeBaseAPIImpl
44{44{
45public:45public:
46 QScopeBaseAPIImplTest(FactoryFunc const& creator, QObject* parent = 0)46 QScopeBaseAPIImplTest(FactoryFunc const& creator)
47 : QScopeBaseAPIImpl(creator, parent)47 : QScopeBaseAPIImpl(creator)
48 {48 {
49 }49 }
5050
@@ -52,6 +52,11 @@
52 {52 {
53 return qtapp_->thread();53 return qtapp_->thread();
54 }54 }
55
56 bool qtapp_stopped()
57 {
58 return qtapp_stopped_;
59 }
55};60};
5661
57QScopeBase* create_my_scope()62QScopeBase* create_my_scope()
@@ -85,4 +90,9 @@
8590
86 // stop the Qt application91 // stop the Qt application
87 impl.stop();92 impl.stop();
93
94 while (!impl.qtapp_stopped())
95 {
96 std::this_thread::sleep_for(std::chrono::milliseconds(10));
97 }
88}98}
8999
=== modified file 'test/headers/CMakeLists.txt'
--- test/headers/CMakeLists.txt 2015-02-05 14:57:01 +0000
+++ test/headers/CMakeLists.txt 2015-02-27 03:36:41 +0000
@@ -5,7 +5,7 @@
5set(root_inc_dir ${CMAKE_SOURCE_DIR}/include)5set(root_inc_dir ${CMAKE_SOURCE_DIR}/include)
66
7set(subdirs7set(subdirs
8 unity/scopes/8 unity/scopes
9 unity/scopes/qt9 unity/scopes/qt
10 unity/scopes/testing10 unity/scopes/testing
11 unity/scopes/utility11 unity/scopes/utility
@@ -56,4 +56,4 @@
5656
57add_test(cleanincludes ${CMAKE_CURRENT_SOURCE_DIR}/includechecker.py ${CMAKE_SOURCE_DIR}/include)57add_test(cleanincludes ${CMAKE_CURRENT_SOURCE_DIR}/includechecker.py ${CMAKE_SOURCE_DIR}/include)
58add_test(noglobalincludes ${CMAKE_CURRENT_SOURCE_DIR}/check_global_usage.py58add_test(noglobalincludes ${CMAKE_CURRENT_SOURCE_DIR}/check_global_usage.py
59${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)59 ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)

Subscribers

People subscribed via source and target branches

to all changes: