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
1=== modified file 'tests/CMakeLists.txt'
2--- tests/CMakeLists.txt 2013-03-12 15:21:19 +0000
3+++ tests/CMakeLists.txt 2013-03-18 22:56:25 +0000
4@@ -99,6 +99,27 @@
5 test_service_panel.cpp)
6 target_link_libraries(test-gtest-service unity-shared ${LIBS})
7
8+# gtest-slow, start moving things over that are slow running tests
9+ set (GTEST_SLOW_SOURCES
10+ test_main.cpp
11+ logger_helper.cpp
12+ test_im_text_entry_slow.cpp
13+ test_im_text_entry_class.cpp
14+ test_tooltip_manager.cpp
15+ )
16+
17+ set (GTEST_SLOW_LIBS
18+ gtest
19+ gmock
20+ launcher-lib
21+ unity-shared
22+ )
23+
24+ add_executable(test-gtest-slow ${GTEST_SLOW_SOURCES})
25+
26+ target_link_libraries(test-gtest-slow ${GTEST_SLOW_LIBS})
27+
28+ add_test(UnityGTestSlow test-gtest-slow)
29
30 # The actual test executable (xless) - do not put anything that requires X in here
31 set (GTEST_XLESS_SOURCES
32@@ -218,6 +239,7 @@
33 test_hud_view.cpp
34 test_icon_loader.cpp
35 test_im_text_entry.cpp
36+ test_im_text_entry_class.cpp
37 test_launcher.cpp
38 test_launcher_controller.cpp
39 test_launcher_drag_window.cpp
40@@ -263,7 +285,6 @@
41 test_texture_cache.cpp
42 test_text_input.cpp
43 test_thumbnail_generator.cpp
44- test_tooltip_manager.cpp
45 test_trash_launcher_icon.cpp
46 test_unity_settings.cpp
47 test_unity_window_style.cpp
48@@ -322,6 +343,7 @@
49 set (GTEST_TEST_COMMAND_GESTURES ./test-gestures/test-gestures)
50 endif (ENABLE_X_SUPPORT)
51 set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless)
52+set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow)
53 set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --task ./test-gtest-service --task ./test-gtest-dbus)
54
55 set (TEST_COMMAND
56@@ -330,6 +352,7 @@
57 && ${GTEST_TEST_COMMAND_XLESS} --gtest_output=xml:./
58 && ${GTEST_TEST_COMMAND_GESTURES} --gtest_output=xml:./
59 && ${GTEST_TEST_COMMAND_DBUS} --gtest_output=xml:./
60+ && ${GTEST_TEST_COMMAND_SLOW} --gtest_output=xml:./
61 )
62
63 set (TEST_COMMAND_HEADLESS
64@@ -340,7 +363,7 @@
65
66 if (GTEST_SRC_DIR)
67 if (ENABLE_X_SUPPORT)
68- add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-xless test-gtest-dbus test-gestures)
69+ add_custom_target (check COMMAND ${TEST_COMMAND} DEPENDS test-unit test-gtest test-gtest-slow test-gtest-xless test-gtest-dbus test-gestures)
70 add_custom_target (check-headless COMMAND ${TEST_COMMAND_HEADLESS} DEPENDS test-gtest-xless test-gtest-dbus test-gestures)
71 add_custom_target (gcheck COMMAND ${DBUS_TEST_COMMAND} DEPENDS test-gtest test-gtest-xless)
72 else ()
73
74=== modified file 'tests/test_im_text_entry.cpp'
75--- tests/test_im_text_entry.cpp 2012-07-03 04:19:21 +0000
76+++ tests/test_im_text_entry.cpp 2013-03-18 22:56:25 +0000
77@@ -1,5 +1,5 @@
78 /*
79- * Copyright 2012 Canonical Ltd.
80+ * Copyright 2012-2013 Canonical Ltd.
81 *
82 * This program is free software: you can redistribute it and/or modify it
83 * under the terms of the GNU Lesser General Public License version 3, as
84@@ -19,49 +19,12 @@
85 *
86 */
87
88-#include <gmock/gmock.h>
89-#include "unity-shared/IMTextEntry.h"
90+#include "test_im_text_entry.h"
91
92 using namespace testing;
93 using namespace unity;
94 using namespace nux;
95
96-namespace
97-{
98-
99-class TestEvent : public nux::Event
100-{
101-public:
102- TestEvent(nux::KeyModifier keymod, unsigned long keysym)
103- {
104- type = NUX_KEYDOWN;
105- key_modifiers = keymod;
106- x11_keysym = keysym;
107- }
108-
109- TestEvent(unsigned long keysym)
110- {
111- type = NUX_KEYDOWN;
112- x11_keysym = keysym;
113- }
114-};
115-
116-class MockTextEntry : public IMTextEntry
117-{
118-public:
119- MOCK_METHOD0(CutClipboard, void());
120- MOCK_METHOD0(CopyClipboard, void());
121- MOCK_METHOD0(PasteClipboard, void());
122- MOCK_METHOD0(PastePrimaryClipboard, void());
123-
124- bool InspectKeyEvent(nux::Event const& event)
125- {
126- key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0);
127- return IMTextEntry::InspectKeyEvent(event);
128- }
129-};
130-
131-
132 TEST(TestIMTextEntry, CopyCtrlC)
133 {
134 MockTextEntry text_entry;
135@@ -173,27 +136,3 @@
136 EXPECT_TRUE(text_entry.InspectKeyEvent(event));
137 }
138 }
139-
140-TEST(TestIMTextEntry, AltKeybindings)
141-{
142- MockTextEntry text_entry;
143-
144- for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
145- {
146- TestEvent event(KEY_MODIFIER_ALT, keysym);
147- EXPECT_FALSE(text_entry.InspectKeyEvent(event));
148- }
149-}
150-
151-TEST(TestIMTextEntry, SuperKeybindings)
152-{
153- MockTextEntry text_entry;
154-
155- for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
156- {
157- TestEvent event(KEY_MODIFIER_SUPER, keysym);
158- EXPECT_FALSE(text_entry.InspectKeyEvent(event));
159- }
160-}
161-
162-}
163
164=== added file 'tests/test_im_text_entry.h'
165--- tests/test_im_text_entry.h 1970-01-01 00:00:00 +0000
166+++ tests/test_im_text_entry.h 2013-03-18 22:56:25 +0000
167@@ -0,0 +1,47 @@
168+/*
169+ * Copyright 2012-2013 Canonical Ltd.
170+ *
171+ * This program is free software: you can redistribute it and/or modify it
172+ * under the terms of the GNU Lesser General Public License version 3, as
173+ * published by the Free Software Foundation.
174+ *
175+ * This program is distributed in the hope that it will be useful, but
176+ * WITHOUT ANY WARRANTY; without even the implied warranties of
177+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
178+ * PURPOSE. See the applicable version of the GNU Lesser General Public
179+ * License for more details.
180+ *
181+ * You should have received a copy of both the GNU Lesser General Public
182+ * License version 3 along with this program. If not, see
183+ * <http://www.gnu.org/licenses/>
184+ *
185+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
186+ *
187+ */
188+
189+#ifndef TEST_IM_TEXT_ENTRY_H
190+#define TEST_IM_TEXT_ENTRY_H
191+
192+#include <gmock/gmock.h>
193+#include "unity-shared/IMTextEntry.h"
194+
195+class TestEvent : public nux::Event
196+{
197+public:
198+ TestEvent(nux::KeyModifier keymod, unsigned long keysym);
199+
200+ TestEvent(unsigned long keysym);
201+};
202+
203+class MockTextEntry : public unity::IMTextEntry
204+{
205+public:
206+ MOCK_METHOD0(CutClipboard, void());
207+ MOCK_METHOD0(CopyClipboard, void());
208+ MOCK_METHOD0(PasteClipboard, void());
209+ MOCK_METHOD0(PastePrimaryClipboard, void());
210+
211+ bool InspectKeyEvent(nux::Event const& event);
212+};
213+
214+#endif // TEST_IM_TEXT_ENTRY_H
215
216=== added file 'tests/test_im_text_entry_class.cpp'
217--- tests/test_im_text_entry_class.cpp 1970-01-01 00:00:00 +0000
218+++ tests/test_im_text_entry_class.cpp 2013-03-18 22:56:25 +0000
219@@ -0,0 +1,41 @@
220+/*
221+ * Copyright 2012-2013 Canonical Ltd.
222+ *
223+ * This program is free software: you can redistribute it and/or modify it
224+ * under the terms of the GNU Lesser General Public License version 3, as
225+ * published by the Free Software Foundation.
226+ *
227+ * This program is distributed in the hope that it will be useful, but
228+ * WITHOUT ANY WARRANTY; without even the implied warranties of
229+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
230+ * PURPOSE. See the applicable version of the GNU Lesser General Public
231+ * License for more details.
232+ *
233+ * You should have received a copy of both the GNU Lesser General Public
234+ * License version 3 along with this program. If not, see
235+ * <http://www.gnu.org/licenses/>
236+ *
237+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
238+ *
239+ */
240+
241+#include "test_im_text_entry.h"
242+
243+TestEvent::TestEvent(nux::KeyModifier keymod, unsigned long keysym)
244+{
245+ type = nux::NUX_KEYDOWN;
246+ key_modifiers = keymod;
247+ x11_keysym = keysym;
248+}
249+
250+TestEvent::TestEvent(unsigned long keysym)
251+{
252+ type = nux::NUX_KEYDOWN;
253+ x11_keysym = keysym;
254+}
255+
256+bool MockTextEntry::InspectKeyEvent(nux::Event const& event)
257+{
258+ key_down.emit(event.type, event.GetKeySym(), event.GetKeyState(), nullptr, 0);
259+ return IMTextEntry::InspectKeyEvent(event);
260+}
261
262=== added file 'tests/test_im_text_entry_slow.cpp'
263--- tests/test_im_text_entry_slow.cpp 1970-01-01 00:00:00 +0000
264+++ tests/test_im_text_entry_slow.cpp 2013-03-18 22:56:25 +0000
265@@ -0,0 +1,46 @@
266+/*
267+ * Copyright 2012-2013 Canonical Ltd.
268+ *
269+ * This program is free software: you can redistribute it and/or modify it
270+ * under the terms of the GNU Lesser General Public License version 3, as
271+ * published by the Free Software Foundation.
272+ *
273+ * This program is distributed in the hope that it will be useful, but
274+ * WITHOUT ANY WARRANTY; without even the implied warranties of
275+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
276+ * PURPOSE. See the applicable version of the GNU Lesser General Public
277+ * License for more details.
278+ *
279+ * You should have received a copy of both the GNU Lesser General Public
280+ * License version 3 along with this program. If not, see
281+ * <http://www.gnu.org/licenses/>
282+ *
283+ * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
284+ *
285+ */
286+
287+#include "test_im_text_entry.h"
288+
289+using namespace nux;
290+
291+TEST(TestIMTextEntry, AltKeybindings)
292+{
293+ MockTextEntry text_entry;
294+
295+ for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
296+ {
297+ TestEvent event(KEY_MODIFIER_ALT, keysym);
298+ EXPECT_FALSE(text_entry.InspectKeyEvent(event));
299+ }
300+}
301+
302+TEST(TestIMTextEntry, SuperKeybindings)
303+{
304+ MockTextEntry text_entry;
305+
306+ for (unsigned long keysym = 0; keysym < XK_VoidSymbol; ++keysym)
307+ {
308+ TestEvent event(KEY_MODIFIER_SUPER, keysym);
309+ EXPECT_FALSE(text_entry.InspectKeyEvent(event));
310+ }
311+}