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

Side by Side Diff: ash/shell_unittest.cc

Issue 12313118: Refactor: Shelf Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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
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/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"
11 #include "ash/desktop_background/desktop_background_widget_controller.h" 11 #include "ash/desktop_background/desktop_background_widget_controller.h"
12 #include "ash/launcher/launcher.h" 12 #include "ash/launcher/launcher.h"
13 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
14 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_widget.h"
14 #include "ash/shell_delegate.h" 16 #include "ash/shell_delegate.h"
15 #include "ash/shell_window_ids.h" 17 #include "ash/shell_window_ids.h"
16 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
17 #include "ash/wm/root_window_layout_manager.h" 19 #include "ash/wm/root_window_layout_manager.h"
18 #include "ash/wm/shelf_layout_manager.h"
19 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
20 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
21 #include "ui/aura/client/aura_constants.h" 22 #include "ui/aura/client/aura_constants.h"
22 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
23 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
24 #include "ui/gfx/size.h" 25 #include "ui/gfx/size.h"
25 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
26 #include "ui/views/widget/widget_delegate.h" 27 #include "ui/views/widget/widget_delegate.h"
27 28
28 using aura::RootWindow; 29 using aura::RootWindow;
(...skipping 19 matching lines...) Expand all
48 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 49 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
49 EXPECT_TRUE(Shell::GetContainer( 50 EXPECT_TRUE(Shell::GetContainer(
50 root_window, internal::kShellWindowId_DesktopBackgroundContainer)); 51 root_window, internal::kShellWindowId_DesktopBackgroundContainer));
51 EXPECT_TRUE(Shell::GetContainer( 52 EXPECT_TRUE(Shell::GetContainer(
52 root_window, internal::kShellWindowId_DefaultContainer)); 53 root_window, internal::kShellWindowId_DefaultContainer));
53 EXPECT_TRUE(Shell::GetContainer( 54 EXPECT_TRUE(Shell::GetContainer(
54 root_window, internal::kShellWindowId_AlwaysOnTopContainer)); 55 root_window, internal::kShellWindowId_AlwaysOnTopContainer));
55 EXPECT_TRUE(Shell::GetContainer( 56 EXPECT_TRUE(Shell::GetContainer(
56 root_window, internal::kShellWindowId_PanelContainer)); 57 root_window, internal::kShellWindowId_PanelContainer));
57 EXPECT_TRUE(Shell::GetContainer( 58 EXPECT_TRUE(Shell::GetContainer(
58 root_window, internal::kShellWindowId_LauncherContainer)); 59 root_window, internal::kShellWindowId_ShelfContainer));
59 EXPECT_TRUE(Shell::GetContainer( 60 EXPECT_TRUE(Shell::GetContainer(
60 root_window, internal::kShellWindowId_SystemModalContainer)); 61 root_window, internal::kShellWindowId_SystemModalContainer));
61 EXPECT_TRUE(Shell::GetContainer( 62 EXPECT_TRUE(Shell::GetContainer(
62 root_window, internal::kShellWindowId_LockScreenBackgroundContainer)); 63 root_window, internal::kShellWindowId_LockScreenBackgroundContainer));
63 EXPECT_TRUE(Shell::GetContainer( 64 EXPECT_TRUE(Shell::GetContainer(
64 root_window, internal::kShellWindowId_LockScreenContainer)); 65 root_window, internal::kShellWindowId_LockScreenContainer));
65 EXPECT_TRUE(Shell::GetContainer( 66 EXPECT_TRUE(Shell::GetContainer(
66 root_window, internal::kShellWindowId_LockSystemModalContainer)); 67 root_window, internal::kShellWindowId_LockSystemModalContainer));
67 EXPECT_TRUE(Shell::GetContainer( 68 EXPECT_TRUE(Shell::GetContainer(
68 root_window, internal::kShellWindowId_StatusContainer)); 69 root_window, internal::kShellWindowId_StatusContainer));
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 #else 276 #else
276 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics 277 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics
277 #endif 278 #endif
278 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { 279 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
279 Shell* shell = Shell::GetInstance(); 280 Shell* shell = Shell::GetInstance();
280 Shell::TestApi test_api(shell); 281 Shell::TestApi test_api(shell);
281 282
282 // We start with the usual window containers. 283 // We start with the usual window containers.
283 ExpectAllContainers(); 284 ExpectAllContainers();
284 // Launcher is visible. 285 // Launcher is visible.
285 views::Widget* launcher_widget = Launcher::ForPrimaryDisplay()->widget(); 286 ShelfWidget* launcher_widget = Launcher::ForPrimaryDisplay()->shelf_widget();
286 EXPECT_TRUE(launcher_widget->IsVisible()); 287 EXPECT_TRUE(launcher_widget->IsVisible());
287 // Launcher is at bottom-left of screen. 288 // Launcher is at bottom-left of screen.
288 EXPECT_EQ(0, launcher_widget->GetWindowBoundsInScreen().x()); 289 EXPECT_EQ(0, launcher_widget->GetWindowBoundsInScreen().x());
289 EXPECT_EQ(Shell::GetPrimaryRootWindow()->GetHostSize().height(), 290 EXPECT_EQ(Shell::GetPrimaryRootWindow()->GetHostSize().height(),
290 launcher_widget->GetWindowBoundsInScreen().bottom()); 291 launcher_widget->GetWindowBoundsInScreen().bottom());
291 // We have a desktop background but not a bare layer. 292 // We have a desktop background but not a bare layer.
292 // TODO (antrim): enable once we find out why it fails component build. 293 // TODO (antrim): enable once we find out why it fails component build.
293 // internal::DesktopBackgroundWidgetController* background = 294 // internal::DesktopBackgroundWidgetController* background =
294 // Shell::GetPrimaryRootWindow()-> 295 // Shell::GetPrimaryRootWindow()->
295 // GetProperty(internal::kWindowDesktopComponent); 296 // GetProperty(internal::kWindowDesktopComponent);
(...skipping 20 matching lines...) Expand all
316 views::Widget::InitParams widget_params( 317 views::Widget::InitParams widget_params(
317 views::Widget::InitParams::TYPE_WINDOW); 318 views::Widget::InitParams::TYPE_WINDOW);
318 widget_params.bounds.SetRect(11, 22, 300, 400); 319 widget_params.bounds.SetRect(11, 22, 300, 400);
319 views::Widget* widget = CreateTestWindow(widget_params); 320 views::Widget* widget = CreateTestWindow(widget_params);
320 widget->Show(); 321 widget->Show();
321 EXPECT_FALSE(widget->IsMaximized()); 322 EXPECT_FALSE(widget->IsMaximized());
322 323
323 // Shelf defaults to visible. 324 // Shelf defaults to visible.
324 EXPECT_EQ( 325 EXPECT_EQ(
325 SHELF_VISIBLE, 326 SHELF_VISIBLE,
326 Shell::GetPrimaryRootWindowController()->shelf()->visibility_state()); 327 Shell::GetPrimaryRootWindowController()->
328 shelf_layout_manager()->visibility_state());
327 329
328 // Fullscreen window hides it. 330 // Fullscreen window hides it.
329 widget->SetFullscreen(true); 331 widget->SetFullscreen(true);
330 EXPECT_EQ( 332 EXPECT_EQ(
331 SHELF_HIDDEN, 333 SHELF_HIDDEN,
332 Shell::GetPrimaryRootWindowController()->shelf()->visibility_state()); 334 Shell::GetPrimaryRootWindowController()->
335 shelf_layout_manager()->visibility_state());
333 336
334 // Restoring the window restores it. 337 // Restoring the window restores it.
335 widget->Restore(); 338 widget->Restore();
336 EXPECT_EQ( 339 EXPECT_EQ(
337 SHELF_VISIBLE, 340 SHELF_VISIBLE,
338 Shell::GetPrimaryRootWindowController()->shelf()->visibility_state()); 341 Shell::GetPrimaryRootWindowController()->
342 shelf_layout_manager()->visibility_state());
339 343
340 // Clean up. 344 // Clean up.
341 widget->Close(); 345 widget->Close();
342 } 346 }
343 347
344 namespace { 348 namespace {
345 349
346 // Builds the list of parents from |window| to the root. The returned vector is 350 // Builds the list of parents from |window| to the root. The returned vector is
347 // in reverse order (|window| is first). 351 // in reverse order (|window| is first).
348 std::vector<aura::Window*> BuildPathToRoot(aura::Window* window) { 352 std::vector<aura::Window*> BuildPathToRoot(aura::Window* window) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 private: 412 private:
409 DISALLOW_COPY_AND_ASSIGN(ShellTest2); 413 DISALLOW_COPY_AND_ASSIGN(ShellTest2);
410 }; 414 };
411 415
412 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { 416 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) {
413 window_.reset(new aura::Window(NULL)); 417 window_.reset(new aura::Window(NULL));
414 window_->Init(ui::LAYER_NOT_DRAWN); 418 window_->Init(ui::LAYER_NOT_DRAWN);
415 } 419 }
416 420
417 } // namespace ash 421 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698