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

Commit c28181ed authored by Arpit Singh's avatar Arpit Singh
Browse files

Refactor PointerChoreographerTest to use Mock Policy

We can now use mocked PointerChoreographer policy in choreographer
tests.

Bug: 344554018
Test: atest inputlfinger_tests
Change-Id: I8fb0d0094a9a8ea311122c35f8a9a41ada0c12fa
parent 3cb24e3d
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -113,17 +113,31 @@ TestPointerChoreographer::TestPointerChoreographer(
                    windowInfoListener = nullptr;
                }) {}

class PointerChoreographerTest : public testing::Test, public PointerChoreographerPolicyInterface {
class PointerChoreographerTest : public testing::Test {
protected:
    TestInputListener mTestListener;
    sp<gui::WindowInfosListener> mRegisteredWindowInfoListener;
    std::vector<gui::WindowInfo> mInjectedInitialWindowInfos;
    TestPointerChoreographer mChoreographer{mTestListener, *this, mRegisteredWindowInfoListener,
    testing::NiceMock<MockPointerChoreographerPolicyInterface> mMockPolicy;
    TestPointerChoreographer mChoreographer{mTestListener, mMockPolicy,
                                            mRegisteredWindowInfoListener,
                                            mInjectedInitialWindowInfos};

    void SetUp() override {
        // flag overrides
        input_flags::hide_pointer_indicators_for_secure_windows(true);

        ON_CALL(mMockPolicy, createPointerController).WillByDefault([this](ControllerType type) {
            std::shared_ptr<FakePointerController> pc = std::make_shared<FakePointerController>();
            EXPECT_FALSE(pc->isPointerShown());
            mCreatedControllers.emplace_back(type, pc);
            return pc;
        });

        ON_CALL(mMockPolicy, notifyPointerDisplayIdChanged)
                .WillByDefault([this](ui::LogicalDisplayId displayId, const FloatPoint& position) {
                    mPointerDisplayIdNotified = displayId;
                });
    }

    std::shared_ptr<FakePointerController> assertPointerControllerCreated(
@@ -177,19 +191,6 @@ private:
    std::deque<std::pair<ControllerType, std::shared_ptr<FakePointerController>>>
            mCreatedControllers;
    std::optional<ui::LogicalDisplayId> mPointerDisplayIdNotified;

    std::shared_ptr<PointerControllerInterface> createPointerController(
            ControllerType type) override {
        std::shared_ptr<FakePointerController> pc = std::make_shared<FakePointerController>();
        EXPECT_FALSE(pc->isPointerShown());
        mCreatedControllers.emplace_back(type, pc);
        return pc;
    }

    void notifyPointerDisplayIdChanged(ui::LogicalDisplayId displayId,
                                       const FloatPoint& position) override {
        mPointerDisplayIdNotified = displayId;
    }
};

TEST_F(PointerChoreographerTest, ForwardsArgsToInnerListener) {