Merge lp:~mikemc/unity-scope-click/add-cxx-scope into lp:unity-scope-click
- add-cxx-scope
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | dobey |
Approved revision: | 110 |
Merged at revision: | 105 |
Proposed branch: | lp:~mikemc/unity-scope-click/add-cxx-scope |
Merge into: | lp:unity-scope-click |
Diff against target: |
819 lines (+731/-1) 16 files modified
.bzrignore (+1/-1) CMakeLists.txt (+38/-0) data/CMakeLists.txt (+1/-0) data/clickscope.ini (+7/-0) scope/CMakeLists.txt (+19/-0) scope/clickquery.cpp (+67/-0) scope/clickquery.h (+46/-0) scope/clickscope.cpp (+48/-0) scope/clickscope.h (+47/-0) scope/download-manager.cpp (+107/-0) scope/download-manager.h (+79/-0) scope/tests/CMakeLists.txt (+42/-0) scope/tests/main.cpp (+36/-0) scope/tests/test_download_manager.cpp (+40/-0) scope/tests/test_download_manager.h (+55/-0) scope/tests/test_runner.h (+98/-0) |
To merge this branch: | bzr merge lp:~mikemc/unity-scope-click/add-cxx-scope |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
dobey (community) | Approve | ||
Review via email:
|
Commit message
- Add initial c++ scope code in scope/, using CMake
Description of the change
- Add initial c++ scope code in scope/, using CMake
because it's cmake, the existing autotools build structure is untouched and still works as before. tests pass as before.
NOTE: the new cmake does support out of tree builds. (as far as it gets)
mkdir build && cd build
cmake .. -DCMAKE_
make
-- that ought to get you to the point of linking the test binary, which currently fails.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) wrote : | # |
32 +add_custom_
33 + DEPENDS click-scope-tests
34 +)
35 +
271 +SET (TESTS_TARGET click-scope-tests)
281 +add_executable (${TESTS_TARGET}
This will only build the test program when 'make check' is run, but not run the resulting program. I'd suggest changing TESTS_TARGET to be 'test-click-scope' (it's generally good to start test command names with test-), and add a custom target for click-scope-tests that runs the resulting program without valgrind (see the tests in ubuntuone-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:106
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:108
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) wrote : | # |
24 +set(DATADIR share/unity/scopes) # FIXME, not correct.
This should be SCOPES_DATA_DIR or something. DATADIR is a generic name, and generic variables should get generic paths (DATADIR would just be "share" typically, and PKGDATADIR would be "share/
Also, several of the added source files are missing the copyright/license header. Please add them.
- 109. By Mike McCracken
-
rename DATADIR to be more specific
- 110. By Mike McCracken
-
Use GPL+SSL license for all new c++ files
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:110
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2013-12-10 22:20:49 +0000 | |||
3 | +++ .bzrignore 2014-01-13 22:01:11 +0000 | |||
4 | @@ -17,7 +17,7 @@ | |||
5 | 17 | ltmain.sh | 17 | ltmain.sh |
6 | 18 | missing | 18 | missing |
7 | 19 | stamp-* | 19 | stamp-* |
9 | 20 | *.[ch] | 20 | src/*.[ch] |
10 | 21 | *.desktop | 21 | *.desktop |
11 | 22 | *.gir | 22 | *.gir |
12 | 23 | *.gmo | 23 | *.gmo |
13 | 24 | 24 | ||
14 | === added file 'CMakeLists.txt' | |||
15 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
16 | +++ CMakeLists.txt 2014-01-13 22:01:11 +0000 | |||
17 | @@ -0,0 +1,38 @@ | |||
18 | 1 | project(clickscope CXX) | ||
19 | 2 | cmake_minimum_required(VERSION 2.8.10) | ||
20 | 3 | |||
21 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra") | ||
22 | 5 | |||
23 | 6 | include(GNUInstallDirs) | ||
24 | 7 | set(SCOPE_DATA_DIR share/unity/scopes) # FIXME, not correct. | ||
25 | 8 | |||
26 | 9 | include(FindPkgConfig) | ||
27 | 10 | pkg_check_modules(UNITY_SCOPES libunity-scopes REQUIRED) | ||
28 | 11 | |||
29 | 12 | pkg_check_modules(LIBSIGNON REQUIRED libsignon-qt5 accounts-qt5) | ||
30 | 13 | add_definitions(${LIBSIGNON_CFLAGS} ${LIBSIGNON_CFLAGS_OTHER}) | ||
31 | 14 | |||
32 | 15 | find_package (PkgConfig REQUIRED) | ||
33 | 16 | pkg_check_modules(UBUNTUONE REQUIRED ubuntuoneauth-2.0) | ||
34 | 17 | add_definitions(${UBUNTUONE_CFLAGS} ${UBUNTUONE_CFLAGS_OTHER}) | ||
35 | 18 | |||
36 | 19 | SET (SCOPE_LIB_VERSION 0.2.0) | ||
37 | 20 | SET (SCOPE_LIB_SOVERSION 0) | ||
38 | 21 | SET (SCOPE_LIB_API_VERSION 2.0) | ||
39 | 22 | SET (SCOPE_LIB_UNVERSIONED clickscope) | ||
40 | 23 | SET (SCOPE_LIB_NAME ${SCOPE_LIB_UNVERSIONED}-${SCOPE_LIB_API_VERSION}) | ||
41 | 24 | |||
42 | 25 | add_subdirectory(scope) | ||
43 | 26 | add_subdirectory(data) | ||
44 | 27 | |||
45 | 28 | add_custom_target(check | ||
46 | 29 | DEPENDS click-scope-tests | ||
47 | 30 | ) | ||
48 | 31 | |||
49 | 32 | add_custom_target(check-valgrind | ||
50 | 33 | DEPENDS click-scope-tests-valgrind | ||
51 | 34 | ) | ||
52 | 35 | |||
53 | 36 | add_custom_target(check-valgrind-leaks | ||
54 | 37 | DEPENDS click-scope-tests-valgrind-leaks | ||
55 | 38 | ) | ||
56 | 0 | 39 | ||
57 | === added file 'data/CMakeLists.txt' | |||
58 | --- data/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
59 | +++ data/CMakeLists.txt 2014-01-13 22:01:11 +0000 | |||
60 | @@ -0,0 +1,1 @@ | |||
61 | 1 | INSTALL(FILES clickscope.ini DESTINATION ${SCOPE_DATA_DIR}) | ||
62 | 0 | 2 | ||
63 | === added file 'data/clickscope.ini' | |||
64 | --- data/clickscope.ini 1970-01-01 00:00:00 +0000 | |||
65 | +++ data/clickscope.ini 2014-01-13 22:01:11 +0000 | |||
66 | @@ -0,0 +1,7 @@ | |||
67 | 1 | [ScopeConfig] | ||
68 | 2 | DisplayName = Click Applications Scope | ||
69 | 3 | Description = Scope for searching the click app store | ||
70 | 4 | Art = clickscope.Art | ||
71 | 5 | Icon = clickscope.Icon | ||
72 | 6 | SearchHint = clickscope.SearchHint | ||
73 | 7 | HotKey = clickscope.HotKey | ||
74 | 0 | 8 | ||
75 | === added directory 'scope' | |||
76 | === added file 'scope/CMakeLists.txt' | |||
77 | --- scope/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
78 | +++ scope/CMakeLists.txt 2014-01-13 22:01:11 +0000 | |||
79 | @@ -0,0 +1,19 @@ | |||
80 | 1 | SET (CMAKE_INCLUDE_CURRENT_DIR ON) | ||
81 | 2 | SET (CMAKE_AUTOMOC ON) | ||
82 | 3 | find_package (Qt5Core REQUIRED) | ||
83 | 4 | |||
84 | 5 | file (GLOB SCOPE_SOURCES *.cpp) | ||
85 | 6 | file (GLOB SCOPE_HEADERS *.h) | ||
86 | 7 | |||
87 | 8 | add_library (${SCOPE_LIB_NAME} SHARED ${SCOPE_SOURCES} ) | ||
88 | 9 | |||
89 | 10 | qt5_use_modules (${SCOPE_LIB_NAME} Network) | ||
90 | 11 | |||
91 | 12 | target_link_libraries (${SCOPE_LIB_NAME} | ||
92 | 13 | ${UNITY_SCOPES_LDFLAGS} | ||
93 | 14 | ${UBUNTUONE_LDFLAGS}) | ||
94 | 15 | |||
95 | 16 | set_property (TARGET ${SCOPE_LIB_NAME} PROPERTY COMPILE_FLAGS ${UNITY_SCOPES_CFLAGS}) | ||
96 | 17 | |||
97 | 18 | |||
98 | 19 | add_subdirectory (tests) | ||
99 | 0 | 20 | ||
100 | === added file 'scope/clickquery.cpp' | |||
101 | --- scope/clickquery.cpp 1970-01-01 00:00:00 +0000 | |||
102 | +++ scope/clickquery.cpp 2014-01-13 22:01:11 +0000 | |||
103 | @@ -0,0 +1,67 @@ | |||
104 | 1 | /* | ||
105 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
106 | 3 | * | ||
107 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
108 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
109 | 6 | * by the Free Software Foundation. | ||
110 | 7 | * | ||
111 | 8 | * This program is distributed in the hope that it will be useful, but | ||
112 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
113 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
114 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
115 | 12 | * | ||
116 | 13 | * You should have received a copy of the GNU General Public License along | ||
117 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
118 | 15 | * | ||
119 | 16 | * In addition, as a special exception, the copyright holders give | ||
120 | 17 | * permission to link the code of portions of this program with the | ||
121 | 18 | * OpenSSL library under certain conditions as described in each | ||
122 | 19 | * individual source file, and distribute linked combinations | ||
123 | 20 | * including the two. | ||
124 | 21 | * You must obey the GNU General Public License in all respects | ||
125 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
126 | 23 | * file(s) with this exception, you may extend this exception to your | ||
127 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
128 | 25 | * do not wish to do so, delete this exception statement from your | ||
129 | 26 | * version. If you delete this exception statement from all source | ||
130 | 27 | * files in the program, then also delete it here. | ||
131 | 28 | */ | ||
132 | 29 | |||
133 | 30 | #include "clickquery.h" | ||
134 | 31 | #include <scopes/Annotation.h> | ||
135 | 32 | #include <scopes/CategoryRenderer.h> | ||
136 | 33 | #include <scopes/CategorisedResult.h> | ||
137 | 34 | #include <scopes/Query.h> | ||
138 | 35 | #include <scopes/Reply.h> | ||
139 | 36 | |||
140 | 37 | |||
141 | 38 | ClickQuery::ClickQuery(string const& query) : | ||
142 | 39 | query_(query) | ||
143 | 40 | { | ||
144 | 41 | } | ||
145 | 42 | |||
146 | 43 | ClickQuery::~ClickQuery() | ||
147 | 44 | { | ||
148 | 45 | } | ||
149 | 46 | |||
150 | 47 | void ClickQuery::cancelled() | ||
151 | 48 | { | ||
152 | 49 | } | ||
153 | 50 | |||
154 | 51 | void ClickQuery::run(ReplyProxy const& reply) | ||
155 | 52 | { | ||
156 | 53 | CategoryRenderer rdr; | ||
157 | 54 | auto cat = reply->register_category("cat1", "Category 1", "", rdr); | ||
158 | 55 | CategorisedResult res(cat); | ||
159 | 56 | res.set_uri("uri"); | ||
160 | 57 | res.set_title("scope-A: result 1 for query \"" + query_ + "\""); | ||
161 | 58 | res.set_art("icon"); | ||
162 | 59 | res.set_dnd_uri("dnd_uri"); | ||
163 | 60 | reply->push(res); | ||
164 | 61 | |||
165 | 62 | Query q("scope-A", query_, ""); | ||
166 | 63 | Annotation annotation(Annotation::Type::Link); | ||
167 | 64 | annotation.add_link("More...", q); | ||
168 | 65 | reply->push(annotation); | ||
169 | 66 | |||
170 | 67 | } | ||
171 | 0 | 68 | ||
172 | === added file 'scope/clickquery.h' | |||
173 | --- scope/clickquery.h 1970-01-01 00:00:00 +0000 | |||
174 | +++ scope/clickquery.h 2014-01-13 22:01:11 +0000 | |||
175 | @@ -0,0 +1,46 @@ | |||
176 | 1 | /* | ||
177 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
178 | 3 | * | ||
179 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
180 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
181 | 6 | * by the Free Software Foundation. | ||
182 | 7 | * | ||
183 | 8 | * This program is distributed in the hope that it will be useful, but | ||
184 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
185 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
186 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
187 | 12 | * | ||
188 | 13 | * You should have received a copy of the GNU General Public License along | ||
189 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
190 | 15 | * | ||
191 | 16 | * In addition, as a special exception, the copyright holders give | ||
192 | 17 | * permission to link the code of portions of this program with the | ||
193 | 18 | * OpenSSL library under certain conditions as described in each | ||
194 | 19 | * individual source file, and distribute linked combinations | ||
195 | 20 | * including the two. | ||
196 | 21 | * You must obey the GNU General Public License in all respects | ||
197 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
198 | 23 | * file(s) with this exception, you may extend this exception to your | ||
199 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
200 | 25 | * do not wish to do so, delete this exception statement from your | ||
201 | 26 | * version. If you delete this exception statement from all source | ||
202 | 27 | * files in the program, then also delete it here. | ||
203 | 28 | */ | ||
204 | 29 | |||
205 | 30 | #include <scopes/QueryBase.h> | ||
206 | 31 | |||
207 | 32 | using namespace std; | ||
208 | 33 | using namespace unity::api::scopes; | ||
209 | 34 | |||
210 | 35 | class ClickQuery : public QueryBase | ||
211 | 36 | { | ||
212 | 37 | public: | ||
213 | 38 | ClickQuery(std::string const& query); | ||
214 | 39 | ~ClickQuery(); | ||
215 | 40 | virtual void cancelled() override; | ||
216 | 41 | |||
217 | 42 | virtual void run(ReplyProxy const& reply) override; | ||
218 | 43 | |||
219 | 44 | private: | ||
220 | 45 | std::string query_; | ||
221 | 46 | }; | ||
222 | 0 | 47 | ||
223 | === added file 'scope/clickscope.cpp' | |||
224 | --- scope/clickscope.cpp 1970-01-01 00:00:00 +0000 | |||
225 | +++ scope/clickscope.cpp 2014-01-13 22:01:11 +0000 | |||
226 | @@ -0,0 +1,48 @@ | |||
227 | 1 | /* | ||
228 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
229 | 3 | * | ||
230 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
231 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
232 | 6 | * by the Free Software Foundation. | ||
233 | 7 | * | ||
234 | 8 | * This program is distributed in the hope that it will be useful, but | ||
235 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
236 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
237 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
238 | 12 | * | ||
239 | 13 | * You should have received a copy of the GNU General Public License along | ||
240 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
241 | 15 | * | ||
242 | 16 | * In addition, as a special exception, the copyright holders give | ||
243 | 17 | * permission to link the code of portions of this program with the | ||
244 | 18 | * OpenSSL library under certain conditions as described in each | ||
245 | 19 | * individual source file, and distribute linked combinations | ||
246 | 20 | * including the two. | ||
247 | 21 | * You must obey the GNU General Public License in all respects | ||
248 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
249 | 23 | * file(s) with this exception, you may extend this exception to your | ||
250 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
251 | 25 | * do not wish to do so, delete this exception statement from your | ||
252 | 26 | * version. If you delete this exception statement from all source | ||
253 | 27 | * files in the program, then also delete it here. | ||
254 | 28 | */ | ||
255 | 29 | |||
256 | 30 | #include "clickscope.h" | ||
257 | 31 | #include "clickquery.h" | ||
258 | 32 | |||
259 | 33 | |||
260 | 34 | int ClickScope::start(std::string const&, unity::api::scopes::RegistryProxy const&) | ||
261 | 35 | { | ||
262 | 36 | return VERSION; | ||
263 | 37 | } | ||
264 | 38 | |||
265 | 39 | void ClickScope::stop() | ||
266 | 40 | { | ||
267 | 41 | } | ||
268 | 42 | |||
269 | 43 | unity::api::scopes::QueryBase::UPtr create_query(std::string const& q, | ||
270 | 44 | unity::api::scopes::VariantMap const&) | ||
271 | 45 | { | ||
272 | 46 | unity::api::scopes::QueryBase::UPtr query(new ClickQuery(q)); | ||
273 | 47 | return query; | ||
274 | 48 | } | ||
275 | 0 | 49 | ||
276 | === added file 'scope/clickscope.h' | |||
277 | --- scope/clickscope.h 1970-01-01 00:00:00 +0000 | |||
278 | +++ scope/clickscope.h 2014-01-13 22:01:11 +0000 | |||
279 | @@ -0,0 +1,47 @@ | |||
280 | 1 | /* | ||
281 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
282 | 3 | * | ||
283 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
284 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
285 | 6 | * by the Free Software Foundation. | ||
286 | 7 | * | ||
287 | 8 | * This program is distributed in the hope that it will be useful, but | ||
288 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
289 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
290 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
291 | 12 | * | ||
292 | 13 | * You should have received a copy of the GNU General Public License along | ||
293 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
294 | 15 | * | ||
295 | 16 | * In addition, as a special exception, the copyright holders give | ||
296 | 17 | * permission to link the code of portions of this program with the | ||
297 | 18 | * OpenSSL library under certain conditions as described in each | ||
298 | 19 | * individual source file, and distribute linked combinations | ||
299 | 20 | * including the two. | ||
300 | 21 | * You must obey the GNU General Public License in all respects | ||
301 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
302 | 23 | * file(s) with this exception, you may extend this exception to your | ||
303 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
304 | 25 | * do not wish to do so, delete this exception statement from your | ||
305 | 26 | * version. If you delete this exception statement from all source | ||
306 | 27 | * files in the program, then also delete it here. | ||
307 | 28 | */ | ||
308 | 29 | |||
309 | 30 | #ifndef CLICKSCOPE_H | ||
310 | 31 | #define CLICKSCOPE_H | ||
311 | 32 | |||
312 | 33 | #include <scopes/ScopeBase.h> | ||
313 | 34 | #include <scopes/QueryBase.h> | ||
314 | 35 | |||
315 | 36 | class ClickScope : public unity::api::scopes::ScopeBase | ||
316 | 37 | { | ||
317 | 38 | public: | ||
318 | 39 | virtual int start(std::string const&, unity::api::scopes::RegistryProxy const&) override; | ||
319 | 40 | |||
320 | 41 | virtual void stop() override; | ||
321 | 42 | |||
322 | 43 | virtual unity::api::scopes::QueryBase::UPtr create_query(std::string const& q, | ||
323 | 44 | unity::api::scopes::VariantMap const&) override; | ||
324 | 45 | }; | ||
325 | 46 | |||
326 | 47 | #endif | ||
327 | 0 | 48 | ||
328 | === added file 'scope/download-manager.cpp' | |||
329 | --- scope/download-manager.cpp 1970-01-01 00:00:00 +0000 | |||
330 | +++ scope/download-manager.cpp 2014-01-13 22:01:11 +0000 | |||
331 | @@ -0,0 +1,107 @@ | |||
332 | 1 | /* | ||
333 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
334 | 3 | * | ||
335 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
336 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
337 | 6 | * by the Free Software Foundation. | ||
338 | 7 | * | ||
339 | 8 | * This program is distributed in the hope that it will be useful, but | ||
340 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
341 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
342 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
343 | 12 | * | ||
344 | 13 | * You should have received a copy of the GNU General Public License along | ||
345 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
346 | 15 | * | ||
347 | 16 | * In addition, as a special exception, the copyright holders give | ||
348 | 17 | * permission to link the code of portions of this program with the | ||
349 | 18 | * OpenSSL library under certain conditions as described in each | ||
350 | 19 | * individual source file, and distribute linked combinations | ||
351 | 20 | * including the two. | ||
352 | 21 | * You must obey the GNU General Public License in all respects | ||
353 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
354 | 23 | * file(s) with this exception, you may extend this exception to your | ||
355 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
356 | 25 | * do not wish to do so, delete this exception statement from your | ||
357 | 26 | * version. If you delete this exception statement from all source | ||
358 | 27 | * files in the program, then also delete it here. | ||
359 | 28 | */ | ||
360 | 29 | |||
361 | 30 | #include <QDebug> | ||
362 | 31 | #include <QObject> | ||
363 | 32 | #include <QString> | ||
364 | 33 | #include <QTimer> | ||
365 | 34 | |||
366 | 35 | #include "ssoservice.h" | ||
367 | 36 | #include "token.h" | ||
368 | 37 | |||
369 | 38 | #include "download-manager.h" | ||
370 | 39 | |||
371 | 40 | namespace ClickScope { | ||
372 | 41 | |||
373 | 42 | |||
374 | 43 | DownloadManager::DownloadManager(QObject *parent) : | ||
375 | 44 | QObject(parent) | ||
376 | 45 | { | ||
377 | 46 | QObject::connect(&service, SIGNAL(credentialsFound(const Token&)), | ||
378 | 47 | this, SLOT(handleCredentialsFound(Token))); | ||
379 | 48 | QObject::connect(&service, SIGNAL(credentialsNotFound()), | ||
380 | 49 | this, SLOT(handleCredentialsNotFound())); | ||
381 | 50 | QObject::connect(&nam, SIGNAL(finished(QNetworkReply*)), | ||
382 | 51 | this, SLOT(handleNetworkFinished(QNetworkReply*))); | ||
383 | 52 | |||
384 | 53 | } | ||
385 | 54 | |||
386 | 55 | DownloadManager::~DownloadManager(){ | ||
387 | 56 | } | ||
388 | 57 | |||
389 | 58 | void DownloadManager::fetchClickToken(QString downloadUrl) | ||
390 | 59 | { | ||
391 | 60 | service.getCredentials(); | ||
392 | 61 | _downloadUrl = downloadUrl; | ||
393 | 62 | } | ||
394 | 63 | |||
395 | 64 | void DownloadManager::handleCredentialsFound(UbuntuOne::Token token) | ||
396 | 65 | { | ||
397 | 66 | qDebug() << "Credentials found, signing url " << _downloadUrl; | ||
398 | 67 | |||
399 | 68 | QString authHeader = token.signUrl(_downloadUrl, QStringLiteral("HEAD")); | ||
400 | 69 | |||
401 | 70 | qDebug() << "URL Signed, authHeader is:" << authHeader; // TODO: remove this log | ||
402 | 71 | |||
403 | 72 | QNetworkRequest req; | ||
404 | 73 | req.setRawHeader(QStringLiteral("Authorization").toUtf8(), | ||
405 | 74 | authHeader.toUtf8()); | ||
406 | 75 | req.setUrl(_downloadUrl); | ||
407 | 76 | nam.get(req); | ||
408 | 77 | } | ||
409 | 78 | |||
410 | 79 | void DownloadManager::handleCredentialsNotFound() | ||
411 | 80 | { | ||
412 | 81 | qDebug() << "No credentials were found."; | ||
413 | 82 | emit clickTokenFetchError(QString("No creds found")); | ||
414 | 83 | } | ||
415 | 84 | |||
416 | 85 | void DownloadManager::handleNetworkFinished(QNetworkReply *reply) | ||
417 | 86 | { | ||
418 | 87 | // TODO: actually get the header | ||
419 | 88 | QString clickTokenHeader; | ||
420 | 89 | QVariant statusAttr = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); | ||
421 | 90 | if(!statusAttr.isValid()) { | ||
422 | 91 | qDebug() << "Invalid HTTP response."; | ||
423 | 92 | return; | ||
424 | 93 | } | ||
425 | 94 | |||
426 | 95 | int status = statusAttr.toInt(); | ||
427 | 96 | qDebug() << "HTTP Status " << status; | ||
428 | 97 | |||
429 | 98 | if (status != 200){ | ||
430 | 99 | qDebug() << reply->rawHeaderPairs(); | ||
431 | 100 | } | ||
432 | 101 | |||
433 | 102 | qDebug() << reply->readAll(); | ||
434 | 103 | |||
435 | 104 | emit clickTokenFetched(clickTokenHeader); | ||
436 | 105 | } | ||
437 | 106 | |||
438 | 107 | } // namespace ClickScope | ||
439 | 0 | 108 | ||
440 | === added file 'scope/download-manager.h' | |||
441 | --- scope/download-manager.h 1970-01-01 00:00:00 +0000 | |||
442 | +++ scope/download-manager.h 2014-01-13 22:01:11 +0000 | |||
443 | @@ -0,0 +1,79 @@ | |||
444 | 1 | /* | ||
445 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
446 | 3 | * | ||
447 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
448 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
449 | 6 | * by the Free Software Foundation. | ||
450 | 7 | * | ||
451 | 8 | * This program is distributed in the hope that it will be useful, but | ||
452 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
453 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
454 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
455 | 12 | * | ||
456 | 13 | * You should have received a copy of the GNU General Public License along | ||
457 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
458 | 15 | * | ||
459 | 16 | * In addition, as a special exception, the copyright holders give | ||
460 | 17 | * permission to link the code of portions of this program with the | ||
461 | 18 | * OpenSSL library under certain conditions as described in each | ||
462 | 19 | * individual source file, and distribute linked combinations | ||
463 | 20 | * including the two. | ||
464 | 21 | * You must obey the GNU General Public License in all respects | ||
465 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
466 | 23 | * file(s) with this exception, you may extend this exception to your | ||
467 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
468 | 25 | * do not wish to do so, delete this exception statement from your | ||
469 | 26 | * version. If you delete this exception statement from all source | ||
470 | 27 | * files in the program, then also delete it here. | ||
471 | 28 | */ | ||
472 | 29 | |||
473 | 30 | #ifndef _DOWNLOAD_MANAGER_H_ | ||
474 | 31 | #define _DOWNLOAD_MANAGER_H_ | ||
475 | 32 | |||
476 | 33 | #include <QDebug> | ||
477 | 34 | #include <QNetworkReply> | ||
478 | 35 | #include <QObject> | ||
479 | 36 | #include <QString> | ||
480 | 37 | |||
481 | 38 | #include "ssoservice.h" | ||
482 | 39 | #include "token.h" | ||
483 | 40 | #include "requests.h" | ||
484 | 41 | #include "errormessages.h" | ||
485 | 42 | |||
486 | 43 | namespace ClickScope { | ||
487 | 44 | |||
488 | 45 | class DownloadManager : public QObject | ||
489 | 46 | { | ||
490 | 47 | Q_OBJECT | ||
491 | 48 | |||
492 | 49 | public: | ||
493 | 50 | |||
494 | 51 | explicit DownloadManager(QObject *parent = 0); | ||
495 | 52 | ~DownloadManager(); | ||
496 | 53 | |||
497 | 54 | public slots: | ||
498 | 55 | |||
499 | 56 | void fetchClickToken(QString downloadUrl); | ||
500 | 57 | |||
501 | 58 | signals: | ||
502 | 59 | |||
503 | 60 | void clickTokenFetched(QString clickToken); | ||
504 | 61 | void clickTokenFetchError(QString errorMessage); | ||
505 | 62 | |||
506 | 63 | private slots: | ||
507 | 64 | |||
508 | 65 | void handleCredentialsFound(UbuntuOne::Token token); | ||
509 | 66 | void handleCredentialsNotFound(); | ||
510 | 67 | void handleNetworkFinished(QNetworkReply *reply); | ||
511 | 68 | |||
512 | 69 | private: | ||
513 | 70 | |||
514 | 71 | UbuntuOne::SSOService service; | ||
515 | 72 | QNetworkAccessManager nam; | ||
516 | 73 | QString _downloadUrl; | ||
517 | 74 | |||
518 | 75 | }; | ||
519 | 76 | |||
520 | 77 | } // namespace ClickScope | ||
521 | 78 | |||
522 | 79 | #endif /* _DOWNLOAD_MANAGER_H_ */ | ||
523 | 0 | 80 | ||
524 | === added directory 'scope/tests' | |||
525 | === added file 'scope/tests/CMakeLists.txt' | |||
526 | --- scope/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
527 | +++ scope/tests/CMakeLists.txt 2014-01-13 22:01:11 +0000 | |||
528 | @@ -0,0 +1,42 @@ | |||
529 | 1 | SET (TESTS_TARGET test-click-scope) | ||
530 | 2 | |||
531 | 3 | # Qt5 bits | ||
532 | 4 | SET (CMAKE_INCLUDE_CURRENT_DIR ON) | ||
533 | 5 | SET (CMAKE_AUTOMOC ON) | ||
534 | 6 | find_package(Qt5Core REQUIRED) | ||
535 | 7 | |||
536 | 8 | FILE (GLOB TEST_SOURCES *.cpp) | ||
537 | 9 | FILE (GLOB TEST_HEADERS *.h) | ||
538 | 10 | |||
539 | 11 | add_executable (${TESTS_TARGET} | ||
540 | 12 | ${TEST_SOURCES} | ||
541 | 13 | ${TEST_HEADERS} | ||
542 | 14 | ) | ||
543 | 15 | |||
544 | 16 | qt5_use_modules (${TESTS_TARGET} Core DBus Network Test) | ||
545 | 17 | |||
546 | 18 | target_include_directories ( ${TESTS_TARGET} PUBLIC ${CMAKE_SOURCE_DIR}/scope ) | ||
547 | 19 | target_link_libraries ( ${TESTS_TARGET} | ||
548 | 20 | ${UNITY_SCOPES_LDFLAGS} | ||
549 | 21 | ${UBUNTUONE_LDFLAGS} | ||
550 | 22 | ) | ||
551 | 23 | target_link_libraries ( ${TESTS_TARGET} | ||
552 | 24 | -Wl,-rpath,${CMAKE_BINARY_DIR}/src | ||
553 | 25 | -L${CMAKE_BINARY_DIR}/src | ||
554 | 26 | ${SCOPE_LIB_NAME} | ||
555 | 27 | ) | ||
556 | 28 | |||
557 | 29 | add_custom_target(click-scope-tests | ||
558 | 30 | COMMAND ${TESTS_TARGET} | ||
559 | 31 | DEPENDS ${TESTS_TARGET} | ||
560 | 32 | ) | ||
561 | 33 | |||
562 | 34 | add_custom_target(click-scope-tests-valgrind | ||
563 | 35 | COMMAND "valgrind --tool=memcheck ${CMAKE_CURRENT_BINARY_DIR}/${TESTS_TARGET}" | ||
564 | 36 | DEPENDS ${TESTS_TARGET} | ||
565 | 37 | ) | ||
566 | 38 | |||
567 | 39 | add_custom_target(click-scope-tests-valgrind-leaks | ||
568 | 40 | COMMAND "valgrind --tool=memcheck --track-origins=yes --num-callers=40 --leak-resolution=high --leak-check=full ${CMAKE_CURRENT_BINARY_DIR}/${TESTS_TARGET}" | ||
569 | 41 | DEPENDS ${TESTS_TARGET} | ||
570 | 42 | ) | ||
571 | 0 | 43 | ||
572 | === added file 'scope/tests/main.cpp' | |||
573 | --- scope/tests/main.cpp 1970-01-01 00:00:00 +0000 | |||
574 | +++ scope/tests/main.cpp 2014-01-13 22:01:11 +0000 | |||
575 | @@ -0,0 +1,36 @@ | |||
576 | 1 | /* | ||
577 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
578 | 3 | * | ||
579 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
580 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
581 | 6 | * by the Free Software Foundation. | ||
582 | 7 | * | ||
583 | 8 | * This program is distributed in the hope that it will be useful, but | ||
584 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
585 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
586 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
587 | 12 | * | ||
588 | 13 | * You should have received a copy of the GNU General Public License along | ||
589 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
590 | 15 | * | ||
591 | 16 | * In addition, as a special exception, the copyright holders give | ||
592 | 17 | * permission to link the code of portions of this program with the | ||
593 | 18 | * OpenSSL library under certain conditions as described in each | ||
594 | 19 | * individual source file, and distribute linked combinations | ||
595 | 20 | * including the two. | ||
596 | 21 | * You must obey the GNU General Public License in all respects | ||
597 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
598 | 23 | * file(s) with this exception, you may extend this exception to your | ||
599 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
600 | 25 | * do not wish to do so, delete this exception statement from your | ||
601 | 26 | * version. If you delete this exception statement from all source | ||
602 | 27 | * files in the program, then also delete it here. | ||
603 | 28 | */ | ||
604 | 29 | |||
605 | 30 | #include <QCoreApplication> | ||
606 | 31 | #include "./test_runner.h" | ||
607 | 32 | |||
608 | 33 | int main(int argc, char *argv[]) { | ||
609 | 34 | QCoreApplication a(argc, argv); | ||
610 | 35 | return RUN_ALL_QTESTS(argc, argv); | ||
611 | 36 | } | ||
612 | 0 | 37 | ||
613 | === added file 'scope/tests/test_download_manager.cpp' | |||
614 | --- scope/tests/test_download_manager.cpp 1970-01-01 00:00:00 +0000 | |||
615 | +++ scope/tests/test_download_manager.cpp 2014-01-13 22:01:11 +0000 | |||
616 | @@ -0,0 +1,40 @@ | |||
617 | 1 | /* | ||
618 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
619 | 3 | * | ||
620 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
621 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
622 | 6 | * by the Free Software Foundation. | ||
623 | 7 | * | ||
624 | 8 | * This program is distributed in the hope that it will be useful, but | ||
625 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
626 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
627 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
628 | 12 | * | ||
629 | 13 | * You should have received a copy of the GNU General Public License along | ||
630 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
631 | 15 | * | ||
632 | 16 | * In addition, as a special exception, the copyright holders give | ||
633 | 17 | * permission to link the code of portions of this program with the | ||
634 | 18 | * OpenSSL library under certain conditions as described in each | ||
635 | 19 | * individual source file, and distribute linked combinations | ||
636 | 20 | * including the two. | ||
637 | 21 | * You must obey the GNU General Public License in all respects | ||
638 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
639 | 23 | * file(s) with this exception, you may extend this exception to your | ||
640 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
641 | 25 | * do not wish to do so, delete this exception statement from your | ||
642 | 26 | * version. If you delete this exception statement from all source | ||
643 | 27 | * files in the program, then also delete it here. | ||
644 | 28 | */ | ||
645 | 29 | |||
646 | 30 | #include "test_download_manager.h" | ||
647 | 31 | |||
648 | 32 | using namespace ClickScope; | ||
649 | 33 | |||
650 | 34 | void TestDownloadManager::testFetchClickTokenCredentialsFound() | ||
651 | 35 | { | ||
652 | 36 | DownloadManager dm; | ||
653 | 37 | QSignalSpy spy(&dm, SIGNAL(clickTokenFetchError())); | ||
654 | 38 | dm.fetchClickToken(QString("")); | ||
655 | 39 | QTRY_COMPARE(spy.count(), 1); | ||
656 | 40 | } | ||
657 | 0 | 41 | ||
658 | === added file 'scope/tests/test_download_manager.h' | |||
659 | --- scope/tests/test_download_manager.h 1970-01-01 00:00:00 +0000 | |||
660 | +++ scope/tests/test_download_manager.h 2014-01-13 22:01:11 +0000 | |||
661 | @@ -0,0 +1,55 @@ | |||
662 | 1 | /* | ||
663 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
664 | 3 | * | ||
665 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
666 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
667 | 6 | * by the Free Software Foundation. | ||
668 | 7 | * | ||
669 | 8 | * This program is distributed in the hope that it will be useful, but | ||
670 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
671 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
672 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
673 | 12 | * | ||
674 | 13 | * You should have received a copy of the GNU General Public License along | ||
675 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
676 | 15 | * | ||
677 | 16 | * In addition, as a special exception, the copyright holders give | ||
678 | 17 | * permission to link the code of portions of this program with the | ||
679 | 18 | * OpenSSL library under certain conditions as described in each | ||
680 | 19 | * individual source file, and distribute linked combinations | ||
681 | 20 | * including the two. | ||
682 | 21 | * You must obey the GNU General Public License in all respects | ||
683 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
684 | 23 | * file(s) with this exception, you may extend this exception to your | ||
685 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
686 | 25 | * do not wish to do so, delete this exception statement from your | ||
687 | 26 | * version. If you delete this exception statement from all source | ||
688 | 27 | * files in the program, then also delete it here. | ||
689 | 28 | */ | ||
690 | 29 | |||
691 | 30 | #ifndef _TEST_DOWNLOAD_MANAGER_H_ | ||
692 | 31 | #define _TEST_DOWNLOAD_MANAGER_H_ | ||
693 | 32 | |||
694 | 33 | #include <QObject> | ||
695 | 34 | #include <QDebug> | ||
696 | 35 | #include <QString> | ||
697 | 36 | #include <QTest> | ||
698 | 37 | #include <QSignalSpy> | ||
699 | 38 | |||
700 | 39 | #include "test_runner.h" | ||
701 | 40 | #include "download-manager.h" | ||
702 | 41 | |||
703 | 42 | using namespace ClickScope; | ||
704 | 43 | |||
705 | 44 | class TestDownloadManager : public QObject | ||
706 | 45 | { | ||
707 | 46 | Q_OBJECT | ||
708 | 47 | |||
709 | 48 | private slots: | ||
710 | 49 | void testFetchClickTokenCredentialsFound(); | ||
711 | 50 | // void testFetchClickTokenCredentialsNotFound(); | ||
712 | 51 | }; | ||
713 | 52 | |||
714 | 53 | DECLARE_TEST(TestDownloadManager) | ||
715 | 54 | |||
716 | 55 | #endif /* _TEST_DOWNLOAD_MANAGER_H_ */ | ||
717 | 0 | 56 | ||
718 | === added file 'scope/tests/test_runner.h' | |||
719 | --- scope/tests/test_runner.h 1970-01-01 00:00:00 +0000 | |||
720 | +++ scope/tests/test_runner.h 2014-01-13 22:01:11 +0000 | |||
721 | @@ -0,0 +1,98 @@ | |||
722 | 1 | /* | ||
723 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
724 | 3 | * | ||
725 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
726 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
727 | 6 | * by the Free Software Foundation. | ||
728 | 7 | * | ||
729 | 8 | * This program is distributed in the hope that it will be useful, but | ||
730 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
731 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
732 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
733 | 12 | * | ||
734 | 13 | * You should have received a copy of the GNU General Public License along | ||
735 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
736 | 15 | * | ||
737 | 16 | * In addition, as a special exception, the copyright holders give | ||
738 | 17 | * permission to link the code of portions of this program with the | ||
739 | 18 | * OpenSSL library under certain conditions as described in each | ||
740 | 19 | * individual source file, and distribute linked combinations | ||
741 | 20 | * including the two. | ||
742 | 21 | * You must obey the GNU General Public License in all respects | ||
743 | 22 | * for all of the code used other than OpenSSL. If you modify | ||
744 | 23 | * file(s) with this exception, you may extend this exception to your | ||
745 | 24 | * version of the file(s), but you are not obligated to do so. If you | ||
746 | 25 | * do not wish to do so, delete this exception statement from your | ||
747 | 26 | * version. If you delete this exception statement from all source | ||
748 | 27 | * files in the program, then also delete it here. | ||
749 | 28 | */ | ||
750 | 29 | |||
751 | 30 | #ifndef TEST_RUNNER_H | ||
752 | 31 | #define TEST_RUNNER_H | ||
753 | 32 | |||
754 | 33 | #include <QDir> | ||
755 | 34 | #include <QList> | ||
756 | 35 | #include <QTest> | ||
757 | 36 | #include <QSharedPointer> | ||
758 | 37 | #include <iostream> | ||
759 | 38 | |||
760 | 39 | class TestRunner { | ||
761 | 40 | public: | ||
762 | 41 | |||
763 | 42 | static TestRunner& Instance() { | ||
764 | 43 | static TestRunner instance; | ||
765 | 44 | return instance; | ||
766 | 45 | } | ||
767 | 46 | |||
768 | 47 | template <typename T> | ||
769 | 48 | char RegisterTest(char* name) { | ||
770 | 49 | if(!_tests.contains(name)) { | ||
771 | 50 | QSharedPointer<QObject> test(new T()); | ||
772 | 51 | _tests.insert(name, QSharedPointer<QObject>(test)); | ||
773 | 52 | } | ||
774 | 53 | return char(1); | ||
775 | 54 | } | ||
776 | 55 | |||
777 | 56 | int RunAll(int argc, char *argv[]) { | ||
778 | 57 | // provide command line to run a single test case | ||
779 | 58 | QCoreApplication* app = QCoreApplication::instance(); | ||
780 | 59 | QStringList args = app->arguments(); | ||
781 | 60 | |||
782 | 61 | if (args.contains("-testcase")) { | ||
783 | 62 | int index = args.indexOf("-testcase"); | ||
784 | 63 | if (args.count() > index + 1) { | ||
785 | 64 | QString testcase = args[index + 1]; | ||
786 | 65 | if (_tests.contains(testcase)) { | ||
787 | 66 | args.removeAt(index + 1); | ||
788 | 67 | args.removeAt(index); | ||
789 | 68 | return QTest::qExec(_tests[testcase].data(), args); | ||
790 | 69 | } else { | ||
791 | 70 | return -1; | ||
792 | 71 | } | ||
793 | 72 | } else { | ||
794 | 73 | return -1; | ||
795 | 74 | } | ||
796 | 75 | } else { | ||
797 | 76 | int errorCode = 0; | ||
798 | 77 | foreach (QString const &testName, _tests.keys()) { | ||
799 | 78 | errorCode |= QTest::qExec(_tests[testName].data(), argc, argv); | ||
800 | 79 | std::cout << std::endl; | ||
801 | 80 | } | ||
802 | 81 | return errorCode; | ||
803 | 82 | } | ||
804 | 83 | } | ||
805 | 84 | |||
806 | 85 | private: | ||
807 | 86 | QMap<QString, QSharedPointer<QObject> > _tests; | ||
808 | 87 | }; | ||
809 | 88 | |||
810 | 89 | |||
811 | 90 | // Use this macro after your test declaration | ||
812 | 91 | #define DECLARE_TEST(className)\ | ||
813 | 92 | static char test_##className = TestRunner::Instance().RegisterTest<className>(const_cast<char *>(#className)); | ||
814 | 93 | |||
815 | 94 | // Use this macro to execute all tests | ||
816 | 95 | #define RUN_ALL_QTESTS(argc, argv)\ | ||
817 | 96 | TestRunner::Instance().RunAll(argc, argv); | ||
818 | 97 | |||
819 | 98 | #endif // TEST_RUNNER_H |
PASSED: Continuous integration, rev:105 jenkins. qa.ubuntu. com/job/ unity-scope- click-ci/ 157/ jenkins. qa.ubuntu. com/job/ unity-scope- click-trusty- amd64-ci/ 55 jenkins. qa.ubuntu. com/job/ unity-scope- click-trusty- armhf-ci/ 55
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- scope-click- ci/157/ rebuild
http://