[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 5 | #include "ash/root_window_controller.h" |
| 6 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 7 | #include "ash/display/display_controller.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 8 | #include "ash/shell.h" |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 9 | #include "ash/shell_delegate.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 10 | #include "ash/shell_window_ids.h" |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 11 | #include "ash/system/tray/system_tray_delegate.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 12 | #include "ash/test/ash_test_base.h" |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 13 | #include "ash/wm/system_modal_container_layout_manager.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 14 | #include "ash/wm/window_util.h" |
[email protected] | 792b9b1 | 2012-12-11 03:53:27 | [diff] [blame^] | 15 | #include "ui/aura/client/focus_change_observer.h" |
[email protected] | 8cfb672 | 2012-11-28 03:28:46 | [diff] [blame] | 16 | #include "ui/aura/client/focus_client.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 17 | #include "ui/aura/env.h" |
| 18 | #include "ui/aura/root_window.h" |
| 19 | #include "ui/aura/test/event_generator.h" |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 20 | #include "ui/aura/test/test_window_delegate.h" |
| 21 | #include "ui/aura/test/test_windows.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 22 | #include "ui/aura/window.h" |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 23 | #include "ui/aura/window_tracker.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 24 | #include "ui/views/controls/menu/menu_controller.h" |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 25 | #include "ui/views/corewm/focus_change_event.h" |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 26 | #include "ui/views/widget/widget.h" |
| 27 | #include "ui/views/widget/widget_delegate.h" |
| 28 | |
| 29 | namespace ash { |
| 30 | namespace { |
| 31 | |
| 32 | class TestDelegate : public views::WidgetDelegateView { |
| 33 | public: |
| 34 | explicit TestDelegate(bool system_modal) : system_modal_(system_modal) {} |
| 35 | virtual ~TestDelegate() {} |
| 36 | |
| 37 | // Overridden from views::WidgetDelegate: |
| 38 | virtual views::View* GetContentsView() OVERRIDE { |
| 39 | return this; |
| 40 | } |
| 41 | |
| 42 | virtual ui::ModalType GetModalType() const OVERRIDE { |
| 43 | return system_modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; |
| 44 | } |
| 45 | |
| 46 | private: |
| 47 | bool system_modal_; |
| 48 | DISALLOW_COPY_AND_ASSIGN(TestDelegate); |
| 49 | }; |
| 50 | |
[email protected] | 792b9b1 | 2012-12-11 03:53:27 | [diff] [blame^] | 51 | class DeleteOnBlurDelegate : public aura::test::TestWindowDelegate, |
| 52 | public aura::client::FocusChangeObserver { |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 53 | public: |
| 54 | DeleteOnBlurDelegate() : window_(NULL) {} |
| 55 | virtual ~DeleteOnBlurDelegate() {} |
| 56 | |
[email protected] | 792b9b1 | 2012-12-11 03:53:27 | [diff] [blame^] | 57 | void SetWindow(aura::Window* window) { |
| 58 | window_ = window; |
| 59 | aura::client::SetFocusChangeObserver(window_, this); |
| 60 | } |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 61 | |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 62 | private: |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 63 | // aura::test::TestWindowDelegate overrides: |
| 64 | virtual bool CanFocus() OVERRIDE { |
| 65 | return true; |
| 66 | } |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 67 | |
[email protected] | 792b9b1 | 2012-12-11 03:53:27 | [diff] [blame^] | 68 | // aura::client::FocusChangeObserver implementation: |
| 69 | virtual void OnWindowFocused(aura::Window* gained_focus, |
| 70 | aura::Window* lost_focus) OVERRIDE { |
| 71 | if (window_ == lost_focus) |
| 72 | delete window_; |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 73 | } |
| 74 | |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 75 | aura::Window* window_; |
| 76 | |
| 77 | DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
| 78 | }; |
| 79 | |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 80 | views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
| 81 | views::Widget* widget = |
| 82 | views::Widget::CreateWindowWithBounds(NULL, bounds); |
| 83 | widget->Show(); |
| 84 | return widget; |
| 85 | } |
| 86 | |
| 87 | views::Widget* CreateModalWidget(const gfx::Rect& bounds) { |
| 88 | views::Widget* widget = |
| 89 | views::Widget::CreateWindowWithBounds(new TestDelegate(true), bounds); |
| 90 | widget->Show(); |
| 91 | return widget; |
| 92 | } |
| 93 | |
[email protected] | 3b162e1 | 2012-11-09 11:52:35 | [diff] [blame] | 94 | views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, |
| 95 | gfx::NativeWindow parent) { |
| 96 | views::Widget* widget = |
| 97 | views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), |
| 98 | parent, |
| 99 | bounds); |
| 100 | widget->Show(); |
| 101 | return widget; |
| 102 | } |
| 103 | |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 104 | aura::Window* GetModalContainer(aura::RootWindow* root_window) { |
| 105 | return Shell::GetContainer( |
| 106 | root_window, |
| 107 | ash::internal::kShellWindowId_SystemModalContainer); |
| 108 | } |
| 109 | |
| 110 | } // namespace |
| 111 | |
| 112 | namespace test { |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 113 | |
[email protected] | 3e4351b | 2012-08-09 04:04:16 | [diff] [blame] | 114 | typedef test::AshTestBase RootWindowControllerTest; |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 115 | |
| 116 | TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 117 | UpdateDisplay("600x600,500x500"); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 118 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 119 | internal::RootWindowController* controller = |
| 120 | Shell::GetPrimaryRootWindowController(); |
| 121 | controller->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 122 | |
| 123 | views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
| 124 | EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 125 | EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 126 | EXPECT_EQ("50,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 127 | normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 128 | |
| 129 | views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
| 130 | maximized->Maximize(); |
| 131 | EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
[email protected] | 1a01538 | 2012-12-01 19:44:59 | [diff] [blame] | 132 | |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 133 | EXPECT_EQ("600,0 500x500", maximized->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 134 | EXPECT_EQ("0,0 500x500", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 135 | maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 136 | |
| 137 | views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
| 138 | minimized->Minimize(); |
| 139 | EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 140 | EXPECT_EQ("800,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 141 | minimized->GetWindowBoundsInScreen().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 142 | |
| 143 | views::Widget* fullscreen = CreateTestWidget(gfx::Rect(900, 10, 100, 100)); |
| 144 | fullscreen->SetFullscreen(true); |
| 145 | EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); |
[email protected] | 1a01538 | 2012-12-01 19:44:59 | [diff] [blame] | 146 | |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 147 | EXPECT_EQ("600,0 500x500", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 148 | fullscreen->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 149 | EXPECT_EQ("0,0 500x500", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 150 | fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 151 | |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 152 | // Make sure a window that will delete itself when losing focus |
| 153 | // will not crash. |
| 154 | aura::WindowTracker tracker; |
| 155 | DeleteOnBlurDelegate delete_on_blur_delegate; |
[email protected] | 5ebe610 | 2012-11-28 21:00:03 | [diff] [blame] | 156 | aura::Window* d2 = CreateTestWindowInShellWithDelegate( |
| 157 | &delete_on_blur_delegate, 0, gfx::Rect(50, 50, 100, 100)); |
[email protected] | 792b9b1 | 2012-12-11 03:53:27 | [diff] [blame^] | 158 | delete_on_blur_delegate.SetWindow(d2); |
[email protected] | 8cfb672 | 2012-11-28 03:28:46 | [diff] [blame] | 159 | aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2, NULL); |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 160 | tracker.Add(d2); |
| 161 | |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 162 | UpdateDisplay("600x600"); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 163 | |
[email protected] | dbf835d8 | 2012-09-11 18:23:09 | [diff] [blame] | 164 | // d2 must have been deleted. |
| 165 | EXPECT_FALSE(tracker.Contains(d2)); |
| 166 | |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 167 | EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 168 | EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 169 | EXPECT_EQ("50,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 170 | normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 171 | |
[email protected] | eefd51b2 | 2012-09-25 20:26:24 | [diff] [blame] | 172 | // Maximized area on primary display has 3px (given as |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 173 | // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. |
| 174 | EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
[email protected] | 7b675df61 | 2012-09-16 18:33:20 | [diff] [blame] | 175 | EXPECT_EQ("0,0 600x597", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 176 | maximized->GetWindowBoundsInScreen().ToString()); |
[email protected] | 7b675df61 | 2012-09-16 18:33:20 | [diff] [blame] | 177 | EXPECT_EQ("0,0 600x597", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 178 | maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 179 | |
| 180 | EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 181 | EXPECT_EQ("200,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 182 | minimized->GetWindowBoundsInScreen().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 183 | |
| 184 | EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
| 185 | EXPECT_TRUE(fullscreen->IsFullscreen()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 186 | EXPECT_EQ("0,0 600x600", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 187 | fullscreen->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 188 | EXPECT_EQ("0,0 600x600", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 189 | fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 190 | |
| 191 | // Test if the restore bounds are correctly updated. |
| 192 | wm::RestoreWindow(maximized->GetNativeView()); |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 193 | EXPECT_EQ("100,10 100x100", maximized->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 194 | EXPECT_EQ("100,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 195 | maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 196 | |
| 197 | fullscreen->SetFullscreen(false); |
| 198 | EXPECT_EQ("300,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 199 | fullscreen->GetWindowBoundsInScreen().ToString()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 200 | EXPECT_EQ("300,10 100x100", |
[email protected] | e2f64d10 | 2012-07-19 19:17:04 | [diff] [blame] | 201 | fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | TEST_F(RootWindowControllerTest, MoveWindows_Modal) { |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 205 | UpdateDisplay("500x500,500x500"); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 206 | |
| 207 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 208 | // Emulate virtual screen coordinate system. |
| 209 | root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 210 | root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
| 211 | |
| 212 | views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); |
| 213 | EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
| 214 | EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); |
| 215 | |
| 216 | views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); |
| 217 | EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); |
| 218 | EXPECT_TRUE(GetModalContainer(root_windows[1])->Contains( |
| 219 | modal->GetNativeView())); |
| 220 | EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 221 | |
| 222 | aura::test::EventGenerator generator_1st(root_windows[0]); |
| 223 | generator_1st.ClickLeftButton(); |
| 224 | EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 225 | |
[email protected] | f634dd3 | 2012-07-23 22:49:07 | [diff] [blame] | 226 | UpdateDisplay("500x500"); |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 227 | EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
| 228 | EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 229 | generator_1st.ClickLeftButton(); |
| 230 | EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
| 231 | } |
| 232 | |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 233 | TEST_F(RootWindowControllerTest, ModalContainer) { |
| 234 | UpdateDisplay("600x600"); |
| 235 | Shell* shell = Shell::GetInstance(); |
| 236 | internal::RootWindowController* controller = |
| 237 | shell->GetPrimaryRootWindowController(); |
| 238 | EXPECT_EQ(user::LOGGED_IN_USER, |
| 239 | shell->tray_delegate()->GetUserLoginStatus()); |
| 240 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 241 | internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 242 | controller->GetSystemModalLayoutManager(NULL)); |
| 243 | |
[email protected] | 3b162e1 | 2012-11-09 11:52:35 | [diff] [blame] | 244 | views::Widget* session_modal_widget = |
| 245 | CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 246 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 247 | internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 248 | controller->GetSystemModalLayoutManager( |
| 249 | session_modal_widget->GetNativeView())); |
| 250 | |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 251 | shell->delegate()->LockScreen(); |
| 252 | EXPECT_EQ(user::LOGGED_IN_LOCKED, |
| 253 | shell->tray_delegate()->GetUserLoginStatus()); |
| 254 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 255 | internal::kShellWindowId_LockSystemModalContainer)->layout_manager(), |
| 256 | controller->GetSystemModalLayoutManager(NULL)); |
[email protected] | 3b162e1 | 2012-11-09 11:52:35 | [diff] [blame] | 257 | |
| 258 | aura::Window* lock_container = |
| 259 | Shell::GetContainer(controller->root_window(), |
| 260 | internal::kShellWindowId_LockScreenContainer); |
| 261 | views::Widget* lock_modal_widget = |
| 262 | CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); |
| 263 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 264 | internal::kShellWindowId_LockSystemModalContainer)->layout_manager(), |
| 265 | controller->GetSystemModalLayoutManager( |
| 266 | lock_modal_widget->GetNativeView())); |
| 267 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 268 | internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 269 | controller->GetSystemModalLayoutManager( |
| 270 | session_modal_widget->GetNativeView())); |
| 271 | |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 272 | shell->delegate()->UnlockScreen(); |
| 273 | } |
| 274 | |
[email protected] | 1b21992 | 2012-11-13 21:16:43 | [diff] [blame] | 275 | TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { |
| 276 | UpdateDisplay("600x600"); |
| 277 | Shell* shell = Shell::GetInstance(); |
| 278 | |
| 279 | // Configure login screen environment. |
| 280 | SetUserLoggedIn(false); |
| 281 | EXPECT_EQ(user::LOGGED_IN_NONE, |
| 282 | shell->tray_delegate()->GetUserLoginStatus()); |
| 283 | EXPECT_FALSE(shell->delegate()->IsUserLoggedIn()); |
| 284 | EXPECT_FALSE(shell->delegate()->IsSessionStarted()); |
| 285 | |
| 286 | internal::RootWindowController* controller = |
| 287 | shell->GetPrimaryRootWindowController(); |
| 288 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 289 | internal::kShellWindowId_LockSystemModalContainer)->layout_manager(), |
| 290 | controller->GetSystemModalLayoutManager(NULL)); |
| 291 | |
| 292 | aura::Window* lock_container = |
| 293 | Shell::GetContainer(controller->root_window(), |
| 294 | internal::kShellWindowId_LockScreenContainer); |
| 295 | views::Widget* login_modal_widget = |
| 296 | CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); |
| 297 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 298 | internal::kShellWindowId_LockSystemModalContainer)->layout_manager(), |
| 299 | controller->GetSystemModalLayoutManager( |
| 300 | login_modal_widget->GetNativeView())); |
| 301 | login_modal_widget->Close(); |
| 302 | |
| 303 | // Configure user session environment. |
| 304 | SetUserLoggedIn(true); |
| 305 | SetSessionStarted(true); |
| 306 | EXPECT_EQ(user::LOGGED_IN_USER, |
| 307 | shell->tray_delegate()->GetUserLoginStatus()); |
| 308 | EXPECT_TRUE(shell->delegate()->IsUserLoggedIn()); |
| 309 | EXPECT_TRUE(shell->delegate()->IsSessionStarted()); |
| 310 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 311 | internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 312 | controller->GetSystemModalLayoutManager(NULL)); |
| 313 | |
| 314 | views::Widget* session_modal_widget = |
| 315 | CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
| 316 | EXPECT_EQ(Shell::GetContainer(controller->root_window(), |
| 317 | internal::kShellWindowId_SystemModalContainer)->layout_manager(), |
| 318 | controller->GetSystemModalLayoutManager( |
| 319 | session_modal_widget->GetNativeView())); |
| 320 | } |
| 321 | |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 322 | } // namespace test |
| 323 | } // namespace ash |