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

Commit 30261db6 authored by Ady Abraham's avatar Ady Abraham Committed by Automerger Merge Worker
Browse files

composer: 2.4: fix VTS usage of desired time am: 30d25738 am: b6728936

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/12171999

Change-Id: Ibbdc435742ff5d89553ae178c3924306400e8ca8
parents 5444e7e4 b6728936
Loading
Loading
Loading
Loading
+17 −23
Original line number Original line Diff line number Diff line
@@ -201,8 +201,12 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {


    void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }
    void execute() { mComposerClient->execute(mReader.get(), mWriter.get()); }


    void Test_setActiveConfigWithConstraints(
    struct TestParameters {
            const IComposerClient::VsyncPeriodChangeConstraints& constraints, bool refreshMiss);
        nsecs_t delayForChange;
        bool refreshMiss;
    };

    void Test_setActiveConfigWithConstraints(const TestParameters& params);


    void sendRefreshFrame(const VsyncPeriodChangeTimeline*);
    void sendRefreshFrame(const VsyncPeriodChangeTimeline*);


@@ -453,9 +457,7 @@ void GraphicsComposerHidlCommandTest::waitForVsyncPeriodChange(
}
}


void GraphicsComposerHidlCommandTest::Test_setActiveConfigWithConstraints(
void GraphicsComposerHidlCommandTest::Test_setActiveConfigWithConstraints(
        const IComposerClient::VsyncPeriodChangeConstraints& constraints, bool refreshMiss) {
        const TestParameters& params) {
    VsyncPeriodChangeTimeline timeline = {};

    for (Display display : mComposerCallback->getDisplays()) {
    for (Display display : mComposerCallback->getDisplays()) {
        forEachTwoConfigs(display, [&](Config config1, Config config2) {
        forEachTwoConfigs(display, [&](Config config1, Config config2) {
            mComposerClient->setActiveConfig(display, config1);
            mComposerClient->setActiveConfig(display, config1);
@@ -470,6 +472,10 @@ void GraphicsComposerHidlCommandTest::Test_setActiveConfigWithConstraints(
                return;  // continue
                return;  // continue
            }
            }


            VsyncPeriodChangeTimeline timeline;
            IComposerClient::VsyncPeriodChangeConstraints constraints = {
                    .desiredTimeNanos = systemTime() + params.delayForChange,
                    .seamlessRequired = false};
            EXPECT_EQ(Error::NONE, mComposerClient->setActiveConfigWithConstraints(
            EXPECT_EQ(Error::NONE, mComposerClient->setActiveConfigWithConstraints(
                                           display, config2, constraints, &timeline));
                                           display, config2, constraints, &timeline));


@@ -480,7 +486,7 @@ void GraphicsComposerHidlCommandTest::Test_setActiveConfigWithConstraints(
                        kReasonableTimeForChange.count());
                        kReasonableTimeForChange.count());


            if (timeline.refreshRequired) {
            if (timeline.refreshRequired) {
                if (refreshMiss) {
                if (params.refreshMiss) {
                    // Miss the refresh frame on purpose to make sure the implementation sends a
                    // Miss the refresh frame on purpose to make sure the implementation sends a
                    // callback
                    // callback
                    std::this_thread::sleep_until(toTimePoint(timeline.refreshTimeNanos) + 100ms);
                    std::this_thread::sleep_until(toTimePoint(timeline.refreshTimeNanos) + 100ms);
@@ -494,7 +500,7 @@ void GraphicsComposerHidlCommandTest::Test_setActiveConfigWithConstraints(
            // cases the implementation might have missed the deadline. In this case a new
            // cases the implementation might have missed the deadline. In this case a new
            // timeline should have been provided.
            // timeline should have been provided.
            auto newTimeline = mComposerCallback->takeLastVsyncPeriodChangeTimeline();
            auto newTimeline = mComposerCallback->takeLastVsyncPeriodChangeTimeline();
            if (timeline.refreshRequired && refreshMiss) {
            if (timeline.refreshRequired && params.refreshMiss) {
                EXPECT_TRUE(newTimeline.has_value());
                EXPECT_TRUE(newTimeline.has_value());
            }
            }


@@ -515,28 +521,16 @@ void GraphicsComposerHidlCommandTest::Test_setActiveConfigWithConstraints(
}
}


TEST_P(GraphicsComposerHidlCommandTest, setActiveConfigWithConstraints) {
TEST_P(GraphicsComposerHidlCommandTest, setActiveConfigWithConstraints) {
    IComposerClient::VsyncPeriodChangeConstraints constraints;
    Test_setActiveConfigWithConstraints({.delayForChange = 0, .refreshMiss = false});

    constraints.seamlessRequired = false;
    constraints.desiredTimeNanos = systemTime();
    Test_setActiveConfigWithConstraints(constraints, false);
}
}


TEST_P(GraphicsComposerHidlCommandTest, setActiveConfigWithConstraints_Delayed) {
TEST_P(GraphicsComposerHidlCommandTest, setActiveConfigWithConstraints_Delayed) {
    IComposerClient::VsyncPeriodChangeConstraints constraints;
    Test_setActiveConfigWithConstraints({.delayForChange = 300'000'000,  // 300ms

                                         .refreshMiss = false});
    constexpr nsecs_t kDelayForChange = 300'000'000;  // 300ms
    constraints.seamlessRequired = false;
    constraints.desiredTimeNanos = systemTime() + kDelayForChange;
    Test_setActiveConfigWithConstraints(constraints, false);
}
}


TEST_P(GraphicsComposerHidlCommandTest, setActiveConfigWithConstraints_MissRefresh) {
TEST_P(GraphicsComposerHidlCommandTest, setActiveConfigWithConstraints_MissRefresh) {
    IComposerClient::VsyncPeriodChangeConstraints constraints;
    Test_setActiveConfigWithConstraints({.delayForChange = 0, .refreshMiss = true});

    constraints.seamlessRequired = false;
    constraints.desiredTimeNanos = systemTime();
    Test_setActiveConfigWithConstraints(constraints, true);
}
}


TEST_P(GraphicsComposerHidlTest, setAutoLowLatencyModeBadDisplay) {
TEST_P(GraphicsComposerHidlTest, setAutoLowLatencyModeBadDisplay) {