Merge lp:~unity-team/unity/libunity-7.0-breakage-tests into lp:~unity-team/unity/libunity-7.0-breakage

Proposed by Nick Dedekind
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
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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

+1 regarding the autopilot parts

review: Approve (autopilot)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

- TEST(TestDesktopUtilitiesDataDirectories, TestGetUserDataDirectory)
- TEST(TestDesktopUtilitiesDataDirectories, TestGetSystemDataDirectory)
- TEST(TestDesktopUtilitiesDataDirectories, TestGetDataDirectory)

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.

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

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: