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

Side by Side Diff: ash/shell_unittest.cc

Issue 10857021: Prepare a bunch of ash tests for workspace2. With Workspace2 you can't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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
OLDNEW
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/ash_switches.h" 5 #include "ash/ash_switches.h"
6 #include "ash/desktop_background/desktop_background_widget_controller.h" 6 #include "ash/desktop_background/desktop_background_widget_controller.h"
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_delegate.h" 9 #include "ash/shell_delegate.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 void TestCreateWindow(views::Widget::InitParams::Type type, 79 void TestCreateWindow(views::Widget::InitParams::Type type,
80 bool always_on_top, 80 bool always_on_top,
81 aura::Window* expected_container) { 81 aura::Window* expected_container) {
82 views::Widget::InitParams widget_params(type); 82 views::Widget::InitParams widget_params(type);
83 widget_params.keep_on_top = always_on_top; 83 widget_params.keep_on_top = always_on_top;
84 84
85 views::Widget* widget = CreateTestWindow(widget_params); 85 views::Widget* widget = CreateTestWindow(widget_params);
86 widget->Show(); 86 widget->Show();
87 87
88 EXPECT_EQ(expected_container, widget->GetNativeWindow()->parent()) << 88 EXPECT_TRUE(expected_container->Contains(
89 widget->GetNativeWindow()->parent())) <<
89 "TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top; 90 "TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top;
90 91
91 widget->Close(); 92 widget->Close();
92 } 93 }
93 94
94 class ModalWindow : public views::WidgetDelegateView { 95 class ModalWindow : public views::WidgetDelegateView {
95 public: 96 public:
96 ModalWindow() {} 97 ModalWindow() {}
97 virtual ~ModalWindow() {} 98 virtual ~ModalWindow() {}
98 99
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 139
139 TEST_F(ShellTest, ChangeAlwaysOnTop) { 140 TEST_F(ShellTest, ChangeAlwaysOnTop) {
140 views::Widget::InitParams widget_params( 141 views::Widget::InitParams widget_params(
141 views::Widget::InitParams::TYPE_WINDOW); 142 views::Widget::InitParams::TYPE_WINDOW);
142 143
143 // Creates a normal window 144 // Creates a normal window
144 views::Widget* widget = CreateTestWindow(widget_params); 145 views::Widget* widget = CreateTestWindow(widget_params);
145 widget->Show(); 146 widget->Show();
146 147
147 // It should be in default container. 148 // It should be in default container.
148 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 149 EXPECT_TRUE(GetDefaultContainer()->Contains(
150 widget->GetNativeWindow()->parent()));
149 151
150 // Flip always-on-top flag. 152 // Flip always-on-top flag.
151 widget->SetAlwaysOnTop(true); 153 widget->SetAlwaysOnTop(true);
152 // And it should in always on top container now. 154 // And it should in always on top container now.
153 EXPECT_EQ(GetAlwaysOnTopContainer(), widget->GetNativeWindow()->parent()); 155 EXPECT_EQ(GetAlwaysOnTopContainer(), widget->GetNativeWindow()->parent());
154 156
155 // Flip always-on-top flag. 157 // Flip always-on-top flag.
156 widget->SetAlwaysOnTop(false); 158 widget->SetAlwaysOnTop(false);
157 // It should go back to default container. 159 // It should go back to default container.
158 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 160 EXPECT_TRUE(GetDefaultContainer()->Contains(
161 widget->GetNativeWindow()->parent()));
159 162
160 // Set the same always-on-top flag again. 163 // Set the same always-on-top flag again.
161 widget->SetAlwaysOnTop(false); 164 widget->SetAlwaysOnTop(false);
162 // Should have no effect and we are still in the default container. 165 // Should have no effect and we are still in the default container.
163 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 166 EXPECT_TRUE(GetDefaultContainer()->Contains(
167 widget->GetNativeWindow()->parent()));
164 168
165 widget->Close(); 169 widget->Close();
166 } 170 }
167 171
168 TEST_F(ShellTest, CreateModalWindow) { 172 TEST_F(ShellTest, CreateModalWindow) {
169 views::Widget::InitParams widget_params( 173 views::Widget::InitParams widget_params(
170 views::Widget::InitParams::TYPE_WINDOW); 174 views::Widget::InitParams::TYPE_WINDOW);
171 175
172 // Create a normal window. 176 // Create a normal window.
173 views::Widget* widget = CreateTestWindow(widget_params); 177 views::Widget* widget = CreateTestWindow(widget_params);
174 widget->Show(); 178 widget->Show();
175 179
176 // It should be in default container. 180 // It should be in default container.
177 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 181 EXPECT_TRUE(GetDefaultContainer()->Contains(
182 widget->GetNativeWindow()->parent()));
178 183
179 // Create a modal window. 184 // Create a modal window.
180 views::Widget* modal_widget = views::Widget::CreateWindowWithParent( 185 views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
181 new ModalWindow(), widget->GetNativeView()); 186 new ModalWindow(), widget->GetNativeView());
182 modal_widget->Show(); 187 modal_widget->Show();
183 188
184 // It should be in modal container. 189 // It should be in modal container.
185 aura::Window* modal_container = Shell::GetContainer( 190 aura::Window* modal_container = Shell::GetContainer(
186 Shell::GetPrimaryRootWindow(), 191 Shell::GetPrimaryRootWindow(),
187 internal::kShellWindowId_SystemModalContainer); 192 internal::kShellWindowId_SystemModalContainer);
188 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); 193 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent());
189 194
190 modal_widget->Close(); 195 modal_widget->Close();
191 widget->Close(); 196 widget->Close();
192 } 197 }
193 198
194 TEST_F(ShellTest, CreateLockScreenModalWindow) { 199 TEST_F(ShellTest, CreateLockScreenModalWindow) {
195 views::Widget::InitParams widget_params( 200 views::Widget::InitParams widget_params(
196 views::Widget::InitParams::TYPE_WINDOW); 201 views::Widget::InitParams::TYPE_WINDOW);
197 202
198 // Create a normal window. 203 // Create a normal window.
199 views::Widget* widget = CreateTestWindow(widget_params); 204 views::Widget* widget = CreateTestWindow(widget_params);
200 widget->Show(); 205 widget->Show();
201 206
202 // It should be in default container. 207 // It should be in default container.
203 EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent()); 208 EXPECT_TRUE(GetDefaultContainer()->Contains(
209 widget->GetNativeWindow()->parent()));
204 210
205 // Create a LockScreen window. 211 // Create a LockScreen window.
206 views::Widget* lock_widget = CreateTestWindow(widget_params); 212 views::Widget* lock_widget = CreateTestWindow(widget_params);
207 ash::Shell::GetContainer( 213 ash::Shell::GetContainer(
208 Shell::GetPrimaryRootWindow(), 214 Shell::GetPrimaryRootWindow(),
209 ash::internal::kShellWindowId_LockScreenContainer)-> 215 ash::internal::kShellWindowId_LockScreenContainer)->
210 AddChild(lock_widget->GetNativeView()); 216 AddChild(lock_widget->GetNativeView());
211 lock_widget->Show(); 217 lock_widget->Show();
212 218
213 // It should be in LockScreen container. 219 // It should be in LockScreen container.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics 263 #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics
258 #else 264 #else
259 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics 265 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics
260 #endif 266 #endif
261 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { 267 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
262 Shell* shell = Shell::GetInstance(); 268 Shell* shell = Shell::GetInstance();
263 Shell::TestApi test_api(shell); 269 Shell::TestApi test_api(shell);
264 270
265 // We start with the usual window containers. 271 // We start with the usual window containers.
266 ExpectAllContainers(); 272 ExpectAllContainers();
267 // We have a default container event filter (for window drags).
268 EXPECT_TRUE(GetDefaultContainer()->event_filter());
269 // Launcher is visible. 273 // Launcher is visible.
270 views::Widget* launcher_widget = shell->launcher()->widget(); 274 views::Widget* launcher_widget = shell->launcher()->widget();
271 EXPECT_TRUE(launcher_widget->IsVisible()); 275 EXPECT_TRUE(launcher_widget->IsVisible());
272 // Launcher is at bottom-left of screen. 276 // Launcher is at bottom-left of screen.
273 EXPECT_EQ(0, launcher_widget->GetWindowBoundsInScreen().x()); 277 EXPECT_EQ(0, launcher_widget->GetWindowBoundsInScreen().x());
274 EXPECT_EQ(Shell::GetPrimaryRootWindow()->GetHostSize().height(), 278 EXPECT_EQ(Shell::GetPrimaryRootWindow()->GetHostSize().height(),
275 launcher_widget->GetWindowBoundsInScreen().bottom()); 279 launcher_widget->GetWindowBoundsInScreen().bottom());
276 // We have a desktop background but not a bare layer. 280 // We have a desktop background but not a bare layer.
277 // TODO (antrim): enable once we find out why it fails component build. 281 // TODO (antrim): enable once we find out why it fails component build.
278 // internal::DesktopBackgroundWidgetController* background = 282 // internal::DesktopBackgroundWidgetController* background =
279 // Shell::GetPrimaryRootWindow()-> 283 // Shell::GetPrimaryRootWindow()->
280 // GetProperty(internal::kWindowDesktopComponent); 284 // GetProperty(internal::kWindowDesktopComponent);
281 // EXPECT_TRUE(background); 285 // EXPECT_TRUE(background);
282 // EXPECT_TRUE(background->widget()); 286 // EXPECT_TRUE(background->widget());
283 // EXPECT_FALSE(background->layer()); 287 // EXPECT_FALSE(background->layer());
284 288
285 // Create a normal window. It is not maximized. 289 // Create a normal window. It is not maximized.
286 views::Widget::InitParams widget_params( 290 views::Widget::InitParams widget_params(
287 views::Widget::InitParams::TYPE_WINDOW); 291 views::Widget::InitParams::TYPE_WINDOW);
288 widget_params.bounds.SetRect(11, 22, 300, 400); 292 widget_params.bounds.SetRect(11, 22, 300, 400);
289 views::Widget* widget = CreateTestWindow(widget_params); 293 views::Widget* widget = CreateTestWindow(widget_params);
290 widget->Show(); 294 widget->Show();
291 EXPECT_FALSE(widget->IsMaximized()); 295 EXPECT_FALSE(widget->IsMaximized());
292 296
297 // We have a default container event filter (for window drags).
298 EXPECT_TRUE(widget->GetNativeWindow()->parent()->event_filter());
299
293 // Clean up. 300 // Clean up.
294 widget->Close(); 301 widget->Close();
295 } 302 }
296 303
297 TEST_F(ShellTest, FullscreenWindowHidesShelf) { 304 TEST_F(ShellTest, FullscreenWindowHidesShelf) {
298 ExpectAllContainers(); 305 ExpectAllContainers();
299 306
300 // Create a normal window. It is not maximized. 307 // Create a normal window. It is not maximized.
301 views::Widget::InitParams widget_params( 308 views::Widget::InitParams widget_params(
302 views::Widget::InitParams::TYPE_WINDOW); 309 views::Widget::InitParams::TYPE_WINDOW);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 private: 348 private:
342 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 349 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
343 }; 350 };
344 351
345 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 352 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
346 window_.reset(new aura::Window(NULL)); 353 window_.reset(new aura::Window(NULL));
347 window_->Init(ui::LAYER_NOT_DRAWN); 354 window_->Init(ui::LAYER_NOT_DRAWN);
348 } 355 }
349 356
350 } // namespace ash 357 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_context_menu_unittest.cc ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698