| Index: ui/events/event_processor_unittest.cc
|
| diff --git a/ui/events/event_processor_unittest.cc b/ui/events/event_processor_unittest.cc
|
| index c8b20229354c93e807b07628e576dd7c512561cf..05378362d3b4b204e6662749da2fe7b1ec73aaa0 100644
|
| --- a/ui/events/event_processor_unittest.cc
|
| +++ b/ui/events/event_processor_unittest.cc
|
| @@ -25,7 +25,7 @@ class EventProcessorTest : public testing::Test {
|
| // testing::Test:
|
| virtual void SetUp() OVERRIDE {
|
| processor_.SetRoot(scoped_ptr<EventTarget>(new TestEventTarget()));
|
| - processor_.ResetCounts();
|
| + processor_.Reset();
|
| root()->SetEventTargeter(make_scoped_ptr(new EventTargeter()));
|
| }
|
|
|
| @@ -280,6 +280,44 @@ TEST_F(EventProcessorTest, OnEventProcessingFinished) {
|
| EXPECT_EQ(1, processor()->num_times_processing_finished());
|
| }
|
|
|
| +// Verifies that OnEventProcessingStarted() has been called when starting to
|
| +// process an event, and that dispatch only takes place if it returns true.
|
| +// Also verifies that OnEventProcessingFinished() is also called in both
|
| +// cases.
|
| +TEST_F(EventProcessorTest, OnEventProcessingStarted) {
|
| + scoped_ptr<TestEventTarget> child(new TestEventTarget());
|
| + root()->AddChild(child.Pass());
|
| +
|
| + // Dispatch a mouse event. We expect the event to be seen by the target,
|
| + // OnEventProcessingStarted() should be called once, and
|
| + // OnEventProcessingFinished() should be called once.
|
| + MouseEvent mouse(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + EF_NONE, EF_NONE);
|
| + DispatchEvent(&mouse);
|
| + EXPECT_TRUE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED));
|
| + EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED));
|
| + EXPECT_FALSE(mouse.handled());
|
| + EXPECT_EQ(1, processor()->num_times_processing_started());
|
| + EXPECT_EQ(1, processor()->num_times_processing_finished());
|
| + processor()->Reset();
|
| + root()->ResetReceivedEvents();
|
| + root()->child_at(0)->ResetReceivedEvents();
|
| +
|
| + // Force OnEventProcessingStarted() to return false and dispatch another
|
| + // mouse event. We expect the event to not be seen by the target this
|
| + // time, but OnEventProcessingStarted() and OnEventProcessingFinished()
|
| + // should both still be called once.
|
| + processor()->SetShouldProcessingOccur(false);
|
| + MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + EF_NONE, EF_NONE);
|
| + DispatchEvent(&mouse2);
|
| + EXPECT_FALSE(root()->child_at(0)->DidReceiveEvent(ET_MOUSE_MOVED));
|
| + EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED));
|
| + EXPECT_FALSE(mouse2.handled());
|
| + EXPECT_EQ(1, processor()->num_times_processing_started());
|
| + EXPECT_EQ(1, processor()->num_times_processing_finished());
|
| +}
|
| +
|
| class IgnoreEventTargeter : public EventTargeter {
|
| public:
|
| IgnoreEventTargeter() {}
|
|
|