2
* Copyright © 2012 Canonical Ltd.
2
* Copyright © 2012-2014 Canonical Ltd.
4
4
* This program is free software: you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License version 3 as
69
69
EXPECT_CALL(listener, destroying_surface(_, _))
72
ms::ApplicationSession session(mt::fake_shared(surface_factory), "Foo",
73
std::make_shared<mtd::NullSnapshotStrategy>(),
74
mt::fake_shared(listener),
75
mt::fake_shared(sender));
72
ms::ApplicationSession session(
73
mt::fake_shared(surface_factory),
76
std::make_shared<mtd::NullSnapshotStrategy>(),
77
mt::fake_shared(listener),
78
mt::fake_shared(sender));
77
80
msh::SurfaceCreationParameters params;
78
81
auto surf = session.create_surface(params);
97
100
EXPECT_CALL(listener, destroying_surface(_, _)).Times(1);
100
ms::ApplicationSession session(mt::fake_shared(surface_factory), "Foo",
101
std::make_shared<mtd::NullSnapshotStrategy>(), mt::fake_shared(listener),
102
mt::fake_shared(sender));
103
ms::ApplicationSession session(
104
mt::fake_shared(surface_factory),
107
std::make_shared<mtd::NullSnapshotStrategy>(),
108
mt::fake_shared(listener),
109
mt::fake_shared(sender));
104
111
msh::SurfaceCreationParameters params;
105
112
session.create_surface(params);
123
130
.WillOnce(Return(make_mock_surface()));
126
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
127
std::make_shared<mtd::NullSnapshotStrategy>(),
128
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
133
ms::ApplicationSession app_session(
134
mt::fake_shared(surface_factory),
137
std::make_shared<mtd::NullSnapshotStrategy>(),
138
std::make_shared<msh::NullSessionListener>(),
139
mt::fake_shared(sender));
131
142
msh::SurfaceCreationParameters params;
156
167
mtd::MockSurfaceFactory surface_factory;
157
168
ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault(Return(mock_surface));
159
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
160
std::make_shared<mtd::NullSnapshotStrategy>(),
161
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
170
ms::ApplicationSession app_session(
171
mt::fake_shared(surface_factory),
174
std::make_shared<mtd::NullSnapshotStrategy>(),
175
std::make_shared<msh::NullSessionListener>(),
176
mt::fake_shared(sender));
163
178
EXPECT_CALL(surface_factory, create_surface(_, _, _, _));
177
192
app_session.destroy_surface(surf);
180
TEST(Session, get_invalid_surface_throw_behavior)
195
TEST(ApplicationSession, get_invalid_surface_throw_behavior)
182
197
using namespace ::testing;
184
199
mtd::NullEventSink sender;
185
200
mtd::MockSurfaceFactory surface_factory;
186
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
187
std::make_shared<mtd::NullSnapshotStrategy>(),
188
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
201
ms::ApplicationSession app_session(
202
mt::fake_shared(surface_factory),
205
std::make_shared<mtd::NullSnapshotStrategy>(),
206
std::make_shared<msh::NullSessionListener>(),
207
mt::fake_shared(sender));
189
209
mf::SurfaceId invalid_surface_id(1);
193
213
}, std::runtime_error);
196
TEST(Session, destroy_invalid_surface_throw_behavior)
216
TEST(ApplicationSession, destroy_invalid_surface_throw_behavior)
198
218
using namespace ::testing;
200
220
mtd::NullEventSink sender;
201
221
mtd::MockSurfaceFactory surface_factory;
202
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
203
std::make_shared<mtd::NullSnapshotStrategy>(),
204
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
222
ms::ApplicationSession app_session(
223
mt::fake_shared(surface_factory),
226
std::make_shared<mtd::NullSnapshotStrategy>(),
227
std::make_shared<msh::NullSessionListener>(),
228
mt::fake_shared(sender));
205
230
mf::SurfaceId invalid_surface_id(1);
226
251
auto snapshot_strategy = std::make_shared<MockSnapshotStrategy>();
227
252
mtd::NullEventSink sender;
228
253
mtd::MockSurfaceFactory surface_factory;
229
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
231
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
254
ms::ApplicationSession app_session(
255
mt::fake_shared(surface_factory),
259
std::make_shared<msh::NullSessionListener>(),
260
mt::fake_shared(sender));
233
262
EXPECT_CALL(*snapshot_strategy, take_snapshot_of(_,_));
245
274
MOCK_METHOD1(handle_display_config_change, void(mir::graphics::DisplayConfiguration const&));
248
TEST(Session, display_config_sender)
277
TEST(ApplicationSession, display_config_sender)
250
279
using namespace ::testing;
256
285
EXPECT_CALL(sender, handle_display_config_change(testing::Ref(stub_config)))
259
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
260
std::make_shared<mtd::NullSnapshotStrategy>(),
261
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
288
ms::ApplicationSession app_session(
289
mt::fake_shared(surface_factory),
292
std::make_shared<mtd::NullSnapshotStrategy>(),
293
std::make_shared<msh::NullSessionListener>(),
294
mt::fake_shared(sender));
263
296
app_session.send_display_config(stub_config);
266
TEST(Session, lifecycle_event_sender)
299
TEST(ApplicationSession, lifecycle_event_sender)
268
301
using namespace ::testing;
271
304
mtd::MockSurfaceFactory surface_factory;
272
305
MockEventSink sender;
274
ms::ApplicationSession app_session(mt::fake_shared(surface_factory), "Foo",
275
std::make_shared<mtd::NullSnapshotStrategy>(),
276
std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
307
ms::ApplicationSession app_session(
308
mt::fake_shared(surface_factory),
311
std::make_shared<mtd::NullSnapshotStrategy>(),
312
std::make_shared<msh::NullSessionListener>(),
313
mt::fake_shared(sender));
278
315
EXPECT_CALL(sender, handle_lifecycle_event(exp_state)).Times(1);
280
317
app_session.set_lifecycle_state(mir_lifecycle_state_will_suspend);
320
TEST(ApplicationSession, process_id)
322
using namespace ::testing;
324
pid_t const pid{__LINE__};
326
mtd::MockSurfaceFactory surface_factory;
327
MockEventSink sender;
329
ms::ApplicationSession app_session(
330
mt::fake_shared(surface_factory),
333
std::make_shared<mtd::NullSnapshotStrategy>(),
334
std::make_shared<msh::NullSessionListener>(),
335
mt::fake_shared(sender));
337
EXPECT_THAT(app_session.process_id(), Eq(pid));