From 0aedf144346f5b7ddbbe11c17497e3d51dc50762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Wed, 20 Mar 2013 16:15:46 +0100 Subject: First workaround: add a 2 second sleep after each configuration change in compiz during HudAlternativeKeybindingTests. This way we'll be sure that the keybinding change got applied. (bzr r3239.2.1) --- tests/autopilot/unity/tests/test_hud.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index bc040a1ed..eb71ec294 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -718,14 +718,18 @@ class HudAlternativeKeybindingTests(HudTestsBase): def test_super_h(self): """Test hud reveal on h.""" + self.addCleanup(sleep, 2.0) self.set_unity_option("show_hud", "h") + sleep(2.0) # Don't use reveal_hud, but be explicit in the keybindings. self.keyboard.press_and_release("Super+h") self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_ctrl_alt_h(self): """Test hud reveal on h.""" + self.addCleanup(sleep, 2.0) self.set_unity_option("show_hud", "h") + sleep(2.0) # Don't use reveal_hud, but be explicit in the keybindings. self.keyboard.press_and_release("Ctrl+Alt+h") self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) -- cgit v1.2.3 From b6cb5ebd60ee675e82debe168eb5864797aa7314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= Date: Wed, 20 Mar 2013 23:10:59 +0100 Subject: A more complicated way of working around the lack of feedback from compiz on settings change application. Let's try a few times before deciding that the keybinding does not work. (bzr r3239.2.2) --- tests/autopilot/unity/tests/test_hud.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index eb71ec294..bcb80ad03 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -22,6 +22,7 @@ from testtools.matchers import ( LessThan, NotEquals, ) +from testtools.matchers import MismatchError from time import sleep from unity.emulators.icons import HudLauncherIcon @@ -716,22 +717,36 @@ class HudVisualTests(HudTestsBase): class HudAlternativeKeybindingTests(HudTestsBase): + def alternateCheck(self, keybinding="Alt", hide=False): + """Nasty workaround for LP: #1157738""" + # So, since we have no way of making sure that after changing the unity option + # the change will be already 'applied' on the system, let's try the keybinding + # a few times before deciding that it does not work and we have a regression + # Seems better than a sleep(some_value_here) + for i in range(1, 4): + try: + self.keyboard.press_and_release(keybinding) + self.assertThat(self.unity.hud.visible, Eventually(Equals(True), timeout=3)) + break + except MismatchError: + continue + if hide: + self.unity.hud.ensure_hidden() + def test_super_h(self): """Test hud reveal on h.""" - self.addCleanup(sleep, 2.0) + self.addCleanup(self.alternateCheck, hide=True) self.set_unity_option("show_hud", "h") - sleep(2.0) # Don't use reveal_hud, but be explicit in the keybindings. - self.keyboard.press_and_release("Super+h") + self.alternateCheck("Super+h") self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) def test_ctrl_alt_h(self): """Test hud reveal on h.""" - self.addCleanup(sleep, 2.0) + self.addCleanup(self.alternateCheck, hide=True) self.set_unity_option("show_hud", "h") - sleep(2.0) # Don't use reveal_hud, but be explicit in the keybindings. - self.keyboard.press_and_release("Ctrl+Alt+h") + self.alternateCheck("Ctrl+Alt+h") self.assertThat(self.unity.hud.visible, Eventually(Equals(True))) -- cgit v1.2.3