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/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ash/wm/system_modal_container_layout_manager.h" | 13 #include "ash/wm/system_modal_container_layout_manager.h" |
14 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
15 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 16 #include "base/command_line.h" |
16 #include "ui/aura/client/focus_change_observer.h" | 17 #include "ui/aura/client/focus_change_observer.h" |
17 #include "ui/aura/client/focus_client.h" | 18 #include "ui/aura/client/focus_client.h" |
18 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
19 #include "ui/aura/root_window.h" | 20 #include "ui/aura/root_window.h" |
20 #include "ui/aura/test/event_generator.h" | 21 #include "ui/aura/test/event_generator.h" |
21 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
22 #include "ui/aura/test/test_windows.h" | 23 #include "ui/aura/test/test_windows.h" |
23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
24 #include "ui/aura/window_tracker.h" | 25 #include "ui/aura/window_tracker.h" |
| 26 #include "ui/keyboard/keyboard_switches.h" |
25 #include "ui/views/controls/menu/menu_controller.h" | 27 #include "ui/views/controls/menu/menu_controller.h" |
26 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
27 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
28 | 30 |
29 using aura::Window; | 31 using aura::Window; |
30 using views::Widget; | 32 using views::Widget; |
31 | 33 |
32 namespace ash { | 34 namespace ash { |
33 namespace { | 35 namespace { |
34 | 36 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 aura::Window* lost_focus) OVERRIDE { | 75 aura::Window* lost_focus) OVERRIDE { |
74 if (window_ == lost_focus) | 76 if (window_ == lost_focus) |
75 delete window_; | 77 delete window_; |
76 } | 78 } |
77 | 79 |
78 aura::Window* window_; | 80 aura::Window* window_; |
79 | 81 |
80 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); | 82 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
81 }; | 83 }; |
82 | 84 |
| 85 class ClickTestWindow : public views::WidgetDelegateView { |
| 86 public: |
| 87 ClickTestWindow() : mouse_presses_(0) {} |
| 88 virtual ~ClickTestWindow() {} |
| 89 |
| 90 // Overridden from views::WidgetDelegate: |
| 91 virtual views::View* GetContentsView() OVERRIDE { |
| 92 return this; |
| 93 } |
| 94 |
| 95 aura::Window* CreateTestWindowWithParent(aura::Window* parent) { |
| 96 DCHECK(parent); |
| 97 views::Widget* widget = Widget::CreateWindowWithParent(this, parent); |
| 98 return widget->GetNativeView(); |
| 99 } |
| 100 |
| 101 // Overridden from views::View: |
| 102 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { |
| 103 mouse_presses_++; |
| 104 return false; |
| 105 } |
| 106 |
| 107 int mouse_presses() const { return mouse_presses_; } |
| 108 |
| 109 private: |
| 110 int mouse_presses_; |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(ClickTestWindow); |
| 113 }; |
| 114 |
83 } // namespace | 115 } // namespace |
84 | 116 |
85 namespace test { | 117 namespace test { |
86 | 118 |
87 class RootWindowControllerTest : public test::AshTestBase { | 119 class RootWindowControllerTest : public test::AshTestBase { |
88 public: | 120 public: |
89 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | 121 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
90 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 122 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
91 NULL, CurrentContext(), bounds); | 123 NULL, CurrentContext(), bounds); |
92 widget->Show(); | 124 widget->Show(); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1))); | 517 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1))); |
486 EXPECT_EQ(event_target, | 518 EXPECT_EQ(event_target, |
487 root->GetEventHandlerForPoint(gfx::Point(size.width() - 1, 0))); | 519 root->GetEventHandlerForPoint(gfx::Point(size.width() - 1, 0))); |
488 EXPECT_EQ(event_target, | 520 EXPECT_EQ(event_target, |
489 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1))); | 521 root->GetEventHandlerForPoint(gfx::Point(0, size.height() - 1))); |
490 EXPECT_EQ(event_target, | 522 EXPECT_EQ(event_target, |
491 root->GetEventHandlerForPoint( | 523 root->GetEventHandlerForPoint( |
492 gfx::Point(size.width() - 1, size.height() - 1))); | 524 gfx::Point(size.width() - 1, size.height() - 1))); |
493 } | 525 } |
494 | 526 |
| 527 class VirtualKeyboardRootWindowControllerTest : public test::AshTestBase { |
| 528 public: |
| 529 VirtualKeyboardRootWindowControllerTest() {}; |
| 530 virtual ~VirtualKeyboardRootWindowControllerTest() {}; |
| 531 |
| 532 virtual void SetUp() OVERRIDE { |
| 533 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 534 keyboard::switches::kEnableVirtualKeyboard); |
| 535 test::AshTestBase::SetUp(); |
| 536 } |
| 537 |
| 538 private: |
| 539 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); |
| 540 }; |
| 541 |
| 542 // Test for http://crbug.com/263599. Virtual keyboard should be able to receive |
| 543 // events at blocked user session. |
| 544 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 545 ClickVirtualKeyboardInBlockedWindow) { |
| 546 aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow(); |
| 547 aura::Window* keyboard_container = Shell::GetContainer(root_window, |
| 548 internal::kShellWindowId_VirtualKeyboardContainer); |
| 549 ASSERT_TRUE(keyboard_container); |
| 550 keyboard_container->Show(); |
| 551 |
| 552 ClickTestWindow* main_delegate = new ClickTestWindow(); |
| 553 scoped_ptr<aura::Window> keyboard_window( |
| 554 main_delegate->CreateTestWindowWithParent(keyboard_container)); |
| 555 keyboard_container->layout_manager()->OnWindowResized(); |
| 556 keyboard_window->Show(); |
| 557 aura::test::EventGenerator event_generator(root_window, |
| 558 keyboard_window.get()); |
| 559 event_generator.ClickLeftButton(); |
| 560 int expected_mouse_presses = 1; |
| 561 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); |
| 562 |
| 563 for (int block_reason = FIRST_BLOCK_REASON; |
| 564 block_reason < NUMBER_OF_BLOCK_REASONS; |
| 565 ++block_reason) { |
| 566 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
| 567 event_generator.ClickLeftButton(); |
| 568 expected_mouse_presses++; |
| 569 EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses()); |
| 570 UnblockUserSession(); |
| 571 } |
| 572 } |
| 573 |
495 } // namespace test | 574 } // namespace test |
496 } // namespace ash | 575 } // namespace ash |
OLD | NEW |