| 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/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); | 59 EXPECT_FALSE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); |
| 60 | 60 |
| 61 root()->RemoveChild(root()->child_at(0)); | 61 root()->RemoveChild(root()->child_at(0)); |
| 62 DispatchEvent(&mouse); | 62 DispatchEvent(&mouse); |
| 63 EXPECT_TRUE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); | 63 EXPECT_TRUE(root()->DidReceiveEvent(ET_MOUSE_MOVED)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 template<typename T> | 66 template<typename T> |
| 67 class BoundsEventTargeter : public EventTargeter { | 67 class BoundsEventTargeter : public EventTargeter { |
| 68 public: | 68 public: |
| 69 virtual ~BoundsEventTargeter() {} | 69 ~BoundsEventTargeter() override {} |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 virtual bool SubtreeShouldBeExploredForEvent( | 72 bool SubtreeShouldBeExploredForEvent( |
| 73 EventTarget* target, const LocatedEvent& event) override { | 73 EventTarget* target, const LocatedEvent& event) override { |
| 74 T* t = static_cast<T*>(target); | 74 T* t = static_cast<T*>(target); |
| 75 return (t->bounds().Contains(event.location())); | 75 return (t->bounds().Contains(event.location())); |
| 76 } | 76 } |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class BoundsTestTarget : public TestEventTarget { | 79 class BoundsTestTarget : public TestEventTarget { |
| 80 public: | 80 public: |
| 81 BoundsTestTarget() {} | 81 BoundsTestTarget() {} |
| 82 ~BoundsTestTarget() override {} | 82 ~BoundsTestTarget() override {} |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 DispatchEvent(&mouse); | 515 DispatchEvent(&mouse); |
| 516 | 516 |
| 517 std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC", | 517 std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC", |
| 518 "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" }; | 518 "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" }; |
| 519 EXPECT_EQ(std::vector<std::string>( | 519 EXPECT_EQ(std::vector<std::string>( |
| 520 expected, expected + arraysize(expected)), recorder); | 520 expected, expected + arraysize(expected)), recorder); |
| 521 } | 521 } |
| 522 | 522 |
| 523 } // namespace test | 523 } // namespace test |
| 524 } // namespace ui | 524 } // namespace ui |
| OLD | NEW |