Merge lp:~unity-team/unity/libunity-7.0-breakage-tests into lp:~unity-team/unity/libunity-7.0-breakage
- libunity-7.0-breakage-tests
- Merge into libunity-7.0-breakage
Status: | Merged |
---|---|
Approved by: | Nick Dedekind |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3089 |
Proposed branch: | lp:~unity-team/unity/libunity-7.0-breakage-tests |
Merge into: | lp:~unity-team/unity/libunity-7.0-breakage |
Diff against target: |
6520 lines (+4236/-767) 53 files modified
CMakeLists.txt (+16/-0) tests/CMakeLists.txt (+39/-14) tests/MockCategories.h (+67/-0) tests/autopilot/unity/emulators/dash.py (+113/-101) tests/autopilot/unity/emulators/hud.py (+2/-2) tests/autopilot/unity/emulators/launcher.py (+3/-2) tests/autopilot/unity/emulators/panel.py (+4/-4) tests/autopilot/unity/emulators/quicklist.py (+7/-3) tests/autopilot/unity/emulators/switcher.py (+2/-2) tests/autopilot/unity/tests/test_command_lens.py (+23/-23) tests/autopilot/unity/tests/test_dash.py (+177/-177) tests/autopilot/unity/tests/test_home_lens.py (+4/-4) tests/autopilot/unity/tests/test_search.py (+20/-20) tests/autopilot/unity/tests/test_shopping_lens.py (+31/-31) tests/data/unity/scopes/testscope1.scope (+13/-0) tests/data/unity/scopes/testscope2.scope (+13/-0) tests/data/unity/scopes/testscope3.scope (+13/-0) tests/data/unity/scopes/testscope4.scope (+13/-0) tests/test_categories.cpp (+86/-4) tests/test_dash_view.cpp (+0/-67) tests/test_dashview.cpp (+116/-0) tests/test_dashview_impl.cpp (+12/-12) tests/test_dbus_indicators.cpp (+3/-3) tests/test_desktop_utilities.cpp (+67/-55) tests/test_glib_source.cpp (+1/-1) tests/test_glib_variant.cpp (+23/-9) tests/test_gsettings_scopes.cpp (+230/-0) tests/test_hud.cpp (+48/-92) tests/test_hud_view.cpp (+1/-0) tests/test_lensview.cpp (+0/-98) tests/test_main.cpp (+8/-0) tests/test_main_dbus.cpp (+25/-1) tests/test_main_xless.cpp (+6/-0) tests/test_mock_scope.h (+178/-0) tests/test_model_iterator.cpp (+87/-1) tests/test_preview_player.cpp (+151/-0) tests/test_results.cpp (+140/-0) tests/test_resultviewgrid.cpp (+1/-1) tests/test_scope.cpp (+236/-0) tests/test_scope_bar.cpp (+134/-0) tests/test_scope_data.cpp (+67/-0) tests/test_scope_filter.cpp (+335/-0) tests/test_scope_impl.c (+511/-0) tests/test_scope_impl.h (+66/-0) tests/test_scope_proxy.cpp (+312/-0) tests/test_scopeview.cpp (+104/-0) tests/test_service_main.cpp (+24/-0) tests/test_service_model.cpp (+195/-20) tests/test_service_model.h (+11/-0) tests/test_service_scope.cpp (+270/-0) tests/test_service_scope.h (+48/-0) tests/test_tracks.cpp (+131/-0) tests/test_utils.h (+49/-20) |
To merge this branch: | bzr merge lp:~unity-team/unity/libunity-7.0-breakage-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Łukasz Zemczak | autopilot | Approve | |
Review via email: mp+153607@code.launchpad.net |
Commit message
Added/Updated unit tests for new libunity scope API.
Description of the change
Added/Updated unit tests for new libunity scope API.
PS Jenkins bot (ps-jenkins) wrote : | # |
Łukasz Zemczak (sil2100) wrote : | # |
+1 regarding the autopilot parts
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3088
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Nick Dedekind (nick-dedekind) wrote : | # |
- TEST(TestDeskto
- TEST(TestDeskto
- TEST(TestDeskto
Removed these tests. Calling the functions these tests are testing before running these tests invalidates the results (:S). glib caches the function results and therefore does not change their values when XDG folders update.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3089
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2013-03-20 13:14:31 +0000 | |||
3 | +++ CMakeLists.txt 2013-03-21 14:03:22 +0000 | |||
4 | @@ -53,6 +53,8 @@ | |||
5 | 53 | 53 | ||
6 | 54 | if (CMAKE_BUILD_TYPE MATCHES coverage) | 54 | if (CMAKE_BUILD_TYPE MATCHES coverage) |
7 | 55 | set (COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml") | 55 | set (COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml") |
8 | 56 | set (COVERAGE_INFO_FILE "${CMAKE_BINARY_DIR}/coverage-html.info") | ||
9 | 57 | set (COVERAGE_HTML_DIR "${CMAKE_BINARY_DIR}/coverage-html") | ||
10 | 56 | 58 | ||
11 | 57 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" ) | 59 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" ) |
12 | 58 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" ) | 60 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" ) |
13 | @@ -67,6 +69,20 @@ | |||
14 | 67 | add_custom_target (coverage-xml | 69 | add_custom_target (coverage-xml |
15 | 68 | COMMAND "${GCOVR_EXECUTABLE}" --exclude="tests.*" --exclude="obj-.*" -x -r "${CMAKE_SOURCE_DIR}" -o "${COVERAGE_XML_FILE}") | 70 | COMMAND "${GCOVR_EXECUTABLE}" --exclude="tests.*" --exclude="obj-.*" -x -r "${CMAKE_SOURCE_DIR}" -o "${COVERAGE_XML_FILE}") |
16 | 69 | endif() | 71 | endif() |
17 | 72 | |||
18 | 73 | find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${LCOV_ROOT}/bin") | ||
19 | 74 | find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT} "${GENHTML_ROOT}/bin") | ||
20 | 75 | if (NOT LCOV_EXECUTABLE) | ||
21 | 76 | message(FATAL_ERROR "Cannot enable coverage targets because gcovr was not found.") | ||
22 | 77 | elseif (NOT GENHTML_EXECUTABLE) | ||
23 | 78 | message(FATAL_ERROR "Cannot enable coverage targets because genhtml was not found.") | ||
24 | 79 | else () | ||
25 | 80 | message (STATUS "Enabling HTML coverage report") | ||
26 | 81 | add_custom_target (coverage-html | ||
27 | 82 | COMMAND "${LCOV_EXECUTABLE}" --directory "${CMAKE_BINARY_DIR}" --capture --output-file "${COVERAGE_INFO_FILE}" | ||
28 | 83 | COMMAND "${GENHTML_EXECUTABLE}" --output-directory "${COVERAGE_HTML_DIR}" "${COVERAGE_INFO_FILE}") | ||
29 | 84 | endif() | ||
30 | 85 | |||
31 | 70 | endif (CMAKE_BUILD_TYPE MATCHES coverage) | 86 | endif (CMAKE_BUILD_TYPE MATCHES coverage) |
32 | 71 | 87 | ||
33 | 72 | 88 | ||
34 | 73 | 89 | ||
35 | === modified file 'tests/CMakeLists.txt' | |||
36 | --- tests/CMakeLists.txt 2013-03-20 13:14:31 +0000 | |||
37 | +++ tests/CMakeLists.txt 2013-03-21 14:03:22 +0000 | |||
38 | @@ -16,16 +16,20 @@ | |||
39 | 16 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/kde4/afile.desktop | 16 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/kde4/afile.desktop |
40 | 17 | ${CMAKE_BINARY_DIR}/tests/data/applications/kde4/afile.desktop) | 17 | ${CMAKE_BINARY_DIR}/tests/data/applications/kde4/afile.desktop) |
41 | 18 | 18 | ||
52 | 19 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/lenses/social/social.lens | 19 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/scopes/testscope1.scope |
53 | 20 | ${CMAKE_BINARY_DIR}/tests/data/lenses/social/social.lens) | 20 | ${CMAKE_BINARY_DIR}/tests/data/unity/scopes/testscope1.scope) |
54 | 21 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/lenses/files/files.lens | 21 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/scopes/testscope2.scope |
55 | 22 | ${CMAKE_BINARY_DIR}/tests/data/lenses/files/files.lens) | 22 | ${CMAKE_BINARY_DIR}/tests/data/unity/scopes/testscope2.scope) |
56 | 23 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/lenses/applications/applications.lens | 23 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/scopes/testscope3.scope |
57 | 24 | ${CMAKE_BINARY_DIR}/tests/data/lenses/applications/applications.lens) | 24 | ${CMAKE_BINARY_DIR}/tests/data/unity/scopes/testscope3.scope) |
58 | 25 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/lenses/invalid-lens-file/invalid-lens-file.lens | 25 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/scopes/testscope4.scope |
59 | 26 | ${CMAKE_BINARY_DIR}/tests/data/lenses/invalid-lens-file/invalid-lens-file.lens) | 26 | ${CMAKE_BINARY_DIR}/tests/data/unity/scopes/testscope4.scope) |
60 | 27 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/lenses/invalid-lens-group/invalid-lens-group.lens | 27 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/sounds/brownnoise.mp3 |
61 | 28 | ${CMAKE_BINARY_DIR}/tests/data/lenses/invalid-lens-group/invalid-lens-group.lens) | 28 | ${CMAKE_BINARY_DIR}/tests/data/unity/sounds/brownnoise.mp3 COPYONLY) |
62 | 29 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/sounds/pinknoise.mp3 | ||
63 | 30 | ${CMAKE_BINARY_DIR}/tests/data/unity/sounds/pinknoise.mp3 COPYONLY) | ||
64 | 31 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/unity/sounds/whitenoise.mp3 | ||
65 | 32 | ${CMAKE_BINARY_DIR}/tests/data/unity/sounds/whitenoise.mp3 COPYONLY) | ||
66 | 29 | 33 | ||
67 | 30 | # | 34 | # |
68 | 31 | # Unit tests | 35 | # Unit tests |
69 | @@ -95,8 +99,18 @@ | |||
70 | 95 | test_service_hud.cpp | 99 | test_service_hud.cpp |
71 | 96 | test_service_main.cpp | 100 | test_service_main.cpp |
72 | 97 | test_service_model.cpp | 101 | test_service_model.cpp |
75 | 98 | test_service_panel.cpp) | 102 | test_service_panel.cpp |
76 | 99 | target_link_libraries(test-gtest-service unity-shared ${LIBS}) | 103 | test_service_scope.cpp) |
77 | 104 | |||
78 | 105 | # Build plain C files separately so they don't try to include the | ||
79 | 106 | # C++ pch. | ||
80 | 107 | add_library(test-gtest-service-plainc STATIC | ||
81 | 108 | test_scope_impl.c) | ||
82 | 109 | |||
83 | 110 | target_link_libraries(test-gtest-service | ||
84 | 111 | test-gtest-service-plainc | ||
85 | 112 | unity-shared | ||
86 | 113 | ${LIBS}) | ||
87 | 100 | 114 | ||
88 | 101 | # gtest-slow, start moving things over that are slow running tests | 115 | # gtest-slow, start moving things over that are slow running tests |
89 | 102 | set (GTEST_SLOW_SOURCES | 116 | set (GTEST_SLOW_SOURCES |
90 | @@ -135,6 +149,7 @@ | |||
91 | 135 | test_glib_source.cpp | 149 | test_glib_source.cpp |
92 | 136 | test_glib_variant.cpp | 150 | test_glib_variant.cpp |
93 | 137 | test_grabhandle.cpp | 151 | test_grabhandle.cpp |
94 | 152 | test_gsettings_scopes.cpp | ||
95 | 138 | test_desktop_utilities.cpp | 153 | test_desktop_utilities.cpp |
96 | 139 | test_indicator.cpp | 154 | test_indicator.cpp |
97 | 140 | test_indicator_appmenu.cpp | 155 | test_indicator_appmenu.cpp |
98 | @@ -149,6 +164,7 @@ | |||
99 | 149 | test_layout_system.cpp | 164 | test_layout_system.cpp |
100 | 150 | test_model_iterator.cpp | 165 | test_model_iterator.cpp |
101 | 151 | test_previews.cpp | 166 | test_previews.cpp |
102 | 167 | test_scope_data.cpp | ||
103 | 152 | test_time_util.cpp | 168 | test_time_util.cpp |
104 | 153 | test_ubus.cpp | 169 | test_ubus.cpp |
105 | 154 | test_unityshell_private.cpp | 170 | test_unityshell_private.cpp |
106 | @@ -204,10 +220,14 @@ | |||
107 | 204 | test_utils.h | 220 | test_utils.h |
108 | 205 | test_ratings_filter.cpp | 221 | test_ratings_filter.cpp |
109 | 206 | test_results.cpp | 222 | test_results.cpp |
110 | 223 | test_scope.cpp | ||
111 | 224 | test_scope_filter.cpp | ||
112 | 225 | test_scope_proxy.cpp | ||
113 | 226 | test_tracks.cpp | ||
114 | 207 | ) | 227 | ) |
115 | 208 | target_link_libraries(test-gtest-dbus gtest unity-shared ${LIBS}) | 228 | target_link_libraries(test-gtest-dbus gtest unity-shared ${LIBS}) |
116 | 209 | add_test(UnityGTestDBus test-gtest-dbus) | 229 | add_test(UnityGTestDBus test-gtest-dbus) |
118 | 210 | add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service gtest) | 230 | add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} unity-shared test-gtest-service gtest) |
119 | 211 | 231 | ||
120 | 212 | if (ENABLE_X_SUPPORT) | 232 | if (ENABLE_X_SUPPORT) |
121 | 213 | # Tests that require X | 233 | # Tests that require X |
122 | @@ -219,6 +239,8 @@ | |||
123 | 219 | test_application_launcher_icon.cpp | 239 | test_application_launcher_icon.cpp |
124 | 220 | test_bamf_application.cpp | 240 | test_bamf_application.cpp |
125 | 221 | test_bfb_launcher_icon.cpp | 241 | test_bfb_launcher_icon.cpp |
126 | 242 | test_dashview.cpp | ||
127 | 243 | test_dashview_impl.cpp | ||
128 | 222 | test_dash_controller.cpp | 244 | test_dash_controller.cpp |
129 | 223 | test_desktop_launcher_icon.cpp | 245 | test_desktop_launcher_icon.cpp |
130 | 224 | test_device_launcher_section.cpp | 246 | test_device_launcher_section.cpp |
131 | @@ -233,6 +255,7 @@ | |||
132 | 233 | test_hud_view.cpp | 255 | test_hud_view.cpp |
133 | 234 | test_icon_loader.cpp | 256 | test_icon_loader.cpp |
134 | 235 | test_im_text_entry.cpp | 257 | test_im_text_entry.cpp |
135 | 258 | test_keyboard_util.cpp | ||
136 | 236 | test_im_text_entry_class.cpp | 259 | test_im_text_entry_class.cpp |
137 | 237 | test_launcher.cpp | 260 | test_launcher.cpp |
138 | 238 | test_launcher_controller.cpp | 261 | test_launcher_controller.cpp |
139 | @@ -242,13 +265,13 @@ | |||
140 | 242 | test_launcher_icon.cpp | 265 | test_launcher_icon.cpp |
141 | 243 | test_launcher_minimize_speed.cpp | 266 | test_launcher_minimize_speed.cpp |
142 | 244 | test_launcher_tooltip.cpp | 267 | test_launcher_tooltip.cpp |
143 | 245 | test_keyboard_util.cpp | ||
144 | 246 | test_panel_indicators_view.cpp | 268 | test_panel_indicators_view.cpp |
145 | 247 | test_panel_menu_view.cpp | 269 | test_panel_menu_view.cpp |
146 | 248 | test_panel_style.cpp | 270 | test_panel_style.cpp |
147 | 249 | test_panel_tray.cpp | 271 | test_panel_tray.cpp |
148 | 250 | test_panel_view.cpp | 272 | test_panel_view.cpp |
149 | 251 | test_places_group.cpp | 273 | test_places_group.cpp |
150 | 274 | test_preview_player.cpp | ||
151 | 252 | test_previews_application.cpp | 275 | test_previews_application.cpp |
152 | 253 | test_previews_generic.cpp | 276 | test_previews_generic.cpp |
153 | 254 | test_previews_movie.cpp | 277 | test_previews_movie.cpp |
154 | @@ -260,6 +283,8 @@ | |||
155 | 260 | test_quicklist_view.cpp | 283 | test_quicklist_view.cpp |
156 | 261 | test_result_renderer.cpp | 284 | test_result_renderer.cpp |
157 | 262 | test_resultviewgrid.cpp | 285 | test_resultviewgrid.cpp |
158 | 286 | test_scope_bar.cpp | ||
159 | 287 | test_scopeview.cpp | ||
160 | 263 | test_searchbar.cpp | 288 | test_searchbar.cpp |
161 | 264 | test_session_button.cpp | 289 | test_session_button.cpp |
162 | 265 | test_session_controller.cpp | 290 | test_session_controller.cpp |
163 | 266 | 291 | ||
164 | === added file 'tests/MockCategories.h' | |||
165 | --- tests/MockCategories.h 1970-01-01 00:00:00 +0000 | |||
166 | +++ tests/MockCategories.h 2013-03-21 14:03:22 +0000 | |||
167 | @@ -0,0 +1,67 @@ | |||
168 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
169 | 2 | /* | ||
170 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
171 | 4 | * | ||
172 | 5 | * This program is free software: you can redistribute it and/or modify | ||
173 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
174 | 7 | * published by the Free Software Foundation. | ||
175 | 8 | * | ||
176 | 9 | * This program is distributed in the hope that it will be useful, | ||
177 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
178 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
179 | 12 | * GNU General Public License for more details. | ||
180 | 13 | * | ||
181 | 14 | * You should have received a copy of the GNU General Public License | ||
182 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
183 | 16 | * | ||
184 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
185 | 18 | */ | ||
186 | 19 | |||
187 | 20 | #ifndef _UNITY_MOCK_CATEGORIES_H | ||
188 | 21 | #define _UNITY_MOCK_CATEGORIES_H | ||
189 | 22 | |||
190 | 23 | #include <dee.h> | ||
191 | 24 | |||
192 | 25 | namespace unity | ||
193 | 26 | { | ||
194 | 27 | namespace dash | ||
195 | 28 | { | ||
196 | 29 | |||
197 | 30 | class MockCategories : public Categories | ||
198 | 31 | { | ||
199 | 32 | public: | ||
200 | 33 | MockCategories(unsigned count) | ||
201 | 34 | : Categories(LOCAL) | ||
202 | 35 | , model_(dee_sequence_model_new()) | ||
203 | 36 | { | ||
204 | 37 | dee_model_set_schema(model_, "s", "s", "s", "s", "a{sv}", nullptr); | ||
205 | 38 | AddResults(count); | ||
206 | 39 | |||
207 | 40 | SetModel(model_); | ||
208 | 41 | } | ||
209 | 42 | |||
210 | 43 | void AddResults(unsigned count) | ||
211 | 44 | { | ||
212 | 45 | GVariantBuilder b; | ||
213 | 46 | g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); | ||
214 | 47 | GVariant *hints = g_variant_builder_end(&b); | ||
215 | 48 | |||
216 | 49 | for(unsigned i = 0; i < count; ++i) | ||
217 | 50 | { | ||
218 | 51 | dee_model_append(model_, | ||
219 | 52 | ("cat"+std::to_string(i)).c_str(), | ||
220 | 53 | ("Category "+std::to_string(i)).c_str(), | ||
221 | 54 | "gtk-apply", | ||
222 | 55 | "grid", | ||
223 | 56 | hints); | ||
224 | 57 | } | ||
225 | 58 | g_variant_unref(hints); | ||
226 | 59 | } | ||
227 | 60 | |||
228 | 61 | glib::Object<DeeModel> model_; | ||
229 | 62 | }; | ||
230 | 63 | |||
231 | 64 | } | ||
232 | 65 | } | ||
233 | 66 | |||
234 | 67 | #endif // _UNITY_MOCK_CATEGORIES_H | ||
235 | 0 | \ No newline at end of file | 68 | \ No newline at end of file |
236 | 1 | 69 | ||
237 | === modified file 'tests/autopilot/unity/emulators/dash.py' | |||
238 | --- tests/autopilot/unity/emulators/dash.py 2013-02-21 10:03:21 +0000 | |||
239 | +++ tests/autopilot/unity/emulators/dash.py 2013-03-21 14:03:22 +0000 | |||
240 | @@ -9,7 +9,8 @@ | |||
241 | 9 | 9 | ||
242 | 10 | from __future__ import absolute_import | 10 | from __future__ import absolute_import |
243 | 11 | 11 | ||
245 | 12 | from autopilot.emulators.X11 import Keyboard, Mouse | 12 | |
246 | 13 | from autopilot.emulators.input import get_keyboard, get_mouse | ||
247 | 13 | from autopilot.keybindings import KeybindingsHelper | 14 | from autopilot.keybindings import KeybindingsHelper |
248 | 14 | from testtools.matchers import GreaterThan | 15 | from testtools.matchers import GreaterThan |
249 | 15 | 16 | ||
250 | @@ -23,6 +24,11 @@ | |||
251 | 23 | class DashController(UnityIntrospectionObject, KeybindingsHelper): | 24 | class DashController(UnityIntrospectionObject, KeybindingsHelper): |
252 | 24 | """The main dash controller object.""" | 25 | """The main dash controller object.""" |
253 | 25 | 26 | ||
254 | 27 | def __init__(self, *args, **kwargs): | ||
255 | 28 | super(DashController, self).__init__(*args, **kwargs) | ||
256 | 29 | self.keyboard = get_keyboard() | ||
257 | 30 | self.mouse = get_mouse() | ||
258 | 31 | |||
259 | 26 | def get_dash_view(self): | 32 | def get_dash_view(self): |
260 | 27 | """Get the dash view that's attached to this controller.""" | 33 | """Get the dash view that's attached to this controller.""" |
261 | 28 | return self.get_children_by_type(DashView)[0] | 34 | return self.get_children_by_type(DashView)[0] |
262 | @@ -89,41 +95,41 @@ | |||
263 | 89 | Assumes dash is already visible, and search bar has keyboard focus. | 95 | Assumes dash is already visible, and search bar has keyboard focus. |
264 | 90 | 96 | ||
265 | 91 | """ | 97 | """ |
268 | 92 | self._keyboard.press_and_release("Ctrl+a") | 98 | self.keyboard.press_and_release("Ctrl+a") |
269 | 93 | self._keyboard.press_and_release("Delete") | 99 | self.keyboard.press_and_release("Delete") |
270 | 94 | self.search_string.wait_for("") | 100 | self.search_string.wait_for("") |
271 | 95 | 101 | ||
303 | 96 | def reveal_application_lens(self, clear_search=True): | 102 | def reveal_application_scope(self, clear_search=True): |
304 | 97 | """Reveal the application lense.""" | 103 | """Reveal the application scope.""" |
305 | 98 | logger.debug("Revealing application lens with Super+a.") | 104 | logger.debug("Revealing application scope with Super+a.") |
306 | 99 | self._reveal_lens("lens_reveal/apps", clear_search) | 105 | self._reveal_scope("lens_reveal/apps", clear_search) |
307 | 100 | return self.view.get_lensview_by_name("applications.lens") | 106 | return self.view.get_scopeview_by_name("applications.scope") |
308 | 101 | 107 | ||
309 | 102 | def reveal_music_lens(self, clear_search=True): | 108 | def reveal_music_scope(self, clear_search=True): |
310 | 103 | """Reveal the music lense.""" | 109 | """Reveal the music scope.""" |
311 | 104 | logger.debug("Revealing music lens with Super+m.") | 110 | logger.debug("Revealing music scope with Super+m.") |
312 | 105 | self._reveal_lens("lens_reveal/music", clear_search) | 111 | self._reveal_scope("lens_reveal/music", clear_search) |
313 | 106 | return self.view.get_lensview_by_name("music.lens") | 112 | return self.view.get_scopeview_by_name("music.scope") |
314 | 107 | 113 | ||
315 | 108 | def reveal_file_lens(self, clear_search=True): | 114 | def reveal_file_scope(self, clear_search=True): |
316 | 109 | """Reveal the file lense.""" | 115 | """Reveal the file scope.""" |
317 | 110 | logger.debug("Revealing file lens with Super+f.") | 116 | logger.debug("Revealing file scope with Super+f.") |
318 | 111 | self._reveal_lens("lens_reveal/files", clear_search) | 117 | self._reveal_scope("lens_reveal/files", clear_search) |
319 | 112 | return self.view.get_lensview_by_name("files.lens") | 118 | return self.view.get_scopeview_by_name("files.scope") |
320 | 113 | 119 | ||
321 | 114 | def reveal_video_lens(self, clear_search=True): | 120 | def reveal_video_scope(self, clear_search=True): |
322 | 115 | """Reveal the video lens""" | 121 | """Reveal the video scope""" |
323 | 116 | logger.debug("Revealing video lens with Super+v.") | 122 | logger.debug("Revealing video scope with Super+v.") |
324 | 117 | self._reveal_lens("lens_reveal/video", clear_search) | 123 | self._reveal_scope("lens_reveal/video", clear_search) |
325 | 118 | return self.view.get_lensview_by_name("video.lens") | 124 | return self.view.get_scopeview_by_name("video.scope") |
326 | 119 | 125 | ||
327 | 120 | def reveal_command_lens(self, clear_search=True): | 126 | def reveal_command_scope(self, clear_search=True): |
328 | 121 | """Reveal the 'run command' lens.""" | 127 | """Reveal the 'run command' scope.""" |
329 | 122 | logger.debug("Revealing command lens with Alt+F2.") | 128 | logger.debug("Revealing command scope with Alt+F2.") |
330 | 123 | self._reveal_lens("lens_reveal/command", clear_search) | 129 | self._reveal_scope("lens_reveal/command", clear_search) |
331 | 124 | return self.view.get_lensview_by_name("commands.lens") | 130 | return self.view.get_scopeview_by_name("commands.scope") |
332 | 125 | 131 | ||
333 | 126 | def _reveal_lens(self, binding_name, clear_search): | 132 | def _reveal_scope(self, binding_name, clear_search): |
334 | 127 | self.keybinding_hold(binding_name) | 133 | self.keybinding_hold(binding_name) |
335 | 128 | self.keybinding_tap(binding_name) | 134 | self.keybinding_tap(binding_name) |
336 | 129 | self.keybinding_release(binding_name) | 135 | self.keybinding_release(binding_name) |
337 | @@ -132,13 +138,13 @@ | |||
338 | 132 | self.clear_search() | 138 | self.clear_search() |
339 | 133 | 139 | ||
340 | 134 | @property | 140 | @property |
343 | 135 | def active_lens(self): | 141 | def active_scope(self): |
344 | 136 | return self.view.get_lensbar().active_lens | 142 | return self.view.get_scopebar().active_scope |
345 | 137 | 143 | ||
350 | 138 | def get_current_lens(self): | 144 | def get_current_scope(self): |
351 | 139 | """Get the currently-active LensView object.""" | 145 | """Get the currently-active ScopeView object.""" |
352 | 140 | active_lens_name = self.view.get_lensbar().active_lens | 146 | active_scope_name = self.view.get_scopebar().active_scope |
353 | 141 | return self.view.get_lensview_by_name(active_lens_name) | 147 | return self.view.get_scopeview_by_name(active_scope_name) |
354 | 142 | 148 | ||
355 | 143 | @property | 149 | @property |
356 | 144 | def geometry(self): | 150 | def geometry(self): |
357 | @@ -152,16 +158,16 @@ | |||
358 | 152 | """Get the search bar attached to this dash view.""" | 158 | """Get the search bar attached to this dash view.""" |
359 | 153 | return self.get_children_by_type(SearchBar)[0] | 159 | return self.get_children_by_type(SearchBar)[0] |
360 | 154 | 160 | ||
364 | 155 | def get_lensbar(self): | 161 | def get_scopebar(self): |
365 | 156 | """Get the lensbar attached to this dash view.""" | 162 | """Get the scopebar attached to this dash view.""" |
366 | 157 | return self.get_children_by_type(LensBar)[0] | 163 | return self.get_children_by_type(ScopeBar)[0] |
367 | 158 | 164 | ||
374 | 159 | def get_lensview_by_name(self, lens_name): | 165 | def get_scopeview_by_name(self, scope_name): |
375 | 160 | """Get a LensView child object by it's name. For example, "home.lens".""" | 166 | """Get a ScopeView child object by it's name. For example, "home.scope".""" |
376 | 161 | lenses = self.get_children_by_type(LensView) | 167 | scopes = self.get_children_by_type(ScopeView) |
377 | 162 | for lens in lenses: | 168 | for scope in scopes: |
378 | 163 | if lens.name == lens_name: | 169 | if scope.name == scope_name: |
379 | 164 | return lens | 170 | return scope |
380 | 165 | 171 | ||
381 | 166 | def get_preview_container(self): | 172 | def get_preview_container(self): |
382 | 167 | """Get the preview container attached to this dash view.""" | 173 | """Get the preview container attached to this dash view.""" |
383 | @@ -175,24 +181,24 @@ | |||
384 | 175 | """The search bar for the dash view.""" | 181 | """The search bar for the dash view.""" |
385 | 176 | 182 | ||
386 | 177 | 183 | ||
389 | 178 | class LensBar(UnityIntrospectionObject): | 184 | class ScopeBar(UnityIntrospectionObject): |
390 | 179 | """The bar of lens icons at the bottom of the dash.""" | 185 | """The bar of scope icons at the bottom of the dash.""" |
391 | 180 | def get_icon_by_name(self, name): | 186 | def get_icon_by_name(self, name): |
394 | 181 | """Get a LensBarIcon child object by it's name. For example, 'home.lens'.""" | 187 | """Get a ScopeBarIcon child object by it's name. For example, 'home.scope'.""" |
395 | 182 | icons = self.get_children_by_type(LensBarIcon) | 188 | icons = self.get_children_by_type(ScopeBarIcon) |
396 | 183 | for icon in icons: | 189 | for icon in icons: |
397 | 184 | if icon.name == name: | 190 | if icon.name == name: |
398 | 185 | return icon | 191 | return icon |
399 | 186 | 192 | ||
406 | 187 | class LensBarIcon(UnityIntrospectionObject): | 193 | class ScopeBarIcon(UnityIntrospectionObject): |
407 | 188 | """A lens icon at the bottom of the dash.""" | 194 | """A scope icon at the bottom of the dash.""" |
408 | 189 | 195 | ||
409 | 190 | 196 | ||
410 | 191 | class LensView(UnityIntrospectionObject): | 197 | class ScopeView(UnityIntrospectionObject): |
411 | 192 | """A Lens View.""" | 198 | """A Scope View.""" |
412 | 193 | 199 | ||
413 | 194 | def get_groups(self): | 200 | def get_groups(self): |
415 | 195 | """Get a list of all groups within this lensview. May return an empty list.""" | 201 | """Get a list of all groups within this scopeview. May return an empty list.""" |
416 | 196 | groups = self.get_children_by_type(PlacesGroup) | 202 | groups = self.get_children_by_type(PlacesGroup) |
417 | 197 | return groups | 203 | return groups |
418 | 198 | 204 | ||
419 | @@ -217,11 +223,11 @@ | |||
420 | 217 | return None | 223 | return None |
421 | 218 | 224 | ||
422 | 219 | def get_num_visible_categories(self): | 225 | def get_num_visible_categories(self): |
424 | 220 | """Get the number of visible categories in this lens.""" | 226 | """Get the number of visible categories in this scope.""" |
425 | 221 | return len([c for c in self.get_children_by_type(PlacesGroup) if c.is_visible]) | 227 | return len([c for c in self.get_children_by_type(PlacesGroup) if c.is_visible]) |
426 | 222 | 228 | ||
427 | 223 | def get_filterbar(self): | 229 | def get_filterbar(self): |
429 | 224 | """Get the filter bar for the current lense, or None if it doesn't have one.""" | 230 | """Get the filter bar for the current scope, or None if it doesn't have one.""" |
430 | 225 | bars = self.get_children_by_type(FilterBar) | 231 | bars = self.get_children_by_type(FilterBar) |
431 | 226 | if bars: | 232 | if bars: |
432 | 227 | return bars[0] | 233 | return bars[0] |
433 | @@ -229,7 +235,7 @@ | |||
434 | 229 | 235 | ||
435 | 230 | 236 | ||
436 | 231 | class PlacesGroup(UnityIntrospectionObject): | 237 | class PlacesGroup(UnityIntrospectionObject): |
438 | 232 | """A category in the lense view.""" | 238 | """A category in the scope view.""" |
439 | 233 | 239 | ||
440 | 234 | def get_results(self): | 240 | def get_results(self): |
441 | 235 | """Get a list of all results within this category. May return an empty list.""" | 241 | """Get a list of all results within this category. May return an empty list.""" |
442 | @@ -244,31 +250,36 @@ | |||
443 | 244 | class Result(UnityIntrospectionObject): | 250 | class Result(UnityIntrospectionObject): |
444 | 245 | """A single result in the dash.""" | 251 | """A single result in the dash.""" |
445 | 246 | 252 | ||
446 | 253 | def __init__(self, *args, **kwargs): | ||
447 | 254 | super(Result, self).__init__(*args, **kwargs) | ||
448 | 255 | self.mouse = get_mouse() | ||
449 | 256 | self.keyboard = get_keyboard() | ||
450 | 257 | |||
451 | 247 | def activate(self): | 258 | def activate(self): |
452 | 248 | tx = self.x + (self.width / 2) | 259 | tx = self.x + (self.width / 2) |
453 | 249 | ty = self.y + (self.height / 2) | 260 | ty = self.y + (self.height / 2) |
457 | 250 | m = Mouse() | 261 | self.mouse.move(tx, ty) |
458 | 251 | m.move(tx, ty) | 262 | self.mouse.click(1) |
456 | 252 | m.click(1) | ||
459 | 253 | 263 | ||
460 | 254 | def preview(self): | 264 | def preview(self): |
461 | 255 | tx = self.x + (self.width / 2) | 265 | tx = self.x + (self.width / 2) |
462 | 256 | ty = self.y + (self.height / 2) | 266 | ty = self.y + (self.height / 2) |
466 | 257 | m = Mouse() | 267 | self.mouse.move(tx, ty) |
467 | 258 | m.move(tx, ty) | 268 | self.mouse.click(3) |
465 | 259 | m.click(3) | ||
468 | 260 | 269 | ||
469 | 261 | def preview_key(self): | 270 | def preview_key(self): |
470 | 262 | tx = self.x + (self.width / 2) | 271 | tx = self.x + (self.width / 2) |
471 | 263 | ty = self.y + (self.height / 2) | 272 | ty = self.y + (self.height / 2) |
474 | 264 | m = Mouse() | 273 | self.mouse.move(tx, ty) |
473 | 265 | m.move(tx, ty) | ||
475 | 266 | 274 | ||
478 | 267 | k = Keyboard() | 275 | self.keyboard.press_and_release('Menu') |
477 | 268 | k.press_and_release('Menu') | ||
479 | 269 | 276 | ||
480 | 270 | class FilterBar(UnityIntrospectionObject): | 277 | class FilterBar(UnityIntrospectionObject): |
482 | 271 | """A filterbar, as shown inside a lens.""" | 278 | """A filterbar, as shown inside a scope.""" |
483 | 279 | |||
484 | 280 | def __init__(self, *args, **kwargs): | ||
485 | 281 | super(FilterBar, self).__init__(*args, **kwargs) | ||
486 | 282 | self.mouse = get_mouse() | ||
487 | 272 | 283 | ||
488 | 273 | def get_num_filters(self): | 284 | def get_num_filters(self): |
489 | 274 | """Get the number of filters in this filter bar.""" | 285 | """Get the number of filters in this filter bar.""" |
490 | @@ -285,7 +296,7 @@ | |||
491 | 285 | 296 | ||
492 | 286 | @property | 297 | @property |
493 | 287 | def expanded(self): | 298 | def expanded(self): |
495 | 288 | """Return True if the filterbar on this lens is expanded, False otherwise. | 299 | """Return True if the filterbar on this scope is expanded, False otherwise. |
496 | 289 | """ | 300 | """ |
497 | 290 | searchbar = self._get_searchbar() | 301 | searchbar = self._get_searchbar() |
498 | 291 | return searchbar.showing_filters | 302 | return searchbar.showing_filters |
499 | @@ -296,9 +307,8 @@ | |||
500 | 296 | searchbar = self._get_searchbar() | 307 | searchbar = self._get_searchbar() |
501 | 297 | tx = searchbar.filter_label_x + (searchbar.filter_label_width / 2) | 308 | tx = searchbar.filter_label_x + (searchbar.filter_label_width / 2) |
502 | 298 | ty = searchbar.filter_label_y + (searchbar.filter_label_height / 2) | 309 | ty = searchbar.filter_label_y + (searchbar.filter_label_height / 2) |
506 | 299 | m = Mouse() | 310 | self.mouse.move(tx, ty) |
507 | 300 | m.move(tx, ty) | 311 | self.mouse.click() |
505 | 301 | m.click() | ||
508 | 302 | self.expanded.wait_for(True) | 312 | self.expanded.wait_for(True) |
509 | 303 | 313 | ||
510 | 304 | def ensure_collapsed(self): | 314 | def ensure_collapsed(self): |
511 | @@ -307,9 +317,8 @@ | |||
512 | 307 | searchbar = self._get_searchbar() | 317 | searchbar = self._get_searchbar() |
513 | 308 | tx = searchbar.filter_label_x + (searchbar.filter_label_width / 2) | 318 | tx = searchbar.filter_label_x + (searchbar.filter_label_width / 2) |
514 | 309 | ty = searchbar.filter_label_y + (searchbar.filter_label_height / 2) | 319 | ty = searchbar.filter_label_y + (searchbar.filter_label_height / 2) |
518 | 310 | m = Mouse() | 320 | self.mouse.move(tx, ty) |
519 | 311 | m.move(tx, ty) | 321 | self.mouse.click() |
517 | 312 | m.click() | ||
520 | 313 | self.expanded.wait_for(False) | 322 | self.expanded.wait_for(False) |
521 | 314 | 323 | ||
522 | 315 | def _get_searchbar(self): | 324 | def _get_searchbar(self): |
523 | @@ -327,14 +336,17 @@ | |||
524 | 327 | class FilterExpanderLabel(UnityIntrospectionObject): | 336 | class FilterExpanderLabel(UnityIntrospectionObject): |
525 | 328 | """A label that expands into a filter within a filter bar.""" | 337 | """A label that expands into a filter within a filter bar.""" |
526 | 329 | 338 | ||
527 | 339 | def __init__(self, *args, **kwargs): | ||
528 | 340 | super(FilterExpanderLabel, self).__init__(*args, **kwargs) | ||
529 | 341 | self.mouse = get_mouse() | ||
530 | 342 | |||
531 | 330 | def ensure_expanded(self): | 343 | def ensure_expanded(self): |
532 | 331 | """Expand the filter expander label, if it's not already""" | 344 | """Expand the filter expander label, if it's not already""" |
533 | 332 | if not self.expanded: | 345 | if not self.expanded: |
534 | 333 | tx = self.x + self.width / 2 | 346 | tx = self.x + self.width / 2 |
535 | 334 | ty = self.y + self.height / 2 | 347 | ty = self.y + self.height / 2 |
539 | 335 | m = Mouse() | 348 | self.mouse.move(tx, ty) |
540 | 336 | m.move(tx, ty) | 349 | self.mouse.click() |
538 | 337 | m.click() | ||
541 | 338 | self.expanded.wait_for(True) | 350 | self.expanded.wait_for(True) |
542 | 339 | 351 | ||
543 | 340 | def ensure_collapsed(self): | 352 | def ensure_collapsed(self): |
544 | @@ -342,9 +354,8 @@ | |||
545 | 342 | if self.expanded: | 354 | if self.expanded: |
546 | 343 | tx = self.x + self.width / 2 | 355 | tx = self.x + self.width / 2 |
547 | 344 | ty = self.y + self.height / 2 | 356 | ty = self.y + self.height / 2 |
551 | 345 | m = Mouse() | 357 | self.mouse.move(tx, ty) |
552 | 346 | m.move(tx, ty) | 358 | self.mouse.click() |
550 | 347 | m.click() | ||
553 | 348 | self.expanded.wait_for(False) | 359 | self.expanded.wait_for(False) |
554 | 349 | 360 | ||
555 | 350 | 361 | ||
556 | @@ -357,7 +368,7 @@ | |||
557 | 357 | 368 | ||
558 | 358 | 369 | ||
559 | 359 | class Preview(UnityIntrospectionObject): | 370 | class Preview(UnityIntrospectionObject): |
561 | 360 | """A preview of a dash lens result.""" | 371 | """A preview of a dash scope result.""" |
562 | 361 | 372 | ||
563 | 362 | def get_num_actions(self): | 373 | def get_num_actions(self): |
564 | 363 | """Get the number of actions for the preview.""" | 374 | """Get the number of actions for the preview.""" |
565 | @@ -378,9 +389,8 @@ | |||
566 | 378 | if action: | 389 | if action: |
567 | 379 | tx = action.x + (searchbar.width / 2) | 390 | tx = action.x + (searchbar.width / 2) |
568 | 380 | ty = action.y + (searchbar.height / 2) | 391 | ty = action.y + (searchbar.height / 2) |
572 | 381 | m = Mouse() | 392 | self.mouse.move(tx, ty) |
573 | 382 | m.move(tx, ty) | 393 | self.mouse.click() |
571 | 383 | m.click() | ||
574 | 384 | 394 | ||
575 | 385 | @property | 395 | @property |
576 | 386 | def cover_art(self): | 396 | def cover_art(self): |
577 | @@ -404,16 +414,16 @@ | |||
578 | 404 | 414 | ||
579 | 405 | 415 | ||
580 | 406 | class ApplicationPreview(Preview): | 416 | class ApplicationPreview(Preview): |
582 | 407 | """A application preview of a dash lens result.""" | 417 | """A application preview of a dash scope result.""" |
583 | 408 | 418 | ||
584 | 409 | class GenericPreview(Preview): | 419 | class GenericPreview(Preview): |
586 | 410 | """A generic preview of a dash lens result.""" | 420 | """A generic preview of a dash scope result.""" |
587 | 411 | 421 | ||
588 | 412 | class MusicPreview(Preview): | 422 | class MusicPreview(Preview): |
590 | 413 | """A music preview of a dash lens result.""" | 423 | """A music preview of a dash scope result.""" |
591 | 414 | 424 | ||
592 | 415 | class MoviePreview(Preview): | 425 | class MoviePreview(Preview): |
594 | 416 | """A movie preview of a dash lens result.""" | 426 | """A movie preview of a dash scope result.""" |
595 | 417 | 427 | ||
596 | 418 | class PreviewContent(UnityIntrospectionObject): | 428 | class PreviewContent(UnityIntrospectionObject): |
597 | 419 | """A preview content layout for the dash previews.""" | 429 | """A preview content layout for the dash previews.""" |
598 | @@ -428,6 +438,10 @@ | |||
599 | 428 | class PreviewContainer(UnityIntrospectionObject): | 438 | class PreviewContainer(UnityIntrospectionObject): |
600 | 429 | """A container view for the main dash preview widget.""" | 439 | """A container view for the main dash preview widget.""" |
601 | 430 | 440 | ||
602 | 441 | def __init__(self, *args, **kwargs): | ||
603 | 442 | super(PreviewContainer, self).__init__(*args, **kwargs) | ||
604 | 443 | self.mouse = get_mouse() | ||
605 | 444 | |||
606 | 431 | @property | 445 | @property |
607 | 432 | def content(self): | 446 | def content(self): |
608 | 433 | return self.get_content() | 447 | return self.get_content() |
609 | @@ -463,14 +477,13 @@ | |||
610 | 463 | 477 | ||
611 | 464 | tx = navigator.button_x + (navigator.button_width / 2) | 478 | tx = navigator.button_x + (navigator.button_width / 2) |
612 | 465 | ty = navigator.button_y + (navigator.button_height / 2) | 479 | ty = navigator.button_y + (navigator.button_height / 2) |
615 | 466 | m = Mouse() | 480 | self.mouse.move(tx, ty) |
614 | 467 | m.move(tx, ty) | ||
616 | 468 | 481 | ||
617 | 469 | old_preview_initiate_count = self.preview_initiate_count | 482 | old_preview_initiate_count = self.preview_initiate_count |
618 | 470 | 483 | ||
619 | 471 | for i in range(count): | 484 | for i in range(count): |
620 | 472 | self.navigate_left_enabled.wait_for(True) | 485 | self.navigate_left_enabled.wait_for(True) |
622 | 473 | m.click() | 486 | self.mouse.click() |
623 | 474 | self.preview_initiate_count.wait_for(GreaterThan(old_preview_initiate_count)) | 487 | self.preview_initiate_count.wait_for(GreaterThan(old_preview_initiate_count)) |
624 | 475 | old_preview_initiate_count = self.preview_initiate_count | 488 | old_preview_initiate_count = self.preview_initiate_count |
625 | 476 | 489 | ||
626 | @@ -480,14 +493,13 @@ | |||
627 | 480 | 493 | ||
628 | 481 | tx = navigator.button_x + (navigator.button_width / 2) | 494 | tx = navigator.button_x + (navigator.button_width / 2) |
629 | 482 | ty = navigator.button_y + (navigator.button_height / 2) | 495 | ty = navigator.button_y + (navigator.button_height / 2) |
632 | 483 | m = Mouse() | 496 | self.mouse.move(tx, ty) |
631 | 484 | m.move(tx, ty) | ||
633 | 485 | 497 | ||
634 | 486 | old_preview_initiate_count = self.preview_initiate_count | 498 | old_preview_initiate_count = self.preview_initiate_count |
635 | 487 | 499 | ||
636 | 488 | for i in range(count): | 500 | for i in range(count): |
637 | 489 | self.navigate_right_enabled.wait_for(True) | 501 | self.navigate_right_enabled.wait_for(True) |
639 | 490 | m.click() | 502 | self.mouse.click() |
640 | 491 | self.preview_initiate_count.wait_for(GreaterThan(old_preview_initiate_count)) | 503 | self.preview_initiate_count.wait_for(GreaterThan(old_preview_initiate_count)) |
641 | 492 | old_preview_initiate_count = self.preview_initiate_count | 504 | old_preview_initiate_count = self.preview_initiate_count |
642 | 493 | 505 | ||
643 | 494 | 506 | ||
644 | === modified file 'tests/autopilot/unity/emulators/hud.py' | |||
645 | --- tests/autopilot/unity/emulators/hud.py 2013-02-04 19:54:47 +0000 | |||
646 | +++ tests/autopilot/unity/emulators/hud.py 2013-03-21 14:03:22 +0000 | |||
647 | @@ -9,7 +9,7 @@ | |||
648 | 9 | 9 | ||
649 | 10 | from __future__ import absolute_import | 10 | from __future__ import absolute_import |
650 | 11 | 11 | ||
652 | 12 | from autopilot.emulators.X11 import Keyboard | 12 | from autopilot.emulators.input import get_keyboard |
653 | 13 | from autopilot.keybindings import KeybindingsHelper | 13 | from autopilot.keybindings import KeybindingsHelper |
654 | 14 | from HTMLParser import HTMLParser | 14 | from HTMLParser import HTMLParser |
655 | 15 | import re | 15 | import re |
656 | @@ -24,7 +24,7 @@ | |||
657 | 24 | 24 | ||
658 | 25 | def __init__(self, *args, **kwargs): | 25 | def __init__(self, *args, **kwargs): |
659 | 26 | super(HudController, self).__init__(*args, **kwargs) | 26 | super(HudController, self).__init__(*args, **kwargs) |
661 | 27 | self.keyboard = Keyboard() | 27 | self.keyboard = get_keyboard() |
662 | 28 | 28 | ||
663 | 29 | def get_hud_view(self): | 29 | def get_hud_view(self): |
664 | 30 | views = self.get_children_by_type(HudView) | 30 | views = self.get_children_by_type(HudView) |
665 | 31 | 31 | ||
666 | === modified file 'tests/autopilot/unity/emulators/launcher.py' | |||
667 | --- tests/autopilot/unity/emulators/launcher.py 2013-03-18 19:58:05 +0000 | |||
668 | +++ tests/autopilot/unity/emulators/launcher.py 2013-03-21 14:03:22 +0000 | |||
669 | @@ -9,7 +9,8 @@ | |||
670 | 9 | 9 | ||
671 | 10 | from __future__ import absolute_import | 10 | from __future__ import absolute_import |
672 | 11 | 11 | ||
674 | 12 | from autopilot.emulators.X11 import Mouse, ScreenGeometry | 12 | from autopilot.emulators.input import get_mouse |
675 | 13 | from autopilot.emulators.X11 import ScreenGeometry | ||
676 | 13 | from autopilot.keybindings import KeybindingsHelper | 14 | from autopilot.keybindings import KeybindingsHelper |
677 | 14 | from autopilot.utilities import get_compiz_option | 15 | from autopilot.utilities import get_compiz_option |
678 | 15 | import logging | 16 | import logging |
679 | @@ -67,7 +68,7 @@ | |||
680 | 67 | self.in_keynav_mode = False | 68 | self.in_keynav_mode = False |
681 | 68 | self.in_switcher_mode = False | 69 | self.in_switcher_mode = False |
682 | 69 | 70 | ||
684 | 70 | self._mouse = Mouse() | 71 | self._mouse = get_mouse() |
685 | 71 | self._screen = ScreenGeometry() | 72 | self._screen = ScreenGeometry() |
686 | 72 | 73 | ||
687 | 73 | def _perform_key_nav_binding(self, keybinding): | 74 | def _perform_key_nav_binding(self, keybinding): |
688 | 74 | 75 | ||
689 | === modified file 'tests/autopilot/unity/emulators/panel.py' | |||
690 | --- tests/autopilot/unity/emulators/panel.py 2012-12-18 11:27:43 +0000 | |||
691 | +++ tests/autopilot/unity/emulators/panel.py 2013-03-21 14:03:22 +0000 | |||
692 | @@ -12,7 +12,7 @@ | |||
693 | 12 | import logging | 12 | import logging |
694 | 13 | from time import sleep | 13 | from time import sleep |
695 | 14 | 14 | ||
697 | 15 | from autopilot.emulators.X11 import Mouse | 15 | from autopilot.emulators.input import get_mouse |
698 | 16 | from autopilot.keybindings import KeybindingsHelper | 16 | from autopilot.keybindings import KeybindingsHelper |
699 | 17 | 17 | ||
700 | 18 | from unity.emulators import UnityIntrospectionObject | 18 | from unity.emulators import UnityIntrospectionObject |
701 | @@ -53,7 +53,7 @@ | |||
702 | 53 | 53 | ||
703 | 54 | def __init__(self, *args, **kwargs): | 54 | def __init__(self, *args, **kwargs): |
704 | 55 | super(UnityPanel, self).__init__(*args, **kwargs) | 55 | super(UnityPanel, self).__init__(*args, **kwargs) |
706 | 56 | self._mouse = Mouse() | 56 | self._mouse = get_mouse() |
707 | 57 | 57 | ||
708 | 58 | def __get_menu_view(self): | 58 | def __get_menu_view(self): |
709 | 59 | """Return the menu view.""" | 59 | """Return the menu view.""" |
710 | @@ -261,7 +261,7 @@ | |||
711 | 261 | 261 | ||
712 | 262 | def __init__(self, *args, **kwargs): | 262 | def __init__(self, *args, **kwargs): |
713 | 263 | super(WindowButton, self).__init__(*args, **kwargs) | 263 | super(WindowButton, self).__init__(*args, **kwargs) |
715 | 264 | self._mouse = Mouse() | 264 | self._mouse = get_mouse() |
716 | 265 | 265 | ||
717 | 266 | def mouse_move_to(self): | 266 | def mouse_move_to(self): |
718 | 267 | target_x = self.x + self.width / 2 | 267 | target_x = self.x + self.width / 2 |
719 | @@ -319,7 +319,7 @@ | |||
720 | 319 | 319 | ||
721 | 320 | def __init__(self, *args, **kwargs): | 320 | def __init__(self, *args, **kwargs): |
722 | 321 | super(IndicatorEntry, self).__init__(*args, **kwargs) | 321 | super(IndicatorEntry, self).__init__(*args, **kwargs) |
724 | 322 | self._mouse = Mouse() | 322 | self._mouse = get_mouse() |
725 | 323 | 323 | ||
726 | 324 | def mouse_move_to(self): | 324 | def mouse_move_to(self): |
727 | 325 | target_x = self.x + self.width / 2 | 325 | target_x = self.x + self.width / 2 |
728 | 326 | 326 | ||
729 | === modified file 'tests/autopilot/unity/emulators/quicklist.py' | |||
730 | --- tests/autopilot/unity/emulators/quicklist.py 2012-08-01 23:35:56 +0000 | |||
731 | +++ tests/autopilot/unity/emulators/quicklist.py 2013-03-21 14:03:22 +0000 | |||
732 | @@ -11,7 +11,7 @@ | |||
733 | 11 | 11 | ||
734 | 12 | import logging | 12 | import logging |
735 | 13 | 13 | ||
737 | 14 | from autopilot.emulators.X11 import Mouse | 14 | from autopilot.emulators.input import get_mouse |
738 | 15 | 15 | ||
739 | 16 | from unity.emulators import UnityIntrospectionObject | 16 | from unity.emulators import UnityIntrospectionObject |
740 | 17 | 17 | ||
741 | @@ -21,6 +21,10 @@ | |||
742 | 21 | class Quicklist(UnityIntrospectionObject): | 21 | class Quicklist(UnityIntrospectionObject): |
743 | 22 | """Represents a quicklist.""" | 22 | """Represents a quicklist.""" |
744 | 23 | 23 | ||
745 | 24 | def __init__(self, *args, **kwargs): | ||
746 | 25 | super(Quicklist, self).__init__(*args, **kwargs) | ||
747 | 26 | self._mouse = get_mouse() | ||
748 | 27 | |||
749 | 24 | @property | 28 | @property |
750 | 25 | def items(self): | 29 | def items(self): |
751 | 26 | """Individual items in the quicklist.""" | 30 | """Individual items in the quicklist.""" |
752 | @@ -56,7 +60,7 @@ | |||
753 | 56 | logger.debug("Moving mouse outside the quicklist %r", self) | 60 | logger.debug("Moving mouse outside the quicklist %r", self) |
754 | 57 | target_x = self.x + self.width + 10 | 61 | target_x = self.x + self.width + 10 |
755 | 58 | target_y = self.y + self.height / 2 | 62 | target_y = self.y + self.height / 2 |
757 | 59 | Mouse().move(target_x, target_y, animate=False) | 63 | self._mouse.move(target_x, target_y, animate=False) |
758 | 60 | 64 | ||
759 | 61 | @property | 65 | @property |
760 | 62 | def selected_item(self): | 66 | def selected_item(self): |
761 | @@ -75,7 +79,7 @@ | |||
762 | 75 | 79 | ||
763 | 76 | def __init__(self, *args, **kwargs): | 80 | def __init__(self, *args, **kwargs): |
764 | 77 | super(QuicklistMenuItem, self).__init__(*args, **kwargs) | 81 | super(QuicklistMenuItem, self).__init__(*args, **kwargs) |
766 | 78 | self._mouse = Mouse() | 82 | self._mouse = get_mouse() |
767 | 79 | 83 | ||
768 | 80 | @property | 84 | @property |
769 | 81 | def geometry(self): | 85 | def geometry(self): |
770 | 82 | 86 | ||
771 | === modified file 'tests/autopilot/unity/emulators/switcher.py' | |||
772 | --- tests/autopilot/unity/emulators/switcher.py 2013-02-04 20:28:02 +0000 | |||
773 | +++ tests/autopilot/unity/emulators/switcher.py 2013-03-21 14:03:22 +0000 | |||
774 | @@ -11,7 +11,7 @@ | |||
775 | 11 | 11 | ||
776 | 12 | import logging | 12 | import logging |
777 | 13 | 13 | ||
779 | 14 | from autopilot.emulators.X11 import Mouse | 14 | from autopilot.emulators.input import get_mouse |
780 | 15 | from autopilot.keybindings import KeybindingsHelper | 15 | from autopilot.keybindings import KeybindingsHelper |
781 | 16 | 16 | ||
782 | 17 | from unity.emulators import UnityIntrospectionObject | 17 | from unity.emulators import UnityIntrospectionObject |
783 | @@ -45,7 +45,7 @@ | |||
784 | 45 | 45 | ||
785 | 46 | def __init__(self, *args, **kwargs): | 46 | def __init__(self, *args, **kwargs): |
786 | 47 | super(SwitcherController, self).__init__(*args, **kwargs) | 47 | super(SwitcherController, self).__init__(*args, **kwargs) |
788 | 48 | self._mouse = Mouse() | 48 | self._mouse = get_mouse() |
789 | 49 | 49 | ||
790 | 50 | def get_switcher_view(self): | 50 | def get_switcher_view(self): |
791 | 51 | views = self.get_children_by_type(SwitcherView) | 51 | views = self.get_children_by_type(SwitcherView) |
792 | 52 | 52 | ||
793 | === modified file 'tests/autopilot/unity/tests/test_command_lens.py' | |||
794 | --- tests/autopilot/unity/tests/test_command_lens.py 2013-02-21 10:03:21 +0000 | |||
795 | +++ tests/autopilot/unity/tests/test_command_lens.py 2013-03-21 14:03:22 +0000 | |||
796 | @@ -16,47 +16,47 @@ | |||
797 | 16 | 16 | ||
798 | 17 | import gettext | 17 | import gettext |
799 | 18 | 18 | ||
802 | 19 | class CommandLensSearchTests(UnityTestCase): | 19 | class CommandScopeSearchTests(UnityTestCase): |
803 | 20 | """Test the command lense search bahavior.""" | 20 | """Test the command scope search bahavior.""" |
804 | 21 | 21 | ||
805 | 22 | def setUp(self): | 22 | def setUp(self): |
808 | 23 | super(CommandLensSearchTests, self).setUp() | 23 | super(CommandScopeSearchTests, self).setUp() |
809 | 24 | gettext.install("unity-lens-applications") | 24 | gettext.install("unity-scope-applications") |
810 | 25 | 25 | ||
811 | 26 | def tearDown(self): | 26 | def tearDown(self): |
812 | 27 | self.unity.dash.ensure_hidden() | 27 | self.unity.dash.ensure_hidden() |
814 | 28 | super(CommandLensSearchTests, self).tearDown() | 28 | super(CommandScopeSearchTests, self).tearDown() |
815 | 29 | 29 | ||
816 | 30 | def test_no_results(self): | 30 | def test_no_results(self): |
817 | 31 | """An empty string should get no results.""" | 31 | """An empty string should get no results.""" |
820 | 32 | self.unity.dash.reveal_command_lens() | 32 | self.unity.dash.reveal_command_scope() |
821 | 33 | command_lens = self.unity.dash.get_current_lens() | 33 | command_scope = self.unity.dash.get_current_scope() |
822 | 34 | 34 | ||
823 | 35 | if self.unity.dash.search_string != "": | 35 | if self.unity.dash.search_string != "": |
824 | 36 | self.keyboard.press_and_release("Delete") | 36 | self.keyboard.press_and_release("Delete") |
825 | 37 | 37 | ||
826 | 38 | self.assertThat(self.unity.dash.search_string, Eventually(Equals(""))) | 38 | self.assertThat(self.unity.dash.search_string, Eventually(Equals(""))) |
828 | 39 | results_category = command_lens.get_category_by_name(_("Results")) | 39 | results_category = command_scope.get_category_by_name(_("Results")) |
829 | 40 | self.assertThat(results_category.is_visible, Eventually(Equals(False))) | 40 | self.assertThat(results_category.is_visible, Eventually(Equals(False))) |
830 | 41 | 41 | ||
831 | 42 | def test_results_category_appears(self): | 42 | def test_results_category_appears(self): |
832 | 43 | """Results category must appear when there are some results.""" | 43 | """Results category must appear when there are some results.""" |
835 | 44 | self.unity.dash.reveal_command_lens() | 44 | self.unity.dash.reveal_command_scope() |
836 | 45 | command_lens = self.unity.dash.get_current_lens() | 45 | command_scope = self.unity.dash.get_current_scope() |
837 | 46 | # lots of apps start with 'a'... | 46 | # lots of apps start with 'a'... |
838 | 47 | self.keyboard.type("a") | 47 | self.keyboard.type("a") |
839 | 48 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("a"))) | 48 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("a"))) |
841 | 49 | results_category = command_lens.get_category_by_name(_("Results")) | 49 | results_category = command_scope.get_category_by_name(_("Results")) |
842 | 50 | self.assertThat(results_category.is_visible, Eventually(Equals(True))) | 50 | self.assertThat(results_category.is_visible, Eventually(Equals(True))) |
843 | 51 | 51 | ||
844 | 52 | def test_result_category_actually_contains_results(self): | 52 | def test_result_category_actually_contains_results(self): |
845 | 53 | """With a search string of 'a', the results category must contain some results.""" | 53 | """With a search string of 'a', the results category must contain some results.""" |
848 | 54 | self.unity.dash.reveal_command_lens() | 54 | self.unity.dash.reveal_command_scope() |
849 | 55 | command_lens = self.unity.dash.get_current_lens() | 55 | command_scope = self.unity.dash.get_current_scope() |
850 | 56 | # lots of apps start with 'a'... | 56 | # lots of apps start with 'a'... |
851 | 57 | self.keyboard.type("a") | 57 | self.keyboard.type("a") |
852 | 58 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("a"))) | 58 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("a"))) |
854 | 59 | results_category = command_lens.get_category_by_name(_("Results")) | 59 | results_category = command_scope.get_category_by_name(_("Results")) |
855 | 60 | results = results_category.get_results() | 60 | results = results_category.get_results() |
856 | 61 | self.assertTrue(results) | 61 | self.assertTrue(results) |
857 | 62 | 62 | ||
858 | @@ -66,7 +66,7 @@ | |||
859 | 66 | self.close_all_app("Text Editor") | 66 | self.close_all_app("Text Editor") |
860 | 67 | sleep(1) | 67 | sleep(1) |
861 | 68 | 68 | ||
863 | 69 | self.unity.dash.reveal_command_lens() | 69 | self.unity.dash.reveal_command_scope() |
864 | 70 | self.keyboard.type("g") | 70 | self.keyboard.type("g") |
865 | 71 | sleep(1) | 71 | sleep(1) |
866 | 72 | self.keyboard.type("edit", 0.1) | 72 | self.keyboard.type("edit", 0.1) |
867 | @@ -76,13 +76,13 @@ | |||
868 | 76 | self.assertTrue(app_found) | 76 | self.assertTrue(app_found) |
869 | 77 | 77 | ||
870 | 78 | def test_ctrl_tab_switching(self): | 78 | def test_ctrl_tab_switching(self): |
875 | 79 | """Pressing Ctrl+Tab after launching command lens must switch to Home lens.""" | 79 | """Pressing Ctrl+Tab after launching command scope must switch to Home scope.""" |
876 | 80 | self.unity.dash.reveal_command_lens() | 80 | self.unity.dash.reveal_command_scope() |
877 | 81 | self.keybinding("dash/lens/next") | 81 | self.keybinding("dash/scope/next") |
878 | 82 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals("home.lens"))) | 82 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals("home.scope"))) |
879 | 83 | 83 | ||
880 | 84 | def test_ctrl_shift_tab_switching(self): | 84 | def test_ctrl_shift_tab_switching(self): |
885 | 85 | """Pressing Ctrl+Shift+Tab after launching command lens must switch to Video lens.""" | 85 | """Pressing Ctrl+Shift+Tab after launching command scope must switch to Video scope.""" |
886 | 86 | self.unity.dash.reveal_command_lens() | 86 | self.unity.dash.reveal_command_scope() |
887 | 87 | self.keybinding("dash/lens/prev") | 87 | self.keybinding("dash/scope/prev") |
888 | 88 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals("video.lens"))) | 88 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals("video.scope"))) |
889 | 89 | 89 | ||
890 | === modified file 'tests/autopilot/unity/tests/test_dash.py' | |||
891 | --- tests/autopilot/unity/tests/test_dash.py 2013-03-18 17:23:42 +0000 | |||
892 | +++ tests/autopilot/unity/tests/test_dash.py 2013-03-21 14:03:22 +0000 | |||
893 | @@ -44,36 +44,36 @@ | |||
894 | 44 | self.unity.dash.ensure_visible() | 44 | self.unity.dash.ensure_visible() |
895 | 45 | self.unity.dash.ensure_hidden() | 45 | self.unity.dash.ensure_hidden() |
896 | 46 | 46 | ||
924 | 47 | def test_application_lens_shortcut(self): | 47 | def test_application_scope_shortcut(self): |
925 | 48 | """Application lense must reveal when Super+a is pressed.""" | 48 | """Application scope must reveal when Super+a is pressed.""" |
926 | 49 | self.unity.dash.reveal_application_lens() | 49 | self.unity.dash.reveal_application_scope() |
927 | 50 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('applications.lens'))) | 50 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('applications.scope'))) |
928 | 51 | 51 | ||
929 | 52 | def test_music_lens_shortcut(self): | 52 | def test_music_scope_shortcut(self): |
930 | 53 | """Music lense must reveal when Super+w is pressed.""" | 53 | """Music scope must reveal when Super+w is pressed.""" |
931 | 54 | self.unity.dash.reveal_music_lens() | 54 | self.unity.dash.reveal_music_scope() |
932 | 55 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('music.lens'))) | 55 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('music.scope'))) |
933 | 56 | 56 | ||
934 | 57 | def test_file_lens_shortcut(self): | 57 | def test_file_scope_shortcut(self): |
935 | 58 | """File lense must reveal when Super+f is pressed.""" | 58 | """File scope must reveal when Super+f is pressed.""" |
936 | 59 | self.unity.dash.reveal_file_lens() | 59 | self.unity.dash.reveal_file_scope() |
937 | 60 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('files.lens'))) | 60 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('files.scope'))) |
938 | 61 | 61 | ||
939 | 62 | def test_video_lens_shortcut(self): | 62 | def test_video_scope_shortcut(self): |
940 | 63 | """Video lens must reveal when super+v is pressed.""" | 63 | """Video scope must reveal when super+v is pressed.""" |
941 | 64 | self.unity.dash.reveal_video_lens() | 64 | self.unity.dash.reveal_video_scope() |
942 | 65 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('video.lens'))) | 65 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('video.scope'))) |
943 | 66 | 66 | ||
944 | 67 | def test_command_lens_shortcut(self): | 67 | def test_command_scope_shortcut(self): |
945 | 68 | """Run Command lens must reveat on alt+F2.""" | 68 | """Run Command scope must reveat on alt+F2.""" |
946 | 69 | self.unity.dash.reveal_command_lens() | 69 | self.unity.dash.reveal_command_scope() |
947 | 70 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('commands.lens'))) | 70 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('commands.scope'))) |
948 | 71 | 71 | ||
949 | 72 | def test_can_go_from_dash_to_command_lens(self): | 72 | def test_can_go_from_dash_to_command_scope(self): |
950 | 73 | """Switch to command lens without closing the dash.""" | 73 | """Switch to command scope without closing the dash.""" |
951 | 74 | self.unity.dash.ensure_visible() | 74 | self.unity.dash.ensure_visible() |
954 | 75 | self.unity.dash.reveal_command_lens() | 75 | self.unity.dash.reveal_command_scope() |
955 | 76 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('commands.lens'))) | 76 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('commands.scope'))) |
956 | 77 | 77 | ||
957 | 78 | def test_alt_f4_close_dash(self): | 78 | def test_alt_f4_close_dash(self): |
958 | 79 | """Dash must close on alt+F4.""" | 79 | """Dash must close on alt+F4.""" |
959 | @@ -156,23 +156,23 @@ | |||
960 | 156 | self.unity.dash.ensure_visible() | 156 | self.unity.dash.ensure_visible() |
961 | 157 | self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) | 157 | self.assertThat(self.unity.dash.visible, Eventually(Equals(True))) |
962 | 158 | 158 | ||
980 | 159 | def test_command_lens_opens_when_in_spread(self): | 159 | def test_command_scope_opens_when_in_spread(self): |
981 | 160 | """This test shows the command lens opens when in spread mode.""" | 160 | """This test shows the command scope opens when in spread mode.""" |
982 | 161 | self.start_placeholder_app() | 161 | self.start_placeholder_app() |
983 | 162 | self.keybinding("spread/start") | 162 | self.keybinding("spread/start") |
984 | 163 | self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) | 163 | self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) |
985 | 164 | 164 | ||
986 | 165 | self.unity.dash.reveal_command_lens() | 165 | self.unity.dash.reveal_command_scope() |
987 | 166 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('commands.lens'))) | 166 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('commands.scope'))) |
988 | 167 | 167 | ||
989 | 168 | def test_lens_opens_when_in_spread(self): | 168 | def test_scope_opens_when_in_spread(self): |
990 | 169 | """This test shows that any lens opens when in spread mode.""" | 169 | """This test shows that any scope opens when in spread mode.""" |
991 | 170 | self.start_placeholder_app() | 170 | self.start_placeholder_app() |
992 | 171 | self.keybinding("spread/start") | 171 | self.keybinding("spread/start") |
993 | 172 | self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) | 172 | self.assertThat(self.unity.window_manager.scale_active, Eventually(Equals(True))) |
994 | 173 | 173 | ||
995 | 174 | self.unity.dash.reveal_application_lens() | 174 | self.unity.dash.reveal_application_scope() |
996 | 175 | self.assertThat(self.unity.dash.active_lens, Eventually(Equals('applications.lens'))) | 175 | self.assertThat(self.unity.dash.active_scope, Eventually(Equals('applications.scope'))) |
997 | 176 | 176 | ||
998 | 177 | 177 | ||
999 | 178 | class DashSearchInputTests(DashTestCase): | 178 | class DashSearchInputTests(DashTestCase): |
1000 | @@ -199,28 +199,28 @@ | |||
1001 | 199 | 199 | ||
1002 | 200 | def test_multi_key(self): | 200 | def test_multi_key(self): |
1003 | 201 | """Pressing 'Multi_key' must not add any characters to the search.""" | 201 | """Pressing 'Multi_key' must not add any characters to the search.""" |
1005 | 202 | self.unity.dash.reveal_application_lens() | 202 | self.unity.dash.reveal_application_scope() |
1006 | 203 | self.keyboard.press_and_release('Multi_key') | 203 | self.keyboard.press_and_release('Multi_key') |
1007 | 204 | self.keyboard.type("o") | 204 | self.keyboard.type("o") |
1008 | 205 | self.assertSearchText("") | 205 | self.assertSearchText("") |
1009 | 206 | 206 | ||
1010 | 207 | def test_multi_key_o(self): | 207 | def test_multi_key_o(self): |
1011 | 208 | """Pressing the sequences 'Multi_key' + '^' + 'o' must produce 'ô'.""" | 208 | """Pressing the sequences 'Multi_key' + '^' + 'o' must produce 'ô'.""" |
1013 | 209 | self.unity.dash.reveal_application_lens() | 209 | self.unity.dash.reveal_application_scope() |
1014 | 210 | self.keyboard.press_and_release('Multi_key') | 210 | self.keyboard.press_and_release('Multi_key') |
1015 | 211 | self.keyboard.type("^o") | 211 | self.keyboard.type("^o") |
1016 | 212 | self.assertSearchText(u'\xf4') | 212 | self.assertSearchText(u'\xf4') |
1017 | 213 | 213 | ||
1018 | 214 | def test_multi_key_copyright(self): | 214 | def test_multi_key_copyright(self): |
1019 | 215 | """Pressing the sequences 'Multi_key' + 'c' + 'o' must produce '©'.""" | 215 | """Pressing the sequences 'Multi_key' + 'c' + 'o' must produce '©'.""" |
1021 | 216 | self.unity.dash.reveal_application_lens() | 216 | self.unity.dash.reveal_application_scope() |
1022 | 217 | self.keyboard.press_and_release('Multi_key') | 217 | self.keyboard.press_and_release('Multi_key') |
1023 | 218 | self.keyboard.type("oc") | 218 | self.keyboard.type("oc") |
1024 | 219 | self.assertSearchText(u'\xa9') | 219 | self.assertSearchText(u'\xa9') |
1025 | 220 | 220 | ||
1026 | 221 | def test_multi_key_delete(self): | 221 | def test_multi_key_delete(self): |
1027 | 222 | """Pressing 'Multi_key' must not get stuck looking for a sequence.""" | 222 | """Pressing 'Multi_key' must not get stuck looking for a sequence.""" |
1029 | 223 | self.unity.dash.reveal_application_lens() | 223 | self.unity.dash.reveal_application_scope() |
1030 | 224 | self.keyboard.type("dd") | 224 | self.keyboard.type("dd") |
1031 | 225 | self.keyboard.press_and_release('Multi_key') | 225 | self.keyboard.press_and_release('Multi_key') |
1032 | 226 | self.keyboard.press_and_release('BackSpace') | 226 | self.keyboard.press_and_release('BackSpace') |
1033 | @@ -231,64 +231,64 @@ | |||
1034 | 231 | class DashKeyNavTests(DashTestCase): | 231 | class DashKeyNavTests(DashTestCase): |
1035 | 232 | """Test the unity Dash keyboard navigation.""" | 232 | """Test the unity Dash keyboard navigation.""" |
1036 | 233 | 233 | ||
1056 | 234 | def test_lensbar_gets_keyfocus(self): | 234 | def test_scopebar_gets_keyfocus(self): |
1057 | 235 | """Test that the lensbar gets key focus after using Down keypresses.""" | 235 | """Test that the scopebar gets key focus after using Down keypresses.""" |
1058 | 236 | self.unity.dash.ensure_visible() | 236 | self.unity.dash.ensure_visible() |
1059 | 237 | 237 | ||
1060 | 238 | # Make sure that the lens bar can get the focus | 238 | # Make sure that the scope bar can get the focus |
1061 | 239 | for i in range(self.unity.dash.get_num_rows()): | 239 | for i in range(self.unity.dash.get_num_rows()): |
1062 | 240 | self.keyboard.press_and_release("Down") | 240 | self.keyboard.press_and_release("Down") |
1063 | 241 | lensbar = self.unity.dash.view.get_lensbar() | 241 | scopebar = self.unity.dash.view.get_scopebar() |
1064 | 242 | self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals(''))) | 242 | self.assertThat(scopebar.focused_scope_icon, Eventually(NotEquals(''))) |
1065 | 243 | 243 | ||
1066 | 244 | def test_lensbar_focus_changes(self): | 244 | def test_scopebar_focus_changes(self): |
1067 | 245 | """Lensbar focused icon should change with Left and Right keypresses.""" | 245 | """Scopebar focused icon should change with Left and Right keypresses.""" |
1068 | 246 | self.unity.dash.ensure_visible() | 246 | self.unity.dash.ensure_visible() |
1069 | 247 | 247 | ||
1070 | 248 | for i in range(self.unity.dash.get_num_rows()): | 248 | for i in range(self.unity.dash.get_num_rows()): |
1071 | 249 | self.keyboard.press_and_release("Down") | 249 | self.keyboard.press_and_release("Down") |
1072 | 250 | lensbar = self.unity.dash.view.get_lensbar() | 250 | scopebar = self.unity.dash.view.get_scopebar() |
1073 | 251 | 251 | ||
1074 | 252 | current_focused_icon = lensbar.focused_lens_icon | 252 | current_focused_icon = scopebar.focused_scope_icon |
1075 | 253 | 253 | ||
1076 | 254 | self.keyboard.press_and_release("Right") | 254 | self.keyboard.press_and_release("Right") |
1078 | 255 | self.assertThat(lensbar.focused_lens_icon, Eventually(NotEquals(current_focused_icon))) | 255 | self.assertThat(scopebar.focused_scope_icon, Eventually(NotEquals(current_focused_icon))) |
1079 | 256 | 256 | ||
1080 | 257 | self.keyboard.press_and_release("Left") | 257 | self.keyboard.press_and_release("Left") |
1082 | 258 | self.assertThat(lensbar.focused_lens_icon, Eventually(Equals(current_focused_icon))) | 258 | self.assertThat(scopebar.focused_scope_icon, Eventually(Equals(current_focused_icon))) |
1083 | 259 | 259 | ||
1086 | 260 | def test_lensbar_enter_activation(self): | 260 | def test_scopebar_enter_activation(self): |
1087 | 261 | """Must be able to activate LensBar icons that have focus with an Enter keypress.""" | 261 | """Must be able to activate ScopeBar icons that have focus with an Enter keypress.""" |
1088 | 262 | self.unity.dash.ensure_visible() | 262 | self.unity.dash.ensure_visible() |
1089 | 263 | 263 | ||
1090 | 264 | for i in range(self.unity.dash.get_num_rows()): | 264 | for i in range(self.unity.dash.get_num_rows()): |
1091 | 265 | self.keyboard.press_and_release("Down") | 265 | self.keyboard.press_and_release("Down") |
1092 | 266 | self.keyboard.press_and_release("Right") | 266 | self.keyboard.press_and_release("Right") |
1095 | 267 | lensbar = self.unity.dash.view.get_lensbar() | 267 | scopebar = self.unity.dash.view.get_scopebar() |
1096 | 268 | focused_icon = lensbar.focused_lens_icon | 268 | focused_icon = scopebar.focused_scope_icon |
1097 | 269 | self.keyboard.press_and_release("Enter") | 269 | self.keyboard.press_and_release("Enter") |
1098 | 270 | 270 | ||
1100 | 271 | self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon))) | 271 | self.assertThat(scopebar.active_scope, Eventually(Equals(focused_icon))) |
1101 | 272 | 272 | ||
1104 | 273 | # lensbar should lose focus after activation. | 273 | # scopebar should lose focus after activation. |
1105 | 274 | self.assertThat(lensbar.focused_lens_icon, Eventually(Equals(""))) | 274 | self.assertThat(scopebar.focused_scope_icon, Eventually(Equals(""))) |
1106 | 275 | 275 | ||
1107 | 276 | def test_focus_returns_to_searchbar(self): | 276 | def test_focus_returns_to_searchbar(self): |
1108 | 277 | """This test makes sure that the focus is returned to the searchbar of the newly | 277 | """This test makes sure that the focus is returned to the searchbar of the newly |
1110 | 278 | activated lens.""" | 278 | activated scope.""" |
1111 | 279 | self.unity.dash.ensure_visible() | 279 | self.unity.dash.ensure_visible() |
1112 | 280 | 280 | ||
1113 | 281 | for i in range(self.unity.dash.get_num_rows()): | 281 | for i in range(self.unity.dash.get_num_rows()): |
1114 | 282 | self.keyboard.press_and_release("Down") | 282 | self.keyboard.press_and_release("Down") |
1115 | 283 | self.keyboard.press_and_release("Right") | 283 | self.keyboard.press_and_release("Right") |
1118 | 284 | lensbar = self.unity.dash.view.get_lensbar() | 284 | scopebar = self.unity.dash.view.get_scopebar() |
1119 | 285 | focused_icon = lensbar.focused_lens_icon | 285 | focused_icon = scopebar.focused_scope_icon |
1120 | 286 | self.keyboard.press_and_release("Enter") | 286 | self.keyboard.press_and_release("Enter") |
1121 | 287 | 287 | ||
1124 | 288 | self.assertThat(lensbar.active_lens, Eventually(Equals(focused_icon))) | 288 | self.assertThat(scopebar.active_scope, Eventually(Equals(focused_icon))) |
1125 | 289 | self.assertThat(lensbar.focused_lens_icon, Eventually(Equals(""))) | 289 | self.assertThat(scopebar.focused_scope_icon, Eventually(Equals(""))) |
1126 | 290 | 290 | ||
1128 | 291 | # Now we make sure if the newly activated lens searchbar have the focus. | 291 | # Now we make sure if the newly activated scope searchbar have the focus. |
1129 | 292 | self.keyboard.type("HasFocus") | 292 | self.keyboard.type("HasFocus") |
1130 | 293 | 293 | ||
1131 | 294 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("HasFocus"))) | 294 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("HasFocus"))) |
1132 | @@ -304,22 +304,22 @@ | |||
1133 | 304 | self.unity.dash.ensure_visible() | 304 | self.unity.dash.ensure_visible() |
1134 | 305 | # Make sure that a category have the focus. | 305 | # Make sure that a category have the focus. |
1135 | 306 | self.keyboard.press_and_release("Down") | 306 | self.keyboard.press_and_release("Down") |
1138 | 307 | lens = self.unity.dash.get_current_lens() | 307 | scope = self.unity.dash.get_current_scope() |
1139 | 308 | category = lens.get_focused_category() | 308 | category = scope.get_focused_category() |
1140 | 309 | self.assertIsNot(category, None) | 309 | self.assertIsNot(category, None) |
1141 | 310 | # Make sure that the category is highlighted. | 310 | # Make sure that the category is highlighted. |
1142 | 311 | self.assertTrue(category.header_is_highlighted) | 311 | self.assertTrue(category.header_is_highlighted) |
1143 | 312 | 312 | ||
1146 | 313 | def test_control_tab_lens_cycle(self): | 313 | def test_control_tab_scope_cycle(self): |
1147 | 314 | """This test makes sure that Ctrl+Tab cycles lenses.""" | 314 | """This test makes sure that Ctrl+Tab cycles scopes.""" |
1148 | 315 | self.unity.dash.ensure_visible() | 315 | self.unity.dash.ensure_visible() |
1149 | 316 | 316 | ||
1150 | 317 | self.keyboard.press('Control') | 317 | self.keyboard.press('Control') |
1151 | 318 | self.keyboard.press_and_release('Tab') | 318 | self.keyboard.press_and_release('Tab') |
1152 | 319 | self.keyboard.release('Control') | 319 | self.keyboard.release('Control') |
1153 | 320 | 320 | ||
1156 | 321 | lensbar = self.unity.dash.view.get_lensbar() | 321 | scopebar = self.unity.dash.view.get_scopebar() |
1157 | 322 | self.assertEqual(lensbar.active_lens, u'applications.lens') | 322 | self.assertEqual(scopebar.active_scope, u'applications.scope') |
1158 | 323 | 323 | ||
1159 | 324 | self.keyboard.press('Control') | 324 | self.keyboard.press('Control') |
1160 | 325 | self.keyboard.press('Shift') | 325 | self.keyboard.press('Shift') |
1161 | @@ -327,33 +327,33 @@ | |||
1162 | 327 | self.keyboard.release('Control') | 327 | self.keyboard.release('Control') |
1163 | 328 | self.keyboard.release('Shift') | 328 | self.keyboard.release('Shift') |
1164 | 329 | 329 | ||
1166 | 330 | self.assertThat(lensbar.active_lens, Eventually(Equals('home.lens'))) | 330 | self.assertThat(scopebar.active_scope, Eventually(Equals('home.scope'))) |
1167 | 331 | 331 | ||
1168 | 332 | def test_tab_cycle_category_headers(self): | 332 | def test_tab_cycle_category_headers(self): |
1169 | 333 | """ Makes sure that pressing tab cycles through the category headers""" | 333 | """ Makes sure that pressing tab cycles through the category headers""" |
1170 | 334 | self.unity.dash.ensure_visible() | 334 | self.unity.dash.ensure_visible() |
1172 | 335 | lens = self.unity.dash.get_current_lens() | 335 | scope = self.unity.dash.get_current_scope() |
1173 | 336 | 336 | ||
1174 | 337 | # Test that tab cycles through the categories. | 337 | # Test that tab cycles through the categories. |
1175 | 338 | # + 1 is to cycle back to first header | 338 | # + 1 is to cycle back to first header |
1177 | 339 | for i in range(lens.get_num_visible_categories() + 1): | 339 | for i in range(scope.get_num_visible_categories() + 1): |
1178 | 340 | self.keyboard.press_and_release('Tab') | 340 | self.keyboard.press_and_release('Tab') |
1180 | 341 | category = lens.get_focused_category() | 341 | category = scope.get_focused_category() |
1181 | 342 | self.assertIsNot(category, None) | 342 | self.assertIsNot(category, None) |
1182 | 343 | 343 | ||
1183 | 344 | def test_tab_with_filter_bar(self): | 344 | def test_tab_with_filter_bar(self): |
1184 | 345 | """ This test makes sure that Tab works well with the filter bara.""" | 345 | """ This test makes sure that Tab works well with the filter bara.""" |
1187 | 346 | self.unity.dash.reveal_application_lens() | 346 | self.unity.dash.reveal_application_scope() |
1188 | 347 | lens = self.unity.dash.get_current_lens() | 347 | scope = self.unity.dash.get_current_scope() |
1189 | 348 | 348 | ||
1190 | 349 | # Tabs to last category | 349 | # Tabs to last category |
1192 | 350 | for i in range(lens.get_num_visible_categories()): | 350 | for i in range(scope.get_num_visible_categories()): |
1193 | 351 | self.keyboard.press_and_release('Tab') | 351 | self.keyboard.press_and_release('Tab') |
1194 | 352 | 352 | ||
1195 | 353 | self.keyboard.press_and_release('Tab') | 353 | self.keyboard.press_and_release('Tab') |
1196 | 354 | self.assertThat(self.unity.dash.searchbar.expander_has_focus, Eventually(Equals(True))) | 354 | self.assertThat(self.unity.dash.searchbar.expander_has_focus, Eventually(Equals(True))) |
1197 | 355 | 355 | ||
1199 | 356 | filter_bar = lens.get_filterbar() | 356 | filter_bar = scope.get_filterbar() |
1200 | 357 | if not self.unity.dash.searchbar.showing_filters: | 357 | if not self.unity.dash.searchbar.showing_filters: |
1201 | 358 | self.keyboard.press_and_release('Enter') | 358 | self.keyboard.press_and_release('Enter') |
1202 | 359 | self.assertThat(self.unity.dash.searchbar.showing_filters, Eventually(Equals(True))) | 359 | self.assertThat(self.unity.dash.searchbar.showing_filters, Eventually(Equals(True))) |
1203 | @@ -366,17 +366,17 @@ | |||
1204 | 366 | 366 | ||
1205 | 367 | # Ensure that tab cycles back to a category header | 367 | # Ensure that tab cycles back to a category header |
1206 | 368 | self.keyboard.press_and_release('Tab') | 368 | self.keyboard.press_and_release('Tab') |
1208 | 369 | category = lens.get_focused_category() | 369 | category = scope.get_focused_category() |
1209 | 370 | self.assertIsNot(category, None) | 370 | self.assertIsNot(category, None) |
1210 | 371 | 371 | ||
1211 | 372 | def test_bottom_up_keynav_with_filter_bar(self): | 372 | def test_bottom_up_keynav_with_filter_bar(self): |
1212 | 373 | """This test makes sure that bottom-up key navigation works well | 373 | """This test makes sure that bottom-up key navigation works well |
1213 | 374 | in the dash filter bar. | 374 | in the dash filter bar. |
1214 | 375 | """ | 375 | """ |
1217 | 376 | self.unity.dash.reveal_application_lens() | 376 | self.unity.dash.reveal_application_scope() |
1218 | 377 | lens = self.unity.dash.get_current_lens() | 377 | scope = self.unity.dash.get_current_scope() |
1219 | 378 | 378 | ||
1221 | 379 | filter_bar = lens.get_filterbar() | 379 | filter_bar = scope.get_filterbar() |
1222 | 380 | # Need to ensure the filter expander has focus, so if it's already | 380 | # Need to ensure the filter expander has focus, so if it's already |
1223 | 381 | # expanded, we collapse it first: | 381 | # expanded, we collapse it first: |
1224 | 382 | filter_bar.ensure_collapsed() | 382 | filter_bar.ensure_collapsed() |
1225 | @@ -496,8 +496,8 @@ | |||
1226 | 496 | """Expanding or collapsing the filterbar must keave keyboard focus in the | 496 | """Expanding or collapsing the filterbar must keave keyboard focus in the |
1227 | 497 | search bar. | 497 | search bar. |
1228 | 498 | """ | 498 | """ |
1231 | 499 | self.unity.dash.reveal_application_lens() | 499 | self.unity.dash.reveal_application_scope() |
1232 | 500 | filter_bar = self.unity.dash.get_current_lens().get_filterbar() | 500 | filter_bar = self.unity.dash.get_current_scope().get_filterbar() |
1233 | 501 | filter_bar.ensure_collapsed() | 501 | filter_bar.ensure_collapsed() |
1234 | 502 | 502 | ||
1235 | 503 | self.keyboard.type("hello") | 503 | self.keyboard.type("hello") |
1236 | @@ -519,39 +519,39 @@ | |||
1237 | 519 | self.assertSearchText("HasFocus") | 519 | self.assertSearchText("HasFocus") |
1238 | 520 | 520 | ||
1239 | 521 | 521 | ||
1242 | 522 | class DashLensResultsTests(DashTestCase): | 522 | class DashScopeResultsTests(DashTestCase): |
1243 | 523 | """Tests results from the lens view.""" | 523 | """Tests results from the scope view.""" |
1244 | 524 | 524 | ||
1245 | 525 | def test_results_message_empty_search(self): | 525 | def test_results_message_empty_search(self): |
1246 | 526 | """This tests a message is not shown when there is no text.""" | 526 | """This tests a message is not shown when there is no text.""" |
1250 | 527 | self.unity.dash.reveal_application_lens() | 527 | self.unity.dash.reveal_application_scope() |
1251 | 528 | lens = self.unity.dash.get_current_lens() | 528 | scope = self.unity.dash.get_current_scope() |
1252 | 529 | self.assertThat(lens.no_results_active, Eventually(Equals(False))) | 529 | self.assertThat(scope.no_results_active, Eventually(Equals(False))) |
1253 | 530 | 530 | ||
1254 | 531 | def test_results_message(self): | 531 | def test_results_message(self): |
1255 | 532 | """This test no mesage will be shown when results are there.""" | 532 | """This test no mesage will be shown when results are there.""" |
1257 | 533 | self.unity.dash.reveal_application_lens() | 533 | self.unity.dash.reveal_application_scope() |
1258 | 534 | self.keyboard.type("Terminal") | 534 | self.keyboard.type("Terminal") |
1259 | 535 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("Terminal"))) | 535 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("Terminal"))) |
1262 | 536 | lens = self.unity.dash.get_current_lens() | 536 | scope = self.unity.dash.get_current_scope() |
1263 | 537 | self.assertThat(lens.no_results_active, Eventually(Equals(False))) | 537 | self.assertThat(scope.no_results_active, Eventually(Equals(False))) |
1264 | 538 | 538 | ||
1265 | 539 | def test_no_results_message(self): | 539 | def test_no_results_message(self): |
1268 | 540 | """This test shows a message will appear in the lens.""" | 540 | """This test shows a message will appear in the scope.""" |
1269 | 541 | self.unity.dash.reveal_application_lens() | 541 | self.unity.dash.reveal_application_scope() |
1270 | 542 | self.keyboard.type("qwerlkjzvxc") | 542 | self.keyboard.type("qwerlkjzvxc") |
1271 | 543 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("qwerlkjzvxc"))) | 543 | self.assertThat(self.unity.dash.search_string, Eventually(Equals("qwerlkjzvxc"))) |
1274 | 544 | lens = self.unity.dash.get_current_lens() | 544 | scope = self.unity.dash.get_current_scope() |
1275 | 545 | self.assertThat(lens.no_results_active, Eventually(Equals(True))) | 545 | self.assertThat(scope.no_results_active, Eventually(Equals(True))) |
1276 | 546 | 546 | ||
1277 | 547 | def test_results_update_on_filter_changed(self): | 547 | def test_results_update_on_filter_changed(self): |
1278 | 548 | """This test makes sure the results change when filters change.""" | 548 | """This test makes sure the results change when filters change.""" |
1282 | 549 | gettext.install("unity-lens-applications") | 549 | gettext.install("unity-scope-applications") |
1283 | 550 | self.unity.dash.reveal_application_lens() | 550 | self.unity.dash.reveal_application_scope() |
1284 | 551 | lens = self.unity.dash.get_current_lens() | 551 | scope = self.unity.dash.get_current_scope() |
1285 | 552 | self.keyboard.type(" ") | 552 | self.keyboard.type(" ") |
1286 | 553 | self.assertThat(self.unity.dash.search_string, Eventually(Equals(" "))) | 553 | self.assertThat(self.unity.dash.search_string, Eventually(Equals(" "))) |
1288 | 554 | results_category = lens.get_category_by_name(_("Installed")) | 554 | results_category = scope.get_category_by_name(_("Installed")) |
1289 | 555 | old_results = results_category.get_results() | 555 | old_results = results_category.get_results() |
1290 | 556 | 556 | ||
1291 | 557 | # FIXME: This should be a method on the dash emulator perhaps, or | 557 | # FIXME: This should be a method on the dash emulator perhaps, or |
1292 | @@ -559,20 +559,20 @@ | |||
1293 | 559 | # function that is only called once! | 559 | # function that is only called once! |
1294 | 560 | def activate_filter(add_cleanup = False): | 560 | def activate_filter(add_cleanup = False): |
1295 | 561 | # Tabs to last category | 561 | # Tabs to last category |
1297 | 562 | for i in range(lens.get_num_visible_categories()): | 562 | for i in range(scope.get_num_visible_categories()): |
1298 | 563 | self.keyboard.press_and_release('Tab') | 563 | self.keyboard.press_and_release('Tab') |
1299 | 564 | 564 | ||
1300 | 565 | self.keyboard.press_and_release('Tab') | 565 | self.keyboard.press_and_release('Tab') |
1301 | 566 | self.assertThat(self.unity.dash.searchbar.expander_has_focus, Eventually(Equals(True))) | 566 | self.assertThat(self.unity.dash.searchbar.expander_has_focus, Eventually(Equals(True))) |
1302 | 567 | 567 | ||
1304 | 568 | filter_bar = lens.get_filterbar() | 568 | filter_bar = scope.get_filterbar() |
1305 | 569 | if not self.unity.dash.searchbar.showing_filters: | 569 | if not self.unity.dash.searchbar.showing_filters: |
1306 | 570 | self.keyboard.press_and_release('Enter') | 570 | self.keyboard.press_and_release('Enter') |
1307 | 571 | self.assertThat(self.unity.dash.searchbar.showing_filters, Eventually(Equals(True))) | 571 | self.assertThat(self.unity.dash.searchbar.showing_filters, Eventually(Equals(True))) |
1308 | 572 | if add_cleanup: | 572 | if add_cleanup: |
1309 | 573 | self.addCleanup(filter_bar.ensure_collapsed) | 573 | self.addCleanup(filter_bar.ensure_collapsed) |
1310 | 574 | 574 | ||
1312 | 575 | # Tab to the "Type" filter in apps lens | 575 | # Tab to the "Type" filter in apps scope |
1313 | 576 | self.keyboard.press_and_release('Tab') | 576 | self.keyboard.press_and_release('Tab') |
1314 | 577 | new_focused_filter = filter_bar.get_focused_filter() | 577 | new_focused_filter = filter_bar.get_focused_filter() |
1315 | 578 | self.assertIsNotNone(new_focused_filter) | 578 | self.assertIsNotNone(new_focused_filter) |
1316 | @@ -586,7 +586,7 @@ | |||
1317 | 586 | activate_filter(True) | 586 | activate_filter(True) |
1318 | 587 | self.addCleanup(activate_filter) | 587 | self.addCleanup(activate_filter) |
1319 | 588 | 588 | ||
1321 | 589 | results_category = lens.get_category_by_name(_("Installed")) | 589 | results_category = scope.get_category_by_name(_("Installed")) |
1322 | 590 | results = results_category.get_results() | 590 | results = results_category.get_results() |
1323 | 591 | self.assertIsNot(results, old_results) | 591 | self.assertIsNot(results, old_results) |
1324 | 592 | 592 | ||
1325 | @@ -597,14 +597,14 @@ | |||
1326 | 597 | class DashVisualTests(DashTestCase): | 597 | class DashVisualTests(DashTestCase): |
1327 | 598 | """Tests that the dash visual is correct.""" | 598 | """Tests that the dash visual is correct.""" |
1328 | 599 | 599 | ||
1331 | 600 | def test_closing_dash_hides_current_lens(self): | 600 | def test_closing_dash_hides_current_scope(self): |
1332 | 601 | """When exiting from the dash the current lens must set it self to not visible.""" | 601 | """When exiting from the dash the current scope must set it self to not visible.""" |
1333 | 602 | 602 | ||
1334 | 603 | self.unity.dash.ensure_visible() | 603 | self.unity.dash.ensure_visible() |
1336 | 604 | lens = self.unity.dash.get_current_lens() | 604 | scope = self.unity.dash.get_current_scope() |
1337 | 605 | self.unity.dash.ensure_hidden() | 605 | self.unity.dash.ensure_hidden() |
1338 | 606 | 606 | ||
1340 | 607 | self.assertThat(lens.visible, Eventually(Equals(False))) | 607 | self.assertThat(scope.visible, Eventually(Equals(False))) |
1341 | 608 | 608 | ||
1342 | 609 | def test_dash_position_with_non_default_launcher_width(self): | 609 | def test_dash_position_with_non_default_launcher_width(self): |
1343 | 610 | """"There should be no empty space between launcher and dash when the launcher | 610 | """"There should be no empty space between launcher and dash when the launcher |
1344 | @@ -625,10 +625,10 @@ | |||
1345 | 625 | """The see more results label should be baseline aligned | 625 | """The see more results label should be baseline aligned |
1346 | 626 | with the category name label. | 626 | with the category name label. |
1347 | 627 | """ | 627 | """ |
1349 | 628 | self.unity.dash.reveal_application_lens() | 628 | self.unity.dash.reveal_application_scope() |
1350 | 629 | 629 | ||
1353 | 630 | lens = self.unity.dash.get_current_lens() | 630 | scope = self.unity.dash.get_current_scope() |
1354 | 631 | groups = lens.get_groups() | 631 | groups = scope.get_groups() |
1355 | 632 | 632 | ||
1356 | 633 | for group in groups: | 633 | for group in groups: |
1357 | 634 | if (group.is_visible and group.expand_label_is_visible): | 634 | if (group.is_visible and group.expand_label_is_visible): |
1358 | @@ -637,25 +637,25 @@ | |||
1359 | 637 | self.assertThat(expand_label_y, Equals(name_label_y)) | 637 | self.assertThat(expand_label_y, Equals(name_label_y)) |
1360 | 638 | 638 | ||
1361 | 639 | 639 | ||
1364 | 640 | class DashLensBarTests(DashTestCase): | 640 | class DashScopeBarTests(DashTestCase): |
1365 | 641 | """Tests that the lensbar works well.""" | 641 | """Tests that the scopebar works well.""" |
1366 | 642 | 642 | ||
1367 | 643 | def setUp(self): | 643 | def setUp(self): |
1369 | 644 | super(DashLensBarTests, self).setUp() | 644 | super(DashScopeBarTests, self).setUp() |
1370 | 645 | self.unity.dash.ensure_visible() | 645 | self.unity.dash.ensure_visible() |
1372 | 646 | self.lensbar = self.unity.dash.view.get_lensbar() | 646 | self.scopebar = self.unity.dash.view.get_scopebar() |
1373 | 647 | 647 | ||
1374 | 648 | def test_click_inside_highlight(self): | 648 | def test_click_inside_highlight(self): |
1376 | 649 | """Lens selection should work when clicking in | 649 | """Scope selection should work when clicking in |
1377 | 650 | the rectangle outside of the icon. | 650 | the rectangle outside of the icon. |
1378 | 651 | """ | 651 | """ |
1380 | 652 | app_icon = self.lensbar.get_icon_by_name(u'applications.lens') | 652 | app_icon = self.scopebar.get_icon_by_name(u'applications.scope') |
1381 | 653 | 653 | ||
1382 | 654 | self.mouse.move(app_icon.x + (app_icon.width / 2), | 654 | self.mouse.move(app_icon.x + (app_icon.width / 2), |
1383 | 655 | app_icon.y + (app_icon.height / 2)) | 655 | app_icon.y + (app_icon.height / 2)) |
1384 | 656 | self.mouse.click() | 656 | self.mouse.click() |
1385 | 657 | 657 | ||
1387 | 658 | self.assertThat(self.lensbar.active_lens, Eventually(Equals('applications.lens'))) | 658 | self.assertThat(self.scopebar.active_scope, Eventually(Equals('applications.scope'))) |
1388 | 659 | 659 | ||
1389 | 660 | 660 | ||
1390 | 661 | class DashBorderTests(DashTestCase): | 661 | class DashBorderTests(DashTestCase): |
1391 | @@ -703,11 +703,11 @@ | |||
1392 | 703 | """Clicking into a category highlight must expand/collapse | 703 | """Clicking into a category highlight must expand/collapse |
1393 | 704 | the view. | 704 | the view. |
1394 | 705 | """ | 705 | """ |
1397 | 706 | gettext.install("unity-lens-applications", unicode=True) | 706 | gettext.install("unity-scope-applications", unicode=True) |
1398 | 707 | lens = self.unity.dash.reveal_application_lens() | 707 | scope = self.unity.dash.reveal_application_scope() |
1399 | 708 | self.addCleanup(self.unity.dash.ensure_hidden) | 708 | self.addCleanup(self.unity.dash.ensure_hidden) |
1400 | 709 | 709 | ||
1402 | 710 | category = lens.get_category_by_name(_("Installed")) | 710 | category = scope.get_category_by_name(_("Installed")) |
1403 | 711 | is_expanded = category.is_expanded | 711 | is_expanded = category.is_expanded |
1404 | 712 | 712 | ||
1405 | 713 | self.mouse.move(self.unity.dash.view.x + self.unity.dash.view.width / 2, | 713 | self.mouse.move(self.unity.dash.view.x + self.unity.dash.view.width / 2, |
1406 | @@ -722,18 +722,18 @@ | |||
1407 | 722 | 722 | ||
1408 | 723 | class PreviewInvocationTests(DashTestCase): | 723 | class PreviewInvocationTests(DashTestCase): |
1409 | 724 | """Tests that dash previews can be opened and closed in different | 724 | """Tests that dash previews can be opened and closed in different |
1411 | 725 | lenses. | 725 | scopes. |
1412 | 726 | """ | 726 | """ |
1415 | 727 | def test_app_lens_preview_open_close(self): | 727 | def test_app_scope_preview_open_close(self): |
1416 | 728 | """Right-clicking on an application lens result must show | 728 | """Right-clicking on an application scope result must show |
1417 | 729 | its preview. | 729 | its preview. |
1418 | 730 | 730 | ||
1419 | 731 | """ | 731 | """ |
1422 | 732 | gettext.install("unity-lens-applications", unicode=True) | 732 | gettext.install("unity-scope-applications", unicode=True) |
1423 | 733 | lens = self.unity.dash.reveal_application_lens() | 733 | scope = self.unity.dash.reveal_application_scope() |
1424 | 734 | self.addCleanup(self.unity.dash.ensure_hidden) | 734 | self.addCleanup(self.unity.dash.ensure_hidden) |
1425 | 735 | 735 | ||
1427 | 736 | category = lens.get_category_by_name(_("More suggestions")) | 736 | category = scope.get_category_by_name(_("More suggestions")) |
1428 | 737 | results = category.get_results() | 737 | results = category.get_results() |
1429 | 738 | result = results[0] | 738 | result = results[0] |
1430 | 739 | # result.preview handles finding xy co-ords and right mouse-click | 739 | # result.preview handles finding xy co-ords and right mouse-click |
1431 | @@ -744,24 +744,24 @@ | |||
1432 | 744 | 744 | ||
1433 | 745 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) | 745 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) |
1434 | 746 | 746 | ||
1437 | 747 | def test_files_lens_preview_open_close(self): | 747 | def test_files_scope_preview_open_close(self): |
1438 | 748 | """Right-clicking on a files lens result must show its | 748 | """Right-clicking on a files scope result must show its |
1439 | 749 | preview. | 749 | preview. |
1440 | 750 | """ | 750 | """ |
1442 | 751 | gettext.install("unity-lens-files", unicode=True) | 751 | gettext.install("unity-scope-files", unicode=True) |
1443 | 752 | 752 | ||
1444 | 753 | # Instead of skipping the test, here we can create a dummy file to open and | 753 | # Instead of skipping the test, here we can create a dummy file to open and |
1446 | 754 | # make sure the lens result is non-empty | 754 | # make sure the scope result is non-empty |
1447 | 755 | (file_handle, file_path) = mkstemp() | 755 | (file_handle, file_path) = mkstemp() |
1448 | 756 | self.addCleanup(remove, file_path) | 756 | self.addCleanup(remove, file_path) |
1449 | 757 | gedit_win = self.start_app_window('Text Editor', files=[file_path], locale='C') | 757 | gedit_win = self.start_app_window('Text Editor', files=[file_path], locale='C') |
1450 | 758 | self.addCleanup(self.close_all_app, 'Text Editor') | 758 | self.addCleanup(self.close_all_app, 'Text Editor') |
1451 | 759 | self.assertProperty(gedit_win, is_focused=True) | 759 | self.assertProperty(gedit_win, is_focused=True) |
1452 | 760 | 760 | ||
1454 | 761 | lens = self.unity.dash.reveal_file_lens() | 761 | scope = self.unity.dash.reveal_file_scope() |
1455 | 762 | self.addCleanup(self.unity.dash.ensure_hidden) | 762 | self.addCleanup(self.unity.dash.ensure_hidden) |
1456 | 763 | 763 | ||
1458 | 764 | category = lens.get_category_by_name(_("Recent")) | 764 | category = scope.get_category_by_name(_("Recent")) |
1459 | 765 | refresh_results_fn = lambda: len(category.get_results()) | 765 | refresh_results_fn = lambda: len(category.get_results()) |
1460 | 766 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(0))) | 766 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(0))) |
1461 | 767 | results = category.get_results() | 767 | results = category.get_results() |
1462 | @@ -774,18 +774,18 @@ | |||
1463 | 774 | 774 | ||
1464 | 775 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) | 775 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) |
1465 | 776 | 776 | ||
1468 | 777 | def test_music_lens_preview_open_close(self): | 777 | def test_music_scope_preview_open_close(self): |
1469 | 778 | """Right-clicking on a music lens result must show its | 778 | """Right-clicking on a music scope result must show its |
1470 | 779 | preview. | 779 | preview. |
1471 | 780 | """ | 780 | """ |
1473 | 781 | lens = self.unity.dash.reveal_music_lens() | 781 | scope = self.unity.dash.reveal_music_scope() |
1474 | 782 | self.addCleanup(self.unity.dash.ensure_hidden) | 782 | self.addCleanup(self.unity.dash.ensure_hidden) |
1475 | 783 | 783 | ||
1477 | 784 | category = lens.get_category_by_name("Songs") | 784 | category = scope.get_category_by_name("Songs") |
1478 | 785 | # Incase there was no music ever played we skip the test instead | 785 | # Incase there was no music ever played we skip the test instead |
1479 | 786 | # of failing. | 786 | # of failing. |
1480 | 787 | if category is None or not category.is_visible: | 787 | if category is None or not category.is_visible: |
1482 | 788 | self.skipTest("This lens is probably empty") | 788 | self.skipTest("This scope is probably empty") |
1483 | 789 | 789 | ||
1484 | 790 | results = category.get_results() | 790 | results = category.get_results() |
1485 | 791 | 791 | ||
1486 | @@ -798,28 +798,28 @@ | |||
1487 | 798 | 798 | ||
1488 | 799 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) | 799 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(False))) |
1489 | 800 | 800 | ||
1492 | 801 | def test_video_lens_preview_open_close(self): | 801 | def test_video_scope_preview_open_close(self): |
1493 | 802 | """Right-clicking on a video lens result must show its | 802 | """Right-clicking on a video scope result must show its |
1494 | 803 | preview. | 803 | preview. |
1495 | 804 | """ | 804 | """ |
1497 | 805 | gettext.install("unity-lens-video", unicode=True) | 805 | gettext.install("unity-scope-video", unicode=True) |
1498 | 806 | 806 | ||
1501 | 807 | def get_category(lens): | 807 | def get_category(scope): |
1502 | 808 | category = lens.get_category_by_name(_("Recently Viewed")) | 808 | category = scope.get_category_by_name(_("Recently Viewed")) |
1503 | 809 | # If there was no video played on this system this category is expected | 809 | # If there was no video played on this system this category is expected |
1504 | 810 | # to be empty, if its empty we check if the 'Online' category have any | 810 | # to be empty, if its empty we check if the 'Online' category have any |
1505 | 811 | # contents, if not then we skip the test. | 811 | # contents, if not then we skip the test. |
1506 | 812 | if category is None or not category.is_visible: | 812 | if category is None or not category.is_visible: |
1508 | 813 | category = lens.get_category_by_name("Online") | 813 | category = scope.get_category_by_name("Online") |
1509 | 814 | if category is None or not category.is_visible: | 814 | if category is None or not category.is_visible: |
1511 | 815 | self.skipTest("This lens is probably empty") | 815 | self.skipTest("This scope is probably empty") |
1512 | 816 | return category | 816 | return category |
1513 | 817 | 817 | ||
1515 | 818 | lens = self.unity.dash.reveal_video_lens() | 818 | scope = self.unity.dash.reveal_video_scope() |
1516 | 819 | self.addCleanup(self.unity.dash.ensure_hidden) | 819 | self.addCleanup(self.unity.dash.ensure_hidden) |
1517 | 820 | 820 | ||
1520 | 821 | self.assertThat(lambda: get_category(lens), Eventually(NotEquals(None))) | 821 | self.assertThat(lambda: get_category(scope), Eventually(NotEquals(None))) |
1521 | 822 | category = get_category(lens) | 822 | category = get_category(scope) |
1522 | 823 | 823 | ||
1523 | 824 | results = category.get_results() | 824 | results = category.get_results() |
1524 | 825 | 825 | ||
1525 | @@ -836,11 +836,11 @@ | |||
1526 | 836 | """Pressing menu key on a selected dash result must show | 836 | """Pressing menu key on a selected dash result must show |
1527 | 837 | its preview. | 837 | its preview. |
1528 | 838 | """ | 838 | """ |
1531 | 839 | gettext.install("unity-lens-applications", unicode=True) | 839 | gettext.install("unity-scope-applications", unicode=True) |
1532 | 840 | lens = self.unity.dash.reveal_application_lens() | 840 | scope = self.unity.dash.reveal_application_scope() |
1533 | 841 | self.addCleanup(self.unity.dash.ensure_hidden) | 841 | self.addCleanup(self.unity.dash.ensure_hidden) |
1534 | 842 | 842 | ||
1536 | 843 | category = lens.get_category_by_name(_("More suggestions")) | 843 | category = scope.get_category_by_name(_("More suggestions")) |
1537 | 844 | results = category.get_results() | 844 | results = category.get_results() |
1538 | 845 | result = results[0] | 845 | result = results[0] |
1539 | 846 | # result.preview_key() handles finding xy co-ords and key press | 846 | # result.preview_key() handles finding xy co-ords and key press |
1540 | @@ -853,12 +853,12 @@ | |||
1541 | 853 | 853 | ||
1542 | 854 | def setUp(self): | 854 | def setUp(self): |
1543 | 855 | super(PreviewNavigateTests, self).setUp() | 855 | super(PreviewNavigateTests, self).setUp() |
1545 | 856 | gettext.install("unity-lens-applications", unicode=True) | 856 | gettext.install("unity-scope-applications", unicode=True) |
1546 | 857 | 857 | ||
1548 | 858 | lens = self.unity.dash.reveal_application_lens() | 858 | scope = self.unity.dash.reveal_application_scope() |
1549 | 859 | self.addCleanup(self.unity.dash.ensure_hidden) | 859 | self.addCleanup(self.unity.dash.ensure_hidden) |
1550 | 860 | 860 | ||
1552 | 861 | results_category = lens.get_category_by_name(_("More suggestions")) | 861 | results_category = scope.get_category_by_name(_("More suggestions")) |
1553 | 862 | # wait for results (we need 4 results to perorm the multi-navigation tests) | 862 | # wait for results (we need 4 results to perorm the multi-navigation tests) |
1554 | 863 | refresh_fn = lambda: len(results_category.get_results()) | 863 | refresh_fn = lambda: len(results_category.get_results()) |
1555 | 864 | self.assertThat(refresh_fn, Eventually(GreaterThan(4))) | 864 | self.assertThat(refresh_fn, Eventually(GreaterThan(4))) |
1556 | @@ -984,12 +984,12 @@ | |||
1557 | 984 | 984 | ||
1558 | 985 | def setUp(self): | 985 | def setUp(self): |
1559 | 986 | super(PreviewClickCancelTests, self).setUp() | 986 | super(PreviewClickCancelTests, self).setUp() |
1562 | 987 | gettext.install("unity-lens-applications") | 987 | gettext.install("unity-scope-applications") |
1563 | 988 | lens = self.unity.dash.reveal_application_lens() | 988 | scope = self.unity.dash.reveal_application_scope() |
1564 | 989 | self.addCleanup(self.unity.dash.ensure_hidden) | 989 | self.addCleanup(self.unity.dash.ensure_hidden) |
1565 | 990 | # Only testing an application preview for this test. | 990 | # Only testing an application preview for this test. |
1566 | 991 | self.keyboard.type("Software Updater") | 991 | self.keyboard.type("Software Updater") |
1568 | 992 | results_category = lens.get_category_by_name(_("Installed")) | 992 | results_category = scope.get_category_by_name(_("Installed")) |
1569 | 993 | results = results_category.get_results() | 993 | results = results_category.get_results() |
1570 | 994 | 994 | ||
1571 | 995 | result = results[0] | 995 | result = results[0] |
1572 | 996 | 996 | ||
1573 | === modified file 'tests/autopilot/unity/tests/test_home_lens.py' | |||
1574 | --- tests/autopilot/unity/tests/test_home_lens.py 2013-02-21 10:03:21 +0000 | |||
1575 | +++ tests/autopilot/unity/tests/test_home_lens.py 2013-03-21 14:03:22 +0000 | |||
1576 | @@ -15,15 +15,15 @@ | |||
1577 | 15 | from unity.tests import UnityTestCase | 15 | from unity.tests import UnityTestCase |
1578 | 16 | 16 | ||
1579 | 17 | 17 | ||
1582 | 18 | class HomeLensSearchTests(UnityTestCase): | 18 | class HomeScopeSearchTests(UnityTestCase): |
1583 | 19 | """Test the command lense search bahavior.""" | 19 | """Test the command scope search bahavior.""" |
1584 | 20 | 20 | ||
1585 | 21 | def setUp(self): | 21 | def setUp(self): |
1587 | 22 | super(HomeLensSearchTests, self).setUp() | 22 | super(HomeScopeSearchTests, self).setUp() |
1588 | 23 | 23 | ||
1589 | 24 | def tearDown(self): | 24 | def tearDown(self): |
1590 | 25 | self.unity.dash.ensure_hidden() | 25 | self.unity.dash.ensure_hidden() |
1592 | 26 | super(HomeLensSearchTests, self).tearDown() | 26 | super(HomeScopeSearchTests, self).tearDown() |
1593 | 27 | 27 | ||
1594 | 28 | def test_quick_run_app(self): | 28 | def test_quick_run_app(self): |
1595 | 29 | """Hitting enter runs an application even though a search might not have fully | 29 | """Hitting enter runs an application even though a search might not have fully |
1596 | 30 | 30 | ||
1597 | === modified file 'tests/autopilot/unity/tests/test_search.py' | |||
1598 | --- tests/autopilot/unity/tests/test_search.py 2013-03-12 13:31:41 +0000 | |||
1599 | +++ tests/autopilot/unity/tests/test_search.py 2013-03-21 14:03:22 +0000 | |||
1600 | @@ -20,8 +20,8 @@ | |||
1601 | 20 | 20 | ||
1602 | 21 | # XXX: Ugly workaround for a really annoying bug (LP: #1152517) which breaks | 21 | # XXX: Ugly workaround for a really annoying bug (LP: #1152517) which breaks |
1603 | 22 | # this test suite. So, to workaround, we toggle the dash once before doing any | 22 | # this test suite. So, to workaround, we toggle the dash once before doing any |
1606 | 23 | # app lens search tests | 23 | # app scope search tests |
1607 | 24 | workaround_lenses_load_done = False | 24 | workaround_scopes_load_done = False |
1608 | 25 | 25 | ||
1609 | 26 | class SearchTestsBase(UnityTestCase): | 26 | class SearchTestsBase(UnityTestCase): |
1610 | 27 | """Base class for testing searching in search fields. | 27 | """Base class for testing searching in search fields. |
1611 | @@ -59,28 +59,28 @@ | |||
1612 | 59 | self.input_and_check_result(self.input, self.result) | 59 | self.input_and_check_result(self.input, self.result) |
1613 | 60 | 60 | ||
1614 | 61 | 61 | ||
1616 | 62 | # Lens tests | 62 | # Scope tests |
1617 | 63 | 63 | ||
1620 | 64 | class ApplicationLensSearchTestBase(SearchTestsBase): | 64 | class ApplicationScopeSearchTestBase(SearchTestsBase): |
1621 | 65 | """Common class for all tests for searching in the application lens.""" | 65 | """Common class for all tests for searching in the application scope.""" |
1622 | 66 | 66 | ||
1623 | 67 | def setUp(self): | 67 | def setUp(self): |
1625 | 68 | super(ApplicationLensSearchTestBase, self).setUp() | 68 | super(ApplicationScopeSearchTestBase, self).setUp() |
1626 | 69 | # XXX: Temporary workaround for LP: #1152517 | 69 | # XXX: Temporary workaround for LP: #1152517 |
1629 | 70 | global workaround_lenses_load_done | 70 | global workaround_scopes_load_done |
1630 | 71 | if not workaround_lenses_load_done: | 71 | if not workaround_scopes_load_done: |
1631 | 72 | self.unity.dash.ensure_visible() | 72 | self.unity.dash.ensure_visible() |
1632 | 73 | self.unity.dash.ensure_hidden() | 73 | self.unity.dash.ensure_hidden() |
1634 | 74 | workaround_lenses_load_done = True | 74 | workaround_scopes_load_done = True |
1635 | 75 | 75 | ||
1637 | 76 | self.app_lens = self.unity.dash.reveal_application_lens() | 76 | self.app_scope = self.unity.dash.reveal_application_scope() |
1638 | 77 | self.addCleanup(self.unity.dash.ensure_hidden) | 77 | self.addCleanup(self.unity.dash.ensure_hidden) |
1639 | 78 | gettext.install("unity-lens-applications", unicode=True) | 78 | gettext.install("unity-lens-applications", unicode=True) |
1640 | 79 | 79 | ||
1641 | 80 | def input_and_check_result(self, string, expected): | 80 | def input_and_check_result(self, string, expected): |
1642 | 81 | self.keyboard.type(string) | 81 | self.keyboard.type(string) |
1643 | 82 | self.assertThat(self.unity.dash.search_string, Eventually(Equals(string))) | 82 | self.assertThat(self.unity.dash.search_string, Eventually(Equals(string))) |
1645 | 83 | category = self.app_lens.get_category_by_name(_("Installed")) | 83 | category = self.app_scope.get_category_by_name(_("Installed")) |
1646 | 84 | refresh_results_fn = lambda: len(category.get_results()) | 84 | refresh_results_fn = lambda: len(category.get_results()) |
1647 | 85 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(0))) | 85 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(0))) |
1648 | 86 | results = category.get_results() | 86 | results = category.get_results() |
1649 | @@ -92,8 +92,8 @@ | |||
1650 | 92 | self.assertTrue(found) | 92 | self.assertTrue(found) |
1651 | 93 | 93 | ||
1652 | 94 | 94 | ||
1655 | 95 | class ApplicationLensSearchTests(ApplicationLensSearchTestBase): | 95 | class ApplicationScopeSearchTests(ApplicationScopeSearchTestBase): |
1656 | 96 | """Simple search tests for the application lens.""" | 96 | """Simple search tests for the application scope.""" |
1657 | 97 | 97 | ||
1658 | 98 | scenarios = [ | 98 | scenarios = [ |
1659 | 99 | ('basic', {'input': 'Window Mocker', 'result': 'Window Mocker'}), | 99 | ('basic', {'input': 'Window Mocker', 'result': 'Window Mocker'}), |
1660 | @@ -104,15 +104,15 @@ | |||
1661 | 104 | ] | 104 | ] |
1662 | 105 | 105 | ||
1663 | 106 | def setUp(self): | 106 | def setUp(self): |
1665 | 107 | super(ApplicationLensSearchTests, self).setUp() | 107 | super(ApplicationScopeSearchTests, self).setUp() |
1666 | 108 | 108 | ||
1668 | 109 | def test_application_lens_search(self): | 109 | def test_application_scope_search(self): |
1669 | 110 | self.do_search_test() | 110 | self.do_search_test() |
1670 | 111 | 111 | ||
1671 | 112 | 112 | ||
1675 | 113 | class ApplicationLensFuzzySearchTests(ApplicationLensSearchTestBase): | 113 | class ApplicationScopeFuzzySearchTests(ApplicationScopeSearchTestBase): |
1676 | 114 | """Fuzzy, erroneous search tests for the application lens. | 114 | """Fuzzy, erroneous search tests for the application scope. |
1677 | 115 | This checks if the application lens will find the searched application | 115 | This checks if the application scope will find the searched application |
1678 | 116 | (windowmocker here, since we want some app that has the name | 116 | (windowmocker here, since we want some app that has the name |
1679 | 117 | locale-independent) when small spelling errors are made. | 117 | locale-independent) when small spelling errors are made. |
1680 | 118 | """ | 118 | """ |
1681 | @@ -125,9 +125,9 @@ | |||
1682 | 125 | ] | 125 | ] |
1683 | 126 | 126 | ||
1684 | 127 | def setUp(self): | 127 | def setUp(self): |
1686 | 128 | super(ApplicationLensFuzzySearchTests, self).setUp() | 128 | super(ApplicationScopeFuzzySearchTests, self).setUp() |
1687 | 129 | 129 | ||
1689 | 130 | def test_application_lens_fuzzy_search(self): | 130 | def test_application_scope_fuzzy_search(self): |
1690 | 131 | self.do_search_test() | 131 | self.do_search_test() |
1691 | 132 | 132 | ||
1692 | 133 | 133 | ||
1693 | 134 | 134 | ||
1694 | === modified file 'tests/autopilot/unity/tests/test_shopping_lens.py' | |||
1695 | --- tests/autopilot/unity/tests/test_shopping_lens.py 2013-02-21 10:03:21 +0000 | |||
1696 | +++ tests/autopilot/unity/tests/test_shopping_lens.py 2013-03-21 14:03:22 +0000 | |||
1697 | @@ -17,70 +17,70 @@ | |||
1698 | 17 | from unity.tests import UnityTestCase | 17 | from unity.tests import UnityTestCase |
1699 | 18 | 18 | ||
1700 | 19 | 19 | ||
1703 | 20 | class ShoppingLensTests(UnityTestCase): | 20 | class ShoppingScopeTests(UnityTestCase): |
1704 | 21 | """Test the shopping lens bahavior.""" | 21 | """Test the shopping scope bahavior.""" |
1705 | 22 | 22 | ||
1706 | 23 | def setUp(self): | 23 | def setUp(self): |
1708 | 24 | super(ShoppingLensTests, self).setUp() | 24 | super(ShoppingScopeTests, self).setUp() |
1709 | 25 | try: | 25 | try: |
1710 | 26 | urllib2.urlopen("http://www.google.com", timeout=2) | 26 | urllib2.urlopen("http://www.google.com", timeout=2) |
1711 | 27 | except urllib2.URLError, e: | 27 | except urllib2.URLError, e: |
1712 | 28 | self.skip("Skipping test, no internet connection") | 28 | self.skip("Skipping test, no internet connection") |
1714 | 29 | gettext.install("unity-lens-shopping") | 29 | gettext.install("unity-scope-shopping") |
1715 | 30 | 30 | ||
1716 | 31 | def tearDown(self): | 31 | def tearDown(self): |
1717 | 32 | self.unity.dash.ensure_hidden() | 32 | self.unity.dash.ensure_hidden() |
1719 | 33 | super(ShoppingLensTests, self).tearDown() | 33 | super(ShoppingScopeTests, self).tearDown() |
1720 | 34 | 34 | ||
1723 | 35 | def test_no_results_in_home_lens_if_empty_search(self): | 35 | def test_no_results_in_home_scope_if_empty_search(self): |
1724 | 36 | """Test that the home lens contains no results if the search bar is empty.""" | 36 | """Test that the home scope contains no results if the search bar is empty.""" |
1725 | 37 | self.unity.dash.ensure_visible() | 37 | self.unity.dash.ensure_visible() |
1727 | 38 | lens = self.unity.dash.get_current_lens() | 38 | scope = self.unity.dash.get_current_scope() |
1728 | 39 | 39 | ||
1730 | 40 | results_category = lens.get_category_by_name(_("More suggestions")) | 40 | results_category = scope.get_category_by_name(_("More suggestions")) |
1731 | 41 | refresh_results_fn = lambda: len(results_category.get_results()) | 41 | refresh_results_fn = lambda: len(results_category.get_results()) |
1732 | 42 | self.assertThat(refresh_results_fn, Eventually(Equals(0))) | 42 | self.assertThat(refresh_results_fn, Eventually(Equals(0))) |
1733 | 43 | 43 | ||
1736 | 44 | def test_home_lens_has_shopping_results(self): | 44 | def test_home_scope_has_shopping_results(self): |
1737 | 45 | """Test that the home lens contains results.""" | 45 | """Test that the home scope contains results.""" |
1738 | 46 | self.unity.dash.ensure_visible() | 46 | self.unity.dash.ensure_visible() |
1740 | 47 | lens = self.unity.dash.get_current_lens() | 47 | scope = self.unity.dash.get_current_scope() |
1741 | 48 | 48 | ||
1742 | 49 | self.keyboard.type("playstation") | 49 | self.keyboard.type("playstation") |
1744 | 50 | results_category = lens.get_category_by_name(_("More suggestions")) | 50 | results_category = scope.get_category_by_name(_("More suggestions")) |
1745 | 51 | 51 | ||
1746 | 52 | refresh_results_fn = lambda: len(results_category.get_results()) | 52 | refresh_results_fn = lambda: len(results_category.get_results()) |
1747 | 53 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) | 53 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) |
1748 | 54 | 54 | ||
1753 | 55 | def test_application_lens_has_shopping_results(self): | 55 | def test_application_scope_has_shopping_results(self): |
1754 | 56 | """Test that the application lens contains results.""" | 56 | """Test that the application scope contains results.""" |
1755 | 57 | self.unity.dash.reveal_application_lens() | 57 | self.unity.dash.reveal_application_scope() |
1756 | 58 | lens = self.unity.dash.get_current_lens() | 58 | scope = self.unity.dash.get_current_scope() |
1757 | 59 | 59 | ||
1758 | 60 | self.keyboard.type("Text Editor") | 60 | self.keyboard.type("Text Editor") |
1760 | 61 | results_category = lens.get_category_by_name(_("More suggestions")) | 61 | results_category = scope.get_category_by_name(_("More suggestions")) |
1761 | 62 | 62 | ||
1762 | 63 | refresh_results_fn = lambda: len(results_category.get_results()) | 63 | refresh_results_fn = lambda: len(results_category.get_results()) |
1763 | 64 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) | 64 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) |
1764 | 65 | 65 | ||
1769 | 66 | def test_music_lens_has_shopping_results(self): | 66 | def test_music_scope_has_shopping_results(self): |
1770 | 67 | """Test that the music lens contains results.""" | 67 | """Test that the music scope contains results.""" |
1771 | 68 | self.unity.dash.reveal_music_lens() | 68 | self.unity.dash.reveal_music_scope() |
1772 | 69 | lens = self.unity.dash.get_current_lens() | 69 | scope = self.unity.dash.get_current_scope() |
1773 | 70 | 70 | ||
1774 | 71 | self.keyboard.type("megadeth") | 71 | self.keyboard.type("megadeth") |
1776 | 72 | results_category = lens.get_category_by_name(_("More suggestions")) | 72 | results_category = scope.get_category_by_name(_("More suggestions")) |
1777 | 73 | 73 | ||
1778 | 74 | refresh_results_fn = lambda: len(results_category.get_results()) | 74 | refresh_results_fn = lambda: len(results_category.get_results()) |
1779 | 75 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) | 75 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) |
1780 | 76 | 76 | ||
1783 | 77 | def test_preview_works_with_shopping_lens(self): | 77 | def test_preview_works_with_shopping_scope(self): |
1784 | 78 | """This test shows the dash preview works with shopping lens results.""" | 78 | """This test shows the dash preview works with shopping scope results.""" |
1785 | 79 | self.unity.dash.ensure_visible() | 79 | self.unity.dash.ensure_visible() |
1787 | 80 | lens = self.unity.dash.get_current_lens() | 80 | scope = self.unity.dash.get_current_scope() |
1788 | 81 | 81 | ||
1789 | 82 | self.keyboard.type("playstation") | 82 | self.keyboard.type("playstation") |
1791 | 83 | results_category = lens.get_category_by_name(_("More suggestions")) | 83 | results_category = scope.get_category_by_name(_("More suggestions")) |
1792 | 84 | 84 | ||
1793 | 85 | refresh_results_fn = lambda: len(results_category.get_results()) | 85 | refresh_results_fn = lambda: len(results_category.get_results()) |
1794 | 86 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) | 86 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(1))) |
1795 | @@ -90,15 +90,15 @@ | |||
1796 | 90 | 90 | ||
1797 | 91 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) | 91 | self.assertThat(self.unity.dash.preview_displaying, Eventually(Equals(True))) |
1798 | 92 | 92 | ||
1801 | 93 | def test_shopping_lens_preview_navigate_right(self): | 93 | def test_shopping_scope_preview_navigate_right(self): |
1802 | 94 | """This test shows that shopping lens results can open previews, | 94 | """This test shows that shopping scope results can open previews, |
1803 | 95 | then move to the next shopping result. | 95 | then move to the next shopping result. |
1804 | 96 | """ | 96 | """ |
1805 | 97 | self.unity.dash.ensure_visible() | 97 | self.unity.dash.ensure_visible() |
1807 | 98 | lens = self.unity.dash.get_current_lens() | 98 | scope = self.unity.dash.get_current_scope() |
1808 | 99 | 99 | ||
1809 | 100 | self.keyboard.type("playstation") | 100 | self.keyboard.type("playstation") |
1811 | 101 | results_category = lens.get_category_by_name(_("More suggestions")) | 101 | results_category = scope.get_category_by_name(_("More suggestions")) |
1812 | 102 | 102 | ||
1813 | 103 | refresh_results_fn = lambda: len(results_category.get_results()) | 103 | refresh_results_fn = lambda: len(results_category.get_results()) |
1814 | 104 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(2))) | 104 | self.assertThat(refresh_results_fn, Eventually(GreaterThan(2))) |
1815 | 105 | 105 | ||
1816 | === added directory 'tests/data/unity' | |||
1817 | === added directory 'tests/data/unity/scopes' | |||
1818 | === added file 'tests/data/unity/scopes/testscope1.scope' | |||
1819 | --- tests/data/unity/scopes/testscope1.scope 1970-01-01 00:00:00 +0000 | |||
1820 | +++ tests/data/unity/scopes/testscope1.scope 2013-03-21 14:03:22 +0000 | |||
1821 | @@ -0,0 +1,13 @@ | |||
1822 | 1 | [Scope] | ||
1823 | 2 | DBusName=com.canonical.Unity.Test.Scope | ||
1824 | 3 | DBusPath=/com/canonical/unity/scope/testscope1 | ||
1825 | 4 | Icon=/usr/share/unity/6/icon-sub1.svg | ||
1826 | 5 | RequiredMetadata= | ||
1827 | 6 | OptionalMetadata= | ||
1828 | 7 | Keywords=misc; | ||
1829 | 8 | Type=varia | ||
1830 | 9 | QueryPattern=^@ | ||
1831 | 10 | Name=TestScope1 | ||
1832 | 11 | Description=Find various stuff 1 | ||
1833 | 12 | SearchHint=Search stuff 1 | ||
1834 | 13 | Shortcut=q | ||
1835 | 0 | 14 | ||
1836 | === added file 'tests/data/unity/scopes/testscope2.scope' | |||
1837 | --- tests/data/unity/scopes/testscope2.scope 1970-01-01 00:00:00 +0000 | |||
1838 | +++ tests/data/unity/scopes/testscope2.scope 2013-03-21 14:03:22 +0000 | |||
1839 | @@ -0,0 +1,13 @@ | |||
1840 | 1 | [Scope] | ||
1841 | 2 | DBusName=com.canonical.Unity.Test.Scope | ||
1842 | 3 | DBusPath=/com/canonical/unity/scope/testscope2 | ||
1843 | 4 | Icon=/usr/share/unity/6/icon-sub2.svg | ||
1844 | 5 | RequiredMetadata= | ||
1845 | 6 | OptionalMetadata= | ||
1846 | 7 | Keywords=misc; | ||
1847 | 8 | Type=varia | ||
1848 | 9 | QueryPattern=^@ | ||
1849 | 10 | Name=TestScope2 | ||
1850 | 11 | Description=Find various stuff 2 | ||
1851 | 12 | SearchHint=Search stuff 2 | ||
1852 | 13 | Shortcut=w | ||
1853 | 0 | 14 | ||
1854 | === added file 'tests/data/unity/scopes/testscope3.scope' | |||
1855 | --- tests/data/unity/scopes/testscope3.scope 1970-01-01 00:00:00 +0000 | |||
1856 | +++ tests/data/unity/scopes/testscope3.scope 2013-03-21 14:03:22 +0000 | |||
1857 | @@ -0,0 +1,13 @@ | |||
1858 | 1 | [Scope] | ||
1859 | 2 | DBusName=com.canonical.Unity.Test.Scope | ||
1860 | 3 | DBusPath=/com/canonical/unity/scope/testscope3 | ||
1861 | 4 | Icon=/usr/share/unity/6/icon-sub3.svg | ||
1862 | 5 | RequiredMetadata= | ||
1863 | 6 | OptionalMetadata= | ||
1864 | 7 | Keywords=misc; | ||
1865 | 8 | Type=varia | ||
1866 | 9 | QueryPattern=^@ | ||
1867 | 10 | Name=TestScope3 | ||
1868 | 11 | Description=Find various stuff 3 | ||
1869 | 12 | SearchHint=Search stuff 3 | ||
1870 | 13 | Shortcut=e | ||
1871 | 0 | 14 | ||
1872 | === added file 'tests/data/unity/scopes/testscope4.scope' | |||
1873 | --- tests/data/unity/scopes/testscope4.scope 1970-01-01 00:00:00 +0000 | |||
1874 | +++ tests/data/unity/scopes/testscope4.scope 2013-03-21 14:03:22 +0000 | |||
1875 | @@ -0,0 +1,13 @@ | |||
1876 | 1 | [Scope] | ||
1877 | 2 | DBusName=com.canonical.Unity.Test.Scope | ||
1878 | 3 | DBusPath=/com/canonical/unity/scope/testscope4 | ||
1879 | 4 | Icon=/usr/share/unity/6/icon-sub4.svg | ||
1880 | 5 | RequiredMetadata= | ||
1881 | 6 | OptionalMetadata= | ||
1882 | 7 | Keywords=misc; | ||
1883 | 8 | Type=varia | ||
1884 | 9 | QueryPattern=^@ | ||
1885 | 10 | Name=TestScope4 | ||
1886 | 11 | Description=Find various stuff 4 | ||
1887 | 12 | SearchHint=Search stuff 4 | ||
1888 | 13 | Shortcut=r | ||
1889 | 0 | 14 | ||
1890 | === added directory 'tests/data/unity/sounds' | |||
1891 | === added file 'tests/data/unity/sounds/brownnoise.mp3' | |||
1892 | 1 | Binary files tests/data/unity/sounds/brownnoise.mp3 1970-01-01 00:00:00 +0000 and tests/data/unity/sounds/brownnoise.mp3 2013-03-21 14:03:22 +0000 differ | 15 | Binary files tests/data/unity/sounds/brownnoise.mp3 1970-01-01 00:00:00 +0000 and tests/data/unity/sounds/brownnoise.mp3 2013-03-21 14:03:22 +0000 differ |
1893 | === added file 'tests/data/unity/sounds/pinknoise.mp3' | |||
1894 | 2 | Binary files tests/data/unity/sounds/pinknoise.mp3 1970-01-01 00:00:00 +0000 and tests/data/unity/sounds/pinknoise.mp3 2013-03-21 14:03:22 +0000 differ | 16 | Binary files tests/data/unity/sounds/pinknoise.mp3 1970-01-01 00:00:00 +0000 and tests/data/unity/sounds/pinknoise.mp3 2013-03-21 14:03:22 +0000 differ |
1895 | === added file 'tests/data/unity/sounds/whitenoise.mp3' | |||
1896 | 3 | Binary files tests/data/unity/sounds/whitenoise.mp3 1970-01-01 00:00:00 +0000 and tests/data/unity/sounds/whitenoise.mp3 2013-03-21 14:03:22 +0000 differ | 17 | Binary files tests/data/unity/sounds/whitenoise.mp3 1970-01-01 00:00:00 +0000 and tests/data/unity/sounds/whitenoise.mp3 2013-03-21 14:03:22 +0000 differ |
1897 | === modified file 'tests/test_categories.cpp' | |||
1898 | --- tests/test_categories.cpp 2013-03-12 13:49:41 +0000 | |||
1899 | +++ tests/test_categories.cpp 2013-03-21 14:03:22 +0000 | |||
1900 | @@ -13,6 +13,7 @@ | |||
1901 | 13 | { | 13 | { |
1902 | 14 | 14 | ||
1903 | 15 | static const string swarm_name = "com.canonical.test.categoriesmodel"; | 15 | static const string swarm_name = "com.canonical.test.categoriesmodel"; |
1904 | 16 | static const string swarm_name_changing = "com.canonical.test.categoriesmodel_changing"; | ||
1905 | 16 | static const unsigned int n_rows = 5; | 17 | static const unsigned int n_rows = 5; |
1906 | 17 | 18 | ||
1907 | 18 | static void WaitForSynchronize(Categories& model) | 19 | static void WaitForSynchronize(Categories& model) |
1908 | @@ -46,12 +47,17 @@ | |||
1909 | 46 | { | 47 | { |
1910 | 47 | Category adaptor = model.RowAtIndex(i); | 48 | Category adaptor = model.RowAtIndex(i); |
1911 | 48 | 49 | ||
1915 | 49 | unity::glib::String tmp(g_strdup_printf("Category %d", i)); | 50 | unity::glib::String tmp(g_strdup_printf("cat%d", i)); |
1916 | 50 | string value = tmp.Str(); | 51 | string id = tmp.Str(); |
1917 | 51 | EXPECT_EQ(adaptor.name(), value); | 52 | |
1918 | 53 | unity::glib::String tmp2(g_strdup_printf("Category %d", i)); | ||
1919 | 54 | string name = tmp2.Str(); | ||
1920 | 55 | |||
1921 | 56 | EXPECT_EQ(adaptor.id(), id); | ||
1922 | 57 | EXPECT_EQ(adaptor.name(), name); | ||
1923 | 52 | EXPECT_EQ(adaptor.icon_hint(), "gtk-apply"); | 58 | EXPECT_EQ(adaptor.icon_hint(), "gtk-apply"); |
1924 | 59 | EXPECT_EQ(adaptor.renderer_name(), "grid"); | ||
1925 | 53 | EXPECT_EQ(adaptor.index(), i); | 60 | EXPECT_EQ(adaptor.index(), i); |
1926 | 54 | EXPECT_EQ(adaptor.renderer_name(), "grid"); | ||
1927 | 55 | } | 61 | } |
1928 | 56 | } | 62 | } |
1929 | 57 | 63 | ||
1930 | @@ -82,4 +88,80 @@ | |||
1931 | 82 | } | 88 | } |
1932 | 83 | } | 89 | } |
1933 | 84 | 90 | ||
1934 | 91 | // We're testing the model's ability to store and retrieve random pointers | ||
1935 | 92 | TEST(TestCategories, TestOnRowChanged) | ||
1936 | 93 | { | ||
1937 | 94 | Categories model; | ||
1938 | 95 | model.swarm_name = swarm_name_changing; | ||
1939 | 96 | WaitForSynchronize(model); | ||
1940 | 97 | |||
1941 | 98 | bool changed = false; | ||
1942 | 99 | model.category_changed.connect([&changed] (Category const&) { changed = true;}); | ||
1943 | 100 | Utils::WaitUntilMSec(changed, | ||
1944 | 101 | 2000, | ||
1945 | 102 | []() { return g_strdup_printf("Did not detect row change from %s.", swarm_name_changing.c_str()); }); | ||
1946 | 103 | } | ||
1947 | 104 | |||
1948 | 105 | |||
1949 | 106 | // We're testing the model's ability to store and retrieve random pointers | ||
1950 | 107 | TEST(TestCategories, TestOnRowAdded) | ||
1951 | 108 | { | ||
1952 | 109 | Categories model; | ||
1953 | 110 | model.swarm_name = swarm_name_changing; | ||
1954 | 111 | WaitForSynchronize(model); | ||
1955 | 112 | |||
1956 | 113 | bool added = false; | ||
1957 | 114 | model.category_added.connect([&added] (Category const&) { added = true;}); | ||
1958 | 115 | Utils::WaitUntilMSec(added, | ||
1959 | 116 | 2000, | ||
1960 | 117 | []() { return g_strdup_printf("Did not detect row add %s.", swarm_name_changing.c_str()); }); | ||
1961 | 118 | } | ||
1962 | 119 | |||
1963 | 120 | // We're testing the model's ability to store and retrieve random pointers | ||
1964 | 121 | TEST(TestCategories, TestOnRowRemoved) | ||
1965 | 122 | { | ||
1966 | 123 | Categories model; | ||
1967 | 124 | model.swarm_name = swarm_name_changing; | ||
1968 | 125 | WaitForSynchronize(model); | ||
1969 | 126 | |||
1970 | 127 | bool removed = false; | ||
1971 | 128 | model.category_removed.connect([&removed] (Category const&) { removed = true;}); | ||
1972 | 129 | Utils::WaitUntilMSec(removed, | ||
1973 | 130 | 2000, | ||
1974 | 131 | []() { return g_strdup_printf("Did not detect row remove %s.", swarm_name_changing.c_str()); }); | ||
1975 | 132 | } | ||
1976 | 133 | |||
1977 | 134 | TEST(TestCategories, TestCategoryCopy) | ||
1978 | 135 | { | ||
1979 | 136 | Categories model; | ||
1980 | 137 | model.swarm_name = swarm_name_changing; | ||
1981 | 138 | WaitForSynchronize(model); | ||
1982 | 139 | |||
1983 | 140 | Category category = model.RowAtIndex(0); | ||
1984 | 141 | Category category_2(category); | ||
1985 | 142 | |||
1986 | 143 | EXPECT_EQ(category.id(), category_2.id()); | ||
1987 | 144 | EXPECT_EQ(category.name(), category_2.name()); | ||
1988 | 145 | EXPECT_EQ(category.icon_hint(), category_2.icon_hint()); | ||
1989 | 146 | EXPECT_EQ(category.renderer_name(), category_2.renderer_name()); | ||
1990 | 147 | EXPECT_EQ(category.index(), category_2.index()); | ||
1991 | 148 | } | ||
1992 | 149 | |||
1993 | 150 | TEST(TestCategories, TestCategoryEqual) | ||
1994 | 151 | { | ||
1995 | 152 | Categories model; | ||
1996 | 153 | model.swarm_name = swarm_name_changing; | ||
1997 | 154 | WaitForSynchronize(model); | ||
1998 | 155 | |||
1999 | 156 | Category category = model.RowAtIndex(0); | ||
2000 | 157 | Category category_2(NULL, NULL, NULL); | ||
2001 | 158 | category_2 = category; | ||
2002 | 159 | |||
2003 | 160 | EXPECT_EQ(category.id(), category_2.id()); | ||
2004 | 161 | EXPECT_EQ(category.name(), category_2.name()); | ||
2005 | 162 | EXPECT_EQ(category.icon_hint(), category_2.icon_hint()); | ||
2006 | 163 | EXPECT_EQ(category.renderer_name(), category_2.renderer_name()); | ||
2007 | 164 | EXPECT_EQ(category.index(), category_2.index()); | ||
2008 | 165 | } | ||
2009 | 166 | |||
2010 | 85 | } | 167 | } |
2011 | 86 | 168 | ||
2012 | === removed file 'tests/test_dash_view.cpp' | |||
2013 | --- tests/test_dash_view.cpp 2013-03-12 21:45:58 +0000 | |||
2014 | +++ tests/test_dash_view.cpp 1970-01-01 00:00:00 +0000 | |||
2015 | @@ -1,67 +0,0 @@ | |||
2016 | 1 | /* | ||
2017 | 2 | * Copyright (C) 2013 Canonical Ltd | ||
2018 | 3 | * | ||
2019 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2020 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2021 | 6 | * published by the Free Software Foundation. | ||
2022 | 7 | * | ||
2023 | 8 | * This program is distributed in the hope that it will be useful, | ||
2024 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2025 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2026 | 11 | * GNU General Public License for more details. | ||
2027 | 12 | * | ||
2028 | 13 | * You should have received a copy of the GNU General Public License | ||
2029 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2030 | 15 | * | ||
2031 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
2032 | 17 | */ | ||
2033 | 18 | |||
2034 | 19 | #include <gmock/gmock.h> | ||
2035 | 20 | |||
2036 | 21 | #include <UnityCore/Lenses.h> | ||
2037 | 22 | |||
2038 | 23 | #include "ApplicationStarter.h" | ||
2039 | 24 | #include "DashView.h" | ||
2040 | 25 | #include "unity-shared/DashStyle.h" | ||
2041 | 26 | #include "unity-shared/PanelStyle.h" | ||
2042 | 27 | #include "unity-shared/UnitySettings.h" | ||
2043 | 28 | |||
2044 | 29 | #include "mock-lenses.h" | ||
2045 | 30 | |||
2046 | 31 | using namespace unity::dash; | ||
2047 | 32 | using namespace testing; | ||
2048 | 33 | |||
2049 | 34 | namespace { | ||
2050 | 35 | |||
2051 | 36 | struct MockApplicationStarter : public unity::ApplicationStarter { | ||
2052 | 37 | typedef std::shared_ptr<MockApplicationStarter> Ptr; | ||
2053 | 38 | MOCK_METHOD2(Launch, bool(std::string const&, Time)); | ||
2054 | 39 | }; | ||
2055 | 40 | |||
2056 | 41 | |||
2057 | 42 | struct TestDashView : public testing::Test { | ||
2058 | 43 | TestDashView() | ||
2059 | 44 | : lenses_(std::make_shared<testmocks::ThreeMockTestLenses>()) | ||
2060 | 45 | , application_starter_(std::make_shared<MockApplicationStarter>()) | ||
2061 | 46 | , dash_view_(new DashView(lenses_, application_starter_)) | ||
2062 | 47 | {} | ||
2063 | 48 | |||
2064 | 49 | unity::Settings unity_settings_; | ||
2065 | 50 | Style dash_style; | ||
2066 | 51 | unity::panel::Style panel_style; | ||
2067 | 52 | Lenses::Ptr lenses_; | ||
2068 | 53 | MockApplicationStarter::Ptr application_starter_; | ||
2069 | 54 | nux::ObjectPtr<DashView> dash_view_; | ||
2070 | 55 | }; | ||
2071 | 56 | |||
2072 | 57 | |||
2073 | 58 | TEST_F(TestDashView, LensActivatedSignal) | ||
2074 | 59 | { | ||
2075 | 60 | EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1); | ||
2076 | 61 | lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:application://uri", NOT_HANDLED, Lens::Hints()); | ||
2077 | 62 | |||
2078 | 63 | EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1); | ||
2079 | 64 | lenses_->GetLensAtIndex(0)->activated.emit("0xaabbcc:unity-runner://uri", NOT_HANDLED, Lens::Hints()); | ||
2080 | 65 | } | ||
2081 | 66 | |||
2082 | 67 | } | ||
2083 | 68 | 0 | ||
2084 | === added file 'tests/test_dashview.cpp' | |||
2085 | --- tests/test_dashview.cpp 1970-01-01 00:00:00 +0000 | |||
2086 | +++ tests/test_dashview.cpp 2013-03-21 14:03:22 +0000 | |||
2087 | @@ -0,0 +1,116 @@ | |||
2088 | 1 | /* | ||
2089 | 2 | * Copyright 2013 Canonical Ltd. | ||
2090 | 3 | * | ||
2091 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2092 | 5 | * under the terms of the GNU Lesser General Public License version 3, as | ||
2093 | 6 | * published by the Free Software Foundation. | ||
2094 | 7 | * | ||
2095 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2096 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2097 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
2098 | 11 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
2099 | 12 | * License for more details. | ||
2100 | 13 | * | ||
2101 | 14 | * You should have received a copy of both the GNU Lesser General Public | ||
2102 | 15 | * License version 3 along with this program. If not, see | ||
2103 | 16 | * <http://www.gnu.org/licenses/> | ||
2104 | 17 | * | ||
2105 | 18 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
2106 | 19 | * | ||
2107 | 20 | */ | ||
2108 | 21 | |||
2109 | 22 | #include <list> | ||
2110 | 23 | |||
2111 | 24 | #include <gtest/gtest.h> | ||
2112 | 25 | #include <gmock/gmock.h> | ||
2113 | 26 | |||
2114 | 27 | #include <Nux/Nux.h> | ||
2115 | 28 | #include <NuxCore/ObjectPtr.h> | ||
2116 | 29 | |||
2117 | 30 | #include "dash/DashView.h" | ||
2118 | 31 | #include "dash/ApplicationStarter.h" | ||
2119 | 32 | #include "unity-shared/DashStyle.h" | ||
2120 | 33 | #include "unity-shared/PanelStyle.h" | ||
2121 | 34 | #include "unity-shared/UnitySettings.h" | ||
2122 | 35 | |||
2123 | 36 | #include "test_mock_scope.h" | ||
2124 | 37 | #include "test_utils.h" | ||
2125 | 38 | |||
2126 | 39 | using namespace unity; | ||
2127 | 40 | using namespace unity::dash; | ||
2128 | 41 | using namespace testing; | ||
2129 | 42 | |||
2130 | 43 | namespace unity | ||
2131 | 44 | { | ||
2132 | 45 | namespace dash | ||
2133 | 46 | { | ||
2134 | 47 | |||
2135 | 48 | namespace | ||
2136 | 49 | { | ||
2137 | 50 | const char* scopes_default[] = { "testscope1.scope", | ||
2138 | 51 | "testscope2.scope", | ||
2139 | 52 | "testscope3.scope", | ||
2140 | 53 | "testscope4.scope", | ||
2141 | 54 | NULL }; | ||
2142 | 55 | |||
2143 | 56 | } | ||
2144 | 57 | |||
2145 | 58 | struct MockApplicationStarter : public unity::ApplicationStarter { | ||
2146 | 59 | typedef std::shared_ptr<MockApplicationStarter> Ptr; | ||
2147 | 60 | MOCK_METHOD2(Launch, bool(std::string const&, Time)); | ||
2148 | 61 | }; | ||
2149 | 62 | |||
2150 | 63 | class TestDashView : public ::testing::Test | ||
2151 | 64 | { | ||
2152 | 65 | public: | ||
2153 | 66 | TestDashView() | ||
2154 | 67 | : application_starter_(std::make_shared<MockApplicationStarter>()) | ||
2155 | 68 | {} | ||
2156 | 69 | |||
2157 | 70 | virtual void SetUp() { Utils::init_gsettings_test_environment(); } | ||
2158 | 71 | virtual void TearDown() { Utils::reset_gsettings_test_environment(); } | ||
2159 | 72 | |||
2160 | 73 | class MockDashView : public DashView | ||
2161 | 74 | { | ||
2162 | 75 | public: | ||
2163 | 76 | MockDashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter) | ||
2164 | 77 | : DashView(scopes, application_starter) | ||
2165 | 78 | { | ||
2166 | 79 | } | ||
2167 | 80 | |||
2168 | 81 | using DashView::scope_views_; | ||
2169 | 82 | }; | ||
2170 | 83 | |||
2171 | 84 | protected: | ||
2172 | 85 | Settings unity_settings_; | ||
2173 | 86 | dash::Style dash_style_; | ||
2174 | 87 | panel::Style panel_style_; | ||
2175 | 88 | MockApplicationStarter::Ptr application_starter_; | ||
2176 | 89 | }; | ||
2177 | 90 | |||
2178 | 91 | TEST_F(TestDashView, TestConstruct) | ||
2179 | 92 | { | ||
2180 | 93 | Scopes::Ptr scopes(new MockGSettingsScopes(scopes_default)); | ||
2181 | 94 | nux::ObjectPtr<MockDashView> view(new MockDashView(scopes, application_starter_)); | ||
2182 | 95 | |||
2183 | 96 | EXPECT_EQ(view->scope_views_.size(), 4) << "Error: Incorrect number of scope views (" << view->scope_views_.size() << " != 4)"; | ||
2184 | 97 | } | ||
2185 | 98 | |||
2186 | 99 | |||
2187 | 100 | TEST_F(TestDashView, LensActivatedSignal) | ||
2188 | 101 | { | ||
2189 | 102 | Scopes::Ptr scopes(new MockGSettingsScopes(scopes_default)); | ||
2190 | 103 | nux::ObjectPtr<MockDashView> view(new MockDashView(scopes, application_starter_)); | ||
2191 | 104 | |||
2192 | 105 | LocalResult result; | ||
2193 | 106 | result.uri = "application://uri"; | ||
2194 | 107 | |||
2195 | 108 | EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1); | ||
2196 | 109 | scopes->GetScopeAtIndex(0)->activated.emit(result, NOT_HANDLED, glib::HintsMap()); | ||
2197 | 110 | |||
2198 | 111 | EXPECT_CALL(*application_starter_, Launch("uri", _)).Times(1); | ||
2199 | 112 | scopes->GetScopeAtIndex(0)->activated.emit(result, NOT_HANDLED, glib::HintsMap()); | ||
2200 | 113 | } | ||
2201 | 114 | |||
2202 | 115 | } | ||
2203 | 116 | } | ||
2204 | 0 | 117 | ||
2205 | === modified file 'tests/test_dashview_impl.cpp' | |||
2206 | --- tests/test_dashview_impl.cpp 2013-02-21 10:03:21 +0000 | |||
2207 | +++ tests/test_dashview_impl.cpp 2013-03-21 14:03:22 +0000 | |||
2208 | @@ -27,52 +27,52 @@ | |||
2209 | 27 | namespace | 27 | namespace |
2210 | 28 | { | 28 | { |
2211 | 29 | 29 | ||
2213 | 30 | TEST(TestParseLensFilter, TestSimpleString) | 30 | TEST(TestParseScopeFilter, TestSimpleString) |
2214 | 31 | { | 31 | { |
2216 | 32 | LensFilter filter = parse_lens_uri("simple"); | 32 | ScopeFilter filter = parse_scope_uri("simple"); |
2217 | 33 | 33 | ||
2218 | 34 | EXPECT_THAT(filter.id, Eq("simple")); | 34 | EXPECT_THAT(filter.id, Eq("simple")); |
2219 | 35 | EXPECT_TRUE(filter.filters.empty()); | 35 | EXPECT_TRUE(filter.filters.empty()); |
2220 | 36 | } | 36 | } |
2221 | 37 | 37 | ||
2223 | 38 | TEST(TestParseLensFilter, TestNonFilterParameter) | 38 | TEST(TestParseScopeFilter, TestNonFilterParameter) |
2224 | 39 | { | 39 | { |
2225 | 40 | // Only params that start with "filter_" are added. | 40 | // Only params that start with "filter_" are added. |
2227 | 41 | LensFilter filter = parse_lens_uri("uri?param=test"); | 41 | ScopeFilter filter = parse_scope_uri("uri?param=test"); |
2228 | 42 | 42 | ||
2229 | 43 | EXPECT_THAT(filter.id, Eq("uri")); | 43 | EXPECT_THAT(filter.id, Eq("uri")); |
2230 | 44 | EXPECT_TRUE(filter.filters.empty()); | 44 | EXPECT_TRUE(filter.filters.empty()); |
2231 | 45 | } | 45 | } |
2232 | 46 | 46 | ||
2234 | 47 | TEST(TestParseLensFilter, TestSingleParameter) | 47 | TEST(TestParseScopeFilter, TestSingleParameter) |
2235 | 48 | { | 48 | { |
2237 | 49 | LensFilter filter = parse_lens_uri("uri?filter_param=test"); | 49 | ScopeFilter filter = parse_scope_uri("uri?filter_param=test"); |
2238 | 50 | 50 | ||
2239 | 51 | EXPECT_THAT(filter.id, Eq("uri")); | 51 | EXPECT_THAT(filter.id, Eq("uri")); |
2240 | 52 | EXPECT_THAT(filter.filters.size(), Eq(1)); | 52 | EXPECT_THAT(filter.filters.size(), Eq(1)); |
2241 | 53 | EXPECT_THAT(filter.filters["param"], Eq("test")); | 53 | EXPECT_THAT(filter.filters["param"], Eq("test")); |
2242 | 54 | } | 54 | } |
2243 | 55 | 55 | ||
2245 | 56 | TEST(TestParseLensFilter, TestNoEquals) | 56 | TEST(TestParseScopeFilter, TestNoEquals) |
2246 | 57 | { | 57 | { |
2248 | 58 | LensFilter filter = parse_lens_uri("uri?filter_param"); | 58 | ScopeFilter filter = parse_scope_uri("uri?filter_param"); |
2249 | 59 | 59 | ||
2250 | 60 | EXPECT_THAT(filter.id, Eq("uri")); | 60 | EXPECT_THAT(filter.id, Eq("uri")); |
2251 | 61 | EXPECT_TRUE(filter.filters.empty()); | 61 | EXPECT_TRUE(filter.filters.empty()); |
2252 | 62 | } | 62 | } |
2253 | 63 | 63 | ||
2255 | 64 | TEST(TestParseLensFilter, TestEmbeddedEquals) | 64 | TEST(TestParseScopeFilter, TestEmbeddedEquals) |
2256 | 65 | { | 65 | { |
2258 | 66 | LensFilter filter = parse_lens_uri("uri?filter_param=a=b"); | 66 | ScopeFilter filter = parse_scope_uri("uri?filter_param=a=b"); |
2259 | 67 | 67 | ||
2260 | 68 | EXPECT_THAT(filter.id, Eq("uri")); | 68 | EXPECT_THAT(filter.id, Eq("uri")); |
2261 | 69 | EXPECT_THAT(filter.filters.size(), Eq(1)); | 69 | EXPECT_THAT(filter.filters.size(), Eq(1)); |
2262 | 70 | EXPECT_THAT(filter.filters["param"], Eq("a=b")); | 70 | EXPECT_THAT(filter.filters["param"], Eq("a=b")); |
2263 | 71 | } | 71 | } |
2264 | 72 | 72 | ||
2266 | 73 | TEST(TestParseLensFilter, TestMultipleParameters) | 73 | TEST(TestParseScopeFilter, TestMultipleParameters) |
2267 | 74 | { | 74 | { |
2269 | 75 | LensFilter filter = parse_lens_uri("uri?filter_param1=first&filter_param2=second"); | 75 | ScopeFilter filter = parse_scope_uri("uri?filter_param1=first&filter_param2=second"); |
2270 | 76 | 76 | ||
2271 | 77 | EXPECT_THAT(filter.id, Eq("uri")); | 77 | EXPECT_THAT(filter.id, Eq("uri")); |
2272 | 78 | EXPECT_THAT(filter.filters.size(), Eq(2)); | 78 | EXPECT_THAT(filter.filters.size(), Eq(2)); |
2273 | 79 | 79 | ||
2274 | === modified file 'tests/test_dbus_indicators.cpp' | |||
2275 | --- tests/test_dbus_indicators.cpp 2013-02-21 10:03:21 +0000 | |||
2276 | +++ tests/test_dbus_indicators.cpp 2013-03-21 14:03:22 +0000 | |||
2277 | @@ -39,7 +39,7 @@ | |||
2278 | 39 | dbus_indicators.reset(new DBusIndicatorsTest ()); | 39 | dbus_indicators.reset(new DBusIndicatorsTest ()); |
2279 | 40 | 40 | ||
2280 | 41 | // wait until the dbus indicator has connected to the panel service | 41 | // wait until the dbus indicator has connected to the panel service |
2282 | 42 | Utils::WaitUntil(sigc::mem_fun(*dbus_indicators, &DBusIndicatorsTest::IsConnected)); | 42 | Utils::WaitUntil(sigc::mem_fun(*dbus_indicators, &DBusIndicatorsTest::IsConnected), true, 5); |
2283 | 43 | } | 43 | } |
2284 | 44 | 44 | ||
2285 | 45 | bool TriggerResync1Sent() const | 45 | bool TriggerResync1Sent() const |
2286 | @@ -75,7 +75,7 @@ | |||
2287 | 75 | TEST_F(TestDBusIndicators, TestSync) | 75 | TEST_F(TestDBusIndicators, TestSync) |
2288 | 76 | { | 76 | { |
2289 | 77 | // wait until the dbus indicator gets any indicator from the panel service | 77 | // wait until the dbus indicator gets any indicator from the panel service |
2291 | 78 | Utils::WaitUntil(sigc::mem_fun(*dbus_indicators, &DBusIndicatorsTest::HasIndicators)); | 78 | Utils::WaitUntil(sigc::mem_fun(*dbus_indicators, &DBusIndicatorsTest::HasIndicators), true, 5); |
2292 | 79 | 79 | ||
2293 | 80 | EXPECT_EQ(dbus_indicators->GetIndicators().size(), 1); | 80 | EXPECT_EQ(dbus_indicators->GetIndicators().size(), 1); |
2294 | 81 | EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().size(), 2); | 81 | EXPECT_EQ(dbus_indicators->GetIndicators().front()->GetEntries().size(), 2); |
2295 | @@ -85,7 +85,7 @@ | |||
2296 | 85 | // Tell the service to trigger a resync and to send the entries in the reverse order | 85 | // Tell the service to trigger a resync and to send the entries in the reverse order |
2297 | 86 | CallPanelMethod("TriggerResync1"); | 86 | CallPanelMethod("TriggerResync1"); |
2298 | 87 | 87 | ||
2300 | 88 | Utils::WaitUntil(sigc::mem_fun(this, &TestDBusIndicators::TriggerResync1Sent)); | 88 | Utils::WaitUntil(sigc::mem_fun(this, &TestDBusIndicators::TriggerResync1Sent), true, 5); |
2301 | 89 | // We know the resync has been sent, but it may have not been processed | 89 | // We know the resync has been sent, but it may have not been processed |
2302 | 90 | // so do one interation of the main loop more | 90 | // so do one interation of the main loop more |
2303 | 91 | g_main_context_iteration(g_main_context_get_thread_default(), TRUE); | 91 | g_main_context_iteration(g_main_context_get_thread_default(), TRUE); |
2304 | 92 | 92 | ||
2305 | === modified file 'tests/test_desktop_utilities.cpp' | |||
2306 | --- tests/test_desktop_utilities.cpp 2012-11-06 18:19:09 +0000 | |||
2307 | +++ tests/test_desktop_utilities.cpp 2013-03-21 14:03:22 +0000 | |||
2308 | @@ -106,61 +106,73 @@ | |||
2309 | 106 | Eq("subdir1-subdir2-to.desktop")); | 106 | Eq("subdir1-subdir2-to.desktop")); |
2310 | 107 | } | 107 | } |
2311 | 108 | 108 | ||
2367 | 109 | TEST(TestDesktopUtilitiesDataDirectories, TestGetUserDataDirectory) | 109 | // We can't test this. GetUserDataDirectory uses g_get_user_data_dir which caches data dir. |
2368 | 110 | { | 110 | // If we perform a DesktopUtilities::GetUserDataDirectory(); before running this test, the test will fail, because setting the XDG_DATA_HOME |
2369 | 111 | const gchar* env = g_getenv("XDG_DATA_HOME"); | 111 | // will not change the cached value. |
2370 | 112 | std::string old_home = env ? env : ""; | 112 | |
2371 | 113 | 113 | // TEST(TestDesktopUtilitiesDataDirectories, TestGetUserDataDirectory) | |
2372 | 114 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); | 114 | // { |
2373 | 115 | 115 | // const gchar* env = g_getenv("XDG_DATA_HOME"); | |
2374 | 116 | std::string const& user_data_dir = DesktopUtilities::GetUserDataDirectory(); | 116 | // std::string old_home = env ? env : ""; |
2375 | 117 | 117 | ||
2376 | 118 | g_setenv("XDG_DATA_HOME", old_home.c_str(), TRUE); | 118 | // g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); |
2377 | 119 | 119 | ||
2378 | 120 | EXPECT_THAT(user_data_dir, Eq("UnityUserConfig")); | 120 | // std::string const& user_data_dir = DesktopUtilities::GetUserDataDirectory(); |
2379 | 121 | } | 121 | |
2380 | 122 | 122 | // g_setenv("XDG_DATA_HOME", old_home.c_str(), TRUE); | |
2381 | 123 | TEST(TestDesktopUtilitiesDataDirectories, TestGetSystemDataDirectory) | 123 | |
2382 | 124 | { | 124 | // EXPECT_THAT(user_data_dir, Eq("UnityUserConfig")); |
2383 | 125 | const gchar* env = g_getenv("XDG_DATA_DIRS"); | 125 | // } |
2384 | 126 | std::string old_dirs = env ? env : ""; | 126 | |
2385 | 127 | g_setenv("XDG_DATA_DIRS", ("dir1:dir2::dir3:dir4:"+LOCAL_DATA_DIR).c_str(), TRUE); | 127 | // We can't test this. GetSystemDataDirectories uses g_get_system_data_dirs which caches the values. |
2386 | 128 | 128 | // If we perform a DesktopUtilities::GetSystemDataDirectories(); before running this test, the test will fail, because setting the XDG_DATA_DIRS | |
2387 | 129 | std::vector<std::string> const& system_dirs = DesktopUtilities::GetSystemDataDirectories(); | 129 | // will not change the cached value. |
2388 | 130 | 130 | ||
2389 | 131 | g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); | 131 | // TEST(TestDesktopUtilitiesDataDirectories, TestGetSystemDataDirectory) |
2390 | 132 | 132 | // { | |
2391 | 133 | ASSERT_THAT(system_dirs.size(), Eq(5)); | 133 | // const gchar* env = g_getenv("XDG_DATA_DIRS"); |
2392 | 134 | EXPECT_THAT(system_dirs[0], Eq("dir1")); | 134 | // std::string old_dirs = env ? env : ""; |
2393 | 135 | EXPECT_THAT(system_dirs[1], Eq("dir2")); | 135 | // g_setenv("XDG_DATA_DIRS", ("dir1:dir2::dir3:dir4:"+LOCAL_DATA_DIR).c_str(), TRUE); |
2394 | 136 | EXPECT_THAT(system_dirs[2], Eq("dir3")); | 136 | |
2395 | 137 | EXPECT_THAT(system_dirs[3], Eq("dir4")); | 137 | // std::vector<std::string> const& system_dirs = DesktopUtilities::GetSystemDataDirectories(); |
2396 | 138 | EXPECT_THAT(system_dirs[4], Eq(LOCAL_DATA_DIR)); | 138 | |
2397 | 139 | } | 139 | // g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); |
2398 | 140 | 140 | ||
2399 | 141 | TEST(TestDesktopUtilitiesDataDirectories, TestGetDataDirectory) | 141 | // ASSERT_THAT(system_dirs.size(), Eq(5)); |
2400 | 142 | { | 142 | // EXPECT_THAT(system_dirs[0], Eq("dir1")); |
2401 | 143 | const gchar* env = g_getenv("XDG_DATA_DIRS"); | 143 | // EXPECT_THAT(system_dirs[1], Eq("dir2")); |
2402 | 144 | std::string old_dirs = env ? env : ""; | 144 | // EXPECT_THAT(system_dirs[2], Eq("dir3")); |
2403 | 145 | env = g_getenv("XDG_DATA_HOME"); | 145 | // EXPECT_THAT(system_dirs[3], Eq("dir4")); |
2404 | 146 | std::string old_home = env ? env : ""; | 146 | // EXPECT_THAT(system_dirs[4], Eq(LOCAL_DATA_DIR)); |
2405 | 147 | 147 | // } | |
2406 | 148 | g_setenv("XDG_DATA_DIRS", ("dir1:dir2::dir3:dir4:"+LOCAL_DATA_DIR).c_str(), TRUE); | 148 | |
2407 | 149 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); | 149 | // We can't test this. TestGetDataDirectory uses g_get_system_data_dirs which caches the values. |
2408 | 150 | 150 | // If we perform a DesktopUtilities::TestGetDataDirectory(); before running this test, the test will fail, because setting the XDG_DATA_DIRS or XDG_DATA_HOME | |
2409 | 151 | std::vector<std::string> const& data_dirs = DesktopUtilities::GetDataDirectories(); | 151 | // will not change the cached value. |
2410 | 152 | 152 | ||
2411 | 153 | g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); | 153 | // TEST(TestDesktopUtilitiesDataDirectories, TestGetDataDirectory) |
2412 | 154 | g_setenv("XDG_DATA_HOME", old_home.c_str(), TRUE); | 154 | // { |
2413 | 155 | 155 | // const gchar* env = g_getenv("XDG_DATA_DIRS"); | |
2414 | 156 | ASSERT_THAT(data_dirs.size(), Eq(6)); | 156 | // std::string old_dirs = env ? env : ""; |
2415 | 157 | EXPECT_THAT(data_dirs[0], Eq("dir1")); | 157 | // env = g_getenv("XDG_DATA_HOME"); |
2416 | 158 | EXPECT_THAT(data_dirs[1], Eq("dir2")); | 158 | // std::string old_home = env ? env : ""; |
2417 | 159 | EXPECT_THAT(data_dirs[2], Eq("dir3")); | 159 | |
2418 | 160 | EXPECT_THAT(data_dirs[3], Eq("dir4")); | 160 | // g_setenv("XDG_DATA_DIRS", ("dir1:dir2::dir3:dir4:"+LOCAL_DATA_DIR).c_str(), TRUE); |
2419 | 161 | EXPECT_THAT(data_dirs[4], Eq(LOCAL_DATA_DIR)); | 161 | // g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); |
2420 | 162 | EXPECT_THAT(data_dirs[5], Eq("UnityUserConfig")); | 162 | |
2421 | 163 | } | 163 | // std::vector<std::string> const& data_dirs = DesktopUtilities::GetDataDirectories(); |
2422 | 164 | |||
2423 | 165 | // g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); | ||
2424 | 166 | // g_setenv("XDG_DATA_HOME", old_home.c_str(), TRUE); | ||
2425 | 167 | |||
2426 | 168 | // ASSERT_THAT(data_dirs.size(), Eq(6)); | ||
2427 | 169 | // EXPECT_THAT(data_dirs[0], Eq("dir1")); | ||
2428 | 170 | // EXPECT_THAT(data_dirs[1], Eq("dir2")); | ||
2429 | 171 | // EXPECT_THAT(data_dirs[2], Eq("dir3")); | ||
2430 | 172 | // EXPECT_THAT(data_dirs[3], Eq("dir4")); | ||
2431 | 173 | // EXPECT_THAT(data_dirs[4], Eq(LOCAL_DATA_DIR)); | ||
2432 | 174 | // EXPECT_THAT(data_dirs[5], Eq("UnityUserConfig")); | ||
2433 | 175 | // } | ||
2434 | 164 | 176 | ||
2435 | 165 | TEST(TestDesktopUtilities, TestGetDesktopPathById) | 177 | TEST(TestDesktopUtilities, TestGetDesktopPathById) |
2436 | 166 | { | 178 | { |
2437 | 167 | 179 | ||
2438 | === modified file 'tests/test_glib_source.cpp' | |||
2439 | --- tests/test_glib_source.cpp 2013-02-21 10:03:21 +0000 | |||
2440 | +++ tests/test_glib_source.cpp 2013-03-21 14:03:22 +0000 | |||
2441 | @@ -437,7 +437,7 @@ | |||
2442 | 437 | idle.Run(&OnSourceCallbackStop); | 437 | idle.Run(&OnSourceCallbackStop); |
2443 | 438 | EXPECT_TRUE(idle.IsRunning()); | 438 | EXPECT_TRUE(idle.IsRunning()); |
2444 | 439 | 439 | ||
2446 | 440 | Utils::WaitUntilMSec([&idle] {return idle.IsRunning();}, false, 300); | 440 | Utils::WaitUntilMSec([&idle] {return idle.IsRunning();}, false, 20000); |
2447 | 441 | EXPECT_TRUE(callback_called); | 441 | EXPECT_TRUE(callback_called); |
2448 | 442 | EXPECT_EQ(callback_call_count, 1); | 442 | EXPECT_EQ(callback_call_count, 1); |
2449 | 443 | } | 443 | } |
2450 | 444 | 444 | ||
2451 | === modified file 'tests/test_glib_variant.cpp' | |||
2452 | --- tests/test_glib_variant.cpp 2013-03-12 13:31:41 +0000 | |||
2453 | +++ tests/test_glib_variant.cpp 2013-03-21 14:03:22 +0000 | |||
2454 | @@ -118,10 +118,16 @@ | |||
2455 | 118 | 118 | ||
2456 | 119 | g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}")); | 119 | g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}")); |
2457 | 120 | variant::BuilderWrapper bw (&b); | 120 | variant::BuilderWrapper bw (&b); |
2460 | 121 | bw.add ("string-key", "string-value"); | 121 | bw.add ("charstring-key", "charstring-value"); |
2461 | 122 | bw.add ("int-key", 123); | 122 | bw.add ("string-key", std::string("string-value")); |
2462 | 123 | bw.add ("gint32-key", (gint32)-1); | ||
2463 | 124 | bw.add ("guint32-key", (guint32)-2); | ||
2464 | 125 | bw.add ("gint64-key", (gint64)-3); | ||
2465 | 126 | bw.add ("guint64-key", (guint64)-4); | ||
2466 | 127 | bw.add ("float-key", (float)1.1); | ||
2467 | 128 | bw.add ("double-key", (double)2.2); | ||
2468 | 123 | bw.add ("bool-key", true); | 129 | bw.add ("bool-key", true); |
2470 | 124 | bw.add ("last", "foo"); | 130 | bw.add ("variant-key", g_variant_new_int32(123)); |
2471 | 125 | 131 | ||
2472 | 126 | GVariant *dict_variant = g_variant_builder_end (&b); | 132 | GVariant *dict_variant = g_variant_builder_end (&b); |
2473 | 127 | Variant dict (g_variant_new_tuple (&dict_variant, 1)); | 133 | Variant dict (g_variant_new_tuple (&dict_variant, 1)); |
2474 | @@ -132,10 +138,15 @@ | |||
2475 | 132 | HintsMap hints; | 138 | HintsMap hints; |
2476 | 133 | EXPECT_TRUE(dict.ASVToHints (hints)); | 139 | EXPECT_TRUE(dict.ASVToHints (hints)); |
2477 | 134 | 140 | ||
2478 | 141 | EXPECT_EQ(hints["charstring-key"].GetString(), "charstring-value"); | ||
2479 | 135 | EXPECT_EQ(hints["string-key"].GetString(), "string-value"); | 142 | EXPECT_EQ(hints["string-key"].GetString(), "string-value"); |
2481 | 136 | EXPECT_EQ(hints["int-key"].GetInt32(), 123); | 143 | EXPECT_EQ(hints["gint32-key"].GetInt32(), (gint32)-1); |
2482 | 144 | EXPECT_EQ(hints["guint32-key"].GetUInt32(), (guint32)-2); | ||
2483 | 145 | EXPECT_EQ(hints["gint64-key"].GetInt64(), (gint64)-3); | ||
2484 | 146 | EXPECT_EQ(hints["guint64-key"].GetUInt64(), (guint64)-4); | ||
2485 | 147 | EXPECT_EQ(hints["float-key"].GetFloat(), (float)1.1); | ||
2486 | 148 | EXPECT_EQ(hints["double-key"].GetDouble(), (double)2.2); | ||
2487 | 137 | EXPECT_EQ(hints["bool-key"].GetBool(), true); | 149 | EXPECT_EQ(hints["bool-key"].GetBool(), true); |
2488 | 138 | EXPECT_EQ(hints["last"].GetString(), "foo"); | ||
2489 | 139 | 150 | ||
2490 | 140 | // throw away all references to the original variant | 151 | // throw away all references to the original variant |
2491 | 141 | dict = g_variant_new_string ("bar"); | 152 | dict = g_variant_new_string ("bar"); |
2492 | @@ -144,10 +155,15 @@ | |||
2493 | 144 | EXPECT_EQ(dict.GetString(), "bar"); | 155 | EXPECT_EQ(dict.GetString(), "bar"); |
2494 | 145 | 156 | ||
2495 | 146 | // this has to still work | 157 | // this has to still work |
2496 | 158 | EXPECT_EQ(hints["charstring-key"].GetString(), "charstring-value"); | ||
2497 | 147 | EXPECT_EQ(hints["string-key"].GetString(), "string-value"); | 159 | EXPECT_EQ(hints["string-key"].GetString(), "string-value"); |
2499 | 148 | EXPECT_EQ(hints["int-key"].GetInt32(), 123); | 160 | EXPECT_EQ(hints["gint32-key"].GetInt32(), (gint32)-1); |
2500 | 161 | EXPECT_EQ(hints["guint32-key"].GetUInt32(), (guint32)-2); | ||
2501 | 162 | EXPECT_EQ(hints["gint64-key"].GetInt64(), (gint64)-3); | ||
2502 | 163 | EXPECT_EQ(hints["guint64-key"].GetUInt64(), (guint64)-4); | ||
2503 | 164 | EXPECT_EQ(hints["float-key"].GetFloat(), (float)1.1); | ||
2504 | 165 | EXPECT_EQ(hints["double-key"].GetDouble(), (double)2.2); | ||
2505 | 149 | EXPECT_EQ(hints["bool-key"].GetBool(), true); | 166 | EXPECT_EQ(hints["bool-key"].GetBool(), true); |
2506 | 150 | EXPECT_EQ(hints["last"].GetString(), "foo"); | ||
2507 | 151 | } | 167 | } |
2508 | 152 | 168 | ||
2509 | 153 | TEST(TestGLibVariant, GetString) | 169 | TEST(TestGLibVariant, GetString) |
2510 | @@ -205,6 +221,4 @@ | |||
2511 | 205 | } | 221 | } |
2512 | 206 | 222 | ||
2513 | 207 | 223 | ||
2514 | 208 | |||
2515 | 209 | |||
2516 | 210 | } // Namespace | 224 | } // Namespace |
2517 | 211 | 225 | ||
2518 | === added file 'tests/test_gsettings_scopes.cpp' | |||
2519 | --- tests/test_gsettings_scopes.cpp 1970-01-01 00:00:00 +0000 | |||
2520 | +++ tests/test_gsettings_scopes.cpp 2013-03-21 14:03:22 +0000 | |||
2521 | @@ -0,0 +1,230 @@ | |||
2522 | 1 | /* | ||
2523 | 2 | * Copyright (C) 2013 Canonical Ltd | ||
2524 | 3 | * | ||
2525 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2526 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2527 | 6 | * published by the Free Software Foundation. | ||
2528 | 7 | * | ||
2529 | 8 | * This program is distributed in the hope that it will be useful, | ||
2530 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2531 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2532 | 11 | * GNU General Public License for more details. | ||
2533 | 12 | * | ||
2534 | 13 | * You should have received a copy of the GNU General Public License | ||
2535 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2536 | 15 | * | ||
2537 | 16 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
2538 | 17 | */ | ||
2539 | 18 | |||
2540 | 19 | #include <gtest/gtest.h> | ||
2541 | 20 | #include <glib-object.h> | ||
2542 | 21 | #include "test_mock_scope.h" | ||
2543 | 22 | #include "test_utils.h" | ||
2544 | 23 | |||
2545 | 24 | using namespace std; | ||
2546 | 25 | using namespace unity; | ||
2547 | 26 | using namespace unity::dash; | ||
2548 | 27 | |||
2549 | 28 | namespace | ||
2550 | 29 | { | ||
2551 | 30 | |||
2552 | 31 | const char* scopes_default[] = { "testscope1.scope", | ||
2553 | 32 | "testscope2.scope", | ||
2554 | 33 | "testscope3.scope", | ||
2555 | 34 | "testscope4.scope", | ||
2556 | 35 | NULL | ||
2557 | 36 | }; | ||
2558 | 37 | |||
2559 | 38 | const char* scopes_test_update[] = { "testscope1.scope", | ||
2560 | 39 | "testscope4.scope", | ||
2561 | 40 | NULL | ||
2562 | 41 | }; | ||
2563 | 42 | |||
2564 | 43 | const char* scopes_updated[] = { "testscope1.scope", | ||
2565 | 44 | "testscope2.scope", | ||
2566 | 45 | "testscope3.scope", | ||
2567 | 46 | NULL | ||
2568 | 47 | }; | ||
2569 | 48 | |||
2570 | 49 | // A new one of these is created for each test | ||
2571 | 50 | class TestGSettingsScopes : public testing::Test | ||
2572 | 51 | { | ||
2573 | 52 | public: | ||
2574 | 53 | TestGSettingsScopes():scope_added(0),scope_removed(0),scopes_reordered(0) | ||
2575 | 54 | {} | ||
2576 | 55 | |||
2577 | 56 | virtual void SetUp() { Utils::init_gsettings_test_environment(); } | ||
2578 | 57 | virtual void TearDown() { Utils::reset_gsettings_test_environment(); } | ||
2579 | 58 | |||
2580 | 59 | void ConnectScope(Scopes* scopes) | ||
2581 | 60 | { | ||
2582 | 61 | scopes->scope_added.connect([this](Scope::Ptr const& scope, int) | ||
2583 | 62 | { | ||
2584 | 63 | ++scope_added; | ||
2585 | 64 | }); | ||
2586 | 65 | scopes->scope_removed.connect([this](Scope::Ptr const& scope) | ||
2587 | 66 | { | ||
2588 | 67 | ++scope_removed; | ||
2589 | 68 | }); | ||
2590 | 69 | scopes->scopes_reordered.connect([this](Scopes::ScopeList const& list) | ||
2591 | 70 | { | ||
2592 | 71 | ++scopes_reordered; | ||
2593 | 72 | }); | ||
2594 | 73 | } | ||
2595 | 74 | |||
2596 | 75 | int scope_added; | ||
2597 | 76 | int scope_removed; | ||
2598 | 77 | int scopes_reordered; | ||
2599 | 78 | }; | ||
2600 | 79 | |||
2601 | 80 | TEST_F(TestGSettingsScopes, TestAdded) | ||
2602 | 81 | { | ||
2603 | 82 | MockGSettingsScopes scopes(scopes_default); | ||
2604 | 83 | ConnectScope(&scopes); | ||
2605 | 84 | |||
2606 | 85 | scopes.InsertScope("testscope1.scope", 0); | ||
2607 | 86 | EXPECT_EQ(scopes.count, (unsigned int)1); | ||
2608 | 87 | EXPECT_EQ(scopes_reordered, (unsigned int)0); | ||
2609 | 88 | |||
2610 | 89 | // add another | ||
2611 | 90 | scopes.InsertScope("testscope2.scope", 1); | ||
2612 | 91 | EXPECT_EQ(scopes.count, (unsigned int)2); | ||
2613 | 92 | EXPECT_EQ(scopes_reordered, (unsigned int)0); | ||
2614 | 93 | |||
2615 | 94 | int position = -1; | ||
2616 | 95 | EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 0); | ||
2617 | 96 | EXPECT_TRUE(scopes.GetScope("testscope2.scope", &position) && position == 1); | ||
2618 | 97 | } | ||
2619 | 98 | |||
2620 | 99 | TEST_F(TestGSettingsScopes, TestReorderBefore) | ||
2621 | 100 | { | ||
2622 | 101 | MockGSettingsScopes scopes(scopes_default); | ||
2623 | 102 | ConnectScope(&scopes); | ||
2624 | 103 | |||
2625 | 104 | scopes.InsertScope("testscope1.scope", 0); | ||
2626 | 105 | scopes.InsertScope("testscope2.scope", 1); | ||
2627 | 106 | scopes.InsertScope("testscope3.scope", 2); | ||
2628 | 107 | scopes.InsertScope("testscope4.scope", 3); | ||
2629 | 108 | EXPECT_EQ(scopes.count, (unsigned int)4); | ||
2630 | 109 | EXPECT_EQ(scopes_reordered, (unsigned int)0); | ||
2631 | 110 | |||
2632 | 111 | // change position | ||
2633 | 112 | scopes.InsertScope("testscope3.scope", 0); | ||
2634 | 113 | EXPECT_EQ(scopes_reordered, (unsigned int)1); | ||
2635 | 114 | |||
2636 | 115 | int position = -1; | ||
2637 | 116 | EXPECT_TRUE(scopes.GetScope("testscope3.scope", &position) && position == 0); | ||
2638 | 117 | EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 1); | ||
2639 | 118 | EXPECT_TRUE(scopes.GetScope("testscope2.scope", &position) && position == 2); | ||
2640 | 119 | EXPECT_TRUE(scopes.GetScope("testscope4.scope", &position) && position == 3); | ||
2641 | 120 | } | ||
2642 | 121 | |||
2643 | 122 | TEST_F(TestGSettingsScopes, TestReorderAfter) | ||
2644 | 123 | { | ||
2645 | 124 | MockGSettingsScopes scopes(scopes_default); | ||
2646 | 125 | ConnectScope(&scopes); | ||
2647 | 126 | |||
2648 | 127 | scopes.InsertScope("testscope1.scope", 0); | ||
2649 | 128 | scopes.InsertScope("testscope2.scope", 1); | ||
2650 | 129 | scopes.InsertScope("testscope3.scope", 2); | ||
2651 | 130 | scopes.InsertScope("testscope4.scope", 3); | ||
2652 | 131 | EXPECT_EQ(scopes.count, (unsigned int)4); | ||
2653 | 132 | EXPECT_EQ(scopes_reordered, (unsigned int)0); | ||
2654 | 133 | |||
2655 | 134 | // change position | ||
2656 | 135 | scopes.InsertScope("testscope2.scope", 3); | ||
2657 | 136 | EXPECT_EQ(scopes_reordered, (unsigned int)1); | ||
2658 | 137 | |||
2659 | 138 | int position = -1; | ||
2660 | 139 | EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 0); | ||
2661 | 140 | EXPECT_TRUE(scopes.GetScope("testscope3.scope", &position) && position == 1); | ||
2662 | 141 | EXPECT_TRUE(scopes.GetScope("testscope4.scope", &position) && position == 2); | ||
2663 | 142 | EXPECT_TRUE(scopes.GetScope("testscope2.scope", &position) && position == 3); | ||
2664 | 143 | } | ||
2665 | 144 | |||
2666 | 145 | |||
2667 | 146 | TEST_F(TestGSettingsScopes, TestAddNonExists) | ||
2668 | 147 | { | ||
2669 | 148 | MockGSettingsScopes scopes(scopes_default); | ||
2670 | 149 | ConnectScope(&scopes); | ||
2671 | 150 | |||
2672 | 151 | scopes.InsertScope("non-existing.scope", 0); | ||
2673 | 152 | EXPECT_EQ(scope_added, (unsigned int)0); | ||
2674 | 153 | EXPECT_EQ(scopes.count, (unsigned int)0); | ||
2675 | 154 | } | ||
2676 | 155 | |||
2677 | 156 | TEST_F(TestGSettingsScopes, TestAddSame) | ||
2678 | 157 | { | ||
2679 | 158 | MockGSettingsScopes scopes(scopes_default); | ||
2680 | 159 | ConnectScope(&scopes); | ||
2681 | 160 | |||
2682 | 161 | scopes.InsertScope("testscope1.scope", 0); | ||
2683 | 162 | EXPECT_EQ(scope_added, (unsigned int)1); | ||
2684 | 163 | EXPECT_EQ(scopes.count, (unsigned int)1); | ||
2685 | 164 | |||
2686 | 165 | // shouldnt add another | ||
2687 | 166 | scopes.InsertScope("testscope1.scope", 1); | ||
2688 | 167 | |||
2689 | 168 | EXPECT_EQ(scope_added, (unsigned int)1); | ||
2690 | 169 | EXPECT_EQ(scopes.count, (unsigned int)1); | ||
2691 | 170 | EXPECT_EQ(scopes_reordered, (unsigned int)0); | ||
2692 | 171 | } | ||
2693 | 172 | |||
2694 | 173 | TEST_F(TestGSettingsScopes, TestAddRemove) | ||
2695 | 174 | { | ||
2696 | 175 | MockGSettingsScopes scopes(scopes_default); | ||
2697 | 176 | ConnectScope(&scopes); | ||
2698 | 177 | |||
2699 | 178 | scopes.InsertScope("testscope1.scope", 0); | ||
2700 | 179 | EXPECT_EQ(scope_added, (unsigned int)1); | ||
2701 | 180 | EXPECT_EQ(scopes.count, (unsigned int)1); | ||
2702 | 181 | |||
2703 | 182 | scopes.RemoveScope("testscope1.scope"); | ||
2704 | 183 | EXPECT_EQ(scope_removed, (unsigned int)1); | ||
2705 | 184 | EXPECT_EQ(scopes.count, (unsigned int)0); | ||
2706 | 185 | } | ||
2707 | 186 | |||
2708 | 187 | TEST_F(TestGSettingsScopes, TestRemoveNonExists) | ||
2709 | 188 | { | ||
2710 | 189 | MockGSettingsScopes scopes(scopes_default); | ||
2711 | 190 | ConnectScope(&scopes); | ||
2712 | 191 | |||
2713 | 192 | scopes.RemoveScope("non-existing.scope"); | ||
2714 | 193 | EXPECT_EQ(scope_removed, (unsigned int)0); | ||
2715 | 194 | EXPECT_EQ(scopes.count, (unsigned int)0); | ||
2716 | 195 | } | ||
2717 | 196 | |||
2718 | 197 | TEST_F(TestGSettingsScopes, TestLoad) | ||
2719 | 198 | { | ||
2720 | 199 | MockGSettingsScopes scopes(scopes_default); | ||
2721 | 200 | ConnectScope(&scopes); | ||
2722 | 201 | |||
2723 | 202 | scopes.LoadScopes(); | ||
2724 | 203 | EXPECT_EQ(scope_added, (unsigned int)4); | ||
2725 | 204 | |||
2726 | 205 | int position = -1; | ||
2727 | 206 | EXPECT_TRUE(scopes.GetScope("testscope1.scope", &position) && position == 0); | ||
2728 | 207 | EXPECT_TRUE(scopes.GetScope("testscope2.scope", &position) && position == 1); | ||
2729 | 208 | EXPECT_TRUE(scopes.GetScope("testscope3.scope", &position) && position == 2); | ||
2730 | 209 | EXPECT_TRUE(scopes.GetScope("testscope4.scope", &position) && position == 3); | ||
2731 | 210 | } | ||
2732 | 211 | |||
2733 | 212 | TEST_F(TestGSettingsScopes, TestLoadUpdateGSettings) | ||
2734 | 213 | { | ||
2735 | 214 | MockGSettingsScopes scopes(scopes_test_update); | ||
2736 | 215 | ConnectScope(&scopes); | ||
2737 | 216 | |||
2738 | 217 | scopes.LoadScopes(); | ||
2739 | 218 | EXPECT_EQ(scope_added, (unsigned int)2); | ||
2740 | 219 | EXPECT_EQ(scopes.count, (unsigned int)2); | ||
2741 | 220 | |||
2742 | 221 | scopes.UpdateScopes(scopes_updated); | ||
2743 | 222 | Utils::WaitUntilMSec([this] { return scope_removed > 0; }, true, 2000); | ||
2744 | 223 | |||
2745 | 224 | EXPECT_EQ(scope_added, (unsigned int)4); | ||
2746 | 225 | EXPECT_EQ(scope_removed, (unsigned int)1); | ||
2747 | 226 | EXPECT_EQ(scopes.count, (unsigned int)3); | ||
2748 | 227 | } | ||
2749 | 228 | |||
2750 | 229 | |||
2751 | 230 | } | ||
2752 | 0 | 231 | ||
2753 | === modified file 'tests/test_hud.cpp' | |||
2754 | --- tests/test_hud.cpp 2013-02-21 10:03:21 +0000 | |||
2755 | +++ tests/test_hud.cpp 2013-03-21 14:03:22 +0000 | |||
2756 | @@ -3,140 +3,96 @@ | |||
2757 | 3 | #include <UnityCore/GLibWrapper.h> | 3 | #include <UnityCore/GLibWrapper.h> |
2758 | 4 | #include <UnityCore/Hud.h> | 4 | #include <UnityCore/Hud.h> |
2759 | 5 | #include <sigc++/connection.h> | 5 | #include <sigc++/connection.h> |
2760 | 6 | #include "test_utils.h" | ||
2761 | 6 | 7 | ||
2762 | 7 | using namespace std; | 8 | using namespace std; |
2763 | 8 | 9 | ||
2764 | 10 | namespace unity | ||
2765 | 11 | { | ||
2766 | 12 | namespace hud | ||
2767 | 13 | { | ||
2768 | 14 | |||
2769 | 15 | |||
2770 | 9 | namespace | 16 | namespace |
2771 | 10 | { | 17 | { |
2772 | 11 | 18 | ||
2834 | 12 | GMainLoop* loop_ = NULL; | 19 | static void WaitForConnect(Hud::Ptr hud) |
2835 | 13 | unity::hud::Hud *hud; | 20 | { |
2836 | 14 | 21 | ::Utils::WaitUntil([hud]() { return hud->connected(); }, | |
2837 | 15 | class TestHud : public ::testing::Test | 22 | true, |
2838 | 16 | { | 23 | 10, |
2839 | 17 | public: | 24 | []() { return g_strdup("Timed out waiting for hud connection"); }); |
2840 | 18 | TestHud() | 25 | } |
2841 | 19 | : query_return_result(false) | 26 | |
2842 | 20 | , connected_result(false) | 27 | } |
2843 | 21 | { | 28 | |
2844 | 22 | } | 29 | TEST(TestHud, TestConstruction) |
2845 | 23 | unity::hud::Hud::Queries queries; | 30 | { |
2846 | 24 | bool query_return_result; | 31 | Hud::Ptr hud(new Hud("com.canonical.Unity.Test", "/com/canonical/hud")); |
2847 | 25 | bool connected_result; | 32 | WaitForConnect(hud); |
2848 | 26 | int number_signals_found; | 33 | } |
2849 | 27 | }; | 34 | |
2850 | 28 | 35 | TEST(TestHud, TestQueryReturn) | |
2851 | 29 | TEST_F(TestHud, TestConstruction) | 36 | { |
2852 | 30 | { | 37 | Hud::Ptr hud(new Hud("com.canonical.Unity.Test", "/com/canonical/hud")); |
2853 | 31 | loop_ = g_main_loop_new(NULL, FALSE); | 38 | WaitForConnect(hud); |
2854 | 32 | hud = new unity::hud::Hud("com.canonical.Unity.Test", "/com/canonical/hud"); | 39 | |
2855 | 33 | 40 | bool query_return_result = false; | |
2856 | 34 | // performs a check on the hud, if the hud is connected, report a sucess | 41 | Hud::Queries queries; |
2796 | 35 | auto timeout_check = [] (gpointer data) -> gboolean | ||
2797 | 36 | { | ||
2798 | 37 | TestHud* self = static_cast<TestHud*>(data); | ||
2799 | 38 | if (hud->connected) | ||
2800 | 39 | { | ||
2801 | 40 | self->connected_result = true; | ||
2802 | 41 | g_main_loop_quit(loop_); | ||
2803 | 42 | return FALSE; | ||
2804 | 43 | } | ||
2805 | 44 | else | ||
2806 | 45 | { | ||
2807 | 46 | self->connected_result = false; | ||
2808 | 47 | return TRUE; | ||
2809 | 48 | } | ||
2810 | 49 | }; | ||
2811 | 50 | |||
2812 | 51 | |||
2813 | 52 | // if the hud is not connected when this lambda runs, fail. | ||
2814 | 53 | auto timeout_bailout = [] (gpointer data) -> gboolean | ||
2815 | 54 | { | ||
2816 | 55 | TestHud* self = static_cast<TestHud*>(data); | ||
2817 | 56 | // reached timeout, failed testing | ||
2818 | 57 | self->connected_result = false; | ||
2819 | 58 | g_main_loop_quit(loop_); | ||
2820 | 59 | return FALSE; | ||
2821 | 60 | }; | ||
2822 | 61 | |||
2823 | 62 | g_timeout_add(1000, timeout_check, this); | ||
2824 | 63 | g_timeout_add(10000, timeout_bailout, this); | ||
2825 | 64 | |||
2826 | 65 | g_main_loop_run(loop_); | ||
2827 | 66 | |||
2828 | 67 | EXPECT_EQ(connected_result, true); | ||
2829 | 68 | } | ||
2830 | 69 | |||
2831 | 70 | TEST_F(TestHud, TestQueryReturn) | ||
2832 | 71 | { | ||
2833 | 72 | query_return_result = false; | ||
2857 | 73 | 42 | ||
2858 | 74 | // make sure we receive the queries | 43 | // make sure we receive the queries |
2860 | 75 | auto query_connection = [this](unity::hud::Hud::Queries queries_) | 44 | auto query_connection = [&query_return_result, &queries](Hud::Queries const& queries_) |
2861 | 76 | { | 45 | { |
2862 | 77 | query_return_result = true; | 46 | query_return_result = true; |
2863 | 78 | g_main_loop_quit(loop_); | ||
2864 | 79 | queries = queries_; | 47 | queries = queries_; |
2865 | 80 | }; | 48 | }; |
2866 | 81 | |||
2867 | 82 | auto timeout_bailout = [] (gpointer data) -> gboolean | ||
2868 | 83 | { | ||
2869 | 84 | TestHud* self = static_cast<TestHud*>(data); | ||
2870 | 85 | self->query_return_result = false; | ||
2871 | 86 | g_main_loop_quit(loop_); | ||
2872 | 87 | return FALSE; | ||
2873 | 88 | }; | ||
2874 | 89 | 49 | ||
2875 | 90 | sigc::connection connection = hud->queries_updated.connect(query_connection); | 50 | sigc::connection connection = hud->queries_updated.connect(query_connection); |
2876 | 91 | 51 | ||
2877 | 92 | guint source_id = g_timeout_add(10000, timeout_bailout, this); | ||
2878 | 93 | |||
2879 | 94 | // next check we get 30 entries from this specific known callback | 52 | // next check we get 30 entries from this specific known callback |
2880 | 95 | hud->RequestQuery("Request30Queries"); | 53 | hud->RequestQuery("Request30Queries"); |
2885 | 96 | g_main_loop_run(loop_); | 54 | |
2886 | 97 | EXPECT_EQ(query_return_result, true); | 55 | ::Utils::WaitUntil([&queries, &query_return_result]() { return query_return_result && queries.size() > 0; }, |
2887 | 98 | EXPECT_NE(queries.size(), 0); | 56 | true, |
2888 | 99 | g_source_remove(source_id); | 57 | 10, |
2889 | 58 | []() { return g_strdup("Timed out waiting for hud queries"); }); | ||
2890 | 100 | 59 | ||
2891 | 101 | // finally close the connection - Nothing to check for here | 60 | // finally close the connection - Nothing to check for here |
2892 | 102 | hud->CloseQuery(); | 61 | hud->CloseQuery(); |
2893 | 103 | connection.disconnect(); | 62 | connection.disconnect(); |
2894 | 104 | } | 63 | } |
2895 | 105 | 64 | ||
2897 | 106 | TEST_F(TestHud, TestSigEmission) | 65 | TEST(TestHud, TestSigEmission) |
2898 | 107 | { | 66 | { |
2899 | 67 | Hud::Ptr hud(new Hud("com.canonical.Unity.Test", "/com/canonical/hud")); | ||
2900 | 68 | WaitForConnect(hud); | ||
2901 | 69 | |||
2902 | 108 | // checks that the signal emission from Hud is working correctly | 70 | // checks that the signal emission from Hud is working correctly |
2903 | 109 | // the service is setup to emit the same signal every 1000ms | 71 | // the service is setup to emit the same signal every 1000ms |
2904 | 110 | // using the same query key as its StarQuery method | 72 | // using the same query key as its StarQuery method |
2905 | 111 | // so calling StartQuery and listening we expect > 1 | 73 | // so calling StartQuery and listening we expect > 1 |
2906 | 112 | // signal emission | 74 | // signal emission |
2908 | 113 | number_signals_found = 0; | 75 | int number_signals_found = 0; |
2909 | 114 | 76 | ||
2910 | 115 | // make sure we receive the queries | 77 | // make sure we receive the queries |
2912 | 116 | auto query_connection = [this](unity::hud::Hud::Queries queries_) | 78 | auto query_connection = [&number_signals_found](Hud::Queries const&) |
2913 | 117 | { | 79 | { |
2914 | 118 | number_signals_found += 1; | 80 | number_signals_found += 1; |
2915 | 119 | }; | 81 | }; |
2916 | 120 | |||
2917 | 121 | auto timeout_bailout = [] (gpointer data) -> gboolean | ||
2918 | 122 | { | ||
2919 | 123 | g_main_loop_quit(loop_); | ||
2920 | 124 | return FALSE; | ||
2921 | 125 | }; | ||
2922 | 126 | 82 | ||
2923 | 127 | sigc::connection connection = hud->queries_updated.connect(query_connection); | 83 | sigc::connection connection = hud->queries_updated.connect(query_connection); |
2924 | 128 | 84 | ||
2925 | 129 | hud->RequestQuery("Request30Queries"); | 85 | hud->RequestQuery("Request30Queries"); |
2931 | 130 | guint source_id = g_timeout_add(10000, timeout_bailout, this); | 86 | |
2932 | 131 | 87 | ::Utils::WaitUntil([&number_signals_found]() { return number_signals_found > 1; }, | |
2933 | 132 | g_main_loop_run(loop_); | 88 | true, |
2934 | 133 | EXPECT_GT(number_signals_found, 1); | 89 | 10, |
2935 | 134 | g_source_remove(source_id); | 90 | []() { return g_strdup("Timed out waiting for hud signals"); }); |
2936 | 135 | 91 | ||
2937 | 136 | // finally close the connection - Nothing to check for here | 92 | // finally close the connection - Nothing to check for here |
2938 | 137 | hud->CloseQuery(); | 93 | hud->CloseQuery(); |
2939 | 138 | connection.disconnect(); | 94 | connection.disconnect(); |
2940 | 139 | |||
2941 | 140 | } | 95 | } |
2942 | 141 | 96 | ||
2943 | 142 | } | 97 | } |
2944 | 98 | } | ||
2945 | 143 | 99 | ||
2946 | === modified file 'tests/test_hud_view.cpp' | |||
2947 | --- tests/test_hud_view.cpp 2013-02-21 10:03:21 +0000 | |||
2948 | +++ tests/test_hud_view.cpp 2013-03-21 14:03:22 +0000 | |||
2949 | @@ -32,6 +32,7 @@ | |||
2950 | 32 | #include "unity-shared/DashStyle.h" | 32 | #include "unity-shared/DashStyle.h" |
2951 | 33 | #include "unity-shared/PanelStyle.h" | 33 | #include "unity-shared/PanelStyle.h" |
2952 | 34 | #include "unity-shared/UnitySettings.h" | 34 | #include "unity-shared/UnitySettings.h" |
2953 | 35 | |||
2954 | 35 | using namespace unity; | 36 | using namespace unity; |
2955 | 36 | 37 | ||
2956 | 37 | namespace | 38 | namespace |
2957 | 38 | 39 | ||
2958 | === removed file 'tests/test_lensview.cpp' | |||
2959 | --- tests/test_lensview.cpp 2013-02-21 10:03:21 +0000 | |||
2960 | +++ tests/test_lensview.cpp 1970-01-01 00:00:00 +0000 | |||
2961 | @@ -1,98 +0,0 @@ | |||
2962 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2963 | 2 | /* | ||
2964 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
2965 | 4 | * | ||
2966 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2967 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2968 | 7 | * published by the Free Software Foundation. | ||
2969 | 8 | * | ||
2970 | 9 | * This program is distributed in the hope that it will be useful, | ||
2971 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2972 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2973 | 12 | * GNU General Public License for more details. | ||
2974 | 13 | * | ||
2975 | 14 | * You should have received a copy of the GNU General Public License | ||
2976 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2977 | 16 | * | ||
2978 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
2979 | 18 | */ | ||
2980 | 19 | |||
2981 | 20 | #include <gtest/gtest.h> | ||
2982 | 21 | #include <gmock/gmock.h> | ||
2983 | 22 | #include <dash/LensView.h> | ||
2984 | 23 | #include <dash/PlacesGroup.h> | ||
2985 | 24 | #include <unity-shared/DashStyle.h> | ||
2986 | 25 | #include <unity-shared/UnitySettings.h> | ||
2987 | 26 | #include <UnityCore/Category.h> | ||
2988 | 27 | |||
2989 | 28 | using namespace unity; | ||
2990 | 29 | using namespace unity::dash; | ||
2991 | 30 | |||
2992 | 31 | namespace unity | ||
2993 | 32 | { | ||
2994 | 33 | namespace dash | ||
2995 | 34 | { | ||
2996 | 35 | |||
2997 | 36 | class TestLensView : public ::testing::Test | ||
2998 | 37 | { | ||
2999 | 38 | public: | ||
3000 | 39 | |||
3001 | 40 | class FakePlacesGroup : public PlacesGroup | ||
3002 | 41 | { | ||
3003 | 42 | public: | ||
3004 | 43 | FakePlacesGroup():PlacesGroup(dash::Style::Instance()) {} | ||
3005 | 44 | |||
3006 | 45 | using PlacesGroup::_using_filters_background; | ||
3007 | 46 | }; | ||
3008 | 47 | |||
3009 | 48 | class FakeLensView : public LensView | ||
3010 | 49 | { | ||
3011 | 50 | public: | ||
3012 | 51 | FakeLensView():LensView(Lens::Ptr(), nullptr) {} | ||
3013 | 52 | |||
3014 | 53 | using LensView::OnCategoryAdded; | ||
3015 | 54 | |||
3016 | 55 | PlacesGroup* CreatePlacesGroup() | ||
3017 | 56 | { | ||
3018 | 57 | FakePlacesGroup* category = new FakePlacesGroup(); | ||
3019 | 58 | fake_categories_.push_back(category); | ||
3020 | 59 | return category; | ||
3021 | 60 | } | ||
3022 | 61 | |||
3023 | 62 | std::vector<FakePlacesGroup*> fake_categories_; | ||
3024 | 63 | }; | ||
3025 | 64 | |||
3026 | 65 | TestLensView() | ||
3027 | 66 | : lens_view_(new FakeLensView()) | ||
3028 | 67 | { | ||
3029 | 68 | } | ||
3030 | 69 | |||
3031 | 70 | unity::Settings settings; | ||
3032 | 71 | dash::Style style; | ||
3033 | 72 | std::unique_ptr<FakeLensView> lens_view_; | ||
3034 | 73 | }; | ||
3035 | 74 | |||
3036 | 75 | TEST_F(TestLensView, TestCategoryInsert) | ||
3037 | 76 | { | ||
3038 | 77 | Category cat(NULL, NULL, NULL); | ||
3039 | 78 | lens_view_->OnCategoryAdded(cat); | ||
3040 | 79 | |||
3041 | 80 | ASSERT_TRUE(lens_view_->categories().size() > 0); | ||
3042 | 81 | } | ||
3043 | 82 | |||
3044 | 83 | TEST_F(TestLensView, TestFilterExpansion) | ||
3045 | 84 | { | ||
3046 | 85 | Category cat(NULL, NULL, NULL); | ||
3047 | 86 | lens_view_->OnCategoryAdded(cat); | ||
3048 | 87 | lens_view_->OnCategoryAdded(cat); | ||
3049 | 88 | lens_view_->OnCategoryAdded(cat); | ||
3050 | 89 | |||
3051 | 90 | lens_view_->filters_expanded = true; | ||
3052 | 91 | for (unsigned i = 0; i < lens_view_->fake_categories_.size(); i++) | ||
3053 | 92 | { | ||
3054 | 93 | EXPECT_EQ(lens_view_->fake_categories_[i]->_using_filters_background, true); | ||
3055 | 94 | } | ||
3056 | 95 | } | ||
3057 | 96 | |||
3058 | 97 | } | ||
3059 | 98 | } | ||
3060 | 99 | 0 | ||
3061 | === modified file 'tests/test_main.cpp' | |||
3062 | --- tests/test_main.cpp 2013-02-21 10:03:21 +0000 | |||
3063 | +++ tests/test_main.cpp 2013-03-21 14:03:22 +0000 | |||
3064 | @@ -6,6 +6,11 @@ | |||
3065 | 6 | #include <config.h> | 6 | #include <config.h> |
3066 | 7 | 7 | ||
3067 | 8 | #include "logger_helper.h" | 8 | #include "logger_helper.h" |
3068 | 9 | #include "test_utils.h" | ||
3069 | 10 | |||
3070 | 11 | |||
3071 | 12 | const gchar* LOCAL_DATA_DIR = BUILDDIR"/tests/data:/usr/share"; | ||
3072 | 13 | const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; | ||
3073 | 9 | 14 | ||
3074 | 10 | int main(int argc, char** argv) | 15 | int main(int argc, char** argv) |
3075 | 11 | { | 16 | { |
3076 | @@ -16,6 +21,7 @@ | |||
3077 | 16 | const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data:/usr/share"; | 21 | const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data:/usr/share"; |
3078 | 17 | g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE); | 22 | g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE); |
3079 | 18 | g_setenv("LC_ALL", "C", TRUE); | 23 | g_setenv("LC_ALL", "C", TRUE); |
3080 | 24 | Utils::init_gsettings_test_environment(); | ||
3081 | 19 | 25 | ||
3082 | 20 | gtk_init(&argc, &argv); | 26 | gtk_init(&argc, &argv); |
3083 | 21 | setlocale(LC_ALL, "C"); | 27 | setlocale(LC_ALL, "C"); |
3084 | @@ -33,6 +39,8 @@ | |||
3085 | 33 | // StandaloneWindowManager brought in at link time. | 39 | // StandaloneWindowManager brought in at link time. |
3086 | 34 | int ret = RUN_ALL_TESTS(); | 40 | int ret = RUN_ALL_TESTS(); |
3087 | 35 | 41 | ||
3088 | 42 | Utils::reset_gsettings_test_environment(); | ||
3089 | 43 | |||
3090 | 36 | return ret; | 44 | return ret; |
3091 | 37 | } | 45 | } |
3092 | 38 | 46 | ||
3093 | 39 | 47 | ||
3094 | === modified file 'tests/test_main_dbus.cpp' | |||
3095 | --- tests/test_main_dbus.cpp 2013-03-12 13:31:41 +0000 | |||
3096 | +++ tests/test_main_dbus.cpp 2013-03-21 14:03:22 +0000 | |||
3097 | @@ -4,9 +4,20 @@ | |||
3098 | 4 | #include <Nux/Nux.h> | 4 | #include <Nux/Nux.h> |
3099 | 5 | #include "test_utils.h" | 5 | #include "test_utils.h" |
3100 | 6 | 6 | ||
3101 | 7 | #include "config.h" | ||
3102 | 8 | |||
3103 | 7 | static bool wait_until_test_service_appears(); | 9 | static bool wait_until_test_service_appears(); |
3104 | 8 | static void tell_service_to_exit(); | 10 | static void tell_service_to_exit(); |
3105 | 9 | 11 | ||
3106 | 12 | static gboolean no_exit = FALSE; | ||
3107 | 13 | |||
3108 | 14 | static GOptionEntry entries[] = | ||
3109 | 15 | { | ||
3110 | 16 | { "no-exit", 'n', 0, G_OPTION_ARG_NONE, &no_exit, "Do not handle exit call", NULL }, | ||
3111 | 17 | { NULL } | ||
3112 | 18 | }; | ||
3113 | 19 | |||
3114 | 20 | |||
3115 | 10 | int main(int argc, char** argv) | 21 | int main(int argc, char** argv) |
3116 | 11 | { | 22 | { |
3117 | 12 | ::testing::InitGoogleTest(&argc, argv); | 23 | ::testing::InitGoogleTest(&argc, argv); |
3118 | @@ -14,8 +25,20 @@ | |||
3119 | 14 | g_type_init(); | 25 | g_type_init(); |
3120 | 15 | #endif | 26 | #endif |
3121 | 16 | 27 | ||
3122 | 28 | GError *error = NULL; | ||
3123 | 29 | GOptionContext *context; | ||
3124 | 30 | context = g_option_context_new ("- DBus tests"); | ||
3125 | 31 | g_option_context_add_main_entries (context, entries, NULL); | ||
3126 | 32 | if (!g_option_context_parse (context, &argc, &argv, &error)) | ||
3127 | 33 | { | ||
3128 | 34 | g_print ("option parsing failed: %s\n", error->message); | ||
3129 | 35 | return 1; | ||
3130 | 36 | } | ||
3131 | 37 | |||
3132 | 17 | nux::NuxInitialize (0); | 38 | nux::NuxInitialize (0); |
3133 | 18 | 39 | ||
3134 | 40 | g_setenv("XDG_DATA_HOME", BUILDDIR"/tests/data", TRUE); | ||
3135 | 41 | |||
3136 | 19 | // We need the service to be ready before we are | 42 | // We need the service to be ready before we are |
3137 | 20 | 43 | ||
3138 | 21 | if (!wait_until_test_service_appears()) | 44 | if (!wait_until_test_service_appears()) |
3139 | @@ -32,7 +55,8 @@ | |||
3140 | 32 | 55 | ||
3141 | 33 | int ret = RUN_ALL_TESTS(); | 56 | int ret = RUN_ALL_TESTS(); |
3142 | 34 | 57 | ||
3144 | 35 | tell_service_to_exit(); | 58 | if (!no_exit) |
3145 | 59 | tell_service_to_exit(); | ||
3146 | 36 | 60 | ||
3147 | 37 | return ret; | 61 | return ret; |
3148 | 38 | } | 62 | } |
3149 | 39 | 63 | ||
3150 | === modified file 'tests/test_main_xless.cpp' | |||
3151 | --- tests/test_main_xless.cpp 2013-02-21 10:03:21 +0000 | |||
3152 | +++ tests/test_main_xless.cpp 2013-03-21 14:03:22 +0000 | |||
3153 | @@ -2,6 +2,10 @@ | |||
3154 | 2 | #include <gio/gio.h> | 2 | #include <gio/gio.h> |
3155 | 3 | #include <NuxCore/Logger.h> | 3 | #include <NuxCore/Logger.h> |
3156 | 4 | #include <Nux/Nux.h> | 4 | #include <Nux/Nux.h> |
3157 | 5 | #include <config.h> | ||
3158 | 6 | |||
3159 | 7 | |||
3160 | 8 | const gchar* LOCAL_DATA_DIR = BUILDDIR"/tests/data:/usr/share"; | ||
3161 | 5 | 9 | ||
3162 | 6 | int main(int argc, char** argv) | 10 | int main(int argc, char** argv) |
3163 | 7 | { | 11 | { |
3164 | @@ -11,6 +15,8 @@ | |||
3165 | 11 | #endif | 15 | #endif |
3166 | 12 | setlocale(LC_ALL, "C"); | 16 | setlocale(LC_ALL, "C"); |
3167 | 13 | 17 | ||
3168 | 18 | g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR, TRUE); | ||
3169 | 19 | |||
3170 | 14 | // Slightly higher as we're more likely to test things we know will fail | 20 | // Slightly higher as we're more likely to test things we know will fail |
3171 | 15 | nux::logging::configure_logging("<root>=error"); | 21 | nux::logging::configure_logging("<root>=error"); |
3172 | 16 | 22 | ||
3173 | 17 | 23 | ||
3174 | === added file 'tests/test_mock_scope.h' | |||
3175 | --- tests/test_mock_scope.h 1970-01-01 00:00:00 +0000 | |||
3176 | +++ tests/test_mock_scope.h 2013-03-21 14:03:22 +0000 | |||
3177 | @@ -0,0 +1,178 @@ | |||
3178 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
3179 | 2 | /* | ||
3180 | 3 | * Copyright 2013 Canonical Ltd. | ||
3181 | 4 | * | ||
3182 | 5 | * This program is free software: you can redistribute it and/or modify it | ||
3183 | 6 | * under the terms of the GNU Lesser General Public License version 3, as | ||
3184 | 7 | * published by the Free Software Foundation. | ||
3185 | 8 | * | ||
3186 | 9 | * This program is distributed in the hope that it will be useful, but | ||
3187 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3188 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
3189 | 12 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
3190 | 13 | * License for more details. | ||
3191 | 14 | * | ||
3192 | 15 | * You should have received a copy of both the GNU Lesser General Public | ||
3193 | 16 | * License version 3 along with this program. If not, see | ||
3194 | 17 | * <http://www.gnu.org/licenses/> | ||
3195 | 18 | * | ||
3196 | 19 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
3197 | 20 | * | ||
3198 | 21 | */ | ||
3199 | 22 | |||
3200 | 23 | #ifndef TEST_MOCK_SCOPE_H | ||
3201 | 24 | #define TEST_MOCK_SCOPE_H | ||
3202 | 25 | |||
3203 | 26 | #include <gmock/gmock.h> | ||
3204 | 27 | #include <UnityCore/GSettingsScopes.h> | ||
3205 | 28 | #include <UnityCore/GLibSource.h> | ||
3206 | 29 | |||
3207 | 30 | #include <unity-protocol.h> | ||
3208 | 31 | |||
3209 | 32 | namespace unity | ||
3210 | 33 | { | ||
3211 | 34 | namespace dash | ||
3212 | 35 | { | ||
3213 | 36 | |||
3214 | 37 | namespace | ||
3215 | 38 | { | ||
3216 | 39 | const gchar* SETTINGS_NAME = "com.canonical.Unity.Dash"; | ||
3217 | 40 | const gchar* SCOPES_SETTINGS_KEY = "scopes"; | ||
3218 | 41 | } | ||
3219 | 42 | |||
3220 | 43 | // Mock Scopes for use in xless tests. (no dbus!) | ||
3221 | 44 | class MockScopeProxy : public ScopeProxyInterface | ||
3222 | 45 | { | ||
3223 | 46 | public: | ||
3224 | 47 | MockScopeProxy(std::string const& _name, std::string const& _icon_hint) | ||
3225 | 48 | : connected_(true) | ||
3226 | 49 | { | ||
3227 | 50 | connected.SetGetterFunction([this] () { return connected_; }); | ||
3228 | 51 | name.SetGetterFunction([_name] () { return _name; }); | ||
3229 | 52 | icon_hint.SetGetterFunction([_icon_hint] () { return _icon_hint; }); | ||
3230 | 53 | visible.SetGetterFunction([]() { return true; }); | ||
3231 | 54 | } | ||
3232 | 55 | |||
3233 | 56 | virtual void ConnectProxy() { connected_ = true; } | ||
3234 | 57 | virtual void DisconnectProxy() { connected_ = false; } | ||
3235 | 58 | |||
3236 | 59 | virtual void Search(std::string const& search_hint, SearchCallback const& callback = nullptr, GCancellable* cancellable = nullptr) | ||
3237 | 60 | { | ||
3238 | 61 | source_manager.AddIdle([search_hint, callback] () { | ||
3239 | 62 | callback(search_hint, glib::HintsMap(), glib::Error()); | ||
3240 | 63 | return true; | ||
3241 | 64 | }, "Search"); | ||
3242 | 65 | } | ||
3243 | 66 | |||
3244 | 67 | virtual void Activate(LocalResult const& result, uint activate_type, glib::HintsMap const& hints, ActivateCallback const& callback = nullptr, GCancellable* cancellable = nullptr) | ||
3245 | 68 | { | ||
3246 | 69 | source_manager.AddIdle([activate_type, callback, result] () | ||
3247 | 70 | { | ||
3248 | 71 | switch (activate_type) | ||
3249 | 72 | { | ||
3250 | 73 | case UNITY_PROTOCOL_ACTION_TYPE_ACTIVATE_RESULT: | ||
3251 | 74 | callback(result, ScopeHandledType::NOT_HANDLED, glib::HintsMap(), glib::Error()); | ||
3252 | 75 | break; | ||
3253 | 76 | |||
3254 | 77 | case UNITY_PROTOCOL_ACTION_TYPE_PREVIEW_RESULT: | ||
3255 | 78 | callback(result, ScopeHandledType::SHOW_PREVIEW, glib::HintsMap(), glib::Error()); | ||
3256 | 79 | break; | ||
3257 | 80 | |||
3258 | 81 | case UNITY_PROTOCOL_ACTION_TYPE_PREVIEW_ACTION: | ||
3259 | 82 | callback(result, ScopeHandledType::HIDE_DASH, glib::HintsMap(), glib::Error()); | ||
3260 | 83 | break; | ||
3261 | 84 | |||
3262 | 85 | default: | ||
3263 | 86 | { | ||
3264 | 87 | glib::Error error; | ||
3265 | 88 | GError** real_err = &error; | ||
3266 | 89 | *real_err = g_error_new_literal(G_SCOPE_ERROR, G_SCOPE_ERROR_NO_ACTIVATION_HANDLER, "Invalid scope activation typehandler"); | ||
3267 | 90 | callback(result, ScopeHandledType::NOT_HANDLED, glib::HintsMap(), error); | ||
3268 | 91 | } break; | ||
3269 | 92 | } | ||
3270 | 93 | return true; | ||
3271 | 94 | }, "Activate"); | ||
3272 | 95 | } | ||
3273 | 96 | |||
3274 | 97 | virtual Results::Ptr GetResultsForCategory(unsigned category) const | ||
3275 | 98 | { | ||
3276 | 99 | return Results::Ptr(); | ||
3277 | 100 | } | ||
3278 | 101 | |||
3279 | 102 | protected: | ||
3280 | 103 | glib::SourceManager source_manager; | ||
3281 | 104 | bool connected_; | ||
3282 | 105 | }; | ||
3283 | 106 | |||
3284 | 107 | class MockScopeData : public ScopeData | ||
3285 | 108 | { | ||
3286 | 109 | public: | ||
3287 | 110 | MockScopeData(std::string const& scope_id, | ||
3288 | 111 | std::string const& _dbus_name = "", | ||
3289 | 112 | std::string const& _dbus_path = "") | ||
3290 | 113 | { | ||
3291 | 114 | id = scope_id; | ||
3292 | 115 | dbus_name = _dbus_name; | ||
3293 | 116 | dbus_path = _dbus_path; | ||
3294 | 117 | } | ||
3295 | 118 | }; | ||
3296 | 119 | |||
3297 | 120 | class MockScope : public Scope | ||
3298 | 121 | { | ||
3299 | 122 | public: | ||
3300 | 123 | typedef std::shared_ptr<MockScope> Ptr; | ||
3301 | 124 | |||
3302 | 125 | MockScope(ScopeData::Ptr const& scope_data, | ||
3303 | 126 | std::string const& name = "", | ||
3304 | 127 | std::string const& icon_hint = "") | ||
3305 | 128 | : Scope(scope_data) | ||
3306 | 129 | { | ||
3307 | 130 | proxy_func = [name, icon_hint]() | ||
3308 | 131 | { | ||
3309 | 132 | return ScopeProxyInterface::Ptr(new MockScopeProxy(name, icon_hint)); | ||
3310 | 133 | }; | ||
3311 | 134 | |||
3312 | 135 | Init(); | ||
3313 | 136 | } | ||
3314 | 137 | |||
3315 | 138 | virtual ScopeProxyInterface::Ptr CreateProxyInterface() const | ||
3316 | 139 | { | ||
3317 | 140 | return proxy_func(); | ||
3318 | 141 | } | ||
3319 | 142 | |||
3320 | 143 | std::function<ScopeProxyInterface::Ptr(void)> proxy_func; | ||
3321 | 144 | }; | ||
3322 | 145 | |||
3323 | 146 | class MockGSettingsScopes : public GSettingsScopes | ||
3324 | 147 | { | ||
3325 | 148 | public: | ||
3326 | 149 | MockGSettingsScopes(const char* scopes_settings[]) | ||
3327 | 150 | { | ||
3328 | 151 | gsettings_client = g_settings_new(SETTINGS_NAME); | ||
3329 | 152 | UpdateScopes(scopes_settings); | ||
3330 | 153 | } | ||
3331 | 154 | |||
3332 | 155 | using GSettingsScopes::InsertScope; | ||
3333 | 156 | using GSettingsScopes::RemoveScope; | ||
3334 | 157 | |||
3335 | 158 | void UpdateScopes(const char* scopes_settings[]) | ||
3336 | 159 | { | ||
3337 | 160 | g_settings_set_strv(gsettings_client, SCOPES_SETTINGS_KEY, scopes_settings); | ||
3338 | 161 | } | ||
3339 | 162 | |||
3340 | 163 | protected: | ||
3341 | 164 | virtual Scope::Ptr CreateScope(ScopeData::Ptr const& scope_data) | ||
3342 | 165 | { | ||
3343 | 166 | Scope::Ptr scope(new MockScope(scope_data)); | ||
3344 | 167 | return scope; | ||
3345 | 168 | } | ||
3346 | 169 | |||
3347 | 170 | private: | ||
3348 | 171 | glib::Object<GSettings> gsettings_client; | ||
3349 | 172 | }; | ||
3350 | 173 | |||
3351 | 174 | } // namesapce dash | ||
3352 | 175 | } // namesapce unity | ||
3353 | 176 | |||
3354 | 177 | |||
3355 | 178 | #endif // TEST_MOCK_SCOPE_H | ||
3356 | 0 | 179 | ||
3357 | === modified file 'tests/test_model_iterator.cpp' | |||
3358 | --- tests/test_model_iterator.cpp 2013-03-19 14:05:51 +0000 | |||
3359 | +++ tests/test_model_iterator.cpp 2013-03-21 14:03:22 +0000 | |||
3360 | @@ -110,6 +110,20 @@ | |||
3361 | 110 | EXPECT_NE(one, two); | 110 | EXPECT_NE(one, two); |
3362 | 111 | } | 111 | } |
3363 | 112 | 112 | ||
3364 | 113 | TEST_F(TestResultIterator, TestEqual) | ||
3365 | 114 | { | ||
3366 | 115 | AddResult("mailto:nospam@example.org", "Email"); | ||
3367 | 116 | |||
3368 | 117 | ResultIterator one(results->model()); | ||
3369 | 118 | ResultIterator two = one; | ||
3370 | 119 | |||
3371 | 120 | EXPECT_EQ(one, two); | ||
3372 | 121 | |||
3373 | 122 | ResultIterator const& original = two++; | ||
3374 | 123 | EXPECT_EQ(original, one); | ||
3375 | 124 | EXPECT_NE(one, two); | ||
3376 | 125 | } | ||
3377 | 126 | |||
3378 | 113 | TEST_F(TestResultIterator, TestIncrement) | 127 | TEST_F(TestResultIterator, TestIncrement) |
3379 | 114 | { | 128 | { |
3380 | 115 | AddResult("file:///foo.txt", "Result #1"); | 129 | AddResult("file:///foo.txt", "Result #1"); |
3381 | @@ -129,5 +143,77 @@ | |||
3382 | 129 | EXPECT_FALSE(it.IsFirst()); | 143 | EXPECT_FALSE(it.IsFirst()); |
3383 | 130 | } | 144 | } |
3384 | 131 | 145 | ||
3386 | 132 | 146 | TEST_F(TestResultIterator, TestDecrement) | |
3387 | 147 | { | ||
3388 | 148 | AddResult("file:///foo.txt", "Result #1"); | ||
3389 | 149 | AddResult("file:///qoo.txt", "Result #2"); | ||
3390 | 150 | |||
3391 | 151 | ResultIterator it(results->end()); | ||
3392 | 152 | EXPECT_TRUE(it.IsLast()); | ||
3393 | 153 | |||
3394 | 154 | it--; | ||
3395 | 155 | EXPECT_EQ((*it).uri, "file:///qoo.txt"); | ||
3396 | 156 | EXPECT_EQ((*it).name, "Result #2"); | ||
3397 | 157 | |||
3398 | 158 | it--; | ||
3399 | 159 | EXPECT_EQ((*it).uri, "file:///foo.txt"); | ||
3400 | 160 | EXPECT_EQ((*it).name, "Result #1"); | ||
3401 | 161 | |||
3402 | 162 | EXPECT_TRUE(it.IsFirst()); | ||
3403 | 163 | EXPECT_FALSE(it.IsLast()); | ||
3404 | 164 | } | ||
3405 | 165 | |||
3406 | 166 | TEST_F(TestResultIterator, TestAdd) | ||
3407 | 167 | { | ||
3408 | 168 | AddResult("file:///foo.txt", "Result #1"); | ||
3409 | 169 | AddResult("file:///qoo.txt", "Result #2"); | ||
3410 | 170 | AddResult("file:///bar.txt", "Result #3"); | ||
3411 | 171 | |||
3412 | 172 | ResultIterator it(results->model()); | ||
3413 | 173 | EXPECT_EQ((*it).uri, "file:///foo.txt"); | ||
3414 | 174 | EXPECT_EQ((*it).name, "Result #1"); | ||
3415 | 175 | |||
3416 | 176 | it+=2; | ||
3417 | 177 | EXPECT_EQ((*it).uri, "file:///bar.txt"); | ||
3418 | 178 | EXPECT_EQ((*it).name, "Result #3"); | ||
3419 | 179 | EXPECT_FALSE(it.IsLast()); | ||
3420 | 180 | |||
3421 | 181 | it+=1; | ||
3422 | 182 | EXPECT_TRUE(it.IsLast()); | ||
3423 | 183 | EXPECT_FALSE(it.IsFirst()); | ||
3424 | 184 | } | ||
3425 | 185 | |||
3426 | 186 | TEST_F(TestResultIterator, TestSubtract) | ||
3427 | 187 | { | ||
3428 | 188 | AddResult("file:///foo.txt", "Result #1"); | ||
3429 | 189 | AddResult("file:///qoo.txt", "Result #2"); | ||
3430 | 190 | AddResult("file:///bar.txt", "Result #3"); | ||
3431 | 191 | |||
3432 | 192 | ResultIterator it(results->end()); | ||
3433 | 193 | EXPECT_TRUE(it.IsLast()); | ||
3434 | 194 | |||
3435 | 195 | it--; | ||
3436 | 196 | EXPECT_EQ((*it).uri, "file:///bar.txt"); | ||
3437 | 197 | EXPECT_EQ((*it).name, "Result #3"); | ||
3438 | 198 | |||
3439 | 199 | it-=2; | ||
3440 | 200 | EXPECT_EQ((*it).uri, "file:///foo.txt"); | ||
3441 | 201 | EXPECT_EQ((*it).name, "Result #1"); | ||
3442 | 202 | EXPECT_TRUE(it.IsFirst()); | ||
3443 | 203 | EXPECT_FALSE(it.IsLast()); | ||
3444 | 204 | } | ||
3445 | 205 | |||
3446 | 206 | TEST_F(TestResultIterator, TestOperatorAt) | ||
3447 | 207 | { | ||
3448 | 208 | AddResult("file:///foo.txt", "Result #1"); | ||
3449 | 209 | AddResult("file:///qoo.txt", "Result #2"); | ||
3450 | 210 | AddResult("file:///bar.txt", "Result #3"); | ||
3451 | 211 | |||
3452 | 212 | ResultIterator it(results->begin()); | ||
3453 | 213 | it = it[1]; | ||
3454 | 214 | |||
3455 | 215 | EXPECT_EQ((*it).uri, "file:///qoo.txt"); | ||
3456 | 216 | EXPECT_EQ((*it).name, "Result #2"); | ||
3457 | 133 | } // Namespace | 217 | } // Namespace |
3458 | 218 | |||
3459 | 219 | } | ||
3460 | 134 | 220 | ||
3461 | === added file 'tests/test_preview_player.cpp' | |||
3462 | --- tests/test_preview_player.cpp 1970-01-01 00:00:00 +0000 | |||
3463 | +++ tests/test_preview_player.cpp 2013-03-21 14:03:22 +0000 | |||
3464 | @@ -0,0 +1,151 @@ | |||
3465 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
3466 | 2 | /* | ||
3467 | 3 | * Copyright (C) 2013 Canonical Ltd | ||
3468 | 4 | * | ||
3469 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3470 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
3471 | 7 | * published by the Free Software Foundation. | ||
3472 | 8 | * | ||
3473 | 9 | * This program is distributed in the hope that it will be useful, | ||
3474 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3475 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3476 | 12 | * GNU General Public License for more details. | ||
3477 | 13 | * | ||
3478 | 14 | * You should have received a copy of the GNU General Public License | ||
3479 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3480 | 16 | * | ||
3481 | 17 | * Authored by: Nick Dedekind <nick.dedekinc@canonical.com> | ||
3482 | 18 | */ | ||
3483 | 19 | |||
3484 | 20 | #include <gmock/gmock.h> | ||
3485 | 21 | #include "UnityCore/PreviewPlayer.h" | ||
3486 | 22 | #include "test_utils.h" | ||
3487 | 23 | #include "config.h" | ||
3488 | 24 | #include "sigc++/connection.h" | ||
3489 | 25 | |||
3490 | 26 | namespace unity | ||
3491 | 27 | { | ||
3492 | 28 | |||
3493 | 29 | const gchar* WHITE_NOISE = "file://" BUILDDIR "/tests/data/unity/sounds/whitenoise.mp3"; | ||
3494 | 30 | |||
3495 | 31 | |||
3496 | 32 | namespace | ||
3497 | 33 | { | ||
3498 | 34 | void PlayAndWait(PreviewPlayer* player, std::string const& uri) | ||
3499 | 35 | { | ||
3500 | 36 | bool play_returned = false; | ||
3501 | 37 | auto play_callback = [&play_returned] (glib::Error const& error) { | ||
3502 | 38 | play_returned = true; | ||
3503 | 39 | EXPECT_TRUE(!error) << "Error: " << error.Message(); | ||
3504 | 40 | }; | ||
3505 | 41 | |||
3506 | 42 | bool updated_called = false; | ||
3507 | 43 | auto updated_callback = [uri, &updated_called] (std::string const& _uri, PlayerState state, double) { | ||
3508 | 44 | updated_called = true; | ||
3509 | 45 | EXPECT_EQ(_uri, uri) << "Uri for PLAY not correct (" << _uri << " != " << _uri << ")"; | ||
3510 | 46 | EXPECT_EQ((int)state, (int)PlayerState::PLAYING) << "Incorrect state returned on PLAY."; | ||
3511 | 47 | }; | ||
3512 | 48 | |||
3513 | 49 | sigc::connection conn = player->updated.connect(updated_callback); | ||
3514 | 50 | player->Play(uri, play_callback); | ||
3515 | 51 | ::Utils::WaitUntilMSec(play_returned, 3000, []() { return g_strdup("PLAY did not return"); }); | ||
3516 | 52 | ::Utils::WaitUntilMSec(updated_called, 5000, []() { return g_strdup("Update not called on PLAY"); }); | ||
3517 | 53 | conn.disconnect(); | ||
3518 | 54 | } | ||
3519 | 55 | |||
3520 | 56 | void PauseAndWait(PreviewPlayer* player) | ||
3521 | 57 | { | ||
3522 | 58 | bool pause_returned = false; | ||
3523 | 59 | auto callback = [&pause_returned] (glib::Error const& error) { | ||
3524 | 60 | pause_returned = true; | ||
3525 | 61 | EXPECT_TRUE(!error) << "Error: " << error.Message(); | ||
3526 | 62 | }; | ||
3527 | 63 | |||
3528 | 64 | bool updated_called = false; | ||
3529 | 65 | auto updated_callback = [&updated_called] (std::string const&, PlayerState state, double) { | ||
3530 | 66 | updated_called = true; | ||
3531 | 67 | EXPECT_EQ((int)state, (int)PlayerState::PAUSED) << "Incorrect state returned on PAUSE."; | ||
3532 | 68 | }; | ||
3533 | 69 | |||
3534 | 70 | sigc::connection conn = player->updated.connect(updated_callback); | ||
3535 | 71 | player->Pause(callback); | ||
3536 | 72 | ::Utils::WaitUntilMSec(pause_returned, 3000, []() { return g_strdup("PAUSE did not return"); }); | ||
3537 | 73 | ::Utils::WaitUntilMSec(updated_called, 5000, []() { return g_strdup("Update not called om PAUSE"); }); | ||
3538 | 74 | conn.disconnect(); | ||
3539 | 75 | } | ||
3540 | 76 | |||
3541 | 77 | void ResumeAndWait(PreviewPlayer* player) | ||
3542 | 78 | { | ||
3543 | 79 | bool resume_returned = false; | ||
3544 | 80 | auto callback = [&resume_returned] (glib::Error const& error) { | ||
3545 | 81 | resume_returned = true; | ||
3546 | 82 | EXPECT_TRUE(!error) << "Error: " << error.Message(); | ||
3547 | 83 | }; | ||
3548 | 84 | |||
3549 | 85 | bool updated_called = false; | ||
3550 | 86 | auto updated_callback = [&updated_called] (std::string const&, PlayerState state, double) { | ||
3551 | 87 | updated_called = true; | ||
3552 | 88 | EXPECT_EQ((int)state, (int)PlayerState::PLAYING) << "Incorrect state returned on RESUME."; | ||
3553 | 89 | }; | ||
3554 | 90 | |||
3555 | 91 | sigc::connection conn = player->updated.connect(updated_callback); | ||
3556 | 92 | player->Resume(callback); | ||
3557 | 93 | ::Utils::WaitUntilMSec(resume_returned, 3000, []() { return g_strdup("RESUME did not return"); }); | ||
3558 | 94 | ::Utils::WaitUntilMSec(updated_called, 5000, []() { return g_strdup("Update not called on RESUME"); }); | ||
3559 | 95 | conn.disconnect(); | ||
3560 | 96 | } | ||
3561 | 97 | |||
3562 | 98 | void StopAndWait(PreviewPlayer* player) | ||
3563 | 99 | { | ||
3564 | 100 | bool stop_returned = false; | ||
3565 | 101 | auto callback = [&stop_returned] (glib::Error const& error) { | ||
3566 | 102 | stop_returned = true; | ||
3567 | 103 | EXPECT_TRUE(!error) << "Error: " << error.Message(); | ||
3568 | 104 | }; | ||
3569 | 105 | |||
3570 | 106 | bool updated_called = false; | ||
3571 | 107 | auto updated_callback = [&updated_called] (std::string const&, PlayerState state, double) { | ||
3572 | 108 | updated_called = true; | ||
3573 | 109 | EXPECT_EQ((int)state, (int)PlayerState::STOPPED) << "Incorrect state returned on STOP."; | ||
3574 | 110 | }; | ||
3575 | 111 | |||
3576 | 112 | sigc::connection conn = player->updated.connect(updated_callback); | ||
3577 | 113 | player->Stop(callback); | ||
3578 | 114 | ::Utils::WaitUntilMSec(stop_returned, 3000, []() { return g_strdup("STOP did not return"); }); | ||
3579 | 115 | ::Utils::WaitUntilMSec(updated_called, 5000, []() { return g_strdup("Update not called on STOP"); }); | ||
3580 | 116 | conn.disconnect(); | ||
3581 | 117 | } | ||
3582 | 118 | } | ||
3583 | 119 | |||
3584 | 120 | TEST(TestPreviewPlayer, TestConstruct) | ||
3585 | 121 | { | ||
3586 | 122 | PreviewPlayer player1; | ||
3587 | 123 | PreviewPlayer player2; | ||
3588 | 124 | } | ||
3589 | 125 | |||
3590 | 126 | TEST(TestPreviewPlayer, TestPlayerControl) | ||
3591 | 127 | { | ||
3592 | 128 | PreviewPlayer player; | ||
3593 | 129 | |||
3594 | 130 | PlayAndWait(&player, WHITE_NOISE); | ||
3595 | 131 | |||
3596 | 132 | PauseAndWait(&player); | ||
3597 | 133 | |||
3598 | 134 | ResumeAndWait(&player); | ||
3599 | 135 | |||
3600 | 136 | StopAndWait(&player); | ||
3601 | 137 | } | ||
3602 | 138 | |||
3603 | 139 | TEST(TestPreviewPlayer, TestMultiPlayer) | ||
3604 | 140 | { | ||
3605 | 141 | PreviewPlayer player1; | ||
3606 | 142 | { | ||
3607 | 143 | PreviewPlayer player2; | ||
3608 | 144 | PlayAndWait(&player2, WHITE_NOISE); | ||
3609 | 145 | } | ||
3610 | 146 | |||
3611 | 147 | StopAndWait(&player1); | ||
3612 | 148 | } | ||
3613 | 149 | |||
3614 | 150 | |||
3615 | 151 | } // namespace unity | ||
3616 | 0 | \ No newline at end of file | 152 | \ No newline at end of file |
3617 | 1 | 153 | ||
3618 | === modified file 'tests/test_results.cpp' | |||
3619 | --- tests/test_results.cpp 2013-03-19 14:05:51 +0000 | |||
3620 | +++ tests/test_results.cpp 2013-03-21 14:03:22 +0000 | |||
3621 | @@ -74,10 +74,21 @@ | |||
3622 | 74 | EXPECT_EQ(result.uri(), value); | 74 | EXPECT_EQ(result.uri(), value); |
3623 | 75 | EXPECT_EQ(result.icon_hint(), value); | 75 | EXPECT_EQ(result.icon_hint(), value); |
3624 | 76 | EXPECT_EQ(result.category_index(), (i / 50)); | 76 | EXPECT_EQ(result.category_index(), (i / 50)); |
3625 | 77 | EXPECT_EQ(result.result_type(), 0); | ||
3626 | 77 | EXPECT_EQ(result.mimetype(), value); | 78 | EXPECT_EQ(result.mimetype(), value); |
3627 | 78 | EXPECT_EQ(result.name(), value); | 79 | EXPECT_EQ(result.name(), value); |
3628 | 79 | EXPECT_EQ(result.comment(), value); | 80 | EXPECT_EQ(result.comment(), value); |
3629 | 80 | EXPECT_EQ(result.dnd_uri(), value); | 81 | EXPECT_EQ(result.dnd_uri(), value); |
3630 | 82 | |||
3631 | 83 | glib::HintsMap hints = result.hints(); | ||
3632 | 84 | auto iter = hints.find("key"); | ||
3633 | 85 | EXPECT_TRUE(iter != hints.end()); | ||
3634 | 86 | if (iter != hints.end()) | ||
3635 | 87 | { | ||
3636 | 88 | std::string value = glib::gchar_to_string(g_variant_get_string(iter->second, NULL)); | ||
3637 | 89 | EXPECT_EQ(value, "value"); | ||
3638 | 90 | } | ||
3639 | 91 | |||
3640 | 81 | i++; | 92 | i++; |
3641 | 82 | } | 93 | } |
3642 | 83 | 94 | ||
3643 | @@ -156,4 +167,133 @@ | |||
3644 | 156 | } | 167 | } |
3645 | 157 | } | 168 | } |
3646 | 158 | 169 | ||
3647 | 170 | // We're testing the model's ability to store and retrieve random pointers | ||
3648 | 171 | TEST(TestResults, TestResultEqual) | ||
3649 | 172 | { | ||
3650 | 173 | Results model; | ||
3651 | 174 | model.swarm_name = swarm_name; | ||
3652 | 175 | |||
3653 | 176 | WaitForSynchronize(model); | ||
3654 | 177 | |||
3655 | 178 | Result result_1(*model.begin()); | ||
3656 | 179 | Result result_2(NULL, NULL, NULL); | ||
3657 | 180 | result_2 = result_1; | ||
3658 | 181 | |||
3659 | 182 | EXPECT_EQ(result_2.uri(), result_1.uri()); | ||
3660 | 183 | EXPECT_EQ(result_2.icon_hint(), result_1.icon_hint()); | ||
3661 | 184 | EXPECT_EQ(result_2.category_index(), result_1.category_index()); | ||
3662 | 185 | EXPECT_EQ(result_2.result_type(), result_1.result_type()); | ||
3663 | 186 | EXPECT_EQ(result_2.mimetype(), result_1.mimetype()); | ||
3664 | 187 | EXPECT_EQ(result_2.name(), result_1.name()); | ||
3665 | 188 | EXPECT_EQ(result_2.comment(), result_1.comment()); | ||
3666 | 189 | EXPECT_EQ(result_2.dnd_uri(), result_1.dnd_uri()); | ||
3667 | 190 | } | ||
3668 | 191 | |||
3669 | 192 | // We're testing the model's ability to store and retrieve random pointers | ||
3670 | 193 | TEST(TestResults, LocalResult_Construct) | ||
3671 | 194 | { | ||
3672 | 195 | Results model; | ||
3673 | 196 | model.swarm_name = swarm_name; | ||
3674 | 197 | |||
3675 | 198 | WaitForSynchronize(model); | ||
3676 | 199 | |||
3677 | 200 | ResultIterator iter(model.model); | ||
3678 | 201 | for (Result const& result : model) | ||
3679 | 202 | { | ||
3680 | 203 | LocalResult local_result_1(result); | ||
3681 | 204 | LocalResult local_result_2(local_result_1); | ||
3682 | 205 | |||
3683 | 206 | EXPECT_EQ(local_result_1.uri, result.uri()); | ||
3684 | 207 | EXPECT_EQ(local_result_1.icon_hint, result.icon_hint()); | ||
3685 | 208 | EXPECT_EQ(local_result_1.category_index, result.category_index()); | ||
3686 | 209 | EXPECT_EQ(local_result_1.result_type, result.result_type()); | ||
3687 | 210 | EXPECT_EQ(local_result_1.mimetype, result.mimetype()); | ||
3688 | 211 | EXPECT_EQ(local_result_1.name, result.name()); | ||
3689 | 212 | EXPECT_EQ(local_result_1.comment, result.comment()); | ||
3690 | 213 | EXPECT_EQ(local_result_1.dnd_uri, result.dnd_uri()); | ||
3691 | 214 | |||
3692 | 215 | EXPECT_EQ(local_result_2.uri, result.uri()); | ||
3693 | 216 | EXPECT_EQ(local_result_2.icon_hint, result.icon_hint()); | ||
3694 | 217 | EXPECT_EQ(local_result_2.category_index, result.category_index()); | ||
3695 | 218 | EXPECT_EQ(local_result_2.result_type, result.result_type()); | ||
3696 | 219 | EXPECT_EQ(local_result_2.mimetype, result.mimetype()); | ||
3697 | 220 | EXPECT_EQ(local_result_2.name, result.name()); | ||
3698 | 221 | EXPECT_EQ(local_result_2.comment, result.comment()); | ||
3699 | 222 | EXPECT_EQ(local_result_2.dnd_uri, result.dnd_uri()); | ||
3700 | 223 | } | ||
3701 | 224 | } | ||
3702 | 225 | |||
3703 | 226 | |||
3704 | 227 | // We're testing the model's ability to store and retrieve random pointers | ||
3705 | 228 | TEST(TestResults, LocalResult_OperatorEqual) | ||
3706 | 229 | { | ||
3707 | 230 | Results model; | ||
3708 | 231 | model.swarm_name = swarm_name; | ||
3709 | 232 | |||
3710 | 233 | WaitForSynchronize(model); | ||
3711 | 234 | |||
3712 | 235 | ResultIterator iter(model.model); | ||
3713 | 236 | for (Result const& result : model) | ||
3714 | 237 | { | ||
3715 | 238 | LocalResult local_result_1(result); | ||
3716 | 239 | LocalResult local_result_2(local_result_1); | ||
3717 | 240 | |||
3718 | 241 | EXPECT_TRUE(local_result_1 == local_result_2); | ||
3719 | 242 | EXPECT_FALSE(local_result_1 != local_result_2); | ||
3720 | 243 | } | ||
3721 | 244 | } | ||
3722 | 245 | |||
3723 | 246 | |||
3724 | 247 | // We're testing the model's ability to store and retrieve random pointers | ||
3725 | 248 | TEST(TestResults, LocalResult_FromToVariant) | ||
3726 | 249 | { | ||
3727 | 250 | LocalResult local_result_1; | ||
3728 | 251 | local_result_1.uri = "uri"; | ||
3729 | 252 | local_result_1.icon_hint = "icon_hint"; | ||
3730 | 253 | local_result_1.category_index = 1; | ||
3731 | 254 | local_result_1.result_type = 2; | ||
3732 | 255 | local_result_1.mimetype = "mimetype"; | ||
3733 | 256 | local_result_1.name = "name"; | ||
3734 | 257 | local_result_1.comment = "comment"; | ||
3735 | 258 | local_result_1.dnd_uri = "dnd_uri"; | ||
3736 | 259 | |||
3737 | 260 | local_result_1.hints["key1"] = g_variant_new_string("value1"); | ||
3738 | 261 | local_result_1.hints["key2"] = g_variant_new_string("value2"); | ||
3739 | 262 | |||
3740 | 263 | glib::Variant variant_value = local_result_1.Variant(); | ||
3741 | 264 | LocalResult local_result_2 = LocalResult::FromVariant(variant_value); | ||
3742 | 265 | |||
3743 | 266 | EXPECT_EQ(local_result_2.uri, "uri"); | ||
3744 | 267 | EXPECT_EQ(local_result_2.icon_hint, "icon_hint"); | ||
3745 | 268 | EXPECT_EQ(local_result_2.category_index, 1); | ||
3746 | 269 | EXPECT_EQ(local_result_2.result_type, 2); | ||
3747 | 270 | EXPECT_EQ(local_result_2.mimetype, "mimetype"); | ||
3748 | 271 | EXPECT_EQ(local_result_2.name, "name"); | ||
3749 | 272 | EXPECT_EQ(local_result_2.comment, "comment"); | ||
3750 | 273 | EXPECT_EQ(local_result_2.dnd_uri, "dnd_uri"); | ||
3751 | 274 | |||
3752 | 275 | auto iter = local_result_2.hints.find("key1"); | ||
3753 | 276 | EXPECT_TRUE(iter != local_result_2.hints.end()); | ||
3754 | 277 | if (iter != local_result_2.hints.end()) | ||
3755 | 278 | { | ||
3756 | 279 | std::string value = glib::gchar_to_string(g_variant_get_string(iter->second, NULL)); | ||
3757 | 280 | EXPECT_EQ(value, "value1"); | ||
3758 | 281 | } | ||
3759 | 282 | iter = local_result_2.hints.find("key2"); | ||
3760 | 283 | EXPECT_TRUE(iter != local_result_2.hints.end()); | ||
3761 | 284 | if (iter != local_result_2.hints.end()) | ||
3762 | 285 | { | ||
3763 | 286 | std::string value = glib::gchar_to_string(g_variant_get_string(iter->second, NULL)); | ||
3764 | 287 | EXPECT_EQ(value, "value2"); | ||
3765 | 288 | } | ||
3766 | 289 | } | ||
3767 | 290 | |||
3768 | 291 | |||
3769 | 292 | // We're testing the model's ability to store and retrieve random pointers | ||
3770 | 293 | TEST(TestResults, LocalResult_Variants) | ||
3771 | 294 | { | ||
3772 | 295 | LocalResult local_result; | ||
3773 | 296 | EXPECT_EQ(local_result.Variants().size(), 9); | ||
3774 | 297 | } | ||
3775 | 298 | |||
3776 | 159 | } | 299 | } |
3777 | 160 | 300 | ||
3778 | === modified file 'tests/test_resultviewgrid.cpp' | |||
3779 | --- tests/test_resultviewgrid.cpp 2013-02-21 10:03:21 +0000 | |||
3780 | +++ tests/test_resultviewgrid.cpp 2013-03-21 14:03:22 +0000 | |||
3781 | @@ -49,7 +49,7 @@ | |||
3782 | 49 | public: | 49 | public: |
3783 | 50 | virtual void SetUp() | 50 | virtual void SetUp() |
3784 | 51 | { | 51 | { |
3786 | 52 | view.Adopt(new MockResultViewGrid(NUX_TRACKER_LOCATION)); | 52 | view.Adopt(new NiceMock<MockResultViewGrid>(NUX_TRACKER_LOCATION)); |
3787 | 53 | renderer.Adopt(new dash::ResultRenderer(NUX_TRACKER_LOCATION)); | 53 | renderer.Adopt(new dash::ResultRenderer(NUX_TRACKER_LOCATION)); |
3788 | 54 | 54 | ||
3789 | 55 | view->SetModelRenderer(renderer.GetPointer()); | 55 | view->SetModelRenderer(renderer.GetPointer()); |
3790 | 56 | 56 | ||
3791 | === added file 'tests/test_scope.cpp' | |||
3792 | --- tests/test_scope.cpp 1970-01-01 00:00:00 +0000 | |||
3793 | +++ tests/test_scope.cpp 2013-03-21 14:03:22 +0000 | |||
3794 | @@ -0,0 +1,236 @@ | |||
3795 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
3796 | 2 | /* | ||
3797 | 3 | * Copyright (C) 2013 Canonical Ltd | ||
3798 | 4 | * | ||
3799 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3800 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
3801 | 7 | * published by the Free Software Foundation. | ||
3802 | 8 | * | ||
3803 | 9 | * This program is distributed in the hope that it will be useful, | ||
3804 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3805 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3806 | 12 | * GNU General Public License for more details. | ||
3807 | 13 | * | ||
3808 | 14 | * You should have received a copy of the GNU General Public License | ||
3809 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3810 | 16 | * | ||
3811 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
3812 | 18 | */ | ||
3813 | 19 | |||
3814 | 20 | #include <boost/lexical_cast.hpp> | ||
3815 | 21 | #include <gtest/gtest.h> | ||
3816 | 22 | #include <glib-object.h> | ||
3817 | 23 | #include <unity-protocol.h> | ||
3818 | 24 | |||
3819 | 25 | #include <UnityCore/GLibWrapper.h> | ||
3820 | 26 | #include <UnityCore/Scope.h> | ||
3821 | 27 | #include <UnityCore/CheckOptionFilter.h> | ||
3822 | 28 | |||
3823 | 29 | #include "test_utils.h" | ||
3824 | 30 | #include "RadioOptionFilter.h" | ||
3825 | 31 | |||
3826 | 32 | using namespace std; | ||
3827 | 33 | using namespace unity; | ||
3828 | 34 | using namespace unity::dash; | ||
3829 | 35 | |||
3830 | 36 | namespace unity | ||
3831 | 37 | { | ||
3832 | 38 | namespace dash | ||
3833 | 39 | { | ||
3834 | 40 | |||
3835 | 41 | namespace | ||
3836 | 42 | { | ||
3837 | 43 | const std::string SCOPE_NAME = "testscope1.scope"; | ||
3838 | 44 | } | ||
3839 | 45 | |||
3840 | 46 | class TestScope : public ::testing::Test | ||
3841 | 47 | { | ||
3842 | 48 | public: | ||
3843 | 49 | TestScope() { } | ||
3844 | 50 | |||
3845 | 51 | virtual void SetUp() | ||
3846 | 52 | { | ||
3847 | 53 | glib::Error err; | ||
3848 | 54 | ScopeData::Ptr data(ScopeData::ReadProtocolDataForId(SCOPE_NAME, err)); | ||
3849 | 55 | ASSERT_TRUE(err ? false : true); | ||
3850 | 56 | |||
3851 | 57 | scope_.reset(new Scope(data)); | ||
3852 | 58 | scope_->Init(); | ||
3853 | 59 | } | ||
3854 | 60 | |||
3855 | 61 | void ConnectAndWait() | ||
3856 | 62 | { | ||
3857 | 63 | scope_->Connect(); | ||
3858 | 64 | Utils::WaitUntilMSec([this] { return scope_->connected() == true; }, true, 2000); | ||
3859 | 65 | } | ||
3860 | 66 | |||
3861 | 67 | Filter::Ptr WaitForFilter(std::string const& filter_to_wait_for) | ||
3862 | 68 | { | ||
3863 | 69 | Filter::Ptr filter_ret; | ||
3864 | 70 | Filters::Ptr filters = scope_->filters(); | ||
3865 | 71 | Utils::WaitUntilMSec([filters, filter_to_wait_for, &filter_ret] | ||
3866 | 72 | { | ||
3867 | 73 | for (std::size_t i = 0; i < filters->count(); i++) | ||
3868 | 74 | { | ||
3869 | 75 | Filter::Ptr filter = filters->FilterAtIndex(i); | ||
3870 | 76 | if (filter && filter->id == filter_to_wait_for) | ||
3871 | 77 | { | ||
3872 | 78 | filter_ret = filter; | ||
3873 | 79 | return true; | ||
3874 | 80 | } | ||
3875 | 81 | } | ||
3876 | 82 | return false; | ||
3877 | 83 | }, | ||
3878 | 84 | true, | ||
3879 | 85 | 2000, | ||
3880 | 86 | [filter_to_wait_for] { return g_strdup_printf("Filter '%s' not found", filter_to_wait_for.c_str()); }); | ||
3881 | 87 | return filter_ret; | ||
3882 | 88 | } | ||
3883 | 89 | |||
3884 | 90 | Scope::Ptr scope_; | ||
3885 | 91 | }; | ||
3886 | 92 | |||
3887 | 93 | TEST_F(TestScope, TestConnection) | ||
3888 | 94 | { | ||
3889 | 95 | ConnectAndWait(); | ||
3890 | 96 | ASSERT_TRUE(scope_->connected); | ||
3891 | 97 | } | ||
3892 | 98 | |||
3893 | 99 | TEST_F(TestScope, Search) | ||
3894 | 100 | { | ||
3895 | 101 | // Auto-connect on search | ||
3896 | 102 | bool search_ok = false; | ||
3897 | 103 | auto search_callback = [&search_ok] (std::string const& search_string, glib::HintsMap const&, glib::Error const&) { | ||
3898 | 104 | search_ok = true; | ||
3899 | 105 | }; | ||
3900 | 106 | |||
3901 | 107 | scope_->Search("12:test_search", search_callback, nullptr); | ||
3902 | 108 | Utils::WaitUntilMSec(search_ok, | ||
3903 | 109 | 2000, | ||
3904 | 110 | [] { return g_strdup("Search did not finish sucessfully"); }); | ||
3905 | 111 | } | ||
3906 | 112 | |||
3907 | 113 | TEST_F(TestScope, ActivateUri) | ||
3908 | 114 | { | ||
3909 | 115 | // Auto-connect on activate | ||
3910 | 116 | bool activated_return = false; | ||
3911 | 117 | auto activate_callback = [&activated_return] (LocalResult const&, ScopeHandledType, glib::Error const&) { | ||
3912 | 118 | activated_return = true; | ||
3913 | 119 | }; | ||
3914 | 120 | |||
3915 | 121 | LocalResult result; result.uri = "file:://test"; | ||
3916 | 122 | scope_->Activate(result, | ||
3917 | 123 | activate_callback); | ||
3918 | 124 | |||
3919 | 125 | Utils::WaitUntilMSec(activated_return, | ||
3920 | 126 | 2000, | ||
3921 | 127 | [] { return g_strdup("Failed to activate"); }); | ||
3922 | 128 | } | ||
3923 | 129 | |||
3924 | 130 | TEST_F(TestScope, PreviewPerformAction) | ||
3925 | 131 | { | ||
3926 | 132 | Preview::Ptr preview; | ||
3927 | 133 | // Auto-connect on preview | ||
3928 | 134 | bool preview_ok = false; | ||
3929 | 135 | auto preview_callback = [&preview_ok, &preview] (LocalResult const&, Preview::Ptr const& _preview, glib::Error const&) { | ||
3930 | 136 | preview_ok = true; | ||
3931 | 137 | preview = _preview; | ||
3932 | 138 | }; | ||
3933 | 139 | |||
3934 | 140 | LocalResult result; result.uri = "file:://test"; | ||
3935 | 141 | scope_->Preview(result, | ||
3936 | 142 | preview_callback); | ||
3937 | 143 | |||
3938 | 144 | Utils::WaitUntilMSec(preview_ok, | ||
3939 | 145 | 2000, | ||
3940 | 146 | [] { return g_strdup("Failed to preview"); }); | ||
3941 | 147 | EXPECT_TRUE(preview ? true : false); | ||
3942 | 148 | if (preview) | ||
3943 | 149 | { | ||
3944 | 150 | Preview::ActionPtrList actions = preview->GetActions(); | ||
3945 | 151 | // EXPECT_TRUE(actions.size() > 0); | ||
3946 | 152 | for (auto action : actions) | ||
3947 | 153 | preview->PerformAction(action->id); | ||
3948 | 154 | } | ||
3949 | 155 | } | ||
3950 | 156 | |||
3951 | 157 | TEST_F(TestScope, ActivatePreviewAction) | ||
3952 | 158 | { | ||
3953 | 159 | // Auto-connect on preview | ||
3954 | 160 | bool preview_action_ok = false; | ||
3955 | 161 | auto preview_action_callback = [&preview_action_ok] (LocalResult const&, ScopeHandledType, glib::Error const&) { | ||
3956 | 162 | preview_action_ok = true; | ||
3957 | 163 | }; | ||
3958 | 164 | |||
3959 | 165 | LocalResult result; result.uri = "file:://test"; | ||
3960 | 166 | scope_->ActivatePreviewAction("play", | ||
3961 | 167 | result, | ||
3962 | 168 | glib::HintsMap(), | ||
3963 | 169 | preview_action_callback); | ||
3964 | 170 | |||
3965 | 171 | Utils::WaitUntilMSec(preview_action_ok, | ||
3966 | 172 | 2000, | ||
3967 | 173 | [] { return g_strdup("Failed to activate preview action"); }); | ||
3968 | 174 | } | ||
3969 | 175 | |||
3970 | 176 | TEST_F(TestScope, UpdateSearchCategoryWorkflow) | ||
3971 | 177 | { | ||
3972 | 178 | bool search_ok = false; | ||
3973 | 179 | bool search_finished = false; | ||
3974 | 180 | auto search_callback = [&search_ok, &search_finished] (std::string const& search_string, glib::HintsMap const&, glib::Error const& error) { | ||
3975 | 181 | search_finished = true; | ||
3976 | 182 | search_ok = error ? false : true; | ||
3977 | 183 | }; | ||
3978 | 184 | |||
3979 | 185 | // 1. First search | ||
3980 | 186 | scope_->Search("13:cat", search_callback); | ||
3981 | 187 | |||
3982 | 188 | Results::Ptr results = scope_->results(); | ||
3983 | 189 | Utils::WaitUntilMSec(search_ok, 2000, [] { return g_strdup("First search failed."); }); | ||
3984 | 190 | Utils::WaitUntilMSec([results] { return results->count() == 13; }, | ||
3985 | 191 | true, | ||
3986 | 192 | 2000, | ||
3987 | 193 | [results] { return g_strdup_printf("First search. Either search didn't finish, or result count is not as expected (%u != 13).", static_cast<int>(results->count())); }); | ||
3988 | 194 | EXPECT_EQ(search_ok, true); | ||
3989 | 195 | |||
3990 | 196 | Results::Ptr category_model0 = scope_->GetResultsForCategory(0); | ||
3991 | 197 | Results::Ptr category_model1 = scope_->GetResultsForCategory(1); | ||
3992 | 198 | Results::Ptr category_model2 = scope_->GetResultsForCategory(2); | ||
3993 | 199 | |||
3994 | 200 | EXPECT_EQ(category_model0->count(), 5) << "Category 0 result count not as expected (" << category_model0->count() << " != 5)"; | ||
3995 | 201 | EXPECT_EQ(category_model1->count(), 4) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)"; | ||
3996 | 202 | EXPECT_EQ(category_model2->count(), 4) << "Category 2 result count not as expected (" << category_model2->count() << " != 4)"; | ||
3997 | 203 | |||
3998 | 204 | // 2. Update the filter. | ||
3999 | 205 | CheckOptionFilter::Ptr type_filter = std::static_pointer_cast<CheckOptionFilter>(WaitForFilter("categories")); | ||
4000 | 206 | ASSERT_TRUE(type_filter ? true : false); | ||
4001 | 207 | |||
4002 | 208 | bool filter_updated = false; | ||
4003 | 209 | std::vector<FilterOption::Ptr> options = type_filter->options(); | ||
4004 | 210 | for (FilterOption::Ptr const& option : options) | ||
4005 | 211 | { | ||
4006 | 212 | if (option->id == "cat1") | ||
4007 | 213 | { | ||
4008 | 214 | option->active = true; | ||
4009 | 215 | filter_updated = true; | ||
4010 | 216 | } | ||
4011 | 217 | } | ||
4012 | 218 | EXPECT_TRUE(filter_updated) << "Could not update filter opiton 'cat1' of filter 'categories'"; | ||
4013 | 219 | |||
4014 | 220 | // Results should be updated for fulter. | ||
4015 | 221 | Utils::WaitUntilMSec([results] { return results->count() == 4; }, | ||
4016 | 222 | true, | ||
4017 | 223 | 2000, | ||
4018 | 224 | [results] { return g_strdup_printf("First search. Either search didn't finish, or result count is not as expected (%u != 4).", static_cast<int>(results->count())); }); | ||
4019 | 225 | |||
4020 | 226 | category_model0 = scope_->GetResultsForCategory(0); | ||
4021 | 227 | category_model1 = scope_->GetResultsForCategory(1); | ||
4022 | 228 | category_model2 = scope_->GetResultsForCategory(2); | ||
4023 | 229 | |||
4024 | 230 | EXPECT_EQ(category_model0->count(), 0) << "Category 0 result count not as expected (" << category_model0->count() << " != 0)"; | ||
4025 | 231 | EXPECT_EQ(category_model1->count(), 4) << "Category 1 result count not as expected (" << category_model1->count() << " != 4)"; | ||
4026 | 232 | EXPECT_EQ(category_model2->count(), 0) << "Category 2 result count not as expected (" << category_model2->count() << " != 0)"; | ||
4027 | 233 | } | ||
4028 | 234 | |||
4029 | 235 | } // namespace dash | ||
4030 | 236 | } // namespace unity | ||
4031 | 0 | 237 | ||
4032 | === added file 'tests/test_scope_bar.cpp' | |||
4033 | --- tests/test_scope_bar.cpp 1970-01-01 00:00:00 +0000 | |||
4034 | +++ tests/test_scope_bar.cpp 2013-03-21 14:03:22 +0000 | |||
4035 | @@ -0,0 +1,134 @@ | |||
4036 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
4037 | 2 | /* | ||
4038 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
4039 | 4 | * | ||
4040 | 5 | * This program is free software: you can redistribute it and/or modify | ||
4041 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
4042 | 7 | * published by the Free Software Foundation. | ||
4043 | 8 | * | ||
4044 | 9 | * This program is distributed in the hope that it will be useful, | ||
4045 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4046 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4047 | 12 | * GNU General Public License for more details. | ||
4048 | 13 | * | ||
4049 | 14 | * You should have received a copy of the GNU General Public License | ||
4050 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4051 | 16 | * | ||
4052 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
4053 | 18 | */ | ||
4054 | 19 | |||
4055 | 20 | #include <gtest/gtest.h> | ||
4056 | 21 | #include <gmock/gmock.h> | ||
4057 | 22 | #include <dash/ScopeBar.h> | ||
4058 | 23 | |||
4059 | 24 | #include "unity-shared/DashStyle.h" | ||
4060 | 25 | #include "unity-shared/UnitySettings.h" | ||
4061 | 26 | #include "test_mock_scope.h" | ||
4062 | 27 | |||
4063 | 28 | using namespace unity; | ||
4064 | 29 | using namespace unity::dash; | ||
4065 | 30 | |||
4066 | 31 | namespace unity | ||
4067 | 32 | { | ||
4068 | 33 | namespace dash | ||
4069 | 34 | { | ||
4070 | 35 | |||
4071 | 36 | class TestScopeBar : public ::testing::Test | ||
4072 | 37 | { | ||
4073 | 38 | public: | ||
4074 | 39 | TestScopeBar() | ||
4075 | 40 | { | ||
4076 | 41 | } | ||
4077 | 42 | |||
4078 | 43 | void CheckSize(ScopeBar const& scope_bar, int size) | ||
4079 | 44 | { | ||
4080 | 45 | EXPECT_EQ(scope_bar.icons_.size(), size); | ||
4081 | 46 | } | ||
4082 | 47 | |||
4083 | 48 | unity::Settings settings; | ||
4084 | 49 | dash::Style style; | ||
4085 | 50 | }; | ||
4086 | 51 | |||
4087 | 52 | TEST_F(TestScopeBar, TestAddScopes) | ||
4088 | 53 | { | ||
4089 | 54 | ScopeBar scope_bar; | ||
4090 | 55 | |||
4091 | 56 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope1.scope"), "TestScope1", "icon-sub1.svg")); | ||
4092 | 57 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope2.scope"), "TestScope2", "icon-sub2.svg")); | ||
4093 | 58 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope3.scope"), "TestScope3", "icon-sub3.svg")); | ||
4094 | 59 | |||
4095 | 60 | CheckSize(scope_bar, 3); | ||
4096 | 61 | } | ||
4097 | 62 | |||
4098 | 63 | TEST_F(TestScopeBar, TestActivate) | ||
4099 | 64 | { | ||
4100 | 65 | ScopeBar scope_bar; | ||
4101 | 66 | |||
4102 | 67 | std::string active_scope = ""; | ||
4103 | 68 | scope_bar.scope_activated.connect([&active_scope](std::string const& activated) { active_scope = activated; } ); | ||
4104 | 69 | |||
4105 | 70 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope1.scope"), "TestScope1", "icon-sub1.svg")); | ||
4106 | 71 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope2.scope"), "TestScope2", "icon-sub2.svg")); | ||
4107 | 72 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope3.scope"), "TestScope3", "icon-sub3.svg")); | ||
4108 | 73 | |||
4109 | 74 | scope_bar.Activate("testscope1.scope"); | ||
4110 | 75 | EXPECT_EQ(active_scope, "testscope1.scope"); | ||
4111 | 76 | |||
4112 | 77 | scope_bar.Activate("testscope2.scope"); | ||
4113 | 78 | EXPECT_EQ(active_scope, "testscope2.scope"); | ||
4114 | 79 | |||
4115 | 80 | scope_bar.Activate("testscope3.scope"); | ||
4116 | 81 | EXPECT_EQ(active_scope, "testscope3.scope"); | ||
4117 | 82 | } | ||
4118 | 83 | |||
4119 | 84 | TEST_F(TestScopeBar, TestActivateNext) | ||
4120 | 85 | { | ||
4121 | 86 | ScopeBar scope_bar; | ||
4122 | 87 | |||
4123 | 88 | std::string active_scope = ""; | ||
4124 | 89 | scope_bar.scope_activated.connect([&active_scope](std::string const& activated) { active_scope = activated; } ); | ||
4125 | 90 | |||
4126 | 91 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope1.scope"), "TestScope1", "icon-sub1.svg")); | ||
4127 | 92 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope2.scope"), "TestScope2", "icon-sub2.svg")); | ||
4128 | 93 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope3.scope"), "TestScope3", "icon-sub3.svg")); | ||
4129 | 94 | |||
4130 | 95 | scope_bar.ActivateNext(); | ||
4131 | 96 | EXPECT_EQ(active_scope, "testscope1.scope"); | ||
4132 | 97 | |||
4133 | 98 | scope_bar.ActivateNext(); | ||
4134 | 99 | EXPECT_EQ(active_scope, "testscope2.scope"); | ||
4135 | 100 | |||
4136 | 101 | scope_bar.ActivateNext(); | ||
4137 | 102 | EXPECT_EQ(active_scope, "testscope3.scope"); | ||
4138 | 103 | |||
4139 | 104 | scope_bar.ActivateNext(); | ||
4140 | 105 | EXPECT_EQ(active_scope, "testscope1.scope"); | ||
4141 | 106 | } | ||
4142 | 107 | |||
4143 | 108 | TEST_F(TestScopeBar, TestActivatePrevious) | ||
4144 | 109 | { | ||
4145 | 110 | ScopeBar scope_bar; | ||
4146 | 111 | |||
4147 | 112 | std::string active_scope = ""; | ||
4148 | 113 | scope_bar.scope_activated.connect([&active_scope](std::string const& activated) { active_scope = activated; } ); | ||
4149 | 114 | |||
4150 | 115 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope1.scope"), "TestScope1", "icon-sub1.svg")); | ||
4151 | 116 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope2.scope"), "TestScope2", "icon-sub2.svg")); | ||
4152 | 117 | scope_bar.AddScope(std::make_shared<MockScope>(std::make_shared<MockScopeData>("testscope3.scope"), "TestScope3", "icon-sub3.svg")); | ||
4153 | 118 | |||
4154 | 119 | scope_bar.ActivatePrevious(); | ||
4155 | 120 | EXPECT_EQ(active_scope, "testscope3.scope"); | ||
4156 | 121 | |||
4157 | 122 | scope_bar.ActivatePrevious(); | ||
4158 | 123 | EXPECT_EQ(active_scope, "testscope2.scope"); | ||
4159 | 124 | |||
4160 | 125 | scope_bar.ActivatePrevious(); | ||
4161 | 126 | EXPECT_EQ(active_scope, "testscope1.scope"); | ||
4162 | 127 | |||
4163 | 128 | scope_bar.ActivatePrevious(); | ||
4164 | 129 | EXPECT_EQ(active_scope, "testscope3.scope"); | ||
4165 | 130 | } | ||
4166 | 131 | |||
4167 | 132 | |||
4168 | 133 | } | ||
4169 | 134 | } | ||
4170 | 0 | 135 | ||
4171 | === added file 'tests/test_scope_data.cpp' | |||
4172 | --- tests/test_scope_data.cpp 1970-01-01 00:00:00 +0000 | |||
4173 | +++ tests/test_scope_data.cpp 2013-03-21 14:03:22 +0000 | |||
4174 | @@ -0,0 +1,67 @@ | |||
4175 | 1 | /* | ||
4176 | 2 | * Copyright (C) 2013 Canonical Ltd | ||
4177 | 3 | * | ||
4178 | 4 | * This program is free software: you can redistribute it and/or modify | ||
4179 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
4180 | 6 | * published by the Free Software Foundation. | ||
4181 | 7 | * | ||
4182 | 8 | * This program is distributed in the hope that it will be useful, | ||
4183 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4184 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4185 | 11 | * GNU General Public License for more details. | ||
4186 | 12 | * | ||
4187 | 13 | * You should have received a copy of the GNU General Public License | ||
4188 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4189 | 15 | * | ||
4190 | 16 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
4191 | 17 | */ | ||
4192 | 18 | |||
4193 | 19 | #include <gtest/gtest.h> | ||
4194 | 20 | #include <glib-object.h> | ||
4195 | 21 | #include "test_utils.h" | ||
4196 | 22 | #include "UnityCore/ScopeData.cpp" | ||
4197 | 23 | |||
4198 | 24 | using namespace std; | ||
4199 | 25 | using namespace unity; | ||
4200 | 26 | using namespace unity::dash; | ||
4201 | 27 | |||
4202 | 28 | namespace | ||
4203 | 29 | { | ||
4204 | 30 | |||
4205 | 31 | // A new one of these is created for each test | ||
4206 | 32 | class TestScopeData : public testing::Test | ||
4207 | 33 | { | ||
4208 | 34 | public: | ||
4209 | 35 | TestScopeData() | ||
4210 | 36 | {} | ||
4211 | 37 | }; | ||
4212 | 38 | |||
4213 | 39 | TEST_F(TestScopeData, TestReadExisting) | ||
4214 | 40 | { | ||
4215 | 41 | glib::Error error; | ||
4216 | 42 | ScopeData::Ptr scope_data(ScopeData::ReadProtocolDataForId("testscope1.scope", error)); | ||
4217 | 43 | ASSERT_TRUE(scope_data && !error); | ||
4218 | 44 | |||
4219 | 45 | EXPECT_EQ(scope_data->id(), "testscope1.scope"); | ||
4220 | 46 | EXPECT_EQ(scope_data->name(), "TestScope1"); | ||
4221 | 47 | EXPECT_EQ(scope_data->dbus_name(), "com.canonical.Unity.Test.Scope"); | ||
4222 | 48 | EXPECT_EQ(scope_data->dbus_path(), "/com/canonical/unity/scope/testscope1"); | ||
4223 | 49 | EXPECT_EQ(scope_data->icon_hint(), "/usr/share/unity/6/icon-sub1.svg"); | ||
4224 | 50 | EXPECT_EQ(scope_data->category_icon_hint(), ""); | ||
4225 | 51 | EXPECT_EQ(scope_data->type(), "varia"); | ||
4226 | 52 | EXPECT_EQ(scope_data->query_pattern(), "^@"); | ||
4227 | 53 | EXPECT_EQ(scope_data->description(), "Find various stuff 1"); | ||
4228 | 54 | EXPECT_EQ(scope_data->shortcut(), "q"); | ||
4229 | 55 | EXPECT_EQ(scope_data->search_hint(), "Search stuff 1"); | ||
4230 | 56 | EXPECT_TRUE(scope_data->keywords().size() == 1 && scope_data->keywords().front()=="misc"); | ||
4231 | 57 | // EXPECT_EQ(scope_data->full_path(), ""); | ||
4232 | 58 | } | ||
4233 | 59 | |||
4234 | 60 | TEST_F(TestScopeData, TestNonExisting) | ||
4235 | 61 | { | ||
4236 | 62 | glib::Error error; | ||
4237 | 63 | ScopeData::Ptr scope_data(ScopeData::ReadProtocolDataForId("non-existing.scope", error)); | ||
4238 | 64 | EXPECT_TRUE(scope_data && error); | ||
4239 | 65 | } | ||
4240 | 66 | |||
4241 | 67 | } | ||
4242 | 0 | 68 | ||
4243 | === added file 'tests/test_scope_filter.cpp' | |||
4244 | --- tests/test_scope_filter.cpp 1970-01-01 00:00:00 +0000 | |||
4245 | +++ tests/test_scope_filter.cpp 2013-03-21 14:03:22 +0000 | |||
4246 | @@ -0,0 +1,335 @@ | |||
4247 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
4248 | 2 | /* | ||
4249 | 3 | * Copyright (C) 2013 Canonical Ltd | ||
4250 | 4 | * | ||
4251 | 5 | * This program is free software: you can redistribute it and/or modify | ||
4252 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
4253 | 7 | * published by the Free Software Foundation. | ||
4254 | 8 | * | ||
4255 | 9 | * This program is distributed in the hope that it will be useful, | ||
4256 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4257 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4258 | 12 | * GNU General Public License for more details. | ||
4259 | 13 | * | ||
4260 | 14 | * You should have received a copy of the GNU General Public License | ||
4261 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4262 | 16 | * | ||
4263 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
4264 | 18 | */ | ||
4265 | 19 | |||
4266 | 20 | #include <boost/lexical_cast.hpp> | ||
4267 | 21 | #include <gtest/gtest.h> | ||
4268 | 22 | #include <glib-object.h> | ||
4269 | 23 | #include <unity-protocol.h> | ||
4270 | 24 | |||
4271 | 25 | #include <UnityCore/GLibWrapper.h> | ||
4272 | 26 | #include <UnityCore/Scope.h> | ||
4273 | 27 | #include <UnityCore/Variant.h> | ||
4274 | 28 | |||
4275 | 29 | #include <UnityCore/CheckOptionFilter.h> | ||
4276 | 30 | #include <UnityCore/MultiRangeFilter.h> | ||
4277 | 31 | #include <UnityCore/RadioOptionFilter.h> | ||
4278 | 32 | #include <UnityCore/RatingsFilter.h> | ||
4279 | 33 | |||
4280 | 34 | #include "test_utils.h" | ||
4281 | 35 | |||
4282 | 36 | using namespace std; | ||
4283 | 37 | using namespace unity; | ||
4284 | 38 | using namespace unity::dash; | ||
4285 | 39 | |||
4286 | 40 | namespace unity | ||
4287 | 41 | { | ||
4288 | 42 | namespace dash | ||
4289 | 43 | { | ||
4290 | 44 | |||
4291 | 45 | namespace | ||
4292 | 46 | { | ||
4293 | 47 | const std::string SCOPE_NAME = "testscope1.scope"; | ||
4294 | 48 | } | ||
4295 | 49 | |||
4296 | 50 | class TestScopeFilter : public ::testing::Test | ||
4297 | 51 | { | ||
4298 | 52 | public: | ||
4299 | 53 | TestScopeFilter() { } | ||
4300 | 54 | |||
4301 | 55 | virtual void SetUp() | ||
4302 | 56 | { | ||
4303 | 57 | glib::Error err; | ||
4304 | 58 | ScopeData::Ptr data(ScopeData::ReadProtocolDataForId(SCOPE_NAME, err)); | ||
4305 | 59 | ASSERT_TRUE(err ? false : true); | ||
4306 | 60 | |||
4307 | 61 | scope_.reset(new Scope(data)); | ||
4308 | 62 | scope_->Init(); | ||
4309 | 63 | ConnectAndWait(); | ||
4310 | 64 | } | ||
4311 | 65 | |||
4312 | 66 | void ConnectAndWait() | ||
4313 | 67 | { | ||
4314 | 68 | scope_->Connect(); | ||
4315 | 69 | Utils::WaitUntilMSec([this] { return scope_->connected() == true; }, true, 2000); | ||
4316 | 70 | } | ||
4317 | 71 | |||
4318 | 72 | void WaitForSynchronize(Filters::Ptr const& model, unsigned int count) | ||
4319 | 73 | { | ||
4320 | 74 | Utils::WaitUntil([model,count] { return model->count == count; }); | ||
4321 | 75 | } | ||
4322 | 76 | |||
4323 | 77 | Scope::Ptr scope_; | ||
4324 | 78 | }; | ||
4325 | 79 | |||
4326 | 80 | TEST_F(TestScopeFilter, TestFilterCheckOption) | ||
4327 | 81 | { | ||
4328 | 82 | Filters::Ptr filters = scope_->filters; | ||
4329 | 83 | WaitForSynchronize(filters, 4); | ||
4330 | 84 | |||
4331 | 85 | CheckOptionFilter::Ptr filter = static_pointer_cast<CheckOptionFilter>(filters->FilterAtIndex(0)); | ||
4332 | 86 | EXPECT_EQ(filter->id, "categories"); | ||
4333 | 87 | EXPECT_EQ(filter->name, "Categories"); | ||
4334 | 88 | EXPECT_EQ(filter->icon_hint, ""); | ||
4335 | 89 | EXPECT_EQ(filter->renderer_name, "filter-checkoption"); | ||
4336 | 90 | EXPECT_TRUE(filter->visible); | ||
4337 | 91 | EXPECT_FALSE(filter->collapsed); | ||
4338 | 92 | EXPECT_FALSE(filter->filtering); | ||
4339 | 93 | |||
4340 | 94 | CheckOptionFilter::CheckOptions options = filter->options; | ||
4341 | 95 | EXPECT_EQ(options.size(), (unsigned int)3); | ||
4342 | 96 | |||
4343 | 97 | EXPECT_EQ(options[0]->id, "cat0"); | ||
4344 | 98 | EXPECT_EQ(options[0]->name, "Category 0"); | ||
4345 | 99 | EXPECT_EQ(options[0]->icon_hint, "gtk-cdrom"); | ||
4346 | 100 | EXPECT_FALSE(options[0]->active); | ||
4347 | 101 | |||
4348 | 102 | EXPECT_EQ(options[1]->id, "cat1"); | ||
4349 | 103 | EXPECT_EQ(options[1]->name, "Category 1"); | ||
4350 | 104 | EXPECT_EQ(options[1]->icon_hint, "gtk-directory"); | ||
4351 | 105 | EXPECT_FALSE(options[1]->active); | ||
4352 | 106 | |||
4353 | 107 | EXPECT_EQ(options[2]->id, "cat2"); | ||
4354 | 108 | EXPECT_EQ(options[2]->name, "Category 2"); | ||
4355 | 109 | EXPECT_EQ(options[2]->icon_hint, "gtk-clear"); | ||
4356 | 110 | EXPECT_FALSE(options[2]->active); | ||
4357 | 111 | } | ||
4358 | 112 | |||
4359 | 113 | TEST_F(TestScopeFilter, TestFilterCheckOptionLogic) | ||
4360 | 114 | { | ||
4361 | 115 | Filters::Ptr filters = scope_->filters; | ||
4362 | 116 | WaitForSynchronize(filters, 4); | ||
4363 | 117 | |||
4364 | 118 | CheckOptionFilter::Ptr filter = static_pointer_cast<CheckOptionFilter>(filters->FilterAtIndex(0)); | ||
4365 | 119 | CheckOptionFilter::CheckOptions options = filter->options; | ||
4366 | 120 | |||
4367 | 121 | EXPECT_FALSE (filter->filtering); | ||
4368 | 122 | EXPECT_FALSE (options[0]->active); | ||
4369 | 123 | EXPECT_FALSE (options[1]->active); | ||
4370 | 124 | EXPECT_FALSE (options[2]->active); | ||
4371 | 125 | |||
4372 | 126 | options[0]->active = true; | ||
4373 | 127 | options[0]->active = false; | ||
4374 | 128 | EXPECT_FALSE (filter->filtering); | ||
4375 | 129 | EXPECT_FALSE (options[0]->active); | ||
4376 | 130 | EXPECT_FALSE (options[1]->active); | ||
4377 | 131 | EXPECT_FALSE (options[2]->active); | ||
4378 | 132 | |||
4379 | 133 | options[0]->active = true; | ||
4380 | 134 | EXPECT_TRUE (filter->filtering); | ||
4381 | 135 | EXPECT_TRUE (options[0]->active); | ||
4382 | 136 | EXPECT_FALSE (options[1]->active); | ||
4383 | 137 | EXPECT_FALSE (options[2]->active); | ||
4384 | 138 | |||
4385 | 139 | options[1]->active = true; | ||
4386 | 140 | EXPECT_TRUE (filter->filtering); | ||
4387 | 141 | EXPECT_TRUE (options[0]->active); | ||
4388 | 142 | EXPECT_TRUE (options[1]->active); | ||
4389 | 143 | EXPECT_FALSE (options[2]->active); | ||
4390 | 144 | |||
4391 | 145 | options[2]->active = true; | ||
4392 | 146 | EXPECT_TRUE (filter->filtering); | ||
4393 | 147 | EXPECT_TRUE (options[0]->active); | ||
4394 | 148 | EXPECT_TRUE (options[1]->active); | ||
4395 | 149 | EXPECT_TRUE (options[2]->active); | ||
4396 | 150 | |||
4397 | 151 | filter->Clear(); | ||
4398 | 152 | EXPECT_FALSE (filter->filtering); | ||
4399 | 153 | EXPECT_FALSE (options[0]->active); | ||
4400 | 154 | EXPECT_FALSE (options[1]->active); | ||
4401 | 155 | EXPECT_FALSE (options[2]->active); | ||
4402 | 156 | } | ||
4403 | 157 | |||
4404 | 158 | TEST_F(TestScopeFilter, TestFilterRadioOption) | ||
4405 | 159 | { | ||
4406 | 160 | Filters::Ptr filters = scope_->filters; | ||
4407 | 161 | WaitForSynchronize(filters, 4); | ||
4408 | 162 | |||
4409 | 163 | RadioOptionFilter::Ptr filter = static_pointer_cast<RadioOptionFilter>(filters->FilterAtIndex(1)); | ||
4410 | 164 | EXPECT_EQ(filter->id, "when"); | ||
4411 | 165 | EXPECT_EQ(filter->name, "When"); | ||
4412 | 166 | EXPECT_EQ(filter->icon_hint, ""); | ||
4413 | 167 | EXPECT_EQ(filter->renderer_name, "filter-radiooption"); | ||
4414 | 168 | EXPECT_TRUE(filter->visible); | ||
4415 | 169 | EXPECT_FALSE(filter->collapsed); | ||
4416 | 170 | EXPECT_FALSE(filter->filtering); | ||
4417 | 171 | |||
4418 | 172 | RadioOptionFilter::RadioOptions options = filter->options; | ||
4419 | 173 | EXPECT_EQ(options.size(), (unsigned int)3); | ||
4420 | 174 | |||
4421 | 175 | EXPECT_EQ(options[0]->id, "today"); | ||
4422 | 176 | EXPECT_EQ(options[0]->name, "Today"); | ||
4423 | 177 | EXPECT_EQ(options[0]->icon_hint, ""); | ||
4424 | 178 | EXPECT_FALSE(options[0]->active); | ||
4425 | 179 | |||
4426 | 180 | EXPECT_EQ(options[1]->id, "yesterday"); | ||
4427 | 181 | EXPECT_EQ(options[1]->name, "Yesterday"); | ||
4428 | 182 | EXPECT_EQ(options[1]->icon_hint, ""); | ||
4429 | 183 | EXPECT_FALSE(options[1]->active); | ||
4430 | 184 | |||
4431 | 185 | EXPECT_EQ(options[2]->id, "lastweek"); | ||
4432 | 186 | EXPECT_EQ(options[2]->name, "Last Week"); | ||
4433 | 187 | EXPECT_EQ(options[2]->icon_hint, ""); | ||
4434 | 188 | EXPECT_FALSE(options[2]->active); | ||
4435 | 189 | } | ||
4436 | 190 | |||
4437 | 191 | TEST_F(TestScopeFilter, TestFilterRadioOptionLogic) | ||
4438 | 192 | { | ||
4439 | 193 | Filters::Ptr filters = scope_->filters; | ||
4440 | 194 | WaitForSynchronize(filters, 4); | ||
4441 | 195 | |||
4442 | 196 | RadioOptionFilter::Ptr filter = static_pointer_cast<RadioOptionFilter>(filters->FilterAtIndex(1)); | ||
4443 | 197 | RadioOptionFilter::RadioOptions options = filter->options; | ||
4444 | 198 | |||
4445 | 199 | EXPECT_FALSE (filter->filtering); | ||
4446 | 200 | EXPECT_FALSE (options[0]->active); | ||
4447 | 201 | EXPECT_FALSE (options[1]->active); | ||
4448 | 202 | EXPECT_FALSE (options[2]->active); | ||
4449 | 203 | |||
4450 | 204 | options[0]->active = true; | ||
4451 | 205 | options[0]->active = false; | ||
4452 | 206 | EXPECT_FALSE (filter->filtering); | ||
4453 | 207 | EXPECT_FALSE (options[0]->active); | ||
4454 | 208 | EXPECT_FALSE (options[1]->active); | ||
4455 | 209 | EXPECT_FALSE (options[2]->active); | ||
4456 | 210 | |||
4457 | 211 | options[0]->active = true; | ||
4458 | 212 | EXPECT_TRUE (filter->filtering); | ||
4459 | 213 | EXPECT_TRUE (options[0]->active); | ||
4460 | 214 | EXPECT_FALSE (options[1]->active); | ||
4461 | 215 | EXPECT_FALSE (options[2]->active); | ||
4462 | 216 | |||
4463 | 217 | options[1]->active = true; | ||
4464 | 218 | EXPECT_TRUE (filter->filtering); | ||
4465 | 219 | EXPECT_FALSE (options[0]->active); | ||
4466 | 220 | EXPECT_TRUE (options[1]->active); | ||
4467 | 221 | EXPECT_FALSE (options[2]->active); | ||
4468 | 222 | |||
4469 | 223 | options[2]->active = true; | ||
4470 | 224 | EXPECT_TRUE (filter->filtering); | ||
4471 | 225 | EXPECT_FALSE (options[0]->active); | ||
4472 | 226 | EXPECT_FALSE (options[1]->active); | ||
4473 | 227 | EXPECT_TRUE (options[2]->active); | ||
4474 | 228 | |||
4475 | 229 | filter->Clear(); | ||
4476 | 230 | EXPECT_FALSE (filter->filtering); | ||
4477 | 231 | EXPECT_FALSE (options[0]->active); | ||
4478 | 232 | EXPECT_FALSE (options[1]->active); | ||
4479 | 233 | EXPECT_FALSE (options[2]->active); | ||
4480 | 234 | } | ||
4481 | 235 | |||
4482 | 236 | TEST_F(TestScopeFilter, TestFilterRatings) | ||
4483 | 237 | { | ||
4484 | 238 | Filters::Ptr filters = scope_->filters; | ||
4485 | 239 | WaitForSynchronize(filters, 4); | ||
4486 | 240 | |||
4487 | 241 | RatingsFilter::Ptr filter = static_pointer_cast<RatingsFilter>(filters->FilterAtIndex(2)); | ||
4488 | 242 | EXPECT_EQ(filter->id, "ratings"); | ||
4489 | 243 | EXPECT_EQ(filter->name, "Ratings"); | ||
4490 | 244 | EXPECT_EQ(filter->icon_hint, ""); | ||
4491 | 245 | std::string tmp = filter->renderer_name; | ||
4492 | 246 | EXPECT_EQ(filter->renderer_name, "filter-ratings"); | ||
4493 | 247 | EXPECT_TRUE(filter->visible); | ||
4494 | 248 | EXPECT_FALSE(filter->collapsed); | ||
4495 | 249 | EXPECT_FALSE(filter->filtering); | ||
4496 | 250 | |||
4497 | 251 | EXPECT_FLOAT_EQ(filter->rating, 0.0f); | ||
4498 | 252 | filter->rating = 0.5f; | ||
4499 | 253 | EXPECT_FLOAT_EQ(filter->rating, 0.5f); | ||
4500 | 254 | } | ||
4501 | 255 | |||
4502 | 256 | TEST_F(TestScopeFilter, TestFilterMultiRange) | ||
4503 | 257 | { | ||
4504 | 258 | Filters::Ptr filters = scope_->filters; | ||
4505 | 259 | WaitForSynchronize(filters, 4); | ||
4506 | 260 | |||
4507 | 261 | MultiRangeFilter::Ptr filter = static_pointer_cast<MultiRangeFilter>(filters->FilterAtIndex(3)); | ||
4508 | 262 | EXPECT_EQ(filter->id, "size"); | ||
4509 | 263 | EXPECT_EQ(filter->name, "Size"); | ||
4510 | 264 | EXPECT_EQ(filter->icon_hint, ""); | ||
4511 | 265 | std::string tmp = filter->renderer_name; | ||
4512 | 266 | EXPECT_EQ(filter->renderer_name, "filter-multirange"); | ||
4513 | 267 | EXPECT_TRUE(filter->visible); | ||
4514 | 268 | EXPECT_TRUE(filter->collapsed); | ||
4515 | 269 | EXPECT_FALSE(filter->filtering); | ||
4516 | 270 | |||
4517 | 271 | MultiRangeFilter::Options options = filter->options; | ||
4518 | 272 | EXPECT_EQ(options.size(), (unsigned int)4); | ||
4519 | 273 | |||
4520 | 274 | EXPECT_EQ(options[0]->id, "1MB"); | ||
4521 | 275 | EXPECT_EQ(options[0]->name, "1MB"); | ||
4522 | 276 | EXPECT_EQ(options[0]->icon_hint, ""); | ||
4523 | 277 | EXPECT_FALSE(options[0]->active); | ||
4524 | 278 | |||
4525 | 279 | EXPECT_EQ(options[1]->id, "10MB"); | ||
4526 | 280 | EXPECT_EQ(options[1]->name, "10MB"); | ||
4527 | 281 | EXPECT_EQ(options[1]->icon_hint, ""); | ||
4528 | 282 | EXPECT_FALSE(options[1]->active); | ||
4529 | 283 | |||
4530 | 284 | EXPECT_EQ(options[2]->id, "100MB"); | ||
4531 | 285 | EXPECT_EQ(options[2]->name, "100MB"); | ||
4532 | 286 | EXPECT_EQ(options[2]->icon_hint, ""); | ||
4533 | 287 | EXPECT_FALSE(options[2]->active); | ||
4534 | 288 | } | ||
4535 | 289 | |||
4536 | 290 | TEST_F(TestScopeFilter, TestFilterMultiRangeLogic) | ||
4537 | 291 | { | ||
4538 | 292 | Filters::Ptr filters = scope_->filters; | ||
4539 | 293 | WaitForSynchronize(filters, 4); | ||
4540 | 294 | |||
4541 | 295 | MultiRangeFilter::Ptr filter = static_pointer_cast<MultiRangeFilter>(filters->FilterAtIndex(3)); | ||
4542 | 296 | MultiRangeFilter::Options options = filter->options; | ||
4543 | 297 | |||
4544 | 298 | EXPECT_FALSE (filter->filtering); | ||
4545 | 299 | EXPECT_FALSE (options[0]->active); | ||
4546 | 300 | EXPECT_FALSE (options[1]->active); | ||
4547 | 301 | EXPECT_FALSE (options[2]->active); | ||
4548 | 302 | EXPECT_FALSE (options[3]->active); | ||
4549 | 303 | |||
4550 | 304 | options[0]->active = true; | ||
4551 | 305 | EXPECT_TRUE (options[0]->active); | ||
4552 | 306 | EXPECT_TRUE (filter->filtering); | ||
4553 | 307 | options[3]->active = true; | ||
4554 | 308 | EXPECT_FALSE (options[0]->active); | ||
4555 | 309 | EXPECT_TRUE (options[3]->active); | ||
4556 | 310 | |||
4557 | 311 | options[0]->active = true; | ||
4558 | 312 | options[1]->active = true; | ||
4559 | 313 | EXPECT_TRUE (filter->filtering); | ||
4560 | 314 | EXPECT_TRUE (options[0]->active); | ||
4561 | 315 | EXPECT_TRUE (options[1]->active); | ||
4562 | 316 | EXPECT_FALSE (options[2]->active); | ||
4563 | 317 | EXPECT_FALSE (options[3]->active); | ||
4564 | 318 | |||
4565 | 319 | options[0]->active = false; | ||
4566 | 320 | EXPECT_TRUE (filter->filtering); | ||
4567 | 321 | EXPECT_FALSE (options[0]->active); | ||
4568 | 322 | EXPECT_TRUE (options[1]->active); | ||
4569 | 323 | EXPECT_FALSE (options[2]->active); | ||
4570 | 324 | EXPECT_FALSE (options[3]->active); | ||
4571 | 325 | |||
4572 | 326 | filter->Clear(); | ||
4573 | 327 | EXPECT_FALSE (filter->filtering); | ||
4574 | 328 | EXPECT_FALSE (options[0]->active); | ||
4575 | 329 | EXPECT_FALSE (options[1]->active); | ||
4576 | 330 | EXPECT_FALSE (options[2]->active); | ||
4577 | 331 | EXPECT_FALSE (options[3]->active); | ||
4578 | 332 | } | ||
4579 | 333 | |||
4580 | 334 | } | ||
4581 | 335 | } | ||
4582 | 0 | 336 | ||
4583 | === added file 'tests/test_scope_impl.c' | |||
4584 | --- tests/test_scope_impl.c 1970-01-01 00:00:00 +0000 | |||
4585 | +++ tests/test_scope_impl.c 2013-03-21 14:03:22 +0000 | |||
4586 | @@ -0,0 +1,511 @@ | |||
4587 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
4588 | 2 | /* | ||
4589 | 3 | * Copyright (C) 2013 Canonical Ltd | ||
4590 | 4 | * | ||
4591 | 5 | * This program is free software: you can redistribute it and/or modify | ||
4592 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
4593 | 7 | * published by the Free Software Foundation. | ||
4594 | 8 | * | ||
4595 | 9 | * This program is distributed in the hope that it will be useful, | ||
4596 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4597 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4598 | 12 | * GNU General Public License for more details. | ||
4599 | 13 | * | ||
4600 | 14 | * You should have received a copy of the GNU General Public License | ||
4601 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4602 | 16 | * | ||
4603 | 17 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
4604 | 18 | */ | ||
4605 | 19 | |||
4606 | 20 | #include "test_scope_impl.h" | ||
4607 | 21 | #include <unity.h> | ||
4608 | 22 | |||
4609 | 23 | #include <stdio.h> | ||
4610 | 24 | |||
4611 | 25 | #define TEST_DBUS_NAME "com.canonical.Unity.Test.Scope" | ||
4612 | 26 | |||
4613 | 27 | #define _g_object_unref_safe(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) | ||
4614 | 28 | #define _g_free_safe(var) (var = (g_free (var), NULL)) | ||
4615 | 29 | |||
4616 | 30 | /* ------------------ Test Searcher ---------------------- */ | ||
4617 | 31 | |||
4618 | 32 | #define TEST_TYPE_SEARCHER (test_searcher_get_type ()) | ||
4619 | 33 | #define TEST_SCOPE_SEARCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_SEARCHER, TestSearcher)) | ||
4620 | 34 | #define TEST_SEARCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_SEARCHER, TestSearcherClass)) | ||
4621 | 35 | #define TEST_IS_SEARCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_SEARCHER)) | ||
4622 | 36 | #define TEST_IS_SEARCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_SEARCHER)) | ||
4623 | 37 | #define TEST_SEARCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SEARCHER, TestSearcherClass)) | ||
4624 | 38 | |||
4625 | 39 | typedef struct _TestSearcher TestSearcher; | ||
4626 | 40 | typedef struct _TestSearcherClass TestSearcherClass; | ||
4627 | 41 | typedef struct _TestSearcherPrivate TestSearcherPrivate; | ||
4628 | 42 | |||
4629 | 43 | struct _TestSearcher { | ||
4630 | 44 | UnityScopeSearchBase parent_instance; | ||
4631 | 45 | TestSearcherPrivate * priv; | ||
4632 | 46 | }; | ||
4633 | 47 | |||
4634 | 48 | struct _TestSearcherClass { | ||
4635 | 49 | UnityScopeSearchBaseClass parent_class; | ||
4636 | 50 | }; | ||
4637 | 51 | |||
4638 | 52 | struct _TestSearcherPrivate { | ||
4639 | 53 | TestScope* _owner; | ||
4640 | 54 | }; | ||
4641 | 55 | |||
4642 | 56 | typedef struct _SearcherRunData SearcherRunData; | ||
4643 | 57 | |||
4644 | 58 | G_DEFINE_TYPE(TestSearcher, test_searcher, UNITY_TYPE_SCOPE_SEARCH_BASE); | ||
4645 | 59 | |||
4646 | 60 | #define TEST_SEARCHER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_TYPE_SEARCHER, TestSearcherPrivate)) | ||
4647 | 61 | enum { | ||
4648 | 62 | TEST_SEARCHER_DUMMY_PROPERTY, | ||
4649 | 63 | TEST_SEARCHER_OWNER | ||
4650 | 64 | }; | ||
4651 | 65 | |||
4652 | 66 | static TestSearcher* test_searcher_new (TestScope* scope); | ||
4653 | 67 | static void test_searcher_run_async (UnityScopeSearchBase* self, UnityScopeSearchBaseCallback async_callback, void* async_callback_target); | ||
4654 | 68 | static void test_searcher_run (UnityScopeSearchBase* base); | ||
4655 | 69 | static TestScope* test_searcher_get_owner (TestSearcher* self); | ||
4656 | 70 | static void test_searcher_set_owner (TestSearcher* self, TestScope* value); | ||
4657 | 71 | static void test_searcher_finalize (GObject* obj); | ||
4658 | 72 | static void test_searcher_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); | ||
4659 | 73 | static void test_searcher_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); | ||
4660 | 74 | |||
4661 | 75 | static TestSearcher* test_searcher_new (TestScope* scope) | ||
4662 | 76 | { | ||
4663 | 77 | return (TestSearcher*) g_object_new (TEST_TYPE_SEARCHER, "owner", scope, NULL); | ||
4664 | 78 | } | ||
4665 | 79 | |||
4666 | 80 | static TestScope* test_searcher_get_owner (TestSearcher* self) | ||
4667 | 81 | { | ||
4668 | 82 | g_return_val_if_fail (self != NULL, NULL); | ||
4669 | 83 | return self->priv->_owner; | ||
4670 | 84 | } | ||
4671 | 85 | |||
4672 | 86 | static void test_searcher_set_owner (TestSearcher* self, TestScope* value) | ||
4673 | 87 | { | ||
4674 | 88 | g_return_if_fail (self != NULL); | ||
4675 | 89 | self->priv->_owner = value; | ||
4676 | 90 | g_object_notify ((GObject *) self, "owner"); | ||
4677 | 91 | } | ||
4678 | 92 | |||
4679 | 93 | static void test_searcher_class_init (TestSearcherClass * klass) | ||
4680 | 94 | { | ||
4681 | 95 | g_type_class_add_private (klass, sizeof (TestSearcherPrivate)); | ||
4682 | 96 | UNITY_SCOPE_SEARCH_BASE_CLASS (klass)->run_async = test_searcher_run_async; | ||
4683 | 97 | UNITY_SCOPE_SEARCH_BASE_CLASS (klass)->run = test_searcher_run; | ||
4684 | 98 | G_OBJECT_CLASS (klass)->get_property = test_searcher_get_property; | ||
4685 | 99 | G_OBJECT_CLASS (klass)->set_property = test_searcher_set_property; | ||
4686 | 100 | G_OBJECT_CLASS (klass)->finalize = test_searcher_finalize; | ||
4687 | 101 | g_object_class_install_property (G_OBJECT_CLASS (klass), TEST_SEARCHER_OWNER, g_param_spec_object ("owner", "owner", "owner", TEST_TYPE_SCOPE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); | ||
4688 | 102 | } | ||
4689 | 103 | |||
4690 | 104 | static void test_searcher_init(TestSearcher* self) | ||
4691 | 105 | { | ||
4692 | 106 | self->priv = TEST_SEARCHER_GET_PRIVATE (self); | ||
4693 | 107 | } | ||
4694 | 108 | |||
4695 | 109 | static void test_searcher_finalize (GObject* obj) | ||
4696 | 110 | { | ||
4697 | 111 | TestSearcher * self; | ||
4698 | 112 | self = TEST_SCOPE_SEARCHER (obj); | ||
4699 | 113 | G_OBJECT_CLASS (test_searcher_parent_class)->finalize (obj); | ||
4700 | 114 | } | ||
4701 | 115 | |||
4702 | 116 | static void test_searcher_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) | ||
4703 | 117 | { | ||
4704 | 118 | TestSearcher * self; | ||
4705 | 119 | self = TEST_SCOPE_SEARCHER (object); | ||
4706 | 120 | switch (property_id) { | ||
4707 | 121 | case TEST_SEARCHER_OWNER: | ||
4708 | 122 | g_value_set_object (value, test_searcher_get_owner (self)); | ||
4709 | 123 | break; | ||
4710 | 124 | default: | ||
4711 | 125 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
4712 | 126 | break; | ||
4713 | 127 | } | ||
4714 | 128 | } | ||
4715 | 129 | |||
4716 | 130 | static void test_searcher_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) | ||
4717 | 131 | { | ||
4718 | 132 | TestSearcher * self; | ||
4719 | 133 | self = TEST_SCOPE_SEARCHER (object); | ||
4720 | 134 | switch (property_id) { | ||
4721 | 135 | case TEST_SEARCHER_OWNER: | ||
4722 | 136 | test_searcher_set_owner (self, g_value_get_object (value)); | ||
4723 | 137 | break; | ||
4724 | 138 | default: | ||
4725 | 139 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
4726 | 140 | break; | ||
4727 | 141 | } | ||
4728 | 142 | } | ||
4729 | 143 | |||
4730 | 144 | struct _SearcherRunData | ||
4731 | 145 | { | ||
4732 | 146 | int _ref_count_; | ||
4733 | 147 | TestSearcher * self; | ||
4734 | 148 | GMainLoop* ml; | ||
4735 | 149 | UnityScopeSearchBaseCallback async_callback; | ||
4736 | 150 | void* async_callback_target; | ||
4737 | 151 | }; | ||
4738 | 152 | |||
4739 | 153 | static SearcherRunData* run_data_ref (SearcherRunData* data) | ||
4740 | 154 | { | ||
4741 | 155 | g_atomic_int_inc (&data->_ref_count_); | ||
4742 | 156 | return data; | ||
4743 | 157 | } | ||
4744 | 158 | |||
4745 | 159 | static void run_data_unref (void * _userdata_) | ||
4746 | 160 | { | ||
4747 | 161 | SearcherRunData* data; | ||
4748 | 162 | data = (SearcherRunData*) _userdata_; | ||
4749 | 163 | if (g_atomic_int_dec_and_test (&data->_ref_count_)) | ||
4750 | 164 | { | ||
4751 | 165 | TestSearcher* self; | ||
4752 | 166 | self = data->self; | ||
4753 | 167 | g_main_loop_unref (data->ml); | ||
4754 | 168 | g_object_unref (self); | ||
4755 | 169 | g_slice_free (SearcherRunData, data); | ||
4756 | 170 | } | ||
4757 | 171 | } | ||
4758 | 172 | |||
4759 | 173 | static gboolean test_searcher_main_loop_func (gpointer data) | ||
4760 | 174 | { | ||
4761 | 175 | SearcherRunData* search_data; | ||
4762 | 176 | search_data = (SearcherRunData*) data; | ||
4763 | 177 | |||
4764 | 178 | TestSearcher* self; | ||
4765 | 179 | self = search_data->self; | ||
4766 | 180 | UNITY_SCOPE_SEARCH_BASE_GET_CLASS (self)->run(UNITY_SCOPE_SEARCH_BASE (self)); | ||
4767 | 181 | |||
4768 | 182 | search_data->async_callback (UNITY_SCOPE_SEARCH_BASE (self), search_data->async_callback_target); | ||
4769 | 183 | g_main_loop_quit (search_data->ml); | ||
4770 | 184 | return FALSE; | ||
4771 | 185 | } | ||
4772 | 186 | |||
4773 | 187 | static void test_searcher_run_async (UnityScopeSearchBase* base, UnityScopeSearchBaseCallback async_callback, void* async_callback_target) | ||
4774 | 188 | { | ||
4775 | 189 | TestSearcher * self; | ||
4776 | 190 | SearcherRunData* data; | ||
4777 | 191 | self = TEST_SCOPE_SEARCHER (base); | ||
4778 | 192 | data = g_slice_new (SearcherRunData); | ||
4779 | 193 | data->_ref_count_ = 1; | ||
4780 | 194 | data->self = g_object_ref (self); | ||
4781 | 195 | data->ml = g_main_loop_new (NULL, FALSE); | ||
4782 | 196 | data->async_callback = async_callback; | ||
4783 | 197 | data->async_callback_target = async_callback_target; | ||
4784 | 198 | |||
4785 | 199 | g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, test_searcher_main_loop_func, run_data_ref (data), run_data_unref); | ||
4786 | 200 | g_main_loop_run (data->ml); | ||
4787 | 201 | run_data_unref (data); | ||
4788 | 202 | data = NULL; | ||
4789 | 203 | } | ||
4790 | 204 | |||
4791 | 205 | static void test_searcher_run (UnityScopeSearchBase* base) | ||
4792 | 206 | { | ||
4793 | 207 | TestSearcher* self; | ||
4794 | 208 | self = TEST_SCOPE_SEARCHER (base); | ||
4795 | 209 | |||
4796 | 210 | g_signal_emit_by_name (self->priv->_owner, "search", base); | ||
4797 | 211 | } | ||
4798 | 212 | |||
4799 | 213 | /* ------------------ Test Result Previewer ---------------------- */ | ||
4800 | 214 | |||
4801 | 215 | #define TEST_TYPE_RESULT_PREVIEWER (test_result_previewer_get_type ()) | ||
4802 | 216 | #define TEST_RESULT_PREVIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_RESULT_PREVIEWER, TestResultPreviewer)) | ||
4803 | 217 | #define TEST_RESULT_PREVIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_TYPE_RESULT_PREVIEWER, TestResultPreviewerClass)) | ||
4804 | 218 | #define TEST_IS_RESULT_PREVIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_RESULT_PREVIEWER)) | ||
4805 | 219 | #define TEST_IS_RESULT_PREVIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_TYPE_RESULT_PREVIEWER)) | ||
4806 | 220 | #define TEST_RESULT_PREVIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_RESULT_PREVIEWER, TestResultPreviewerClass)) | ||
4807 | 221 | |||
4808 | 222 | typedef struct _TestResultPreviewer TestResultPreviewer; | ||
4809 | 223 | typedef struct _TestResultPreviewerClass TestResultPreviewerClass; | ||
4810 | 224 | |||
4811 | 225 | struct _TestResultPreviewer { | ||
4812 | 226 | UnityResultPreviewer parent_instance; | ||
4813 | 227 | }; | ||
4814 | 228 | |||
4815 | 229 | struct _TestResultPreviewerClass { | ||
4816 | 230 | UnityResultPreviewerClass parent_class; | ||
4817 | 231 | }; | ||
4818 | 232 | |||
4819 | 233 | G_DEFINE_TYPE(TestResultPreviewer, test_result_previewer, UNITY_TYPE_RESULT_PREVIEWER); | ||
4820 | 234 | |||
4821 | 235 | static UnityAbstractPreview* test_result_previewer_run(UnityResultPreviewer* self) | ||
4822 | 236 | { | ||
4823 | 237 | UnityAbstractPreview* preview; | ||
4824 | 238 | preview = UNITY_ABSTRACT_PREVIEW (unity_generic_preview_new ("title", "description", NULL)); | ||
4825 | 239 | |||
4826 | 240 | unity_preview_add_action(UNITY_PREVIEW (preview), unity_preview_action_new ("action1", "Action 1", NULL)); | ||
4827 | 241 | unity_preview_add_action(UNITY_PREVIEW (preview), unity_preview_action_new ("action2", "Action 2", NULL)); | ||
4828 | 242 | |||
4829 | 243 | return preview; | ||
4830 | 244 | } | ||
4831 | 245 | |||
4832 | 246 | static void test_result_previewer_class_init(TestResultPreviewerClass* klass) | ||
4833 | 247 | { | ||
4834 | 248 | UNITY_RESULT_PREVIEWER_CLASS (klass)->run = test_result_previewer_run; | ||
4835 | 249 | } | ||
4836 | 250 | |||
4837 | 251 | static void test_result_previewer_init(TestResultPreviewer* self) | ||
4838 | 252 | { | ||
4839 | 253 | } | ||
4840 | 254 | |||
4841 | 255 | TestResultPreviewer* test_result_previewer_new () | ||
4842 | 256 | { | ||
4843 | 257 | return (TestResultPreviewer*) g_object_new (TEST_TYPE_RESULT_PREVIEWER, NULL); | ||
4844 | 258 | } | ||
4845 | 259 | |||
4846 | 260 | /* ------------------ Test Scope ---------------------- */ | ||
4847 | 261 | |||
4848 | 262 | #define TEST_SCOPE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TEST_TYPE_SCOPE, TestScopePrivate)) | ||
4849 | 263 | |||
4850 | 264 | G_DEFINE_TYPE(TestScope, test_scope, UNITY_TYPE_ABSTRACT_SCOPE); | ||
4851 | 265 | |||
4852 | 266 | struct _TestScopePrivate | ||
4853 | 267 | { | ||
4854 | 268 | gchar* _dbus_path; | ||
4855 | 269 | UnityScopeDBusConnector* _connector; | ||
4856 | 270 | UnityCategorySet* _categories; | ||
4857 | 271 | UnityFilterSet* _filters; | ||
4858 | 272 | }; | ||
4859 | 273 | |||
4860 | 274 | enum { | ||
4861 | 275 | TEST_SCOPE_DUMMY_PROPERTY, | ||
4862 | 276 | TEST_SCOPE_DBUS_PATH | ||
4863 | 277 | }; | ||
4864 | 278 | |||
4865 | 279 | static UnityScopeSearchBase* test_scope_create_search_for_query(UnityAbstractScope* self, UnitySearchContext* search_context); | ||
4866 | 280 | static UnityResultPreviewer* test_scope_create_previewer(UnityAbstractScope* self, UnityScopeResult* _result_, UnitySearchMetadata* metadata); | ||
4867 | 281 | static UnityCategorySet* test_scope_get_categories(UnityAbstractScope* self); | ||
4868 | 282 | static UnityFilterSet* test_scope_get_filters(UnityAbstractScope* self); | ||
4869 | 283 | static UnitySchema* test_scope_get_schema(UnityAbstractScope* self); | ||
4870 | 284 | static gchar* test_scope_get_search_hint(UnityAbstractScope* self); | ||
4871 | 285 | static gchar* test_scope_get_group_name(UnityAbstractScope* self); | ||
4872 | 286 | static gchar* test_scope_get_unique_name(UnityAbstractScope* self); | ||
4873 | 287 | static UnityActivationResponse* test_scope_activate(UnityAbstractScope* self, UnityScopeResult* _result_, UnitySearchMetadata* metadata, const gchar* action_id); | ||
4874 | 288 | static void test_scope_set_dbus_path (TestScope* self, const gchar* value); | ||
4875 | 289 | static const gchar* test_scope_get_dbus_path (TestScope* self); | ||
4876 | 290 | |||
4877 | 291 | static void test_scope_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); | ||
4878 | 292 | static void test_scope_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); | ||
4879 | 293 | static void g_cclosure_user_marshal_OBJECT__STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data); | ||
4880 | 294 | |||
4881 | 295 | static void test_scope_class_init(TestScopeClass* klass) | ||
4882 | 296 | { | ||
4883 | 297 | g_type_class_add_private (klass, sizeof (TestScopePrivate)); | ||
4884 | 298 | |||
4885 | 299 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->create_search_for_query = test_scope_create_search_for_query; | ||
4886 | 300 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->create_previewer = test_scope_create_previewer; | ||
4887 | 301 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_categories = test_scope_get_categories; | ||
4888 | 302 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_filters = test_scope_get_filters; | ||
4889 | 303 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_schema = test_scope_get_schema; | ||
4890 | 304 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_search_hint = test_scope_get_search_hint; | ||
4891 | 305 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_group_name = test_scope_get_group_name; | ||
4892 | 306 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->get_unique_name = test_scope_get_unique_name; | ||
4893 | 307 | UNITY_ABSTRACT_SCOPE_CLASS (klass)->activate = test_scope_activate; | ||
4894 | 308 | G_OBJECT_CLASS (klass)->get_property = test_scope_get_property; | ||
4895 | 309 | G_OBJECT_CLASS (klass)->set_property = test_scope_set_property; | ||
4896 | 310 | |||
4897 | 311 | g_object_class_install_property (G_OBJECT_CLASS (klass), TEST_SCOPE_DBUS_PATH, g_param_spec_string ("dbus-path", "dbus-path", "dbus-path", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); | ||
4898 | 312 | g_signal_new ("search", TEST_TYPE_SCOPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, UNITY_TYPE_SCOPE_SEARCH_BASE); | ||
4899 | 313 | g_signal_new ("activate_uri", TEST_TYPE_SCOPE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_OBJECT__STRING, UNITY_TYPE_ACTIVATION_RESPONSE, 1, G_TYPE_STRING); | ||
4900 | 314 | } | ||
4901 | 315 | |||
4902 | 316 | static void test_scope_init(TestScope* self) | ||
4903 | 317 | { | ||
4904 | 318 | self->priv = TEST_SCOPE_GET_PRIVATE (self); | ||
4905 | 319 | |||
4906 | 320 | self->priv->_dbus_path = NULL; | ||
4907 | 321 | self->priv->_connector = NULL; | ||
4908 | 322 | self->priv->_categories = NULL; | ||
4909 | 323 | self->priv->_filters = NULL; | ||
4910 | 324 | } | ||
4911 | 325 | |||
4912 | 326 | static void test_scope_finalize (GObject* obj) | ||
4913 | 327 | { | ||
4914 | 328 | TestScope * self; | ||
4915 | 329 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, TEST_TYPE_SCOPE, TestScope); | ||
4916 | 330 | _g_free_safe (self->priv->_dbus_path); | ||
4917 | 331 | _g_object_unref_safe (self->priv->_connector); | ||
4918 | 332 | _g_object_unref_safe (self->priv->_categories); | ||
4919 | 333 | G_OBJECT_CLASS (test_scope_parent_class)->finalize (obj); | ||
4920 | 334 | } | ||
4921 | 335 | |||
4922 | 336 | static void test_scope_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) | ||
4923 | 337 | { | ||
4924 | 338 | TestScope * self; | ||
4925 | 339 | self = G_TYPE_CHECK_INSTANCE_CAST (object, TEST_TYPE_SCOPE, TestScope); | ||
4926 | 340 | switch (property_id) | ||
4927 | 341 | { | ||
4928 | 342 | case TEST_SCOPE_DBUS_PATH: | ||
4929 | 343 | g_value_set_string (value, test_scope_get_dbus_path (self)); | ||
4930 | 344 | break; | ||
4931 | 345 | default: | ||
4932 | 346 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
4933 | 347 | break; | ||
4934 | 348 | } | ||
4935 | 349 | } | ||
4936 | 350 | |||
4937 | 351 | static void test_scope_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) | ||
4938 | 352 | { | ||
4939 | 353 | TestScope * self; | ||
4940 | 354 | self = G_TYPE_CHECK_INSTANCE_CAST (object, TEST_TYPE_SCOPE, TestScope); | ||
4941 | 355 | switch (property_id) { | ||
4942 | 356 | case TEST_SCOPE_DBUS_PATH: | ||
4943 | 357 | test_scope_set_dbus_path (self, g_value_get_string (value)); | ||
4944 | 358 | break; | ||
4945 | 359 | default: | ||
4946 | 360 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
4947 | 361 | break; | ||
4948 | 362 | } | ||
4949 | 363 | } | ||
4950 | 364 | |||
4951 | 365 | static UnityScopeSearchBase* test_scope_create_search_for_query(UnityAbstractScope* base, UnitySearchContext* search_context) | ||
4952 | 366 | { | ||
4953 | 367 | UnityScopeSearchBase* searcher; | ||
4954 | 368 | TestScope* scope; | ||
4955 | 369 | scope = (TestScope*) base; | ||
4956 | 370 | searcher = (UnityScopeSearchBase*) test_searcher_new (scope); | ||
4957 | 371 | |||
4958 | 372 | UnitySearchContext ctx; | ||
4959 | 373 | ctx = *search_context; | ||
4960 | 374 | unity_scope_search_base_set_search_context (searcher, &ctx); | ||
4961 | 375 | return searcher; | ||
4962 | 376 | } | ||
4963 | 377 | |||
4964 | 378 | static UnityResultPreviewer* test_scope_create_previewer(UnityAbstractScope* self, UnityScopeResult* result, UnitySearchMetadata* metadata) | ||
4965 | 379 | { | ||
4966 | 380 | UnityResultPreviewer* previewer; | ||
4967 | 381 | previewer = UNITY_RESULT_PREVIEWER (test_result_previewer_new()); | ||
4968 | 382 | unity_scope_result_copy(result, &previewer->result); | ||
4969 | 383 | return previewer; | ||
4970 | 384 | } | ||
4971 | 385 | |||
4972 | 386 | static UnityCategorySet* test_scope_get_categories(UnityAbstractScope* base) | ||
4973 | 387 | { | ||
4974 | 388 | TestScope* self; | ||
4975 | 389 | self = G_TYPE_CHECK_INSTANCE_CAST (base, TEST_TYPE_SCOPE, TestScope); | ||
4976 | 390 | g_return_if_fail (self != NULL); | ||
4977 | 391 | |||
4978 | 392 | return self->priv->_categories; | ||
4979 | 393 | } | ||
4980 | 394 | |||
4981 | 395 | static UnityFilterSet* test_scope_get_filters(UnityAbstractScope* base) | ||
4982 | 396 | { | ||
4983 | 397 | TestScope* self; | ||
4984 | 398 | self = G_TYPE_CHECK_INSTANCE_CAST (base, TEST_TYPE_SCOPE, TestScope); | ||
4985 | 399 | g_return_if_fail (self != NULL); | ||
4986 | 400 | |||
4987 | 401 | return self->priv->_filters; | ||
4988 | 402 | } | ||
4989 | 403 | |||
4990 | 404 | static UnitySchema* test_scope_get_schema(UnityAbstractScope* self) | ||
4991 | 405 | { | ||
4992 | 406 | UnitySchema* schema = unity_schema_new (); | ||
4993 | 407 | unity_schema_add_field (schema, "required_string", "s", UNITY_SCHEMA_FIELD_TYPE_REQUIRED); | ||
4994 | 408 | unity_schema_add_field (schema, "required_int", "i", UNITY_SCHEMA_FIELD_TYPE_REQUIRED); | ||
4995 | 409 | unity_schema_add_field (schema, "optional_string", "s", UNITY_SCHEMA_FIELD_TYPE_OPTIONAL); | ||
4996 | 410 | return schema; | ||
4997 | 411 | } | ||
4998 | 412 | |||
4999 | 413 | static gchar* test_scope_get_search_hint(UnityAbstractScope* self) | ||
5000 | 414 | { |
FAILED: Continuous integration, rev:3083 jenkins. qa.ubuntu. com/job/ unity-team- unity-libunity- 7.0-breakage- ci/17/ jenkins. qa.ubuntu. com/job/ unity-team- unity-libunity- 7.0-breakage- raring- amd64-ci/ 17/console
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity-team- unity-libunity- 7.0-breakage- ci/17/rebuild
http://