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 "ash/wm/activation_controller.h" | 5 #include "ash/wm/activation_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/test/test_activation_delegate.h" | 10 #include "ash/test/test_activation_delegate.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // Test if the clicking on a menu picks the transient parent as activatable | 184 // Test if the clicking on a menu picks the transient parent as activatable |
185 // window. | 185 // window. |
186 TEST_F(ActivationControllerTest, ClickOnMenu) { | 186 TEST_F(ActivationControllerTest, ClickOnMenu) { |
187 aura::test::TestWindowDelegate wd; | 187 aura::test::TestWindowDelegate wd; |
188 TestActivationDelegate ad1; | 188 TestActivationDelegate ad1; |
189 TestActivationDelegate ad2(false); | 189 TestActivationDelegate ad2(false); |
190 | 190 |
191 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 191 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
192 &wd, 1, gfx::Rect(100, 100), NULL)); | 192 &wd, 1, gfx::Rect(100, 100), NULL)); |
193 ad1.SetWindow(w1.get()); | 193 ad1.SetWindow(w1.get()); |
194 EXPECT_TRUE(wm::IsActiveWindow(NULL)); | 194 EXPECT_EQ(NULL, wm::GetActiveWindow()); |
195 | 195 |
196 // Clicking on an activatable window activtes the window. | 196 // Clicking on an activatable window activtes the window. |
197 aura::test::EventGenerator generator(Shell::GetRootWindow(), w1.get()); | 197 aura::test::EventGenerator generator(Shell::GetRootWindow(), w1.get()); |
198 generator.ClickLeftButton(); | 198 generator.ClickLeftButton(); |
199 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 199 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
200 | 200 |
201 // Creates a menu that covers the transient parent. | 201 // Creates a menu that covers the transient parent. |
202 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType( | 202 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType( |
203 &wd, aura::client::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL)); | 203 &wd, aura::client::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL)); |
204 ad2.SetWindow(menu.get()); | 204 ad2.SetWindow(menu.get()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( | 252 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( |
253 NULL, 1, gfx::Rect(10, 10, 50, 50), NULL)); | 253 NULL, 1, gfx::Rect(10, 10, 50, 50), NULL)); |
254 | 254 |
255 // Activate w1. | 255 // Activate w1. |
256 wm::ActivateWindow(w1.get()); | 256 wm::ActivateWindow(w1.get()); |
257 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 257 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
258 EXPECT_EQ(1, ad1.activated_count()); | 258 EXPECT_EQ(1, ad1.activated_count()); |
259 // Should not have gotten a OnLostActive yet. | 259 // Should not have gotten a OnLostActive yet. |
260 EXPECT_EQ(0, ad1.lost_active_count()); | 260 EXPECT_EQ(0, ad1.lost_active_count()); |
261 | 261 |
262 // ActivateWindow(NULL) should deactivate the active window. | 262 // Deactivate the active window. |
263 wm::ActivateWindow(NULL); | 263 wm::DeactivateWindow(w1.get()); |
264 EXPECT_FALSE(wm::IsActiveWindow(w1.get())); | 264 EXPECT_FALSE(wm::IsActiveWindow(w1.get())); |
265 EXPECT_EQ(1, ad1.lost_active_count()); | 265 EXPECT_EQ(1, ad1.lost_active_count()); |
266 EXPECT_FALSE(ad1.window_was_active()); | 266 EXPECT_FALSE(ad1.window_was_active()); |
267 | 267 |
268 // Activate w1 again. w1 should have gotten OnActivated. | 268 // Activate w1 again. w1 should have gotten OnActivated. |
269 wm::ActivateWindow(w1.get()); | 269 wm::ActivateWindow(w1.get()); |
270 EXPECT_EQ(2, ad1.activated_count()); | 270 EXPECT_EQ(2, ad1.activated_count()); |
271 EXPECT_EQ(1, ad1.lost_active_count()); | 271 EXPECT_EQ(1, ad1.lost_active_count()); |
272 | 272 |
273 // Reset the delegate. | 273 // Reset the delegate. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 // Try focusing |w21|. Same rules apply. | 345 // Try focusing |w21|. Same rules apply. |
346 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); | 346 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
347 EXPECT_FALSE(w21->HasFocus()); | 347 EXPECT_FALSE(w21->HasFocus()); |
348 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 348 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
349 EXPECT_TRUE(w1->HasFocus()); | 349 EXPECT_TRUE(w1->HasFocus()); |
350 } | 350 } |
351 | 351 |
352 } // namespace test | 352 } // namespace test |
353 } // namespace ash | 353 } // namespace ash |
OLD | NEW |