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

Side by Side Diff: ash/wm/shelf_layout_manager_unittest.cc

Issue 9764008: Makes the launcher auto-hide for maximized windows. This turned out to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add null checks and cleanup Created 8 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 | 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/wm/shelf_layout_manager.h" 5 #include "ash/wm/shelf_layout_manager.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
47 #define MAYBE_SetVisible FAILS_SetVisible 47 #define MAYBE_SetVisible FAILS_SetVisible
48 #else 48 #else
49 #define MAYBE_SetVisible SetVisible 49 #define MAYBE_SetVisible SetVisible
50 #endif 50 #endif
51 // Makes sure SetVisible updates work area and widget appropriately. 51 // Makes sure SetVisible updates work area and widget appropriately.
52 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { 52 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
53 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 53 ShelfLayoutManager* shelf = GetShelfLayoutManager();
54 // Force an initial layout. 54 // Force an initial layout.
55 shelf->LayoutShelf(); 55 shelf->LayoutShelf();
56 ASSERT_TRUE(shelf->visible()); 56 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
57 const aura::MonitorManager* manager = 57 const aura::MonitorManager* manager =
58 aura::Env::GetInstance()->monitor_manager(); 58 aura::Env::GetInstance()->monitor_manager();
59 const aura::Monitor* monitor = 59 const aura::Monitor* monitor =
60 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 60 manager->GetMonitorNearestWindow(Shell::GetRootWindow());
61 ASSERT_TRUE(monitor); 61 ASSERT_TRUE(monitor);
62 // Bottom inset should be the max of widget heights. 62 // Bottom inset should be the max of widget heights.
63 EXPECT_EQ(shelf->max_height() + ShelfLayoutManager::kWorkspaceAreaBottomInset, 63 EXPECT_EQ(shelf->shelf_height() +
64 ShelfLayoutManager::kWorkspaceAreaBottomInset,
64 monitor->work_area_insets().bottom()); 65 monitor->work_area_insets().bottom());
65 66
66 // Hide the shelf. 67 // Hide the shelf.
67 shelf->SetVisible(false); 68 shelf->SetState(ShelfLayoutManager::HIDDEN,
69 ShelfLayoutManager::AUTO_HIDE_HIDDEN);
68 // Run the animation to completion. 70 // Run the animation to completion.
69 StepWidgetLayerAnimatorToEnd(shelf->launcher()); 71 StepWidgetLayerAnimatorToEnd(shelf->launcher());
70 StepWidgetLayerAnimatorToEnd(shelf->status()); 72 StepWidgetLayerAnimatorToEnd(shelf->status());
71 EXPECT_FALSE(shelf->visible()); 73 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
72 EXPECT_EQ(0, monitor->work_area_insets().bottom()); 74 EXPECT_EQ(0, monitor->work_area_insets().bottom());
73 75
74 // Make sure the bounds of the two widgets changed. 76 // Make sure the bounds of the two widgets changed.
75 EXPECT_GE(shelf->launcher()->GetNativeView()->bounds().y(), 77 EXPECT_GE(shelf->launcher()->GetNativeView()->bounds().y(),
76 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 78 gfx::Screen::GetPrimaryMonitorBounds().bottom());
77 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 79 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
78 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 80 gfx::Screen::GetPrimaryMonitorBounds().bottom());
79 81
80 // And show it again. 82 // And show it again.
81 shelf->SetVisible(true); 83 shelf->SetState(ShelfLayoutManager::VISIBLE,
84 ShelfLayoutManager::AUTO_HIDE_HIDDEN);
82 // Run the animation to completion. 85 // Run the animation to completion.
83 StepWidgetLayerAnimatorToEnd(shelf->launcher()); 86 StepWidgetLayerAnimatorToEnd(shelf->launcher());
84 StepWidgetLayerAnimatorToEnd(shelf->status()); 87 StepWidgetLayerAnimatorToEnd(shelf->status());
85 EXPECT_TRUE(shelf->visible()); 88 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
86 EXPECT_EQ(shelf->max_height() + ShelfLayoutManager::kWorkspaceAreaBottomInset, 89 EXPECT_EQ(shelf->shelf_height() +
90 ShelfLayoutManager::kWorkspaceAreaBottomInset,
87 monitor->work_area_insets().bottom()); 91 monitor->work_area_insets().bottom());
88 92
89 // Make sure the bounds of the two widgets changed. 93 // Make sure the bounds of the two widgets changed.
90 gfx::Rect launcher_bounds(shelf->launcher()->GetNativeView()->bounds()); 94 gfx::Rect launcher_bounds(shelf->launcher()->GetNativeView()->bounds());
91 int bottom = gfx::Screen::GetPrimaryMonitorBounds().bottom() - 95 int bottom = gfx::Screen::GetPrimaryMonitorBounds().bottom() -
92 shelf->max_height(); 96 shelf->shelf_height();
93 EXPECT_EQ(launcher_bounds.y(), 97 EXPECT_EQ(launcher_bounds.y(),
94 bottom + (shelf->max_height() - launcher_bounds.height()) / 2); 98 bottom + (shelf->shelf_height() - launcher_bounds.height()) / 2);
95 gfx::Rect status_bounds(shelf->status()->GetNativeView()->bounds()); 99 gfx::Rect status_bounds(shelf->status()->GetNativeView()->bounds());
96 EXPECT_EQ(status_bounds.y(), 100 EXPECT_EQ(status_bounds.y(),
97 bottom + shelf->max_height() - status_bounds.height()); 101 bottom + shelf->shelf_height() - status_bounds.height());
98 } 102 }
99 103
100 // Makes sure LayoutShelf invoked while animating cleans things up. 104 // Makes sure LayoutShelf invoked while animating cleans things up.
101 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 105 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
102 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 106 ShelfLayoutManager* shelf = GetShelfLayoutManager();
103 // Force an initial layout. 107 // Force an initial layout.
104 shelf->LayoutShelf(); 108 shelf->LayoutShelf();
105 ASSERT_TRUE(shelf->visible()); 109 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
106 110
107 const aura::MonitorManager* manager = 111 const aura::MonitorManager* manager =
108 aura::Env::GetInstance()->monitor_manager(); 112 aura::Env::GetInstance()->monitor_manager();
109 const aura::Monitor* monitor = 113 const aura::Monitor* monitor =
110 manager->GetMonitorNearestWindow(Shell::GetRootWindow()); 114 manager->GetMonitorNearestWindow(Shell::GetRootWindow());
111 115
112 // Hide the shelf. 116 // Hide the shelf.
113 shelf->SetVisible(false); 117 shelf->SetState(ShelfLayoutManager::HIDDEN,
118 ShelfLayoutManager::AUTO_HIDE_HIDDEN);
114 shelf->LayoutShelf(); 119 shelf->LayoutShelf();
115 EXPECT_FALSE(shelf->visible()); 120 EXPECT_EQ(ShelfLayoutManager::HIDDEN, shelf->visibility_state());
116 EXPECT_FALSE(shelf->visible());
117 EXPECT_EQ(0, monitor->work_area_insets().bottom()); 121 EXPECT_EQ(0, monitor->work_area_insets().bottom());
118 // Make sure the bounds of the two widgets changed. 122 // Make sure the bounds of the two widgets changed.
119 EXPECT_GE(shelf->launcher()->GetNativeView()->bounds().y(), 123 EXPECT_GE(shelf->launcher()->GetNativeView()->bounds().y(),
120 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 124 gfx::Screen::GetPrimaryMonitorBounds().bottom());
121 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(), 125 EXPECT_GE(shelf->status()->GetNativeView()->bounds().y(),
122 gfx::Screen::GetPrimaryMonitorBounds().bottom()); 126 gfx::Screen::GetPrimaryMonitorBounds().bottom());
123 } 127 }
124 128
125 // Makes sure the launcher is initially sized correctly. 129 // Makes sure the launcher is initially sized correctly.
126 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) { 130 TEST_F(ShelfLayoutManagerTest, LauncherInitiallySized) {
(...skipping 26 matching lines...) Expand all
153 views::Widget* widget = new views::Widget; 157 views::Widget* widget = new views::Widget;
154 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 158 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
155 params.bounds = gfx::Rect(0, 0, 200, 200); 159 params.bounds = gfx::Rect(0, 0, 200, 200);
156 // Widget is now owned by the parent window. 160 // Widget is now owned by the parent window.
157 widget->Init(params); 161 widget->Init(params);
158 widget->SetFullscreen(true); 162 widget->SetFullscreen(true);
159 } 163 }
160 164
161 } // namespace internal 165 } // namespace internal
162 } // namespace ash 166 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698