Merge lp:~aacid/qtmir/fix_qteventfeeder_test_leak into lp:qtmir

Proposed by Albert Astals Cid
Status: Superseded
Proposed branch: lp:~aacid/qtmir/fix_qteventfeeder_test_leak
Merge into: lp:qtmir
Diff against target: 127 lines (+28/-4)
6 files modified
CMakeLists.txt (+7/-0)
src/modules/Unity/Application/session.cpp (+1/-1)
tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h (+12/-1)
tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp (+2/-2)
tests/mirserver/ScreensModel/screensmodel_test.cpp (+1/-0)
tests/modules/SessionManager/session_test.cpp (+5/-0)
To merge this branch: bzr merge lp:~aacid/qtmir/fix_qteventfeeder_test_leak
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+296032@code.launchpad.net

This proposal has been superseded by a proposal from 2016-05-30.

Commit message

Fix memory leak in QtEventFeederTest

MockQtWindowSystem needs to delete the devices passed to registerTouchDevice as the real Qt class does

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

To post a comment you must log in.
501. By Albert Astals Cid

remove debug change

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-05-18 11:15:56 +0000
3+++ CMakeLists.txt 2016-05-30 10:26:25 +0000
4@@ -13,6 +13,13 @@
5 # Find includes in corresponding build directories
6 set(CMAKE_INCLUDE_CURRENT_DIR ON)
7
8+find_package (ECM 1.7.0 QUIET NO_MODULE)
9+if (ECM_FOUND)
10+ # Provides us with -DECM_ENABLE_SANITIZERS='X'
11+ # Where X can be address, thread, memory, leak, undefined
12+ include("${ECM_MODULE_DIR}/ECMEnableSanitizers.cmake")
13+endif()
14+
15 # add custom cmake modules
16 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
17
18
19=== modified file 'src/modules/Unity/Application/session.cpp'
20--- src/modules/Unity/Application/session.cpp 2016-05-17 19:18:44 +0000
21+++ src/modules/Unity/Application/session.cpp 2016-05-30 10:26:25 +0000
22@@ -84,7 +84,7 @@
23
24 Session::~Session()
25 {
26- qCDebug(QTMIR_SESSIONS) << "Session::~Session() " << name();
27+ qDebug() << "Session::~Session() " << name();
28 stopPromptSessions();
29
30 QList<SessionInterface*> children(m_children->list());
31
32=== modified file 'tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h'
33--- tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2016-01-07 11:37:55 +0000
34+++ tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2016-05-30 10:26:25 +0000
35@@ -28,7 +28,6 @@
36 MOCK_METHOD1(getWindowForTouchPoint, QWindow*(const QPoint &point));
37 MOCK_METHOD0(lastWindow, QWindow*());
38 MOCK_METHOD0(focusedWindow, QWindow*());
39- MOCK_METHOD1(registerTouchDevice, void(QTouchDevice* device));
40
41 // Wanted to use GMock, but MOCK_METHOD11 not implemented
42 void handleExtendedKeyEvent(QWindow */*window*/, ulong /*timestamp*/, QEvent::Type /*type*/, int /*key*/,
43@@ -43,6 +42,18 @@
44 Qt::KeyboardModifiers mods));
45 MOCK_METHOD4(handleMouseEvent, void(ulong timestamp, QPointF point, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers));
46 MOCK_METHOD3(handleWheelEvent, void(ulong timestamp, QPoint angleDelta, Qt::KeyboardModifiers mods));
47+
48+ ~MockQtWindowSystem()
49+ {
50+ qDeleteAll(m_devices);
51+ }
52+
53+ void registerTouchDevice(QTouchDevice* device)
54+ {
55+ m_devices << device;
56+ }
57+
58+ QVector<QTouchDevice*> m_devices;
59 };
60
61 namespace testing
62
63=== modified file 'tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp'
64--- tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2016-04-29 15:41:00 +0000
65+++ tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2016-05-30 10:26:25 +0000
66@@ -78,11 +78,11 @@
67 mockWindowSystem = new MockQtWindowSystem;
68 auto screens = QSharedPointer<ScreensModel>();
69
70- EXPECT_CALL(*mockWindowSystem, registerTouchDevice(_));
71+ ASSERT_TRUE(mockWindowSystem->m_devices.count() == 0);
72
73 qtEventFeeder = new QtEventFeeder(screens, mockWindowSystem);
74
75- ASSERT_TRUE(Mock::VerifyAndClearExpectations(mockWindowSystem));
76+ ASSERT_TRUE(mockWindowSystem->m_devices.count() == 1);
77
78 int argc = 0;
79 char **argv = nullptr;
80
81=== modified file 'tests/mirserver/ScreensModel/screensmodel_test.cpp'
82--- tests/mirserver/ScreensModel/screensmodel_test.cpp 2016-04-29 15:41:00 +0000
83+++ tests/mirserver/ScreensModel/screensmodel_test.cpp 2016-05-30 10:26:25 +0000
84@@ -64,6 +64,7 @@
85 void ScreensModelTest::TearDown()
86 {
87 delete screensModel;
88+ delete app;
89 }
90
91 TEST_F(ScreensModelTest, SingleScreenFound)
92
93=== modified file 'tests/modules/SessionManager/session_test.cpp'
94--- tests/modules/SessionManager/session_test.cpp 2016-05-17 19:18:44 +0000
95+++ tests/modules/SessionManager/session_test.cpp 2016-05-30 10:26:25 +0000
96@@ -65,6 +65,8 @@
97
98 surface->drawFirstFrame();
99 EXPECT_EQ(Session::Running, session->state());
100+
101+ delete surface;
102 }
103
104 TEST_F(SessionTests, AddChildSession)
105@@ -223,6 +225,7 @@
106 FakeMirSurface *surface = new FakeMirSurface;
107 session->registerSurface(surface);
108 surface->drawFirstFrame();
109+ delete surface;
110 }
111 EXPECT_EQ(Session::Running, session->state());
112
113@@ -254,6 +257,7 @@
114 FakeMirSurface *surface = new FakeMirSurface;
115 session->registerSurface(surface);
116 surface->drawFirstFrame();
117+ delete surface;
118 }
119 EXPECT_EQ(Session::Running, session->state());
120
121@@ -299,6 +303,7 @@
122 FakeMirSurface *surface = new FakeMirSurface;
123 session->registerSurface(surface);
124 surface->drawFirstFrame();
125+ delete surface;
126 }
127 EXPECT_EQ(Session::Running, session->state());
128

Subscribers

People subscribed via source and target branches