summaryrefslogtreecommitdiff
path: root/tests
diff options
authorMichal Hruby <michal.mhr@gmail.com>2012-11-14 09:57:56 +0100
committerMichal Hruby <michal.mhr@gmail.com>2012-11-14 09:57:56 +0100
commit774cf2f4f69300f5120a7ec37a0d4f204ed91e67 (patch)
tree8b31bcf9196c2a6481731efc648f6bb6cfe2b08a /tests
parent01d77af4108751948d0b46817fd1b14d192f8496 (diff)
parent70167e222b43a1594724812c39ea6583597c946b (diff)
Merge trunk
(bzr r2866.7.4)
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt139
-rw-r--r--tests/autopilot/unity/tests/__init__.py8
-rw-r--r--tests/autopilot/unity/tests/launcher/test_shortcut.py6
-rw-r--r--tests/autopilot/unity/tests/test_command_lens.py8
-rw-r--r--tests/autopilot/unity/tests/test_dash.py82
-rw-r--r--tests/autopilot/unity/tests/test_hud.py3
-rw-r--r--tests/autopilot/unity/tests/test_panel.py4
-rw-r--r--tests/autopilot/unity/tests/test_shopping_lens.py18
-rw-r--r--tests/autopilot/unity/tests/test_switcher.py29
-rw-r--r--tests/test_launcher.cpp111
-rw-r--r--tests/test_launcher_controller.cpp2
-rw-r--r--tests/test_launcher_hide_machine.cpp75
-rw-r--r--tests/test_launcher_hover_machine.cpp115
13 files changed, 433 insertions, 167 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e5c69a84e..36b8183b3 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -112,51 +112,71 @@ if (GTEST_SRC_DIR AND
# The actual test executable (xless) - do not put anything that requires X in here
- add_executable(test-gtest-xless
- test_main_xless.cpp
- test_animator.cpp
- test_launcher_model.cpp
- test_glib_object.cpp
- test_glib_object_utils.cpp
- test_glib_object_utils.h
- test_glib_signals.cpp
- test_glib_signals_utils.cpp
- test_glib_signals_utils.h
- test_glib_source.cpp
- test_glib_variant.cpp
- test_grabhandle.cpp
- test_desktop_utilities.cpp
- test_hud_private.cpp
- test_indicator.cpp
- test_indicator_appmenu.cpp
- test_indicator_entry.cpp
- test_indicators.cpp
- test_introspection.cpp
- test_favorite_store.cpp
- test_favorite_store_gsettings.cpp
- test_favorite_store_private.cpp
- test_home_lens.cpp
- test_launcher_entry_remote.cpp
- test_model_iterator.cpp
- test_pointer_barrier.cpp
- test_previews.cpp
- test_shortcut_model.cpp
- test_shortcut_private.cpp
- test_showdesktop_handler.cpp
- test_ubus.cpp
- test_unityshell_private.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp
- ${UNITY_SRC}/DebugDBusInterface.cpp
- ${UNITY_SRC}/XPathQueryPart.cpp
- ${UNITY_SRC}/UnityshellPrivate.cpp
- ${UNITY_SRC}/UnityShowdesktopHandler.cpp
- ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp
- ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp
- ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp
- ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp
- ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp
- )
- target_link_libraries(test-gtest-xless gtest unity-shared ${GMOCK_LIB} ${GMOCK_MAIN_LIB} ${LIBS} launcher-lib shortcuts-lib hud-lib)
+ set (GTEST_XLESS_SOURCES
+ test_main_xless.cpp
+ test_animator.cpp
+ test_launcher_model.cpp
+ test_glib_object.cpp
+ test_glib_object_utils.cpp
+ test_glib_object_utils.h
+ test_glib_signals.cpp
+ test_glib_signals_utils.cpp
+ test_glib_signals_utils.h
+ test_glib_source.cpp
+ test_glib_variant.cpp
+ test_grabhandle.cpp
+ test_desktop_utilities.cpp
+ test_indicator.cpp
+ test_indicator_appmenu.cpp
+ test_indicator_entry.cpp
+ test_indicators.cpp
+ test_introspection.cpp
+ test_favorite_store.cpp
+ test_favorite_store_gsettings.cpp
+ test_favorite_store_private.cpp
+ test_home_lens.cpp
+ test_launcher_entry_remote.cpp
+ test_model_iterator.cpp
+ test_previews.cpp
+ test_ubus.cpp
+ test_unityshell_private.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp
+ ${UNITY_SRC}/UnityshellPrivate.cpp
+ ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp
+ ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp
+ ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-impl-factory.cpp
+ ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-layout.cpp
+ ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-texture.cpp
+ )
+
+ set (GTEST_XLESS_LIBS
+ gtest
+ unity-shared
+ launcher-lib
+ ${GMOCK_LIB}
+ ${GMOCK_MAIN_LIB}
+ ${LIBS}
+ )
+
+ if (ENABLE_X_SUPPORT)
+ set (GTEST_XLESS_SOURCES
+ test_hud_private.cpp
+ test_pointer_barrier.cpp
+ test_shortcut_model.cpp
+ test_shortcut_private.cpp
+ ${LAUNCHER_SOURCES}
+ )
+ set (GTEST_XLESS_LIBS
+ ${GTEST_XLESS_LIBS}
+ shortcuts-lib
+ hud-lib
+ )
+ endif ()
+
+ add_executable(test-gtest-xless ${GTEST_XLESS_SOURCES})
+
+ target_link_libraries(test-gtest-xless ${GTEST_XLESS_LIBS})
+
add_test(UnityGTestXless test-gtest-xless)
add_dependencies(test-gtest-xless unity-core-${UNITY_API_VERSION} gtest)
@@ -179,6 +199,7 @@ if (GTEST_SRC_DIR AND
add_test(UnityGTestDBus test-gtest-dbus)
add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service gtest)
+if (ENABLE_X_SUPPORT)
# Tests that require X
add_executable(test-gtest
test_main.cpp
@@ -197,6 +218,8 @@ if (GTEST_SRC_DIR AND
test_im_text_entry.cpp
test_launcher_controller.cpp
test_launcher_drag_window.cpp
+ test_launcher_hide_machine.cpp
+ test_launcher_hover_machine.cpp
test_launcher_icon.cpp
test_keyboard_util.cpp
test_panel_style.cpp
@@ -213,6 +236,7 @@ if (GTEST_SRC_DIR AND
test_shortcut_controller.cpp
test_single_monitor_launcher_icon.cpp
test_expo_launcher_icon.cpp
+ test_showdesktop_handler.cpp
test_switcher_controller.cpp
test_switcher_model.cpp
test_texture_cache.cpp
@@ -225,17 +249,20 @@ if (GTEST_SRC_DIR AND
bamf-mock-application.c
gmockmount.c
gmockvolume.c
+ ${UNITY_SRC}/UnityShowdesktopHandler.cpp
${CMAKE_SOURCE_DIR}/plugins/unityshell/src/WindowMinimizeSpeedController.cpp
)
target_link_libraries(test-gtest gtest gmock unity-shared ${LIBS} launcher-lib unity-shared-standalone shortcuts-lib previews-lib hud-lib switcher-lib dash-lib panel-lib)
add_test(UnityGTest test-gtest)
add_dependencies(test-gtest unity-core-${UNITY_API_VERSION} gtest gmock)
-
+endif (ENABLE_X_SUPPORT)
endif (GTEST_SRC_DIR AND
GMOCK_LIB AND
GMOCK_MAIN_LIB)
-add_subdirectory (test-gestures)
+if(ENABLE_X_SUPPORT)
+ add_subdirectory (test-gestures)
+endif()
#
# check target
@@ -243,10 +270,12 @@ add_subdirectory (test-gestures)
set (TEST_RESULT_DIR ${CMAKE_BINARY_DIR}/tests)
set (TEST_RESULT_XML ${TEST_RESULT_DIR}/test-results.xml)
set (TEST_RESULT_HTML ${TEST_RESULT_DIR}/test-results.html)
-set (GTEST_TEST_COMMAND ./test-gtest)
+if (ENABLE_X_SUPPORT)
+ set (GTEST_TEST_COMMAND ./test-gtest)
+ set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures)
+endif (ENABLE_X_SUPPORT)
set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless)
set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus)
-set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures)
set (TEST_COMMAND
gtester --verbose -k --g-fatal-warnings -o=${TEST_RESULT_XML} ./test-unit
@@ -263,10 +292,16 @@ set (TEST_COMMAND_HEADLESS
&& echo "Warning, DBus test cases are disabled!!")
if (GTEST_SRC_DIR)
- add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures)
- add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures)
+ if (ENABLE_X_SUPPORT)
+ add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures)
+ add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures)
+ add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless)
+ else ()
+ add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest-xless test-gtest-dbus)
+ add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus)
+ add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest-xless)
+ endif ()
add_custom_target (check-report COMMAND ${TEST_UNIT_COMMAND} && gtester-report ${TEST_RESULT_XML} > ${TEST_RESULT_HTML})
- add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless)
else (GTEST_SRC_DIR)
add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit)
endif (GTEST_SRC_DIR)
diff --git a/tests/autopilot/unity/tests/__init__.py b/tests/autopilot/unity/tests/__init__.py
index 5b4ba983f..0d96931dc 100644
--- a/tests/autopilot/unity/tests/__init__.py
+++ b/tests/autopilot/unity/tests/__init__.py
@@ -11,6 +11,7 @@
from __future__ import absolute_import
+from codecs import open
from autopilot.matchers import Eventually
from autopilot.testcase import AutopilotTestCase
from dbus import DBusException
@@ -117,6 +118,11 @@ class UnityTestCase(AutopilotTestCase):
reasons.append("The test left the launcher in switcher mode.")
log.warning("Test left the launcher in switcher mode, exiting it...")
launcher.switcher_cancel()
+ if not self.well_behaved(launcher, quicklist_open=False):
+ well_behaved = False
+ reasons.append("The test left a quicklist open.")
+ log.warning("The test left a quicklist open.")
+ self.keyboard.press_and_release('Escape')
if not well_behaved:
self.fail("/n".join(reasons))
@@ -210,7 +216,7 @@ class UnityTestCase(AutopilotTestCase):
reset_logging()
except DBusException:
pass
- with open(self._unity_log_file_name) as unity_log:
+ with open(self._unity_log_file_name, encoding='utf-8') as unity_log:
self.addDetail('unity-log', text_content(unity_log.read()))
os.remove(self._unity_log_file_name)
self._unity_log_file_name = ""
diff --git a/tests/autopilot/unity/tests/launcher/test_shortcut.py b/tests/autopilot/unity/tests/launcher/test_shortcut.py
index 8747b5723..9cb3093ff 100644
--- a/tests/autopilot/unity/tests/launcher/test_shortcut.py
+++ b/tests/autopilot/unity/tests/launcher/test_shortcut.py
@@ -53,3 +53,9 @@ class LauncherShortcutTests(LauncherTestCase):
self.addCleanup(self.launcher_instance.switcher_cancel)
self.launcher_instance.switcher_prev()
self.assertThat(self.launcher_instance.shortcuts_shown, Eventually(Equals(True)))
+
+ def test_tooltip_not_shown(self):
+ """Tooltip must not be shown after revealing the launcher with keyboard
+ and mouse is not on the launcher.
+ """
+ self.assertThat(self.launcher_instance.tooltip_shown, Eventually(Equals(False)))
diff --git a/tests/autopilot/unity/tests/test_command_lens.py b/tests/autopilot/unity/tests/test_command_lens.py
index 2f69d1ce3..13db7a2da 100644
--- a/tests/autopilot/unity/tests/test_command_lens.py
+++ b/tests/autopilot/unity/tests/test_command_lens.py
@@ -14,12 +14,14 @@ from time import sleep
from unity.tests import UnityTestCase
+import gettext
class CommandLensSearchTests(UnityTestCase):
"""Test the command lense search bahavior."""
def setUp(self):
super(CommandLensSearchTests, self).setUp()
+ gettext.install("unity-lens-applications")
def tearDown(self):
self.dash.ensure_hidden()
@@ -34,7 +36,7 @@ class CommandLensSearchTests(UnityTestCase):
self.keyboard.press_and_release("Delete")
self.assertThat(self.dash.search_string, Eventually(Equals("")))
- results_category = command_lens.get_category_by_name("Results")
+ results_category = command_lens.get_category_by_name(_("Results"))
self.assertThat(results_category.is_visible, Eventually(Equals(False)))
def test_results_category_appears(self):
@@ -44,7 +46,7 @@ class CommandLensSearchTests(UnityTestCase):
# lots of apps start with 'a'...
self.keyboard.type("a")
self.assertThat(self.dash.search_string, Eventually(Equals("a")))
- results_category = command_lens.get_category_by_name("Results")
+ results_category = command_lens.get_category_by_name(_("Results"))
self.assertThat(results_category.is_visible, Eventually(Equals(True)))
def test_result_category_actually_contains_results(self):
@@ -54,7 +56,7 @@ class CommandLensSearchTests(UnityTestCase):
# lots of apps start with 'a'...
self.keyboard.type("a")
self.assertThat(self.dash.search_string, Eventually(Equals("a")))
- results_category = command_lens.get_category_by_name("Results")
+ results_category = command_lens.get_category_by_name(_("Results"))
results = results_category.get_results()
self.assertTrue(results)
diff --git a/tests/autopilot/unity/tests/test_dash.py b/tests/autopilot/unity/tests/test_dash.py
index c8f8ca846..ad34f07b3 100644
--- a/tests/autopilot/unity/tests/test_dash.py
+++ b/tests/autopilot/unity/tests/test_dash.py
@@ -75,38 +75,6 @@ class DashRevealTests(DashTestCase):
self.keyboard.press_and_release("Alt+F4")
self.assertThat(self.dash.visible, Eventually(Equals(False)))
- def test_dash_closes_on_spread(self):
- """This test shows that when the spread is initiated, the dash closes."""
- self.dash.ensure_visible()
- self.addCleanup(self.keybinding, "spread/cancel")
- self.keybinding("spread/start")
- self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
- self.assertThat(self.dash.visible, Eventually(Equals(False)))
-
- def test_dash_opens_when_in_spread(self):
- """This test shows the dash opens when in spread mode."""
- self.keybinding("spread/start")
- self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
-
- self.dash.ensure_visible()
- self.assertThat(self.dash.visible, Eventually(Equals(True)))
-
- def test_command_lens_opens_when_in_spread(self):
- """This test shows the command lens opens when in spread mode."""
- self.keybinding("spread/start")
- self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
-
- self.dash.reveal_command_lens()
- self.assertThat(self.dash.active_lens, Eventually(Equals('commands.lens')))
-
- def test_lens_opens_when_in_spread(self):
- """This test shows that any lens opens when in spread mode."""
- self.keybinding("spread/start")
- self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
-
- self.dash.reveal_application_lens()
- self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens')))
-
def test_closes_mouse_down_outside(self):
"""Test that a mouse down outside of the dash closes the dash."""
@@ -140,6 +108,56 @@ class DashRevealTests(DashTestCase):
self.assertProperty(char_win, is_active=True)
+class DashRevealWithSpreadTests(DashTestCase):
+ """Test the interaction of the Dash with the Spead/Scale
+
+ The Spread (or Scale) in Quantal is not activated if there is no active
+ apps. We use a place holder app so that it is activated as we require.
+
+ """
+ def setUp(self):
+ super(DashRevealWithSpreadTests, self).setUp()
+ self.start_placeholder_app()
+
+ def start_placeholder_app(self):
+ window_spec = {
+ "Title": "Placeholder application",
+ }
+ self.launch_test_window(window_spec)
+
+ def test_dash_closes_on_spread(self):
+ """This test shows that when the spread is initiated, the dash closes."""
+ self.dash.ensure_visible()
+ self.addCleanup(self.keybinding, "spread/cancel")
+ self.keybinding("spread/start")
+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
+ self.assertThat(self.dash.visible, Eventually(Equals(False)))
+
+ def test_dash_opens_when_in_spread(self):
+ """This test shows the dash opens when in spread mode."""
+ self.keybinding("spread/start")
+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
+
+ self.dash.ensure_visible()
+ self.assertThat(self.dash.visible, Eventually(Equals(True)))
+
+ def test_command_lens_opens_when_in_spread(self):
+ """This test shows the command lens opens when in spread mode."""
+ self.keybinding("spread/start")
+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
+
+ self.dash.reveal_command_lens()
+ self.assertThat(self.dash.active_lens, Eventually(Equals('commands.lens')))
+
+ def test_lens_opens_when_in_spread(self):
+ """This test shows that any lens opens when in spread mode."""
+ self.keybinding("spread/start")
+ self.assertThat(self.window_manager.scale_active, Eventually(Equals(True)))
+
+ self.dash.reveal_application_lens()
+ self.assertThat(self.dash.active_lens, Eventually(Equals('applications.lens')))
+
+
class DashSearchInputTests(DashTestCase):
"""Test features involving input to the dash search"""
diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py
index 2ccb3b580..4623990be 100644
--- a/tests/autopilot/unity/tests/test_hud.py
+++ b/tests/autopilot/unity/tests/test_hud.py
@@ -669,6 +669,9 @@ class HudVisualTests(HudTestsBase):
"""
initial_workspace = self.workspace.current_workspace
self.addCleanup(self.workspace.switch_to, initial_workspace)
+ self.window_manager.enter_show_desktop()
+ self.addCleanup(self.window_manager.leave_show_desktop)
+
self.workspace.switch_to(0)
calc = self.start_app("Calculator")
self.assertTrue(calc.is_active)
diff --git a/tests/autopilot/unity/tests/test_panel.py b/tests/autopilot/unity/tests/test_panel.py
index dea16aefe..5dbbccef1 100644
--- a/tests/autopilot/unity/tests/test_panel.py
+++ b/tests/autopilot/unity/tests/test_panel.py
@@ -589,7 +589,7 @@ class PanelWindowButtonsTests(PanelTestsBase):
maximized=True,
move_to_monitor=True)
- indicator = self.panel.indicators.get_indicator_by_name_hint("indicator-session-devices")
+ indicator = self.panel.indicators.get_indicator_by_name_hint("indicator-session")
self.mouse_open_indicator(indicator)
self.assertThat(self.panel.window_buttons_shown, Eventually(Equals(False)))
@@ -1225,7 +1225,7 @@ class PanelCrossMonitorsTests(PanelTestsBase):
"""Opening an indicator entry and then hovering others entries must open them."""
text_win = self.open_new_application_window("Text Editor")
panel = self.panels.get_panel_for_monitor(text_win.monitor)
- indicator = panel.indicators.get_indicator_by_name_hint("indicator-session-devices")
+ indicator = panel.indicators.get_indicator_by_name_hint("indicator-session")
self.mouse_open_indicator(indicator)
for monitor in range(0, self.screen_geo.get_num_monitors()):
diff --git a/tests/autopilot/unity/tests/test_shopping_lens.py b/tests/autopilot/unity/tests/test_shopping_lens.py
index bc0ee0d48..94d42a771 100644
--- a/tests/autopilot/unity/tests/test_shopping_lens.py
+++ b/tests/autopilot/unity/tests/test_shopping_lens.py
@@ -12,6 +12,7 @@ from autopilot.matchers import Eventually
from testtools.matchers import Equals, GreaterThan
from time import sleep
import urllib2
+import gettext
from unity.tests import UnityTestCase
@@ -25,6 +26,7 @@ class ShoppingLensTests(UnityTestCase):
urllib2.urlopen("http://www.google.com", timeout=2)
except urllib2.URLError, e:
self.skip("Skipping test, no internet connection")
+ gettext.install("unity-lens-shopping")
def tearDown(self):
self.dash.ensure_hidden()
@@ -35,7 +37,7 @@ class ShoppingLensTests(UnityTestCase):
self.dash.ensure_visible()
lens = self.dash.get_current_lens()
- results_category = lens.get_category_by_name("More suggestions")
+ results_category = lens.get_category_by_name(_("More suggestions"))
refresh_results_fn = lambda: len(results_category.get_results())
self.assertThat(refresh_results_fn, Eventually(Equals(0)))
@@ -45,7 +47,7 @@ class ShoppingLensTests(UnityTestCase):
lens = self.dash.get_current_lens()
self.keyboard.type("playstation")
- results_category = lens.get_category_by_name("More suggestions")
+ results_category = lens.get_category_by_name(_("More suggestions"))
refresh_results_fn = lambda: len(results_category.get_results())
self.assertThat(refresh_results_fn, Eventually(GreaterThan(1)))
@@ -56,7 +58,7 @@ class ShoppingLensTests(UnityTestCase):
lens = self.dash.get_current_lens()
self.keyboard.type("Text Editor")
- results_category = lens.get_category_by_name("More suggestions")
+ results_category = lens.get_category_by_name(_("More suggestions"))
refresh_results_fn = lambda: len(results_category.get_results())
self.assertThat(refresh_results_fn, Eventually(GreaterThan(1)))
@@ -67,7 +69,7 @@ class ShoppingLensTests(UnityTestCase):
lens = self.dash.get_current_lens()
self.keyboard.type("megadeth")
- results_category = lens.get_category_by_name("More suggestions")
+ results_category = lens.get_category_by_name(_("More suggestions"))
refresh_results_fn = lambda: len(results_category.get_results())
self.assertThat(refresh_results_fn, Eventually(GreaterThan(1)))
@@ -77,8 +79,8 @@ class ShoppingLensTests(UnityTestCase):
self.dash.ensure_visible()
lens = self.dash.get_current_lens()
- self.keyboard.type("a")
- results_category = lens.get_category_by_name("More suggestions")
+ self.keyboard.type("playstation")
+ results_category = lens.get_category_by_name(_("More suggestions"))
refresh_results_fn = lambda: len(results_category.get_results())
self.assertThat(refresh_results_fn, Eventually(GreaterThan(1)))
@@ -95,8 +97,8 @@ class ShoppingLensTests(UnityTestCase):
self.dash.ensure_visible()
lens = self.dash.get_current_lens()
- self.keyboard.type("a")
- results_category = lens.get_category_by_name("More suggestions")
+ self.keyboard.type("playstation")
+ results_category = lens.get_category_by_name(_("More suggestions"))
refresh_results_fn = lambda: len(results_category.get_results())
self.assertThat(refresh_results_fn, Eventually(GreaterThan(2)))
diff --git a/tests/autopilot/unity/tests/test_switcher.py b/tests/autopilot/unity/tests/test_switcher.py
index 345b6ef5c..fd0b00d8c 100644
--- a/tests/autopilot/unity/tests/test_switcher.py
+++ b/tests/autopilot/unity/tests/test_switcher.py
@@ -246,6 +246,31 @@ class SwitcherWindowsManagementTests(SwitcherTestCase):
self.assertProperty(calc_win, is_focused=True)
self.assertVisibleWindowStack([calc_win, char_win1])
+ def test_switcher_rises_next_window_of_same_application(self):
+ """Tests if alt+tab invoked normally switches to the next application
+ window of the same type.
+
+ """
+ char_win1, char_win2 = self.start_applications("Character Map", "Character Map")
+ self.assertVisibleWindowStack([char_win2, char_win1])
+
+ self.keybinding("switcher/reveal_normal")
+ self.assertProperty(char_win1, is_focused=True)
+
+ def test_switcher_rises_other_application(self):
+ """Tests if alt+tab invoked normally switches correctly to the other
+ application window when the last focused application had 2 windows
+
+ """
+ char_win1, char_win2, calc_win = self.start_applications("Character Map", "Character Map", "Calculator")
+ self.assertVisibleWindowStack([calc_win, char_win2, char_win1])
+
+ self.keybinding("switcher/reveal_normal")
+ self.assertProperty(char_win2, is_focused=True)
+
+ self.keybinding("switcher/reveal_normal")
+ self.assertProperty(calc_win, is_focused=True)
+
class SwitcherDetailsTests(SwitcherTestCase):
"""Test the details mode for the switcher."""
@@ -302,6 +327,10 @@ class SwitcherDetailsModeTests(SwitcherTestCase):
]
)
+ def setUp(self):
+ super(SwitcherDetailsModeTests, self).setUp()
+ self.set_timeout_setting(False)
+
def test_can_start_details_mode(self):
"""Must be able to switch to details mode using selected scenario keycode.
diff --git a/tests/test_launcher.cpp b/tests/test_launcher.cpp
index 542bd2652..d41a1ece3 100644
--- a/tests/test_launcher.cpp
+++ b/tests/test_launcher.cpp
@@ -80,65 +80,22 @@ public:
return AbstractLauncherIcon::Ptr();
}
- float IconBackgroundIntensity(AbstractLauncherIcon::Ptr const& icon, timespec const& current) const
- {
- return Launcher::IconBackgroundIntensity(icon, current);
- }
-
- void StartIconDrag(AbstractLauncherIcon::Ptr const& icon)
- {
- Launcher::StartIconDrag(icon);
- }
-
- void ShowDragWindow()
- {
- Launcher::ShowDragWindow();
- }
-
- void EndIconDrag()
- {
- Launcher::EndIconDrag();
- }
-
- void UpdateDragWindowPosition(int x, int y)
- {
- Launcher::UpdateDragWindowPosition(x, y);
- }
-
- void HideDragWindow()
- {
- Launcher::HideDragWindow();
- }
-
- void ResetMouseDragState()
- {
- Launcher::ResetMouseDragState();
- }
-
- bool DndIsSpecialRequest(std::string const& uri) const
- {
- return Launcher::DndIsSpecialRequest(uri);
- }
-
- int GetDragIconPosition() const
- {
- return _drag_icon_position;
- }
-
- void ProcessDndEnter()
- {
- Launcher::ProcessDndEnter();
- }
-
- void ProcessDndLeave()
- {
- Launcher::ProcessDndLeave();
- }
-
- void ProcessDndMove(int x, int y, std::list<char*> mimes)
- {
- Launcher::ProcessDndMove(x, y, mimes);
- }
+ using Launcher::IconBackgroundIntensity;
+ using Launcher::StartIconDrag;
+ using Launcher::ShowDragWindow;
+ using Launcher::EndIconDrag;
+ using Launcher::UpdateDragWindowPosition;
+ using Launcher::HideDragWindow;
+ using Launcher::ResetMouseDragState;
+ using Launcher::DndIsSpecialRequest;
+ using Launcher::ProcessDndEnter;
+ using Launcher::ProcessDndLeave;
+ using Launcher::ProcessDndMove;
+ using Launcher::ProcessDndDrop;
+ using Launcher::_drag_icon_position;
+
+ using Launcher::IconStartingBlinkValue;
+ using Launcher::IconStartingPulseValue;
void FakeProcessDndMove(int x, int y, std::list<std::string> uris)
{
@@ -158,11 +115,6 @@ public:
_dnd_hovered_icon = MouseIconIntersection(x, y);
}
-
- void ProcessDndDrop(int x, int y)
- {
- Launcher::ProcessDndDrop(x, y);
- }
};
TestLauncher()
@@ -354,7 +306,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged)
// Start dragging icon2
launcher_->StartIconDrag(icon2);
launcher_->ShowDragWindow();
- ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
+ ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
// Moving icon2 at the end
auto const& center3 = icon3->GetCenter(launcher_->monitor());
@@ -364,7 +316,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasChanged)
model_->saved.connect([&model_saved] { model_saved = true; });
EXPECT_CALL(*icon2, Stick(false));
- ASSERT_NE(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
+ ASSERT_NE(launcher_->_drag_icon_position, model_->IconIndex(icon2));
launcher_->EndIconDrag();
// The icon order should be reset
@@ -391,7 +343,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged)
// Start dragging icon2
launcher_->StartIconDrag(icon2);
launcher_->ShowDragWindow();
- ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
+ ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
// Moving icon2 at the end
auto center3 = icon3->GetCenter(launcher_->monitor());
@@ -408,7 +360,7 @@ TEST_F(TestLauncher, DragLauncherIconSavesIconOrderIfPositionHasNotChanged)
bool model_saved = false;
model_->saved.connect([&model_saved] { model_saved = true; });
- ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
+ ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
launcher_->EndIconDrag();
// The icon order should be reset
@@ -524,6 +476,29 @@ TEST_F(TestLauncher, AddRequestSignal)
EXPECT_TRUE(add_request);
}
+TEST_F(TestLauncher, IconStartingPulseValue)
+{
+ struct timespec current;
+ clock_gettime(CLOCK_MONOTONIC, &current);
+ MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon);
+
+ icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true);
+
+ // Pulse value should start at 0.
+ EXPECT_EQ(launcher_->IconStartingPulseValue(icon, current), 0.0);
+}
+
+TEST_F(TestLauncher, IconStartingBlinkValue)
+{
+ struct timespec current;
+ clock_gettime(CLOCK_MONOTONIC, &current);
+ MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon);
+
+ icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true);
+
+ // Pulse value should start at 0.
+ EXPECT_EQ(launcher_->IconStartingBlinkValue(icon, current), 0.0);
+}
}
}
diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
index 22d197b2d..061f74a4a 100644
--- a/tests/test_launcher_controller.cpp
+++ b/tests/test_launcher_controller.cpp
@@ -380,7 +380,7 @@ TEST_F(TestLauncherController, SingleMonitorSwitchToMultimonitor)
EXPECT_EQ(lc.launchers().size(), max_num_monitors);
}
-#ifdef UNITY_HAS_X_ORG_SUPPORT
+#ifdef USE_X11
TEST_F(TestLauncherController, MultiMonitorEdgeBarrierSubscriptions)
{
diff --git a/tests/test_launcher_hide_machine.cpp b/tests/test_launcher_hide_machine.cpp
new file mode 100644
index 000000000..af133766d
--- /dev/null
+++ b/tests/test_launcher_hide_machine.cpp
@@ -0,0 +1,75 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2012 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
+ */
+
+#include <gtest/gtest.h>
+using namespace testing;
+
+#include "launcher/LauncherHideMachine.h"
+#include "test_utils.h"
+namespace ul = unity::launcher;
+
+namespace {
+
+ul::LauncherHideMachine::HideQuirk QUIRKS [] {
+ ul::LauncherHideMachine::QUICKLIST_OPEN,
+ ul::LauncherHideMachine::EXTERNAL_DND_ACTIVE,
+ ul::LauncherHideMachine::INTERNAL_DND_ACTIVE,
+ ul::LauncherHideMachine::TRIGGER_BUTTON_SHOW,
+ ul::LauncherHideMachine::DND_PUSHED_OFF,
+ ul::LauncherHideMachine::MOUSE_MOVE_POST_REVEAL,
+ ul::LauncherHideMachine::VERTICAL_SLIDE_ACTIVE,
+ ul::LauncherHideMachine::KEY_NAV_ACTIVE,
+ ul::LauncherHideMachine::PLACES_VISIBLE,
+ ul::LauncherHideMachine::SCALE_ACTIVE,
+ ul::LauncherHideMachine::EXPO_ACTIVE,
+ ul::LauncherHideMachine::MT_DRAG_OUT,
+ ul::LauncherHideMachine::REVEAL_PRESSURE_PASS,
+ ul::LauncherHideMachine::LAUNCHER_PULSE,
+ ul::LauncherHideMachine::LOCK_HIDE,
+ ul::LauncherHideMachine::SHORTCUT_KEYS_VISIBLE };
+
+struct HideModeNever : public TestWithParam<std::tr1::tuple<ul::LauncherHideMachine::HideQuirk, bool, bool>> {
+ ul::LauncherHideMachine machine;
+};
+
+TEST_P(HideModeNever, Bool2Bool) {
+ auto quirk = std::tr1::get<0>(GetParam());
+ bool initial_value = std::tr1::get<1>(GetParam());
+ bool final_value = std::tr1::get<2>(GetParam());
+
+ machine.SetMode(ul::LauncherHideMachine::HIDE_NEVER);
+ machine.SetQuirk(quirk, initial_value);
+
+ bool sig_received = false;
+ machine.should_hide_changed.connect([&sig_received] (bool /*value*/) {
+ sig_received = true;
+ });
+
+ machine.SetQuirk(quirk, final_value);
+
+ auto check_function = [&sig_received]() { return sig_received; };
+ Utils::WaitUntil(check_function, false, 20/1000);
+}
+
+INSTANTIATE_TEST_CASE_P(TestLauncherHideMachine, HideModeNever,
+ Combine(ValuesIn(QUIRKS), Bool(), Bool()));
+
+// TODO: write tests for HideModeAutohide.
+
+}
diff --git a/tests/test_launcher_hover_machine.cpp b/tests/test_launcher_hover_machine.cpp
new file mode 100644
index 000000000..3ac62b77c
--- /dev/null
+++ b/tests/test_launcher_hover_machine.cpp
@@ -0,0 +1,115 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2012 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
+ */
+
+#include <gtest/gtest.h>
+using namespace testing;
+
+#include "launcher/LauncherHoverMachine.h"
+#include "test_utils.h"
+
+namespace {
+
+unity::LauncherHoverMachine::HoverQuirk QUIRKS [] {
+ unity::LauncherHoverMachine::MOUSE_OVER_LAUNCHER,
+ unity::LauncherHoverMachine::MOUSE_OVER_BFB,
+ unity::LauncherHoverMachine::QUICKLIST_OPEN,
+ unity::LauncherHoverMachine::KEY_NAV_ACTIVE,
+ unity::LauncherHoverMachine::LAUNCHER_IN_ACTION };
+
+struct SingleQuirk : public TestWithParam<std::tr1::tuple<unity::LauncherHoverMachine::HoverQuirk, bool, bool>> {
+ unity::LauncherHoverMachine machine;
+};
+
+TEST_P(SingleQuirk, Bool2Bool) {
+ auto quirk = std::tr1::get<0>(GetParam());
+ bool initial_value = std::tr1::get<1>(GetParam());
+ bool final_value = std::tr1::get<2>(GetParam());
+
+ machine.SetQuirk(quirk, initial_value);
+ Utils::WaitForTimeoutMSec(20); // ignore the first signal
+
+ bool sig_received = false;
+ bool hover = initial_value;
+ machine.should_hover_changed.connect([&sig_received, &hover] (bool value) {
+ sig_received = true;
+ hover = value;
+ });
+
+ machine.SetQuirk(unity::LauncherHoverMachine::LAUNCHER_HIDDEN, false);
+ machine.SetQuirk(quirk, final_value);
+
+ if (initial_value != final_value)
+ {
+ Utils::WaitUntil(sig_received);
+ ASSERT_EQ(hover, final_value);
+ }
+ else
+ {
+ Utils::WaitForTimeoutMSec(20);
+ ASSERT_FALSE(sig_received);
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(TestLauncherHoverMachine, SingleQuirk,
+ Combine(ValuesIn(QUIRKS), Bool(), Bool()));
+
+
+struct MultipleQuirks : public TestWithParam<std::tr1::tuple<unity::LauncherHoverMachine::HoverQuirk, bool, bool,
+ unity::LauncherHoverMachine::HoverQuirk, bool, bool>> {
+ unity::LauncherHoverMachine machine;
+};
+
+TEST_P(MultipleQuirks, DoubleBool2Bool) {
+ auto quirk1 = std::tr1::get<0>(GetParam());
+ auto quirk2 = std::tr1::get<3>(GetParam());
+
+ if (quirk1 == quirk2)
+ return;
+
+ bool initial_value1 = std::tr1::get<1>(GetParam());
+ bool final_value1 = std::tr1::get<2>(GetParam());
+ bool initial_value2 = std::tr1::get<4>(GetParam());
+ bool final_value2 = std::tr1::get<5>(GetParam());
+
+ machine.SetQuirk(quirk1, initial_value1);
+ machine.SetQuirk(quirk2, initial_value2);
+ Utils::WaitForTimeoutMSec(20);
+
+ bool sig_received = false;
+ bool hover = initial_value1 || initial_value2;
+ machine.should_hover_changed.connect([&sig_received, &hover] (bool value) {
+ sig_received = true;
+ hover = value;
+ });
+
+ machine.SetQuirk(unity::LauncherHoverMachine::LAUNCHER_HIDDEN, false);
+ machine.SetQuirk(quirk1, final_value1);
+ machine.SetQuirk(quirk2, final_value2);
+
+ if ((initial_value1 || initial_value2) != (final_value1 || final_value2))
+ Utils::WaitUntil(sig_received);
+
+ auto check_function = [&]() { return hover == (final_value1 || final_value2); };
+ Utils::WaitUntil(check_function, true, 20/1000);
+}
+
+INSTANTIATE_TEST_CASE_P(TestLauncherHoverMachine, MultipleQuirks,
+ Combine(ValuesIn(QUIRKS), Bool(), Bool(), ValuesIn(QUIRKS), Bool(), Bool()));
+
+}