// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/events/event_rewriter.h" #include <list> #include <map> #include <set> #include <utility> #include "base/check_op.h" #include "base/memory/raw_ptr.h" #include "base/notreached.h" #include "base/types/cxx23_to_underlying.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/events/keycodes/dom/dom_code.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/test/test_event_source.h" #include "ui/events/test/test_event_target.h" namespace ui { namespace { TestEventTarget; // TestEventRewriteSink is set up with a sequence of event types, // and fails if the events received via OnEventFromSource() do not match // this sequence. These expected event types are consumed on receipt. class TestEventRewriteSink : public EventSink { … }; std::unique_ptr<Event> CreateEventForType(EventType type) { … } class TestEventRewriteSource : public test::TestEventSource { … }; // This EventRewriter always returns the same status, and if rewriting, the // same event type; it is used to test simple rewriting, and rewriter addition, // removal, and sequencing. Consequently EVENT_REWRITE_DISPATCH_ANOTHER is not // supported here (calls to NextDispatchEvent() would continue indefinitely). class TestConstantEventRewriterOld : public EventRewriter { … }; // This EventRewriter runs a simple state machine; it is used to test // EVENT_REWRITE_DISPATCH_ANOTHER. class TestStateMachineEventRewriterOld : public EventRewriter { … }; // This EventRewriter always accepts the original event. It is used to test // simple rewriting, and rewriter addition, removal, and sequencing. class TestAlwaysAcceptEventRewriter : public EventRewriter { … }; // This EventRewriter always rewrites with the same event type; it is used // to test simple rewriting, and rewriter addition, removal, and sequencing. class TestConstantEventRewriter : public EventRewriter { … }; // This EventRewriter runs a simple state machine; it is used to test // EVENT_REWRITE_DISPATCH_ANOTHER. class TestStateMachineEventRewriter : public EventRewriter { … }; } // namespace TEST(EventRewriterTest, EventRewritingOld) { … } TEST(EventRewriterTest, EventRewriting) { … } } // namespace ui