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

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

Issue 138003007: [Cleanup] Screen cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make sure screen_for_shutdown is reset everytime Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/workspace_controller.h" 5 #include "ash/wm/workspace_controller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/screen_ash.h" 11 #include "ash/screen_util.h"
12 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shelf/shelf_widget.h" 13 #include "ash/shelf/shelf_widget.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/shell_window_ids.h" 15 #include "ash/shell_window_ids.h"
16 #include "ash/system/status_area_widget.h" 16 #include "ash/system/status_area_widget.h"
17 #include "ash/test/ash_test_base.h" 17 #include "ash/test/ash_test_base.h"
18 #include "ash/test/shell_test_api.h" 18 #include "ash/test/shell_test_api.h"
19 #include "ash/wm/window_state.h" 19 #include "ash/wm/window_state.h"
20 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 EXPECT_TRUE(w1->layer()->visible()); 176 EXPECT_TRUE(w1->layer()->visible());
177 177
178 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); 178 EXPECT_EQ("0,0 250x251", w1->bounds().ToString());
179 179
180 // Maximize the window. 180 // Maximize the window.
181 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 181 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
182 182
183 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 183 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
184 184
185 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 185 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
186 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).width(), 186 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get()).width(),
187 w1->bounds().width()); 187 w1->bounds().width());
188 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).height(), 188 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get()).height(),
189 w1->bounds().height()); 189 w1->bounds().height());
190 190
191 // Restore the window. 191 // Restore the window.
192 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 192 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
193 193
194 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 194 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
195 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); 195 EXPECT_EQ("0,0 250x251", w1->bounds().ToString());
196 } 196 }
197 197
198 // Assertions around two windows and toggling one to be fullscreen. 198 // Assertions around two windows and toggling one to be fullscreen.
199 TEST_F(WorkspaceControllerTest, FullscreenWithNormalWindow) { 199 TEST_F(WorkspaceControllerTest, FullscreenWithNormalWindow) {
200 scoped_ptr<Window> w1(CreateTestWindow()); 200 scoped_ptr<Window> w1(CreateTestWindow());
201 scoped_ptr<Window> w2(CreateTestWindow()); 201 scoped_ptr<Window> w2(CreateTestWindow());
202 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); 202 w1->SetBounds(gfx::Rect(0, 0, 250, 251));
203 w1->Show(); 203 w1->Show();
204 204
205 ASSERT_TRUE(w1->layer() != NULL); 205 ASSERT_TRUE(w1->layer() != NULL);
206 EXPECT_TRUE(w1->layer()->visible()); 206 EXPECT_TRUE(w1->layer()->visible());
207 207
208 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); 208 w2->SetBounds(gfx::Rect(0, 0, 50, 51));
209 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 209 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
210 w2->Show(); 210 w2->Show();
211 wm::ActivateWindow(w2.get()); 211 wm::ActivateWindow(w2.get());
212 212
213 // Both windows should be in the same workspace. 213 // Both windows should be in the same workspace.
214 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 214 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
215 EXPECT_EQ(w2.get(), GetDesktop()->children()[1]); 215 EXPECT_EQ(w2.get(), GetDesktop()->children()[1]);
216 216
217 gfx::Rect work_area( 217 gfx::Rect work_area(
218 ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); 218 ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get()));
219 EXPECT_EQ(work_area.width(), w2->bounds().width()); 219 EXPECT_EQ(work_area.width(), w2->bounds().width());
220 EXPECT_EQ(work_area.height(), w2->bounds().height()); 220 EXPECT_EQ(work_area.height(), w2->bounds().height());
221 221
222 // Restore w2, which should then go back to one workspace. 222 // Restore w2, which should then go back to one workspace.
223 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 223 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
224 EXPECT_EQ(50, w2->bounds().width()); 224 EXPECT_EQ(50, w2->bounds().width());
225 EXPECT_EQ(51, w2->bounds().height()); 225 EXPECT_EQ(51, w2->bounds().height());
226 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 226 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
227 } 227 }
228 228
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 w2->Show(); 436 w2->Show();
437 wm::ActivateWindow(w2.get()); 437 wm::ActivateWindow(w2.get());
438 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 438 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
440 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 440 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
441 441
442 // Switch to w1. 442 // Switch to w1.
443 wm::ActivateWindow(w1.get()); 443 wm::ActivateWindow(w1.get());
444 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 444 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
445 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 445 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
446 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( 446 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(
447 w2->parent()).ToString(), 447 w2->parent()).ToString(),
448 w2->bounds().ToString()); 448 w2->bounds().ToString());
449 449
450 // Switch to w2. 450 // Switch to w2.
451 wm::ActivateWindow(w2.get()); 451 wm::ActivateWindow(w2.get());
452 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 452 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
453 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 453 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
454 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 454 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
455 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), 455 EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
456 w2->bounds().ToString()); 456 w2->bounds().ToString());
457 457
458 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. 458 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap.
459 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 459 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
460 wm::ActivateWindow(w2.get()); 460 wm::ActivateWindow(w2.get());
461 EXPECT_FALSE(GetWindowOverlapsShelf()); 461 EXPECT_FALSE(GetWindowOverlapsShelf());
462 462
463 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since 463 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since
464 // the window isn't in the visible workspace. 464 // the window isn't in the visible workspace.
465 w1->SetBounds(touches_shelf_bounds); 465 w1->SetBounds(touches_shelf_bounds);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 // Apply a transform on |second|. After the transform is applied, the window 1381 // Apply a transform on |second|. After the transform is applied, the window
1382 // should no longer be targetted. 1382 // should no longer be targetted.
1383 gfx::Transform transform; 1383 gfx::Transform transform;
1384 transform.Translate(70, 40); 1384 transform.Translate(70, 40);
1385 second->SetTransform(transform); 1385 second->SetTransform(transform);
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 } // namespace internal 1389 } // namespace internal
1390 } // namespace ash 1390 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer_unittest.cc ('k') | chrome/browser/chromeos/display/display_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698