| 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/wm/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool AllRootWindowsHaveModalBackgrounds() { | 59 bool AllRootWindowsHaveModalBackgrounds() { |
| 60 return AllRootWindowsHaveModalBackgroundsForContainer( | 60 return AllRootWindowsHaveModalBackgroundsForContainer( |
| 61 kShellWindowId_SystemModalContainer); | 61 kShellWindowId_SystemModalContainer); |
| 62 } | 62 } |
| 63 | 63 |
| 64 class TestWindow : public views::WidgetDelegateView { | 64 class TestWindow : public views::WidgetDelegateView { |
| 65 public: | 65 public: |
| 66 explicit TestWindow(bool modal) : modal_(modal) {} | 66 explicit TestWindow(bool modal) : modal_(modal) {} |
| 67 virtual ~TestWindow() {} | 67 ~TestWindow() override {} |
| 68 | 68 |
| 69 // The window needs be closed from widget in order for | 69 // The window needs be closed from widget in order for |
| 70 // aura::client::kModalKey property to be reset. | 70 // aura::client::kModalKey property to be reset. |
| 71 static void CloseTestWindow(aura::Window* window) { | 71 static void CloseTestWindow(aura::Window* window) { |
| 72 views::Widget::GetWidgetForNativeWindow(window)->Close(); | 72 views::Widget::GetWidgetForNativeWindow(window)->Close(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Overridden from views::View: | 75 // Overridden from views::View: |
| 76 virtual gfx::Size GetPreferredSize() const override { | 76 gfx::Size GetPreferredSize() const override { return gfx::Size(50, 50); } |
| 77 return gfx::Size(50, 50); | |
| 78 } | |
| 79 | 77 |
| 80 // Overridden from views::WidgetDelegate: | 78 // Overridden from views::WidgetDelegate: |
| 81 virtual views::View* GetContentsView() override { | 79 views::View* GetContentsView() override { return this; } |
| 82 return this; | 80 ui::ModalType GetModalType() const override { |
| 83 } | |
| 84 virtual ui::ModalType GetModalType() const override { | |
| 85 return modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; | 81 return modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; |
| 86 } | 82 } |
| 87 | 83 |
| 88 private: | 84 private: |
| 89 bool modal_; | 85 bool modal_; |
| 90 | 86 |
| 91 DISALLOW_COPY_AND_ASSIGN(TestWindow); | 87 DISALLOW_COPY_AND_ASSIGN(TestWindow); |
| 92 }; | 88 }; |
| 93 | 89 |
| 94 class EventTestWindow : public TestWindow { | 90 class EventTestWindow : public TestWindow { |
| 95 public: | 91 public: |
| 96 explicit EventTestWindow(bool modal) : TestWindow(modal), | 92 explicit EventTestWindow(bool modal) : TestWindow(modal), |
| 97 mouse_presses_(0) {} | 93 mouse_presses_(0) {} |
| 98 virtual ~EventTestWindow() {} | 94 ~EventTestWindow() override {} |
| 99 | 95 |
| 100 aura::Window* OpenTestWindowWithContext(aura::Window* context) { | 96 aura::Window* OpenTestWindowWithContext(aura::Window* context) { |
| 101 views::Widget* widget = | 97 views::Widget* widget = |
| 102 views::Widget::CreateWindowWithContext(this, context); | 98 views::Widget::CreateWindowWithContext(this, context); |
| 103 widget->Show(); | 99 widget->Show(); |
| 104 return widget->GetNativeView(); | 100 return widget->GetNativeView(); |
| 105 } | 101 } |
| 106 | 102 |
| 107 aura::Window* OpenTestWindowWithParent(aura::Window* parent) { | 103 aura::Window* OpenTestWindowWithParent(aura::Window* parent) { |
| 108 DCHECK(parent); | 104 DCHECK(parent); |
| 109 views::Widget* widget = | 105 views::Widget* widget = |
| 110 views::Widget::CreateWindowWithParent(this, parent); | 106 views::Widget::CreateWindowWithParent(this, parent); |
| 111 widget->Show(); | 107 widget->Show(); |
| 112 return widget->GetNativeView(); | 108 return widget->GetNativeView(); |
| 113 } | 109 } |
| 114 | 110 |
| 115 // Overridden from views::View: | 111 // Overridden from views::View: |
| 116 virtual bool OnMousePressed(const ui::MouseEvent& event) override { | 112 bool OnMousePressed(const ui::MouseEvent& event) override { |
| 117 mouse_presses_++; | 113 mouse_presses_++; |
| 118 return false; | 114 return false; |
| 119 } | 115 } |
| 120 | 116 |
| 121 int mouse_presses() const { return mouse_presses_; } | 117 int mouse_presses() const { return mouse_presses_; } |
| 122 private: | 118 private: |
| 123 int mouse_presses_; | 119 int mouse_presses_; |
| 124 | 120 |
| 125 DISALLOW_COPY_AND_ASSIGN(EventTestWindow); | 121 DISALLOW_COPY_AND_ASSIGN(EventTestWindow); |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 class TransientWindowObserver : public aura::WindowObserver { | 124 class TransientWindowObserver : public aura::WindowObserver { |
| 129 public: | 125 public: |
| 130 TransientWindowObserver() : destroyed_(false) {} | 126 TransientWindowObserver() : destroyed_(false) {} |
| 131 virtual ~TransientWindowObserver() {} | 127 ~TransientWindowObserver() override {} |
| 132 | 128 |
| 133 bool destroyed() const { return destroyed_; } | 129 bool destroyed() const { return destroyed_; } |
| 134 | 130 |
| 135 // Overridden from aura::WindowObserver: | 131 // Overridden from aura::WindowObserver: |
| 136 virtual void OnWindowDestroyed(aura::Window* window) override { | 132 void OnWindowDestroyed(aura::Window* window) override { destroyed_ = true; } |
| 137 destroyed_ = true; | |
| 138 } | |
| 139 | 133 |
| 140 private: | 134 private: |
| 141 bool destroyed_; | 135 bool destroyed_; |
| 142 | 136 |
| 143 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); | 137 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); |
| 144 }; | 138 }; |
| 145 | 139 |
| 146 } // namespace | 140 } // namespace |
| 147 | 141 |
| 148 class SystemModalContainerLayoutManagerTest : public AshTestBase { | 142 class SystemModalContainerLayoutManagerTest : public AshTestBase { |
| 149 public: | 143 public: |
| 150 virtual void SetUp() override { | 144 void SetUp() override { |
| 151 // Allow a virtual keyboard (and initialize it per default). | 145 // Allow a virtual keyboard (and initialize it per default). |
| 152 CommandLine::ForCurrentProcess()->AppendSwitch( | 146 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 153 keyboard::switches::kEnableVirtualKeyboard); | 147 keyboard::switches::kEnableVirtualKeyboard); |
| 154 AshTestBase::SetUp(); | 148 AshTestBase::SetUp(); |
| 155 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 149 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
| 156 keyboard::KeyboardController::GetInstance()); | 150 keyboard::KeyboardController::GetInstance()); |
| 157 } | 151 } |
| 158 | 152 |
| 159 virtual void TearDown() override { | 153 void TearDown() override { |
| 160 Shell::GetPrimaryRootWindowController()->DeactivateKeyboard( | 154 Shell::GetPrimaryRootWindowController()->DeactivateKeyboard( |
| 161 keyboard::KeyboardController::GetInstance()); | 155 keyboard::KeyboardController::GetInstance()); |
| 162 AshTestBase::TearDown(); | 156 AshTestBase::TearDown(); |
| 163 } | 157 } |
| 164 | 158 |
| 165 aura::Window* OpenToplevelTestWindow(bool modal) { | 159 aura::Window* OpenToplevelTestWindow(bool modal) { |
| 166 views::Widget* widget = views::Widget::CreateWindowWithContext( | 160 views::Widget* widget = views::Widget::CreateWindowWithContext( |
| 167 new TestWindow(modal), CurrentContext()); | 161 new TestWindow(modal), CurrentContext()); |
| 168 widget->Show(); | 162 widget->Show(); |
| 169 return widget->GetNativeView(); | 163 return widget->GetNativeView(); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 ShowKeyboard(true); | 644 ShowKeyboard(true); |
| 651 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); | 645 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
| 652 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); | 646 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
| 653 EXPECT_EQ(0, modal_window->bounds().y()); | 647 EXPECT_EQ(0, modal_window->bounds().y()); |
| 654 | 648 |
| 655 ShowKeyboard(false); | 649 ShowKeyboard(false); |
| 656 } | 650 } |
| 657 | 651 |
| 658 } // namespace test | 652 } // namespace test |
| 659 } // namespace ash | 653 } // namespace ash |
| OLD | NEW |