OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_shell/root_window_event_filter.h" | 5 #include "ui/aura_shell/root_window_event_filter.h" |
6 | 6 |
| 7 #include "ui/aura/client/activation_delegate.h" |
| 8 #include "ui/aura/client/aura_constants.h" |
7 #include "ui/aura/cursor.h" | 9 #include "ui/aura/cursor.h" |
8 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
9 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
10 #include "ui/aura/test/aura_test_base.h" | 12 #include "ui/aura/test/aura_test_base.h" |
11 #include "ui/aura/test/event_generator.h" | 13 #include "ui/aura/test/event_generator.h" |
12 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
13 #include "ui/aura/test/test_event_filter.h" | 15 #include "ui/aura/test/test_event_filter.h" |
14 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
15 #include "ui/aura/test/test_stacking_client.h" | 17 #include "ui/aura/test/test_stacking_client.h" |
| 18 #include "ui/aura_shell/activation_controller.h" |
16 #include "ui/aura_shell/shell_window_ids.h" | 19 #include "ui/aura_shell/shell_window_ids.h" |
| 20 #include "ui/aura_shell/test/test_activation_delegate.h" |
| 21 #include "ui/aura_shell/window_util.h" |
17 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
18 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
19 | 24 |
20 namespace aura_shell { | 25 namespace aura_shell { |
21 namespace test { | 26 namespace test { |
22 | 27 |
23 class RootWindowEventFilterTest : public aura::test::AuraTestBase { | 28 class RootWindowEventFilterTest : public aura::test::AuraTestBase { |
24 public: | 29 public: |
25 RootWindowEventFilterTest() { | 30 RootWindowEventFilterTest() { |
26 aura::RootWindow::GetInstance()->SetEventFilter( | 31 aura::RootWindow::GetInstance()->SetEventFilter( |
27 new internal::RootWindowEventFilter); | 32 new internal::RootWindowEventFilter); |
28 | 33 |
29 aura::test::TestStackingClient* stacking_client = | 34 aura::test::TestStackingClient* stacking_client = |
30 static_cast<aura::test::TestStackingClient*>( | 35 static_cast<aura::test::TestStackingClient*>( |
31 aura::RootWindow::GetInstance()->stacking_client()); | 36 aura::RootWindow::GetInstance()->stacking_client()); |
32 stacking_client->default_container()->set_id( | 37 stacking_client->default_container()->set_id( |
33 internal::kShellWindowId_DefaultContainer); | 38 internal::kShellWindowId_DefaultContainer); |
| 39 activation_controller_.reset(new internal::ActivationController); |
| 40 activation_controller_->set_default_container_for_test( |
| 41 stacking_client->default_container()); |
34 } | 42 } |
35 virtual ~RootWindowEventFilterTest() { | 43 virtual ~RootWindowEventFilterTest() { |
36 aura::RootWindow::GetInstance()->SetEventFilter(NULL); | 44 aura::RootWindow::GetInstance()->SetEventFilter(NULL); |
37 } | 45 } |
38 | 46 |
39 private: | 47 private: |
| 48 scoped_ptr<internal::ActivationController> activation_controller_; |
| 49 |
40 DISALLOW_COPY_AND_ASSIGN(RootWindowEventFilterTest); | 50 DISALLOW_COPY_AND_ASSIGN(RootWindowEventFilterTest); |
41 }; | 51 }; |
42 | 52 |
43 class HitTestWindowDelegate : public aura::test::TestWindowDelegate { | 53 class HitTestWindowDelegate : public aura::test::TestWindowDelegate { |
44 public: | 54 public: |
45 HitTestWindowDelegate() | 55 HitTestWindowDelegate() |
46 : hittest_code_(HTNOWHERE) { | 56 : hittest_code_(HTNOWHERE) { |
47 } | 57 } |
48 virtual ~HitTestWindowDelegate() {} | 58 virtual ~HitTestWindowDelegate() {} |
49 void set_hittest_code(int hittest_code) { hittest_code_ = hittest_code; } | 59 void set_hittest_code(int hittest_code) { hittest_code_ = hittest_code; } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 w12->RemoveChild(w122.get()); | 127 w12->RemoveChild(w122.get()); |
118 EXPECT_EQ(NULL, w122->GetFocusManager()); | 128 EXPECT_EQ(NULL, w122->GetFocusManager()); |
119 EXPECT_EQ(NULL, w12->GetFocusManager()->GetFocusedWindow()); | 129 EXPECT_EQ(NULL, w12->GetFocusManager()->GetFocusedWindow()); |
120 EXPECT_FALSE(root_window->DispatchKeyEvent(&keyev)); | 130 EXPECT_FALSE(root_window->DispatchKeyEvent(&keyev)); |
121 } | 131 } |
122 | 132 |
123 // Various assertion testing for activating windows. | 133 // Various assertion testing for activating windows. |
124 TEST_F(RootWindowEventFilterTest, ActivateOnMouse) { | 134 TEST_F(RootWindowEventFilterTest, ActivateOnMouse) { |
125 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); | 135 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
126 | 136 |
127 aura::test::ActivateWindowDelegate d1; | 137 TestActivationDelegate d1; |
| 138 aura::test::TestWindowDelegate wd; |
128 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 139 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
129 &d1, 1, gfx::Rect(10, 10, 50, 50), NULL)); | 140 &wd, 1, gfx::Rect(10, 10, 50, 50), NULL)); |
130 aura::test::ActivateWindowDelegate d2; | 141 d1.SetWindow(w1.get()); |
| 142 TestActivationDelegate d2; |
131 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( | 143 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( |
132 &d2, 2, gfx::Rect(70, 70, 50, 50), NULL)); | 144 &wd, 2, gfx::Rect(70, 70, 50, 50), NULL)); |
| 145 d2.SetWindow(w2.get()); |
| 146 |
133 aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); | 147 aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); |
134 | 148 |
135 d1.Clear(); | 149 d1.Clear(); |
136 d2.Clear(); | 150 d2.Clear(); |
137 | 151 |
138 // Activate window1. | 152 // Activate window1. |
139 root_window->SetActiveWindow(w1.get(), NULL); | 153 aura_shell::ActivateWindow(w1.get()); |
140 EXPECT_EQ(w1.get(), root_window->active_window()); | 154 EXPECT_TRUE(IsActiveWindow(w1.get())); |
141 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); | 155 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); |
142 EXPECT_EQ(1, d1.activated_count()); | 156 EXPECT_EQ(1, d1.activated_count()); |
143 EXPECT_EQ(0, d1.lost_active_count()); | 157 EXPECT_EQ(0, d1.lost_active_count()); |
144 d1.Clear(); | 158 d1.Clear(); |
145 | 159 |
146 // Click on window2. | 160 { |
147 gfx::Point press_point = w2->bounds().CenterPoint(); | 161 // Click on window2. |
148 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); | 162 gfx::Point press_point = w2->bounds().CenterPoint(); |
149 aura::test::EventGenerator generator(press_point); | 163 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); |
150 generator.ClickLeftButton(); | 164 aura::test::EventGenerator generator(press_point); |
| 165 generator.ClickLeftButton(); |
151 | 166 |
152 // Window2 should have become active. | 167 // Window2 should have become active. |
153 EXPECT_EQ(w2.get(), root_window->active_window()); | 168 EXPECT_TRUE(IsActiveWindow(w2.get())); |
154 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); | 169 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); |
155 EXPECT_EQ(0, d1.activated_count()); | 170 EXPECT_EQ(0, d1.activated_count()); |
156 EXPECT_EQ(1, d1.lost_active_count()); | 171 EXPECT_EQ(1, d1.lost_active_count()); |
157 EXPECT_EQ(1, d2.activated_count()); | 172 EXPECT_EQ(1, d2.activated_count()); |
158 EXPECT_EQ(0, d2.lost_active_count()); | 173 EXPECT_EQ(0, d2.lost_active_count()); |
159 d1.Clear(); | 174 d1.Clear(); |
160 d2.Clear(); | 175 d2.Clear(); |
| 176 } |
161 | 177 |
162 // Click back on window1, but set it up so w1 doesn't activate on click. | 178 { |
163 press_point = w1->bounds().CenterPoint(); | 179 // Click back on window1, but set it up so w1 doesn't activate on click. |
164 aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point); | 180 gfx::Point press_point = w1->bounds().CenterPoint(); |
165 d1.set_activate(false); | 181 aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point); |
166 generator.ClickLeftButton(); | 182 aura::test::EventGenerator generator(press_point); |
| 183 d1.set_activate(false); |
| 184 generator.ClickLeftButton(); |
167 | 185 |
168 // Window2 should still be active and focused. | 186 // Window2 should still be active and focused. |
169 EXPECT_EQ(w2.get(), root_window->active_window()); | 187 EXPECT_TRUE(IsActiveWindow(w2.get())); |
170 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); | 188 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); |
171 EXPECT_EQ(0, d1.activated_count()); | 189 EXPECT_EQ(0, d1.activated_count()); |
172 EXPECT_EQ(0, d1.lost_active_count()); | 190 EXPECT_EQ(0, d1.lost_active_count()); |
173 EXPECT_EQ(0, d2.activated_count()); | 191 EXPECT_EQ(0, d2.activated_count()); |
174 EXPECT_EQ(0, d2.lost_active_count()); | 192 EXPECT_EQ(0, d2.lost_active_count()); |
175 d1.Clear(); | 193 d1.Clear(); |
176 d2.Clear(); | 194 d2.Clear(); |
| 195 } |
177 | 196 |
178 // Destroy window2, this should make window1 active. | 197 // Destroy window2, this should make window1 active. |
179 d1.set_activate(true); | 198 d1.set_activate(true); |
180 w2.reset(); | 199 w2.reset(); |
181 EXPECT_EQ(0, d2.activated_count()); | 200 EXPECT_EQ(0, d2.activated_count()); |
182 EXPECT_EQ(0, d2.lost_active_count()); | 201 EXPECT_EQ(0, d2.lost_active_count()); |
183 EXPECT_EQ(w1.get(), root_window->active_window()); | 202 EXPECT_TRUE(IsActiveWindow(w1.get())); |
184 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); | 203 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); |
185 EXPECT_EQ(1, d1.activated_count()); | 204 EXPECT_EQ(1, d1.activated_count()); |
186 EXPECT_EQ(0, d1.lost_active_count()); | 205 EXPECT_EQ(0, d1.lost_active_count()); |
187 } | 206 } |
188 | 207 |
189 // Essentially the same as ActivateOnMouse, but for touch events. | 208 // Essentially the same as ActivateOnMouse, but for touch events. |
190 TEST_F(RootWindowEventFilterTest, ActivateOnTouch) { | 209 TEST_F(RootWindowEventFilterTest, ActivateOnTouch) { |
191 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); | 210 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
192 | 211 |
193 aura::test::ActivateWindowDelegate d1; | 212 TestActivationDelegate d1; |
| 213 aura::test::TestWindowDelegate wd; |
194 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 214 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
195 &d1, -1, gfx::Rect(10, 10, 50, 50), NULL)); | 215 &wd, -1, gfx::Rect(10, 10, 50, 50), NULL)); |
196 aura::test::ActivateWindowDelegate d2; | 216 d1.SetWindow(w1.get()); |
| 217 TestActivationDelegate d2; |
197 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( | 218 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( |
198 &d2, -2, gfx::Rect(70, 70, 50, 50), NULL)); | 219 &wd, -2, gfx::Rect(70, 70, 50, 50), NULL)); |
| 220 d2.SetWindow(w2.get()); |
| 221 |
199 aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); | 222 aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); |
200 | 223 |
201 d1.Clear(); | 224 d1.Clear(); |
202 d2.Clear(); | 225 d2.Clear(); |
203 | 226 |
204 // Activate window1. | 227 // Activate window1. |
205 root_window->SetActiveWindow(w1.get(), NULL); | 228 aura_shell::ActivateWindow(w1.get()); |
206 EXPECT_EQ(w1.get(), root_window->active_window()); | 229 EXPECT_TRUE(IsActiveWindow(w1.get())); |
207 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); | 230 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); |
208 EXPECT_EQ(1, d1.activated_count()); | 231 EXPECT_EQ(1, d1.activated_count()); |
209 EXPECT_EQ(0, d1.lost_active_count()); | 232 EXPECT_EQ(0, d1.lost_active_count()); |
210 d1.Clear(); | 233 d1.Clear(); |
211 | 234 |
212 // Touch window2. | 235 // Touch window2. |
213 gfx::Point press_point = w2->bounds().CenterPoint(); | 236 gfx::Point press_point = w2->bounds().CenterPoint(); |
214 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); | 237 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); |
215 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0); | 238 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0); |
216 root_window->DispatchTouchEvent(&touchev1); | 239 root_window->DispatchTouchEvent(&touchev1); |
217 | 240 |
218 // Window2 should have become active. | 241 // Window2 should have become active. |
219 EXPECT_EQ(w2.get(), root_window->active_window()); | 242 EXPECT_TRUE(IsActiveWindow(w2.get())); |
220 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); | 243 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); |
221 EXPECT_EQ(0, d1.activated_count()); | 244 EXPECT_EQ(0, d1.activated_count()); |
222 EXPECT_EQ(1, d1.lost_active_count()); | 245 EXPECT_EQ(1, d1.lost_active_count()); |
223 EXPECT_EQ(1, d2.activated_count()); | 246 EXPECT_EQ(1, d2.activated_count()); |
224 EXPECT_EQ(0, d2.lost_active_count()); | 247 EXPECT_EQ(0, d2.lost_active_count()); |
225 d1.Clear(); | 248 d1.Clear(); |
226 d2.Clear(); | 249 d2.Clear(); |
227 | 250 |
228 // Touch window1, but set it up so w1 doesn't activate on touch. | 251 // Touch window1, but set it up so w1 doesn't activate on touch. |
229 press_point = w1->bounds().CenterPoint(); | 252 press_point = w1->bounds().CenterPoint(); |
230 aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point); | 253 aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point); |
231 d1.set_activate(false); | 254 d1.set_activate(false); |
232 aura::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 0); | 255 aura::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 0); |
233 root_window->DispatchTouchEvent(&touchev2); | 256 root_window->DispatchTouchEvent(&touchev2); |
234 | 257 |
235 // Window2 should still be active and focused. | 258 // Window2 should still be active and focused. |
236 EXPECT_EQ(w2.get(), root_window->active_window()); | 259 EXPECT_TRUE(IsActiveWindow(w2.get())); |
237 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); | 260 EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow()); |
238 EXPECT_EQ(0, d1.activated_count()); | 261 EXPECT_EQ(0, d1.activated_count()); |
239 EXPECT_EQ(0, d1.lost_active_count()); | 262 EXPECT_EQ(0, d1.lost_active_count()); |
240 EXPECT_EQ(0, d2.activated_count()); | 263 EXPECT_EQ(0, d2.activated_count()); |
241 EXPECT_EQ(0, d2.lost_active_count()); | 264 EXPECT_EQ(0, d2.lost_active_count()); |
242 d1.Clear(); | 265 d1.Clear(); |
243 d2.Clear(); | 266 d2.Clear(); |
244 | 267 |
245 // Destroy window2, this should make window1 active. | 268 // Destroy window2, this should make window1 active. |
246 d1.set_activate(true); | 269 d1.set_activate(true); |
247 w2.reset(); | 270 w2.reset(); |
248 EXPECT_EQ(0, d2.activated_count()); | 271 EXPECT_EQ(0, d2.activated_count()); |
249 EXPECT_EQ(0, d2.lost_active_count()); | 272 EXPECT_EQ(0, d2.lost_active_count()); |
250 EXPECT_EQ(w1.get(), root_window->active_window()); | 273 EXPECT_TRUE(IsActiveWindow(w1.get())); |
251 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); | 274 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); |
252 EXPECT_EQ(1, d1.activated_count()); | 275 EXPECT_EQ(1, d1.activated_count()); |
253 EXPECT_EQ(0, d1.lost_active_count()); | 276 EXPECT_EQ(0, d1.lost_active_count()); |
254 } | 277 } |
255 | 278 |
256 TEST_F(RootWindowEventFilterTest, MouseEventCursors) { | 279 TEST_F(RootWindowEventFilterTest, MouseEventCursors) { |
257 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); | 280 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
258 | 281 |
259 // Create a window. | 282 // Create a window. |
260 const int kWindowLeft = 123; | 283 const int kWindowLeft = 123; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 gfx::Size size = root_window->GetHostSize(); | 345 gfx::Size size = root_window->GetHostSize(); |
323 EXPECT_EQ(gfx::Rect(size), | 346 EXPECT_EQ(gfx::Rect(size), |
324 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); | 347 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point())); |
325 | 348 |
326 // Rotate it clock-wise 90 degrees. | 349 // Rotate it clock-wise 90 degrees. |
327 ui::Transform transform; | 350 ui::Transform transform; |
328 transform.SetRotate(90.0f); | 351 transform.SetRotate(90.0f); |
329 transform.ConcatTranslate(size.width(), 0); | 352 transform.ConcatTranslate(size.width(), 0); |
330 root_window->SetTransform(transform); | 353 root_window->SetTransform(transform); |
331 | 354 |
332 aura::test::ActivateWindowDelegate d1; | 355 TestActivationDelegate d1; |
| 356 aura::test::TestWindowDelegate wd; |
333 scoped_ptr<aura::Window> w1( | 357 scoped_ptr<aura::Window> w1( |
334 CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL)); | 358 CreateTestWindowWithDelegate(&wd, 1, gfx::Rect(0, 10, 50, 50), NULL)); |
| 359 d1.SetWindow(w1.get()); |
335 w1->Show(); | 360 w1->Show(); |
336 | 361 |
337 gfx::Point miss_point(5, 5); | 362 gfx::Point miss_point(5, 5); |
338 transform.TransformPoint(miss_point); | 363 transform.TransformPoint(miss_point); |
339 aura::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, | 364 aura::MouseEvent mouseev1(ui::ET_MOUSE_PRESSED, |
340 miss_point, | 365 miss_point, |
341 ui::EF_LEFT_BUTTON_DOWN); | 366 ui::EF_LEFT_BUTTON_DOWN); |
342 root_window->DispatchMouseEvent(&mouseev1); | 367 root_window->DispatchMouseEvent(&mouseev1); |
343 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); | 368 EXPECT_FALSE(w1->GetFocusManager()->GetFocusedWindow()); |
344 aura::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, | 369 aura::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
345 miss_point, | 370 miss_point, |
346 ui::EF_LEFT_BUTTON_DOWN); | 371 ui::EF_LEFT_BUTTON_DOWN); |
347 root_window->DispatchMouseEvent(&mouseup); | 372 root_window->DispatchMouseEvent(&mouseup); |
348 | 373 |
349 gfx::Point hit_point(5, 15); | 374 gfx::Point hit_point(5, 15); |
350 transform.TransformPoint(hit_point); | 375 transform.TransformPoint(hit_point); |
351 aura::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, | 376 aura::MouseEvent mouseev2(ui::ET_MOUSE_PRESSED, |
352 hit_point, | 377 hit_point, |
353 ui::EF_LEFT_BUTTON_DOWN); | 378 ui::EF_LEFT_BUTTON_DOWN); |
354 root_window->DispatchMouseEvent(&mouseev2); | 379 root_window->DispatchMouseEvent(&mouseev2); |
355 EXPECT_EQ(w1.get(), root_window->active_window()); | 380 EXPECT_TRUE(IsActiveWindow(w1.get())); |
356 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); | 381 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); |
357 } | 382 } |
358 | 383 |
359 TEST_F(RootWindowEventFilterTest, AdditionalFilters) { | 384 TEST_F(RootWindowEventFilterTest, AdditionalFilters) { |
360 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); | 385 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
361 | 386 |
362 // Creates a window and make it active | 387 // Creates a window and make it active |
363 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindow( | 388 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindow( |
364 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100), NULL)); | 389 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100), NULL)); |
365 root_window->SetActiveWindow(w1.get(), NULL); | 390 aura_shell::ActivateWindow(w1.get()); |
366 | 391 |
367 // Creates two addition filters | 392 // Creates two addition filters |
368 scoped_ptr<aura::test::TestEventFilter> f1( | 393 scoped_ptr<aura::test::TestEventFilter> f1( |
369 new aura::test::TestEventFilter(NULL)); | 394 new aura::test::TestEventFilter(NULL)); |
370 scoped_ptr<aura::test::TestEventFilter> f2( | 395 scoped_ptr<aura::test::TestEventFilter> f2( |
371 new aura::test::TestEventFilter(NULL)); | 396 new aura::test::TestEventFilter(NULL)); |
372 | 397 |
373 // Adds them to root window event filter. | 398 // Adds them to root window event filter. |
374 internal::RootWindowEventFilter* root_window_filter = | 399 internal::RootWindowEventFilter* root_window_filter = |
375 static_cast<internal::RootWindowEventFilter*>( | 400 static_cast<internal::RootWindowEventFilter*>( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 EXPECT_EQ(0, f1->key_event_count()); | 446 EXPECT_EQ(0, f1->key_event_count()); |
422 EXPECT_EQ(0, f1->mouse_event_count()); | 447 EXPECT_EQ(0, f1->mouse_event_count()); |
423 EXPECT_EQ(1, f2->key_event_count()); | 448 EXPECT_EQ(1, f2->key_event_count()); |
424 EXPECT_EQ(1, f2->mouse_event_count()); | 449 EXPECT_EQ(1, f2->mouse_event_count()); |
425 | 450 |
426 root_window_filter->RemoveFilter(f2.get()); | 451 root_window_filter->RemoveFilter(f2.get()); |
427 } | 452 } |
428 | 453 |
429 } // namespace test | 454 } // namespace test |
430 } // namespace aura_shell | 455 } // namespace aura_shell |
OLD | NEW |