Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cb5c92b authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "composer: vts: check that refresh rate stays the same on inactivity"...

Merge "composer: vts: check that refresh rate stays the same on inactivity" into rvc-dev am: 15f12a26 am: 905ebf5d

Change-Id: Ia2187a50bede8adfbc9d6e996facbf63fb14d8f5
parents aceb4cd6 905ebf5d
Loading
Loading
Loading
Loading
+27 −2
Original line number Original line Diff line number Diff line
@@ -279,23 +279,48 @@ TEST_P(GraphicsComposerHidlTest, getDisplayVsyncPeriod_BadDisplay) {
              mComposerClient->getDisplayVsyncPeriod(mInvalidDisplayId, &vsyncPeriodNanos));
              mComposerClient->getDisplayVsyncPeriod(mInvalidDisplayId, &vsyncPeriodNanos));
}
}


TEST_P(GraphicsComposerHidlTest, getDisplayVsyncPeriod) {
TEST_P(GraphicsComposerHidlCommandTest, getDisplayVsyncPeriod) {
    for (Display display : mComposerCallback->getDisplays()) {
    for (Display display : mComposerCallback->getDisplays()) {
        for (Config config : mComposerClient->getDisplayConfigs(display)) {
        for (Config config : mComposerClient->getDisplayConfigs(display)) {
            VsyncPeriodNanos expectedVsyncPeriodNanos = mComposerClient->getDisplayAttribute_2_4(
            VsyncPeriodNanos expectedVsyncPeriodNanos = mComposerClient->getDisplayAttribute_2_4(
                    display, config, IComposerClient::IComposerClient::Attribute::VSYNC_PERIOD);
                    display, config, IComposerClient::IComposerClient::Attribute::VSYNC_PERIOD);


            mComposerClient->setActiveConfig(display, config);
            VsyncPeriodChangeTimeline timeline;
            IComposerClient::VsyncPeriodChangeConstraints constraints;

            constraints.desiredTimeNanos = systemTime();
            constraints.seamlessRequired = false;
            EXPECT_EQ(Error::NONE, mComposerClient->setActiveConfigWithConstraints(
                                           display, config, constraints, &timeline));

            if (timeline.refreshRequired) {
                sendRefreshFrame(timeline);
            }
            waitForVsyncPeriodChange(display, timeline, constraints.desiredTimeNanos, 0,
                                     expectedVsyncPeriodNanos);

            VsyncPeriodNanos vsyncPeriodNanos;
            VsyncPeriodNanos vsyncPeriodNanos;
            int retryCount = 100;
            int retryCount = 100;
            do {
            do {
                std::this_thread::sleep_for(10ms);
                std::this_thread::sleep_for(10ms);
                vsyncPeriodNanos = 0;
                EXPECT_EQ(Error::NONE,
                EXPECT_EQ(Error::NONE,
                          mComposerClient->getDisplayVsyncPeriod(display, &vsyncPeriodNanos));
                          mComposerClient->getDisplayVsyncPeriod(display, &vsyncPeriodNanos));
                --retryCount;
                --retryCount;
            } while (vsyncPeriodNanos != expectedVsyncPeriodNanos && retryCount > 0);
            } while (vsyncPeriodNanos != expectedVsyncPeriodNanos && retryCount > 0);


            EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);
            EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);

            // Make sure that the vsync period stays the same if the active config is not changed.
            auto timeout = 1ms;
            for (int i = 0; i < 10; i++) {
                std::this_thread::sleep_for(timeout);
                timeout *= 2;
                vsyncPeriodNanos = 0;
                EXPECT_EQ(Error::NONE,
                          mComposerClient->getDisplayVsyncPeriod(display, &vsyncPeriodNanos));
                EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);
            }
        }
        }
    }
    }
}
}