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

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

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix new addition Created 8 years, 2 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
« no previous file with comments | « ash/ui_controls_ash.cc ('k') | ash/wm/coordinate_conversion.cc » ('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) 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/base_layout_manager.h" 5 #include "ash/wm/base_layout_manager.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 initial_work_area_bounds.ToString(), 93 initial_work_area_bounds.ToString(),
94 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString()); 94 ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString());
95 } 95 }
96 96
97 // Tests normal->fullscreen->normal. 97 // Tests normal->fullscreen->normal.
98 TEST_F(BaseLayoutManagerTest, Fullscreen) { 98 TEST_F(BaseLayoutManagerTest, Fullscreen) {
99 gfx::Rect bounds(100, 100, 200, 200); 99 gfx::Rect bounds(100, 100, 200, 200);
100 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 100 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
101 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 101 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
102 // Fullscreen window fills the whole display. 102 // Fullscreen window fills the whole display.
103 EXPECT_EQ( 103 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
104 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), 104 window.get()).bounds().ToString(),
105 window->bounds().ToString()); 105 window->bounds().ToString());
106 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 106 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
107 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 107 EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
108 } 108 }
109 109
110 // Tests fullscreen window size during root window resize. 110 // Tests fullscreen window size during root window resize.
111 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { 111 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) {
112 gfx::Rect bounds(100, 100, 200, 200); 112 gfx::Rect bounds(100, 100, 200, 200);
113 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 113 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
114 // Fullscreen window fills the whole display. 114 // Fullscreen window fills the whole display.
115 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 115 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
116 EXPECT_EQ( 116 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
117 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), 117 window.get()).bounds().ToString(),
118 window->bounds().ToString()); 118 window->bounds().ToString());
119 // Enlarge the root window. We should still match the display size. 119 // Enlarge the root window. We should still match the display size.
120 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); 120 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600));
121 EXPECT_EQ( 121 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
122 gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), 122 window.get()).bounds().ToString(),
123 window->bounds().ToString()); 123 window->bounds().ToString());
124 } 124 }
125 125
126 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. 126 // Fails on Mac only. Need to be implemented. http://crbug.com/111279.
127 #if defined(OS_MACOSX) 127 #if defined(OS_MACOSX)
128 #define MAYBE_RootWindowResizeShrinksWindows \ 128 #define MAYBE_RootWindowResizeShrinksWindows \
129 FAILS_RootWindowResizeShrinksWindows 129 FAILS_RootWindowResizeShrinksWindows
130 #else 130 #else
131 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows 131 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows
132 #endif 132 #endif
133 // Tests that when the screen gets smaller the windows aren't bigger than 133 // Tests that when the screen gets smaller the windows aren't bigger than
134 // the screen. 134 // the screen.
135 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) { 135 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) {
136 scoped_ptr<aura::Window> window( 136 scoped_ptr<aura::Window> window(
137 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); 137 CreateTestWindow(gfx::Rect(10, 20, 500, 400)));
138 gfx::Rect work_area = 138 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
139 gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); 139 window.get()).work_area();
140 // Invariant: Window is smaller than work area. 140 // Invariant: Window is smaller than work area.
141 EXPECT_LE(window->bounds().width(), work_area.width()); 141 EXPECT_LE(window->bounds().width(), work_area.width());
142 EXPECT_LE(window->bounds().height(), work_area.height()); 142 EXPECT_LE(window->bounds().height(), work_area.height());
143 143
144 // Make the root window narrower than our window. 144 // Make the root window narrower than our window.
145 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400)); 145 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400));
146 work_area = gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); 146 work_area = Shell::GetScreen()->GetDisplayNearestWindow(
147 window.get()).work_area();
147 EXPECT_LE(window->bounds().width(), work_area.width()); 148 EXPECT_LE(window->bounds().width(), work_area.width());
148 EXPECT_LE(window->bounds().height(), work_area.height()); 149 EXPECT_LE(window->bounds().height(), work_area.height());
149 150
150 // Make the root window shorter than our window. 151 // Make the root window shorter than our window.
151 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200)); 152 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200));
152 work_area = gfx::Screen::GetDisplayNearestWindow(window.get()).work_area(); 153 work_area = Shell::GetScreen()->GetDisplayNearestWindow(
154 window.get()).work_area();
153 EXPECT_LE(window->bounds().width(), work_area.width()); 155 EXPECT_LE(window->bounds().width(), work_area.width());
154 EXPECT_LE(window->bounds().height(), work_area.height()); 156 EXPECT_LE(window->bounds().height(), work_area.height());
155 157
156 // Enlarging the root window does not change the window bounds. 158 // Enlarging the root window does not change the window bounds.
157 gfx::Rect old_bounds = window->bounds(); 159 gfx::Rect old_bounds = window->bounds();
158 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); 160 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600));
159 EXPECT_EQ(old_bounds.width(), window->bounds().width()); 161 EXPECT_EQ(old_bounds.width(), window->bounds().width());
160 EXPECT_EQ(old_bounds.height(), window->bounds().height()); 162 EXPECT_EQ(old_bounds.height(), window->bounds().height());
161 } 163 }
162 164
163 // Tests that a maximized window with too-large restore bounds will be restored 165 // Tests that a maximized window with too-large restore bounds will be restored
164 // to smaller than the full work area. 166 // to smaller than the full work area.
165 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { 167 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) {
166 // Create a window with bounds that fill the screen. 168 // Create a window with bounds that fill the screen.
167 gfx::Rect bounds = gfx::Screen::GetPrimaryDisplay().bounds(); 169 gfx::Rect bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds();
168 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 170 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
169 // Maximize it, which writes the old bounds to restore bounds. 171 // Maximize it, which writes the old bounds to restore bounds.
170 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 172 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
171 // Restore it. 173 // Restore it.
172 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 174 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
173 // It should have the default maximized window bounds, inset by the grid size. 175 // It should have the default maximized window bounds, inset by the grid size.
174 int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset; 176 int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset;
175 gfx::Rect max_bounds = 177 gfx::Rect max_bounds =
176 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); 178 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get());
177 max_bounds.Inset(grid_size, grid_size); 179 max_bounds.Inset(grid_size, grid_size);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 GetRestoreBoundsInParent(window.get()).ToString()); 229 GetRestoreBoundsInParent(window.get()).ToString());
228 EXPECT_TRUE(wm::IsWindowMaximized(window.get())); 230 EXPECT_TRUE(wm::IsWindowMaximized(window.get()));
229 231
230 wm::RestoreWindow(window.get()); 232 wm::RestoreWindow(window.get());
231 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 233 EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
232 } 234 }
233 235
234 } // namespace 236 } // namespace
235 237
236 } // namespace ash 238 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ui_controls_ash.cc ('k') | ash/wm/coordinate_conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698