Merge lp:~brandontschaefer/unity/move-slow-tests-to-gtest-slow into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3234
Proposed branch: lp:~brandontschaefer/unity/move-slow-tests-to-gtest-slow
Merge into: lp:unity
Diff against target: 311 lines (+161/-65)
5 files modified
tests/CMakeLists.txt (+25/-2)
tests/test_im_text_entry.cpp (+2/-63)
tests/test_im_text_entry.h (+47/-0)
tests/test_im_text_entry_class.cpp (+41/-0)
tests/test_im_text_entry_slow.cpp (+46/-0)
To merge this branch: bzr merge lp:~brandontschaefer/unity/move-slow-tests-to-gtest-slow
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+153951@code.launchpad.net

Commit message

New test suite, test-gtest-slow for tests that are slow, now test-gtest runs at about ~30 seconds which is a huge improvement.

Description of the change

=== Problem ===
test-gtest was taking ~60-70 seconds to finish...which is to long for normal unit tests.

=== Fix ===
Since the tests that were slowing things down are still good tests, move it over into test-gtest-slow, which will now be a place to put unit tests that are slow (ie. half a second is slow).

=== Tests ===
All tests still pass, as this was just refactoring some tests.

[==========] 1081 tests from 83 test cases ran. (29894 ms total) <--- A lot faster!

Tests that still need to be moved over:
http://paste.ubuntu.com/5626706/

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2013-03-12 15:21:19 +0000
+++ tests/CMakeLists.txt 2013-03-18 22:56:25 +0000
@@ -99,6 +99,27 @@
99 test_service_panel.cpp)99 test_service_panel.cpp)
100 target_link_libraries(test-gtest-service unity-shared ${LIBS})100 target_link_libraries(test-gtest-service unity-shared ${LIBS})
101101
102# gtest-slow, start moving things over that are slow running tests
103 set (GTEST_SLOW_SOURCES
104 test_main.cpp
105 logger_helper.cpp
106 test_im_text_entry_slow.cpp
107 test_im_text_entry_class.cpp
108 test_tooltip_manager.cpp
109 )
110
111 set (GTEST_SLOW_LIBS
112 gtest
113 gmock
114 launcher-lib
115 unity-shared
116 )
117
118 add_executable(test-gtest-slow ${GTEST_SLOW_SOURCES})
119
120 target_link_libraries(test-gtest-slow ${GTEST_SLOW_LIBS})
121
122 add_test(UnityGTestSlow test-gtest-slow)
102123
103# The actual test executable (xless) - do not put anything that requires X in here124# The actual test executable (xless) - do not put anything that requires X in here
104 set (GTEST_XLESS_SOURCES125 set (GTEST_XLESS_SOURCES
@@ -218,6 +239,7 @@
218 test_hud_view.cpp239 test_hud_view.cpp
219 test_icon_loader.cpp240 test_icon_loader.cpp
220 test_im_text_entry.cpp241 test_im_text_entry.cpp
242 test_im_text_entry_class.cpp
221 test_launcher.cpp243 test_launcher.cpp
222 test_launcher_controller.cpp244 test_launcher_controller.cpp
223 test_launcher_drag_window.cpp245 test_launcher_drag_window.cpp
@@ -263,7 +285,6 @@
263 test_texture_cache.cpp285 test_texture_cache.cpp
264 test_text_input.cpp286 test_text_input.cpp
265 test_thumbnail_generator.cpp287 test_thumbnail_generator.cpp
266 test_tooltip_manager.cpp
267 test_trash_launcher_icon.cpp288 test_trash_launcher_icon.cpp
268 test_unity_settings.cpp289 test_unity_settings.cpp
269 test_unity_window_style.cpp290 test_unity_window_style.cpp
@@ -322,6 +343,7 @@
322 set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures)343 set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures)
323endif (ENABLE_X_SUPPORT)344endif (ENABLE_X_SUPPORT)
324set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless)345set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless)
346set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow)
325set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus)347set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus)
326348
327set (TEST_COMMAND349set (TEST_COMMAND
@@ -330,6 +352,7 @@
330 && ${GTEST_TEST_COMMAND_XLESS} --gtest_output=xml:./352 && ${GTEST_TEST_COMMAND_XLESS} --gtest_output=xml:./
331 && ${GTEST_TEST_COMMAND_GESTURES} --gtest_output=xml:./353 && ${GTEST_TEST_COMMAND_GESTURES} --gtest_output=xml:./
332 && ${GTEST_TEST_COMMAND_DBUS} --gtest_output=xml:./354 && ${GTEST_TEST_COMMAND_DBUS} --gtest_output=xml:./
355 && ${GTEST_TEST_COMMAND_SLOW} --gtest_output=xml:./
333 )356 )
334357
335set (TEST_COMMAND_HEADLESS358set (TEST_COMMAND_HEADLESS
@@ -340,7 +363,7 @@
340363
341if (GTEST_SRC_DIR)364if (GTEST_SRC_DIR)
342 if (ENABLE_X_SUPPORT)365 if (ENABLE_X_SUPPORT)
343 add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures)366 add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-slow test-gtest-xless test-gtest-dbus test-gestures)
344 add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures)367 add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures)
345 add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless)368 add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless)
346 else ()369 else ()
347370
=== modified file 'tests/test_im_text_entry.cpp'
--- tests/test_im_text_entry.cpp 2012-07-03 04:19:21 +0000
+++ tests/test_im_text_entry.cpp 2013-03-18 22:56:25 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2012 Canonical Ltd.2 * Copyright 2012-2013 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3, as5 * under the terms of the GNU Lesser General Public License version 3, as
@@ -19,49 +19,12 @@
19 *19 *
20 */20 */
2121
22#include <gmock/gmock.h>22#include "test_im_text_entry.h"
23#include "unity-shared/IMTextEntry.h"
2423
25using namespace testing;24using namespace testing;
26using namespace unity;25using namespace unity;
27using namespace nux;26using namespace nux;
2827
29namespace
30{
31
32class TestEvent : public nux::Event
33{
34public:
35 TestEvent(nux::KeyModifier keymod, unsigned long keysym)
36 {
37 type = NUX_KEYDOWN;
38 key_modifiers = keymod;
39 x11_keysym = keysym;
40 }
41
42 TestEvent(unsigned long keysym)
43 {
44 type = NUX_KEYDOWN;
45 x11_keysym = keysym;
46 }
47};
48
49class MockTextEntry : public IMTextEntry
50{
51public:
52 MOCK_METHOD0(CutClipboard, void());
53 MOCK_METHOD0(CopyClipboard, void());
54 MOCK_METHOD0(PasteClipboard, void());
55 MOCK_METHOD0(PastePrimaryClipboard, void());
56
57 bool InspectKeyEvent(nux::Event const& event)
58 {
59 key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0);
60 return IMTextEntry::InspectKeyEvent(event);
61 }
62};
63
64
65TEST(TestIMTextEntry, CopyCtrlC)28TEST(TestIMTextEntry, CopyCtrlC)
66{29{
67 MockTextEntry text_entry;30 MockTextEntry text_entry;
@@ -173,27 +136,3 @@
173 EXPECT_TRUE(text_entry.InspectKeyEvent(event));136 EXPECT_TRUE(text_entry.InspectKeyEvent(event));
174 }137 }
175}138}
176
177TEST(TestIMTextEntry, AltKeybindings)
178{
179 MockTextEntry text_entry;
180
181 for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
182 {
183 TestEvent event(KEY_MODIFIER_ALT, keysym);
184 EXPECT_FALSE(text_entry.InspectKeyEvent(event));
185 }
186}
187
188TEST(TestIMTextEntry, SuperKeybindings)
189{
190 MockTextEntry text_entry;
191
192 for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
193 {
194 TestEvent event(KEY_MODIFIER_SUPER, keysym);
195 EXPECT_FALSE(text_entry.InspectKeyEvent(event));
196 }
197}
198
199}
200139
=== added file 'tests/test_im_text_entry.h'
--- tests/test_im_text_entry.h 1970-01-01 00:00:00 +0000
+++ tests/test_im_text_entry.h 2013-03-18 22:56:25 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2012-2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the applicable version of the GNU Lesser General Public
12 * License for more details.
13 *
14 * You should have received a copy of both the GNU Lesser General Public
15 * License version 3 along with this program. If not, see
16 * <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
19 *
20 */
21
22#ifndef TEST_IM_TEXT_ENTRY_H
23#define TEST_IM_TEXT_ENTRY_H
24
25#include <gmock/gmock.h>
26#include "unity-shared/IMTextEntry.h"
27
28class TestEvent : public nux::Event
29{
30public:
31 TestEvent(nux::KeyModifier keymod, unsigned long keysym);
32
33 TestEvent(unsigned long keysym);
34};
35
36class MockTextEntry : public unity::IMTextEntry
37{
38public:
39 MOCK_METHOD0(CutClipboard, void());
40 MOCK_METHOD0(CopyClipboard, void());
41 MOCK_METHOD0(PasteClipboard, void());
42 MOCK_METHOD0(PastePrimaryClipboard, void());
43
44 bool InspectKeyEvent(nux::Event const& event);
45};
46
47#endif // TEST_IM_TEXT_ENTRY_H
048
=== added file 'tests/test_im_text_entry_class.cpp'
--- tests/test_im_text_entry_class.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_im_text_entry_class.cpp 2013-03-18 22:56:25 +0000
@@ -0,0 +1,41 @@
1/*
2 * Copyright 2012-2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the applicable version of the GNU Lesser General Public
12 * License for more details.
13 *
14 * You should have received a copy of both the GNU Lesser General Public
15 * License version 3 along with this program. If not, see
16 * <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
19 *
20 */
21
22#include "test_im_text_entry.h"
23
24TestEvent::TestEvent(nux::KeyModifier keymod, unsigned long keysym)
25{
26 type = nux::NUX_KEYDOWN;
27 key_modifiers = keymod;
28 x11_keysym = keysym;
29}
30
31TestEvent::TestEvent(unsigned long keysym)
32{
33 type = nux::NUX_KEYDOWN;
34 x11_keysym = keysym;
35}
36
37bool MockTextEntry::InspectKeyEvent(nux::Event const& event)
38{
39 key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0);
40 return IMTextEntry::InspectKeyEvent(event);
41}
042
=== added file 'tests/test_im_text_entry_slow.cpp'
--- tests/test_im_text_entry_slow.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_im_text_entry_slow.cpp 2013-03-18 22:56:25 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2012-2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the applicable version of the GNU Lesser General Public
12 * License for more details.
13 *
14 * You should have received a copy of both the GNU Lesser General Public
15 * License version 3 along with this program. If not, see
16 * <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
19 *
20 */
21
22#include "test_im_text_entry.h"
23
24using namespace nux;
25
26TEST(TestIMTextEntry, AltKeybindings)
27{
28 MockTextEntry text_entry;
29
30 for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
31 {
32 TestEvent event(KEY_MODIFIER_ALT, keysym);
33 EXPECT_FALSE(text_entry.InspectKeyEvent(event));
34 }
35}
36
37TEST(TestIMTextEntry, SuperKeybindings)
38{
39 MockTextEntry text_entry;
40
41 for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
42 {
43 TestEvent event(KEY_MODIFIER_SUPER, keysym);
44 EXPECT_FALSE(text_entry.InspectKeyEvent(event));
45 }
46}