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

Side by Side Diff: ui/events/platform/platform_event_source_unittest.cc

Issue 667823002: PlatformEventDispatcher::DispatchEvent() should return a PostDispatchAction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ui_enums
Patch Set: Fix platform_event_source_unittest.cc 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/platform/platform_event_dispatcher.h ('k') | ui/gl/gl_surface_glx.h » ('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 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 : id_(id), 80 : id_(id),
81 list_(list), 81 list_(list),
82 post_dispatch_action_(POST_DISPATCH_NONE), 82 post_dispatch_action_(POST_DISPATCH_NONE),
83 stop_stream_(false) { 83 stop_stream_(false) {
84 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 84 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
85 } 85 }
86 virtual ~TestPlatformEventDispatcher() { 86 virtual ~TestPlatformEventDispatcher() {
87 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); 87 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
88 } 88 }
89 89
90 void set_post_dispatch_action(uint32_t action) { 90 void set_post_dispatch_action(ui::PostDispatchAction action) {
91 post_dispatch_action_ = action; 91 post_dispatch_action_ = action;
92 } 92 }
93 93
94 protected: 94 protected:
95 // PlatformEventDispatcher: 95 // PlatformEventDispatcher:
96 virtual bool CanDispatchEvent(const PlatformEvent& event) override { 96 virtual bool CanDispatchEvent(const PlatformEvent& event) override {
97 return true; 97 return true;
98 } 98 }
99 99
100 virtual uint32_t DispatchEvent(const PlatformEvent& event) override { 100 virtual ui::PostDispatchAction DispatchEvent(
101 const PlatformEvent& event) override {
101 list_->push_back(id_); 102 list_->push_back(id_);
102 return post_dispatch_action_; 103 return post_dispatch_action_;
103 } 104 }
104 105
105 private: 106 private:
106 int id_; 107 int id_;
107 std::vector<int>* list_; 108 std::vector<int>* list_;
108 uint32_t post_dispatch_action_; 109 ui::PostDispatchAction post_dispatch_action_;
109 bool stop_stream_; 110 bool stop_stream_;
110 111
111 DISALLOW_COPY_AND_ASSIGN(TestPlatformEventDispatcher); 112 DISALLOW_COPY_AND_ASSIGN(TestPlatformEventDispatcher);
112 }; 113 };
113 114
114 class TestPlatformEventObserver : public PlatformEventObserver { 115 class TestPlatformEventObserver : public PlatformEventObserver {
115 public: 116 public:
116 TestPlatformEventObserver(int id, std::vector<int>* list) 117 TestPlatformEventObserver(int id, std::vector<int>* list)
117 : id_(id), list_(list) { 118 : id_(id), list_(list) {
118 PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); 119 PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 RunCallbackDuringDispatch(int id, std::vector<int>* list) 336 RunCallbackDuringDispatch(int id, std::vector<int>* list)
336 : TestPlatformEventDispatcher(id, list) {} 337 : TestPlatformEventDispatcher(id, list) {}
337 virtual ~RunCallbackDuringDispatch() {} 338 virtual ~RunCallbackDuringDispatch() {}
338 339
339 void set_callback(const base::Closure& callback) { 340 void set_callback(const base::Closure& callback) {
340 callback_ = callback; 341 callback_ = callback;
341 } 342 }
342 343
343 protected: 344 protected:
344 // PlatformEventDispatcher: 345 // PlatformEventDispatcher:
345 virtual uint32_t DispatchEvent(const PlatformEvent& event) override { 346 virtual ui::PostDispatchAction DispatchEvent(
347 const PlatformEvent& event) override {
346 if (!callback_.is_null()) 348 if (!callback_.is_null())
347 callback_.Run(); 349 callback_.Run();
348 return TestPlatformEventDispatcher::DispatchEvent(event); 350 return TestPlatformEventDispatcher::DispatchEvent(event);
349 } 351 }
350 352
351 private: 353 private:
352 base::Closure callback_; 354 base::Closure callback_;
353 355
354 DISALLOW_COPY_AND_ASSIGN(RunCallbackDuringDispatch); 356 DISALLOW_COPY_AND_ASSIGN(RunCallbackDuringDispatch);
355 }; 357 };
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 void set_callback(const base::Closure& callback) { 580 void set_callback(const base::Closure& callback) {
579 callback_ = callback; 581 callback_ = callback;
580 } 582 }
581 583
582 private: 584 private:
583 // PlatformEventDispatcher: 585 // PlatformEventDispatcher:
584 virtual bool CanDispatchEvent(const PlatformEvent& event) override { 586 virtual bool CanDispatchEvent(const PlatformEvent& event) override {
585 return true; 587 return true;
586 } 588 }
587 589
588 virtual uint32_t DispatchEvent(const PlatformEvent& event) override { 590 virtual ui::PostDispatchAction DispatchEvent(
591 const PlatformEvent& event) override {
589 handler_.reset(); 592 handler_.reset();
590 uint32_t action = TestPlatformEventDispatcher::DispatchEvent(event); 593 ui::PostDispatchAction action =
594 TestPlatformEventDispatcher::DispatchEvent(event);
591 if (!callback_.is_null()) { 595 if (!callback_.is_null()) {
592 callback_.Run(); 596 callback_.Run();
593 callback_ = base::Closure(); 597 callback_ = base::Closure();
594 } 598 }
595 return action; 599 return action;
596 } 600 }
597 601
598 scoped_ptr<ScopedEventDispatcher> handler_; 602 scoped_ptr<ScopedEventDispatcher> handler_;
599 base::Closure callback_; 603 base::Closure callback_;
600 604
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 ASSERT_EQ(2u, list.size()); 782 ASSERT_EQ(2u, list.size());
779 EXPECT_EQ(15, list[0]); 783 EXPECT_EQ(15, list[0]);
780 EXPECT_EQ(10, list[1]); 784 EXPECT_EQ(10, list[1]);
781 } 785 }
782 }; 786 };
783 787
784 RUN_TEST_IN_MESSAGE_LOOP( 788 RUN_TEST_IN_MESSAGE_LOOP(
785 ConsecutiveOverriddenDispatcherInTheSameMessageLoopIteration) 789 ConsecutiveOverriddenDispatcherInTheSameMessageLoopIteration)
786 790
787 } // namespace ui 791 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/platform/platform_event_dispatcher.h ('k') | ui/gl/gl_surface_glx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698