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

Side by Side Diff: ash/wm/root_window_event_filter_unittest.cc

Issue 9033007: Rename the aura_shell namespace to ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
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 "ash/wm/root_window_event_filter.h" 5 #include "ash/wm/root_window_event_filter.h"
6 6
7 #include "ash/shell_window_ids.h" 7 #include "ash/shell_window_ids.h"
8 #include "ash/test/test_activation_delegate.h" 8 #include "ash/test/test_activation_delegate.h"
9 #include "ash/wm/activation_controller.h" 9 #include "ash/wm/activation_controller.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
11 #include "ui/aura/client/activation_delegate.h" 11 #include "ui/aura/client/activation_delegate.h"
12 #include "ui/aura/cursor.h" 12 #include "ui/aura/cursor.h"
13 #include "ui/aura/event.h" 13 #include "ui/aura/event.h"
14 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
15 #include "ui/aura/test/aura_test_base.h" 15 #include "ui/aura/test/aura_test_base.h"
16 #include "ui/aura/test/event_generator.h" 16 #include "ui/aura/test/event_generator.h"
17 #include "ui/aura/test/test_windows.h" 17 #include "ui/aura/test/test_windows.h"
18 #include "ui/aura/test/test_event_filter.h" 18 #include "ui/aura/test/test_event_filter.h"
19 #include "ui/aura/test/test_window_delegate.h" 19 #include "ui/aura/test/test_window_delegate.h"
20 #include "ui/base/hit_test.h" 20 #include "ui/base/hit_test.h"
21 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
22 22
23 namespace aura_shell { 23 namespace ash {
24 namespace test { 24 namespace test {
25 25
26 class RootWindowEventFilterTest : public aura::test::AuraTestBase { 26 class RootWindowEventFilterTest : public aura::test::AuraTestBase {
27 public: 27 public:
28 RootWindowEventFilterTest() { 28 RootWindowEventFilterTest() {
29 aura::RootWindow::GetInstance()->SetEventFilter( 29 aura::RootWindow::GetInstance()->SetEventFilter(
30 new internal::RootWindowEventFilter); 30 new internal::RootWindowEventFilter);
31 31
32 aura::RootWindow::GetInstance()->set_id( 32 aura::RootWindow::GetInstance()->set_id(
33 internal::kShellWindowId_DefaultContainer); 33 internal::kShellWindowId_DefaultContainer);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( 139 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
140 &wd, 2, gfx::Rect(70, 70, 50, 50), NULL)); 140 &wd, 2, gfx::Rect(70, 70, 50, 50), NULL));
141 d2.SetWindow(w2.get()); 141 d2.SetWindow(w2.get());
142 142
143 aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); 143 aura::internal::FocusManager* focus_manager = w1->GetFocusManager();
144 144
145 d1.Clear(); 145 d1.Clear();
146 d2.Clear(); 146 d2.Clear();
147 147
148 // Activate window1. 148 // Activate window1.
149 aura_shell::ActivateWindow(w1.get()); 149 ash::ActivateWindow(w1.get());
150 EXPECT_TRUE(IsActiveWindow(w1.get())); 150 EXPECT_TRUE(IsActiveWindow(w1.get()));
151 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); 151 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
152 EXPECT_EQ(1, d1.activated_count()); 152 EXPECT_EQ(1, d1.activated_count());
153 EXPECT_EQ(0, d1.lost_active_count()); 153 EXPECT_EQ(0, d1.lost_active_count());
154 d1.Clear(); 154 d1.Clear();
155 155
156 { 156 {
157 // Click on window2. 157 // Click on window2.
158 gfx::Point press_point = w2->bounds().CenterPoint(); 158 gfx::Point press_point = w2->bounds().CenterPoint();
159 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); 159 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( 214 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
215 &wd, -2, gfx::Rect(70, 70, 50, 50), NULL)); 215 &wd, -2, gfx::Rect(70, 70, 50, 50), NULL));
216 d2.SetWindow(w2.get()); 216 d2.SetWindow(w2.get());
217 217
218 aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); 218 aura::internal::FocusManager* focus_manager = w1->GetFocusManager();
219 219
220 d1.Clear(); 220 d1.Clear();
221 d2.Clear(); 221 d2.Clear();
222 222
223 // Activate window1. 223 // Activate window1.
224 aura_shell::ActivateWindow(w1.get()); 224 ash::ActivateWindow(w1.get());
225 EXPECT_TRUE(IsActiveWindow(w1.get())); 225 EXPECT_TRUE(IsActiveWindow(w1.get()));
226 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); 226 EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
227 EXPECT_EQ(1, d1.activated_count()); 227 EXPECT_EQ(1, d1.activated_count());
228 EXPECT_EQ(0, d1.lost_active_count()); 228 EXPECT_EQ(0, d1.lost_active_count());
229 d1.Clear(); 229 d1.Clear();
230 230
231 // Touch window2. 231 // Touch window2.
232 gfx::Point press_point = w2->bounds().CenterPoint(); 232 gfx::Point press_point = w2->bounds().CenterPoint();
233 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); 233 aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point);
234 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0); 234 aura::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 EXPECT_TRUE(IsActiveWindow(w1.get())); 376 EXPECT_TRUE(IsActiveWindow(w1.get()));
377 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow()); 377 EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow());
378 } 378 }
379 379
380 TEST_F(RootWindowEventFilterTest, AdditionalFilters) { 380 TEST_F(RootWindowEventFilterTest, AdditionalFilters) {
381 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); 381 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
382 382
383 // Creates a window and make it active 383 // Creates a window and make it active
384 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindow( 384 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindow(
385 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100), NULL)); 385 SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100), NULL));
386 aura_shell::ActivateWindow(w1.get()); 386 ash::ActivateWindow(w1.get());
387 387
388 // Creates two addition filters 388 // Creates two addition filters
389 scoped_ptr<aura::test::TestEventFilter> f1( 389 scoped_ptr<aura::test::TestEventFilter> f1(
390 new aura::test::TestEventFilter(NULL)); 390 new aura::test::TestEventFilter(NULL));
391 scoped_ptr<aura::test::TestEventFilter> f2( 391 scoped_ptr<aura::test::TestEventFilter> f2(
392 new aura::test::TestEventFilter(NULL)); 392 new aura::test::TestEventFilter(NULL));
393 393
394 // Adds them to root window event filter. 394 // Adds them to root window event filter.
395 internal::RootWindowEventFilter* root_window_filter = 395 internal::RootWindowEventFilter* root_window_filter =
396 static_cast<internal::RootWindowEventFilter*>( 396 static_cast<internal::RootWindowEventFilter*>(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // f1 should get no events since it's out and f2 should get them. 441 // f1 should get no events since it's out and f2 should get them.
442 EXPECT_EQ(0, f1->key_event_count()); 442 EXPECT_EQ(0, f1->key_event_count());
443 EXPECT_EQ(0, f1->mouse_event_count()); 443 EXPECT_EQ(0, f1->mouse_event_count());
444 EXPECT_EQ(1, f2->key_event_count()); 444 EXPECT_EQ(1, f2->key_event_count());
445 EXPECT_EQ(1, f2->mouse_event_count()); 445 EXPECT_EQ(1, f2->mouse_event_count());
446 446
447 root_window_filter->RemoveFilter(f2.get()); 447 root_window_filter->RemoveFilter(f2.get());
448 } 448 }
449 449
450 } // namespace test 450 } // namespace test
451 } // namespace aura_shell 451 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698