Mir

Merge lp:~alan-griffiths/mir/tidy-code into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 4094
Proposed branch: lp:~alan-griffiths/mir/tidy-code
Merge into: lp:mir
Diff against target: 489 lines (+0/-420)
6 files modified
src/client/CMakeLists.txt (+0/-1)
src/client/private.cpp (+0/-26)
src/include/client/mir/client/private.h (+0/-47)
tests/integration-tests/CMakeLists.txt (+0/-10)
tests/integration-tests/test_protobuf.cpp (+0/-316)
tests/integration-tests/test_protobuf.proto (+0/-20)
To merge this branch: bzr merge lp:~alan-griffiths/mir/tidy-code
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Andreas Pokorny (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+320227@code.launchpad.net

Commit message

Remove unused mechanism for exposing the protobuf RPC channel

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4094
https://mir-jenkins.ubuntu.com/job/mir-ci/3183/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4279
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4366
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4356
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4356
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4356
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4306
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4306/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4306
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4306/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4306
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4306/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4306
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4306/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4306
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4306/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4306
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4306/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3183/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:4095
https://mir-jenkins.ubuntu.com/job/mir-ci/3184/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/4280/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4367
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4357
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4357
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4357
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4307
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4307/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4307
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4307/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4307
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4307/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4307/console
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4307/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4307
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4307/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4307
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4307/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3184/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4095
https://mir-jenkins.ubuntu.com/job/mir-ci/3186/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4284
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4371
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/4361
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/4361
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4361
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4311
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4311/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4311
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/4311/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4311
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4311/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4311
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/4311/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4311
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/4311/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4311
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/4311/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3186/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

lots of red..

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Sure, if it really is unused.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2017-01-24 13:43:12 +0000
+++ src/client/CMakeLists.txt 2017-03-17 17:00:15 +0000
@@ -66,7 +66,6 @@
66 logging/perf_report.cpp66 logging/perf_report.cpp
67 default_connection_configuration.cpp67 default_connection_configuration.cpp
68 connection_surface_map.cpp68 connection_surface_map.cpp
69 private.cpp
70 frame_clock.cpp69 frame_clock.cpp
71 mir_screencast.cpp70 mir_screencast.cpp
72 mir_screencast_api.cpp71 mir_screencast_api.cpp
7372
=== removed file 'src/client/private.cpp'
--- src/client/private.cpp 2017-01-18 02:29:37 +0000
+++ src/client/private.cpp 1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it 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,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "mir/client/private.h"
20#include "mir_connection.h"
21
22auto mir::client::the_rpc_channel(MirConnection *connection)
23-> std::shared_ptr<mir::client::rpc::MirBasicRpcChannel>
24{
25 return connection->rpc_channel();
26}
270
=== removed file 'src/include/client/mir/client/private.h'
--- src/include/client/mir/client/private.h 2016-01-29 08:18:22 +0000
+++ src/include/client/mir/client/private.h 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it 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,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_CLIENT_PRIVATE_H_
20#define MIR_CLIENT_PRIVATE_H_
21
22#include <mir_toolkit/client_types.h>
23
24#include <memory>
25
26namespace mir
27{
28namespace client
29{
30namespace rpc
31{
32class MirBasicRpcChannel;
33}
34/**
35 * Get the the RpcChannel associated with the connection.
36 * This is a "private" function to support development of client-side protobuf RPC calls
37 * using the Mir infrastructure. This intended for internal prototyping and there is no
38 * commitment to long term support.
39 *
40 * @param connection - a connection to a Mir server
41 * @return the RpcChannel associated with the connection
42 */
43std::shared_ptr<mir::client::rpc::MirBasicRpcChannel> the_rpc_channel(MirConnection* connection);
44}
45}
46
47#endif /* MIR_CLIENT_PRIVATE_H_ */
480
=== modified file 'tests/integration-tests/CMakeLists.txt'
--- tests/integration-tests/CMakeLists.txt 2017-02-15 14:45:41 +0000
+++ tests/integration-tests/CMakeLists.txt 2017-03-17 17:00:15 +0000
@@ -2,7 +2,6 @@
22
3include_directories(3include_directories(
4 ${CMAKE_SOURCE_DIR}4 ${CMAKE_SOURCE_DIR}
5 ${PROTOBUF_INCLUDE_DIRS}
6 ${CMAKE_CURRENT_BINARY_DIR}5 ${CMAKE_CURRENT_BINARY_DIR}
7 ${PROJECT_SOURCE_DIR}/include/cookie6 ${PROJECT_SOURCE_DIR}/include/cookie
8 ${PROJECT_SOURCE_DIR}/src/include/platform7 ${PROJECT_SOURCE_DIR}/src/include/platform
@@ -14,11 +13,6 @@
14 ${PROJECT_SOURCE_DIR}/include/renderers/sw13 ${PROJECT_SOURCE_DIR}/include/renderers/sw
15)14)
1615
17protobuf_generate_cpp(
18 GENERATED_PROTOBUF_SRCS GENERATED_PROTOBUF_HDRS
19 test_protobuf.proto
20)
21
22set(16set(
23 INTEGRATION_TESTS_SRCS17 INTEGRATION_TESTS_SRCS
24 test_focus_selection.cpp18 test_focus_selection.cpp
@@ -27,7 +21,6 @@
27 test_buffer_scheduling.cpp21 test_buffer_scheduling.cpp
28 test_client_screencast.cpp22 test_client_screencast.cpp
29 test_large_messages.cpp23 test_large_messages.cpp
30 test_protobuf.cpp
31 test_surfaceloop.cpp24 test_surfaceloop.cpp
32 test_stale_frames.cpp25 test_stale_frames.cpp
33 test_test_framework.cpp26 test_test_framework.cpp
@@ -42,8 +35,6 @@
42 test_server_shutdown.cpp35 test_server_shutdown.cpp
43 test_session.cpp36 test_session.cpp
44 session_management.cpp37 session_management.cpp
45 ${GENERATED_PROTOBUF_SRCS}
46 ${GENERATED_PROTOBUF_HDRS}
47)38)
4839
49add_subdirectory(client/)40add_subdirectory(client/)
@@ -77,7 +68,6 @@
7768
78 mircommon69 mircommon
7970
80 ${PROTOBUF_LITE_LIBRARIES}
81 ${Boost_LIBRARIES}71 ${Boost_LIBRARIES}
82 ${GTEST_BOTH_LIBRARIES}72 ${GTEST_BOTH_LIBRARIES}
83 ${GMOCK_LIBRARY}73 ${GMOCK_LIBRARY}
8474
=== removed file 'tests/integration-tests/test_protobuf.cpp'
--- tests/integration-tests/test_protobuf.cpp 2017-01-18 02:29:37 +0000
+++ tests/integration-tests/test_protobuf.cpp 1970-01-01 00:00:00 +0000
@@ -1,316 +0,0 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "test_protobuf.pb.h"
20#include "src/client/rpc/mir_basic_rpc_channel.h"
21
22#include "mir_toolkit/mir_client_library.h"
23#include "mir/client/private.h"
24#include "mir/frontend/protobuf_message_sender.h"
25#include "mir/frontend/protobuf_connection_creator.h"
26#include "mir/frontend/template_protobuf_message_processor.h"
27
28#include "mir_test_framework/stubbed_server_configuration.h"
29#include "mir_test_framework/in_process_server.h"
30#include "mir/test/doubles/null_platform_ipc_operations.h"
31
32#include <gtest/gtest.h>
33#include <gmock/gmock.h>
34
35#include <atomic>
36
37namespace mf = mir::frontend;
38namespace mfd = mir::frontend::detail;
39namespace mtf = mir_test_framework;
40
41/*************************************************************************/
42/*************************************************************************/
43/* Note that the functionality demonstrated here relies on "detail" and */
44/* is not guaranteed to be supported in future. */
45/*************************************************************************/
46/*************************************************************************/
47namespace
48{
49struct DemoMirServer
50{
51 MOCK_CONST_METHOD1(on_call, std::string(std::string));
52
53 DemoMirServer()
54 {
55 using namespace testing;
56 ON_CALL(*this, on_call(_)).WillByDefault(Return("ok"));
57 }
58
59 void function(
60 mir::protobuf::test::Parameters const* parameters,
61 mir::protobuf::test::Result* response,
62 google::protobuf::Closure* done)
63 {
64 response->set_value(on_call(parameters->name()));
65 done->Run();
66 }
67};
68
69struct AMirServer
70{
71 AMirServer(std::shared_ptr<mir::client::rpc::MirBasicRpcChannel> const& channel)
72 : channel{channel}
73 {
74 }
75
76 void function(
77 mir::protobuf::test::Parameters const* parameters,
78 mir::protobuf::test::Result* response,
79 google::protobuf::Closure* done)
80 {
81 channel->call_method(std::string(__func__), parameters, response, done);
82 }
83 std::shared_ptr<mir::client::rpc::MirBasicRpcChannel> channel;
84};
85
86// using a global for easy access from tests and DemoMessageProcessor::dispatch()
87DemoMirServer* demo_mir_server;
88
89struct DemoMessageProcessor : mfd::MessageProcessor
90{
91 DemoMessageProcessor(
92 std::shared_ptr<mfd::ProtobufMessageSender> const& sender,
93 std::shared_ptr<mfd::MessageProcessor> const& wrapped) :
94 sender(sender),
95 wrapped(wrapped) {}
96
97 void client_pid(int /*pid*/) override {}
98
99 bool dispatch(mfd::Invocation const& invocation, std::vector<mir::Fd> const& fds) override
100 {
101 if ("function" == invocation.method_name())
102 {
103 mfd::invoke(
104 this,
105 demo_mir_server,
106 &DemoMirServer::function,
107 invocation);
108 return true;
109 }
110
111 return wrapped->dispatch(invocation, fds);
112 }
113
114 void send_response(::google::protobuf::uint32 id, ::google::protobuf::MessageLite* response)
115 {
116 sender->send_response(id, response, {});
117 }
118
119 std::shared_ptr<mfd::ProtobufMessageSender> const sender;
120 std::shared_ptr<mfd::MessageProcessor> const wrapped;
121};
122
123struct DemoConnectionCreator : mf::ProtobufConnectionCreator
124{
125 using ProtobufConnectionCreator::ProtobufConnectionCreator;
126
127 MOCK_CONST_METHOD3(create_processor,
128 std::shared_ptr<mfd::MessageProcessor>(
129 std::shared_ptr<mfd::ProtobufMessageSender> const& sender,
130 std::shared_ptr<mfd::DisplayServer> const& display_server,
131 std::shared_ptr<mf::MessageProcessorReport> const& report));
132
133 std::shared_ptr<mfd::MessageProcessor> create_wrapped_processor(
134 std::shared_ptr<mfd::ProtobufMessageSender> const& sender,
135 std::shared_ptr<mfd::DisplayServer> const& display_server,
136 std::shared_ptr<mf::MessageProcessorReport> const& report) const
137 {
138 auto const wrapped = mf::ProtobufConnectionCreator::create_processor(
139 sender,
140 display_server,
141 report);
142
143 return std::make_shared<DemoMessageProcessor>(sender, wrapped);
144 }
145
146 std::shared_ptr<mfd::MessageProcessor> create_unwrapped_processor(
147 std::shared_ptr<mfd::ProtobufMessageSender> const& sender,
148 std::shared_ptr<mfd::DisplayServer> const& display_server,
149 std::shared_ptr<mf::MessageProcessorReport> const& report) const
150 {
151 return mf::ProtobufConnectionCreator::create_processor(
152 sender,
153 display_server,
154 report);
155 }
156};
157
158struct DemoServerConfiguration : mtf::StubbedServerConfiguration
159{
160 std::shared_ptr<mf::ConnectionCreator> the_connection_creator() override
161 {
162 return connection_creator([this]
163 {
164 return std::make_shared<DemoConnectionCreator>(
165 new_ipc_factory(the_session_authorizer()),
166 the_session_authorizer(),
167 std::make_shared<mir::test::doubles::NullPlatformIpcOperations>(),
168 the_message_processor_report());
169 });
170 }
171
172};
173
174struct DemoPrivateProtobuf : mtf::InProcessServer
175{
176 mir::DefaultServerConfiguration& server_config() override { return my_server_config; }
177
178 DemoServerConfiguration my_server_config;
179
180 std::shared_ptr<DemoConnectionCreator> demo_connection_creator;
181
182 void SetUp() override
183 {
184 ::demo_mir_server = &demo_mir_server;
185
186 mtf::InProcessServer::SetUp();
187 demo_connection_creator = std::dynamic_pointer_cast<DemoConnectionCreator>(my_server_config.the_connection_creator());
188
189 using namespace testing;
190 ASSERT_THAT(demo_connection_creator, NotNull());
191
192 ON_CALL(*demo_connection_creator, create_processor(_, _, _))
193 .WillByDefault(Invoke(demo_connection_creator.get(), &DemoConnectionCreator::create_unwrapped_processor));
194 }
195
196 testing::NiceMock<DemoMirServer> demo_mir_server;
197};
198
199void callback(std::atomic<bool>* called_back) { called_back->store(true); }
200char const* const nothing_returned = "Nothing returned";
201}
202
203TEST_F(DemoPrivateProtobuf, client_calls_server)
204{
205 using namespace testing;
206 EXPECT_CALL(*demo_connection_creator, create_processor(_, _, _));
207
208 auto const connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
209 ASSERT_TRUE(mir_connection_is_valid(connection));
210
211 auto const rpc_channel = mir::client::the_rpc_channel(connection);
212
213 using namespace mir::protobuf::test;
214 using namespace google::protobuf;
215
216 AMirServer server(rpc_channel);
217
218 Parameters parameters;
219 parameters.set_name(__PRETTY_FUNCTION__);
220
221 Result result;
222 result.set_error(nothing_returned);
223 std::atomic<bool> called_back{false};
224
225 // After the call there's a race between the client releasing the connection
226 // and the server dropping the connection.
227 // If the latter wins we'll invoke the client's lifecycle_event_callback.
228 // As the default callback kills the process with SIGHUP, we need to
229 // replace it to ensure the test can continue.
230 mir_connection_set_lifecycle_event_callback(
231 connection,
232 [](MirConnection*, MirLifecycleState, void*){},
233 nullptr);
234
235 // Note:
236 // As the default server won't recognise this call it drops the connection
237 // resulting in a callback when the connection drops (but result being unchanged)
238 server.function(
239 &parameters,
240 &result,
241 NewCallback(&callback, &called_back));
242
243 mir_connection_release(connection);
244
245 EXPECT_TRUE(called_back);
246 EXPECT_THAT(result.error(), Eq(nothing_returned));
247}
248
249TEST_F(DemoPrivateProtobuf, wrapping_message_processor)
250{
251 using namespace testing;
252 EXPECT_CALL(*demo_connection_creator, create_processor(_, _, _))
253 .Times(1)
254 .WillOnce(Invoke(demo_connection_creator.get(), &DemoConnectionCreator::create_wrapped_processor));
255
256 auto const connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
257
258 mir_connection_release(connection);
259}
260
261TEST_F(DemoPrivateProtobuf, server_receives_function_call)
262{
263 using namespace testing;
264 EXPECT_CALL(*demo_connection_creator, create_processor(_, _, _))
265 .WillRepeatedly(Invoke(demo_connection_creator.get(), &DemoConnectionCreator::create_wrapped_processor));
266
267 auto const connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
268 ASSERT_TRUE(mir_connection_is_valid(connection));
269
270 auto const rpc_channel = mir::client::the_rpc_channel(connection);
271
272 using namespace mir::protobuf::test;
273 using namespace google::protobuf;
274
275 AMirServer server(rpc_channel);
276
277 Parameters parameters;
278 Result result;
279 parameters.set_name(__PRETTY_FUNCTION__);
280
281 EXPECT_CALL(demo_mir_server, on_call(__PRETTY_FUNCTION__)).Times(1);
282
283 server.function(&parameters, &result, NewCallback([]{}));
284
285 mir_connection_release(connection);
286}
287
288
289TEST_F(DemoPrivateProtobuf, client_receives_result)
290{
291 using namespace testing;
292 EXPECT_CALL(*demo_connection_creator, create_processor(_, _, _))
293 .WillRepeatedly(Invoke(demo_connection_creator.get(), &DemoConnectionCreator::create_wrapped_processor));
294 EXPECT_CALL(demo_mir_server, on_call(_)).WillRepeatedly(Return(__PRETTY_FUNCTION__));
295
296 auto const connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
297 ASSERT_TRUE(mir_connection_is_valid(connection));
298
299 auto const rpc_channel = mir::client::the_rpc_channel(connection);
300
301 using namespace mir::protobuf::test;
302 using namespace google::protobuf;
303
304 AMirServer server(rpc_channel);
305
306 Parameters parameters;
307 Result result;
308 parameters.set_name(__PRETTY_FUNCTION__);
309
310 server.function(&parameters, &result, NewCallback([]{}));
311
312 mir_connection_release(connection);
313
314 EXPECT_THAT(result.has_error(), Eq(false));
315 EXPECT_THAT(result.value(), Eq(__PRETTY_FUNCTION__));
316}
3170
=== removed file 'tests/integration-tests/test_protobuf.proto'
--- tests/integration-tests/test_protobuf.proto 2017-01-18 02:29:37 +0000
+++ tests/integration-tests/test_protobuf.proto 1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
1syntax = "proto2";
2option optimize_for = LITE_RUNTIME;
3
4package mir.protobuf.test;
5
6message Parameters {
7 required string name = 1;
8}
9
10message StructuredError {
11 optional uint32 domain = 1;
12 optional uint32 code = 2;
13}
14
15message Result {
16 optional string error = 127;
17 optional StructuredError structured_error = 128;
18 optional string value = 1;
19}
20

Subscribers

People subscribed via source and target branches