~robertcarr/mir/send-clients-input

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/gbm/test_gbm_display.cpp

  • Committer: Daniel van Vugt
  • Date: 2013-03-07 08:04:05 UTC
  • mfrom: (467.1.6 trunk)
  • mto: (467.1.21 trunk)
  • mto: This revision was merged to the branch mainline in revision 486.
  • Revision ID: daniel.van.vugt@canonical.com-20130307080405-vgn5g2ts7j08xekk
MergeĀ latestĀ lp:mir

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <boost/throw_exception.hpp>
19
19
#include "src/graphics/gbm/gbm_platform.h"
20
20
#include "src/graphics/gbm/gbm_display.h"
21
 
#include "src/graphics/gbm/gbm_display_reporter.h"
 
21
#include "mir/logging/display_report.h"
22
22
#include "mir/logging/logger.h"
23
23
 
24
24
#include "mir_test/egl_mock.h"
25
25
#include "mir_test/gl_mock.h"
26
 
#include "mir_test_doubles/null_display_listener.h"
27
 
#include "mir_test_doubles/mock_display_listener.h"
 
26
#include "mir/graphics/null_display_report.h"
 
27
#include "mir_test_doubles/mock_display_report.h"
28
28
 
29
29
#include "mock_drm.h"
30
30
#include "mock_gbm.h"
50
50
{
51
51
public:
52
52
    GBMDisplayTest() :
53
 
        mock_reporter(new ::testing::NiceMock<mtd::MockDisplayListener>())
 
53
        mock_report(new ::testing::NiceMock<mtd::MockDisplayReport>())
54
54
    {
55
55
        using namespace testing;
56
56
        ON_CALL(mock_egl, eglChooseConfig(_,_,_,1,_))
165
165
    ::testing::NiceMock<mir::GLMock> mock_gl;
166
166
    ::testing::NiceMock<mgg::MockDRM> mock_drm;
167
167
    ::testing::NiceMock<mgg::MockGBM> mock_gbm;
168
 
    std::shared_ptr<testing::NiceMock<mtd::MockDisplayListener>> mock_reporter;
 
168
    std::shared_ptr<testing::NiceMock<mtd::MockDisplayReport>> mock_report;
169
169
};
170
170
 
171
171
}
230
230
 
231
231
    EXPECT_NO_THROW(
232
232
    {
233
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
234
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
233
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
234
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
235
235
    });
236
236
}
237
237
 
271
271
 
272
272
    EXPECT_NO_THROW(
273
273
    {
274
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
275
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
274
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
275
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
276
276
    });
277
277
}
278
278
 
289
289
 
290
290
    EXPECT_THROW(
291
291
    {
292
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
293
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
292
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
293
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
294
294
    }, std::runtime_error);
295
295
}
296
296
 
308
308
    EXPECT_CALL(mock_drm, drmClose(_))
309
309
        .Times(Exactly(1));
310
310
 
311
 
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
 
311
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
312
312
 
313
313
    EXPECT_THROW({
314
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
314
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
315
315
    }, std::runtime_error) << "Expected that c'tor of GBMDisplay throws";
316
316
}
317
317
 
330
330
        .Times(Exactly(1));
331
331
 
332
332
    EXPECT_THROW({
333
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
 
333
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
334
334
    }, std::runtime_error) << "Expected c'tor of GBMDisplay to throw an exception";
335
335
}
336
336
 
392
392
 
393
393
    EXPECT_NO_THROW(
394
394
    {
395
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
396
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
395
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
396
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
397
397
 
398
398
        display->for_each_display_buffer([](mg::DisplayBuffer& db)
399
399
        {
432
432
 
433
433
    EXPECT_NO_THROW(
434
434
    {
435
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
436
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
435
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
436
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
437
437
 
438
438
        display->for_each_display_buffer([](mg::DisplayBuffer& db)
439
439
        {
447
447
    using namespace ::testing;
448
448
 
449
449
    EXPECT_CALL(
450
 
        *mock_reporter,
 
450
        *mock_report,
451
451
        report_successful_setup_of_native_resources()).Times(Exactly(1));
452
452
    EXPECT_CALL(
453
 
        *mock_reporter,
 
453
        *mock_report,
454
454
        report_successful_egl_make_current_on_construction()).Times(Exactly(1));
455
455
 
456
456
    EXPECT_CALL(
457
 
        *mock_reporter,
 
457
        *mock_report,
458
458
        report_successful_egl_buffer_swap_on_construction()).Times(Exactly(1));
459
459
 
460
460
    EXPECT_CALL(
461
 
        *mock_reporter,
 
461
        *mock_report,
462
462
        report_successful_drm_mode_set_crtc_on_construction()).Times(Exactly(1));
463
463
 
464
464
    EXPECT_CALL(
465
 
        *mock_reporter,
 
465
        *mock_report,
466
466
        report_successful_display_construction()).Times(Exactly(1));
467
467
 
468
468
    EXPECT_NO_THROW(
469
469
    {
470
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
471
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
470
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
471
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
472
472
    });
473
473
}
474
474
 
476
476
{
477
477
    using namespace ::testing;
478
478
 
479
 
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
 
479
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
480
480
    auto logger = std::make_shared<MockLogger>();
481
481
 
482
 
    auto reporter = std::make_shared<mgg::GBMDisplayReporter>(logger);
483
 
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
482
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
483
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
484
484
 
485
485
    EXPECT_CALL(
486
486
        *logger,
487
487
        log(Eq(ml::Logger::informational),
488
488
            StrEq("Successfully setup native resources."),
489
 
            StrEq("GBMDisplay"))).Times(Exactly(1));
 
489
            StrEq("graphics"))).Times(Exactly(1));
490
490
 
491
491
    reporter->report_successful_setup_of_native_resources();
492
492
}
495
495
{
496
496
    using namespace ::testing;
497
497
 
498
 
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
 
498
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
499
499
    auto logger = std::make_shared<MockLogger>();
500
500
 
501
 
    auto reporter = std::make_shared<mgg::GBMDisplayReporter>(logger);
502
 
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
501
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
502
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
503
503
 
504
504
    EXPECT_CALL(
505
505
        *logger,
506
506
        log(Eq(ml::Logger::informational),
507
507
            StrEq("Successfully made egl context current on construction."),
508
 
            StrEq("GBMDisplay"))).Times(Exactly(1));
 
508
            StrEq("graphics"))).Times(Exactly(1));
509
509
 
510
510
    reporter->report_successful_egl_make_current_on_construction();
511
511
}
514
514
{
515
515
    using namespace ::testing;
516
516
 
517
 
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
 
517
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
518
518
    auto logger = std::make_shared<MockLogger>();
519
519
 
520
 
    auto reporter = std::make_shared<mgg::GBMDisplayReporter>(logger);
521
 
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
520
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
521
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
522
522
 
523
523
    EXPECT_CALL(
524
524
        *logger,
525
525
        log(Eq(ml::Logger::informational),
526
526
            StrEq("Successfully performed egl buffer swap on construction."),
527
 
            StrEq("GBMDisplay"))).Times(Exactly(1));
 
527
            StrEq("graphics"))).Times(Exactly(1));
528
528
 
529
529
    reporter->report_successful_egl_buffer_swap_on_construction();
530
530
}
533
533
{
534
534
    using namespace ::testing;
535
535
 
536
 
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
 
536
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
537
537
    auto logger = std::make_shared<MockLogger>();
538
538
 
539
 
    auto reporter = std::make_shared<mgg::GBMDisplayReporter>(logger);
540
 
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
539
    auto reporter = std::make_shared<ml::DisplayReport>(logger);
 
540
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
541
541
 
542
542
    EXPECT_CALL(
543
543
        *logger,
544
544
        log(Eq(ml::Logger::informational),
545
545
            StrEq("Successfully performed drm mode setup on construction."),
546
 
            StrEq("GBMDisplay"))).Times(Exactly(1));
 
546
            StrEq("graphics"))).Times(Exactly(1));
547
547
 
548
548
    reporter->report_successful_drm_mode_set_crtc_on_construction();
549
549
}
559
559
 
560
560
    EXPECT_THROW(
561
561
    {
562
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
563
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
562
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
563
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
564
564
    }, std::runtime_error);
565
565
}
566
566
 
575
575
 
576
576
    EXPECT_THROW(
577
577
    {
578
 
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
579
 
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
578
        auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
579
        auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
580
580
    }, std::runtime_error);
581
581
}
582
582
 
584
584
{
585
585
    using namespace ::testing;
586
586
 
587
 
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mtd::NullDisplayListener>());
588
 
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_reporter);
 
587
    auto platform = std::make_shared<mgg::GBMPlatform>(std::make_shared<mg::NullDisplayReport>());
 
588
    auto display = std::make_shared<mgg::GBMDisplay>(platform, mock_report);
589
589
 
590
590
    int callback_count{0};
591
591