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/aura/event_filter.h" | 5 #include "ui/aura/event_filter.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // +- w11 | 85 // +- w11 |
86 // +- w111 (EF) | 86 // +- w111 (EF) |
87 // +- w1111 <-- target window | 87 // +- w1111 <-- target window |
88 TEST_F(EventFilterTest, Basic) { | 88 TEST_F(EventFilterTest, Basic) { |
89 scoped_ptr<Window> w1(CreateWindow(1, RootWindow::GetInstance(), NULL)); | 89 scoped_ptr<Window> w1(CreateWindow(1, RootWindow::GetInstance(), NULL)); |
90 scoped_ptr<Window> w11(CreateWindow(11, w1.get(), NULL)); | 90 scoped_ptr<Window> w11(CreateWindow(11, w1.get(), NULL)); |
91 scoped_ptr<Window> w111(CreateWindow(111, w11.get(), NULL)); | 91 scoped_ptr<Window> w111(CreateWindow(111, w11.get(), NULL)); |
92 TestEventFilterWindowDelegate* d1111 = new TestEventFilterWindowDelegate; | 92 TestEventFilterWindowDelegate* d1111 = new TestEventFilterWindowDelegate; |
93 scoped_ptr<Window> w1111(CreateWindow(1111, w111.get(), d1111)); | 93 scoped_ptr<Window> w1111(CreateWindow(1111, w111.get(), d1111)); |
94 | 94 |
95 TestEventFilter* root_window_filter = | 95 TestEventFilter* root_window_filter = new TestEventFilter; |
96 new TestEventFilter(RootWindow::GetInstance()); | 96 TestEventFilter* w1_filter = new TestEventFilter; |
97 TestEventFilter* w1_filter = new TestEventFilter(w1.get()); | 97 TestEventFilter* w111_filter = new TestEventFilter; |
98 TestEventFilter* w111_filter = new TestEventFilter(w111.get()); | |
99 RootWindow::GetInstance()->SetEventFilter(root_window_filter); | 98 RootWindow::GetInstance()->SetEventFilter(root_window_filter); |
100 w1->SetEventFilter(w1_filter); | 99 w1->SetEventFilter(w1_filter); |
101 w111->SetEventFilter(w111_filter); | 100 w111->SetEventFilter(w111_filter); |
102 | 101 |
103 w1111->GetFocusManager()->SetFocusedWindow(w1111.get()); | 102 w1111->GetFocusManager()->SetFocusedWindow(w1111.get()); |
104 | 103 |
105 // To start with, no one is going to consume any events. All three filters | 104 // To start with, no one is going to consume any events. All three filters |
106 // and the w1111's delegate should receive the event. | 105 // and the w1111's delegate should receive the event. |
107 EventGenerator generator(w1111.get()); | 106 EventGenerator generator(w1111.get()); |
108 generator.PressLeftButton(); | 107 generator.PressLeftButton(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 EXPECT_EQ(0, w111_filter->mouse_event_count()); | 144 EXPECT_EQ(0, w111_filter->mouse_event_count()); |
146 EXPECT_EQ(0, d1111->mouse_event_count()); | 145 EXPECT_EQ(0, d1111->mouse_event_count()); |
147 EXPECT_EQ(0, root_window_filter->touch_event_count()); | 146 EXPECT_EQ(0, root_window_filter->touch_event_count()); |
148 EXPECT_EQ(0, w1_filter->touch_event_count()); | 147 EXPECT_EQ(0, w1_filter->touch_event_count()); |
149 EXPECT_EQ(0, w111_filter->touch_event_count()); | 148 EXPECT_EQ(0, w111_filter->touch_event_count()); |
150 EXPECT_EQ(0, d1111->touch_event_count()); | 149 EXPECT_EQ(0, d1111->touch_event_count()); |
151 } | 150 } |
152 | 151 |
153 } // namespace test | 152 } // namespace test |
154 } // namespace aura | 153 } // namespace aura |
OLD | NEW |