Merge lp:~brandontschaefer/unity/lp.1102699-fix-unit-tests into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3066
Proposed branch: lp:~brandontschaefer/unity/lp.1102699-fix-unit-tests
Merge into: lp:unity
Diff against target: 169 lines (+21/-21)
8 files modified
tests/test_launcher.cpp (+2/-2)
tests/test_launcher_drag_window.cpp (+13/-13)
tests/test_previews_application.cpp (+1/-1)
tests/test_previews_generic.cpp (+1/-1)
tests/test_previews_movie.cpp (+1/-1)
tests/test_previews_music.cpp (+1/-1)
tests/test_previews_social.cpp (+1/-1)
tests/test_shortcut_controller.cpp (+1/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/lp.1102699-fix-unit-tests
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Andrea Azzarone (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+144625@code.launchpad.net

Commit message

Fixes a bunch of base window leaks in the unit tests, which was causes a crash. This also fixes a shortcut controller crash.

Description of the change

=== Problem ===
Lots of nux::BaseWindows were being leaked and not being cleaned up. Some were lost in circular reference, but wasn't getting clean up for the view_window_list in nux, so some dead windows where being looked at when my test was faking mouse events. This lead to the crash...

=== Fix ===
You must put ALL nux::BaseWindows into a nux::ObjectPtr, otherwise problems.

=== Tests ===
This fixes crashing tests.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Seems to fix the crash here. Btw code looks good!

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_launcher.cpp'
2--- tests/test_launcher.cpp 2012-11-26 19:24:33 +0000
3+++ tests/test_launcher.cpp 2013-01-24 03:24:23 +0000
4@@ -130,7 +130,7 @@
5 : parent_window_(new nux::BaseWindow("TestLauncherWindow"))
6 , model_(new LauncherModel)
7 , options_(new Options)
8- , launcher_(new MockLauncher(parent_window_))
9+ , launcher_(new MockLauncher(parent_window_.GetPointer()))
10 {
11 launcher_->options = options_;
12 launcher_->SetModel(model_);
13@@ -160,7 +160,7 @@
14 }
15
16 MockUScreen uscreen;
17- nux::BaseWindow* parent_window_;
18+ nux::ObjectPtr<nux::BaseWindow> parent_window_;
19 Settings settings;
20 panel::Style panel_style;
21 LauncherModel::Ptr model_;
22
23=== modified file 'tests/test_launcher_drag_window.cpp'
24--- tests/test_launcher_drag_window.cpp 2012-10-11 01:44:15 +0000
25+++ tests/test_launcher_drag_window.cpp 2013-01-24 03:24:23 +0000
26@@ -38,19 +38,19 @@
27 struct TestLauncherDragWindow : public testing::Test
28 {
29 TestLauncherDragWindow()
30- : drag_window(nux::ObjectPtr<nux::IOpenGLBaseTexture>(new nux::IOpenGLBaseTexture(nux::RTTEXTURE, ICON_WIDTH, ICON_HEIGHT, 24, 1, nux::BITFMT_B8G8R8A8)))
31+ : drag_window(new LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture>(new nux::IOpenGLBaseTexture(nux::RTTEXTURE, ICON_WIDTH, ICON_HEIGHT, 24, 1, nux::BITFMT_B8G8R8A8))))
32 {}
33
34- LauncherDragWindow drag_window;
35+ nux::ObjectPtr<LauncherDragWindow> drag_window;
36 };
37 }
38
39 TEST_F(TestLauncherDragWindow, Construction)
40 {
41- EXPECT_EQ(drag_window.GetBaseWidth(), ICON_WIDTH);
42- EXPECT_EQ(drag_window.GetBaseHeight(), ICON_HEIGHT);
43- EXPECT_FALSE(drag_window.Animating());
44- EXPECT_FALSE(drag_window.Cancelled());
45+ EXPECT_EQ(drag_window->GetBaseWidth(), ICON_WIDTH);
46+ EXPECT_EQ(drag_window->GetBaseHeight(), ICON_HEIGHT);
47+ EXPECT_FALSE(drag_window->Animating());
48+ EXPECT_FALSE(drag_window->Cancelled());
49 }
50
51 TEST_F(TestLauncherDragWindow, EscapeRequestsCancellation)
52@@ -60,32 +60,32 @@
53 cancel.x11_keysym = NUX_VK_ESCAPE;
54 bool got_signal;
55
56- drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; });
57- drag_window.GrabKeyboard();
58+ drag_window->drag_cancel_request.connect([&got_signal] { got_signal = true; });
59+ drag_window->GrabKeyboard();
60 nux::GetWindowCompositor().ProcessEvent(cancel);
61
62 EXPECT_TRUE(got_signal);
63- EXPECT_TRUE(drag_window.Cancelled());
64+ EXPECT_TRUE(drag_window->Cancelled());
65 }
66
67 TEST_F(TestLauncherDragWindow, CancelsOnWindowMapped)
68 {
69 bool got_signal;
70- drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; });
71+ drag_window->drag_cancel_request.connect([&got_signal] { got_signal = true; });
72 WindowManager::Default().window_mapped.emit(0);
73
74 EXPECT_TRUE(got_signal);
75- EXPECT_TRUE(drag_window.Cancelled());
76+ EXPECT_TRUE(drag_window->Cancelled());
77 }
78
79 TEST_F(TestLauncherDragWindow, CancelsOnWindowUnmapped)
80 {
81 bool got_signal;
82- drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; });
83+ drag_window->drag_cancel_request.connect([&got_signal] { got_signal = true; });
84 WindowManager::Default().window_unmapped.emit(0);
85
86 EXPECT_TRUE(got_signal);
87- EXPECT_TRUE(drag_window.Cancelled());
88+ EXPECT_TRUE(drag_window->Cancelled());
89 }
90
91 }
92
93=== modified file 'tests/test_previews_application.cpp'
94--- tests/test_previews_application.cpp 2012-11-07 16:31:01 +0000
95+++ tests/test_previews_application.cpp 2013-01-24 03:24:23 +0000
96@@ -96,7 +96,7 @@
97 g_hash_table_unref(action_hints1);
98 }
99
100- nux::BaseWindow* parent_window_;
101+ nux::ObjectPtr<nux::BaseWindow> parent_window_;
102 dash::Preview::Ptr preview_model_;
103
104 unity::Settings settings;
105
106=== modified file 'tests/test_previews_generic.cpp'
107--- tests/test_previews_generic.cpp 2012-11-07 16:31:01 +0000
108+++ tests/test_previews_generic.cpp 2013-01-24 03:24:23 +0000
109@@ -83,7 +83,7 @@
110 g_hash_table_unref(action_hints1);
111 }
112
113- nux::BaseWindow* parent_window_;
114+ nux::ObjectPtr<nux::BaseWindow> parent_window_;
115 dash::Preview::Ptr preview_model_;
116
117 unity::Settings settings;
118
119=== modified file 'tests/test_previews_movie.cpp'
120--- tests/test_previews_movie.cpp 2012-11-07 16:31:01 +0000
121+++ tests/test_previews_movie.cpp 2013-01-24 03:24:23 +0000
122@@ -89,7 +89,7 @@
123 g_hash_table_unref(action_hints1);
124 }
125
126- nux::BaseWindow* parent_window_;
127+ nux::ObjectPtr<nux::BaseWindow> parent_window_;
128 dash::Preview::Ptr preview_model_;
129
130 unity::Settings settings;
131
132=== modified file 'tests/test_previews_music.cpp'
133--- tests/test_previews_music.cpp 2012-11-07 16:31:01 +0000
134+++ tests/test_previews_music.cpp 2013-01-24 03:24:23 +0000
135@@ -86,7 +86,7 @@
136 g_hash_table_unref(action_hints1);
137 }
138
139- nux::BaseWindow* parent_window_;
140+ nux::ObjectPtr<nux::BaseWindow> parent_window_;
141 dash::Preview::Ptr preview_model_;
142
143 unity::Settings settings;
144
145=== modified file 'tests/test_previews_social.cpp'
146--- tests/test_previews_social.cpp 2012-11-07 16:31:01 +0000
147+++ tests/test_previews_social.cpp 2013-01-24 03:24:23 +0000
148@@ -81,7 +81,7 @@
149 preview_model_ = dash::Preview::PreviewForVariant(v);
150 }
151
152- nux::BaseWindow* parent_window_;
153+ nux::ObjectPtr<nux::BaseWindow> parent_window_;
154 dash::Preview::Ptr preview_model_;
155
156 unity::Settings settings;
157
158=== modified file 'tests/test_shortcut_controller.cpp'
159--- tests/test_shortcut_controller.cpp 2013-01-22 23:03:34 +0000
160+++ tests/test_shortcut_controller.cpp 2013-01-24 03:24:23 +0000
161@@ -87,7 +87,7 @@
162 MockUScreen uscreen;
163 Settings unity_settings;
164 MockBaseWindowRaiser::Ptr base_window_raiser_;
165- AbstractModeller::Ptr const& modeller_;
166+ AbstractModeller::Ptr modeller_;
167 NiceMock<MockShortcutController> controller_;
168
169 nux::animation::TickSource tick_source_;