diff options
| author | Brandon Schaefer <brandon.schaefer@canonical.com> | 2013-03-18 15:48:08 -0700 |
|---|---|---|
| committer | Brandon Schaefer <brandon.schaefer@canonical.com> | 2013-03-18 15:48:08 -0700 |
| commit | 184f6571382cce8e1ffc0fdd9911bef46588e660 (patch) | |
| tree | 2783a6c9f7086e1754bdda178af80858f3227c31 /tests | |
| parent | ec099e014d76bf229cf23dc74caa1df78bd0694a (diff) | |
* Make a new test suite, test-gtest-slow for tests that run slow.
* Moved over 2 im_text_entry tests which took ~30 seconds to run. * Moved over tooltip_manager as each tests took over half a second. (bzr r3225.2.1)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 27 | ||||
| -rw-r--r-- | tests/test_im_text_entry.cpp | 65 | ||||
| -rw-r--r-- | tests/test_im_text_entry.h | 47 | ||||
| -rw-r--r-- | tests/test_im_text_entry_class.cpp | 41 | ||||
| -rw-r--r-- | tests/test_im_text_entry_slow.cpp | 46 |
5 files changed, 161 insertions, 65 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8fdb8444f..d07dd17e2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -99,6 +99,27 @@ if (GTEST_SRC_DIR AND test_service_panel.cpp) target_link_libraries(test-gtest-service unity-shared ${LIBS}) +# gtest-slow, start moving things over that are slow running tests + set (GTEST_SLOW_SOURCES + test_main.cpp + logger_helper.cpp + test_im_text_entry_slow.cpp + test_im_text_entry_class.cpp + test_tooltip_manager.cpp + ) + + set (GTEST_SLOW_LIBS + gtest + gmock + launcher-lib + unity-shared + ) + + add_executable(test-gtest-slow ${GTEST_SLOW_SOURCES}) + + target_link_libraries(test-gtest-slow ${GTEST_SLOW_LIBS}) + + add_test(UnityGTestSlow test-gtest-slow) # The actual test executable (xless) - do not put anything that requires X in here set (GTEST_XLESS_SOURCES @@ -218,6 +239,7 @@ if (ENABLE_X_SUPPORT) test_hud_view.cpp test_icon_loader.cpp test_im_text_entry.cpp + test_im_text_entry_class.cpp test_launcher.cpp test_launcher_controller.cpp test_launcher_drag_window.cpp @@ -263,7 +285,6 @@ if (ENABLE_X_SUPPORT) test_texture_cache.cpp test_text_input.cpp test_thumbnail_generator.cpp - test_tooltip_manager.cpp test_trash_launcher_icon.cpp test_unity_settings.cpp test_unity_window_style.cpp @@ -322,6 +343,7 @@ if (ENABLE_X_SUPPORT) 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_SLOW ./test-gtest-slow) set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus) set (TEST_COMMAND @@ -330,6 +352,7 @@ set (TEST_COMMAND && ${GTEST_TEST_COMMAND_XLESS} --gtest_output=xml:./ && ${GTEST_TEST_COMMAND_GESTURES} --gtest_output=xml:./ && ${GTEST_TEST_COMMAND_DBUS} --gtest_output=xml:./ + && ${GTEST_TEST_COMMAND_SLOW} --gtest_output=xml:./ ) set (TEST_COMMAND_HEADLESS @@ -340,7 +363,7 @@ set (TEST_COMMAND_HEADLESS if (GTEST_SRC_DIR) 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 COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-slow 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 () diff --git a/tests/test_im_text_entry.cpp b/tests/test_im_text_entry.cpp index 2c5457119..334b6ab9d 100644 --- a/tests/test_im_text_entry.cpp +++ b/tests/test_im_text_entry.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Canonical Ltd. + * Copyright 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, as @@ -19,49 +19,12 @@ * */ -#include <gmock/gmock.h> -#include "unity-shared/IMTextEntry.h" +#include "test_im_text_entry.h" using namespace testing; using namespace unity; using namespace nux; -namespace -{ - -class TestEvent : public nux::Event -{ -public: - TestEvent(nux::KeyModifier keymod, unsigned long keysym) - { - type = NUX_KEYDOWN; - key_modifiers = keymod; - x11_keysym = keysym; - } - - TestEvent(unsigned long keysym) - { - type = NUX_KEYDOWN; - x11_keysym = keysym; - } -}; - -class MockTextEntry : public IMTextEntry -{ -public: - MOCK_METHOD0(CutClipboard, void()); - MOCK_METHOD0(CopyClipboard, void()); - MOCK_METHOD0(PasteClipboard, void()); - MOCK_METHOD0(PastePrimaryClipboard, void()); - - bool InspectKeyEvent(nux::Event const& event) - { - key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0); - return IMTextEntry::InspectKeyEvent(event); - } -}; - - TEST(TestIMTextEntry, CopyCtrlC) { MockTextEntry text_entry; @@ -173,27 +136,3 @@ TEST(TestIMTextEntry, CtrlKeybindings) EXPECT_TRUE(text_entry.InspectKeyEvent(event)); } } - -TEST(TestIMTextEntry, AltKeybindings) -{ - MockTextEntry text_entry; - - for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) - { - TestEvent event(KEY_MODIFIER_ALT, keysym); - EXPECT_FALSE(text_entry.InspectKeyEvent(event)); - } -} - -TEST(TestIMTextEntry, SuperKeybindings) -{ - MockTextEntry text_entry; - - for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) - { - TestEvent event(KEY_MODIFIER_SUPER, keysym); - EXPECT_FALSE(text_entry.InspectKeyEvent(event)); - } -} - -} diff --git a/tests/test_im_text_entry.h b/tests/test_im_text_entry.h new file mode 100644 index 000000000..1fa0e8f10 --- /dev/null +++ b/tests/test_im_text_entry.h @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * + */ + +#ifndef TEST_IM_TEXT_ENTRY_H +#define TEST_IM_TEXT_ENTRY_H + +#include <gmock/gmock.h> +#include "unity-shared/IMTextEntry.h" + +class TestEvent : public nux::Event +{ +public: + TestEvent(nux::KeyModifier keymod, unsigned long keysym); + + TestEvent(unsigned long keysym); +}; + +class MockTextEntry : public unity::IMTextEntry +{ +public: + MOCK_METHOD0(CutClipboard, void()); + MOCK_METHOD0(CopyClipboard, void()); + MOCK_METHOD0(PasteClipboard, void()); + MOCK_METHOD0(PastePrimaryClipboard, void()); + + bool InspectKeyEvent(nux::Event const& event); +}; + +#endif // TEST_IM_TEXT_ENTRY_H diff --git a/tests/test_im_text_entry_class.cpp b/tests/test_im_text_entry_class.cpp new file mode 100644 index 000000000..52083994f --- /dev/null +++ b/tests/test_im_text_entry_class.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * + */ + +#include "test_im_text_entry.h" + +TestEvent::TestEvent(nux::KeyModifier keymod, unsigned long keysym) +{ + type = nux::NUX_KEYDOWN; + key_modifiers = keymod; + x11_keysym = keysym; +} + +TestEvent::TestEvent(unsigned long keysym) +{ + type = nux::NUX_KEYDOWN; + x11_keysym = keysym; +} + +bool MockTextEntry::InspectKeyEvent(nux::Event const& event) +{ + key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0); + return IMTextEntry::InspectKeyEvent(event); +} diff --git a/tests/test_im_text_entry_slow.cpp b/tests/test_im_text_entry_slow.cpp new file mode 100644 index 000000000..caa3493b8 --- /dev/null +++ b/tests/test_im_text_entry_slow.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * + */ + +#include "test_im_text_entry.h" + +using namespace nux; + +TEST(TestIMTextEntry, AltKeybindings) +{ + MockTextEntry text_entry; + + for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) + { + TestEvent event(KEY_MODIFIER_ALT, keysym); + EXPECT_FALSE(text_entry.InspectKeyEvent(event)); + } +} + +TEST(TestIMTextEntry, SuperKeybindings) +{ + MockTextEntry text_entry; + + for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym) + { + TestEvent event(KEY_MODIFIER_SUPER, keysym); + EXPECT_FALSE(text_entry.InspectKeyEvent(event)); + } +} |
