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/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 kShellWindowId_ImeWindowParentContainer)); | 85 kShellWindowId_ImeWindowParentContainer)); |
86 #if defined(OS_CHROMEOS) | 86 #if defined(OS_CHROMEOS) |
87 EXPECT_TRUE( | 87 EXPECT_TRUE( |
88 Shell::GetContainer(root_window, kShellWindowId_MouseCursorContainer)); | 88 Shell::GetContainer(root_window, kShellWindowId_MouseCursorContainer)); |
89 #endif | 89 #endif |
90 } | 90 } |
91 | 91 |
92 class ModalWindow : public views::WidgetDelegateView { | 92 class ModalWindow : public views::WidgetDelegateView { |
93 public: | 93 public: |
94 ModalWindow() {} | 94 ModalWindow() {} |
95 virtual ~ModalWindow() {} | 95 ~ModalWindow() override {} |
96 | 96 |
97 // Overridden from views::WidgetDelegate: | 97 // Overridden from views::WidgetDelegate: |
98 virtual views::View* GetContentsView() override { | 98 views::View* GetContentsView() override { return this; } |
99 return this; | 99 bool CanResize() const override { return true; } |
100 } | 100 base::string16 GetWindowTitle() const override { |
101 virtual bool CanResize() const override { | |
102 return true; | |
103 } | |
104 virtual base::string16 GetWindowTitle() const override { | |
105 return base::ASCIIToUTF16("Modal Window"); | 101 return base::ASCIIToUTF16("Modal Window"); |
106 } | 102 } |
107 virtual ui::ModalType GetModalType() const override { | 103 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } |
108 return ui::MODAL_TYPE_SYSTEM; | |
109 } | |
110 | 104 |
111 private: | 105 private: |
112 DISALLOW_COPY_AND_ASSIGN(ModalWindow); | 106 DISALLOW_COPY_AND_ASSIGN(ModalWindow); |
113 }; | 107 }; |
114 | 108 |
115 class SimpleMenuDelegate : public ui::SimpleMenuModel::Delegate { | 109 class SimpleMenuDelegate : public ui::SimpleMenuModel::Delegate { |
116 public: | 110 public: |
117 SimpleMenuDelegate() {} | 111 SimpleMenuDelegate() {} |
118 virtual ~SimpleMenuDelegate() {} | 112 ~SimpleMenuDelegate() override {} |
119 | 113 |
120 virtual bool IsCommandIdChecked(int command_id) const override { | 114 bool IsCommandIdChecked(int command_id) const override { return false; } |
| 115 |
| 116 bool IsCommandIdEnabled(int command_id) const override { return true; } |
| 117 |
| 118 bool GetAcceleratorForCommandId(int command_id, |
| 119 ui::Accelerator* accelerator) override { |
121 return false; | 120 return false; |
122 } | 121 } |
123 | 122 |
124 virtual bool IsCommandIdEnabled(int command_id) const override { | 123 void ExecuteCommand(int command_id, int event_flags) override {} |
125 return true; | |
126 } | |
127 | |
128 virtual bool GetAcceleratorForCommandId( | |
129 int command_id, | |
130 ui::Accelerator* accelerator) override { | |
131 return false; | |
132 } | |
133 | |
134 virtual void ExecuteCommand(int command_id, int event_flags) override { | |
135 } | |
136 | 124 |
137 private: | 125 private: |
138 DISALLOW_COPY_AND_ASSIGN(SimpleMenuDelegate); | 126 DISALLOW_COPY_AND_ASSIGN(SimpleMenuDelegate); |
139 }; | 127 }; |
140 | 128 |
141 } // namespace | 129 } // namespace |
142 | 130 |
143 class ShellTest : public test::AshTestBase { | 131 class ShellTest : public test::AshTestBase { |
144 public: | 132 public: |
145 views::Widget* CreateTestWindow(views::Widget::InitParams params) { | 133 views::Widget* CreateTestWindow(views::Widget::InitParams params) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 260 |
273 modal_widget->Close(); | 261 modal_widget->Close(); |
274 widget->Close(); | 262 widget->Close(); |
275 } | 263 } |
276 | 264 |
277 class TestModalDialogDelegate : public views::DialogDelegateView { | 265 class TestModalDialogDelegate : public views::DialogDelegateView { |
278 public: | 266 public: |
279 TestModalDialogDelegate() {} | 267 TestModalDialogDelegate() {} |
280 | 268 |
281 // Overridden from views::WidgetDelegate: | 269 // Overridden from views::WidgetDelegate: |
282 virtual ui::ModalType GetModalType() const override { | 270 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } |
283 return ui::MODAL_TYPE_SYSTEM; | |
284 } | |
285 }; | 271 }; |
286 | 272 |
287 TEST_F(ShellTest, CreateLockScreenModalWindow) { | 273 TEST_F(ShellTest, CreateLockScreenModalWindow) { |
288 views::Widget::InitParams widget_params( | 274 views::Widget::InitParams widget_params( |
289 views::Widget::InitParams::TYPE_WINDOW); | 275 views::Widget::InitParams::TYPE_WINDOW); |
290 | 276 |
291 // Create a normal window. | 277 // Create a normal window. |
292 views::Widget* widget = CreateTestWindow(widget_params); | 278 views::Widget* widget = CreateTestWindow(widget_params); |
293 widget->Show(); | 279 widget->Show(); |
294 EXPECT_TRUE(widget->GetNativeView()->HasFocus()); | 280 EXPECT_TRUE(widget->GetNativeView()->HasFocus()); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 // This verifies WindowObservers are removed when a window is destroyed after | 504 // This verifies WindowObservers are removed when a window is destroyed after |
519 // the Shell is destroyed. This scenario (aura::Windows being deleted after the | 505 // the Shell is destroyed. This scenario (aura::Windows being deleted after the |
520 // Shell) occurs if someone is holding a reference to an unparented Window, as | 506 // Shell) occurs if someone is holding a reference to an unparented Window, as |
521 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as | 507 // is the case with a RenderWidgetHostViewAura that isn't on screen. As long as |
522 // everything is ok, we won't crash. If there is a bug, window's destructor will | 508 // everything is ok, we won't crash. If there is a bug, window's destructor will |
523 // notify some deleted object (say VideoDetector or ActivationController) and | 509 // notify some deleted object (say VideoDetector or ActivationController) and |
524 // this will crash. | 510 // this will crash. |
525 class ShellTest2 : public test::AshTestBase { | 511 class ShellTest2 : public test::AshTestBase { |
526 public: | 512 public: |
527 ShellTest2() {} | 513 ShellTest2() {} |
528 virtual ~ShellTest2() {} | 514 ~ShellTest2() override {} |
529 | 515 |
530 protected: | 516 protected: |
531 scoped_ptr<aura::Window> window_; | 517 scoped_ptr<aura::Window> window_; |
532 | 518 |
533 private: | 519 private: |
534 DISALLOW_COPY_AND_ASSIGN(ShellTest2); | 520 DISALLOW_COPY_AND_ASSIGN(ShellTest2); |
535 }; | 521 }; |
536 | 522 |
537 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { | 523 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { |
538 window_.reset(new aura::Window(NULL)); | 524 window_.reset(new aura::Window(NULL)); |
539 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 525 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
540 } | 526 } |
541 | 527 |
542 } // namespace ash | 528 } // namespace ash |
OLD | NEW |