~ubuntu-branches/ubuntu/trusty/mir/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/unit-tests/scene/test_application_session.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Kevin Gunn
  • Date: 2014-02-12 18:29:29 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20140212182929-ru6hzd1hqdf98tub
Tags: 0.1.5+14.04.20140212-0ubuntu1
[ Kevin Gunn ]
* Cherry-picked from future release 0.1.6:
  - frontend, shell: provide the client process ID in the shell::Session
    interface (LP: #1276704)
* New upstream release 0.1.5 (https://launchpad.net/mir/+milestone/0.1.5)
  - mirclient ABI bumped to 7
  - mirserver ABI bumped to 15
  - Refactoring to support client-controled RPC.
  - Add an translucent server example (use sparingly, this will kill
    performance!)
  - Add workaround for Qualcomm Snapdragon 8960 driver bug.
  - android-input: Improve debug output
  - Screen rotation support half done (rotation of the screen works but input
    rotation not implemented yet).
  - Add groundwork for overlay support to take better advantage of mobile
    hardware features and optimize composition in future.
  - Add support for HWC 1.2 (Android 4.4)
  - Add groundwork for screencasting (screen recording).
  - Optimized surface resizing, significantly reducing event flooding for
    some input configurations like touch.
  - Bugs fixed:
    . Surfaces no longer visible at all on Nexus 10 (LP: #1271853)
    . mir nested server failure: what(): error binding buffer to texture
      (LP: #1272041)
    . Unity does not process events from evdev device created before unity is
      restarted (autopilot tests) (LP: #1238417)
    . mir_unit_tests can't run on touch images any more (missing
      libumockdev.so.0) (LP: #1271434)
    . chmod 777 /tmp/mir_socket is no longer sufficient for non-root clients
      to connect to a root server (LP: #1272143)
    . Nexus7(2013) flo framerate maxes out at 30fps (LP: #1274189)
    . libmirserver user is unable to #include
       <mir/frontend/template_protobuf_message_processor.h> (LP: #1276162)
    . libmirclient user cannot "#include <mir/client/private.h>"
      (LP: #1276565)
    . AndroidInternalClient.internal_client_creation_and_use hangs on Nexus
      10 (LP: #1270685)
    . Tests that use the InProcessServer bind the default socket file
      (LP: #1271604)
    . BasicConnector threads exit immediately (LP: #1271655)
    . Integration tests TestClientIPCRender.test_accelerated_render fails on
      Galaxy Nexus and Nexus4 (LP: #1272597)
    . Android backend unit-tests FTBS on amd64 (LP: #1276621)
    . Erroneous use of last_consumed in SwitchingBundle::compositor_acquire
      (LP: #1270964)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2012 Canonical Ltd.
 
2
 * Copyright © 2012-2014 Canonical Ltd.
3
3
 *
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(_, _))
70
70
        .Times(1);
71
71
 
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),
 
74
        __LINE__,
 
75
        "Foo",
 
76
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
77
        mt::fake_shared(listener),
 
78
        mt::fake_shared(sender));
76
79
 
77
80
    msh::SurfaceCreationParameters params;
78
81
    auto surf = session.create_surface(params);
97
100
    EXPECT_CALL(listener, destroying_surface(_, _)).Times(1);
98
101
 
99
102
    {
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),
 
105
            __LINE__,
 
106
            "Foo",
 
107
            std::make_shared<mtd::NullSnapshotStrategy>(),
 
108
            mt::fake_shared(listener),
 
109
            mt::fake_shared(sender));
103
110
 
104
111
        msh::SurfaceCreationParameters params;
105
112
        session.create_surface(params);
123
130
            .WillOnce(Return(make_mock_surface()));
124
131
    }
125
132
 
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),
 
135
        __LINE__,
 
136
        "Foo",
 
137
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
138
        std::make_shared<msh::NullSessionListener>(),
 
139
        mt::fake_shared(sender));
129
140
 
130
141
 
131
142
    msh::SurfaceCreationParameters params;
156
167
    mtd::MockSurfaceFactory surface_factory;
157
168
    ON_CALL(surface_factory, create_surface(_, _, _, _)).WillByDefault(Return(mock_surface));
158
169
 
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),
 
172
        __LINE__,
 
173
        "Foo",
 
174
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
175
        std::make_shared<msh::NullSessionListener>(),
 
176
        mt::fake_shared(sender));
162
177
 
163
178
    EXPECT_CALL(surface_factory, create_surface(_, _, _, _));
164
179
 
177
192
    app_session.destroy_surface(surf);
178
193
}
179
194
 
180
 
TEST(Session, get_invalid_surface_throw_behavior)
 
195
TEST(ApplicationSession, get_invalid_surface_throw_behavior)
181
196
{
182
197
    using namespace ::testing;
183
198
 
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),
 
203
        __LINE__,
 
204
        "Foo",
 
205
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
206
        std::make_shared<msh::NullSessionListener>(),
 
207
        mt::fake_shared(sender));
 
208
 
189
209
    mf::SurfaceId invalid_surface_id(1);
190
210
 
191
211
    EXPECT_THROW({
193
213
    }, std::runtime_error);
194
214
}
195
215
 
196
 
TEST(Session, destroy_invalid_surface_throw_behavior)
 
216
TEST(ApplicationSession, destroy_invalid_surface_throw_behavior)
197
217
{
198
218
    using namespace ::testing;
199
219
 
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),
 
224
        __LINE__,
 
225
        "Foo",
 
226
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
227
        std::make_shared<msh::NullSessionListener>(),
 
228
        mt::fake_shared(sender));
 
229
 
205
230
    mf::SurfaceId invalid_surface_id(1);
206
231
 
207
232
    EXPECT_THROW({
209
234
    }, std::runtime_error);
210
235
}
211
236
 
212
 
TEST(Session, uses_snapshot_strategy)
 
237
TEST(ApplicationSession, uses_snapshot_strategy)
213
238
{
214
239
    using namespace ::testing;
215
240
 
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",
230
 
                                        snapshot_strategy,
231
 
                                        std::make_shared<msh::NullSessionListener>(), mt::fake_shared(sender));
 
254
    ms::ApplicationSession app_session(
 
255
        mt::fake_shared(surface_factory),
 
256
        __LINE__,
 
257
        "Foo",
 
258
        snapshot_strategy,
 
259
        std::make_shared<msh::NullSessionListener>(),
 
260
        mt::fake_shared(sender));
232
261
 
233
262
    EXPECT_CALL(*snapshot_strategy, take_snapshot_of(_,_));
234
263
 
245
274
    MOCK_METHOD1(handle_display_config_change, void(mir::graphics::DisplayConfiguration const&));
246
275
};
247
276
}
248
 
TEST(Session, display_config_sender)
 
277
TEST(ApplicationSession, display_config_sender)
249
278
{
250
279
    using namespace ::testing;
251
280
 
256
285
    EXPECT_CALL(sender, handle_display_config_change(testing::Ref(stub_config)))
257
286
        .Times(1);
258
287
 
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),
 
290
        __LINE__,
 
291
        "Foo",
 
292
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
293
        std::make_shared<msh::NullSessionListener>(),
 
294
        mt::fake_shared(sender));
262
295
 
263
296
    app_session.send_display_config(stub_config);
264
297
}
265
298
 
266
 
TEST(Session, lifecycle_event_sender)
 
299
TEST(ApplicationSession, lifecycle_event_sender)
267
300
{
268
301
    using namespace ::testing;
269
302
 
271
304
    mtd::MockSurfaceFactory surface_factory;
272
305
    MockEventSink sender;
273
306
 
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),
 
309
        __LINE__,
 
310
        "Foo",
 
311
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
312
        std::make_shared<msh::NullSessionListener>(),
 
313
        mt::fake_shared(sender));
277
314
 
278
315
    EXPECT_CALL(sender, handle_lifecycle_event(exp_state)).Times(1);
279
316
 
280
317
    app_session.set_lifecycle_state(mir_lifecycle_state_will_suspend);
281
318
}
 
319
 
 
320
TEST(ApplicationSession, process_id)
 
321
{
 
322
    using namespace ::testing;
 
323
 
 
324
    pid_t const pid{__LINE__};
 
325
 
 
326
    mtd::MockSurfaceFactory surface_factory;
 
327
    MockEventSink sender;
 
328
 
 
329
    ms::ApplicationSession app_session(
 
330
        mt::fake_shared(surface_factory),
 
331
        pid,
 
332
        "Foo",
 
333
        std::make_shared<mtd::NullSnapshotStrategy>(),
 
334
        std::make_shared<msh::NullSessionListener>(),
 
335
        mt::fake_shared(sender));
 
336
 
 
337
    EXPECT_THAT(app_session.process_id(), Eq(pid));
 
338
}