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" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
13 #include "ui/aura/focus_manager.h" | 13 #include "ui/aura/focus_manager.h" |
14 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
15 #include "ui/aura/test/event_generator.h" | 15 #include "ui/aura/test/event_generator.h" |
16 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
17 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
19 | 19 |
20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
21 // Windows headers define macros for these function names which screw with us. | 21 // Windows headers define macros for these function names which screw with us. |
22 #if defined(CreateWindow) | 22 #if defined(CreateWindow) |
23 #undef CreateWindow | 23 #undef CreateWindow |
24 #endif | 24 #endif |
25 #endif | 25 #endif |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Containers used for the tests. | 29 // Containers used for the tests. |
30 const int c1 = ash::internal::kShellWindowId_DefaultContainer; | 30 const int kDefaultContainerID = -1; // Used to identify the default container. |
31 const int c2 = ash::internal::kShellWindowId_AlwaysOnTopContainer; | 31 const int c2 = ash::internal::kShellWindowId_AlwaysOnTopContainer; |
32 const int c3 = ash::internal::kShellWindowId_LockScreenContainer; | 32 const int c3 = ash::internal::kShellWindowId_LockScreenContainer; |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 namespace ash { | 36 namespace ash { |
37 namespace test { | 37 namespace test { |
38 | 38 |
39 typedef test::AshTestBase ActivationControllerTest; | 39 typedef test::AshTestBase ActivationControllerTest; |
40 | 40 |
(...skipping 24 matching lines...) Expand all Loading... |
65 aura::Window* w7() { return w7_.get(); } | 65 aura::Window* w7() { return w7_.get(); } |
66 | 66 |
67 void DestroyWindow2() { | 67 void DestroyWindow2() { |
68 w2_.reset(); | 68 w2_.reset(); |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 void CreateWindows() { | 72 void CreateWindows() { |
73 // Create four windows, the first and third are not activatable, the second | 73 // Create four windows, the first and third are not activatable, the second |
74 // and fourth are. | 74 // and fourth are. |
75 w1_.reset(CreateWindow(1, &ad_1_, c1)); | 75 w1_.reset(CreateWindow(1, &ad_1_, kDefaultContainerID)); |
76 w2_.reset(CreateWindow(2, &ad_2_, c1)); | 76 w2_.reset(CreateWindow(2, &ad_2_, kDefaultContainerID)); |
77 w3_.reset(CreateWindow(3, &ad_3_, c1)); | 77 w3_.reset(CreateWindow(3, &ad_3_, kDefaultContainerID)); |
78 w4_.reset(CreateWindow(4, &ad_4_, c1)); | 78 w4_.reset(CreateWindow(4, &ad_4_, kDefaultContainerID)); |
79 w5_.reset(CreateWindow(5, &ad_5_, c2)); | 79 w5_.reset(CreateWindow(5, &ad_5_, c2)); |
80 w6_.reset(CreateWindow(6, &ad_6_, c2)); | 80 w6_.reset(CreateWindow(6, &ad_6_, c2)); |
81 w7_.reset(CreateWindow(7, &ad_7_, c3)); | 81 w7_.reset(CreateWindow(7, &ad_7_, c3)); |
82 } | 82 } |
83 | 83 |
84 aura::Window* CreateWindow(int id, | 84 aura::Window* CreateWindow(int id, |
85 TestActivationDelegate* delegate, | 85 TestActivationDelegate* delegate, |
86 int container_id) { | 86 int container_id) { |
| 87 aura::Window* parent = container_id == kDefaultContainerID ? NULL : |
| 88 Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id); |
87 aura::Window* window = aura::test::CreateTestWindowWithDelegate( | 89 aura::Window* window = aura::test::CreateTestWindowWithDelegate( |
88 &delegate_, | 90 &delegate_, |
89 id, | 91 id, |
90 gfx::Rect(), | 92 gfx::Rect(), |
91 Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id)); | 93 parent); |
92 delegate->SetWindow(window); | 94 delegate->SetWindow(window); |
93 return window; | 95 return window; |
94 } | 96 } |
95 | 97 |
96 void DestroyWindows() { | 98 void DestroyWindows() { |
97 w1_.reset(); | 99 w1_.reset(); |
98 w2_.reset(); | 100 w2_.reset(); |
99 w3_.reset(); | 101 w3_.reset(); |
100 w4_.reset(); | 102 w4_.reset(); |
101 w5_.reset(); | 103 w5_.reset(); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 462 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
461 &wd, -1, gfx::Rect(50, 50, 50, 50), NULL)); | 463 &wd, -1, gfx::Rect(50, 50, 50, 50), NULL)); |
462 | 464 |
463 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); | 465 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); |
464 w1->layer()->SetVisible(false); | 466 w1->layer()->SetVisible(false); |
465 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); | 467 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); |
466 } | 468 } |
467 | 469 |
468 } // namespace test | 470 } // namespace test |
469 } // namespace ash | 471 } // namespace ash |
OLD | NEW |