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

Side by Side Diff: ui/events/event_rewriter_unittest.cc

Issue 519113002: Do not mutate ui::Event properties during nested event processing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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/event_rewriter.h" 5 #include "ui/events/event_rewriter.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/events/test/test_event_processor.h" 13 #include "ui/events/test/test_event_processor.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 namespace { 17 namespace {
18 18
19 // To test the handling of |EventRewriter|s through |EventSource|, 19 // To test the handling of |EventRewriter|s through |EventSource|,
20 // we rewrite and test event types. 20 // we rewrite and test event types.
21 class TestEvent : public Event { 21 class TestEvent : public Event {
22 public: 22 public:
23 explicit TestEvent(EventType type) 23 explicit TestEvent(EventType type)
24 : Event(type, base::TimeDelta(), 0), unique_id_(next_unique_id_++) {} 24 : Event(type, base::TimeDelta(), 0), unique_id_(next_unique_id_++) {}
25 virtual ~TestEvent() {} 25 virtual ~TestEvent() {}
26 int unique_id() const { return unique_id_; } 26 int unique_id() const { return unique_id_; }
27 27
28 // Event:
29 virtual scoped_ptr<Event> Clone() const OVERRIDE {
30 return scoped_ptr<Event>(new TestEvent(*this));
31 }
32
28 private: 33 private:
29 static int next_unique_id_; 34 static int next_unique_id_;
30 int unique_id_; 35 int unique_id_;
31 }; 36 };
32 37
33 int TestEvent::next_unique_id_ = 0; 38 int TestEvent::next_unique_id_ = 0;
34 39
35 // TestEventRewriteProcessor is set up with a sequence of event types, 40 // TestEventRewriteProcessor is set up with a sequence of event types,
36 // and fails if the events received via OnEventFromSource() do not match 41 // and fails if the events received via OnEventFromSource() do not match
37 // this sequence. These expected event types are consumed on receipt. 42 // this sequence. These expected event types are consumed on receipt.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 s.RemoveEventRewriter(&r3); 227 s.RemoveEventRewriter(&r3);
223 228
224 // Continue with the state-based rewriting. 229 // Continue with the state-based rewriting.
225 p.AddExpectedEvent(ET_MOUSE_RELEASED); 230 p.AddExpectedEvent(ET_MOUSE_RELEASED);
226 p.AddExpectedEvent(ET_KEY_RELEASED); 231 p.AddExpectedEvent(ET_KEY_RELEASED);
227 s.Send(ET_MOUSE_RELEASED); 232 s.Send(ET_MOUSE_RELEASED);
228 p.CheckAllReceived(); 233 p.CheckAllReceived();
229 } 234 }
230 235
231 } // namespace ui 236 } // namespace ui
OLDNEW
« ui/events/event_processor.cc ('K') | « ui/events/event_processor_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698