| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 explicit TestWindow(bool modal) : modal_(modal) {} | 66 explicit TestWindow(bool modal) : modal_(modal) {} |
| 67 virtual ~TestWindow() {} | 67 virtual ~TestWindow() {} |
| 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 virtual gfx::Size GetPreferredSize() const override { |
| 77 return gfx::Size(50, 50); | 77 return gfx::Size(50, 50); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Overridden from views::WidgetDelegate: | 80 // Overridden from views::WidgetDelegate: |
| 81 virtual views::View* GetContentsView() OVERRIDE { | 81 virtual views::View* GetContentsView() override { |
| 82 return this; | 82 return this; |
| 83 } | 83 } |
| 84 virtual ui::ModalType GetModalType() const OVERRIDE { | 84 virtual ui::ModalType GetModalType() const override { |
| 85 return modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; | 85 return modal_ ? ui::MODAL_TYPE_SYSTEM : ui::MODAL_TYPE_NONE; |
| 86 } | 86 } |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 bool modal_; | 89 bool modal_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(TestWindow); | 91 DISALLOW_COPY_AND_ASSIGN(TestWindow); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 class EventTestWindow : public TestWindow { | 94 class EventTestWindow : public TestWindow { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 aura::Window* OpenTestWindowWithParent(aura::Window* parent) { | 107 aura::Window* OpenTestWindowWithParent(aura::Window* parent) { |
| 108 DCHECK(parent); | 108 DCHECK(parent); |
| 109 views::Widget* widget = | 109 views::Widget* widget = |
| 110 views::Widget::CreateWindowWithParent(this, parent); | 110 views::Widget::CreateWindowWithParent(this, parent); |
| 111 widget->Show(); | 111 widget->Show(); |
| 112 return widget->GetNativeView(); | 112 return widget->GetNativeView(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Overridden from views::View: | 115 // Overridden from views::View: |
| 116 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 116 virtual bool OnMousePressed(const ui::MouseEvent& event) override { |
| 117 mouse_presses_++; | 117 mouse_presses_++; |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 | 120 |
| 121 int mouse_presses() const { return mouse_presses_; } | 121 int mouse_presses() const { return mouse_presses_; } |
| 122 private: | 122 private: |
| 123 int mouse_presses_; | 123 int mouse_presses_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(EventTestWindow); | 125 DISALLOW_COPY_AND_ASSIGN(EventTestWindow); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class TransientWindowObserver : public aura::WindowObserver { | 128 class TransientWindowObserver : public aura::WindowObserver { |
| 129 public: | 129 public: |
| 130 TransientWindowObserver() : destroyed_(false) {} | 130 TransientWindowObserver() : destroyed_(false) {} |
| 131 virtual ~TransientWindowObserver() {} | 131 virtual ~TransientWindowObserver() {} |
| 132 | 132 |
| 133 bool destroyed() const { return destroyed_; } | 133 bool destroyed() const { return destroyed_; } |
| 134 | 134 |
| 135 // Overridden from aura::WindowObserver: | 135 // Overridden from aura::WindowObserver: |
| 136 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE { | 136 virtual void OnWindowDestroyed(aura::Window* window) override { |
| 137 destroyed_ = true; | 137 destroyed_ = true; |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 bool destroyed_; | 141 bool destroyed_; |
| 142 | 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); | 143 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 } // namespace | 146 } // namespace |
| 147 | 147 |
| 148 class SystemModalContainerLayoutManagerTest : public AshTestBase { | 148 class SystemModalContainerLayoutManagerTest : public AshTestBase { |
| 149 public: | 149 public: |
| 150 virtual void SetUp() OVERRIDE { | 150 virtual void SetUp() override { |
| 151 // Allow a virtual keyboard (and initialize it per default). | 151 // Allow a virtual keyboard (and initialize it per default). |
| 152 CommandLine::ForCurrentProcess()->AppendSwitch( | 152 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 153 keyboard::switches::kEnableVirtualKeyboard); | 153 keyboard::switches::kEnableVirtualKeyboard); |
| 154 AshTestBase::SetUp(); | 154 AshTestBase::SetUp(); |
| 155 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( | 155 Shell::GetPrimaryRootWindowController()->ActivateKeyboard( |
| 156 keyboard::KeyboardController::GetInstance()); | 156 keyboard::KeyboardController::GetInstance()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 virtual void TearDown() OVERRIDE { | 159 virtual void TearDown() override { |
| 160 Shell::GetPrimaryRootWindowController()->DeactivateKeyboard( | 160 Shell::GetPrimaryRootWindowController()->DeactivateKeyboard( |
| 161 keyboard::KeyboardController::GetInstance()); | 161 keyboard::KeyboardController::GetInstance()); |
| 162 AshTestBase::TearDown(); | 162 AshTestBase::TearDown(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 aura::Window* OpenToplevelTestWindow(bool modal) { | 165 aura::Window* OpenToplevelTestWindow(bool modal) { |
| 166 views::Widget* widget = views::Widget::CreateWindowWithContext( | 166 views::Widget* widget = views::Widget::CreateWindowWithContext( |
| 167 new TestWindow(modal), CurrentContext()); | 167 new TestWindow(modal), CurrentContext()); |
| 168 widget->Show(); | 168 widget->Show(); |
| 169 return widget->GetNativeView(); | 169 return widget->GetNativeView(); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 ShowKeyboard(true); | 650 ShowKeyboard(true); |
| 651 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); | 651 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); |
| 652 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); | 652 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); |
| 653 EXPECT_EQ(0, modal_window->bounds().y()); | 653 EXPECT_EQ(0, modal_window->bounds().y()); |
| 654 | 654 |
| 655 ShowKeyboard(false); | 655 ShowKeyboard(false); |
| 656 } | 656 } |
| 657 | 657 |
| 658 } // namespace test | 658 } // namespace test |
| 659 } // namespace ash | 659 } // namespace ash |
| OLD | NEW |