Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: ui/aura_shell/shell_unittest.cc

Issue 8638013: [cros Aura] Added modal container for screen lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small fix Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/shell_window_ids.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h"
5 #include "ui/aura/test/aura_test_base.h" 6 #include "ui/aura/test/aura_test_base.h"
6 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
7 #include "ui/aura_shell/shell.h" 8 #include "ui/aura_shell/shell.h"
8 #include "ui/aura_shell/shell_window_ids.h" 9 #include "ui/aura_shell/shell_window_ids.h"
9 #include "ui/aura_shell/test/aura_shell_test_base.h" 10 #include "ui/aura_shell/test/aura_shell_test_base.h"
10 #include "ui/views/widget/widget.h" 11 #include "ui/views/widget/widget.h"
12 #include "ui/views/widget/widget_delegate.h"
11 13
12 namespace aura_shell { 14 namespace aura_shell {
13 namespace test { 15 namespace test {
14 16
15 namespace { 17 namespace {
16 18
17 views::Widget* CreateTestWindow(const views::Widget::InitParams& params) { 19 views::Widget* CreateTestWindow(const views::Widget::InitParams& params) {
18 views::Widget* widget = new views::Widget; 20 views::Widget* widget = new views::Widget;
19 widget->Init(params); 21 widget->Init(params);
20 return widget; 22 return widget;
(...skipping 17 matching lines...) Expand all
38 40
39 views::Widget* widget = CreateTestWindow(widget_params); 41 views::Widget* widget = CreateTestWindow(widget_params);
40 widget->Show(); 42 widget->Show();
41 43
42 EXPECT_EQ(expected_container, widget->GetNativeWindow()->parent()) << 44 EXPECT_EQ(expected_container, widget->GetNativeWindow()->parent()) <<
43 "TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top; 45 "TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top;
44 46
45 widget->Close(); 47 widget->Close();
46 } 48 }
47 49
50 class ModalWindow : public views::WidgetDelegateView {
51 public:
52 ModalWindow() {}
53 virtual ~ModalWindow() {}
54
55 // Overridden from views::WidgetDelegate:
56 virtual views::View* GetContentsView() OVERRIDE {
57 return this;
58 }
59 virtual bool CanResize() const OVERRIDE {
60 return true;
61 }
62 virtual string16 GetWindowTitle() const OVERRIDE {
63 return ASCIIToUTF16("Modal Window");
64 }
65 virtual bool IsModal() const OVERRIDE {
66 return true;
67 }
68
69 private:
70 DISALLOW_COPY_AND_ASSIGN(ModalWindow);
71 };
72
48 } // namespace 73 } // namespace
49 74
50 class ShellTest : public AuraShellTestBase { 75 class ShellTest : public AuraShellTestBase {
51 public: 76 public:
52 ShellTest() {} 77 ShellTest() {}
53 virtual ~ShellTest() {} 78 virtual ~ShellTest() {}
54 79
55 private: 80 private:
56 DISALLOW_COPY_AND_ASSIGN(ShellTest); 81 DISALLOW_COPY_AND_ASSIGN(ShellTest);
57 }; 82 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 121 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
97 122
98 // Set the same always-on-top flag again. 123 // Set the same always-on-top flag again.
99 widget->SetAlwaysOnTop(false); 124 widget->SetAlwaysOnTop(false);
100 // Should have no effect and we are still in the default container. 125 // Should have no effect and we are still in the default container.
101 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 126 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
102 127
103 widget->Close(); 128 widget->Close();
104 } 129 }
105 130
131 TEST_F(ShellTest, CreateModalWindow) {
132 views::Widget::InitParams widget_params(
133 views::Widget::InitParams::TYPE_WINDOW);
134
135 // Create a normal window.
136 views::Widget* widget = CreateTestWindow(widget_params);
137 widget->Show();
138
139 // It should be in default container.
140 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
141
142 // Create a modal window.
143 views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
144 new ModalWindow(), widget->GetNativeView());
145 modal_widget->Show();
146
147 // It should be in modal container.
148 aura::Window* modal_container = Shell::GetInstance()->GetContainer(
149 aura_shell::internal::kShellWindowId_ModalContainer);
150 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
151
152 modal_widget->Close();
153 widget->Close();
154 }
155
156 TEST_F(ShellTest, CreateLockScreenModalWindow) {
157 views::Widget::InitParams widget_params(
158 views::Widget::InitParams::TYPE_WINDOW);
159
160 // Create a normal window.
161 views::Widget* widget = CreateTestWindow(widget_params);
162 widget->Show();
163
164 // It should be in default container.
165 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
166
167 // Create a LockScreen window.
168 views::Widget* lock_widget = CreateTestWindow(widget_params);
169 aura_shell::Shell::GetInstance()->GetContainer(
170 aura_shell::internal::kShellWindowId_LockScreenContainer)->
171 AddChild(lock_widget->GetNativeView());
172 lock_widget->Show();
173
174 // It should be in LockScreen container.
175 aura::Window* lock_screen = Shell::GetInstance()->GetContainer(
176 aura_shell::internal::kShellWindowId_LockScreenContainer);
177 EXPECT_EQ(lock_screen, lock_widget->GetNativeWindow()->parent());
178
179 // Create a modal window with a lock window as parent.
180 views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent(
181 new ModalWindow(), lock_widget->GetNativeView());
182 lock_modal_widget->Show();
183
184 // It should be in LockScreen modal container.
185 aura::Window* lock_modal_container = Shell::GetInstance()->GetContainer(
186 aura_shell::internal::kShellWindowId_LockModalContainer);
187 EXPECT_EQ(lock_modal_container,
188 lock_modal_widget->GetNativeWindow()->parent());
189
190 // Create a modal window with a normal window as parent.
191 views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
192 new ModalWindow(), widget->GetNativeView());
193 modal_widget->Show();
194
195 // It should be in non-LockScreen modal container.
196 aura::Window* modal_container = Shell::GetInstance()->GetContainer(
197 aura_shell::internal::kShellWindowId_ModalContainer);
198 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
199
200 modal_widget->Close();
201 lock_modal_widget->Close();
202 lock_widget->Close();
203 widget->Close();
204 }
205
106 } // namespace test 206 } // namespace test
107 } // namespace aura_shell 207 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/shell.cc ('k') | ui/aura_shell/shell_window_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698