| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/always_on_top_controller.h" | 5 #include "ash/wm/always_on_top_controller.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 keyboard::switches::kEnableVirtualKeyboard); | 30 keyboard::switches::kEnableVirtualKeyboard); |
| 31 test::AshTestBase::SetUp(); | 31 test::AshTestBase::SetUp(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardAlwaysOnTopControllerTest); | 35 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardAlwaysOnTopControllerTest); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 class TestLayoutManager : public WorkspaceLayoutManager { | 38 class TestLayoutManager : public WorkspaceLayoutManager { |
| 39 public: | 39 public: |
| 40 explicit TestLayoutManager(WmWindow* window) | 40 explicit TestLayoutManager(aura::Window* window) |
| 41 : WorkspaceLayoutManager(window), keyboard_bounds_changed_(false) {} | 41 : WorkspaceLayoutManager(window), keyboard_bounds_changed_(false) {} |
| 42 | 42 |
| 43 ~TestLayoutManager() override {} | 43 ~TestLayoutManager() override {} |
| 44 | 44 |
| 45 void OnKeyboardBoundsChanging(const gfx::Rect& bounds) override { | 45 void OnKeyboardBoundsChanging(const gfx::Rect& bounds) override { |
| 46 keyboard_bounds_changed_ = true; | 46 keyboard_bounds_changed_ = true; |
| 47 WorkspaceLayoutManager::OnKeyboardBoundsChanging(bounds); | 47 WorkspaceLayoutManager::OnKeyboardBoundsChanging(bounds); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool keyboard_bounds_changed() const { return keyboard_bounds_changed_; } | 50 bool keyboard_bounds_changed() const { return keyboard_bounds_changed_; } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 bool keyboard_bounds_changed_; | 53 bool keyboard_bounds_changed_; |
| 54 DISALLOW_COPY_AND_ASSIGN(TestLayoutManager); | 54 DISALLOW_COPY_AND_ASSIGN(TestLayoutManager); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // Verifies that the always on top controller is notified of keyboard bounds | 57 // Verifies that the always on top controller is notified of keyboard bounds |
| 58 // changing events. | 58 // changing events. |
| 59 TEST_F(VirtualKeyboardAlwaysOnTopControllerTest, NotifyKeyboardBoundsChanged) { | 59 TEST_F(VirtualKeyboardAlwaysOnTopControllerTest, NotifyKeyboardBoundsChanged) { |
| 60 keyboard::KeyboardController* keyboard_controller = | 60 keyboard::KeyboardController* keyboard_controller = |
| 61 keyboard::KeyboardController::GetInstance(); | 61 keyboard::KeyboardController::GetInstance(); |
| 62 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 62 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 63 aura::Window* always_on_top_container = | 63 aura::Window* always_on_top_container = |
| 64 Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); | 64 Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); |
| 65 // Install test layout manager. | 65 // Install test layout manager. |
| 66 TestLayoutManager* manager = | 66 TestLayoutManager* manager = new TestLayoutManager(always_on_top_container); |
| 67 new TestLayoutManager(WmWindow::Get(always_on_top_container)); | |
| 68 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 67 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
| 69 // Deactivates keyboard to unregister existing listeners. | 68 // Deactivates keyboard to unregister existing listeners. |
| 70 controller->DeactivateKeyboard(keyboard_controller); | 69 controller->DeactivateKeyboard(keyboard_controller); |
| 71 AlwaysOnTopController* always_on_top_controller = | 70 AlwaysOnTopController* always_on_top_controller = |
| 72 controller->always_on_top_controller(); | 71 controller->always_on_top_controller(); |
| 73 always_on_top_controller->SetLayoutManagerForTest(base::WrapUnique(manager)); | 72 always_on_top_controller->SetLayoutManagerForTest(base::WrapUnique(manager)); |
| 74 // Activate keyboard. This triggers keyboard listeners to be registered. | 73 // Activate keyboard. This triggers keyboard listeners to be registered. |
| 75 controller->ActivateKeyboard(keyboard_controller); | 74 controller->ActivateKeyboard(keyboard_controller); |
| 76 | 75 |
| 77 // Mock a keyboard appearing. | 76 // Mock a keyboard appearing. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 root_window->bounds(), kKeyboardHeight); | 87 root_window->bounds(), kKeyboardHeight); |
| 89 keyboard_window->SetBounds(keyboard_bounds); | 88 keyboard_window->SetBounds(keyboard_bounds); |
| 90 keyboard_window->Show(); | 89 keyboard_window->Show(); |
| 91 keyboard_controller->NotifyKeyboardBoundsChanging(keyboard_bounds); | 90 keyboard_controller->NotifyKeyboardBoundsChanging(keyboard_bounds); |
| 92 // Verify that test manager was notified of bounds change. | 91 // Verify that test manager was notified of bounds change. |
| 93 ASSERT_TRUE(manager->keyboard_bounds_changed()); | 92 ASSERT_TRUE(manager->keyboard_bounds_changed()); |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace test | 95 } // namespace test |
| 97 } // namespace ash | 96 } // namespace ash |
| OLD | NEW |