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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 aura::Window* lost_focus) OVERRIDE { | 69 aura::Window* lost_focus) OVERRIDE { |
70 if (window_ == lost_focus) | 70 if (window_ == lost_focus) |
71 delete window_; | 71 delete window_; |
72 } | 72 } |
73 | 73 |
74 aura::Window* window_; | 74 aura::Window* window_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
77 }; | 77 }; |
78 | 78 |
79 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | |
80 views::Widget* widget = | |
81 views::Widget::CreateWindowWithBounds(NULL, bounds); | |
82 widget->Show(); | |
83 return widget; | |
84 } | |
85 | |
86 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { | |
87 views::Widget* widget = | |
88 views::Widget::CreateWindowWithBounds(new TestDelegate(true), bounds); | |
89 widget->Show(); | |
90 return widget; | |
91 } | |
92 | |
93 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, | |
94 gfx::NativeWindow parent) { | |
95 views::Widget* widget = | |
96 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), | |
97 parent, | |
98 bounds); | |
99 widget->Show(); | |
100 return widget; | |
101 } | |
102 | |
103 aura::Window* GetModalContainer(aura::RootWindow* root_window) { | |
104 return Shell::GetContainer( | |
105 root_window, | |
106 ash::internal::kShellWindowId_SystemModalContainer); | |
107 } | |
108 | |
109 } // namespace | 79 } // namespace |
110 | 80 |
111 namespace test { | 81 namespace test { |
112 | 82 |
113 typedef test::AshTestBase RootWindowControllerTest; | 83 class RootWindowControllerTest : public test::AshTestBase { |
| 84 public: |
| 85 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
| 86 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 87 NULL, CurrentContext(), bounds); |
| 88 widget->Show(); |
| 89 return widget; |
| 90 } |
| 91 |
| 92 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { |
| 93 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 94 new TestDelegate(true), CurrentContext(), bounds); |
| 95 widget->Show(); |
| 96 return widget; |
| 97 } |
| 98 |
| 99 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, |
| 100 gfx::NativeWindow parent) { |
| 101 views::Widget* widget = |
| 102 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), |
| 103 parent, |
| 104 bounds); |
| 105 widget->Show(); |
| 106 return widget; |
| 107 } |
| 108 |
| 109 aura::Window* GetModalContainer(aura::RootWindow* root_window) { |
| 110 return Shell::GetContainer( |
| 111 root_window, |
| 112 ash::internal::kShellWindowId_SystemModalContainer); |
| 113 } |
| 114 }; |
114 | 115 |
115 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 116 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
116 UpdateDisplay("600x600,500x500"); | 117 UpdateDisplay("600x600,500x500"); |
117 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 118 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
118 internal::RootWindowController* controller = | 119 internal::RootWindowController* controller = |
119 Shell::GetPrimaryRootWindowController(); | 120 Shell::GetPrimaryRootWindowController(); |
120 controller->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 121 controller->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
121 | 122 |
122 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 123 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
123 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 124 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 views::Widget* session_modal_widget = | 314 views::Widget* session_modal_widget = |
314 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 315 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
315 EXPECT_EQ(Shell::GetContainer(controller->root_window(), | 316 EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
316 internal::kShellWindowId_SystemModalContainer)->layout_manager(), | 317 internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
317 controller->GetSystemModalLayoutManager( | 318 controller->GetSystemModalLayoutManager( |
318 session_modal_widget->GetNativeView())); | 319 session_modal_widget->GetNativeView())); |
319 } | 320 } |
320 | 321 |
321 } // namespace test | 322 } // namespace test |
322 } // namespace ash | 323 } // namespace ash |
OLD | NEW |