~brandontschaefer/mir/deprecate-set-event-handler

« back to all changes in this revision

Viewing changes to tests/acceptance-tests/throwback/test_client_library_errors.cpp

* Merge parent, fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
            dummy_client_module.load_function<mcl::CreateClientPlatform>("create_client_platform")(context, nullptr);
79
79
    }
80
80
 
81
 
    void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*surface*/) override
 
81
    void use_egl_native_window(std::shared_ptr<void> /*native_window*/, mir::client::EGLNativeSurface* /*window*/) override
82
82
    {
83
83
    }
84
84
 
85
 
    std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *surface) override
 
85
    std::shared_ptr<void> create_egl_native_window(mir::client::EGLNativeSurface *window) override
86
86
    {
87
87
        if (should_fail<Method::create_egl_native_window, failure_set>())
88
88
        {
89
89
            BOOST_THROW_EXCEPTION(std::runtime_error{exception_text});
90
90
        }
91
 
        return stub_platform->create_egl_native_window(surface);
 
91
        return stub_platform->create_egl_native_window(window);
92
92
    }
93
93
 
94
94
    void populate(MirPlatformPackage& package) const override
216
216
 
217
217
    ASSERT_THAT(connection, IsValid());
218
218
 
219
 
    auto spec = mir_connection_create_spec_for_normal_surface(
220
 
        connection,
221
 
        800, 600,
222
 
        mir_pixel_format_xbgr_8888);
223
 
    auto surface = mir_surface_create_sync(spec);
224
 
    mir_surface_spec_release(spec);
225
 
 
226
 
    ASSERT_NE(surface, nullptr);
227
 
    EXPECT_FALSE(mir_surface_is_valid(surface));
228
 
    EXPECT_THAT(mir_surface_get_error_message(surface), testing::HasSubstr(exception_text));
229
 
 
230
 
    mir_surface_release_sync(surface);
 
219
    auto spec = mir_create_normal_window_spec(connection, 800, 600);
 
220
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_xbgr_8888);
 
221
    auto window = mir_window_create_sync(spec);
 
222
    mir_window_spec_release(spec);
 
223
 
 
224
    ASSERT_NE(window, nullptr);
 
225
    EXPECT_FALSE(mir_window_is_valid(window));
 
226
    EXPECT_THAT(mir_window_get_error_message(window), testing::HasSubstr(exception_text));
 
227
 
 
228
    mir_window_release_sync(window);
231
229
    mir_connection_release(connection);
232
230
}
233
231
 
259
257
 
260
258
    ASSERT_THAT(connection, IsValid());
261
259
 
262
 
    auto spec = mir_connection_create_spec_for_normal_surface(
263
 
        connection,
264
 
        800, 600,
265
 
        mir_pixel_format_xbgr_8888);
266
 
    auto surface = mir_surface_create_sync(spec);
267
 
    mir_surface_spec_release(spec);
 
260
    auto spec = mir_create_normal_window_spec(connection, 800, 600);
 
261
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_xbgr_8888);
 
262
    auto window = mir_window_create_sync(spec);
 
263
    mir_window_spec_release(spec);
268
264
 
269
 
    mir_surface_release_sync(surface);
 
265
    mir_window_release_sync(window);
270
266
    mir_connection_release(connection);
271
267
}
272
268
 
287
283
 
288
284
    ASSERT_THAT(connection, IsValid());
289
285
 
290
 
    auto spec = mir_connection_create_spec_for_normal_surface(
291
 
        connection,
292
 
        800, 600,
293
 
        mir_pixel_format_xbgr_8888);
294
 
    auto surface = mir_surface_create_sync(spec);
295
 
    mir_surface_spec_release(spec);
 
286
    auto spec = mir_create_normal_window_spec(connection, 800, 600);
 
287
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_xbgr_8888);
 
288
    auto window = mir_window_create_sync(spec);
 
289
    mir_window_spec_release(spec);
296
290
 
297
 
    ASSERT_NE(surface, nullptr);
298
 
    EXPECT_FALSE(mir_surface_is_valid(surface));
299
 
    EXPECT_THAT(mir_surface_get_error_message(surface), testing::HasSubstr(exception_text));
 
291
    ASSERT_NE(window, nullptr);
 
292
    EXPECT_FALSE(mir_window_is_valid(window));
 
293
    EXPECT_THAT(mir_window_get_error_message(window), testing::HasSubstr(exception_text));
300
294
 
301
295
    bool callback_called{false};
302
 
    mir_surface_release(surface, &recording_surface_callback, &callback_called);
 
296
    mir_window_release(window, &recording_surface_callback, &callback_called);
303
297
    EXPECT_TRUE(callback_called);
304
298
    mir_connection_release(connection);
305
299
}
313
307
 
314
308
    ASSERT_THAT(connection, IsValid());
315
309
 
316
 
    auto spec = mir_connection_create_spec_for_normal_surface(
317
 
        connection,
318
 
        800, 600,
319
 
        mir_pixel_format_xbgr_8888);
320
 
    auto surface = mir_surface_create_sync(spec);
321
 
    mir_surface_spec_release(spec);
322
 
 
323
 
    ASSERT_NE(surface, nullptr);
324
 
    EXPECT_FALSE(mir_surface_is_valid(surface));
325
 
    EXPECT_THAT(mir_surface_get_error_message(surface), testing::HasSubstr(exception_text));
326
 
 
327
 
    mir_surface_release_sync(surface);
 
310
    auto spec = mir_create_normal_window_spec(connection, 800, 600);
 
311
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_xbgr_8888);
 
312
    auto window = mir_window_create_sync(spec);
 
313
    mir_window_spec_release(spec);
 
314
 
 
315
    ASSERT_NE(window, nullptr);
 
316
    EXPECT_FALSE(mir_window_is_valid(window));
 
317
    EXPECT_THAT(mir_window_get_error_message(window), testing::HasSubstr(exception_text));
 
318
 
 
319
    mir_window_release_sync(window);
328
320
    mir_connection_release(connection);
329
321
}
330
322
 
339
331
    // An ID that parses as valid, but doesn't correspond to any
340
332
    auto invalid_id = mir_persistent_id_from_string("05f223a2-39e5-48b9-9416-b0ce837351b6");
341
333
 
342
 
    auto spec = mir_connection_create_spec_for_input_method(connection,
343
 
                                                            200, 200,
344
 
                                                            mir_pixel_format_argb_8888);
 
334
    auto spec = mir_create_input_method_window_spec(connection, 200, 200);
 
335
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_argb_8888);
345
336
    MirRectangle rect{
346
337
        100,
347
338
        100,
348
339
        10,
349
340
        10
350
341
    };
351
 
    mir_surface_spec_attach_to_foreign_parent(spec, invalid_id, &rect, mir_edge_attachment_any);
 
342
    mir_window_spec_attach_to_foreign_parent(spec, invalid_id, &rect, mir_edge_attachment_any);
352
343
 
353
 
    auto surface = mir_surface_create_sync(spec);
354
 
    EXPECT_THAT(surface, Not(IsValid()));
355
 
    EXPECT_THAT(mir_surface_get_error_message(surface), MatchesRegex(".*Lookup.*failed.*"));
 
344
    auto window = mir_window_create_sync(spec);
 
345
    EXPECT_THAT(window, Not(IsValid()));
 
346
    EXPECT_THAT(mir_window_get_error_message(window), MatchesRegex(".*Lookup.*failed.*"));
356
347
 
357
348
    mir_persistent_id_release(invalid_id);
358
 
    mir_surface_spec_release(spec);
359
 
    mir_surface_release_sync(surface);
 
349
    mir_window_spec_release(spec);
 
350
    mir_window_release_sync(window);
360
351
    mir_connection_release(connection);
361
352
}
362
353
 
404
395
{
405
396
    auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
406
397
 
407
 
    auto spec = mir_connection_create_spec_for_input_method(connection, 100, 100, mir_pixel_format_argb_8888);
 
398
    auto spec = mir_create_input_method_window_spec(connection, 100, 100);
 
399
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_argb_8888);
408
400
 
409
401
    MirRectangle rect{
410
402
        100,
414
406
    };
415
407
    MIR_EXPECT_DEATH(
416
408
    {
417
 
        mir_surface_spec_attach_to_foreign_parent(spec, nullptr, &rect,
 
409
        mir_window_spec_attach_to_foreign_parent(spec, nullptr, &rect,
418
410
                                                  mir_edge_attachment_any);
419
411
    }, "");
420
412
 
425
417
{
426
418
    auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
427
419
 
428
 
    auto spec = mir_connection_create_spec_for_input_method(connection, 100, 100, mir_pixel_format_argb_8888);
 
420
    auto spec = mir_create_input_method_window_spec(connection, 100, 100);
 
421
    mir_window_spec_set_pixel_format(spec, mir_pixel_format_argb_8888);
429
422
 
430
423
    auto id = mir_persistent_id_from_string("fa69b2e9-d507-4005-be61-5068f40a5aec");
431
424
 
432
425
    MIR_EXPECT_DEATH(
433
426
    {
434
 
        mir_surface_spec_attach_to_foreign_parent(spec, id, nullptr,
 
427
        mir_window_spec_attach_to_foreign_parent(spec, id, nullptr,
435
428
                                                  mir_edge_attachment_any);
436
429
    }, "");
437
430