Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: ui/events/event_processor_unittest.cc

Issue 623293004: replace OVERRIDE and FINAL with override and final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/event_dispatcher_unittest.cc ('k') | ui/events/event_rewriter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_targeter.h" 9 #include "ui/events/event_targeter.h"
10 #include "ui/events/test/events_test_utils.h" 10 #include "ui/events/test/events_test_utils.h"
11 #include "ui/events/test/test_event_handler.h" 11 #include "ui/events/test/test_event_handler.h"
12 #include "ui/events/test/test_event_processor.h" 12 #include "ui/events/test/test_event_processor.h"
13 #include "ui/events/test/test_event_target.h" 13 #include "ui/events/test/test_event_target.h"
14 14
15 typedef std::vector<std::string> HandlerSequenceRecorder; 15 typedef std::vector<std::string> HandlerSequenceRecorder;
16 16
17 namespace ui { 17 namespace ui {
18 namespace test { 18 namespace test {
19 19
20 class EventProcessorTest : public testing::Test { 20 class EventProcessorTest : public testing::Test {
21 public: 21 public:
22 EventProcessorTest() {} 22 EventProcessorTest() {}
23 virtual ~EventProcessorTest() {} 23 virtual ~EventProcessorTest() {}
24 24
25 // testing::Test: 25 // testing::Test:
26 virtual void SetUp() OVERRIDE { 26 virtual void SetUp() override {
27 processor_.SetRoot(scoped_ptr<EventTarget>(new TestEventTarget())); 27 processor_.SetRoot(scoped_ptr<EventTarget>(new TestEventTarget()));
28 processor_.Reset(); 28 processor_.Reset();
29 root()->SetEventTargeter(make_scoped_ptr(new EventTargeter())); 29 root()->SetEventTargeter(make_scoped_ptr(new EventTargeter()));
30 } 30 }
31 31
32 TestEventTarget* root() { 32 TestEventTarget* root() {
33 return static_cast<TestEventTarget*>(processor_.GetRootTarget()); 33 return static_cast<TestEventTarget*>(processor_.GetRootTarget());
34 } 34 }
35 35
36 TestEventProcessor* processor() { 36 TestEventProcessor* processor() {
(...skipping 25 matching lines...) Expand all
62 EXPECT_TRUE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); 62 EXPECT_TRUE(root()->DidReceiveEvent(ET_MOUSE_MOVED));
63 } 63 }
64 64
65 template<typename T> 65 template<typename T>
66 class BoundsEventTargeter : public EventTargeter { 66 class BoundsEventTargeter : public EventTargeter {
67 public: 67 public:
68 virtual ~BoundsEventTargeter() {} 68 virtual ~BoundsEventTargeter() {}
69 69
70 protected: 70 protected:
71 virtual bool SubtreeShouldBeExploredForEvent( 71 virtual bool SubtreeShouldBeExploredForEvent(
72 EventTarget* target, const LocatedEvent& event) OVERRIDE { 72 EventTarget* target, const LocatedEvent& event) override {
73 T* t = static_cast<T*>(target); 73 T* t = static_cast<T*>(target);
74 return (t->bounds().Contains(event.location())); 74 return (t->bounds().Contains(event.location()));
75 } 75 }
76 }; 76 };
77 77
78 class BoundsTestTarget : public TestEventTarget { 78 class BoundsTestTarget : public TestEventTarget {
79 public: 79 public:
80 BoundsTestTarget() {} 80 BoundsTestTarget() {}
81 virtual ~BoundsTestTarget() {} 81 virtual ~BoundsTestTarget() {}
82 82
(...skipping 17 matching lines...) Expand all
100 } 100 }
101 *location += vector; 101 *location += vector;
102 } else { 102 } else {
103 NOTREACHED(); 103 NOTREACHED();
104 } 104 }
105 } 105 }
106 106
107 private: 107 private:
108 // EventTarget: 108 // EventTarget:
109 virtual void ConvertEventToTarget(EventTarget* target, 109 virtual void ConvertEventToTarget(EventTarget* target,
110 LocatedEvent* event) OVERRIDE { 110 LocatedEvent* event) override {
111 event->ConvertLocationToTarget(this, 111 event->ConvertLocationToTarget(this,
112 static_cast<BoundsTestTarget*>(target)); 112 static_cast<BoundsTestTarget*>(target));
113 } 113 }
114 114
115 gfx::Rect bounds_; 115 gfx::Rect bounds_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(BoundsTestTarget); 117 DISALLOW_COPY_AND_ASSIGN(BoundsTestTarget);
118 }; 118 };
119 119
120 TEST_F(EventProcessorTest, Bounds) { 120 TEST_F(EventProcessorTest, Bounds) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // target and phase both before and after the nested event processing. Also 178 // target and phase both before and after the nested event processing. Also
179 // verifies that the location of the event remains the same after it has 179 // verifies that the location of the event remains the same after it has
180 // been processed by the second EventProcessor. 180 // been processed by the second EventProcessor.
181 class ReDispatchEventHandler : public TestEventHandler { 181 class ReDispatchEventHandler : public TestEventHandler {
182 public: 182 public:
183 ReDispatchEventHandler(EventProcessor* processor, EventTarget* target) 183 ReDispatchEventHandler(EventProcessor* processor, EventTarget* target)
184 : processor_(processor), expected_target_(target) {} 184 : processor_(processor), expected_target_(target) {}
185 virtual ~ReDispatchEventHandler() {} 185 virtual ~ReDispatchEventHandler() {}
186 186
187 // TestEventHandler: 187 // TestEventHandler:
188 virtual void OnMouseEvent(MouseEvent* event) OVERRIDE { 188 virtual void OnMouseEvent(MouseEvent* event) override {
189 TestEventHandler::OnMouseEvent(event); 189 TestEventHandler::OnMouseEvent(event);
190 190
191 EXPECT_EQ(expected_target_, event->target()); 191 EXPECT_EQ(expected_target_, event->target());
192 EXPECT_EQ(EP_TARGET, event->phase()); 192 EXPECT_EQ(EP_TARGET, event->phase());
193 193
194 gfx::Point location(event->location()); 194 gfx::Point location(event->location());
195 EventDispatchDetails details = processor_->OnEventFromSource(event); 195 EventDispatchDetails details = processor_->OnEventFromSource(event);
196 EXPECT_FALSE(details.dispatcher_destroyed); 196 EXPECT_FALSE(details.dispatcher_destroyed);
197 EXPECT_FALSE(details.target_destroyed); 197 EXPECT_FALSE(details.target_destroyed);
198 198
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 321
322 class IgnoreEventTargeter : public EventTargeter { 322 class IgnoreEventTargeter : public EventTargeter {
323 public: 323 public:
324 IgnoreEventTargeter() {} 324 IgnoreEventTargeter() {}
325 virtual ~IgnoreEventTargeter() {} 325 virtual ~IgnoreEventTargeter() {}
326 326
327 private: 327 private:
328 // EventTargeter: 328 // EventTargeter:
329 virtual bool SubtreeShouldBeExploredForEvent( 329 virtual bool SubtreeShouldBeExploredForEvent(
330 EventTarget* target, const LocatedEvent& event) OVERRIDE { 330 EventTarget* target, const LocatedEvent& event) override {
331 return false; 331 return false;
332 } 332 }
333 }; 333 };
334 334
335 // Verifies that the EventTargeter installed on an EventTarget can dictate 335 // Verifies that the EventTargeter installed on an EventTarget can dictate
336 // whether the target itself can process an event. 336 // whether the target itself can process an event.
337 TEST_F(EventProcessorTest, TargeterChecksOwningEventTarget) { 337 TEST_F(EventProcessorTest, TargeterChecksOwningEventTarget) {
338 scoped_ptr<TestEventTarget> child(new TestEventTarget()); 338 scoped_ptr<TestEventTarget> child(new TestEventTarget());
339 root()->AddChild(child.Pass()); 339 root()->AddChild(child.Pass());
340 340
(...skipping 21 matching lines...) Expand all
362 // specified by FindNextBestTarget(). 362 // specified by FindNextBestTarget().
363 class BubblingEventTargeter : public EventTargeter { 363 class BubblingEventTargeter : public EventTargeter {
364 public: 364 public:
365 explicit BubblingEventTargeter(TestEventTarget* initial_target) 365 explicit BubblingEventTargeter(TestEventTarget* initial_target)
366 : initial_target_(initial_target) {} 366 : initial_target_(initial_target) {}
367 virtual ~BubblingEventTargeter() {} 367 virtual ~BubblingEventTargeter() {}
368 368
369 private: 369 private:
370 // EventTargeter: 370 // EventTargeter:
371 virtual EventTarget* FindTargetForEvent(EventTarget* root, 371 virtual EventTarget* FindTargetForEvent(EventTarget* root,
372 Event* event) OVERRIDE { 372 Event* event) override {
373 return initial_target_; 373 return initial_target_;
374 } 374 }
375 375
376 virtual EventTarget* FindNextBestTarget(EventTarget* previous_target, 376 virtual EventTarget* FindNextBestTarget(EventTarget* previous_target,
377 Event* event) OVERRIDE { 377 Event* event) override {
378 return previous_target->GetParentTarget(); 378 return previous_target->GetParentTarget();
379 } 379 }
380 380
381 TestEventTarget* initial_target_; 381 TestEventTarget* initial_target_;
382 382
383 DISALLOW_COPY_AND_ASSIGN(BubblingEventTargeter); 383 DISALLOW_COPY_AND_ASSIGN(BubblingEventTargeter);
384 }; 384 };
385 385
386 // Tests that unhandled events are correctly dispatched to the next-best 386 // Tests that unhandled events are correctly dispatched to the next-best
387 // target as decided by the BubblingEventTargeter. 387 // target as decided by the BubblingEventTargeter.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 DispatchEvent(&mouse); 516 DispatchEvent(&mouse);
517 517
518 std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC", 518 std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC",
519 "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" }; 519 "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" };
520 EXPECT_EQ(std::vector<std::string>( 520 EXPECT_EQ(std::vector<std::string>(
521 expected, expected + arraysize(expected)), recorder); 521 expected, expected + arraysize(expected)), recorder);
522 } 522 }
523 523
524 } // namespace test 524 } // namespace test
525 } // namespace ui 525 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_dispatcher_unittest.cc ('k') | ui/events/event_rewriter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698