~ci-train-bot/mir/mir-ubuntu-zesty-2683

« back to all changes in this revision

Viewing changes to tests/unit-tests/client/test_client_mir_surface.cpp

  • Committer: Bileto Bot
  • Date: 2017-04-13 15:26:17 UTC
  • mfrom: (1160.2883.164 0.27)
  • Revision ID: ci-train-bot@canonical.com-20170413152617-bs7slz07xbzxu2d3
* New upstream release 0.27.0 (https://launchpad.net/mir/+milestone/0.27.0)
  - ABI summary:
    . mirclient ABI unchanged at 9
    . mirserver ABI bumped to 44
    . mircommon ABI unchanged at 7
    . mirplatform ABI bumped to 61
    . mirprotobuf ABI unchanged at 3
    . mirplatformgraphics ABI bumped to 13
    . mirclientplatform ABI unchanged at 5
    . mirinputplatform ABI bumped to 7
    . mircore ABI unchanged at 1
  - Enhancements:
    . Mostly groundwork required to support major enhancements coming in
      future Mir versions.
    . Removed android-input and eliminated the entire "3rd_party/" subtree.
      Now the Mir source tree contains original code only.
    . Added mir_prompt_session_new_fds_for_prompt_providers_sync API.
    . mirout: Added load and save options for keeping display configs
      on disk.
    . mirout: Added "--" support for applying configuration changes under
      Unity8.
    . Fixed failure of DRM hardware cursor {hide(); show(image);}
    . Added server option: "--cursor software" (MIR_SERVER_CURSOR=software)
    . Added letterboxing/black bars support to the GL renderer in preparation
      for generic output cloning.
    . Added client API for getting the logical size of an output.
    . Migrated MirCookie to use SHA-256.
    . Ensure RealKMSOutputConfiguration stays in sync with actual hardware
      state.
    . Added support for drag-and-drop.
    . Lots of other client API enhancements.
    . Minor clean-ups, optimizations and dead code removal.
  - Bugs fixed:
    . [enhancement] Make able to get version information from client /
      server APIs (LP: #1195540)
    . Touch screen coordinates don't rotate with the screen (LP: #1349660)
    . Subpixel order not included in Mir display information (LP: #1393578)
    . [enhancement] Missing client API for relative surface movement (e.g.
      dragging client-decorated windows) (LP: #1420334) . Mir does not reset
      key states when paused or resumed (modifiers get stuck after VT
      switching) (LP: #1536279)
    . Inconsistent behaviour of Num Lock (LP: #1588237)
    . [ FAILED ] NestedInput.nested_event_filter_receives_keyboard_from_host
      (LP: #1613523)
    . Rotating an output left or right without restarting the
      compositor distorts the image (LP: #1643488)
    . support display scaling slider in unity8 (LP: #1645372)
    . [ FAILED ] NestedInputWithMouse.mouse_pointer_coordinates_in_nested_
      server_are_accumulated (LP: #1646375)
    . [ FAILED ] NestedInputWithMouse.mouse_pointer_position_is_in_sync_with_
      host_server (LP: #1646558)
    . abi_check doesn't check mircore (LP: #1649354)
    . Under Unity8, mir_demo_client_target is distorted and input in the
      wrong place on start-up (LP: #1655804)
    . [testsfail] PromptSessionClientAPI.client_pid_is_associated_with_
      session hangs and times out (LP: #1655929)
    . EDID does not change when hotplugging a monitor (LP: #1660017)
    . [regression] Mir 0.26.0 - spinner loading animation, minimize, maximize
      too fast (LP: #1661072)
    . [regression] Unity8 stutters constantly (like half frame rate) using
      Mir 0.26.0 (LP: #1661128)
    . [regression] mir_demo_server refuses to quit on Ctrl+Alt+Backspace or
      Ctrl+C in its terminal (deadlock in DefaultInputDeviceHub::add_device)
      (LP: #1661151)
    . [regression] mirout crashes when connecting to unity8 or any nested
      server: [libprotobuf FATAL
      /usr/include/google/protobuf/repeated_field.h:1408] CHECK failed:
      (index) < (current_size_): (LP: #1661163)
    . [ FAILED ] DefaultInputManagerTest.forwards_pause_continue_state_
      changes_to_platform (LP: #1661187)
    . [regression] Segfault on detect_fd_leaks during acceptance tests (in
      DisplayConfiguration/{DisplayFormatSetting,DisplaySubpixelSetting})
      (LP: #1661498)
    . [regression] Nested server segfaults or rapidly logs exceptions when a
      fullscreen client starts [in mir_presentation_chain_set_dropping_mode
      ... std::exception::what: Operation not permitted] (LP: #1661508)
    . [regression] Windowed clients of nested servers are all black
      (LP: #1661521)
    . mir_window_request_persistent_id_sync seg faults when called twice
      (LP: #1661704)
    . mir_acceptance_tests now takes 10 seconds longer (in r4002 compared to
      r4001) (LP: #1662044)
    . Mir graphics platform ABI broke in series 0.26 but sonames never
      changed (LP: #1662455)
    . libmirclient-dev missing build depndency on libmircore-dev
      (LP: #1662942)
    . [regression] mirscreencast hangs during screencast creation
      (LP: #1662997)
    . [regression] Software clients of nested servers with size >=480x480
      are all black in Mir 0.25.0 and later (or stretched and distorted under
      Unity8) (LP: #1663062)
    . mir_window_spec_set_cursor_name() doesn't trigger
      mir::scene::SurfaceObserver::cursor_image_set_to (LP: #1663197)
    . android complaint during mirscreencast of nested server (LP: #1664562)
    . qtubuntu sends wrong text as part of QKeyEvent (LP: #1664610)
    . Mir server crashed with SIGSEGV in
      mir::compositor::TemporaryBuffer::size() called from
      mir::gl::tessellate_renderable_into_rectangle() (LP: #1664760)
    . mirout reports logical size of a rotated display incorrectly
      (LP: #1665271)
    . Nested servers (Unity8) periodically stutter (half frame rate) with
      Mir 0.26.1 (LP: #1666372)
    . If the only surface in a session cannot take focus the server crashes
      (LP: #1667645)
    . [regression] OSK input shaping no longer works correctly (LP: #1669444)
    . GTK window functions `Always on Top, Move and Resize' don't work in
      Mir/Unity8 (LP: #1669524)
    . [regression] mir_proving_server mode hotkeys (Ctrl+Alt+=/-) cause the
      server to segfault (LP: #1669752)
    . Test takes minutes to complete: MediatingDisplayChangerTest.confirmed_
      configuration_doesnt_revert_after_timeout (LP: #1671033)
    . [ FAILED ] PosixRWMutex.prefer_writer_nonrecursive_prevents_writer_
      starvation (Timeout waiting to acquire write lock) (LP: #1671037)
    . [regression] Mixing screen rotation with mode changes makes the image
      squished (LP: #1672269)
    . unity-system-compositor crashed with SIGSEGV in
      libinput_device_config_accel_is_available() from
      libinput_device_config_accel_set_speed() from
      mir::input::evdev::LibInputDevice::apply_settings() (LP: #1672955)
    . Presentation chains should support various Vulkan presentation modes
      (LP: #1673533)
    . Need an extension for GBM buffers to replace
      mir_buffer_get_buffer_package() (LP: #1673534)
    . cross-compile-chroot.sh (to zesty) fails to build [cannot find -ludev]
      due to libudev.so being in a different directory to where libudev.pc
      searches for it (LP: #1674201)
    . Please transition to Boost 1.62 (LP: #1675138)
    . [regression] Mir is assigning the first output ID = 0 (==
      mir_display_output_id_invalid) (LP: #1675331)
    . Mir sending key repeat events continually to nested shell after VT
      switch (causes Unity8 lockup for a while) (LP: #1675357)
    . mirout commands don't work when followed by -- (LP: #1676320)
    . mir_demo_standalone_render_overlays fails to link (LP: #1677239)
    . [regression] doxygen processing for capnproto/protobuf broken
      (LP: #1679248)
    . mir_window_spec_set_cursor_render_surface does not work (LP: #1679836)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "mir/events/event_builders.h"
39
39
 
40
40
#include "mir/frontend/connector.h"
41
 
#include "mir/input/input_platform.h"
42
41
 
43
42
#include "mir/test/test_protobuf_server.h"
44
43
#include "mir/test/stub_server_tool.h"
219
218
    { mir_window_attrib_preferred_orientation, mir_orientation_mode_any }
220
219
};
221
220
 
222
 
struct StubClientInputPlatform : public mircv::InputPlatform
223
 
{
224
 
    std::shared_ptr<mir::dispatch::Dispatchable> create_input_receiver(int /* fd */, std::shared_ptr<mircv::XKBMapper> const&, std::function<void(MirEvent*)> const& /* callback */)
225
 
    {
226
 
        return std::shared_ptr<mir::dispatch::Dispatchable>();
227
 
    }
228
 
};
229
 
 
230
 
struct MockClientInputPlatform : public mircv::InputPlatform
231
 
{
232
 
    MOCK_METHOD3(create_input_receiver, std::shared_ptr<mir::dispatch::Dispatchable>(int, std::shared_ptr<mircv::XKBMapper> const&, std::function<void(MirEvent*)> const&));
233
 
};
234
 
 
235
221
class TestConnectionConfiguration : public mcl::DefaultConnectionConfiguration
236
222
{
237
223
public:
273
259
{
274
260
}
275
261
 
276
 
void null_event_callback(MirWindow*, MirEvent const*, void*)
277
 
{
278
 
}
279
 
 
280
262
void null_lifecycle_callback(MirConnection*, MirLifecycleState, void*)
281
263
{
282
264
}
327
309
            server_stub,
328
310
            nullptr,
329
311
            stub_buffer_stream,
330
 
            input_platform,
331
312
            spec,
332
313
            surface_proto,
333
314
            wh);
342
323
            server_stub,
343
324
            nullptr,
344
325
            buffer_stream,
345
 
            input_platform,
346
326
            spec,
347
327
            surface_proto,
348
328
            wh);
367
347
 
368
348
    MirWindowSpec const spec{nullptr, 33, 45, mir_pixel_format_abgr_8888};
369
349
    std::shared_ptr<mtd::MockMirBufferStream> stub_buffer_stream{std::make_shared<mtd::MockMirBufferStream>()};
370
 
    std::shared_ptr<StubClientInputPlatform> const input_platform =
371
 
        std::make_shared<StubClientInputPlatform>();
372
350
    std::shared_ptr<MockServerPackageGenerator> const mock_server_tool =
373
351
        std::make_shared<MockServerPackageGenerator>();
374
352
 
395
373
    }
396
374
}
397
375
 
398
 
TEST_F(MirClientSurfaceTest, creates_input_thread_with_input_dispatcher_when_delegate_specified)
399
 
{
400
 
    using namespace ::testing;
401
 
 
402
 
    auto dispatched = std::make_shared<mt::Signal>();
403
 
 
404
 
    auto mock_input_dispatcher = std::make_shared<mt::TestDispatchable>([dispatched]() { dispatched->raise(); });
405
 
    auto mock_input_platform = std::make_shared<MockClientInputPlatform>();
406
 
 
407
 
    EXPECT_CALL(*mock_input_platform, create_input_receiver(_, _, _)).Times(1)
408
 
        .WillOnce(Return(mock_input_dispatcher));
409
 
 
410
 
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
411
 
        stub_buffer_stream, mock_input_platform, spec, surface_proto, wh};
412
 
    surface.set_event_handler(null_event_callback, nullptr);
413
 
 
414
 
    mock_input_dispatcher->trigger();
415
 
 
416
 
    EXPECT_TRUE(dispatched->wait_for(std::chrono::seconds{5}));
417
 
}
418
 
 
419
376
TEST_F(MirClientSurfaceTest, adopts_the_default_stream)
420
377
{
421
378
    using namespace ::testing;
422
379
 
423
 
    auto mock_input_platform = std::make_shared<MockClientInputPlatform>();
424
380
    auto mock_stream = std::make_shared<mtd::MockMirBufferStream>(); 
425
381
 
426
382
    MirWindow* adopted_by = nullptr;
432
388
 
433
389
    {
434
390
        MirWindow win{connection.get(), *client_comm_channel, nullptr,
435
 
            mock_stream, mock_input_platform, spec, surface_proto, wh};
 
391
            mock_stream, spec, surface_proto, wh};
436
392
        EXPECT_EQ(&win,    adopted_by);
437
393
        EXPECT_EQ(nullptr, unadopted_by);
438
394
    }
446
402
    using namespace ::testing;
447
403
 
448
404
    mir::frontend::BufferStreamId const mock_stream_id(777888);
449
 
    auto mock_input_platform = std::make_shared<MockClientInputPlatform>();
450
405
    auto mock_stream = std::make_shared<mtd::MockMirBufferStream>(); 
451
406
 
452
407
    MirWindow* adopted_by = nullptr;
468
423
        };
469
424
        spec.streams = replacements;
470
425
        MirWindow win{connection.get(), *client_comm_channel, nullptr,
471
 
            nullptr, mock_input_platform, spec, surface_proto, wh};
 
426
            nullptr, spec, surface_proto, wh};
472
427
        ASSERT_EQ(&win,    adopted_by);
473
428
        ASSERT_EQ(nullptr, unadopted_by);
474
429
    }
481
436
{
482
437
    using namespace testing;
483
438
 
484
 
    auto mock_input_platform = std::make_shared<MockClientInputPlatform>();
485
 
 
486
439
    mir::frontend::BufferStreamId const mock_old_stream_id(11);
487
440
    auto mock_old_stream = std::make_shared<mtd::MockMirBufferStream>(); 
488
441
    MirWindow* old_adopted_by = nullptr;
509
462
    surface_map->insert(mock_new_stream_id, mock_new_stream);
510
463
    {
511
464
        MirWindow win{connection.get(), *client_comm_channel, nullptr,
512
 
            mock_old_stream, mock_input_platform, spec, surface_proto, wh};
 
465
            mock_old_stream, spec, surface_proto, wh};
513
466
    
514
467
        EXPECT_EQ(&win,    old_adopted_by);
515
468
        EXPECT_EQ(nullptr, old_unadopted_by);
533
486
    surface_map->erase(mock_new_stream_id);
534
487
}
535
488
 
536
 
TEST_F(MirClientSurfaceTest, replacing_delegate_with_nullptr_prevents_further_dispatch)
537
 
{
538
 
    using namespace ::testing;
539
 
 
540
 
    auto dispatched = std::make_shared<mt::Signal>();
541
 
 
542
 
    auto mock_input_dispatcher = std::make_shared<mt::TestDispatchable>([dispatched]() { dispatched->raise(); });
543
 
    auto mock_input_platform = std::make_shared<MockClientInputPlatform>();
544
 
 
545
 
    EXPECT_CALL(*mock_input_platform, create_input_receiver(_, _, _)).Times(1)
546
 
        .WillOnce(Return(mock_input_dispatcher));
547
 
 
548
 
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
549
 
        stub_buffer_stream, mock_input_platform, spec, surface_proto, wh};
550
 
    surface.set_event_handler(null_event_callback, nullptr);
551
 
 
552
 
    // Should now not get dispatched.
553
 
    surface.set_event_handler(nullptr, nullptr);
554
 
 
555
 
    mock_input_dispatcher->trigger();
556
 
 
557
 
    EXPECT_FALSE(dispatched->wait_for(std::chrono::seconds{1}));
558
 
}
559
 
 
560
 
 
561
 
TEST_F(MirClientSurfaceTest, does_not_create_input_dispatcher_when_no_delegate_specified)
562
 
{
563
 
    using namespace ::testing;
564
 
 
565
 
    auto mock_input_platform = std::make_shared<MockClientInputPlatform>();
566
 
 
567
 
    EXPECT_CALL(*mock_input_platform, create_input_receiver(_, _, _)).Times(0);
568
 
 
569
 
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
570
 
        stub_buffer_stream, mock_input_platform, spec, surface_proto, wh};
571
 
}
572
 
 
573
489
TEST_F(MirClientSurfaceTest, valid_surface_is_valid)
574
490
{
575
491
    auto const surface = create_and_wait_for_surface_with(*client_comm_channel);
597
513
 
598
514
    EXPECT_GE(std::chrono::steady_clock::now(), expected_end);
599
515
 
 
516
#pragma GCC diagnostic push
 
517
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
600
518
    mir_cursor_configuration_destroy(cursor_config);
 
519
#pragma GCC diagnostic pop
601
520
}
602
521
 
603
522
TEST_F(MirClientSurfaceTest, configure_wait_handle_really_blocks)
622
541
    using namespace testing;
623
542
    auto mock_stream = std::make_shared<mtd::MockMirBufferStream>(); 
624
543
    mir::frontend::BufferStreamId const mock_stream_id(2);
625
 
    auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
626
 
    ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
627
 
        .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
628
544
    ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mock_stream_id));
629
545
 
630
546
    geom::Size size(120, 124);
632
548
    auto ev = mir::events::make_event(mir::frontend::SurfaceId(2), size);
633
549
 
634
550
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
635
 
        mock_stream, mock_input_platform, spec, surface_proto, wh};
 
551
        mock_stream, spec, surface_proto, wh};
636
552
    surface_map->insert(mock_stream_id, mock_stream);
637
553
    surface.handle_event(*ev);
638
554
    surface_map->erase(mock_stream_id);
643
559
    using namespace testing;
644
560
    auto mock_stream = std::make_shared<NiceMock<mtd::MockMirBufferStream>>();
645
561
    mir::frontend::BufferStreamId const mock_stream_id(2);
646
 
    auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
647
562
    ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mock_stream_id));
648
 
    ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
649
 
        .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
650
563
 
651
564
    geom::Size size(120, 124);
652
565
    EXPECT_CALL(*mock_stream, set_size(size)).Times(0);
653
566
    auto ev = mir::events::make_event(mir::frontend::SurfaceId(2), size);
654
567
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
655
 
        mock_stream, mock_input_platform, spec, surface_proto, wh};
 
568
        mock_stream, spec, surface_proto, wh};
656
569
 
657
570
    MirWindowSpec spec;
658
571
    std::vector<ContentInfo> info =
668
581
{
669
582
    using namespace testing;
670
583
    auto mock_stream = std::make_shared<mtd::MockMirBufferStream>(); 
671
 
    auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
672
 
    ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
673
 
        .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
674
584
    ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mir::frontend::BufferStreamId(2)));
675
585
    geom::Size size(120, 124);
676
586
    EXPECT_CALL(*mock_stream, set_size(size));
680
590
    surface_proto.set_height(size.height.as_int());
681
591
 
682
592
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
683
 
        mock_stream, mock_input_platform, spec, surface_proto, wh};
 
593
        mock_stream, spec, surface_proto, wh};
684
594
 
685
595
    auto params = surface.get_parameters();
686
596
    EXPECT_THAT(params.width, Eq(size.width.as_int())); 
696
606
{
697
607
    using namespace testing;
698
608
    auto mock_stream = std::make_shared<mtd::MockMirBufferStream>(); 
699
 
    auto mock_input_platform = std::make_shared<NiceMock<MockClientInputPlatform>>();
700
 
    ON_CALL(*mock_input_platform, create_input_receiver(_,_,_))
701
 
        .WillByDefault(Return(std::make_shared<mt::TestDispatchable>([]{})));
702
609
    ON_CALL(*mock_stream, rpc_id()).WillByDefault(Return(mir::frontend::BufferStreamId(2)));
703
610
    geom::Size size(120, 124);
704
611
 
705
612
    surface_proto.set_width(size.width.as_int());
706
613
    surface_proto.set_height(size.height.as_int());
707
614
    MirWindow surface{connection.get(), *client_comm_channel, nullptr,
708
 
        mock_stream, mock_input_platform, spec, surface_proto, wh};
 
615
        mock_stream, spec, surface_proto, wh};
709
616
 
710
617
    auto params = surface.get_parameters();
711
618
    EXPECT_THAT(params.width, Eq(size.width.as_int()));