summaryrefslogtreecommitdiff
path: root/tests
diff options
authorhandsome_feng <445865575@qq.com>2015-12-10 17:21:31 +0800
committerhandsome_feng <445865575@qq.com>2015-12-10 17:21:31 +0800
commit4c796b9d968cd395d0096d56e3ff3bd5402c3ebc (patch)
tree8d512a5a1c5cce8624f0d2b9cf193c3cf6bbe988 /tests
parent94461c38153442f18dc7db3284a30d58dbfb4011 (diff)
fix some problem in autopilot
(bzr r3999.7.10)
Diffstat (limited to 'tests')
-rw-r--r--tests/autopilot/unity/emulators/launcher.py32
-rw-r--r--tests/autopilot/unity/tests/launcher/test_icon_behavior.py17
-rw-r--r--tests/autopilot/unity/tests/launcher/test_scroll.py5
-rw-r--r--tests/autopilot/unity/tests/test_dash.py6
-rw-r--r--tests/autopilot/unity/tests/test_hud.py15
-rw-r--r--tests/autopilot/unity/tests/test_quicklist.py17
-rw-r--r--tests/autopilot/unity/tests/test_wm_keybindings.py10
-rw-r--r--tests/test_launcher_controller.cpp4
8 files changed, 76 insertions, 30 deletions
diff --git a/tests/autopilot/unity/emulators/launcher.py b/tests/autopilot/unity/emulators/launcher.py
index 7a0f14f7e..56f605922 100644
--- a/tests/autopilot/unity/emulators/launcher.py
+++ b/tests/autopilot/unity/emulators/launcher.py
@@ -344,7 +344,7 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
if (move_mouse_after):
self.move_mouse_beside_launcher()
- def drag_icon_to_position(self, icon, pos, target, drag_type=IconDragType.INSIDE):
+ def drag_icon_to_position(self, icon, pos, target, drag_type=IconDragType.INSIDE, launcher_position=LauncherPosition.LEFT):
"""Drag a launcher icon to a new position.
'icon' is the icon to move. It must be either a ApplicationLauncherIcon or an
@@ -387,26 +387,38 @@ class Launcher(UnityIntrospectionObject, KeybindingsHelper):
if drag_type not in (IconDragType.INSIDE, IconDragType.OUTSIDE):
raise ValueError("'drag_type' parameter must be one of IconDragType.INSIDE, IconDragType.OUTSIDE")
- icon_height = get_compiz_option("unityshell", "icon_size")
+ icon_size = get_compiz_option("unityshell", "icon_size")
self.move_mouse_to_icon(icon)
self._mouse.press()
sleep(1)
if drag_type == IconDragType.OUTSIDE:
- shift_over = self._mouse.x + (icon_height * 2)
- self._mouse.move(shift_over, self._mouse.y, rate=20, time_between_events=0.005)
+ if launcher_position == LauncherPosition.LEFT:
+ shift_over = self._mouse.x + (icon_size * 3)
+ self._mouse.move(shift_over, self._mouse.y, rate=20, time_between_events=0.005)
+ else:
+ shift_over = self._mouse.y - (icon_size * 3)
+ self._mouse.move(self._mouse.x, shift_over, rate=20, time_between_events=0.005)
sleep(0.5)
self.move_mouse_to_icon(target)
- target_y = target.center.y
- if target_y < icon.center.y:
- target_y += icon_height
- if pos == IconDragType.BEFORE:
- target_y -= icon_height + (icon_height / 2)
+ if launcher_position == LauncherPosition.LEFT:
+ target_y = target.center.y
+ if target_y < icon.center.y:
+ target_y += icon_size
+ if pos == IconDragType.BEFORE:
+ target_y -= icon_size + (icon_size / 2)
+ self._mouse.move(self._mouse.x, target_y, rate=20, time_between_events=0.005)
+ else:
+ target_x = target.center.x
+ if target_x < icon.center.x:
+ target_x += icon_size
+ if pos == IconDragType.BEFORE:
+ target_x -= icon_size + (icon_size / 2)
+ self._mouse.move(target_x, self._mouse.y, rate=20, time_between_events=0.005)
- self._mouse.move(self._mouse.x, target_y, rate=20, time_between_events=0.005)
sleep(1)
self._mouse.release()
self.move_mouse_beside_launcher()
diff --git a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py
index cec00f6da..b51267dee 100644
--- a/tests/autopilot/unity/tests/launcher/test_icon_behavior.py
+++ b/tests/autopilot/unity/tests/launcher/test_icon_behavior.py
@@ -17,6 +17,7 @@ from time import sleep
from unity.emulators.icons import ApplicationLauncherIcon, ExpoLauncherIcon
from unity.emulators.launcher import IconDragType
+from unity.emulators.launcher import LauncherPosition
from unity.tests.launcher import LauncherTestCase, _make_scenarios
from Xlib import Xutil
@@ -196,7 +197,8 @@ class LauncherIconsTests(LauncherTestCase):
self.launcher_instance.drag_icon_to_position(
calc_icon,
IconDragType.AFTER,
- bfb_icon)
+ bfb_icon,
+ launcher_position = self.launcher_position)
self.launcher_instance.keyboard_reveal_launcher()
self.addCleanup(self.launcher_instance.keyboard_unreveal_launcher)
@@ -354,6 +356,10 @@ class LauncherDragIconsBehavior(LauncherTestCase):
[
('inside', {'drag_type': IconDragType.INSIDE}),
('outside', {'drag_type': IconDragType.OUTSIDE}),
+ ],
+ [
+ ('left', {'launcher_position': LauncherPosition.LEFT}),
+ ('bottom', {'launcher_position': LauncherPosition.BOTTOM}),
])
def setUp(self):
@@ -386,7 +392,8 @@ class LauncherDragIconsBehavior(LauncherTestCase):
calc_icon,
IconDragType.AFTER,
bfb_icon,
- self.drag_type)
+ self.drag_type,
+ self.launcher_position)
moved_icon = self.unity.launcher.model.\
get_launcher_icons_for_monitor(self.launcher_monitor)[1]
self.assertThat(moved_icon, Equals(calc_icon))
@@ -406,14 +413,16 @@ class LauncherDragIconsBehavior(LauncherTestCase):
calc_icon,
IconDragType.AFTER,
bfb_icon,
- self.drag_type)
+ self.drag_type,
+ self.launcher_position)
sleep(1)
self.launcher_instance.drag_icon_to_position(
calc_icon,
IconDragType.BEFORE,
trash_icon,
- self.drag_type)
+ self.drag_type,
+ self.launcher_position)
# Must be the last bamf icon - not necessarily the third-from-end icon.
expected_pos = -2 if self.workspace.num_workspaces < 2 else -1
diff --git a/tests/autopilot/unity/tests/launcher/test_scroll.py b/tests/autopilot/unity/tests/launcher/test_scroll.py
index 59814d0f6..5e500c765 100644
--- a/tests/autopilot/unity/tests/launcher/test_scroll.py
+++ b/tests/autopilot/unity/tests/launcher/test_scroll.py
@@ -88,8 +88,9 @@ class LauncherScrollTests(LauncherTestCase):
launcher_instance.move_mouse_to_icon(last_icon)
# Make sure the first icon is off the screen or else there is no
- # scrolling.
- self.assertThat(first_icon.center.y, LessThan(y))
+ # scrolling when launcher at left
+ if w < h:
+ self.assertThat(first_icon.center.y, LessThan(y))
# Autoscroll to the first icon
launcher_instance.move_mouse_to_icon(first_icon, autoscroll_offset)
diff --git a/tests/autopilot/unity/tests/test_dash.py b/tests/autopilot/unity/tests/test_dash.py
index 606144b8e..7686ba643 100644
--- a/tests/autopilot/unity/tests/test_dash.py
+++ b/tests/autopilot/unity/tests/test_dash.py
@@ -689,8 +689,10 @@ class DashVisualTests(DashTestCase):
self.unity.dash.ensure_visible()
- self.assertThat(self.unity.dash.view.x, Eventually(Equals(launcher.geometry.x + launcher.geometry.width - 1)))
-
+ if launcher.geometry.width < launcher.geometry.height:
+ self.assertThat(self.unity.dash.view.x, Eventually(Equals(launcher.geometry.x + launcher.geometry.width - 1)))
+ else:
+ self.assertThat(self.unity.dash.view.x, Eventually(Equals(0)))
def test_see_more_result_alignment(self):
"""The see more results label should be baseline aligned
diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py
index de0929338..a4809bb37 100644
--- a/tests/autopilot/unity/tests/test_hud.py
+++ b/tests/autopilot/unity/tests/test_hud.py
@@ -27,6 +27,7 @@ from testtools.matchers import MismatchError
from time import sleep
from unity.emulators.icons import HudLauncherIcon
+from unity.emulators.launcher import LauncherPosition
from unity.tests import UnityTestCase
@@ -471,10 +472,10 @@ class HudBehaviorTests(HudTestsBase):
self.unity.hud.ensure_visible()
- # Click bottom right of the screen, but take into account the non-maximized window -
+ # Click right of the screen, but take into account the non-maximized window -
# we do not want to click on it as it focuses the wrong window
w = self.display.get_screen_width() - 1
- h = self.display.get_screen_height() - 1
+ h = (self.display.get_screen_height() - 1) / 2
# If the mouse is over the non-maximized window, move it away from it.
(calc_x, calc_y, calc_w, calc_h) = calc_win.get_windows()[0].geometry
@@ -645,7 +646,10 @@ class HudVisualTests(HudTestsBase):
launcher_screen = [('Launcher on all monitors', {'launcher_primary_only': False}),
('Launcher on primary monitor', {'launcher_primary_only': True})]
- scenarios = multiply_scenarios(_make_monitor_scenarios(), launcher_modes, launcher_screen)
+ launcher_position = [('left', {'launcher_position': LauncherPosition.LEFT}),
+ ('bottom', {'launcher_position': LauncherPosition.BOTTOM})]
+
+ scenarios = multiply_scenarios(_make_monitor_scenarios(), launcher_modes, launcher_screen, launcher_position)
def setUp(self):
super(HudVisualTests, self).setUp()
@@ -655,6 +659,9 @@ class HudVisualTests(HudTestsBase):
self.hud_monitor_is_primary = (self.display.get_primary_screen() == self.hud_monitor)
self.hud_locked = (not self.launcher_autohide and (not self.launcher_primary_only or self.hud_monitor_is_primary))
sleep(0.5)
+ old_pos = self.call_gsettings_cmd('get', 'com.canonical.Unity', 'launcher-position')
+ self.call_gsettings_cmd('set', 'com.canonical.Unity', 'launcher-position', '"%s"' % self.launcher_position)
+ self.addCleanup(self.call_gsettings_cmd, 'set', 'com.canonical.Unity', 'launcher-position', old_pos)
def test_initially_hidden(self):
self.assertFalse(self.unity.hud.visible)
@@ -674,7 +681,7 @@ class HudVisualTests(HudTestsBase):
hud_x = self.unity.hud.geometry[0]
hud_w = self.unity.hud.geometry[2]
- if self.hud_locked:
+ if self.hud_locked and self.launcher_position == LauncherPosition.LEFT:
self.assertThat(hud_x, GreaterThan(monitor_x))
self.assertThat(hud_x, LessThan(monitor_x + monitor_w))
self.assertThat(hud_w, Equals(monitor_x + monitor_w - hud_x))
diff --git a/tests/autopilot/unity/tests/test_quicklist.py b/tests/autopilot/unity/tests/test_quicklist.py
index cfad75b60..9ba44afe0 100644
--- a/tests/autopilot/unity/tests/test_quicklist.py
+++ b/tests/autopilot/unity/tests/test_quicklist.py
@@ -194,12 +194,12 @@ class QuicklistActionTests(UnityTestCase):
icons = self.unity.launcher.model.get_launcher_icons()
- icon0_ql = self.open_quicklist_for_icon(icons[0])
- self.assertThat(icon0_ql.active, Eventually(Equals(True)))
-
icon1_ql = self.open_quicklist_for_icon(icons[1])
self.assertThat(icon1_ql.active, Eventually(Equals(True)))
- self.assertThat(icon0_ql.wait_until_destroyed, Not(Raises()))
+
+ icon0_ql = self.open_quicklist_for_icon(icons[0])
+ self.assertThat(icon0_ql.active, Eventually(Equals(True)))
+ self.assertThat(icon1_ql.wait_until_destroyed, Not(Raises()))
def test_right_clicking_same_icon_doesnt_reopen_ql(self):
"""A right click to the same icon in the launcher must
@@ -244,6 +244,10 @@ class QuicklistKeyNavigationTests(UnityTestCase):
self.ql_launcher = self.unity.launcher.get_launcher_for_monitor(0)
+ old_pos = self.call_gsettings_cmd('get', 'com.canonical.Unity', 'launcher-position')
+ self.call_gsettings_cmd('set', 'com.canonical.Unity', 'launcher-position', '"%s"' % self.launcher_position)
+ self.addCleanup(self.call_gsettings_cmd, 'set', 'com.canonical.Unity', 'launcher-position', old_pos)
+
def open_quicklist_with_mouse(self):
"""Opens a quicklist with the mouse."""
self.ql_launcher.click_launcher_icon(self.ql_launcher_icon, button=3)
@@ -262,7 +266,10 @@ class QuicklistKeyNavigationTests(UnityTestCase):
self.addCleanup(self.ql_launcher.key_nav_cancel)
self.ql_launcher.keyboard_select_icon(self.launcher_position, tooltip_text=self.ql_app.name)
- self.keybinding("launcher/keynav/open-quicklist")
+ if self.launcher_position == LauncherPosition.LEFT:
+ self.keybinding("launcher/keynav/open-quicklist")
+ else:
+ self.keybinding("launcher/keynav/prev")
self.addCleanup(self.keybinding, "launcher/keynav/close-quicklist")
self.assertThat(self.ql_launcher_icon.get_quicklist,
diff --git a/tests/autopilot/unity/tests/test_wm_keybindings.py b/tests/autopilot/unity/tests/test_wm_keybindings.py
index f6dec986a..fe5418d6a 100644
--- a/tests/autopilot/unity/tests/test_wm_keybindings.py
+++ b/tests/autopilot/unity/tests/test_wm_keybindings.py
@@ -99,10 +99,16 @@ class WindowManagerKeybindingsForWindowHandling(UnityTestCase):
monitor = self.bamf_win.monitor
monitor_geo = self.display.get_screen_geometry(monitor)
launcher = self.unity.launcher.get_launcher_for_monitor(monitor)
- launcher_w = 0 if launcher.hidemode else launcher.geometry[2]
+ # When launcher at left, do not use launcher_h, otherwise, do not use launcher_w
+ if launcher.geometry[2] < launcher.geometry[3]:
+ launcher_h = 0
+ launcher_w = 0 if launcher.hidemode else launcher.geometry[2]
+ else:
+ launcher_h = 0 if launcher.hidemode else launcher.geometry[3]
+ launcher_w = 0
panel_h = self.unity.panels.get_panel_for_monitor(monitor).geometry[3]
return (monitor_geo[0] + launcher_w, monitor_geo[1] + panel_h,
- monitor_geo[2] - launcher_w, monitor_geo[3] - panel_h)
+ monitor_geo[2] - launcher_w, monitor_geo[3] - panel_h - launcher_h)
def test_maximize_window(self):
if self.start_restored:
diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp
index 59b5afbc7..04e2cf841 100644
--- a/tests/test_launcher_controller.cpp
+++ b/tests/test_launcher_controller.cpp
@@ -464,6 +464,7 @@ TEST_F(TestLauncherController, MultimonitorGeometries)
{
auto const& monitor_geo = uscreen.GetMonitorGeometry(i);
auto const& launcher_geo = lc.launchers()[i]->GetAbsoluteGeometry();
+
ASSERT_EQ(launcher_geo.x, monitor_geo.x);
ASSERT_EQ(launcher_geo.y, monitor_geo.y + panel_style.PanelHeight(i));
ASSERT_EQ(launcher_geo.height, monitor_geo.height - panel_style.PanelHeight(i));
@@ -474,8 +475,9 @@ TEST_F(TestLauncherController, MultimonitorGeometries)
{
auto const& monitor_geo = uscreen.GetMonitorGeometry(i);
auto const& launcher_geo = lc.launchers()[i]->GetAbsoluteGeometry();
+
ASSERT_EQ(launcher_geo.x, monitor_geo.x);
- ASSERT_EQ(launcher_geo.y, monitor_geo.y + monitor_geo.height - launcher_geo.height);
+ ASSERT_EQ(launcher_geo.y, monitor_geo.y + monitor_geo.height - launcher_geo.height + 1);
ASSERT_EQ(launcher_geo.width, monitor_geo.width);
}
}