35
struct MockApplicationMediatorReport : mf::SessionMediatorReport
35
struct MockSessionMediatorReport : mf::SessionMediatorReport
37
MockApplicationMediatorReport()
39
EXPECT_CALL(*this, session_connect_called(testing::_)).
40
Times(testing::AtLeast(0));
42
EXPECT_CALL(*this, session_create_surface_called(testing::_)).
43
Times(testing::AtLeast(0));
45
EXPECT_CALL(*this, session_next_buffer_called(testing::_)).
46
Times(testing::AtLeast(0));
48
EXPECT_CALL(*this, session_release_surface_called(testing::_)).
49
Times(testing::AtLeast(0));
51
EXPECT_CALL(*this, session_disconnect_called(testing::_)).
52
Times(testing::AtLeast(0));
54
EXPECT_CALL(*this, session_start_prompt_session_called(testing::_, testing::_)).
55
Times(testing::AtLeast(0));
57
EXPECT_CALL(*this, session_stop_prompt_session_called(testing::_)).
58
Times(testing::AtLeast(0));
61
37
MOCK_METHOD1(session_connect_called, void (std::string const&));
62
38
MOCK_METHOD1(session_create_surface_called, void (std::string const&));
63
39
MOCK_METHOD1(session_next_buffer_called, void (std::string const&));
40
MOCK_METHOD1(session_exchange_buffer_called, void (std::string const&));
64
41
MOCK_METHOD1(session_release_surface_called, void (std::string const&));
65
42
MOCK_METHOD1(session_disconnect_called, void (std::string const&));
66
43
MOCK_METHOD2(session_start_prompt_session_called, void (std::string const&, pid_t));
76
53
const int rpc_timeout_ms{100000};
78
typedef BespokeDisplayServerTestFixture ApplicationMediatorReport;
55
typedef BespokeDisplayServerTestFixture SessionMediatorReport;
81
TEST_F(ApplicationMediatorReport, session_connect_called)
58
TEST_F(SessionMediatorReport, session_connect_called)
83
60
struct Server : TestingServerConfiguration
85
std::shared_ptr<mf::SessionMediatorReport>
86
the_application_mediator_report()
62
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
88
auto result = std::make_shared<MockApplicationMediatorReport>();
90
EXPECT_CALL(*result, session_connect_called(testing::_)).
66
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
67
EXPECT_CALL(*report, session_connect_called(testing::_)).
72
std::shared_ptr<MockSessionMediatorReport> report;
95
73
} server_processing;
97
75
launch_server_process(server_processing);
111
89
&client.connect_parameters,
112
90
&client.connection,
113
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::connect_done));
91
google::protobuf::NewCallback(
92
static_cast<mt::TestProtobufClient*>(&client),
93
&mt::TestProtobufClient::connect_done));
115
95
client.wait_for_connect_done();
119
99
launch_client_process(client_process);
122
TEST_F(ApplicationMediatorReport, session_create_surface_called)
102
TEST_F(SessionMediatorReport, session_create_surface_called)
124
104
struct Server : TestingServerConfiguration
126
std::shared_ptr<mf::SessionMediatorReport>
127
the_application_mediator_report()
106
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
129
auto result = std::make_shared<MockApplicationMediatorReport>();
131
EXPECT_CALL(*result, session_create_surface_called(testing::_)).
110
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
111
EXPECT_CALL(*report, session_create_surface_called(testing::_)).
116
std::shared_ptr<MockSessionMediatorReport> report;
136
117
} server_processing;
138
118
launch_server_process(server_processing);
140
120
struct Client: TestingClientConfiguration
144
mt::TestProtobufClient client(mtf::test_socket_file(), rpc_timeout_ms);
124
testing::NiceMock<mt::TestProtobufClient> client(mtf::test_socket_file(), rpc_timeout_ms);
146
126
client.connect_parameters.set_application_name(__PRETTY_FUNCTION__);
147
127
EXPECT_CALL(client, connect_done()).
154
134
&client.connect_parameters,
155
135
&client.connection,
156
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::connect_done));
136
google::protobuf::NewCallback(
137
static_cast<mt::TestProtobufClient*>(&client),
138
&mt::TestProtobufClient::connect_done));
158
140
client.wait_for_connect_done();
162
144
&client.surface_parameters,
164
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::create_surface_done));
146
google::protobuf::NewCallback(
147
static_cast<mt::TestProtobufClient*>(&client),
148
&mt::TestProtobufClient::create_surface_done));
165
149
client.wait_for_create_surface();
170
154
launch_client_process(client_process);
173
TEST_F(ApplicationMediatorReport, session_next_buffer_called)
157
TEST_F(SessionMediatorReport, session_next_buffer_called)
175
159
struct Server : TestingServerConfiguration
177
std::shared_ptr<mf::SessionMediatorReport>
178
the_application_mediator_report()
161
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
180
auto result = std::make_shared<MockApplicationMediatorReport>();
182
EXPECT_CALL(*result, session_next_buffer_called(testing::_)).
165
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
166
EXPECT_CALL(*report, session_next_buffer_called(testing::_)).
171
std::shared_ptr<MockSessionMediatorReport> report;
187
172
} server_processing;
189
173
launch_server_process(server_processing);
191
175
struct Client: TestingClientConfiguration
227
211
launch_client_process(client_process);
230
TEST_F(ApplicationMediatorReport, session_release_surface_called)
214
TEST_F(SessionMediatorReport, session_exchange_buffer_called)
232
216
struct Server : TestingServerConfiguration
234
std::shared_ptr<mf::SessionMediatorReport>
235
the_application_mediator_report()
218
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
237
auto result = std::make_shared<MockApplicationMediatorReport>();
239
EXPECT_CALL(*result, session_release_surface_called(testing::_)).
222
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
223
EXPECT_CALL(*report, session_exchange_buffer_called(testing::_)).
228
std::shared_ptr<MockSessionMediatorReport> report;
244
229
} server_processing;
246
230
launch_server_process(server_processing);
248
232
struct Client: TestingClientConfiguration
254
238
client.connect_parameters.set_application_name(__PRETTY_FUNCTION__);
255
239
EXPECT_CALL(client, connect_done()).Times(testing::AtLeast(0));
256
240
EXPECT_CALL(client, create_surface_done()).Times(testing::AtLeast(0));
257
EXPECT_CALL(client, next_buffer_done()).Times(testing::AtLeast(0));
258
EXPECT_CALL(client, release_surface_done()).Times(testing::AtLeast(0));
241
EXPECT_CALL(client, exchange_buffer_done()).Times(testing::AtLeast(0));
260
243
client.display_server.connect(
272
255
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::create_surface_done));
273
256
client.wait_for_create_surface();
258
mir::protobuf::BufferRequest request;
259
*request.mutable_id() = client.surface.id();
260
*request.mutable_buffer() = client.surface.buffer();
262
client.display_server.exchange_buffer(
265
client.surface.mutable_buffer(),
266
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::exchange_buffer_done));
268
client.wait_for_exchange_buffer();
272
launch_client_process(client_process);
275
TEST_F(SessionMediatorReport, session_release_surface_called)
277
struct Server : TestingServerConfiguration
279
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
283
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
284
EXPECT_CALL(*report, session_release_surface_called(testing::_)).
289
std::shared_ptr<MockSessionMediatorReport> report;
291
launch_server_process(server_processing);
293
struct Client: TestingClientConfiguration
297
testing::NiceMock<mt::TestProtobufClient> client(mtf::test_socket_file(), rpc_timeout_ms);
299
client.connect_parameters.set_application_name(__PRETTY_FUNCTION__);
301
client.display_server.connect(
303
&client.connect_parameters,
305
google::protobuf::NewCallback(
306
static_cast<mt::TestProtobufClient*>(&client),
307
&mt::TestProtobufClient::connect_done));
309
client.wait_for_connect_done();
311
client.display_server.create_surface(
313
&client.surface_parameters,
315
google::protobuf::NewCallback(
316
static_cast<mt::TestProtobufClient*>(&client),
317
&mt::TestProtobufClient::create_surface_done));
318
client.wait_for_create_surface();
275
320
client.display_server.next_buffer(
277
322
&client.surface.id(),
278
323
client.surface.mutable_buffer(),
279
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::next_buffer_done));
324
google::protobuf::NewCallback(
325
static_cast<mt::TestProtobufClient*>(&client),
326
&mt::TestProtobufClient::next_buffer_done));
281
328
client.wait_for_next_buffer();
285
332
&client.surface.id(),
287
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::release_surface_done));
334
google::protobuf::NewCallback(
335
static_cast<mt::TestProtobufClient*>(&client),
336
&mt::TestProtobufClient::release_surface_done));
289
338
client.wait_for_release_surface();
293
342
launch_client_process(client_process);
296
TEST_F(ApplicationMediatorReport, session_disconnect_called)
345
TEST_F(SessionMediatorReport, session_disconnect_called)
298
347
struct Server : TestingServerConfiguration
300
std::shared_ptr<mf::SessionMediatorReport>
301
the_application_mediator_report()
349
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
303
auto result = std::make_shared<MockApplicationMediatorReport>();
305
EXPECT_CALL(*result, session_disconnect_called(testing::_)).
353
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
354
EXPECT_CALL(*report, session_disconnect_called(testing::_)).
359
std::shared_ptr<MockSessionMediatorReport> report;
310
360
} server_processing;
312
361
launch_server_process(server_processing);
314
363
struct Client: TestingClientConfiguration
318
mt::TestProtobufClient client(mtf::test_socket_file(), rpc_timeout_ms);
367
testing::NiceMock<mt::TestProtobufClient> client(mtf::test_socket_file(), rpc_timeout_ms);
320
369
client.connect_parameters.set_application_name(__PRETTY_FUNCTION__);
321
EXPECT_CALL(client, connect_done()).Times(testing::AtLeast(0));
322
EXPECT_CALL(client, create_surface_done()).Times(testing::AtLeast(0));
323
EXPECT_CALL(client, next_buffer_done()).Times(testing::AtLeast(0));
324
EXPECT_CALL(client, release_surface_done()).Times(testing::AtLeast(0));
325
EXPECT_CALL(client, disconnect_done()).Times(testing::AtLeast(0));
327
371
client.display_server.connect(
329
373
&client.connect_parameters,
330
374
&client.connection,
331
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::connect_done));
375
google::protobuf::NewCallback(
376
static_cast<mt::TestProtobufClient*>(&client),
377
&mt::TestProtobufClient::connect_done));
333
379
client.wait_for_connect_done();
337
383
&client.surface_parameters,
339
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::create_surface_done));
385
google::protobuf::NewCallback(
386
static_cast<mt::TestProtobufClient*>(&client),
387
&mt::TestProtobufClient::create_surface_done));
340
388
client.wait_for_create_surface();
342
390
client.display_server.next_buffer(
344
392
&client.surface.id(),
345
393
client.surface.mutable_buffer(),
346
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::next_buffer_done));
394
google::protobuf::NewCallback(
395
static_cast<mt::TestProtobufClient*>(&client),
396
&mt::TestProtobufClient::next_buffer_done));
348
398
client.wait_for_next_buffer();
352
402
&client.surface.id(),
354
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::release_surface_done));
404
google::protobuf::NewCallback(
405
static_cast<mt::TestProtobufClient*>(&client),
406
&mt::TestProtobufClient::release_surface_done));
356
408
client.wait_for_release_surface();
362
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::disconnect_done));
414
google::protobuf::NewCallback(
415
static_cast<mt::TestProtobufClient*>(&client),
416
&mt::TestProtobufClient::disconnect_done));
364
418
client.wait_for_disconnect_done();
368
422
launch_client_process(client_process);
371
TEST_F(ApplicationMediatorReport, prompt_session_start_called)
425
TEST_F(SessionMediatorReport, prompt_session_start_called)
373
427
struct Server : TestingServerConfiguration
375
std::shared_ptr<mf::SessionMediatorReport>
376
the_application_mediator_report()
429
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
378
auto result = std::make_shared<MockApplicationMediatorReport>();
380
EXPECT_CALL(*result, session_start_prompt_session_called(testing::_, testing::_)).
433
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
434
EXPECT_CALL(*report, session_start_prompt_session_called(testing::_, testing::_)).
439
std::shared_ptr<MockSessionMediatorReport> report;
385
440
} server_processing;
387
441
launch_server_process(server_processing);
389
443
struct Client: TestingClientConfiguration
393
mt::TestProtobufClient client(mtf::test_socket_file(), rpc_timeout_ms);
447
testing::NiceMock<mt::TestProtobufClient> client(mtf::test_socket_file(), rpc_timeout_ms);
395
449
client.connect_parameters.set_application_name(__PRETTY_FUNCTION__);
396
EXPECT_CALL(client, connect_done()).
397
Times(testing::AtLeast(0));
398
EXPECT_CALL(client, prompt_session_start_done()).
399
Times(testing::AtLeast(0));
401
451
client.display_server.connect(
403
453
&client.connect_parameters,
404
454
&client.connection,
405
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::connect_done));
455
google::protobuf::NewCallback(
456
static_cast<mt::TestProtobufClient*>(&client),
457
&mt::TestProtobufClient::connect_done));
407
459
client.wait_for_connect_done();
411
463
&client.prompt_session_parameters,
412
464
&client.prompt_session,
413
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::prompt_session_start_done));
465
google::protobuf::NewCallback(
466
static_cast<mt::TestProtobufClient*>(&client),
467
&mt::TestProtobufClient::prompt_session_start_done));
414
469
client.wait_for_prompt_session_start_done();
419
474
launch_client_process(client_process);
422
TEST_F(ApplicationMediatorReport, prompt_session_stop_called)
477
TEST_F(SessionMediatorReport, prompt_session_stop_called)
424
479
struct Server : TestingServerConfiguration
426
std::shared_ptr<mf::SessionMediatorReport>
427
the_application_mediator_report()
481
std::shared_ptr<mf::SessionMediatorReport> the_session_mediator_report() override
429
auto result = std::make_shared<MockApplicationMediatorReport>();
431
EXPECT_CALL(*result, session_stop_prompt_session_called(testing::_)).
485
report = std::make_shared<testing::NiceMock<MockSessionMediatorReport>>();
486
EXPECT_CALL(*report, session_stop_prompt_session_called(testing::_)).
491
std::shared_ptr<MockSessionMediatorReport> report;
436
492
} server_processing;
438
493
launch_server_process(server_processing);
440
495
struct Client: TestingClientConfiguration
444
mt::TestProtobufClient client(mtf::test_socket_file(), rpc_timeout_ms);
499
testing::NiceMock<mt::TestProtobufClient> client(mtf::test_socket_file(), rpc_timeout_ms);
446
501
client.connect_parameters.set_application_name(__PRETTY_FUNCTION__);
447
EXPECT_CALL(client, connect_done()).
448
Times(testing::AtLeast(0));
449
EXPECT_CALL(client, prompt_session_start_done()).
450
Times(testing::AtLeast(0));
451
EXPECT_CALL(client, prompt_session_stop_done()).
452
Times(testing::AtLeast(0));
454
503
client.display_server.connect(
456
505
&client.connect_parameters,
457
506
&client.connection,
458
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::connect_done));
507
google::protobuf::NewCallback(
508
static_cast<mt::TestProtobufClient*>(&client),
509
&mt::TestProtobufClient::connect_done));
460
511
client.wait_for_connect_done();
464
515
&client.prompt_session_parameters,
465
516
&client.prompt_session,
466
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::prompt_session_start_done));
517
google::protobuf::NewCallback(
518
static_cast<mt::TestProtobufClient*>(&client),
519
&mt::TestProtobufClient::prompt_session_start_done));
467
521
client.wait_for_prompt_session_start_done();
469
523
client.display_server.stop_prompt_session(
473
google::protobuf::NewCallback(&client, &mt::TestProtobufClient::prompt_session_stop_done));
527
google::protobuf::NewCallback(
528
static_cast<mt::TestProtobufClient*>(&client),
529
&mt::TestProtobufClient::prompt_session_stop_done));
474
531
client.wait_for_prompt_session_stop_done();
476
533
} client_process;
478
535
launch_client_process(client_process);