OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/platform/platform_event_source.h" | 5 #include "ui/events/platform/platform_event_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // Tests that resetting an overridden dispatcher causes the nested message-loop | 594 // Tests that resetting an overridden dispatcher causes the nested message-loop |
595 // iteration to stop and the rest of the events are dispatched in the next | 595 // iteration to stop and the rest of the events are dispatched in the next |
596 // iteration. | 596 // iteration. |
597 class DestroyedNestedOverriddenDispatcherQuitsNestedLoopIteration | 597 class DestroyedNestedOverriddenDispatcherQuitsNestedLoopIteration |
598 : public PlatformEventTestWithMessageLoop { | 598 : public PlatformEventTestWithMessageLoop { |
599 public: | 599 public: |
600 void NestedTask(std::vector<int>* list, | 600 void NestedTask(std::vector<int>* list, |
601 TestPlatformEventDispatcher* dispatcher) { | 601 TestPlatformEventDispatcher* dispatcher) { |
602 ScopedVector<PlatformEvent> events; | 602 ScopedVector<PlatformEvent> events; |
603 scoped_ptr<PlatformEvent> event(CreatePlatformEvent()); | 603 scoped_ptr<PlatformEvent> event(CreatePlatformEvent()); |
604 events.push_back(event.release()); | 604 events.push_back(event.Pass()); |
605 event = CreatePlatformEvent(); | 605 event = CreatePlatformEvent(); |
606 events.push_back(event.release()); | 606 events.push_back(event.Pass()); |
607 | 607 |
608 // Attempt to dispatch a couple of events. Dispatching the first event will | 608 // Attempt to dispatch a couple of events. Dispatching the first event will |
609 // have terminated the ScopedEventDispatcher object, which will terminate | 609 // have terminated the ScopedEventDispatcher object, which will terminate |
610 // the current iteration of the message-loop. | 610 // the current iteration of the message-loop. |
611 size_t count = source()->DispatchEventStream(events); | 611 size_t count = source()->DispatchEventStream(events); |
612 EXPECT_EQ(1u, count); | 612 EXPECT_EQ(1u, count); |
613 ASSERT_EQ(2u, list->size()); | 613 ASSERT_EQ(2u, list->size()); |
614 EXPECT_EQ(15, (*list)[0]); | 614 EXPECT_EQ(15, (*list)[0]); |
615 EXPECT_EQ(20, (*list)[1]); | 615 EXPECT_EQ(20, (*list)[1]); |
616 list->clear(); | 616 list->clear(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 ASSERT_EQ(2u, list.size()); | 768 ASSERT_EQ(2u, list.size()); |
769 EXPECT_EQ(15, list[0]); | 769 EXPECT_EQ(15, list[0]); |
770 EXPECT_EQ(10, list[1]); | 770 EXPECT_EQ(10, list[1]); |
771 } | 771 } |
772 }; | 772 }; |
773 | 773 |
774 RUN_TEST_IN_MESSAGE_LOOP( | 774 RUN_TEST_IN_MESSAGE_LOOP( |
775 ConsecutiveOverriddenDispatcherInTheSameMessageLoopIteration) | 775 ConsecutiveOverriddenDispatcherInTheSameMessageLoopIteration) |
776 | 776 |
777 } // namespace ui | 777 } // namespace ui |
OLD | NEW |