Mir

Merge lp:~robertcarr/mir/tests-are-bests-when-built-and-run into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Merged
Approved by: Robert Ancell
Approved revision: no longer in the source branch.
Merged at revision: 887
Proposed branch: lp:~robertcarr/mir/tests-are-bests-when-built-and-run
Merge into: lp:~mir-team/mir/trunk
Diff against target: 191 lines (+44/-77)
3 files modified
include/test/mir_test_doubles/mock_input_configuration.h (+0/-54)
tests/unit-tests/input/android/CMakeLists.txt (+1/-0)
tests/unit-tests/input/android/test_android_input_registrar.cpp (+43/-23)
To merge this branch: bzr merge lp:~robertcarr/mir/tests-are-bests-when-built-and-run
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+176766@code.launchpad.net

Commit message

Build test_android_input_registrar.cpp

Description of the change

Build test_android_input_registrar.cpp

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Yep

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'include/test/mir_test_doubles/mock_input_configuration.h'
2--- include/test/mir_test_doubles/mock_input_configuration.h 2013-05-23 20:06:04 +0000
3+++ include/test/mir_test_doubles/mock_input_configuration.h 1970-01-01 00:00:00 +0000
4@@ -1,54 +0,0 @@
5-/*
6- * Copyright © 2013 Canonical Ltd.
7- *
8- * This program is free software: you can redistribute it and/or modify it
9- * under the terms of the GNU General Public License version 3,
10- * as published by the Free Software Foundation.
11- *
12- * This program is distributed in the hope that it will be useful,
13- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- * GNU General Public License for more details.
16- *
17- * You should have received a copy of the GNU General Public License
18- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19- *
20- * Authored by: Robert Carr <robert.carr@canonical.com>
21- */
22-
23-#ifndef MIR_TEST_DOUBLES_MOCK_INPUT_CONFIGURATION_H_
24-#define MIR_TEST_DOUBLES_MOCK_INPUT_CONFIGURATION_H_
25-
26-#include "mir/input/android/android_input_configuration.h"
27-
28-#include <EventHub.h>
29-
30-#include <gmock/gmock.h>
31-
32-namespace droidinput = android;
33-
34-namespace mir
35-{
36-namespace test
37-{
38-namespace doubles
39-{
40-
41-struct MockInputConfiguration : public input::android::InputConfiguration
42-{
43- MOCK_METHOD0(the_event_hub, droidinput::sp<droidinput::EventHubInterface>());
44- MOCK_METHOD0(the_dispatcher, droidinput::sp<droidinput::InputDispatcherInterface>());
45- MOCK_METHOD0(the_dispatcher_thread, std::shared_ptr<input::android::InputThread>());
46- MOCK_METHOD0(the_reader_thread, std::shared_ptr<input::android::InputThread>());
47-
48- MOCK_METHOD0(the_input_registrar, std::shared_ptr<surfaces::InputRegistrar>());
49- MOCK_METHOD0(the_input_targeter, std::shared_ptr<shell::InputTargeter>());
50-
51- MOCK_METHOD1(set_input_targets, void(std::shared_ptr<input::InputTargets> const&));
52-};
53-
54-}
55-}
56-} // namespace mir
57-
58-#endif // MIR_TEST_DOUBLES_MOCK_INPUT_CONFIGURATION_H_
59
60=== modified file 'tests/unit-tests/input/android/CMakeLists.txt'
61--- tests/unit-tests/input/android/CMakeLists.txt 2013-07-03 21:46:28 +0000
62+++ tests/unit-tests/input/android/CMakeLists.txt 2013-07-24 19:17:30 +0000
63@@ -9,6 +9,7 @@
64 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_window_handle.cpp
65 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_targeter.cpp
66 ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_target_enumerator.cpp
67+ ${CMAKE_CURRENT_SOURCE_DIR}/test_android_input_registrar.cpp
68 )
69
70 set(
71
72=== modified file 'tests/unit-tests/input/android/test_android_input_registrar.cpp'
73--- tests/unit-tests/input/android/test_android_input_registrar.cpp 2013-07-05 15:58:08 +0000
74+++ tests/unit-tests/input/android/test_android_input_registrar.cpp 2013-07-24 19:17:30 +0000
75@@ -16,9 +16,10 @@
76 * Authored by: Robert Carr <robert.carr@canonical.com>
77 */
78
79+#include "mir/input/surface.h"
80+
81 #include "src/server/input/android/android_input_registrar.h"
82
83-#include "mir_test_doubles/mock_input_configuration.h"
84 #include "mir_test_doubles/mock_input_dispatcher.h"
85 #include "mir_test_doubles/stub_input_channel.h"
86
87@@ -36,6 +37,7 @@
88 namespace mia = mi::android;
89 namespace mt = mir::test;
90 namespace mtd = mt::doubles;
91+namespace geom = mir::geometry;
92
93 namespace
94 {
95@@ -57,12 +59,32 @@
96 }
97 int test_input_fd;
98 droidinput::sp<mtd::MockInputDispatcher> dispatcher;
99- mtd::MockInputConfiguration config;
100-};
101-
102-MATCHER_P(WindowHandleFor, surface, "")
103-{
104- if (arg->getInputChannel()->getFd() != surface->server_input_fd())
105+};
106+
107+struct StubInputSurface : public mi::Surface
108+{
109+ geom::Point position() const
110+ {
111+ return geom::Point();
112+ }
113+ geom::Size size() const
114+ {
115+ return geom::Size();
116+ }
117+ std::string const& name() const
118+ {
119+ static std::string const name;
120+ return name;
121+ }
122+ bool contains(geom::Point const&) const
123+ {
124+ return true;
125+ }
126+};
127+
128+MATCHER_P(WindowHandleFor, channel, "")
129+{
130+ if (arg->getInputChannel()->getFd() != channel->server_fd())
131 return false;
132 return true;
133 }
134@@ -73,19 +95,18 @@
135 {
136 using namespace ::testing;
137
138- auto surface = std::make_shared<mtd::StubInputChannel>(test_input_fd);
139+ auto channel = std::make_shared<mtd::StubInputChannel>(test_input_fd);
140+ auto surface = std::make_shared<StubInputSurface>();
141
142- EXPECT_CALL(config, the_dispatcher()).Times(1)
143- .WillOnce(Return(dispatcher));
144- EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(surface), false)).Times(1)
145+ EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(channel), false)).Times(1)
146 .WillOnce(Return(droidinput::OK));
147
148- mia::InputRegistrar registrar(mt::fake_shared(config));
149+ mia::InputRegistrar registrar(dispatcher);
150
151- registrar.input_channel_opened(surface);
152+ registrar.input_channel_opened(channel, surface);
153 EXPECT_THROW({
154 // We can't open a surface twice
155- registrar.input_channel_opened(surface);
156+ registrar.input_channel_opened(channel, surface);
157 }, std::logic_error);
158 }
159
160@@ -93,24 +114,23 @@
161 {
162 using namespace ::testing;
163
164- auto surface = std::make_shared<mtd::StubInputChannel>(test_input_fd);
165+ auto channel = std::make_shared<mtd::StubInputChannel>(test_input_fd);
166+ auto surface = std::make_shared<StubInputSurface>();
167
168- EXPECT_CALL(config, the_dispatcher()).Times(1)
169- .WillOnce(Return(dispatcher));
170- EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(surface), false)).Times(1)
171+ EXPECT_CALL(*dispatcher, registerInputChannel(_, WindowHandleFor(channel), false)).Times(1)
172 .WillOnce(Return(droidinput::OK));
173 EXPECT_CALL(*dispatcher, unregisterInputChannel(_)).Times(1);
174- mia::InputRegistrar registrar(mt::fake_shared(config));
175+ mia::InputRegistrar registrar(dispatcher);
176
177 EXPECT_THROW({
178 // We can't close a surface which hasn't been opened
179- registrar.input_channel_closed(surface);
180+ registrar.input_channel_closed(channel);
181 }, std::logic_error);
182- registrar.input_channel_opened(surface);
183- registrar.input_channel_closed(surface);
184+ registrar.input_channel_opened(channel, surface);
185+ registrar.input_channel_closed(channel);
186 EXPECT_THROW({
187 // Nor can we close a surface twice
188- registrar.input_channel_closed(surface);
189+ registrar.input_channel_closed(channel);
190 }, std::logic_error);
191 }
192

Subscribers

People subscribed via source and target branches