| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/events/event_dispatcher.h" | 5 #include "ui/events/event_dispatcher.h" |
| 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_dispatcher.h" | 9 #include "ui/events/event_dispatcher.h" |
| 10 #include "ui/events/event_target.h" | 10 #include "ui/events/event_target.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 class NonCancelableEvent : public Event { | 119 class NonCancelableEvent : public Event { |
| 120 public: | 120 public: |
| 121 NonCancelableEvent() | 121 NonCancelableEvent() |
| 122 : Event(ui::ET_CANCEL_MODE, ui::EventTimeForNow(), 0) { | 122 : Event(ui::ET_CANCEL_MODE, ui::EventTimeForNow(), 0) { |
| 123 set_cancelable(false); | 123 set_cancelable(false); |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual ~NonCancelableEvent() {} | 126 virtual ~NonCancelableEvent() {} |
| 127 | 127 |
| 128 private: | 128 // Event: |
| 129 DISALLOW_COPY_AND_ASSIGN(NonCancelableEvent); | 129 virtual scoped_ptr<Event> Clone() const OVERRIDE { |
| 130 return scoped_ptr<Event>(new NonCancelableEvent(*this)); |
| 131 } |
| 130 }; | 132 }; |
| 131 | 133 |
| 132 // Destroys the dispatcher-delegate when it receives any event. | 134 // Destroys the dispatcher-delegate when it receives any event. |
| 133 class EventHandlerDestroyDispatcherDelegate : public TestEventHandler { | 135 class EventHandlerDestroyDispatcherDelegate : public TestEventHandler { |
| 134 public: | 136 public: |
| 135 EventHandlerDestroyDispatcherDelegate(EventDispatcherDelegate* delegate, | 137 EventHandlerDestroyDispatcherDelegate(EventDispatcherDelegate* delegate, |
| 136 int id) | 138 int id) |
| 137 : TestEventHandler(id), | 139 : TestEventHandler(id), |
| 138 dispatcher_delegate_(delegate) { | 140 dispatcher_delegate_(delegate) { |
| 139 } | 141 } |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 NonCancelableEvent event; | 602 NonCancelableEvent event; |
| 601 EventDispatchDetails details = dispatcher->ProcessEvent(&target, &event); | 603 EventDispatchDetails details = dispatcher->ProcessEvent(&target, &event); |
| 602 EXPECT_TRUE(details.dispatcher_destroyed); | 604 EXPECT_TRUE(details.dispatcher_destroyed); |
| 603 EXPECT_EQ(2U, target.handler_list().size()); | 605 EXPECT_EQ(2U, target.handler_list().size()); |
| 604 EXPECT_EQ(1, target.handler_list()[0]); | 606 EXPECT_EQ(1, target.handler_list()[0]); |
| 605 EXPECT_EQ(2, target.handler_list()[1]); | 607 EXPECT_EQ(2, target.handler_list()[1]); |
| 606 } | 608 } |
| 607 } | 609 } |
| 608 | 610 |
| 609 } // namespace ui | 611 } // namespace ui |
| OLD | NEW |