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

Commit 260a091b authored by Harry Cutts's avatar Harry Cutts Committed by Android (Google) Code Review
Browse files

Merge "TestEventMatchers: explain WithMotionAction failures" into main

parents ce4322b7 fb6d585f
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -75,12 +75,18 @@ public:
    using is_gtest_matcher = void;
    explicit WithMotionActionMatcher(int32_t action) : mAction(action) {}

    bool MatchAndExplain(const MotionEvent& event, std::ostream*) const {
        bool matches = mAction == event.getAction();
        if (event.getAction() == AMOTION_EVENT_ACTION_CANCEL) {
            matches &= (event.getFlags() & AMOTION_EVENT_FLAG_CANCELED) != 0;
    bool MatchAndExplain(const MotionEvent& event, testing::MatchResultListener* listener) const {
        if (mAction != event.getAction()) {
            *listener << "expected " << MotionEvent::actionToString(mAction) << ", but got "
                      << MotionEvent::actionToString(event.getAction());
            return false;
        }
        if (event.getAction() == AMOTION_EVENT_ACTION_CANCEL &&
            (event.getFlags() & AMOTION_EVENT_FLAG_CANCELED) == 0) {
            *listener << "event with CANCEL action is missing FLAG_CANCELED";
            return false;
        }
        return matches;
        return true;
    }

    void DescribeTo(std::ostream* os) const {
+23 −10
Original line number Diff line number Diff line
@@ -108,20 +108,33 @@ public:
    using is_gtest_matcher = void;
    explicit WithMotionActionMatcher(int32_t action) : mAction(action) {}

    bool MatchAndExplain(const NotifyMotionArgs& args, std::ostream*) const {
        bool matches = mAction == args.action;
        if (args.action == AMOTION_EVENT_ACTION_CANCEL) {
            matches &= (args.flags & AMOTION_EVENT_FLAG_CANCELED) != 0;
    bool MatchAndExplain(const NotifyMotionArgs& args,
                         testing::MatchResultListener* listener) const {
        if (mAction != args.action) {
            *listener << "expected " << MotionEvent::actionToString(mAction) << ", but got "
                      << MotionEvent::actionToString(args.action);
            return false;
        }
        return matches;
        if (args.action == AMOTION_EVENT_ACTION_CANCEL &&
            (args.flags & AMOTION_EVENT_FLAG_CANCELED) == 0) {
            *listener << "event with CANCEL action is missing FLAG_CANCELED";
            return false;
        }
        return true;
    }

    bool MatchAndExplain(const MotionEvent& event, std::ostream*) const {
        bool matches = mAction == event.getAction();
        if (event.getAction() == AMOTION_EVENT_ACTION_CANCEL) {
            matches &= (event.getFlags() & AMOTION_EVENT_FLAG_CANCELED) != 0;
    bool MatchAndExplain(const MotionEvent& event, testing::MatchResultListener* listener) const {
        if (mAction != event.getAction()) {
            *listener << "expected " << MotionEvent::actionToString(mAction) << ", but got "
                      << MotionEvent::actionToString(event.getAction());
            return false;
        }
        return matches;
        if (event.getAction() == AMOTION_EVENT_ACTION_CANCEL &&
            (event.getFlags() & AMOTION_EVENT_FLAG_CANCELED) == 0) {
            *listener << "event with CANCEL action is missing FLAG_CANCELED";
            return false;
        }
        return true;
    }

    void DescribeTo(std::ostream* os) const {