Merge lp:~marcustomlinson/qtcreator-plugin-ubuntu/refactor-scope-template into lp:qtcreator-plugin-ubuntu

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 433
Merged at revision: 393
Proposed branch: lp:~marcustomlinson/qtcreator-plugin-ubuntu/refactor-scope-template
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 1816 lines (+518/-788)
24 files modified
share/qtcreator/templates/wizards/ubuntu/scope/CMakeLists.txt (+20/-29)
share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindGMock.cmake (+0/-12)
share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindIntltool.cmake (+0/-265)
share/qtcreator/templates/wizards/ubuntu/scope/data/CMakeLists.txt (+0/-10)
share/qtcreator/templates/wizards/ubuntu/scope/include/api/config.h (+0/-27)
share/qtcreator/templates/wizards/ubuntu/scope/po/POTFILES.in (+11/-11)
share/qtcreator/templates/wizards/ubuntu/scope/src/CMakeLists.txt (+31/-33)
share/qtcreator/templates/wizards/ubuntu/scope/src/client.cpp (+2/-3)
share/qtcreator/templates/wizards/ubuntu/scope/src/client.h (+17/-9)
share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName-settings.ini.in (+21/-0)
share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName.ini.in (+1/-0)
share/qtcreator/templates/wizards/ubuntu/scope/src/localization.h (+3/-3)
share/qtcreator/templates/wizards/ubuntu/scope/src/preview.cpp (+20/-21)
share/qtcreator/templates/wizards/ubuntu/scope/src/preview.h (+3/-7)
share/qtcreator/templates/wizards/ubuntu/scope/src/query.cpp (+41/-41)
share/qtcreator/templates/wizards/ubuntu/scope/src/query.h (+6/-10)
share/qtcreator/templates/wizards/ubuntu/scope/src/scope.cpp (+5/-7)
share/qtcreator/templates/wizards/ubuntu/scope/src/scope.h (+5/-9)
share/qtcreator/templates/wizards/ubuntu/scope/tests/CMakeLists.txt (+15/-8)
share/qtcreator/templates/wizards/ubuntu/scope/tests/server/server.py (+1/-1)
share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/CMakeLists.txt (+7/-25)
share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/scope/test-scope.cpp (+0/-232)
share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/test-scope.py (+290/-0)
share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml (+19/-25)
To merge this branch: bzr merge lp:~marcustomlinson/qtcreator-plugin-ubuntu/refactor-scope-template
Reviewer Review Type Date Requested Status
Benjamin Zeller Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+259083@code.launchpad.net

Commit message

Refactored the scope templates to be more simplistic and comprehensible:
* Reduced directory structure to as few folders as possible
* Renamed scope ini file to <scope-name>.ini
* Added a <scope-name>-settings.ini
* Cleaned out unnecessary complexities from source and CMake files
* More descriptive comments and variable names
* Updated tests to use python3-scope-harness
* Removed cmake/ modules folder (SDK now includes cmake-extras)
* Allow scope template to build with gcc > 4.9
* Added "Keywords" key to scope ini

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:432
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~marcustomlinson/qtcreator-plugin-ubuntu/refactor-scope-template/+merge/259083/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/qtcreator-plugin-ubuntu-ci/542/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/qtcreator-plugin-ubuntu-wily-amd64-ci/3
    SUCCESS: http://jenkins.qa.ubuntu.com/job/qtcreator-plugin-ubuntu-wily-armhf-ci/3

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/qtcreator-plugin-ubuntu-ci/542/rebuild

review: Needs Fixing (continuous-integration)
433. By Marcus Tomlinson

Fixed comment

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

ok

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/CMakeLists.txt'
--- share/qtcreator/templates/wizards/ubuntu/scope/CMakeLists.txt 2015-01-07 10:50:28 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/CMakeLists.txt 2015-05-19 10:38:08 +0000
@@ -1,12 +1,11 @@
1project(%ProjectName:l% CXX)1project(%ProjectName:l% CXX)
2cmake_minimum_required(VERSION 2.8.10)2cmake_minimum_required(VERSION 2.8.10)
3set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
43
5# We require g++ 4.9, to avoid ABI breakage with earlier version.4# We require at least g++ 4.9, to avoid ABI breakage with earlier versions.
6set(cxx_version_required 4.9)5set(cxx_version_required 4.9)
7if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")6if (CMAKE_COMPILER_IS_GNUCXX)
8 if (NOT CMAKE_CXX_COMPILER_VERSION MATCHES "^${cxx_version_required}")7 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx_version_required})
9 message(FATAL_ERROR "g++ version must be ${cxx_version_required}!")8 message(FATAL_ERROR "g++ version must be at least ${cxx_version_required}!")
10 endif()9 endif()
11endif()10endif()
1211
@@ -21,17 +20,14 @@
21 -DQT_NO_KEYWORDS20 -DQT_NO_KEYWORDS
22)21)
2322
23# Search for our dependencies
24include(GNUInstallDirs)24include(GNUInstallDirs)
25find_package(PkgConfig)25find_package(PkgConfig)
26find_package(Intltool)26find_package(Intltool)
2727@if "%ContentType%".substring(0, "network-netcpp-q".length) === "network-netcpp-q"
28# We depend on Boost for string trimming28find_package(Qt5Core REQUIRED)
29find_package(29@endif
30 Boost30
31 REQUIRED
32)
33
34# Search for our dependencies
35pkg_check_modules(31pkg_check_modules(
36 SCOPE32 SCOPE
37 libunity-scopes>=0.6.033 libunity-scopes>=0.6.0
@@ -44,19 +40,16 @@
44 REQUIRED40 REQUIRED
45)41)
4642
47@if "%ContentType%".substring(0, "network-netcpp-q".length) === "network-netcpp-q"
48find_package(Qt5Core REQUIRED)
49include_directories(${Qt5Core_INCLUDE_DIRS})
50@endif
51
52# Add our dependencies to the include paths43# Add our dependencies to the include paths
53include_directories(44include_directories(
54 "${CMAKE_SOURCE_DIR}/include"45 "${CMAKE_SOURCE_DIR}/src"
55 ${Boost_INCLUDE_DIRS}
56 ${SCOPE_INCLUDE_DIRS}46 ${SCOPE_INCLUDE_DIRS}
47@if "%ContentType%".substring(0, "network-netcpp-q".length) === "network-netcpp-q"
48 ${Qt5Core_INCLUDE_DIRS}
49@endif
57)50)
5851
59# Do not remove this line, its required for the correct functionality of the Ubuntu-SDK52# Do not remove these 2 lines, they are required for the correct functionality of the Ubuntu-SDK
60set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")53set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")
61set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project")54set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project")
6255
@@ -68,44 +61,42 @@
68set(SCOPE_NAME "${PACKAGE_NAME}_%ClickHookName:l%")61set(SCOPE_NAME "${PACKAGE_NAME}_%ClickHookName:l%")
6962
70# If we need to refer to the scope's name or package in code, these definitions will help63# If we need to refer to the scope's name or package in code, these definitions will help
71
72add_definitions(-DPACKAGE_NAME="${PACKAGE_NAME}")64add_definitions(-DPACKAGE_NAME="${PACKAGE_NAME}")
73add_definitions(-DSCOPE_NAME="${SCOPE_NAME}")65add_definitions(-DSCOPE_NAME="${SCOPE_NAME}")
74add_definitions(-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}")66add_definitions(-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}")
7567
76#This command figures out the target architecture and puts it into the manifest file68# This command figures out the target architecture and puts it into the manifest file
77execute_process(69execute_process(
78 COMMAND dpkg-architecture -qDEB_HOST_ARCH70 COMMAND dpkg-architecture -qDEB_HOST_ARCH
79 OUTPUT_VARIABLE CLICK_ARCH71 OUTPUT_VARIABLE CLICK_ARCH
80 OUTPUT_STRIP_TRAILING_WHITESPACE72 OUTPUT_STRIP_TRAILING_WHITESPACE
81)73)
8274
75# Configure and install the click manifest and apparmor files
83configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)76configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
84
85# Install the click manifest
86install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION "/")77install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION "/")
87install(FILES "%ClickHookName:l%.apparmor" DESTINATION "/")78install(FILES "%ClickHookName:l%.apparmor" DESTINATION "/")
8879
89# Make these files show up in QtCreator80# Make these files show up in QtCreator
90file(GLOB_RECURSE81file(GLOB_RECURSE
91 _PO_FILES82 _PO_FILES
92 "po/*.po" 83 "po/*.po"
93)84)
94add_custom_target(hidden_files85add_custom_target(hidden_files
95 ALL86 ALL
96 SOURCES87 SOURCES
97 manifest.json.in88 manifest.json.in
98 %ClickHookName:l%.apparmor89 %ClickHookName:l%.apparmor
99 data/${SCOPE_NAME}.ini.in90 src/data/%ClickHookName:l%.ini.in
91 src/data/%ClickHookName:l%-settings.ini.in
100 po/POTFILES.in92 po/POTFILES.in
101 po/${GETTEXT_PACKAGE}.pot93 po/${GETTEXT_PACKAGE}.pot
102 ${_PO_FILES}94 ${_PO_FILES}
103)95)
10496
105# Add our main directories97# Add our main directories
98add_subdirectory(po)
106add_subdirectory(src)99add_subdirectory(src)
107add_subdirectory(data)
108add_subdirectory(po)
109100
110# Set up the tests101# Set up the tests
111enable_testing()102enable_testing()
112103
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/cmake'
=== removed file 'share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindGMock.cmake'
--- share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindGMock.cmake 2014-09-03 12:55:33 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindGMock.cmake 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1# Build with system gmock and embedded gtest
2set (GMOCK_INCLUDE_DIRS "/usr/include/gmock/include" CACHE PATH "gmock source include directory")
3set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
4set (GTEST_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
5
6add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
7
8set(GTEST_LIBRARIES gtest)
9set(GTEST_MAIN_LIBRARIES gtest_main)
10set(GMOCK_LIBRARIES gmock gmock_main)
11
12set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
130
=== removed file 'share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindIntltool.cmake'
--- share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindIntltool.cmake 2015-04-13 09:11:18 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/cmake/FindIntltool.cmake 1970-01-01 00:00:00 +0000
@@ -1,265 +0,0 @@
1# Copyright (C) 2014 Canonical Ltd
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License version 3 as
5# published by the Free Software Foundation.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Lesser General Public License for more details.
11#
12# You should have received a copy of the GNU Lesser General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15# This package provides macros that wrap the intltool programs.
16#
17# An example of common usage is:
18#
19# For an ini file:
20#
21# intltool_merge_translations(
22# "foo.ini.in"
23# "${CMAKE_CURRENT_BINARY_DIR}/foo.ini"
24# ALL
25# UTF8
26# )
27#
28# Inside po/CMakeLists.txt:
29#
30# intltool_update_potfile(
31# ALL
32# GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
33# )
34#
35# intltool_install_translations(
36# ALL
37# GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
38# )
39
40find_package(Gettext REQUIRED)
41
42find_program(INTLTOOL_UPDATE_EXECUTABLE intltool-update)
43
44if(INTLTOOL_UPDATE_EXECUTABLE)
45 execute_process(
46 COMMAND ${INTLTOOL_UPDATE_EXECUTABLE} --version
47 OUTPUT_VARIABLE intltool_update_version
48 ERROR_QUIET
49 OUTPUT_STRIP_TRAILING_WHITESPACE)
50 if (intltool_update_version MATCHES "^intltool-update \\(.*\\) [0-9]")
51 string(
52 REGEX REPLACE "^intltool-update \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1"
53 INTLTOOL_UPDATE_VERSION_STRING "${intltool_update_version}"
54 )
55 endif()
56 unset(intltool_update_version)
57endif()
58
59find_program(INTLTOOL_MERGE_EXECUTABLE intltool-merge)
60
61if(INTLTOOL_MERGE_EXECUTABLE)
62 execute_process(
63 COMMAND ${INTLTOOL_MERGE_EXECUTABLE} --version
64 OUTPUT_VARIABLE intltool_merge_version
65 ERROR_QUIET
66 OUTPUT_STRIP_TRAILING_WHITESPACE)
67 if (intltool_update_version MATCHES "^intltool-merge \\(.*\\) [0-9]")
68 string(
69 REGEX REPLACE "^intltool-merge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1"
70 INTLTOOL_MERGE_VERSION_STRING "${intltool_merge_version}"
71 )
72 endif()
73 unset(intltool_merge_version)
74endif()
75
76include(FindPackageHandleStandardArgs)
77
78find_package_handle_standard_args(
79 Intltool
80 REQUIRED_VARS
81 INTLTOOL_UPDATE_EXECUTABLE
82 INTLTOOL_MERGE_EXECUTABLE
83 VERSION_VAR
84 INTLTOOL_UPDATE_VERSION_STRING
85 HANDLE_COMPONENTS
86)
87
88function(APPEND_EACH LISTNAME GLUE OUTPUT)
89 set(_tmp_list "")
90 foreach(VAL ${${LISTNAME}})
91 list(APPEND _tmp_list "${GLUE}${VAL}")
92 endforeach(VAL ${${LISTNAME}})
93 set(${OUTPUT} "${_tmp_list}" PARENT_SCOPE)
94endfunction()
95
96function(INTLTOOL_UPDATE_POTFILE)
97 set(_options ALL)
98 set(_oneValueArgs GETTEXT_PACKAGE OUTPUT_FILE PO_DIRECTORY)
99
100 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "" ${ARGN})
101
102 set(_POT_FILE "${PROJECT}.pot")
103
104 set(_GETTEXT_PACKAGE "")
105 if(_ARG_GETTEXT_PACKAGE)
106 set(_POT_FILE "${_ARG_GETTEXT_PACKAGE}.pot")
107 set(_GETTEXT_PACKAGE --gettext-package="${_ARG_GETTEXT_PACKAGE}")
108 endif()
109
110 set(_OUTPUT_FILE "")
111 if(_ARG_OUTPUT_FILE)
112 set(_POT_FILE "${_ARG_OUTPUT_FILE}")
113 set(_OUTPUT_FILE --output-file="${_ARG_OUTPUT_FILE}")
114 endif()
115
116 set(_PO_DIRECTORY "${CMAKE_SOURCE_DIR}/po")
117 if(_ARG_PO_DIRECTORY)
118 set(_PO_DIRECTORY "${_ARG_PO_DIRECTORY}")
119 endif()
120
121 file(
122 GLOB_RECURSE _CODE_SOURCES
123 ${CMAKE_SOURCE_DIR}/*.cpp
124 ${CMAKE_SOURCE_DIR}/*.cc
125 ${CMAKE_SOURCE_DIR}/*.cxx
126 ${CMAKE_SOURCE_DIR}/*.vala
127 ${CMAKE_SOURCE_DIR}/*.c
128 ${CMAKE_SOURCE_DIR}/*.h
129 ${CMAKE_SOURCE_DIR}/*.ini.in
130 )
131
132 add_custom_command(
133 OUTPUT
134 "${_PO_DIRECTORY}/${_POT_FILE}"
135 COMMAND ${INTLTOOL_UPDATE_EXECUTABLE} --pot ${_OUTPUT_FILE} ${_GETTEXT_PACKAGE}
136 DEPENDS
137 "${_PO_DIRECTORY}/POTFILES.in"
138 ${_CODE_SOURCES}
139 WORKING_DIRECTORY ${_PO_DIRECTORY}
140 )
141
142 _GETTEXT_GET_UNIQUE_TARGET_NAME(${_POT_FILE} _UNIQUE_TARGET_NAME)
143
144 if(_ARG_ALL)
145 add_custom_target(
146 ${_UNIQUE_TARGET_NAME}
147 ALL
148 DEPENDS
149 "${_PO_DIRECTORY}/${_POT_FILE}"
150 )
151 else()
152 add_custom_target(
153 ${_UNIQUE_TARGET_NAME}
154 DEPENDS
155 "${_PO_DIRECTORY}/${_POT_FILE}"
156 )
157 endif()
158endfunction()
159
160function(INTLTOOL_INSTALL_TRANSLATIONS)
161 set(_options ALL)
162 set(_oneValueArgs GETTEXT_PACKAGE POT_FILE)
163
164 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "" ${ARGN})
165
166 set(_POT_FILE "${PROJECT}.pot")
167
168 if(_ARG_GETTEXT_PACKAGE)
169 set(_POT_FILE "${_ARG_GETTEXT_PACKAGE}.pot")
170 endif()
171
172 if(_ARG_OUTPUT_FILE)
173 set(_POT_FILE "${_ARG_OUTPUT_FILE}")
174 endif()
175
176 file(
177 GLOB _PO_FILES
178 ${CMAKE_CURRENT_SOURCE_DIR}/*.po
179 )
180
181 get_filename_component(_ABS_POT_FILE ${_POT_FILE} ABSOLUTE)
182
183 foreach(_PO_FILE ${_PO_FILES})
184 add_custom_command(
185 OUTPUT
186 ${_PO_FILE}
187 COMMAND
188 ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_PO_FILE} ${_ABS_POT_FILE}
189 DEPENDS
190 ${_ABS_POT_FILE}
191 )
192 endforeach()
193
194 if(_ARG_ALL)
195 gettext_create_translations(
196 ${_POT_FILE}
197 ALL
198 ${_PO_FILES}
199 )
200 else()
201 gettext_create_translations(
202 ${_POT_FILE}
203 ${_PO_FILES}
204 )
205 endif()
206endfunction()
207
208function(INTLTOOL_MERGE_TRANSLATIONS FILENAME OUTPUT_FILE)
209 set(_options ALL UTF8 PASS_THROUGH)
210 set(_oneValueArgs PO_DIRECTORY)
211
212 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "" ${ARGN})
213
214 get_filename_component(_ABS_FILENAME ${FILENAME} ABSOLUTE)
215
216 set(_PO_DIRECTORY "${CMAKE_SOURCE_DIR}/po")
217 if(_ARG_PO_DIRECTORY)
218 set(_PO_DIRECTORY "${_ARG_PO_DIRECTORY}")
219 endif()
220
221 set(_UTF8 "")
222 if(_ARG_UTF8)
223 set(_UTF8 "--utf8")
224 endif()
225
226 set(_PASS_THROUGH "")
227 if(_ARG_PASS_THROUGH)
228 set(_PASS_THROUGH "--pass-through")
229 endif()
230
231 file(
232 GLOB_RECURSE _PO_FILES
233 ${_PO_DIRECTORY}/*.po
234 )
235
236 add_custom_command(
237 OUTPUT
238 ${OUTPUT_FILE}
239 COMMAND
240 ${INTLTOOL_MERGE_EXECUTABLE} --desktop-style --quiet ${_UTF8} ${_PASS_THROUGH} ${_PO_DIRECTORY} ${FILENAME} ${OUTPUT_FILE}
241 DEPENDS
242 ${_ABS_FILENAME}
243 ${_PO_FILES}
244 WORKING_DIRECTORY
245 ${CMAKE_CURRENT_SOURCE_DIR}
246 )
247
248 get_filename_component(_OUTPUT_NAME ${OUTPUT_FILE} NAME)
249 _GETTEXT_GET_UNIQUE_TARGET_NAME(${_OUTPUT_NAME} _UNIQUE_TARGET_NAME)
250
251 if(_ARG_ALL)
252 add_custom_target(
253 ${_UNIQUE_TARGET_NAME}
254 ALL
255 DEPENDS
256 ${OUTPUT_FILE}
257 )
258 else()
259 add_custom_target(
260 ${_UNIQUE_TARGET_NAME}
261 DEPENDS
262 ${OUTPUT_FILE}
263 )
264 endif()
265endfunction()
2660
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/data'
=== removed file 'share/qtcreator/templates/wizards/ubuntu/scope/data/CMakeLists.txt'
--- share/qtcreator/templates/wizards/ubuntu/scope/data/CMakeLists.txt 2014-11-21 14:45:30 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/data/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1
2# Install the scope images
3install(
4 FILES
5 "icon.png"
6 "logo.png"
7 "screenshot.png"
8 DESTINATION
9 "${SCOPE_INSTALL_DIR}"
10)
110
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/include'
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/include/api'
=== removed file 'share/qtcreator/templates/wizards/ubuntu/scope/include/api/config.h'
--- share/qtcreator/templates/wizards/ubuntu/scope/include/api/config.h 2014-10-27 16:24:10 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/include/api/config.h 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1#ifndef API_CONFIG_H_
2#define API_CONFIG_H_
3
4#include <memory>
5#include <string>
6
7namespace api {
8
9struct Config {
10 typedef std::shared_ptr<Config> Ptr;
11
12@if "%ContentType%".substring(0, "network".length) === "network"
13 /*
14 * The root of all API request URLs
15 */
16 std::string apiroot { "http://api.openweathermap.org" };
17
18 /*
19 * The custom HTTP user agent string for this library
20 */
21 std::string user_agent { "example-network-scope 0.1; (foo)" };
22@endif
23};
24
25}
26
27#endif /* API_CONFIG_H_ */
280
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/include/scope'
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/po/POTFILES.in'
--- share/qtcreator/templates/wizards/ubuntu/scope/po/POTFILES.in 2015-01-07 10:50:28 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/po/POTFILES.in 2015-05-19 10:38:08 +0000
@@ -1,11 +1,11 @@
1[type: gettext/ini] data/%ProjectName:l%.%ClickDomain:l%_%ClickHookName:l%.ini.in1[type: gettext/ini] src/data/%ClickHookName:l%.ini.in
2include/api/config.h2[type: gettext/ini] src/data/%ClickHookName:l%-settings.ini.in
3include/api/client.h3src/client.cpp
4include/scope/preview.h4src/client.h
5include/scope/localization.h5src/localization.h
6include/scope/query.h6src/preview.cpp
7include/scope/scope.h7src/preview.h
8src/api/client.cpp8src/query.cpp
9src/scope/query.cpp9src/query.h
10src/scope/scope.cpp10src/scope.cpp
11src/scope/preview.cpp11src/scope.h
1212
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/src/CMakeLists.txt'
--- share/qtcreator/templates/wizards/ubuntu/scope/src/CMakeLists.txt 2014-11-21 14:45:30 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/CMakeLists.txt 2015-05-19 10:38:08 +0000
@@ -1,66 +1,64 @@
11
2# Put the ini file in the build directory next to the scope2# Put the ini files in the build directory next to the scope
3# .so file so test tools can find both easily.3# .so file so that the test tools can find them.
4intltool_merge_translations(4intltool_merge_translations(
5 "${CMAKE_SOURCE_DIR}/data/${SCOPE_NAME}.ini.in"5 "data/%ClickHookName:l%.ini.in"
6 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"6 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
7 ALL7 ALL
8 UTF88 UTF8
9)9)
10intltool_merge_translations(
11 "data/%ClickHookName:l%-settings.ini.in"
12 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
13 ALL
14 UTF8
15)
1016
11# Install the scope ini file17# Install the scope ini files
12install(18install(
13 FILES "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"19 FILES
14 DESTINATION ${SCOPE_INSTALL_DIR}20 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
21 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
22 DESTINATION
23 ${SCOPE_INSTALL_DIR}
15)24)
1625
26# Put the logo file in the build directory next to the scope
27# .ini file so that the test tools can find it.
17configure_file(28configure_file(
18 "${CMAKE_SOURCE_DIR}/data/logo.png"29 "data/logo.png"
19 "${CMAKE_CURRENT_BINARY_DIR}/logo.png"30 "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
20 @ONLY31 @ONLY
21 COPYONLY32 COPYONLY
22)33)
2334
24# The sources to build the scope35# Install the scope images
25set(SCOPE_SOURCES36install(
26 api/client.cpp37 FILES
27 scope/preview.cpp38 "data/icon.png"
28 scope/query.cpp39 "data/logo.png"
29 scope/scope.cpp40 "data/screenshot.png"
41 DESTINATION
42 ${SCOPE_INSTALL_DIR}
30)43)
3144
32# Find all the headers45# Find all the sources
33file(GLOB_RECURSE46file(GLOB_RECURSE
34 SCOPE_HEADERS47 SCOPE_SOURCES
35 "${CMAKE_SOURCE_DIR}/include/*.h" 48 "*.cpp"
36)49 "*.h"
37
38# Build an object library for the scope code
39add_library(
40 scope-static OBJECT
41 ${SCOPE_SOURCES}
42 ${SCOPE_HEADERS}
43)
44
45# Ensure we export all the symbols
46set_target_properties(
47 scope-static
48 PROPERTIES
49 LINK_FLAGS "-Wl,--export-all-symbols"
50)50)
5151
52# Build a shared library containing our scope code.52# Build a shared library containing our scope code.
53# This will be the actual plugin that is loaded.
54add_library(53add_library(
55 scope SHARED54 scope SHARED
56 $<TARGET_OBJECTS:scope-static>55 ${SCOPE_SOURCES}
57)56)
5857
59# Link against the object library and our external library dependencies58# Link against the object library and our external library dependencies
60target_link_libraries(59target_link_libraries(
61 scope60 scope
62 ${SCOPE_LDFLAGS}61 ${SCOPE_LDFLAGS}
63 ${Boost_LIBRARIES}
64)62)
6563
66@if "%ContentType%".substring(0, "network-netcpp-q".length) === "network-netcpp-q"64@if "%ContentType%".substring(0, "network-netcpp-q".length) === "network-netcpp-q"
6765
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/src/api'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/src/api/client.cpp' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/client.cpp'
--- share/qtcreator/templates/wizards/ubuntu/scope/src/api/client.cpp 2014-12-15 10:12:40 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/client.cpp 2015-05-19 10:38:08 +0000
@@ -1,4 +1,4 @@
1#include <api/client.h>1#include <client.h>
22
3@if "%ContentType%".substring(0, "network-netcpp".length) === "network-netcpp"3@if "%ContentType%".substring(0, "network-netcpp".length) === "network-netcpp"
4#include <core/net/error.h>4#include <core/net/error.h>
@@ -18,7 +18,6 @@
18@endif18@endif
19@endif19@endif
2020
21using namespace api;
22using namespace std;21using namespace std;
2322
24Client::Client(Config::Ptr config) :23Client::Client(Config::Ptr config) :
@@ -495,6 +494,6 @@
495 cancelled_ = true;494 cancelled_ = true;
496}495}
497496
498Config::Ptr Client::config() {497Client::Config::Ptr Client::config() {
499 return config_;498 return config_;
500}499}
501500
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/include/api/client.h' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/client.h'
--- share/qtcreator/templates/wizards/ubuntu/scope/include/api/client.h 2014-10-29 15:28:52 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/client.h 2015-05-19 10:38:08 +0000
@@ -1,11 +1,10 @@
1#ifndef API_CLIENT_H_1#ifndef CLIENT_H_
2#define API_CLIENT_H_2#define CLIENT_H_
3
4#include <api/config.h>
53
6#include <atomic>4#include <atomic>
7#include <deque>5#include <deque>
8#include <map>6#include <map>
7#include <memory>
9#include <string>8#include <string>
10@if "%ContentType%".substring(0, "network".length) === "network"9@if "%ContentType%".substring(0, "network".length) === "network"
11#include <core/net/http/request.h>10#include <core/net/http/request.h>
@@ -22,8 +21,6 @@
22@endif21@endif
23@endif22@endif
2423
25namespace api {
26
27/**24/**
28 * Provide a nice way to access the HTTP API.25 * Provide a nice way to access the HTTP API.
29 *26 *
@@ -32,6 +29,19 @@
32class Client {29class Client {
33public:30public:
3431
32 /**
33 * Client configuration
34 */
35 struct Config {
36 typedef std::shared_ptr<Config> Ptr;
37
38 // The root of all API request URLs
39 std::string apiroot { "http://api.openweathermap.org" };
40
41 // The custom HTTP user agent string for this library
42 std::string user_agent { "example-network-scope 0.1; (foo)" };
43 };
44
35@if "%ContentType%" == "empty"45@if "%ContentType%" == "empty"
36 /**46 /**
37 * Result struct47 * Result struct
@@ -163,6 +173,4 @@
163 std::atomic<bool> cancelled_;173 std::atomic<bool> cancelled_;
164};174};
165175
166}176#endif // CLIENT_H_
167
168#endif // API_CLIENT_H_
169177
=== added directory 'share/qtcreator/templates/wizards/ubuntu/scope/src/data'
=== added file 'share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName-settings.ini.in'
--- share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName-settings.ini.in 1970-01-01 00:00:00 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName-settings.ini.in 2015-05-19 10:38:08 +0000
@@ -0,0 +1,21 @@
1@if "%ContentType%".substring(0, "network".length) === "network"
2# Below are some example settings. You can access your scope's
3# settings by calling settings() from the Query::run() method.
4# E.g. auto location = settings().at("location").get_string();
5
6#[location]
7#type = string
8#defaultValue = London,uk
9#_displayName = Default Location
10
11#[units]
12#type = list
13#_displayName = Temperature Units
14#_displayValues = Metric;Imperial
15#defaultValue = 0
16
17#[forecast]
18#type = boolean
19#defaultValue = true
20#_displayName = Show Forecast
21@endif
022
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/data/displayName.ini.in' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName.ini.in'
--- share/qtcreator/templates/wizards/ubuntu/scope/data/displayName.ini.in 2014-11-21 14:45:30 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/data/displayName.ini.in 2015-05-19 10:38:08 +0000
@@ -4,6 +4,7 @@
4Art=screenshot.png4Art=screenshot.png
5Author=Firstname Lastname5Author=Firstname Lastname
6Icon=icon.png6Icon=icon.png
7Keywords=weather
78
8[Appearance]9[Appearance]
9PageHeader.Logo=logo.png10PageHeader.Logo=logo.png
1011
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/data/icon.png' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/data/icon.png'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/data/logo.png' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/data/logo.png'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/data/screenshot.png' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/data/screenshot.png'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/include/scope/localization.h' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/localization.h'
--- share/qtcreator/templates/wizards/ubuntu/scope/include/scope/localization.h 2014-10-13 13:33:36 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/localization.h 2015-05-19 10:38:08 +0000
@@ -1,5 +1,5 @@
1#ifndef SCOPE_LOCALIZATION_H_1#ifndef LOCALIZATION_H_
2#define SCOPE_LOCALIZATION_H_2#define LOCALIZATION_H_
33
4#include <libintl.h>4#include <libintl.h>
5#include <string>5#include <string>
@@ -18,5 +18,5 @@
18 }18 }
19}19}
2020
21#endif // SCOPE_LOCALIZATION_H_21#endif // LOCALIZATION_H_
2222
2323
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/src/scope/preview.cpp' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/preview.cpp'
--- share/qtcreator/templates/wizards/ubuntu/scope/src/scope/preview.cpp 2014-12-15 10:12:40 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/preview.cpp 2015-05-19 10:38:08 +0000
@@ -1,4 +1,4 @@
1#include <scope/preview.h>1#include <preview.h>
22
3#include <unity/scopes/ColumnLayout.h>3#include <unity/scopes/ColumnLayout.h>
4#include <unity/scopes/PreviewWidget.h>4#include <unity/scopes/PreviewWidget.h>
@@ -11,10 +11,9 @@
11namespace sc = unity::scopes;11namespace sc = unity::scopes;
1212
13using namespace std;13using namespace std;
14using namespace scope;
1514
16Preview::Preview(const sc::Result &result, const sc::ActionMetadata &metadata) :15Preview::Preview(const sc::Result &result, const sc::ActionMetadata &metadata) :
17 sc::PreviewQueryBase(result, metadata) {16 sc::PreviewQueryBase(result, metadata) {
18}17}
1918
20void Preview::cancelled() {19void Preview::cancelled() {
@@ -32,36 +31,36 @@
32 // However, we recommend that scopes define layouts for the best visual appearance.31 // However, we recommend that scopes define layouts for the best visual appearance.
3332
34 // Single column layout33 // Single column layout
35 layout1col.add_column( { "image", "header", "summary" });34 layout1col.add_column( { "image_widget", "header_widget", "summary_widget" } );
3635
37 // Two column layout36 // Two column layout
38 layout2col.add_column( { "image" });37 layout2col.add_column( { "image_widget" } );
39 layout2col.add_column( { "header", "summary" });38 layout2col.add_column( { "header_widget", "summary_widget" } );
4039
41 // Three cokumn layout40 // Three cokumn layout
42 layout3col.add_column( { "image" });41 layout3col.add_column( { "image_widget" });
43 layout3col.add_column( { "header", "summary" });42 layout3col.add_column( { "header_widget", "summary_widget" } );
44 layout3col.add_column( { });43 layout3col.add_column( { } );
4544
46 // Register the layouts we just created45 // Register the layouts we just created
47 reply->register_layout( { layout1col, layout2col, layout3col });46 reply->register_layout( { layout1col, layout2col, layout3col } );
47
48 // Define the image section
49 sc::PreviewWidget image("image_widget", "image");
50 // It has a single "source" property, mapped to the result's "art" property
51 image.add_attribute_mapping("source", "art");
4852
49 // Define the header section53 // Define the header section
50 sc::PreviewWidget header("header", "header");54 sc::PreviewWidget header("header_widget", "header");
51 // It has title and a subtitle properties55 // It has a "title" and a "subtitle" property
52 header.add_attribute_mapping("title", "title");56 header.add_attribute_mapping("title", "title");
53 header.add_attribute_mapping("subtitle", "subtitle");57 header.add_attribute_mapping("subtitle", "subtitle");
5458
55 // Define the image section
56 sc::PreviewWidget image("image", "image");
57 // It has a single source property, mapped to the result's art property
58 image.add_attribute_mapping("source", "art");
59
60 // Define the summary section59 // Define the summary section
61 sc::PreviewWidget description("summary", "text");60 sc::PreviewWidget summary("summary_widget", "text");
62 // It has a text property, mapped to the result's description property61 // It has a "text" property, mapped to the result's "description" property
63 description.add_attribute_mapping("text", "description");62 summary.add_attribute_mapping("text", "description");
6463
65 // Push each of the sections64 // Push each of the sections
66 reply->push( { image, header, description });65 reply->push( { image, header, summary } );
67}66}
6867
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/include/scope/preview.h' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/preview.h'
--- share/qtcreator/templates/wizards/ubuntu/scope/include/scope/preview.h 2014-09-03 14:56:27 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/preview.h 2015-05-19 10:38:08 +0000
@@ -1,5 +1,5 @@
1#ifndef SCOPE_PREVIEW_H_1#ifndef PREVIEW_H_
2#define SCOPE_PREVIEW_H_2#define PREVIEW_H_
33
4#include <unity/scopes/PreviewQueryBase.h>4#include <unity/scopes/PreviewQueryBase.h>
55
@@ -9,8 +9,6 @@
9}9}
10}10}
1111
12namespace scope {
13
14/**12/**
15 * Represents an individual preview request.13 * Represents an individual preview request.
16 *14 *
@@ -32,6 +30,4 @@
32 void run(unity::scopes::PreviewReplyProxy const& reply) override;30 void run(unity::scopes::PreviewReplyProxy const& reply) override;
33};31};
3432
35}33#endif // PREVIEW_H_
36
37#endif // SCOPE_PREVIEW_H_
3834
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/src/scope/query.cpp' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/query.cpp'
--- share/qtcreator/templates/wizards/ubuntu/scope/src/scope/query.cpp 2014-12-15 10:12:40 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/query.cpp 2015-05-19 10:38:08 +0000
@@ -1,7 +1,5 @@
1#include <boost/algorithm/string/trim.hpp>1#include <query.h>
22#include <localization.h>
3#include <scope/localization.h>
4#include <scope/query.h>
53
6#include <unity/scopes/Annotation.h>4#include <unity/scopes/Annotation.h>
7#include <unity/scopes/CategorisedResult.h>5#include <unity/scopes/CategorisedResult.h>
@@ -10,18 +8,16 @@
10#include <unity/scopes/SearchReply.h>8#include <unity/scopes/SearchReply.h>
119
12#include <iomanip>10#include <iomanip>
11#include <iostream>
13#include <sstream>12#include <sstream>
1413
15namespace sc = unity::scopes;14namespace sc = unity::scopes;
16namespace alg = boost::algorithm;
1715
18using namespace std;16using namespace std;
19using namespace api;
20using namespace scope;
2117
22@if "%ContentType%" == "empty"18@if "%ContentType%" == "empty"
23/**19/**
24 * Define the layout for theresults20 * Define the layout for the results.
25 *21 *
26 * The icon size is medium, and ask for the card layout22 * The icon size is medium, and ask for the card layout
27 * itself to be horizontal. I.e. the text will be placed23 * itself to be horizontal. I.e. the text will be placed
@@ -49,13 +45,36 @@
4945
50@if "%ContentType%".substring(0, "network".length) === "network"46@if "%ContentType%".substring(0, "network".length) === "network"
51/**47/**
52 * Define the layout for the forecast results48 * Define the larger "current weather" layout.
49 *
50 * The icons are larger.
51 */
52const static string CURRENT_TEMPLATE =
53 R"(
54{
55 "schema-version": 1,
56 "template": {
57 "category-layout": "grid",
58 "card-size": "medium"
59 },
60 "components": {
61 "title": "title",
62 "art" : {
63 "field": "art"
64 },
65 "subtitle": "subtitle"
66 }
67}
68)";
69
70/**
71 * Define the layout for the forecast results.
53 *72 *
54 * The icon size is small, and ask for the card layout73 * The icon size is small, and ask for the card layout
55 * itself to be horizontal. I.e. the text will be placed74 * itself to be horizontal. I.e. the text will be placed
56 * next to the image.75 * next to the image.
57 */76 */
58const static string WEATHER_TEMPLATE =77const static string FORECAST_TEMPLATE =
59 R"(78 R"(
60{79{
61 "schema-version": 1,80 "schema-version": 1,
@@ -73,33 +92,10 @@
73 }92 }
74}93}
75)";94)";
76
77/**
78 * Define the larger "current weather" layout.
79 *
80 * The icons are larger.
81 */
82const static string CITY_TEMPLATE =
83 R"(
84{
85 "schema-version": 1,
86 "template": {
87 "category-layout": "grid",
88 "card-size": "medium"
89 },
90 "components": {
91 "title": "title",
92 "art" : {
93 "field": "art"
94 },
95 "subtitle": "subtitle"
96 }
97}
98)";
99@endif95@endif
10096
101Query::Query(const sc::CannedQuery &query, const sc::SearchMetadata &metadata,97Query::Query(const sc::CannedQuery &query, const sc::SearchMetadata &metadata,
102 Config::Ptr config) :98 Client::Config::Ptr config) :
103 sc::SearchQueryBase(query, metadata), client_(config) {99 sc::SearchQueryBase(query, metadata), client_(config) {
104}100}
105101
@@ -113,8 +109,8 @@
113 // Start by getting information about the query109 // Start by getting information about the query
114 const sc::CannedQuery &query(sc::SearchQueryBase::query());110 const sc::CannedQuery &query(sc::SearchQueryBase::query());
115111
116 // Trim the query string of whitespace112 // Get the query string
117 string query_string = alg::trim_copy(query.query_string());113 string query_string = query.query_string();
118114
119 // the Client is the helper class that provides the results115 // the Client is the helper class that provides the results
120 // without mixing APIs and scopes code.116 // without mixing APIs and scopes code.
@@ -168,8 +164,10 @@
168 // Start by getting information about the query164 // Start by getting information about the query
169 const sc::CannedQuery &query(sc::SearchQueryBase::query());165 const sc::CannedQuery &query(sc::SearchQueryBase::query());
170166
171 // Trim the query string of whitespace167 // Get the query string
172 string query_string = alg::trim_copy(query.query_string());168 string query_string = query.query_string();
169
170 /// Populate current weather category
173171
174 // the Client is the helper class that provides the results172 // the Client is the helper class that provides the results
175 // without mixing APIs and scopes code.173 // without mixing APIs and scopes code.
@@ -190,7 +188,7 @@
190188
191 // Register a category for the current weather, with the title we just built189 // Register a category for the current weather, with the title we just built
192 auto location_cat = reply->register_category("current", ss.str(), "",190 auto location_cat = reply->register_category("current", ss.str(), "",
193 sc::CategoryRenderer(CITY_TEMPLATE));191 sc::CategoryRenderer(CURRENT_TEMPLATE));
194192
195 {193 {
196 // Create a single result for the current weather category194 // Create a single result for the current weather category
@@ -218,6 +216,8 @@
218 }216 }
219 }217 }
220218
219 /// Populate weather forecast category
220
221 Client::Forecast forecast;221 Client::Forecast forecast;
222 if (query_string.empty()) {222 if (query_string.empty()) {
223 // If there is no search string, get the forecast for London223 // If there is no search string, get the forecast for London
@@ -228,8 +228,8 @@
228 }228 }
229229
230 // Register a category for the forecast230 // Register a category for the forecast
231 auto forecast_cat = reply->register_category("forecast",231 auto forecast_cat = reply->register_category("forecast", _("7 day forecast"), "",
232 _("7 day forecast"), "", sc::CategoryRenderer(WEATHER_TEMPLATE));232 sc::CategoryRenderer(FORECAST_TEMPLATE));
233233
234 // For each of the forecast days234 // For each of the forecast days
235 for (const auto &weather : forecast.weather) {235 for (const auto &weather : forecast.weather) {
236236
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/include/scope/query.h' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/query.h'
--- share/qtcreator/templates/wizards/ubuntu/scope/include/scope/query.h 2014-09-03 14:56:27 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/query.h 2015-05-19 10:38:08 +0000
@@ -1,13 +1,11 @@
1#ifndef SCOPE_QUERY_H_1#ifndef QUERY_H_
2#define SCOPE_QUERY_H_2#define QUERY_H_
33
4#include <api/client.h>4#include <client.h>
55
6#include <unity/scopes/SearchQueryBase.h>6#include <unity/scopes/SearchQueryBase.h>
7#include <unity/scopes/ReplyProxyFwd.h>7#include <unity/scopes/ReplyProxyFwd.h>
88
9namespace scope {
10
11/**9/**
12 * Represents an individual query.10 * Represents an individual query.
13 *11 *
@@ -18,7 +16,7 @@
18class Query: public unity::scopes::SearchQueryBase {16class Query: public unity::scopes::SearchQueryBase {
19public:17public:
20 Query(const unity::scopes::CannedQuery &query,18 Query(const unity::scopes::CannedQuery &query,
21 const unity::scopes::SearchMetadata &metadata, api::Config::Ptr config);19 const unity::scopes::SearchMetadata &metadata, Client::Config::Ptr config);
2220
23 ~Query() = default;21 ~Query() = default;
2422
@@ -27,10 +25,8 @@
27 void run(const unity::scopes::SearchReplyProxy &reply) override;25 void run(const unity::scopes::SearchReplyProxy &reply) override;
2826
29private:27private:
30 api::Client client_;28 Client client_;
31};29};
3230
33}31#endif // QUERY_H_
34
35#endif // SCOPE_QUERY_H_
3632
3733
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/src/scope'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/src/scope/scope.cpp' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/scope.cpp'
--- share/qtcreator/templates/wizards/ubuntu/scope/src/scope/scope.cpp 2014-10-27 16:24:10 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/scope.cpp 2015-05-19 10:38:08 +0000
@@ -1,7 +1,7 @@
1#include <scope/localization.h>1#include <preview.h>
2#include <scope/preview.h>2#include <query.h>
3#include <scope/query.h>3#include <scope.h>
4#include <scope/scope.h>4#include <localization.h>
55
6#include <iostream>6#include <iostream>
7#include <sstream>7#include <sstream>
@@ -9,11 +9,9 @@
99
10namespace sc = unity::scopes;10namespace sc = unity::scopes;
11using namespace std;11using namespace std;
12using namespace api;
13using namespace scope;
1412
15void Scope::start(string const&) {13void Scope::start(string const&) {
16 config_ = make_shared<Config>();14 config_ = make_shared<Client::Config>();
1715
18 setlocale(LC_ALL, "");16 setlocale(LC_ALL, "");
19 string translation_directory = ScopeBase::scope_directory()17 string translation_directory = ScopeBase::scope_directory()
2018
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/include/scope/scope.h' => 'share/qtcreator/templates/wizards/ubuntu/scope/src/scope.h'
--- share/qtcreator/templates/wizards/ubuntu/scope/include/scope/scope.h 2014-09-03 14:56:27 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/src/scope.h 2015-05-19 10:38:08 +0000
@@ -1,7 +1,7 @@
1#ifndef SCOPE_SCOPE_H_1#ifndef SCOPE_H_
2#define SCOPE_SCOPE_H_2#define SCOPE_H_
33
4#include <api/config.h>4#include <client.h>
55
6#include <unity/scopes/ScopeBase.h>6#include <unity/scopes/ScopeBase.h>
7#include <unity/scopes/QueryBase.h>7#include <unity/scopes/QueryBase.h>
@@ -9,8 +9,6 @@
9#include <unity/scopes/QueryBase.h>9#include <unity/scopes/QueryBase.h>
10#include <unity/scopes/PreviewQueryBase.h>10#include <unity/scopes/PreviewQueryBase.h>
1111
12namespace scope {
13
14/**12/**
15 * Defines the lifecycle of scope plugin, and acts as a factory13 * Defines the lifecycle of scope plugin, and acts as a factory
16 * for Query and Preview objects.14 * for Query and Preview objects.
@@ -45,9 +43,7 @@
45 unity::scopes::SearchMetadata const&) override;43 unity::scopes::SearchMetadata const&) override;
4644
47protected:45protected:
48 api::Config::Ptr config_;46 Client::Config::Ptr config_;
49};47};
5048
51}49#endif // SCOPE_H_
52
53#endif // SCOPE_SCOPE_H_
5450
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/CMakeLists.txt'
--- share/qtcreator/templates/wizards/ubuntu/scope/tests/CMakeLists.txt 2014-10-27 16:24:10 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/tests/CMakeLists.txt 2015-05-19 10:38:08 +0000
@@ -19,14 +19,22 @@
19)19)
2020
21# Where to find the scope ini file and .so21# Where to find the scope ini file and .so
22add_definitions(22set(TEST_SCOPE_DIRECTORY "${CMAKE_BINARY_DIR}/src")
23 -DTEST_SCOPE_DIRECTORY="${CMAKE_BINARY_DIR}/src"
24)
2523
26@if "%ContentType%".substring(0, "network".length) === "network"
27file(GLOB_RECURSE24file(GLOB_RECURSE
28 TEST_FIXTURES25 TEST_FIXTURES
29 "server/*" 26@if "%ContentType%" == "empty"
27 "unit/*.py"
28@elsif "%ContentType%" == "network-netcpp-json"
29 "server/*.json"
30 "*.py"
31@elsif "%ContentType%" == "network-netcpp-qjson"
32 "server/*.json"
33 "*.py"
34@elsif "%ContentType%" == "network-netcpp-qxml"
35 "server/*.xml"
36 "*.py"
37@endif
30)38)
3139
32# Make this file show up in QtCreator40# Make this file show up in QtCreator
@@ -34,10 +42,9 @@
34 SOURCES ${TEST_FIXTURES}42 SOURCES ${TEST_FIXTURES}
35)43)
3644
45@if "%ContentType%".substring(0, "network".length) === "network"
37# Where to find the test server binary46# Where to find the test server binary
38add_definitions(47set(FAKE_SERVER "${CMAKE_CURRENT_SOURCE_DIR}/server/server.py")
39 -DFAKE_SERVER="${CMAKE_CURRENT_SOURCE_DIR}/server/server.py"
40)
41@endif48@endif
4249
43# Add the unit tests50# Add the unit tests
4451
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/daily/London,uk.json' => 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/London,uk.json'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/daily/London,uk.xml' => 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/London,uk.xml'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/daily/Manchester,uk.json' => 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/Manchester,uk.json'
=== renamed file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/daily/Manchester,uk.xml' => 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/Manchester,uk.xml'
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/forecast/daily'
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/server/server.py'
--- share/qtcreator/templates/wizards/ubuntu/scope/tests/server/server.py 2014-10-29 16:46:30 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/tests/server/server.py 2015-05-19 10:38:08 +0000
@@ -44,7 +44,7 @@
44 if 'mode' in query:44 if 'mode' in query:
45 mode = query['mode'][0]45 mode = query['mode'][0]
4646
47 self.wfile.write(bytes(read_file('forecast/daily/%s.%s' % (query['q'][0], mode)), 'UTF-8'))47 self.wfile.write(bytes(read_file('forecast/%s.%s' % (query['q'][0], mode)), 'UTF-8'))
48 else:48 else:
49 self.send_response(404)49 self.send_response(404)
50 self.send_header("Content-type", "text/html")50 self.send_header("Content-type", "text/html")
5151
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/CMakeLists.txt'
--- share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/CMakeLists.txt 2014-10-29 15:28:52 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/CMakeLists.txt 2015-05-19 10:38:08 +0000
@@ -1,31 +1,13 @@
11
2# Our test executable.2# This command ensures that test-scope.py has execute permission
3# It includes the object code from the scope3execute_process(COMMAND chmod +x "${CMAKE_CURRENT_SOURCE_DIR}/test-scope.py")
4add_executable(
5 scope-unit-tests
6 scope/test-scope.cpp
7 $<TARGET_OBJECTS:scope-static>
8)
9
10# Link against the scope, and all of our test lib dependencies
11target_link_libraries(
12 scope-unit-tests
13 ${GTEST_BOTH_LIBRARIES}
14 ${GMOCK_LIBRARIES}
15 ${SCOPE_LDFLAGS}
16 ${TEST_LDFLAGS}
17 ${Boost_LIBRARIES}
18)
19
20@if "%ContentType%".substring(0, "network-netcpp-q".length) === "network-netcpp-q"
21qt5_use_modules(
22 scope-unit-tests
23 Core
24)
25@endif
264
27# Register the test with CTest5# Register the test with CTest
28add_test(6add_test(
29 scope-unit-tests7 scope-unit-tests
30 scope-unit-tests8@if "%ContentType%" == "empty"
9 "${CMAKE_CURRENT_SOURCE_DIR}/test-scope.py" "${SCOPE_NAME}" "${TEST_SCOPE_DIRECTORY}/${SCOPE_NAME}.ini"
10@elsif "%ContentType%".substring(0, "network".length) === "network"
11 "${CMAKE_CURRENT_SOURCE_DIR}/test-scope.py" "${SCOPE_NAME}" "${TEST_SCOPE_DIRECTORY}/${SCOPE_NAME}.ini" "${FAKE_SERVER}"
12@endif
31)13)
3214
=== removed directory 'share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/scope'
=== removed file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/scope/test-scope.cpp'
--- share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/scope/test-scope.cpp 2014-10-27 16:24:10 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/scope/test-scope.cpp 1970-01-01 00:00:00 +0000
@@ -1,232 +0,0 @@
1#include <scope/scope.h>
2
3#include <core/posix/exec.h>
4#include <gtest/gtest.h>
5#include <gmock/gmock.h>
6#include <string>
7#include <unity/scopes/SearchReply.h>
8#include <unity/scopes/SearchReplyProxyFwd.h>
9#include <unity/scopes/Variant.h>
10#include <unity/scopes/testing/Category.h>
11#include <unity/scopes/testing/MockSearchReply.h>
12#include <unity/scopes/testing/TypedScopeFixture.h>
13
14using namespace std;
15using namespace testing;
16using namespace scope;
17
18namespace posix = core::posix;
19namespace sc = unity::scopes;
20namespace sct = unity::scopes::testing;
21
22/**
23 * Keep the tests in an anonymous namespace
24 */
25namespace {
26
27/**
28 * Custom matcher to check the properties of search results
29 */
30MATCHER_P2(ResultProp, prop, value, "") {
31 if (arg.contains(prop)) {
32 *result_listener << "result[" << prop << "] is " << arg[prop].serialize_json();
33 } else {
34 *result_listener << "result[" << prop << "] is not set";
35 }
36 return arg.contains(prop) && arg[prop] == sc::Variant(value);
37}
38
39/**
40 * Custom matcher to check the presence of departments
41 */
42MATCHER_P(IsDepartment, department, "") {
43 return arg->serialize() == department->serialize();
44}
45
46typedef sct::TypedScopeFixture<Scope> TypedScopeFixtureScope;
47
48class TestScope: public TypedScopeFixtureScope {
49protected:
50@if "%ContentType%".substring(0, "network".length) === "network"
51 void SetUp() override
52 {
53 // Start up Python-based fake OpenWeatherMap server
54 fake_server_ = posix::exec("/usr/bin/python3", { FAKE_SERVER }, { },
55 posix::StandardStream::stdout);
56
57 // Check it's running
58 ASSERT_GT(fake_server_.pid(), 0);
59 string port;
60 // The server will print out the random port it is using
61 fake_server_.cout() >> port;
62 // Check we have a port
63 ASSERT_FALSE(port.empty());
64
65 // Build up the API root
66 string apiroot = "http://127.0.0.1:" + port;
67 // Override the API root that the scope will use
68 setenv("NETWORK_SCOPE_APIROOT", apiroot.c_str(), true);
69
70 // Do the parent SetUp
71 TypedScopeFixture::set_scope_directory(TEST_SCOPE_DIRECTORY);
72 TypedScopeFixtureScope::SetUp();
73 }
74
75 /**
76 * Start by assuming the server is invalid
77 */
78 posix::ChildProcess fake_server_ = posix::ChildProcess::invalid();
79 @endif
80};
81
82TEST_F(TestScope, empty_search_string) {
83@if "%ContentType%".substring(0, "network".length) === "network"
84 const sc::CategoryRenderer renderer;
85 NiceMock<sct::MockSearchReply> reply;
86
87 // Build a query with an empty search string
88 sc::CannedQuery query(SCOPE_NAME, "", "");
89
90 // Expect the current weather category
91 EXPECT_CALL(reply, register_category("current", "London, GB", "", _)).Times(1)
92 .WillOnce(Return(make_shared<sct::Category>("current", "London, GB", "", renderer)));
93
94 // With one result
95 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
96 ResultProp("title", "21.8°C"),
97 ResultProp("art", "http://openweathermap.org/img/w/02d.png"),
98 ResultProp("subtitle", "few clouds")
99 )))).WillOnce(
100 Return(true));
101
102 // Expect the forecast category
103 EXPECT_CALL(reply, register_category("forecast", "7 day forecast", "", _)).Times(1)
104 .WillOnce(Return(make_shared<sct::Category>("forecast", "7 day forecast", "", renderer)));
105
106 // With seven results
107 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
108 ResultProp("title", "25.1°C to 18.8°C"),
109 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
110 ResultProp("subtitle", "light rain")
111 )))).WillOnce(Return(true));
112 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
113 ResultProp("title", "20.9°C to 15.5°C"),
114 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
115 ResultProp("subtitle", "moderate rain")
116 )))).WillOnce(Return(true));
117 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
118 ResultProp("title", "19.6°C to 13.2°C"),
119 ResultProp("art", "http://openweathermap.org/img/w/03d.png"),
120 ResultProp("subtitle", "scattered clouds")
121 )))).WillOnce(Return(true));
122 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
123 ResultProp("title", "18.1°C to 13.5°C"),
124 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
125 ResultProp("subtitle", "moderate rain")
126 )))).WillOnce(Return(true));
127 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
128 ResultProp("title", "17.4°C to 15.4°C"),
129 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
130 ResultProp("subtitle", "heavy intensity rain")
131 )))).WillOnce(Return(true));
132 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
133 ResultProp("title", "18.4°C to 16.2°C"),
134 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
135 ResultProp("subtitle", "moderate rain")
136 )))).WillOnce(Return(true));
137 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
138 ResultProp("title", "19°C to 16.7°C"),
139 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
140 ResultProp("subtitle", "light rain")
141 )))).WillOnce(Return(true));
142
143 sc::SearchReplyProxy reply_proxy(&reply, [](sc::SearchReply*) {}); // note: this is a std::shared_ptr with empty deleter
144 sc::SearchMetadata meta_data("en_EN", "phone");
145
146 // Create a query object
147 auto search_query = scope->search(query, meta_data);
148 ASSERT_NE(nullptr, search_query);
149
150 // Run the search
151 search_query->run(reply_proxy);
152
153 // Google Mock will make assertions when the mocks are destructed.
154@endif
155}
156
157TEST_F(TestScope, search) {
158@if "%ContentType%".substring(0, "network".length) === "network"
159 const sc::CategoryRenderer renderer;
160 NiceMock<sct::MockSearchReply> reply;
161
162 // Build a query with a non-empty search string
163 sc::CannedQuery query(SCOPE_NAME, "Manchester,uk", "");
164
165 // Expect the current weather category
166 EXPECT_CALL(reply, register_category("current", "Manchester, GB", "", _)).Times(1)
167 .WillOnce(Return(make_shared<sct::Category>("current", "Manchester, GB", "", renderer)));
168
169 // With one result
170 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
171 ResultProp("title", "17.4°C"),
172 ResultProp("art", "http://openweathermap.org/img/w/03d.png"),
173 ResultProp("subtitle", "scattered clouds")
174 )))).WillOnce(
175 Return(true));
176
177 // Expect the forecast category
178 EXPECT_CALL(reply, register_category("forecast", "7 day forecast", "", _)).Times(1)
179 .WillOnce(Return(make_shared<sct::Category>("forecast", "7 day forecast", "", renderer)));
180
181 // With seven results
182 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
183 ResultProp("title", "18.8°C to 12°C"),
184 ResultProp("art", "http://openweathermap.org/img/w/01d.png"),
185 ResultProp("subtitle", "sky is clear")
186 )))).WillOnce(Return(true));
187 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
188 ResultProp("title", "18.6°C to 12.3°C"),
189 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
190 ResultProp("subtitle", "moderate rain")
191 )))).WillOnce(Return(true));
192 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
193 ResultProp("title", "17.1°C to 10.8°C"),
194 ResultProp("art", "http://openweathermap.org/img/w/04d.png"),
195 ResultProp("subtitle", "broken clouds")
196 )))).WillOnce(Return(true));
197 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
198 ResultProp("title", "16°C to 12.2°C"),
199 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
200 ResultProp("subtitle", "moderate rain")
201 )))).WillOnce(Return(true));
202 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
203 ResultProp("title", "15.7°C to 13°C"),
204 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
205 ResultProp("subtitle", "light rain")
206 )))).WillOnce(Return(true));
207 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
208 ResultProp("title", "17.6°C to 14.1°C"),
209 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
210 ResultProp("subtitle", "moderate rain")
211 )))).WillOnce(Return(true));
212 EXPECT_CALL(reply, push(Matcher<sc::CategorisedResult const&>(AllOf(
213 ResultProp("title", "15.5°C to 13.4°C"),
214 ResultProp("art", "http://openweathermap.org/img/w/10d.png"),
215 ResultProp("subtitle", "moderate rain")
216 )))).WillOnce(Return(true));
217
218 sc::SearchReplyProxy reply_proxy(&reply, [](sc::SearchReply*) {}); // note: this is a std::shared_ptr with empty deleter
219 sc::SearchMetadata meta_data("en_EN", "phone");
220
221 // Create a query object
222 auto search_query = scope->search(query, meta_data);
223 ASSERT_NE(nullptr, search_query);
224
225 // Run the search
226 search_query->run(reply_proxy);
227
228 // Google Mock will make assertions when the mocks are destructed.
229@endif
230}
231
232} // namespace
2330
=== added file 'share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/test-scope.py'
--- share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/test-scope.py 1970-01-01 00:00:00 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/tests/unit/test-scope.py 2015-05-19 10:38:08 +0000
@@ -0,0 +1,290 @@
1#!/usr/bin/env python3
2
3from scope_harness import *
4from scope_harness.testing import *
5import unittest, sys, os
6from subprocess import Popen, PIPE
7
8@if "%ContentType%".substring(0, "network".length) === "network"
9class AppsTest (ScopeHarnessTestCase):
10 @classmethod
11 def setUpClass(cls):
12 cls.process = Popen(["/usr/bin/python3", FAKE_SERVER], stdout=PIPE)
13 port = cls.process.stdout.readline().decode("utf-8").rstrip('\n')
14 os.environ["NETWORK_SCOPE_APIROOT"] = "http://127.0.0.1:" + port
15
16 @classmethod
17 def tearDownClass(cls):
18 cls.process.terminate()
19
20
21 def start_harness(self):
22 self.harness = ScopeHarness.new_from_scope_list(Parameters([SCOPE_INI]))
23 self.view = self.harness.results_view
24 self.view.active_scope = SCOPE_NAME
25
26
27@if "%ContentType%" == "network-netcpp-qxml"
28 def test_surfacing_results(self):
29 self.start_harness()
30 self.view.search_query = ''
31
32 match = CategoryListMatcher() \
33 .has_exactly(2) \
34 .mode(CategoryListMatcherMode.BY_ID) \
35 .category(CategoryMatcher("current") \
36 .title("London, GB") \
37 .has_at_least(1) \
38 .result(ResultMatcher("2643743") \
39 .title("21.8°C") \
40 .art("http://openweathermap.org/img/w/02d.png") \
41 .subtitle("few clouds") ) ) \
42 .category(CategoryMatcher("forecast") \
43 .title("7 day forecast") \
44 .has_at_least(7) \
45 .result(ResultMatcher("1000000") \
46 .title("25.1°C to 18.8°C") \
47 .art("http://openweathermap.org/img/w/10d.png") \
48 .subtitle("light rain") ) \
49 .result(ResultMatcher("1000001") \
50 .title("20.9°C to 15.5°C") \
51 .art("http://openweathermap.org/img/w/10d.png") \
52 .subtitle("moderate rain") ) \
53 .result(ResultMatcher("1000002") \
54 .title("19.6°C to 13.2°C") \
55 .art("http://openweathermap.org/img/w/03d.png") \
56 .subtitle("scattered clouds") ) \
57 .result(ResultMatcher("1000003") \
58 .title("18.1°C to 13.5°C") \
59 .art("http://openweathermap.org/img/w/10d.png") \
60 .subtitle("moderate rain") ) \
61 .result(ResultMatcher("1000004") \
62 .title("17.4°C to 15.4°C") \
63 .art("http://openweathermap.org/img/w/10d.png") \
64 .subtitle("heavy intensity rain") ) \
65 .result(ResultMatcher("1000005") \
66 .title("18.4°C to 16.2°C") \
67 .art("http://openweathermap.org/img/w/10d.png") \
68 .subtitle("moderate rain") ) \
69 .result(ResultMatcher("1000006") \
70 .title("19°C to 16.7°C") \
71 .art("http://openweathermap.org/img/w/10d.png") \
72 .subtitle("light rain") ) ) \
73 .match(self.view.categories)
74 self.assertMatchResult(match)
75@else
76 def test_surfacing_results(self):
77 self.start_harness()
78 self.view.search_query = ''
79
80 match = CategoryListMatcher() \
81 .has_exactly(2) \
82 .mode(CategoryListMatcherMode.BY_ID) \
83 .category(CategoryMatcher("current") \
84 .title("London, GB") \
85 .has_at_least(1) \
86 .result(ResultMatcher("5091") \
87 .title("21.8°C") \
88 .art("http://openweathermap.org/img/w/02d.png") \
89 .subtitle("few clouds") ) ) \
90 .category(CategoryMatcher("forecast") \
91 .title("7 day forecast") \
92 .has_at_least(7) \
93 .result(ResultMatcher("500") \
94 .title("25.1°C to 18.8°C") \
95 .art("http://openweathermap.org/img/w/10d.png") \
96 .subtitle("light rain") ) \
97 .result(ResultMatcher("501") \
98 .title("20.9°C to 15.5°C") \
99 .art("http://openweathermap.org/img/w/10d.png") \
100 .subtitle("moderate rain") ) \
101 .result(ResultMatcher("802") \
102 .title("19.6°C to 13.2°C") \
103 .art("http://openweathermap.org/img/w/03d.png") \
104 .subtitle("scattered clouds") ) \
105 .result(ResultMatcher("501") \
106 .title("18.1°C to 13.5°C") \
107 .art("http://openweathermap.org/img/w/10d.png") \
108 .subtitle("moderate rain") ) \
109 .result(ResultMatcher("502") \
110 .title("17.4°C to 15.4°C") \
111 .art("http://openweathermap.org/img/w/10d.png") \
112 .subtitle("heavy intensity rain") ) \
113 .result(ResultMatcher("501") \
114 .title("18.4°C to 16.2°C") \
115 .art("http://openweathermap.org/img/w/10d.png") \
116 .subtitle("moderate rain") ) \
117 .result(ResultMatcher("500") \
118 .title("19°C to 16.7°C") \
119 .art("http://openweathermap.org/img/w/10d.png") \
120 .subtitle("light rain") ) ) \
121 .match(self.view.categories)
122 self.assertMatchResult(match)
123@endif
124
125
126@if "%ContentType%" == "network-netcpp-qxml"
127 def test_search_results(self):
128 self.start_harness()
129 self.view.search_query = 'Manchester,uk'
130
131 match = CategoryListMatcher() \
132 .has_exactly(2) \
133 .mode(CategoryListMatcherMode.BY_ID) \
134 .category(CategoryMatcher("current") \
135 .title("Manchester, GB") \
136 .has_at_least(1) \
137 .result(ResultMatcher("2643123") \
138 .title("17.4°C") \
139 .art("http://openweathermap.org/img/w/03d.png") \
140 .subtitle("scattered clouds") ) ) \
141 .category(CategoryMatcher("forecast") \
142 .title("7 day forecast") \
143 .has_at_least(7) \
144 .result(ResultMatcher("1000000") \
145 .title("18.8°C to 12°C") \
146 .art("http://openweathermap.org/img/w/01d.png") \
147 .subtitle("sky is clear") ) \
148 .result(ResultMatcher("1000001") \
149 .title("18.6°C to 12.3°C") \
150 .art("http://openweathermap.org/img/w/10d.png") \
151 .subtitle("moderate rain") ) \
152 .result(ResultMatcher("1000002") \
153 .title("17.1°C to 10.8°C") \
154 .art("http://openweathermap.org/img/w/04d.png") \
155 .subtitle("broken clouds") ) \
156 .result(ResultMatcher("1000003") \
157 .title("16°C to 12.2°C") \
158 .art("http://openweathermap.org/img/w/10d.png") \
159 .subtitle("moderate rain") ) \
160 .result(ResultMatcher("1000004") \
161 .title("15.7°C to 13°C") \
162 .art("http://openweathermap.org/img/w/10d.png") \
163 .subtitle("light rain") ) \
164 .result(ResultMatcher("1000005") \
165 .title("17.6°C to 14.1°C") \
166 .art("http://openweathermap.org/img/w/10d.png") \
167 .subtitle("moderate rain") ) \
168 .result(ResultMatcher("1000006") \
169 .title("15.5°C to 13.4°C") \
170 .art("http://openweathermap.org/img/w/10d.png") \
171 .subtitle("moderate rain") ) ) \
172 .match(self.view.categories)
173 self.assertMatchResult(match)
174@else
175 def test_search_results(self):
176 self.start_harness()
177 self.view.search_query = 'Manchester,uk'
178
179 match = CategoryListMatcher() \
180 .has_exactly(2) \
181 .mode(CategoryListMatcherMode.BY_ID) \
182 .category(CategoryMatcher("current") \
183 .title("Manchester, GB") \
184 .has_at_least(1) \
185 .result(ResultMatcher("5060") \
186 .title("17.4°C") \
187 .art("http://openweathermap.org/img/w/03d.png") \
188 .subtitle("scattered clouds") ) ) \
189 .category(CategoryMatcher("forecast") \
190 .title("7 day forecast") \
191 .has_at_least(7) \
192 .result(ResultMatcher("800") \
193 .title("18.8°C to 12°C") \
194 .art("http://openweathermap.org/img/w/01d.png") \
195 .subtitle("sky is clear") ) \
196 .result(ResultMatcher("501") \
197 .title("18.6°C to 12.3°C") \
198 .art("http://openweathermap.org/img/w/10d.png") \
199 .subtitle("moderate rain") ) \
200 .result(ResultMatcher("803") \
201 .title("17.1°C to 10.8°C") \
202 .art("http://openweathermap.org/img/w/04d.png") \
203 .subtitle("broken clouds") ) \
204 .result(ResultMatcher("501") \
205 .title("16°C to 12.2°C") \
206 .art("http://openweathermap.org/img/w/10d.png") \
207 .subtitle("moderate rain") ) \
208 .result(ResultMatcher("500") \
209 .title("15.7°C to 13°C") \
210 .art("http://openweathermap.org/img/w/10d.png") \
211 .subtitle("light rain") ) \
212 .result(ResultMatcher("501") \
213 .title("17.6°C to 14.1°C") \
214 .art("http://openweathermap.org/img/w/10d.png") \
215 .subtitle("moderate rain") ) \
216 .result(ResultMatcher("501") \
217 .title("15.5°C to 13.4°C") \
218 .art("http://openweathermap.org/img/w/10d.png") \
219 .subtitle("moderate rain") ) ) \
220 .match(self.view.categories)
221 self.assertMatchResult(match)
222@endif
223
224
225if __name__ == '__main__':
226 SCOPE_NAME = sys.argv[1]
227 SCOPE_INI = sys.argv[2]
228 FAKE_SERVER = sys.argv[3]
229
230 unittest.main(argv = sys.argv[:1])
231
232@elsif "%ContentType%" == "empty"
233class AppsTest (ScopeHarnessTestCase):
234 def start_harness(self):
235 self.harness = ScopeHarness.new_from_scope_list(Parameters([SCOPE_INI]))
236 self.view = self.harness.results_view
237 self.view.active_scope = SCOPE_NAME
238
239
240 def test_surfacing_results(self):
241 self.start_harness()
242 self.view.search_query = ''
243
244 match = CategoryListMatcher() \
245 .has_exactly(1) \
246 .mode(CategoryListMatcherMode.BY_ID) \
247 .category(CategoryMatcher("results") \
248 .title("2 results") \
249 .has_at_least(2) \
250 .result(ResultMatcher("uri") \
251 .title("default") \
252 .art("art.png") \
253 .subtitle("subtitle") ) \
254 .result(ResultMatcher("uri2") \
255 .title("default") \
256 .art("art2.png") \
257 .subtitle("subtitle2") ) ) \
258 .match(self.view.categories)
259 self.assertMatchResult(match)
260
261
262 def test_search_results(self):
263 self.start_harness()
264 self.view.search_query = 'test'
265
266 match = CategoryListMatcher() \
267 .has_exactly(1) \
268 .mode(CategoryListMatcherMode.BY_ID) \
269 .category(CategoryMatcher("results") \
270 .title("2 results") \
271 .has_at_least(2) \
272 .result(ResultMatcher("uri") \
273 .title("test") \
274 .art("art.png") \
275 .subtitle("subtitle") ) \
276 .result(ResultMatcher("uri2") \
277 .title("test") \
278 .art("art2.png") \
279 .subtitle("subtitle2") ) ) \
280 .match(self.view.categories)
281 self.assertMatchResult(match)
282
283
284if __name__ == '__main__':
285 SCOPE_NAME = sys.argv[1]
286 SCOPE_INI = sys.argv[2]
287
288 unittest.main(argv = sys.argv[:1])
289
290@endif
0291
=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml'
--- share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml 2015-01-15 12:51:26 +0000
+++ share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml 2015-05-19 10:38:08 +0000
@@ -9,37 +9,31 @@
9 <displayname>Unity Scope (cmake)</displayname>9 <displayname>Unity Scope (cmake)</displayname>
10 <displaycategory>Ubuntu</displaycategory>10 <displaycategory>Ubuntu</displaycategory>
11 <files>11 <files>
12 <file source="cmake/FindGMock.cmake"/>
13 <file source="cmake/FindIntltool.cmake"/>
14
15 <file source="data/CMakeLists.txt"/>
16 <file source="data/displayName.ini.in" target="data/%ProjectName:l%.%ClickDomain:l%_%ClickHookName:l%.ini.in"/>
17 <file source="data/icon.png" binary="true"/>
18 <file source="data/logo.png" binary="true"/>
19 <file source="data/screenshot.png" binary="true"/>
20
21 <file source="include/api/config.h"/>
22 <file source="include/api/client.h"/>
23 <file source="include/scope/localization.h"/>
24 <file source="include/scope/preview.h"/>
25 <file source="include/scope/query.h"/>
26 <file source="include/scope/scope.h"/>
27
28 <file source="src/CMakeLists.txt"/>12 <file source="src/CMakeLists.txt"/>
29 <file source="src/api/client.cpp"/>13 <file source="src/data/displayName.ini.in" target="src/data/%ClickHookName:l%.ini.in"/>
30 <file source="src/scope/query.cpp"/>14 <file source="src/data/displayName-settings.ini.in" target="src/data/%ClickHookName:l%-settings.ini.in"/>
31 <file source="src/scope/scope.cpp" openeditor="true"/>15 <file source="src/data/icon.png" binary="true"/>
32 <file source="src/scope/preview.cpp"/>16 <file source="src/data/logo.png" binary="true"/>
17 <file source="src/data/screenshot.png" binary="true"/>
18 <file source="src/client.cpp"/>
19 <file source="src/client.h"/>
20 <file source="src/localization.h"/>
21 <file source="src/preview.cpp"/>
22 <file source="src/preview.h"/>
23 <file source="src/query.cpp"/>
24 <file source="src/query.h"/>
25 <file source="src/scope.cpp" openeditor="true"/>
26 <file source="src/scope.h"/>
3327
34 <file source="po/CMakeLists.txt"/>28 <file source="po/CMakeLists.txt"/>
35 <file source="po/displayName.pot" target="po/%ProjectName:l%.pot"/>29 <file source="po/displayName.pot" target="po/%ProjectName:l%.pot"/>
36 <file source="po/Makefile.in.in"/>30 <file source="po/Makefile.in.in"/>
37 <file source="po/POTFILES.in"/>31 <file source="po/POTFILES.in"/>
3832
39 <file source="tests/server/forecast/daily/Manchester,uk.json"/>33 <file source="tests/server/forecast/Manchester,uk.json"/>
40 <file source="tests/server/forecast/daily/Manchester,uk.xml"/>34 <file source="tests/server/forecast/Manchester,uk.xml"/>
41 <file source="tests/server/forecast/daily/London,uk.json"/>35 <file source="tests/server/forecast/London,uk.json"/>
42 <file source="tests/server/forecast/daily/London,uk.xml"/>36 <file source="tests/server/forecast/London,uk.xml"/>
43 <file source="tests/server/weather/Manchester,uk.json"/>37 <file source="tests/server/weather/Manchester,uk.json"/>
44 <file source="tests/server/weather/Manchester,uk.xml"/>38 <file source="tests/server/weather/Manchester,uk.xml"/>
45 <file source="tests/server/weather/London,uk.json"/>39 <file source="tests/server/weather/London,uk.json"/>
@@ -47,7 +41,7 @@
47 <file source="tests/server/server.py"/>41 <file source="tests/server/server.py"/>
48 <file source="tests/CMakeLists.txt"/>42 <file source="tests/CMakeLists.txt"/>
49 <file source="tests/unit/CMakeLists.txt"/>43 <file source="tests/unit/CMakeLists.txt"/>
50 <file source="tests/unit/scope/test-scope.cpp"/>44 <file source="tests/unit/test-scope.py"/>
5145
52 <file source="CMakeLists.txt" openproject="true"/>46 <file source="CMakeLists.txt" openproject="true"/>
53 <file source="displayName.apparmor" target="%ClickHookName:l%.apparmor"/>47 <file source="displayName.apparmor" target="%ClickHookName:l%.apparmor"/>

Subscribers

People subscribed via source and target branches