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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { | 111 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { |
112 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 112 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
113 new TestDelegate(true), CurrentContext(), bounds); | 113 new TestDelegate(true), CurrentContext(), bounds); |
114 widget->Show(); | 114 widget->Show(); |
115 return widget; | 115 return widget; |
116 } | 116 } |
117 | 117 |
118 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, | 118 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, |
119 gfx::NativeWindow parent) { | 119 gfx::NativeWindow parent) { |
120 views::Widget* widget = | 120 views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds( |
121 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), | 121 new TestDelegate(true), parent, bounds); |
122 parent, | |
123 bounds); | |
124 widget->Show(); | 122 widget->Show(); |
125 return widget; | 123 return widget; |
126 } | 124 } |
127 | 125 |
128 aura::Window* GetModalContainer(aura::Window* root_window) { | 126 aura::Window* GetModalContainer(aura::Window* root_window) { |
129 return Shell::GetContainer(root_window, | 127 return Shell::GetContainer(root_window, |
130 ash::kShellWindowId_SystemModalContainer); | 128 ash::kShellWindowId_SystemModalContainer); |
131 } | 129 } |
132 }; | 130 }; |
133 | 131 |
(...skipping 23 matching lines...) Expand all Loading... |
157 maximized->Maximize(); | 155 maximized->Maximize(); |
158 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 156 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
159 EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(), | 157 EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(), |
160 maximized->GetWindowBoundsInScreen().ToString()); | 158 maximized->GetWindowBoundsInScreen().ToString()); |
161 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), | 159 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), |
162 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 160 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
163 | 161 |
164 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 162 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
165 minimized->Minimize(); | 163 minimized->Minimize(); |
166 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 164 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
167 EXPECT_EQ("800,10 100x100", | 165 EXPECT_EQ("800,10 100x100", minimized->GetWindowBoundsInScreen().ToString()); |
168 minimized->GetWindowBoundsInScreen().ToString()); | |
169 | 166 |
170 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); | 167 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); |
171 fullscreen->SetFullscreen(true); | 168 fullscreen->SetFullscreen(true); |
172 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); | 169 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); |
173 | 170 |
174 EXPECT_EQ("600,0 300x300", | 171 EXPECT_EQ("600,0 300x300", fullscreen->GetWindowBoundsInScreen().ToString()); |
175 fullscreen->GetWindowBoundsInScreen().ToString()); | |
176 EXPECT_EQ("0,0 300x300", | 172 EXPECT_EQ("0,0 300x300", |
177 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 173 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
178 | 174 |
179 views::Widget* unparented_control = new Widget; | 175 views::Widget* unparented_control = new Widget; |
180 Widget::InitParams params; | 176 Widget::InitParams params; |
181 params.bounds = gfx::Rect(650, 10, 100, 100); | 177 params.bounds = gfx::Rect(650, 10, 100, 100); |
182 params.context = CurrentContext(); | 178 params.context = CurrentContext(); |
183 params.type = Widget::InitParams::TYPE_CONTROL; | 179 params.type = Widget::InitParams::TYPE_CONTROL; |
184 unparented_control->Init(params); | 180 unparented_control->Init(params); |
185 EXPECT_EQ(root_windows[1], | 181 EXPECT_EQ(root_windows[1], |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // Set fullscreen to true, but maximized window's size won't change because | 223 // Set fullscreen to true, but maximized window's size won't change because |
228 // it's not visible. see crbug.com/504299. | 224 // it's not visible. see crbug.com/504299. |
229 fullscreen->SetFullscreen(true); | 225 fullscreen->SetFullscreen(true); |
230 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 226 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
231 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), | 227 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
232 maximized->GetWindowBoundsInScreen().ToString()); | 228 maximized->GetWindowBoundsInScreen().ToString()); |
233 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), | 229 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), |
234 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 230 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
235 | 231 |
236 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 232 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
237 EXPECT_EQ("400,20 100x100", | 233 EXPECT_EQ("400,20 100x100", minimized->GetWindowBoundsInScreen().ToString()); |
238 minimized->GetWindowBoundsInScreen().ToString()); | |
239 | 234 |
240 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 235 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
241 EXPECT_TRUE(fullscreen->IsFullscreen()); | 236 EXPECT_TRUE(fullscreen->IsFullscreen()); |
242 EXPECT_EQ("0,0 600x600", | 237 EXPECT_EQ("0,0 600x600", fullscreen->GetWindowBoundsInScreen().ToString()); |
243 fullscreen->GetWindowBoundsInScreen().ToString()); | |
244 EXPECT_EQ("0,0 600x600", | 238 EXPECT_EQ("0,0 600x600", |
245 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 239 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
246 | 240 |
247 // Test if the restore bounds are correctly updated. | 241 // Test if the restore bounds are correctly updated. |
248 wm::GetWindowState(maximized->GetNativeView())->Restore(); | 242 wm::GetWindowState(maximized->GetNativeView())->Restore(); |
249 EXPECT_EQ("200,20 100x100", maximized->GetWindowBoundsInScreen().ToString()); | 243 EXPECT_EQ("200,20 100x100", maximized->GetWindowBoundsInScreen().ToString()); |
250 EXPECT_EQ("200,20 100x100", | 244 EXPECT_EQ("200,20 100x100", |
251 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 245 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
252 | 246 |
253 fullscreen->SetFullscreen(false); | 247 fullscreen->SetFullscreen(false); |
254 EXPECT_EQ("500,20 100x100", | 248 EXPECT_EQ("500,20 100x100", fullscreen->GetWindowBoundsInScreen().ToString()); |
255 fullscreen->GetWindowBoundsInScreen().ToString()); | |
256 EXPECT_EQ("500,20 100x100", | 249 EXPECT_EQ("500,20 100x100", |
257 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 250 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
258 | 251 |
259 // Test if the unparented widget has moved. | 252 // Test if the unparented widget has moved. |
260 EXPECT_EQ(root_windows[0], | 253 EXPECT_EQ(root_windows[0], |
261 unparented_control->GetNativeView()->GetRootWindow()); | 254 unparented_control->GetNativeView()->GetRootWindow()); |
262 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 255 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
263 unparented_control->GetNativeView()->parent()->id()); | 256 unparented_control->GetNativeView()->parent()->id()); |
264 | 257 |
265 // Test if the panel has moved. | 258 // Test if the panel has moved. |
(...skipping 11 matching lines...) Expand all Loading... |
277 // Emulate virtual screen coordinate system. | 270 // Emulate virtual screen coordinate system. |
278 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); | 271 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
279 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); | 272 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
280 | 273 |
281 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); | 274 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); |
282 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 275 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
283 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); | 276 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); |
284 | 277 |
285 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); | 278 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); |
286 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); | 279 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); |
287 EXPECT_TRUE(GetModalContainer(root_windows[1])->Contains( | 280 EXPECT_TRUE( |
288 modal->GetNativeView())); | 281 GetModalContainer(root_windows[1])->Contains(modal->GetNativeView())); |
289 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 282 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
290 | 283 |
291 ui::test::EventGenerator generator_1st(root_windows[0]); | 284 ui::test::EventGenerator generator_1st(root_windows[0]); |
292 generator_1st.ClickLeftButton(); | 285 generator_1st.ClickLeftButton(); |
293 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 286 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
294 | 287 |
295 UpdateDisplay("500x500"); | 288 UpdateDisplay("500x500"); |
296 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); | 289 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); |
297 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); | 290 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); |
298 generator_1st.ClickLeftButton(); | 291 generator_1st.ClickLeftButton(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 SetSessionStarted(true); | 448 SetSessionStarted(true); |
456 EXPECT_EQ(LoginStatus::USER, | 449 EXPECT_EQ(LoginStatus::USER, |
457 wm_shell->system_tray_delegate()->GetUserLoginStatus()); | 450 wm_shell->system_tray_delegate()->GetUserLoginStatus()); |
458 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers()); | 451 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers()); |
459 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted()); | 452 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted()); |
460 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 453 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
461 ->layout_manager(), | 454 ->layout_manager(), |
462 controller->GetSystemModalLayoutManager(NULL)); | 455 controller->GetSystemModalLayoutManager(NULL)); |
463 | 456 |
464 views::Widget* session_modal_widget = | 457 views::Widget* session_modal_widget = |
465 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 458 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
466 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 459 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
467 ->layout_manager(), | 460 ->layout_manager(), |
468 controller->GetSystemModalLayoutManager( | 461 controller->GetSystemModalLayoutManager( |
469 session_modal_widget->GetNativeView())); | 462 session_modal_widget->GetNativeView())); |
470 } | 463 } |
471 | 464 |
472 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { | 465 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { |
473 UpdateDisplay("600x600"); | 466 UpdateDisplay("600x600"); |
474 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 467 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
475 aura::Window* lock_container = | 468 aura::Window* lock_container = |
476 controller->GetContainer(kShellWindowId_LockScreenContainer); | 469 controller->GetContainer(kShellWindowId_LockScreenContainer); |
477 for (int block_reason = FIRST_BLOCK_REASON; | 470 for (int block_reason = FIRST_BLOCK_REASON; |
478 block_reason < NUMBER_OF_BLOCK_REASONS; | 471 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { |
479 ++block_reason) { | |
480 views::Widget* session_modal_widget = | 472 views::Widget* session_modal_widget = |
481 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 473 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
482 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 474 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
483 ->layout_manager(), | 475 ->layout_manager(), |
484 controller->GetSystemModalLayoutManager( | 476 controller->GetSystemModalLayoutManager( |
485 session_modal_widget->GetNativeView())); | 477 session_modal_widget->GetNativeView())); |
486 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 478 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
487 ->layout_manager(), | 479 ->layout_manager(), |
488 controller->GetSystemModalLayoutManager(NULL)); | 480 controller->GetSystemModalLayoutManager(NULL)); |
489 session_modal_widget->Close(); | 481 session_modal_widget->Close(); |
490 | 482 |
491 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 483 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
492 | 484 |
493 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) | 485 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) |
494 ->layout_manager(), | 486 ->layout_manager(), |
495 controller->GetSystemModalLayoutManager(NULL)); | 487 controller->GetSystemModalLayoutManager(NULL)); |
496 | 488 |
497 views::Widget* lock_modal_widget = | 489 views::Widget* lock_modal_widget = CreateModalWidgetWithParent( |
498 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), | 490 gfx::Rect(300, 10, 100, 100), lock_container); |
499 lock_container); | |
500 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) | 491 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) |
501 ->layout_manager(), | 492 ->layout_manager(), |
502 controller->GetSystemModalLayoutManager( | 493 controller->GetSystemModalLayoutManager( |
503 lock_modal_widget->GetNativeView())); | 494 lock_modal_widget->GetNativeView())); |
504 | 495 |
505 session_modal_widget = | 496 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
506 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | |
507 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) | 497 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) |
508 ->layout_manager(), | 498 ->layout_manager(), |
509 controller->GetSystemModalLayoutManager( | 499 controller->GetSystemModalLayoutManager( |
510 session_modal_widget->GetNativeView())); | 500 session_modal_widget->GetNativeView())); |
511 session_modal_widget->Close(); | 501 session_modal_widget->Close(); |
512 | 502 |
513 lock_modal_widget->Close(); | 503 lock_modal_widget->Close(); |
514 UnblockUserSession(); | 504 UnblockUserSession(); |
515 } | 505 } |
516 } | 506 } |
517 | 507 |
518 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { | 508 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { |
519 UpdateDisplay("600x600"); | 509 UpdateDisplay("600x600"); |
520 RootWindowController* controller = | 510 RootWindowController* controller = |
521 Shell::GetInstance()->GetPrimaryRootWindowController(); | 511 Shell::GetInstance()->GetPrimaryRootWindowController(); |
522 | 512 |
523 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 513 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
524 w1->Maximize(); | 514 w1->Maximize(); |
525 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 515 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
526 w2->SetFullscreen(true); | 516 w2->SetFullscreen(true); |
527 // |w3| is a transient child of |w2|. | 517 // |w3| is a transient child of |w2|. |
528 Widget* w3 = Widget::CreateWindowWithParentAndBounds(NULL, | 518 Widget* w3 = Widget::CreateWindowWithParentAndBounds( |
529 w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 519 NULL, w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
530 | 520 |
531 // Test that GetWindowForFullscreenMode() finds the fullscreen window when one | 521 // Test that GetWindowForFullscreenMode() finds the fullscreen window when one |
532 // of its transient children is active. | 522 // of its transient children is active. |
533 w3->Activate(); | 523 w3->Activate(); |
534 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); | 524 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); |
535 | 525 |
536 // If the topmost window is not fullscreen, it returns NULL. | 526 // If the topmost window is not fullscreen, it returns NULL. |
537 w1->Activate(); | 527 w1->Activate(); |
538 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); | 528 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); |
539 w1->Close(); | 529 w1->Close(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 } | 606 } |
617 | 607 |
618 // Test that user session window can't be focused if user session blocked by | 608 // Test that user session window can't be focused if user session blocked by |
619 // some overlapping UI. | 609 // some overlapping UI. |
620 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { | 610 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { |
621 UpdateDisplay("600x600"); | 611 UpdateDisplay("600x600"); |
622 RootWindowController* controller = | 612 RootWindowController* controller = |
623 Shell::GetInstance()->GetPrimaryRootWindowController(); | 613 Shell::GetInstance()->GetPrimaryRootWindowController(); |
624 aura::Window* lock_container = | 614 aura::Window* lock_container = |
625 controller->GetContainer(kShellWindowId_LockScreenContainer); | 615 controller->GetContainer(kShellWindowId_LockScreenContainer); |
626 aura::Window* lock_window = Widget::CreateWindowWithParentAndBounds(NULL, | 616 aura::Window* lock_window = |
627 lock_container, gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 617 Widget::CreateWindowWithParentAndBounds(NULL, lock_container, |
| 618 gfx::Rect(0, 0, 100, 100)) |
| 619 ->GetNativeView(); |
628 lock_window->Show(); | 620 lock_window->Show(); |
629 aura::Window* session_window = | 621 aura::Window* session_window = |
630 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); | 622 CreateTestWidget(gfx::Rect(0, 0, 100, 100))->GetNativeView(); |
631 session_window->Show(); | 623 session_window->Show(); |
632 | 624 |
633 for (int block_reason = FIRST_BLOCK_REASON; | 625 for (int block_reason = FIRST_BLOCK_REASON; |
634 block_reason < NUMBER_OF_BLOCK_REASONS; | 626 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { |
635 ++block_reason) { | |
636 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 627 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
637 lock_window->Focus(); | 628 lock_window->Focus(); |
638 EXPECT_TRUE(lock_window->HasFocus()); | 629 EXPECT_TRUE(lock_window->HasFocus()); |
639 session_window->Focus(); | 630 session_window->Focus(); |
640 EXPECT_FALSE(session_window->HasFocus()); | 631 EXPECT_FALSE(session_window->HasFocus()); |
641 UnblockUserSession(); | 632 UnblockUserSession(); |
642 } | 633 } |
643 } | 634 } |
644 | 635 |
645 // Tracks whether OnWindowDestroying() has been invoked. | 636 // Tracks whether OnWindowDestroying() has been invoked. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 721 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
731 keyboard::KeyboardController::GetInstance()); | 722 keyboard::KeyboardController::GetInstance()); |
732 } | 723 } |
733 | 724 |
734 private: | 725 private: |
735 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); | 726 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); |
736 }; | 727 }; |
737 | 728 |
738 class MockTextInputClient : public ui::DummyTextInputClient { | 729 class MockTextInputClient : public ui::DummyTextInputClient { |
739 public: | 730 public: |
740 MockTextInputClient() : | 731 MockTextInputClient() : ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} |
741 ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} | |
742 | 732 |
743 void EnsureCaretInRect(const gfx::Rect& rect) override { | 733 void EnsureCaretInRect(const gfx::Rect& rect) override { |
744 visible_rect_ = rect; | 734 visible_rect_ = rect; |
745 } | 735 } |
746 | 736 |
747 const gfx::Rect& visible_rect() const { | 737 const gfx::Rect& visible_rect() const { return visible_rect_; } |
748 return visible_rect_; | |
749 } | |
750 | 738 |
751 private: | 739 private: |
752 gfx::Rect visible_rect_; | 740 gfx::Rect visible_rect_; |
753 | 741 |
754 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); | 742 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); |
755 }; | 743 }; |
756 | 744 |
757 class TargetHitTestEventHandler : public ui::test::TestEventHandler { | 745 class TargetHitTestEventHandler : public ui::test::TestEventHandler { |
758 public: | 746 public: |
759 TargetHitTestEventHandler() {} | 747 TargetHitTestEventHandler() {} |
(...skipping 13 matching lines...) Expand all Loading... |
773 // on primary root window. | 761 // on primary root window. |
774 TEST_F(VirtualKeyboardRootWindowControllerTest, | 762 TEST_F(VirtualKeyboardRootWindowControllerTest, |
775 VirtualKeyboardOnPrimaryRootWindowOnly) { | 763 VirtualKeyboardOnPrimaryRootWindowOnly) { |
776 if (!SupportsMultipleDisplays()) | 764 if (!SupportsMultipleDisplays()) |
777 return; | 765 return; |
778 | 766 |
779 UpdateDisplay("500x500,500x500"); | 767 UpdateDisplay("500x500,500x500"); |
780 | 768 |
781 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 769 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
782 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | 770 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); |
783 aura::Window* secondary_root_window = | 771 aura::Window* secondary_root_window = root_windows[0] == primary_root_window |
784 root_windows[0] == primary_root_window ? | 772 ? root_windows[1] |
785 root_windows[1] : root_windows[0]; | 773 : root_windows[0]; |
786 | 774 |
787 ASSERT_TRUE(Shell::GetContainer(primary_root_window, | 775 ASSERT_TRUE(Shell::GetContainer(primary_root_window, |
788 kShellWindowId_VirtualKeyboardContainer)); | 776 kShellWindowId_VirtualKeyboardContainer)); |
789 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, | 777 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, |
790 kShellWindowId_VirtualKeyboardContainer)); | 778 kShellWindowId_VirtualKeyboardContainer)); |
791 } | 779 } |
792 | 780 |
793 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive | 781 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive |
794 // events at blocked user session. | 782 // events at blocked user session. |
795 TEST_F(VirtualKeyboardRootWindowControllerTest, | 783 TEST_F(VirtualKeyboardRootWindowControllerTest, |
(...skipping 13 matching lines...) Expand all Loading... |
809 | 797 |
810 ui::test::TestEventHandler handler; | 798 ui::test::TestEventHandler handler; |
811 root_window->AddPreTargetHandler(&handler); | 799 root_window->AddPreTargetHandler(&handler); |
812 | 800 |
813 ui::test::EventGenerator event_generator(root_window, keyboard_window); | 801 ui::test::EventGenerator event_generator(root_window, keyboard_window); |
814 event_generator.ClickLeftButton(); | 802 event_generator.ClickLeftButton(); |
815 int expected_mouse_presses = 1; | 803 int expected_mouse_presses = 1; |
816 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); | 804 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); |
817 | 805 |
818 for (int block_reason = FIRST_BLOCK_REASON; | 806 for (int block_reason = FIRST_BLOCK_REASON; |
819 block_reason < NUMBER_OF_BLOCK_REASONS; | 807 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { |
820 ++block_reason) { | |
821 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 808 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
822 event_generator.ClickLeftButton(); | 809 event_generator.ClickLeftButton(); |
823 expected_mouse_presses++; | 810 expected_mouse_presses++; |
824 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); | 811 EXPECT_EQ(expected_mouse_presses, handler.num_mouse_events() / 2); |
825 UnblockUserSession(); | 812 UnblockUserSession(); |
826 } | 813 } |
827 root_window->RemovePreTargetHandler(&handler); | 814 root_window->RemovePreTargetHandler(&handler); |
828 } | 815 } |
829 | 816 |
830 // Test for http://crbug.com/299787. RootWindowController should delete | 817 // Test for http://crbug.com/299787. RootWindowController should delete |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 keyboard_window->set_owned_by_parent(false); | 881 keyboard_window->set_owned_by_parent(false); |
895 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( | 882 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( |
896 root_window->bounds(), 100)); | 883 root_window->bounds(), 100)); |
897 | 884 |
898 ui::test::TestEventHandler handler; | 885 ui::test::TestEventHandler handler; |
899 root_window->AddPreTargetHandler(&handler); | 886 root_window->AddPreTargetHandler(&handler); |
900 ui::test::EventGenerator root_window_event_generator(root_window); | 887 ui::test::EventGenerator root_window_event_generator(root_window); |
901 ui::test::EventGenerator keyboard_event_generator(root_window, | 888 ui::test::EventGenerator keyboard_event_generator(root_window, |
902 keyboard_window); | 889 keyboard_window); |
903 | 890 |
904 views::Widget* modal_widget = | 891 views::Widget* modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
905 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | |
906 | 892 |
907 // Verify that mouse events to the root window are block with a visble modal | 893 // Verify that mouse events to the root window are block with a visble modal |
908 // dialog. | 894 // dialog. |
909 root_window_event_generator.ClickLeftButton(); | 895 root_window_event_generator.ClickLeftButton(); |
910 EXPECT_EQ(0, handler.num_mouse_events()); | 896 EXPECT_EQ(0, handler.num_mouse_events()); |
911 | 897 |
912 // Verify that event dispatch to the virtual keyboard is unblocked. | 898 // Verify that event dispatch to the virtual keyboard is unblocked. |
913 keyboard_event_generator.ClickLeftButton(); | 899 keyboard_event_generator.ClickLeftButton(); |
914 EXPECT_EQ(1, handler.num_mouse_events() / 2); | 900 EXPECT_EQ(1, handler.num_mouse_events() / 2); |
915 | 901 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1046 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
1061 gfx::Rect(0, 400, 800, 200)); | 1047 gfx::Rect(0, 400, 800, 200)); |
1062 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1048 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
1063 | 1049 |
1064 UpdateDisplay("600x800"); | 1050 UpdateDisplay("600x800"); |
1065 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1051 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
1066 } | 1052 } |
1067 | 1053 |
1068 } // namespace test | 1054 } // namespace test |
1069 } // namespace ash | 1055 } // namespace ash |
OLD | NEW |