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

Commit 9ea03122 authored by Brian Johnson's avatar Brian Johnson Committed by Cherrypicker Worker
Browse files

SF: Update unit test to pass non-default mocks.

Update tests to pass non-default mocks so that surfaceflinger internals can be more accurately tested, allowing for testing for division by vsync

Test: on main: lunch cf_x86_64_phone-userdebug && atest
DisplayModeSwitchingTest#changeRefreshRate_OnActiveDisplay_WithoutRefreshRequired
Bug: 278035063
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f626c2f99cdc39266921642eb10d823472c2d74f)
Merged-In: Ica4009c30940dad7a8b1dced712223e8eaabc99a
Change-Id: Ica4009c30940dad7a8b1dced712223e8eaabc99a
parent c655e036
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -49,9 +49,17 @@ public:
        mFlinger.onComposerHalHotplug(PrimaryDisplayVariant::HWC_DISPLAY_ID, Connection::CONNECTED);
        mFlinger.configureAndCommit();

        auto vsyncController = std::make_unique<mock::VsyncController>();
        auto vsyncTracker = std::make_shared<mock::VSyncTracker>();

        EXPECT_CALL(*vsyncTracker, nextAnticipatedVSyncTimeFrom(_)).WillRepeatedly(Return(0));
        EXPECT_CALL(*vsyncTracker, currentPeriod())
                .WillRepeatedly(Return(
                        TestableSurfaceFlinger::FakeHwcDisplayInjector::DEFAULT_VSYNC_PERIOD));

        mDisplay = PrimaryDisplayVariant::makeFakeExistingDisplayInjector(this)
                           .setRefreshRateSelector(std::move(selectorPtr))
                           .inject();
                           .inject(std::move(vsyncController), std::move(vsyncTracker));

        // isVsyncPeriodSwitchSupported should return true, otherwise the SF's HWC proxy
        // will call setActiveConfig instead of setActiveConfigWithConstraints.
+16 −1
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@
#include "mock/MockSchedulerCallback.h"
#include "mock/system/window/MockNativeWindow.h"

#include "Scheduler/VSyncTracker.h"
#include "Scheduler/VsyncController.h"
#include "mock/MockVSyncDispatch.h"
#include "mock/MockVSyncTracker.h"
#include "mock/MockVsyncController.h"

namespace android {

struct DisplayStatInfo;
@@ -911,6 +917,13 @@ public:
        }

        sp<DisplayDevice> inject() NO_THREAD_SAFETY_ANALYSIS {
            return inject(std::make_unique<mock::VsyncController>(),
                          std::make_shared<mock::VSyncTracker>());
        }

        sp<DisplayDevice> inject(std::unique_ptr<android::scheduler::VsyncController> controller,
                                 std::shared_ptr<android::scheduler::VSyncTracker> tracker)
                NO_THREAD_SAFETY_ANALYSIS {
            const auto displayId = mCreationArgs.compositionDisplay->getDisplayId();

            auto& modes = mDisplayModes;
@@ -975,7 +988,9 @@ public:

                if (mFlinger.scheduler() && mRegisterDisplay) {
                    mFlinger.scheduler()->registerDisplay(physicalId,
                                                          display->holdRefreshRateSelector());
                                                          display->holdRefreshRateSelector(),
                                                          std::move(controller),
                                                          std::move(tracker));
                }

                display->setActiveMode(activeModeId, fps, fps);