| OLD | NEW |
| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 template<typename T> | 60 template<typename T> |
| 61 class BoundsEventTargeter : public EventTargeter { | 61 class BoundsEventTargeter : public EventTargeter { |
| 62 public: | 62 public: |
| 63 virtual ~BoundsEventTargeter() {} | 63 virtual ~BoundsEventTargeter() {} |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 virtual bool SubtreeShouldBeExploredForEvent( | 66 virtual bool SubtreeShouldBeExploredForEvent( |
| 67 EventTarget* target, const LocatedEvent& event) OVERRIDE { | 67 EventTarget* target, const LocatedEvent& event) OVERRIDE { |
| 68 T* t = static_cast<T*>(target); | 68 T* t = static_cast<T*>(target); |
| 69 return (t->bounds().Contains(event.location())); | 69 return (t->bounds().Contains(gfx::ToFlooredPoint(event.location()))); |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class BoundsTestTarget : public TestEventTarget { | 73 class BoundsTestTarget : public TestEventTarget { |
| 74 public: | 74 public: |
| 75 BoundsTestTarget() {} | 75 BoundsTestTarget() {} |
| 76 virtual ~BoundsTestTarget() {} | 76 virtual ~BoundsTestTarget() {} |
| 77 | 77 |
| 78 void set_bounds(gfx::Rect rect) { bounds_ = rect; } | 78 void set_bounds(gfx::Rect rect) { bounds_ = rect; } |
| 79 gfx::Rect bounds() const { return bounds_; } | 79 gfx::Rect bounds() const { return bounds_; } |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 DispatchEvent(&mouse); | 365 DispatchEvent(&mouse); |
| 366 | 366 |
| 367 std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC", | 367 std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC", |
| 368 "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" }; | 368 "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" }; |
| 369 EXPECT_EQ(std::vector<std::string>( | 369 EXPECT_EQ(std::vector<std::string>( |
| 370 expected, expected + arraysize(expected)), recorder); | 370 expected, expected + arraysize(expected)), recorder); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace test | 373 } // namespace test |
| 374 } // namespace ui | 374 } // namespace ui |
| OLD | NEW |