| Index: ui/events/event_processor_unittest.cc
|
| diff --git a/ui/events/event_processor_unittest.cc b/ui/events/event_processor_unittest.cc
|
| index 6d8edf5a7b4fc30c738f962c8f2617105b1dea50..15118194046216fc5587acab64b25bca7d3dad52 100644
|
| --- a/ui/events/event_processor_unittest.cc
|
| +++ b/ui/events/event_processor_unittest.cc
|
| @@ -142,9 +142,11 @@ TEST_F(EventProcessorTest, Bounds) {
|
| // Now install a targeter on the parent that looks at the bounds and makes
|
| // sure the event reaches the target only if the location of the event within
|
| // the bounds of the target.
|
| + MouseEvent mouse2(ET_MOUSE_MOVED, gfx::Point(1, 1), gfx::Point(1, 1), EF_NONE,
|
| + EF_NONE);
|
| parent_r->SetEventTargeter(scoped_ptr<EventTargeter>(
|
| new BoundsEventTargeter<BoundsTestTarget>()));
|
| - DispatchEvent(&mouse);
|
| + DispatchEvent(&mouse2);
|
| EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED));
|
| EXPECT_TRUE(parent_r->DidReceiveEvent(ET_MOUSE_MOVED));
|
| EXPECT_FALSE(child_r->DidReceiveEvent(ET_MOUSE_MOVED));
|
| @@ -160,5 +162,42 @@ TEST_F(EventProcessorTest, Bounds) {
|
| EXPECT_TRUE(grandchild_r->DidReceiveEvent(ET_MOUSE_MOVED));
|
| }
|
|
|
| +class IgnoreEventTargeter : public EventTargeter {
|
| + public:
|
| + IgnoreEventTargeter() {}
|
| + virtual ~IgnoreEventTargeter() {}
|
| +
|
| + private:
|
| + // EventTargeter:
|
| + virtual bool SubtreeShouldBeExploredForEvent(
|
| + EventTarget* target, const LocatedEvent& event) OVERRIDE {
|
| + return false;
|
| + }
|
| +};
|
| +
|
| +// Verifies that the EventTargeter installed on an EventTarget can dictate
|
| +// whether the target itself can process an event.
|
| +TEST_F(EventProcessorTest, TargeterChecksOwningEventTarget) {
|
| + scoped_ptr<TestEventTarget> child(new TestEventTarget());
|
| + root()->AddChild(child.Pass());
|
| +
|
| + 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));
|
| + root()->child_at(0)->ResetReceivedEvents();
|
| +
|
| + // Install an even handler on |child| which always prevents the target from
|
| + // receiving event.
|
| + root()->child_at(0)->SetEventTargeter(
|
| + scoped_ptr<EventTargeter>(new IgnoreEventTargeter()));
|
| + 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_TRUE(root()->DidReceiveEvent(ET_MOUSE_MOVED));
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace ui
|
|
|