Mir

Merge lp:~alan-griffiths/mir/another-acceptance-test-uses-mir-Server-API into lp:mir

Proposed by Alan Griffiths
Status: Work in progress
Proposed branch: lp:~alan-griffiths/mir/another-acceptance-test-uses-mir-Server-API
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/some-acceptance-tests-use-mir-Server-API
Diff against target: 583 lines (+219/-121)
11 files modified
include/server/mir/server.h (+9/-0)
server-ABI-sha1sums (+1/-1)
src/server/server.cpp (+9/-0)
src/server/symbols.map (+2/-0)
tests/acceptance-tests/test_client_library.cpp (+2/-21)
tests/acceptance-tests/test_prompt_session_client_api.cpp (+114/-98)
tests/include/mir_test_framework/headless_in_process_server.h (+36/-0)
tests/include/mir_test_framework/headless_test.h (+3/-0)
tests/mir_test_framework/CMakeLists.txt (+1/-0)
tests/mir_test_framework/headless_in_process_server.cpp (+36/-0)
tests/mir_test_framework/headless_test.cpp (+6/-1)
To merge this branch: bzr merge lp:~alan-griffiths/mir/another-acceptance-test-uses-mir-Server-API
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+239581@code.launchpad.net

Commit message

test: Move another of the acceptance test suites [PromptSessionClientAPI.*] to the mir::Server based API

Description of the change

test: Move another of the acceptance test suites [PromptSessionClientAPI.*] to the mir::Server based API

It cleans up the "HeadlessInProcessServer" fixture from the prerequisite branch.

To post a comment you must log in.
2003. By Alan Griffiths

merge lp:~alan-griffiths/mir/some-acceptance-tests-use-mir-Server-API

2004. By Alan Griffiths

Revert accidental deletions in debian

2005. By Alan Griffiths

Delete debug code

2006. By Alan Griffiths

Reduce diff

2007. By Alan Griffiths

merge lp:~alan-griffiths/mir/some-acceptance-tests-use-mir-Server-API

Unmerged revisions

2007. By Alan Griffiths

merge lp:~alan-griffiths/mir/some-acceptance-tests-use-mir-Server-API

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/server/mir/server.h'
--- include/server/mir/server.h 2014-10-24 18:38:24 +0000
+++ include/server/mir/server.h 2014-10-24 18:38:25 +0000
@@ -35,6 +35,7 @@
35class PlacementStrategy;35class PlacementStrategy;
36class SessionListener;36class SessionListener;
37class PromptSessionListener;37class PromptSessionListener;
38class PromptSessionManager;
38class SurfaceConfigurator;39class SurfaceConfigurator;
39class SessionCoordinator;40class SessionCoordinator;
40class SurfaceCoordinator;41class SurfaceCoordinator;
@@ -211,6 +212,9 @@
211 /// \return the prompt session listener.212 /// \return the prompt session listener.
212 auto the_prompt_session_listener() const -> std::shared_ptr<scene::PromptSessionListener>;213 auto the_prompt_session_listener() const -> std::shared_ptr<scene::PromptSessionListener>;
213214
215 /// \return the prompt session manager.
216 auto the_prompt_session_manager() const ->std::shared_ptr<scene::PromptSessionManager>;
217
214 /// \return the session authorizer.218 /// \return the session authorizer.
215 auto the_session_authorizer() const -> std::shared_ptr<frontend::SessionAuthorizer>;219 auto the_session_authorizer() const -> std::shared_ptr<frontend::SessionAuthorizer>;
216220
@@ -247,6 +251,11 @@
247 /// using the format "fd://%d".251 /// using the format "fd://%d".
248 /// \param connect_handler callback to be invoked when the client connects252 /// \param connect_handler callback to be invoked when the client connects
249 auto open_client_socket(ConnectHandler const& connect_handler) -> int;253 auto open_client_socket(ConnectHandler const& connect_handler) -> int;
254
255 /// Get a file descriptor that can be used to connect a prompt provider
256 /// It can be passed to another process, or used directly with mir_connect()
257 /// using the format "fd://%d".
258 auto open_prompt_socket() -> int;
250/** @} */259/** @} */
251private:260private:
252 void apply_settings() const;261 void apply_settings() const;
253262
=== modified file 'server-ABI-sha1sums'
--- server-ABI-sha1sums 2014-10-24 18:38:24 +0000
+++ server-ABI-sha1sums 2014-10-24 18:38:25 +0000
@@ -95,7 +95,7 @@
95993e9f458ffc4288d304413f3fa0b1dcc95a093d include/server/mir/scene/surface_observer.h95993e9f458ffc4288d304413f3fa0b1dcc95a093d include/server/mir/scene/surface_observer.h
967ef3e99901168cda296d74d05a979f47bf9c3ff1 include/server/mir/server_action_queue.h967ef3e99901168cda296d74d05a979f47bf9c3ff1 include/server/mir/server_action_queue.h
978d83a51c278b8b71866d2178d9b6387c1f91a7d0 include/server/mir/server_configuration.h978d83a51c278b8b71866d2178d9b6387c1f91a7d0 include/server/mir/server_configuration.h
982ead070cf169e59015edfd94ca84295ac5adcdd6 include/server/mir/server.h9854faba134ab52958228db3ccc19d45aff7068ca6 include/server/mir/server.h
9986098b500339bfccd07a9bed8298f75a68b18f5c include/server/mir/server_status_listener.h9986098b500339bfccd07a9bed8298f75a68b18f5c include/server/mir/server_status_listener.h
100860c04f32b60e680140148dc9dc2295de145b9c1 include/server/mir/shell/display_layout.h100860c04f32b60e680140148dc9dc2295de145b9c1 include/server/mir/shell/display_layout.h
1016a2107b01feae13060d5c305804906e53c52e0be include/server/mir/shell/focus_controller.h1016a2107b01feae13060d5c305804906e53c52e0be include/server/mir/shell/focus_controller.h
102102
=== modified file 'src/server/server.cpp'
--- src/server/server.cpp 2014-10-24 18:38:24 +0000
+++ src/server/server.cpp 2014-10-24 18:38:25 +0000
@@ -61,6 +61,7 @@
61 MACRO(the_session_authorizer)\61 MACRO(the_session_authorizer)\
62 MACRO(the_session_coordinator)\62 MACRO(the_session_coordinator)\
63 MACRO(the_session_listener)\63 MACRO(the_session_listener)\
64 MACRO(the_prompt_session_manager)\
64 MACRO(the_shell_display_layout)\65 MACRO(the_shell_display_layout)\
65 MACRO(the_surface_configurator)\66 MACRO(the_surface_configurator)\
66 MACRO(the_surface_coordinator)67 MACRO(the_surface_coordinator)
@@ -310,6 +311,14 @@
310 BOOST_THROW_EXCEPTION(std::logic_error("Cannot open connection when not running"));311 BOOST_THROW_EXCEPTION(std::logic_error("Cannot open connection when not running"));
311}312}
312313
314auto mir::Server::open_prompt_socket() -> int
315{
316 if (auto const config = self->server_config)
317 return config->the_prompt_connector()->client_socket_fd();
318
319 BOOST_THROW_EXCEPTION(std::logic_error("Cannot open connection when not running"));
320}
321
313auto mir::Server::open_client_socket(ConnectHandler const& connect_handler) -> int322auto mir::Server::open_client_socket(ConnectHandler const& connect_handler) -> int
314{323{
315 if (auto const config = self->server_config)324 if (auto const config = self->server_config)
316325
=== modified file 'src/server/symbols.map'
--- src/server/symbols.map 2014-10-24 18:38:24 +0000
+++ src/server/symbols.map 2014-10-24 18:38:25 +0000
@@ -394,6 +394,7 @@
394 mir::Server::exited_normally*;394 mir::Server::exited_normally*;
395 mir::Server::get_options*;395 mir::Server::get_options*;
396 mir::Server::open_client_socket*;396 mir::Server::open_client_socket*;
397 mir::Server::open_prompt_socket*;
397 mir::Server::override_the_compositor*;398 mir::Server::override_the_compositor*;
398 mir::Server::override_the_cursor_listener*;399 mir::Server::override_the_cursor_listener*;
399 mir::Server::override_the_gl_config*;400 mir::Server::override_the_gl_config*;
@@ -423,6 +424,7 @@
423 mir::Server::the_graphics_platform*;424 mir::Server::the_graphics_platform*;
424 mir::Server::the_main_loop*;425 mir::Server::the_main_loop*;
425 mir::Server::the_prompt_session_listener*;426 mir::Server::the_prompt_session_listener*;
427 mir::Server::the_prompt_session_manager*;
426 mir::Server::the_session_authorizer*;428 mir::Server::the_session_authorizer*;
427 mir::Server::the_session_coordinator*;429 mir::Server::the_session_coordinator*;
428 mir::Server::the_session_listener*;430 mir::Server::the_session_listener*;
429431
=== modified file 'tests/acceptance-tests/test_client_library.cpp'
--- tests/acceptance-tests/test_client_library.cpp 2014-10-24 18:38:24 +0000
+++ tests/acceptance-tests/test_client_library.cpp 2014-10-24 18:38:25 +0000
@@ -19,7 +19,7 @@
19#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
20#include "mir_toolkit/mir_client_library_debug.h"20#include "mir_toolkit/mir_client_library_debug.h"
2121
22#include "mir_test_framework/headless_test.h"22#include "mir_test_framework/headless_in_process_server.h"
23#include "mir_test_framework/using_stub_client_platform.h"23#include "mir_test_framework/using_stub_client_platform.h"
2424
25#include "src/client/client_buffer.h"25#include "src/client/client_buffer.h"
@@ -50,28 +50,9 @@
50namespace mc = mir::compositor;50namespace mc = mir::compositor;
51namespace mcl = mir::client;51namespace mcl = mir::client;
52namespace mtf = mir_test_framework;52namespace mtf = mir_test_framework;
53
54namespace53namespace
55{54{
56struct HeadlessInProcessServer : mir_test_framework::HeadlessTest55struct ClientLibrary : mtf::HeadlessInProcessServer
57{
58 HeadlessInProcessServer()
59 {
60 add_to_environment("MIR_SERVER_NO_FILE", "");
61 }
62
63 void SetUp() override
64 {
65 start_server();
66 }
67
68 void TearDown() override
69 {
70 stop_server();
71 }
72};
73
74struct ClientLibrary : HeadlessInProcessServer
75{56{
76 mtf::UsingStubClientPlatform using_stub_client_platform;57 mtf::UsingStubClientPlatform using_stub_client_platform;
7758
7859
=== modified file 'tests/acceptance-tests/test_prompt_session_client_api.cpp'
--- tests/acceptance-tests/test_prompt_session_client_api.cpp 2014-10-21 16:21:14 +0000
+++ tests/acceptance-tests/test_prompt_session_client_api.cpp 2014-10-24 18:38:25 +0000
@@ -21,13 +21,14 @@
21#include "mir/scene/prompt_session.h"21#include "mir/scene/prompt_session.h"
22#include "mir/scene/prompt_session_manager.h"22#include "mir/scene/prompt_session_manager.h"
23#include "mir/scene/session.h"23#include "mir/scene/session.h"
24#include "mir/shell/session_coordinator_wrapper.h"
24#include "mir/frontend/session_credentials.h"25#include "mir/frontend/session_credentials.h"
25#include "mir/frontend/shell.h"26#include "mir/frontend/shell.h"
27#include "mir/cached_ptr.h"
26#include "mir/fd.h"28#include "mir/fd.h"
2729
28#include "mir_test_doubles/stub_session_authorizer.h"30#include "mir_test_doubles/stub_session_authorizer.h"
29#include "mir_test_framework/stubbed_server_configuration.h"31#include "mir_test_framework/headless_in_process_server.h"
30#include "mir_test_framework/in_process_server.h"
31#include "mir_test_framework/using_stub_client_platform.h"32#include "mir_test_framework/using_stub_client_platform.h"
32#include "mir_test/popen.h"33#include "mir_test/popen.h"
3334
@@ -40,6 +41,7 @@
40namespace mtd = mir::test::doubles;41namespace mtd = mir::test::doubles;
41namespace mtf = mir_test_framework;42namespace mtf = mir_test_framework;
42namespace ms = mir::scene;43namespace ms = mir::scene;
44namespace msh = mir::shell;
43namespace mf = mir::frontend;45namespace mf = mir::frontend;
4446
45using namespace testing;47using namespace testing;
@@ -48,20 +50,8 @@
48{50{
49struct MockPromptSessionListener : ms::PromptSessionListener51struct MockPromptSessionListener : ms::PromptSessionListener
50{52{
51 MockPromptSessionListener(std::shared_ptr<ms::PromptSessionListener> const& wrapped) :53 MockPromptSessionListener()
52 wrapped(wrapped)
53 {54 {
54 ON_CALL(*this, starting(_)).WillByDefault(Invoke(
55 wrapped.get(), &ms::PromptSessionListener::starting));
56
57 ON_CALL(*this, stopping(_)).WillByDefault(Invoke(
58 wrapped.get(), &ms::PromptSessionListener::stopping));
59
60 ON_CALL(*this, prompt_provider_added(_, _)).WillByDefault(Invoke(
61 wrapped.get(), &ms::PromptSessionListener::prompt_provider_added));
62
63 ON_CALL(*this, prompt_provider_removed(_, _)).WillByDefault(Invoke(
64 wrapped.get(), &ms::PromptSessionListener::prompt_provider_removed));
65 }55 }
6656
67 MOCK_METHOD1(starting, void(std::shared_ptr<ms::PromptSession> const& prompt_session));57 MOCK_METHOD1(starting, void(std::shared_ptr<ms::PromptSession> const& prompt_session));
@@ -72,8 +62,6 @@
7262
73 MOCK_METHOD2(prompt_provider_removed,63 MOCK_METHOD2(prompt_provider_removed,
74 void(ms::PromptSession const& session, std::shared_ptr<ms::Session> const& provider));64 void(ms::PromptSession const& session, std::shared_ptr<ms::Session> const& provider));
75
76 std::shared_ptr<ms::PromptSessionListener> const wrapped;
77};65};
7866
79struct MockSessionAuthorizer : public mtd::StubSessionAuthorizer67struct MockSessionAuthorizer : public mtd::StubSessionAuthorizer
@@ -88,110 +76,136 @@
88 MOCK_METHOD1(prompt_session_is_allowed, bool(mf::SessionCredentials const&));76 MOCK_METHOD1(prompt_session_is_allowed, bool(mf::SessionCredentials const&));
89};77};
9078
91struct PromptSessionTestConfiguration : mtf::StubbedServerConfiguration79// We need to fake the client_pid for the as that is used to identify sessions
80class HookSessionCoordinator : public msh::SessionCoordinatorWrapper
92{81{
93 std::shared_ptr<ms::PromptSessionListener> the_prompt_session_listener() override82public:
94 {83 HookSessionCoordinator(
95 return prompt_session_listener([this]()84 std::shared_ptr<ms::SessionCoordinator> const& wrapped,
96 ->std::shared_ptr<ms::PromptSessionListener>85 std::vector<pid_t> const& pids) :
97 {86 msh::SessionCoordinatorWrapper(wrapped),
98 return the_mock_prompt_session_listener();87 pids(pids)
99 });88 {
100 }89 }
10190
102 std::shared_ptr<MockPromptSessionListener> the_mock_prompt_session_listener()91 auto open_session(
103 {92 pid_t client_pid,
104 return mock_prompt_session_listener([this]93 std::string const& name,
105 {94 std::shared_ptr<mf::EventSink> const& sink)
106 return std::make_shared<NiceMock<MockPromptSessionListener>>(95 -> std::shared_ptr<mf::Session> override
107 mtf::StubbedServerConfiguration::the_prompt_session_listener());96 {
108 });97 auto const override_pid = (next != pids.end()) ? *next++ : client_pid;
109 }98
11099 return wrapped->open_session(override_pid, name, sink);
111 std::shared_ptr<mf::SessionAuthorizer> the_session_authorizer() override100 }
112 {101
113 return session_authorizer([this]()102private:
114 ->std::shared_ptr<mf::SessionAuthorizer>103 std::vector<pid_t> const pids;
115 {104 std::vector<pid_t>::const_iterator next{pids.begin()};
116 return the_mock_session_authorizer();
117 });
118 }
119
120 std::shared_ptr<MockSessionAuthorizer> the_mock_session_authorizer()
121 {
122 return mock_prompt_session_authorizer([this]
123 {
124 return std::make_shared<NiceMock<MockSessionAuthorizer>>();
125 });
126 }
127
128 mir::CachedPtr<MockPromptSessionListener> mock_prompt_session_listener;
129 mir::CachedPtr<MockSessionAuthorizer> mock_prompt_session_authorizer;
130};105};
131106
132struct PromptSessionClientAPI : mtf::InProcessServer107struct PromptSessionClientAPI : mtf::HeadlessInProcessServer
133{108{
134 PromptSessionTestConfiguration server_configuration;
135
136 mir::DefaultServerConfiguration& server_config() override
137 { return server_configuration; }
138
139 MirConnection* connection = nullptr;109 MirConnection* connection = nullptr;
140110
141 static constexpr pid_t application_session_pid = __LINE__;111 static constexpr pid_t application_session_pid = __LINE__;
142 std::shared_ptr<mf::Session> application_session;112 std::shared_ptr<mf::Session> application_session;
113 MirConnection* application_connection{nullptr};
143114
144 std::shared_ptr<ms::PromptSession> server_prompt_session;115 std::shared_ptr<ms::PromptSession> server_prompt_session;
145 mtf::UsingStubClientPlatform using_stub_client_platform;116 mtf::UsingStubClientPlatform using_stub_client_platform;
146117
118 mir::CachedPtr<MockPromptSessionListener> mock_prompt_session_listener;
119 mir::CachedPtr<MockSessionAuthorizer> mock_prompt_session_authorizer;
120
121 std::shared_ptr<MockSessionAuthorizer> the_mock_session_authorizer()
122 {
123 return mock_prompt_session_authorizer([this]
124 {
125 return std::make_shared<NiceMock<MockSessionAuthorizer>>();
126 });
127 }
128
129 std::shared_ptr<MockPromptSessionListener> the_mock_prompt_session_listener()
130 {
131 return mock_prompt_session_listener([]
132 {
133 return std::make_shared<NiceMock<MockPromptSessionListener>>();
134 });
135 }
136
137 auto new_prompt_connection() -> std::string
138 {
139 auto const prompt_fd = server.open_prompt_socket();
140 return HeadlessInProcessServer::connection(prompt_fd);
141 }
142
143 void start_application_session()
144 {
145 std::mutex application_session_mutex;
146 std::condition_variable application_session_cv;
147
148 auto connect_handler = [&](std::shared_ptr<mf::Session> const& session)
149 {
150 std::lock_guard<std::mutex> lock(application_session_mutex);
151 application_session = session;
152 application_session_cv.notify_one();
153 };
154
155 auto const fd = server.open_client_socket(connect_handler);
156
157 application_connection = mir_connect_sync(HeadlessInProcessServer::connection(fd).c_str(), __PRETTY_FUNCTION__);
158
159 std::unique_lock<std::mutex> lock(application_session_mutex);
160 application_session_cv.wait(lock, [&] { return !!application_session; });
161 }
162
147 void SetUp() override163 void SetUp() override
148 {164 {
149 mtf::InProcessServer::SetUp();165 auto session_coordinator_wrapper = [&](std::shared_ptr<ms::SessionCoordinator> const& wrapped)
150166 -> std::shared_ptr<ms::SessionCoordinator>
151 std::shared_ptr<mf::EventSink> dummy_event_sink;167 {
152 auto const the_frontend_shell = server_config().the_frontend_shell();168 std::vector<pid_t> fake_pids;
153169 fake_pids.push_back(application_session_pid);
154 application_session = the_frontend_shell->open_session(170
155 application_session_pid, __PRETTY_FUNCTION__, dummy_event_sink);171 return std::make_shared<HookSessionCoordinator>(wrapped, fake_pids);
172 };
173
174 server.override_the_session_authorizer([this]()
175 ->std::shared_ptr<mf::SessionAuthorizer>
176 {
177 return the_mock_session_authorizer();
178 });
179
180 server.override_the_prompt_session_listener([this]
181 {
182 return the_mock_prompt_session_listener();
183 });
184
185 server.wrap_session_coordinator(session_coordinator_wrapper);
186
187 mtf::HeadlessInProcessServer::SetUp();
188
189 start_application_session();
156 }190 }
157191
158 void capture_server_prompt_session()192 void capture_server_prompt_session()
159 {193 {
160 EXPECT_CALL(*the_mock_prompt_session_listener(), starting(_)).194 EXPECT_CALL(*the_mock_prompt_session_listener(), starting(_)).
161 WillOnce(DoAll(195 WillOnce(SaveArg<0>(&server_prompt_session));
162 Invoke(
163 the_mock_prompt_session_listener()->wrapped.get(),
164 &ms::PromptSessionListener::starting),
165 SaveArg<0>(&server_prompt_session)));
166 }196 }
167197
168 void TearDown() override198 void TearDown() override
169 {199 {
170 // TODO It really shouldn't be necessary to close these sessions.200 application_session.reset();
171 // TODO But the MediatingDisplayChanger id destroyed without deregistering201 if (application_connection) mir_connection_release(application_connection);
172 // TODO callbacks from the BroadcastingSessionEventSink which gets called in
173 // TODO SessionManager::~SessionManager() in code that the comments claim
174 // TODO works around broken ownership.
175 auto const the_frontend_shell = server_config().the_frontend_shell();
176 the_frontend_shell->close_session(application_session);
177
178 if (connection) mir_connection_release(connection);202 if (connection) mir_connection_release(connection);
179 mtf::InProcessServer::TearDown();203 mtf::HeadlessInProcessServer::TearDown();
180 }
181
182 MockPromptSessionListener* the_mock_prompt_session_listener()
183 {
184 return server_configuration.the_mock_prompt_session_listener().get();
185 }
186
187 MockSessionAuthorizer& the_mock_session_authorizer()
188 {
189 return *server_configuration.the_mock_session_authorizer();
190 }204 }
191205
192 std::shared_ptr<ms::PromptSessionManager> the_prompt_session_manager()206 std::shared_ptr<ms::PromptSessionManager> the_prompt_session_manager()
193 {207 {
194 return server_config().the_prompt_session_manager();208 return server.the_prompt_session_manager();
195 }209 }
196210
197 MOCK_METHOD2(prompt_session_state_change,211 MOCK_METHOD2(prompt_session_state_change,
@@ -240,6 +254,8 @@
240 };254 };
241};255};
242256
257constexpr pid_t PromptSessionClientAPI::application_session_pid;
258
243mir_prompt_session_state_change_callback const null_state_change_callback{nullptr};259mir_prompt_session_state_change_callback const null_state_change_callback{nullptr};
244constexpr char const* const PromptSessionClientAPI::provider_name[];260constexpr char const* const PromptSessionClientAPI::provider_name[];
245261
@@ -417,7 +433,7 @@
417 the_prompt_session_manager()->stop_prompt_session(server_prompt_session);433 the_prompt_session_manager()->stop_prompt_session(server_prompt_session);
418434
419 // Verify we have got the "stopped" notification before we go on and release the session435 // Verify we have got the "stopped" notification before we go on and release the session
420 Mock::VerifyAndClearExpectations(the_mock_prompt_session_listener());436 Mock::VerifyAndClearExpectations(the_mock_prompt_session_listener().get());
421437
422 mir_prompt_session_release_sync(prompt_session);438 mir_prompt_session_release_sync(prompt_session);
423}439}
@@ -493,7 +509,7 @@
493509
494TEST_F(PromptSessionClientAPI, cannot_start_a_prompt_session_without_authorization)510TEST_F(PromptSessionClientAPI, cannot_start_a_prompt_session_without_authorization)
495{511{
496 EXPECT_CALL(the_mock_session_authorizer(), prompt_session_is_allowed(_))512 EXPECT_CALL(*the_mock_session_authorizer(), prompt_session_is_allowed(_))
497 .WillOnce(Return(false));513 .WillOnce(Return(false));
498514
499 connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);515 connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
@@ -513,9 +529,9 @@
513TEST_F(PromptSessionClientAPI,529TEST_F(PromptSessionClientAPI,
514 can_start_a_prompt_session_without_authorization_on_prompt_connection)530 can_start_a_prompt_session_without_authorization_on_prompt_connection)
515{531{
516 ON_CALL(the_mock_session_authorizer(), prompt_session_is_allowed(_))532 ON_CALL(*the_mock_session_authorizer(), prompt_session_is_allowed(_))
517 .WillByDefault(Return(false));533 .WillByDefault(Return(false));
518 EXPECT_CALL(the_mock_session_authorizer(), prompt_session_is_allowed(_)).Times(0);534 EXPECT_CALL(*the_mock_session_authorizer(), prompt_session_is_allowed(_)).Times(0);
519535
520 connection = mir_connect_sync(new_prompt_connection().c_str(), __PRETTY_FUNCTION__);536 connection = mir_connect_sync(new_prompt_connection().c_str(), __PRETTY_FUNCTION__);
521537
@@ -539,7 +555,7 @@
539{555{
540 connection = mir_connect_sync(new_prompt_connection().c_str(), __PRETTY_FUNCTION__);556 connection = mir_connect_sync(new_prompt_connection().c_str(), __PRETTY_FUNCTION__);
541557
542 EXPECT_CALL(the_mock_session_authorizer(), connection_is_allowed(_)).Times(0);558 EXPECT_CALL(*the_mock_session_authorizer(), connection_is_allowed(_)).Times(0);
543559
544 MirPromptSession* prompt_session = mir_connection_create_prompt_session_sync(560 MirPromptSession* prompt_session = mir_connection_create_prompt_session_sync(
545 connection, application_session_pid, null_state_change_callback, this);561 connection, application_session_pid, null_state_change_callback, this);
546562
=== added file 'tests/include/mir_test_framework/headless_in_process_server.h'
--- tests/include/mir_test_framework/headless_in_process_server.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir_test_framework/headless_in_process_server.h 2014-10-24 18:38:25 +0000
@@ -0,0 +1,36 @@
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#ifndef MIR_TEST_FRAMEWORK_HEADLESS_IN_PROCESS_SERVER_H_
20#define MIR_TEST_FRAMEWORK_HEADLESS_IN_PROCESS_SERVER_H_
21
22#include "mir_test_framework/headless_test.h"
23
24namespace mir_test_framework
25{
26struct HeadlessInProcessServer : HeadlessTest
27{
28 HeadlessInProcessServer();
29
30 void SetUp() override;
31
32 void TearDown() override;
33};
34}
35
36#endif /* MIR_TEST_FRAMEWORK_HEADLESS_IN_PROCESS_SERVER_H_ */
037
=== modified file 'tests/include/mir_test_framework/headless_test.h'
--- tests/include/mir_test_framework/headless_test.h 2014-10-24 18:38:24 +0000
+++ tests/include/mir_test_framework/headless_test.h 2014-10-24 18:38:25 +0000
@@ -54,6 +54,9 @@
54 /// \return a connection string for a new client to connect to the server54 /// \return a connection string for a new client to connect to the server
55 auto new_connection() -> std::string;55 auto new_connection() -> std::string;
5656
57 /// \return a connection string for a client to connect to the server
58 auto connection(int fd) -> std::string;
59
57 mir::Server server;60 mir::Server server;
5861
59private:62private:
6063
=== modified file 'tests/mir_test_framework/CMakeLists.txt'
--- tests/mir_test_framework/CMakeLists.txt 2014-10-24 18:38:24 +0000
+++ tests/mir_test_framework/CMakeLists.txt 2014-10-24 18:38:25 +0000
@@ -15,6 +15,7 @@
15 executable_path.cpp15 executable_path.cpp
16 command_line_server_configuration.cpp16 command_line_server_configuration.cpp
17 cross_process_sync.cpp17 cross_process_sync.cpp
18 headless_in_process_server.cpp
18 headless_test.cpp19 headless_test.cpp
19 server_runner.cpp20 server_runner.cpp
20 temporary_environment_value.cpp21 temporary_environment_value.cpp
2122
=== added file 'tests/mir_test_framework/headless_in_process_server.cpp'
--- tests/mir_test_framework/headless_in_process_server.cpp 1970-01-01 00:00:00 +0000
+++ tests/mir_test_framework/headless_in_process_server.cpp 2014-10-24 18:38:25 +0000
@@ -0,0 +1,36 @@
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 "mir_test_framework/headless_in_process_server.h"
20
21namespace mtf = mir_test_framework;
22
23mtf::HeadlessInProcessServer::HeadlessInProcessServer()
24{
25 add_to_environment("MIR_SERVER_NO_FILE", "");
26}
27
28void mtf::HeadlessInProcessServer::SetUp()
29{
30 start_server();
31}
32
33void mtf::HeadlessInProcessServer::TearDown()
34{
35 stop_server();
36}
037
=== modified file 'tests/mir_test_framework/headless_test.cpp'
--- tests/mir_test_framework/headless_test.cpp 2014-10-24 18:38:24 +0000
+++ tests/mir_test_framework/headless_test.cpp 2014-10-24 18:38:25 +0000
@@ -103,7 +103,12 @@
103103
104auto mtf::HeadlessTest::new_connection() -> std::string104auto mtf::HeadlessTest::new_connection() -> std::string
105{105{
106 return connection(server.open_client_socket());
107}
108
109auto mtf::HeadlessTest::connection(int fd) -> std::string
110{
106 char connect_string[64] = {0};111 char connect_string[64] = {0};
107 sprintf(connect_string, "fd://%d", server.open_client_socket());112 sprintf(connect_string, "fd://%d", fd);
108 return connect_string;113 return connect_string;
109}114}

Subscribers

People subscribed via source and target branches