~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/mesa/test_display.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
ImportĀ upstreamĀ versionĀ 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "src/platform/graphics/mesa/platform.h"
20
20
#include "src/platform/graphics/mesa/display.h"
21
21
#include "src/platform/graphics/mesa/virtual_terminal.h"
22
 
#include "src/server/logging/display_report.h"
 
22
#include "src/server/report/logging/display_report.h"
23
23
#include "mir/logging/logger.h"
24
24
#include "mir/graphics/display_buffer.h"
25
25
#include "src/server/graphics/default_display_configuration_policy.h"
27
27
 
28
28
#include "mir_test_doubles/mock_egl.h"
29
29
#include "mir_test_doubles/mock_gl.h"
30
 
#include "mir/graphics/null_display_report.h"
 
30
#include "src/server/report/null_report_factory.h"
31
31
#include "mir_test_doubles/mock_display_report.h"
32
32
#include "mir_test_doubles/null_virtual_terminal.h"
33
33
 
47
47
namespace mg=mir::graphics;
48
48
namespace mgm=mir::graphics::mesa;
49
49
namespace ml=mir::logging;
 
50
namespace mrl=mir::report::logging;
50
51
namespace mtd=mir::test::doubles;
51
52
namespace mtf=mir::mir_test_framework;
 
53
namespace mr=mir::report;
52
54
 
53
55
namespace
54
56
{
89
91
public:
90
92
    MesaDisplayTest() :
91
93
        mock_report{std::make_shared<testing::NiceMock<mtd::MockDisplayReport>>()},
92
 
        null_report{std::make_shared<mg::NullDisplayReport>()}
 
94
        null_report{mr::null_display_report()}
93
95
    {
94
96
        using namespace testing;
95
97
        ON_CALL(mock_egl, eglChooseConfig(_,_,_,1,_))
114
116
        EXPECT_CALL(mock_gbm, gbm_device_get_fd(_))
115
117
        .Times(AtLeast(0));
116
118
 
117
 
        fake_devices.add_standard_drm_devices();
 
119
        fake_devices.add_standard_device("standard-drm-devices");
118
120
    }
119
121
 
120
122
    std::shared_ptr<mgm::Platform> create_platform()
330
332
{
331
333
    using namespace testing;
332
334
 
333
 
    EXPECT_CALL(mock_drm, drmOpen(_,_))
 
335
    EXPECT_CALL(mock_drm, open(_,_,_))
334
336
        .Times(AtLeast(1))
335
337
        .WillRepeatedly(Return(-1));
336
338
 
428
430
 
429
431
        /* Handle the flip event */
430
432
        EXPECT_CALL(mock_drm, drmHandleEvent(mock_drm.fake_drm.fd(), _))
431
 
            .Times(1)
432
 
            .WillOnce(DoAll(InvokePageFlipHandler(&user_data), Return(0)));
 
433
            .Times(0);
433
434
 
434
 
        /* Release the current FB */
 
435
        /* Release last_flipped_bufobj (at destruction time) */
435
436
        EXPECT_CALL(mock_gbm, gbm_surface_release_buffer(mock_gbm.fake_gbm.surface, fake.bo1))
436
437
            .Times(Exactly(1));
437
 
 
438
 
        /* Release the new FB (at destruction time) */
 
438
        /* Release scheduled_bufobj (at destruction time) */
439
439
        EXPECT_CALL(mock_gbm, gbm_surface_release_buffer(mock_gbm.fake_gbm.surface, fake.bo2))
440
440
            .Times(Exactly(1));
441
441
    }
468
468
            .Times(Exactly(1))
469
469
            .WillOnce(Return(-1));
470
470
 
471
 
        /* Release the new (not flipped) BO */
 
471
        /* Release failed bufobj */
472
472
        EXPECT_CALL(mock_gbm, gbm_surface_release_buffer(mock_gbm.fake_gbm.surface, fake.bo2))
473
473
            .Times(Exactly(1));
474
474
 
475
 
        /* Release the current FB (at destruction time) */
 
475
        /* Release scheduled_bufobj (at destruction time) */
476
476
        EXPECT_CALL(mock_gbm, gbm_surface_release_buffer(mock_gbm.fake_gbm.surface, fake.bo1))
477
477
            .Times(Exactly(1));
478
478
    }
526
526
    using namespace ::testing;
527
527
 
528
528
    auto logger = std::make_shared<MockLogger>();
529
 
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
529
    auto reporter = std::make_shared<mrl::DisplayReport>(logger);
530
530
 
531
531
    EXPECT_CALL(
532
532
        *logger,
542
542
    using namespace ::testing;
543
543
 
544
544
    auto logger = std::make_shared<MockLogger>();
545
 
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
545
    auto reporter = std::make_shared<mrl::DisplayReport>(logger);
546
546
 
547
547
    EXPECT_CALL(
548
548
        *logger,
558
558
    using namespace ::testing;
559
559
 
560
560
    auto logger = std::make_shared<MockLogger>();
561
 
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
561
    auto reporter = std::make_shared<mrl::DisplayReport>(logger);
562
562
 
563
563
    EXPECT_CALL(
564
564
        *logger,
574
574
    using namespace ::testing;
575
575
 
576
576
    auto logger = std::make_shared<MockLogger>();
577
 
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
577
    auto reporter = std::make_shared<mrl::DisplayReport>(logger);
578
578
 
579
579
    EXPECT_CALL(
580
580
        *logger,
723
723
                        std::make_shared<mg::DefaultDisplayConfigurationPolicy>(),
724
724
                        null_report);
725
725
 
726
 
    auto syspath = fake_devices.add_device("drm", "card2", NULL, {}, {"DEVTYPE", "drm_minor"});
727
 
 
728
726
    mir::AsioMainLoop ml;
729
727
    std::condition_variable done;
730
728
 
747
745
        });
748
746
 
749
747
    std::thread t{
750
 
        [this, syspath]
 
748
        [this]
751
749
        {
752
 
            for (int i = 0; i < device_change_count; ++i)
 
750
            auto const syspath = fake_devices.add_device("drm", "card2", NULL, {}, {"DEVTYPE", "drm_minor"});
 
751
 
 
752
            for (int i = 0; i != device_change_count; ++i)
753
753
            {
 
754
                // sleeping between calls to fake_devices hides race conditions
 
755
                std::this_thread::sleep_for(std::chrono::microseconds{500});
754
756
                fake_devices.emit_device_changed(syspath);
755
 
                std::this_thread::sleep_for(std::chrono::microseconds{500});
756
757
            }
757
758
        }};
758
759
 
760
761
        [this, &done, &m, &ml, &call_count]
761
762
        {
762
763
            std::unique_lock<std::mutex> lock(m);
763
 
            if (!done.wait_for (lock, std::chrono::seconds{1}, [&call_count]() { return call_count == expected_call_count; }))
764
 
                ADD_FAILURE() << "Timeout waiting for change events";
765
 
            ml.stop();
 
764
            if (!done.wait_for(lock, std::chrono::seconds{1}, [&call_count]() { return call_count == expected_call_count; }))
 
765
                ml.stop();
766
766
        }
767
767
    };
768
768