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

« back to all changes in this revision

Viewing changes to tests/unit-tests/platforms/mesa/kms/test_cursor.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:
56
56
{
57
57
    StubKMSOutputContainer()
58
58
        : outputs{
59
 
            {10, std::make_shared<testing::NiceMock<MockKMSOutput>>()},
60
 
            {11, std::make_shared<testing::NiceMock<MockKMSOutput>>()},
61
 
            {12, std::make_shared<testing::NiceMock<MockKMSOutput>>()}}
 
59
            std::make_shared<testing::NiceMock<MockKMSOutput>>(),
 
60
            std::make_shared<testing::NiceMock<MockKMSOutput>>(),
 
61
            std::make_shared<testing::NiceMock<MockKMSOutput>>()}
62
62
    {
63
63
        // These need to be established before Cursor construction:
64
 
        for (auto& entry : outputs)
 
64
        for (auto& output : outputs)
65
65
        {
66
 
            auto& out = *entry.second;
 
66
            auto& out = *output;
67
67
            ON_CALL(out, has_cursor())
68
68
                .WillByDefault(Return(true));
 
69
            ON_CALL(out, set_cursor(_))
 
70
                .WillByDefault(Return(true));
 
71
            ON_CALL(out, clear_cursor())
 
72
                .WillByDefault(Return(true));
69
73
        }
70
74
    }
71
75
 
72
 
    std::shared_ptr<mgm::KMSOutput> get_kms_output_for(uint32_t connector_id)
73
 
    {
74
 
        return outputs[connector_id];
75
 
    }
76
 
 
77
 
    void for_each_output(std::function<void(mgm::KMSOutput&)> functor) const
78
 
    {
79
 
        for (auto const& pair : outputs)
80
 
            functor(*pair.second);
 
76
    void for_each_output(std::function<void(std::shared_ptr<mgm::KMSOutput> const&)> functor) const
 
77
    {
 
78
        for (auto const& output : outputs)
 
79
            functor(output);
81
80
    }
82
81
 
83
82
    void verify_and_clear_expectations()
84
83
    {
85
 
        for (auto const& pair : outputs)
86
 
            ::testing::Mock::VerifyAndClearExpectations(pair.second.get());
87
 
    }
88
 
 
89
 
    std::unordered_map<uint32_t,std::shared_ptr<testing::NiceMock<MockKMSOutput>>> outputs;
 
84
        for (auto const& output : outputs)
 
85
            ::testing::Mock::VerifyAndClearExpectations(output.get());
 
86
    }
 
87
 
 
88
    void update_from_hardware_state()
 
89
    {
 
90
    }
 
91
 
 
92
    std::vector<std::shared_ptr<testing::NiceMock<MockKMSOutput>>> outputs;
90
93
};
91
94
 
92
95
struct StubKMSDisplayConfiguration : public mgm::KMSDisplayConfiguration
93
96
{
94
 
    StubKMSDisplayConfiguration()
 
97
    StubKMSDisplayConfiguration(mgm::KMSOutputContainer& container)
95
98
        : mgm::KMSDisplayConfiguration(),
 
99
          container{container},
96
100
          stub_config{
97
101
            {{
98
 
                mg::DisplayConfigurationOutputId{10},
 
102
                mg::DisplayConfigurationOutputId{0},
99
103
                mg::DisplayConfigurationCardId{},
100
104
                mg::DisplayConfigurationOutputType::vga,
101
105
                {},
120
124
                {}
121
125
            },
122
126
            {
123
 
                mg::DisplayConfigurationOutputId{11},
 
127
                mg::DisplayConfigurationOutputId{1},
124
128
                mg::DisplayConfigurationCardId{},
125
129
                mg::DisplayConfigurationOutputType::vga,
126
130
                {},
145
149
                {}
146
150
            },
147
151
            {
148
 
                mg::DisplayConfigurationOutputId{12},
 
152
                mg::DisplayConfigurationOutputId{2},
149
153
                mg::DisplayConfigurationCardId{},
150
154
                mg::DisplayConfigurationOutputType::vga,
151
155
                {},
170
174
                {}
171
175
            }}}
172
176
    {
 
177
        update();
173
178
    }
174
179
 
175
180
    void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)> f) const override
197
202
        return stub_config.valid();
198
203
    }
199
204
 
200
 
    uint32_t get_kms_connector_id(mg::DisplayConfigurationOutputId id) const override
 
205
    std::shared_ptr<mgm::KMSOutput> get_output_for(mg::DisplayConfigurationOutputId id) const override
201
206
    {
202
 
        return id.as_value();
 
207
        return outputs[id.as_value()];
203
208
    }
204
209
 
205
210
    size_t get_kms_mode_index(mg::DisplayConfigurationOutputId, size_t conf_mode_index) const override
209
214
 
210
215
    void update() override
211
216
    {
 
217
        container.for_each_output(
 
218
            [this](auto const& output)
 
219
            {
 
220
                outputs.push_back(output);
 
221
            });
212
222
    }
213
223
 
214
224
    void set_orentation_of_output(mg::DisplayConfigurationOutputId id, MirOrientation orientation)
221
231
            });
222
232
    }
223
233
 
 
234
    mgm::KMSOutputContainer& container;
224
235
    mtd::StubDisplayConfig stub_config;
 
236
    std::vector<std::shared_ptr<mgm::KMSOutput>> outputs;
225
237
};
226
238
 
227
239
struct StubCurrentConfiguration : public mgm::CurrentConfiguration
228
240
{
 
241
    StubCurrentConfiguration(mgm::KMSOutputContainer& container)
 
242
        : conf(container)
 
243
    {
 
244
    }
 
245
 
229
246
    void with_current_configuration_do(
230
247
        std::function<void(mgm::KMSDisplayConfiguration const&)> const& exec)
231
248
    {
281
298
    size_t const cursor_side{64};
282
299
    MesaCursorTest()
283
300
        : cursor{mock_gbm.fake_gbm.device, output_container,
284
 
            mt::fake_shared(current_configuration),
285
 
            mt::fake_shared(stub_image)}
 
301
            mt::fake_shared(current_configuration)}
286
302
    {
287
303
        using namespace ::testing;
288
304
        ON_CALL(mock_drm, drmGetCap(_, DRM_CAP_CURSOR_WIDTH, _))
301
317
    }
302
318
 
303
319
    testing::NiceMock<mtd::MockDRM> mock_drm;
304
 
    StubCurrentConfiguration current_configuration;
305
320
    StubCursorImage stub_image;
306
321
    StubKMSOutputContainer output_container;
 
322
    StubCurrentConfiguration current_configuration{output_container};
307
323
    mgm::Cursor cursor;
308
324
};
309
325
 
333
349
                                        GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE));
334
350
 
335
351
    mgm::Cursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
336
 
        std::make_shared<StubCurrentConfiguration>(),
337
 
        std::make_shared<StubCursorImage>()};
 
352
        std::make_shared<StubCurrentConfiguration>(output_container)};
338
353
}
339
354
 
340
355
TEST_F(MesaCursorTest, queries_received_cursor_size)
345
360
    EXPECT_CALL(mock_gbm, gbm_bo_get_height(_));
346
361
 
347
362
    mgm::Cursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
348
 
        std::make_shared<StubCurrentConfiguration>(),
349
 
        std::make_shared<StubCursorImage>()};
 
363
        std::make_shared<StubCurrentConfiguration>(output_container)};
350
364
}
351
365
 
352
366
TEST_F(MesaCursorTest, respects_drm_cap_cursor)
361
375
    EXPECT_CALL(mock_gbm, gbm_bo_create(_, drm_buffer_size, drm_buffer_size, _, _));
362
376
 
363
377
    mgm::Cursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
364
 
                           std::make_shared<StubCurrentConfiguration>(),
365
 
                           std::make_shared<StubCursorImage>()};
 
378
                           std::make_shared<StubCurrentConfiguration>(output_container)};
366
379
}
367
380
 
368
381
TEST_F(MesaCursorTest, can_force_64x64_cursor)
379
392
    EXPECT_CALL(mock_gbm, gbm_bo_create(_, 64, 64, _, _));
380
393
 
381
394
    mgm::Cursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
382
 
                           std::make_shared<StubCurrentConfiguration>(),
383
 
                           std::make_shared<StubCursorImage>()};
 
395
                           std::make_shared<StubCurrentConfiguration>(output_container)};
384
396
}
385
397
 
386
398
TEST_F(MesaCursorTest, show_cursor_writes_to_bo)
444
456
    EXPECT_CALL(mock_gbm, gbm_bo_write(mock_gbm.fake_gbm.bo, ContainsASingleWhitePixel(width*height), buffer_size_bytes));
445
457
 
446
458
    mgm::Cursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
447
 
        std::make_shared<StubCurrentConfiguration>(),
448
 
        std::make_shared<SinglePixelCursorImage>()};
 
459
        std::make_shared<StubCurrentConfiguration>(output_container)};
 
460
    cursor_tmp.show(SinglePixelCursorImage());
449
461
}
450
462
 
451
463
TEST_F(MesaCursorTest, throws_when_images_are_too_large)
467
479
    }, std::logic_error);
468
480
}
469
481
 
470
 
TEST_F(MesaCursorTest, forces_cursor_state_on_construction)
 
482
TEST_F(MesaCursorTest, clears_cursor_state_on_construction)
471
483
{
472
484
    using namespace testing;
473
485
 
474
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{0,0}));
475
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_));
476
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor());
477
 
    EXPECT_CALL(*output_container.outputs[12], clear_cursor());
 
486
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
 
487
    EXPECT_CALL(*output_container.outputs[1], clear_cursor());
 
488
    EXPECT_CALL(*output_container.outputs[2], clear_cursor());
478
489
 
479
490
    /* No checking of existing cursor state */
480
 
    EXPECT_CALL(*output_container.outputs[10], has_cursor()).Times(1);
481
 
    EXPECT_CALL(*output_container.outputs[11], has_cursor()).Times(0);
482
 
    EXPECT_CALL(*output_container.outputs[12], has_cursor()).Times(0);
 
491
    EXPECT_CALL(*output_container.outputs[0], has_cursor()).Times(0);
 
492
    EXPECT_CALL(*output_container.outputs[1], has_cursor()).Times(0);
 
493
    EXPECT_CALL(*output_container.outputs[2], has_cursor()).Times(0);
483
494
 
484
495
    mgm::Cursor cursor_tmp{mock_gbm.fake_gbm.device, output_container,
485
 
       std::make_shared<StubCurrentConfiguration>(),
486
 
       std::make_shared<StubCursorImage>()};
 
496
       std::make_shared<StubCurrentConfiguration>(output_container)};
487
497
 
488
498
    output_container.verify_and_clear_expectations();
489
499
}
492
502
{
493
503
    using namespace testing;
494
504
 
495
 
    EXPECT_CALL(*output_container.outputs[10], has_cursor())
496
 
        .WillOnce(Return(false));
 
505
    ON_CALL(*output_container.outputs[0], clear_cursor())
 
506
        .WillByDefault(Return(false));
 
507
    ON_CALL(*output_container.outputs[0], set_cursor(_))
 
508
        .WillByDefault(Return(false));
 
509
    ON_CALL(*output_container.outputs[0], has_cursor())
 
510
        .WillByDefault(Return(false));
497
511
 
498
512
    EXPECT_THROW(
499
513
        mgm::Cursor cursor_tmp(mock_gbm.fake_gbm.device, output_container,
500
 
           std::make_shared<StubCurrentConfiguration>(),
501
 
           std::make_shared<StubCursorImage>())
 
514
           std::make_shared<StubCurrentConfiguration>(output_container));
502
515
    , std::runtime_error);
503
516
}
504
517
 
506
519
{
507
520
    using namespace testing;
508
521
 
509
 
    EXPECT_CALL(*output_container.outputs[10], has_cursor())
 
522
    cursor.show(stub_image);
 
523
 
 
524
    EXPECT_CALL(*output_container.outputs[0], has_cursor())
510
525
        .WillOnce(Return(false))
511
526
        .WillOnce(Return(true));
512
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_));
 
527
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_));
513
528
 
514
 
    EXPECT_CALL(*output_container.outputs[11], has_cursor())
 
529
    EXPECT_CALL(*output_container.outputs[1], has_cursor())
515
530
        .WillOnce(Return(true));
516
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor());
 
531
    EXPECT_CALL(*output_container.outputs[1], clear_cursor());
517
532
 
518
533
    cursor.move_to({10, 10});
519
534
 
524
539
{
525
540
    using namespace testing;
526
541
 
527
 
    EXPECT_CALL(*output_container.outputs[10], has_cursor())
 
542
    cursor.show(stub_image);
 
543
 
 
544
    EXPECT_CALL(*output_container.outputs[0], has_cursor())
528
545
        .WillOnce(Return(true));
529
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_))
 
546
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_))
530
547
        .Times(0);
531
548
 
532
 
    EXPECT_CALL(*output_container.outputs[11], has_cursor())
 
549
    EXPECT_CALL(*output_container.outputs[1], has_cursor())
533
550
        .WillOnce(Return(false));
534
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor())
 
551
    EXPECT_CALL(*output_container.outputs[1], clear_cursor())
535
552
        .Times(0);
536
553
 
537
554
    cursor.move_to({10, 10});
543
560
{
544
561
    using namespace testing;
545
562
 
546
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{10,10}));
547
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(_))
 
563
    cursor.show(stub_image);
 
564
 
 
565
    EXPECT_CALL(*output_container.outputs[0], move_cursor(geom::Point{10,10}));
 
566
    EXPECT_CALL(*output_container.outputs[1], move_cursor(_))
548
567
        .Times(0);
549
568
 
550
569
    cursor.move_to({10, 10});
551
570
 
552
571
    output_container.verify_and_clear_expectations();
553
572
 
554
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(_))
 
573
    EXPECT_CALL(*output_container.outputs[0], move_cursor(_))
555
574
        .Times(0);
556
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,100}));
 
575
    EXPECT_CALL(*output_container.outputs[1], move_cursor(geom::Point{50,100}));
557
576
 
558
577
    cursor.move_to({150, 150});
559
578
 
560
579
    output_container.verify_and_clear_expectations();
561
580
 
562
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
563
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
 
581
    EXPECT_CALL(*output_container.outputs[0], move_cursor(geom::Point{150,75}));
 
582
    EXPECT_CALL(*output_container.outputs[1], move_cursor(geom::Point{50,25}));
564
583
 
565
584
    cursor.move_to({150, 75});
566
585
 
567
586
    output_container.verify_and_clear_expectations();
568
587
 
569
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(_))
 
588
    EXPECT_CALL(*output_container.outputs[0], move_cursor(_))
570
589
        .Times(0);
571
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(_))
 
590
    EXPECT_CALL(*output_container.outputs[1], move_cursor(_))
572
591
        .Times(0);
573
592
 
574
593
    cursor.move_to({-1, -1});
580
599
{
581
600
    using namespace testing;
582
601
 
583
 
    current_configuration.conf.set_orentation_of_output(mg::DisplayConfigurationOutputId{12}, mir_orientation_left);
584
 
 
585
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(geom::Point{112,100}));
586
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(geom::Point{150,96}));
 
602
    cursor.show(stub_image);
 
603
 
 
604
    current_configuration.conf.set_orentation_of_output(mg::DisplayConfigurationOutputId{2}, mir_orientation_left);
 
605
 
 
606
    EXPECT_CALL(*output_container.outputs[2], move_cursor(geom::Point{112,100}));
 
607
    EXPECT_CALL(*output_container.outputs[2], move_cursor(geom::Point{150,96}));
587
608
 
588
609
    cursor.move_to({766, 112});
589
610
    cursor.move_to({770, 150});
596
617
{
597
618
    using namespace testing;
598
619
 
599
 
    current_configuration.conf.set_orentation_of_output(mg::DisplayConfigurationOutputId{12}, mir_orientation_right);
600
 
 
601
 
 
602
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(geom::Point{688,100}));
603
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(geom::Point{650,104}));
 
620
    cursor.show(stub_image);
 
621
 
 
622
    current_configuration.conf.set_orentation_of_output(mg::DisplayConfigurationOutputId{2}, mir_orientation_right);
 
623
 
 
624
 
 
625
    EXPECT_CALL(*output_container.outputs[2], move_cursor(geom::Point{688,100}));
 
626
    EXPECT_CALL(*output_container.outputs[2], move_cursor(geom::Point{650,104}));
604
627
 
605
628
    cursor.move_to({766, 112});
606
629
    cursor.move_to({770, 150});
612
635
{
613
636
    using namespace testing;
614
637
 
615
 
    current_configuration.conf.set_orentation_of_output(mg::DisplayConfigurationOutputId{12}, mir_orientation_inverted);
616
 
 
617
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(geom::Point{700,88}));
618
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(geom::Point{696,50}));
 
638
    cursor.show(stub_image);
 
639
 
 
640
    current_configuration.conf.set_orentation_of_output(mg::DisplayConfigurationOutputId{2}, mir_orientation_inverted);
 
641
 
 
642
    EXPECT_CALL(*output_container.outputs[2], move_cursor(geom::Point{700,88}));
 
643
    EXPECT_CALL(*output_container.outputs[2], move_cursor(geom::Point{696,50}));
619
644
 
620
645
    cursor.move_to({766, 112});
621
646
    cursor.move_to({770, 150});
627
652
{
628
653
    using namespace testing;
629
654
 
630
 
    EXPECT_CALL(*output_container.outputs[10], clear_cursor());
631
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor());
632
 
    EXPECT_CALL(*output_container.outputs[12], clear_cursor());
 
655
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
 
656
    EXPECT_CALL(*output_container.outputs[1], clear_cursor());
 
657
    EXPECT_CALL(*output_container.outputs[2], clear_cursor());
633
658
 
634
659
    cursor.hide();
635
660
 
640
665
{
641
666
    using namespace testing;
642
667
 
643
 
    EXPECT_CALL(*output_container.outputs[10], clear_cursor());
644
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor());
645
 
    EXPECT_CALL(*output_container.outputs[12], clear_cursor());
646
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(_)).Times(0);
647
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(_)).Times(0);
648
 
    EXPECT_CALL(*output_container.outputs[12], move_cursor(_)).Times(0);
 
668
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
 
669
    EXPECT_CALL(*output_container.outputs[1], clear_cursor());
 
670
    EXPECT_CALL(*output_container.outputs[2], clear_cursor());
 
671
    EXPECT_CALL(*output_container.outputs[0], move_cursor(_)).Times(0);
 
672
    EXPECT_CALL(*output_container.outputs[1], move_cursor(_)).Times(0);
 
673
    EXPECT_CALL(*output_container.outputs[2], move_cursor(_)).Times(0);
649
674
 
650
675
    cursor.hide();
651
676
    cursor.move_to({17, 29});
657
682
{
658
683
    using namespace testing;
659
684
 
660
 
    EXPECT_CALL(*output_container.outputs[10], clear_cursor());
661
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor());
662
 
    EXPECT_CALL(*output_container.outputs[12], clear_cursor());
 
685
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
 
686
    EXPECT_CALL(*output_container.outputs[1], clear_cursor());
 
687
    EXPECT_CALL(*output_container.outputs[2], clear_cursor());
663
688
}
664
689
 
665
690
TEST_F(MesaCursorTest, cursor_is_shown_at_correct_location_after_suspend_resume)
666
691
{
667
692
    using namespace testing;
668
693
 
669
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
670
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
671
 
    EXPECT_CALL(*output_container.outputs[10], clear_cursor());
672
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor());
673
 
    EXPECT_CALL(*output_container.outputs[12], has_cursor())
 
694
    cursor.show(stub_image);
 
695
 
 
696
    EXPECT_CALL(*output_container.outputs[0], move_cursor(geom::Point{150,75}));
 
697
    EXPECT_CALL(*output_container.outputs[1], move_cursor(geom::Point{50,25}));
 
698
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
 
699
    EXPECT_CALL(*output_container.outputs[1], clear_cursor());
 
700
    EXPECT_CALL(*output_container.outputs[2], has_cursor())
674
701
        .WillRepeatedly(Return(false));
675
 
    EXPECT_CALL(*output_container.outputs[12], clear_cursor());
 
702
    EXPECT_CALL(*output_container.outputs[2], clear_cursor());
676
703
 
677
704
    cursor.move_to({150, 75});
678
705
    cursor.suspend();
679
706
 
680
707
    output_container.verify_and_clear_expectations();
681
708
 
682
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_));
683
 
    EXPECT_CALL(*output_container.outputs[11], set_cursor(_));
684
 
    EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
685
 
    EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
 
709
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_));
 
710
    EXPECT_CALL(*output_container.outputs[1], set_cursor(_));
 
711
    EXPECT_CALL(*output_container.outputs[0], move_cursor(geom::Point{150,75}));
 
712
    EXPECT_CALL(*output_container.outputs[1], move_cursor(geom::Point{50,25}));
686
713
 
687
714
    cursor.resume();
688
715
    output_container.verify_and_clear_expectations();
692
719
{
693
720
    using namespace testing;
694
721
 
695
 
    EXPECT_CALL(*output_container.outputs[10], clear_cursor()).Times(AnyNumber());
696
 
    EXPECT_CALL(*output_container.outputs[11], clear_cursor()).Times(AnyNumber());
697
 
    EXPECT_CALL(*output_container.outputs[12], clear_cursor()).Times(AnyNumber());
 
722
    EXPECT_CALL(*output_container.outputs[0], clear_cursor()).Times(AnyNumber());
 
723
    EXPECT_CALL(*output_container.outputs[1], clear_cursor()).Times(AnyNumber());
 
724
    EXPECT_CALL(*output_container.outputs[2], clear_cursor()).Times(AnyNumber());
698
725
 
699
726
    cursor.hide();
700
727
    cursor.suspend();
701
728
 
702
729
    output_container.verify_and_clear_expectations();
703
730
 
704
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_)).Times(0);
705
 
    EXPECT_CALL(*output_container.outputs[11], set_cursor(_)).Times(0);
706
 
    EXPECT_CALL(*output_container.outputs[12], set_cursor(_)).Times(0);
 
731
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_)).Times(0);
 
732
    EXPECT_CALL(*output_container.outputs[1], set_cursor(_)).Times(0);
 
733
    EXPECT_CALL(*output_container.outputs[2], set_cursor(_)).Times(0);
707
734
 
708
735
    cursor.resume();
709
736
    output_container.verify_and_clear_expectations();
710
737
}
711
738
 
 
739
TEST_F(MesaCursorTest, show_with_param_places_cursor_on_output)
 
740
{
 
741
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
 
742
    cursor.hide();
 
743
 
 
744
    output_container.verify_and_clear_expectations();
 
745
 
 
746
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_));
 
747
    cursor.show(stub_image);
 
748
}
712
749
 
713
750
TEST_F(MesaCursorTest, show_without_param_places_cursor_on_output_output)
714
751
{
715
752
    using namespace testing;
716
 
    EXPECT_CALL(*output_container.outputs[10], clear_cursor());
 
753
    EXPECT_CALL(*output_container.outputs[0], clear_cursor());
717
754
 
718
755
    cursor.hide();
719
756
    output_container.verify_and_clear_expectations();
720
757
 
721
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_));
 
758
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_));
722
759
    cursor.show();
723
760
}
724
761
 
726
763
{
727
764
    using namespace testing;
728
765
 
 
766
    cursor.show(stub_image); // ensures initial_cursor_location
 
767
 
729
768
    static geom::Displacement hotspot_displacement{10, 10};
730
769
    
731
770
    static geom::Point const
746
785
    
747
786
    
748
787
    EXPECT_CALL(mock_gbm, gbm_bo_write(_, _, _)).Times(AnyNumber());
749
 
    EXPECT_CALL(*output_container.outputs[10], set_cursor(_)).Times(AnyNumber());
 
788
    EXPECT_CALL(*output_container.outputs[0], set_cursor(_)).Times(AnyNumber());
750
789
 
751
790
    // When we set the image with the hotspot, first we should see the cursor move from its initial
752
791
    // location, to account for the displacement. Further movement should be offset by the hotspot.
753
792
    {
754
793
        InSequence seq;
755
 
        EXPECT_CALL(*output_container.outputs[10], move_cursor(initial_buffer_location));
756
 
        EXPECT_CALL(*output_container.outputs[10], move_cursor(expected_buffer_location_1));
757
 
        EXPECT_CALL(*output_container.outputs[10], move_cursor(expected_buffer_location_2));
 
794
        EXPECT_CALL(*output_container.outputs[0], move_cursor(initial_buffer_location));
 
795
        EXPECT_CALL(*output_container.outputs[0], move_cursor(expected_buffer_location_1));
 
796
        EXPECT_CALL(*output_container.outputs[0], move_cursor(expected_buffer_location_2));
758
797
    }
759
798
 
760
799
    cursor.show(HotspotCursor());