diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2012-10-31 20:34:34 +0000 |
|---|---|---|
| committer | Tarmac <> | 2012-10-31 20:34:34 +0000 |
| commit | e7649e2def02977bfaf2e51dd91b82c7a1488be2 (patch) | |
| tree | 82d75fecf24e4b8de3c3136192a7abd7f93ccdd1 /tests | |
| parent | 871b4f1dbd9a2e88b596a3c60da480a9cd1bd069 (diff) | |
| parent | a1f8363483d87bd32e813cb7bee7b07d46a4762d (diff) | |
Move SHORTCUT_KEYS_VISIBLE from hover machine to hide machine.. Fixes: https://bugs.launchpad.net/bugs/1035860. Approved by Thomi Richards, Marco Trevisan (TreviƱo).
(bzr r2874)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/autopilot/unity/tests/launcher/test_shortcut.py | 6 | ||||
| -rw-r--r-- | tests/test_launcher.cpp | 1 | ||||
| -rw-r--r-- | tests/test_launcher_hide_machine.cpp | 75 | ||||
| -rw-r--r-- | tests/test_launcher_hover_machine.cpp | 115 |
5 files changed, 198 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e5c69a84e..cc0e2805d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -197,6 +197,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 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/test_launcher.cpp b/tests/test_launcher.cpp index 542bd2652..2b5827c49 100644 --- a/tests/test_launcher.cpp +++ b/tests/test_launcher.cpp @@ -524,7 +524,6 @@ TEST_F(TestLauncher, AddRequestSignal) EXPECT_TRUE(add_request); } - } } 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())); + +} |
