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

Side by Side Diff: ash/wm/workspace/workspace_manager_unittest.cc

Issue 10795013: Rename bounds accessors to be intuitive and consistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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/wm/workspace/snap_sizer.cc ('k') | ash/wm/workspace/workspace_window_resizer.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/workspace/workspace_manager.h" 5 #include "ash/wm/workspace/workspace_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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 EXPECT_EQ(251, w1->bounds().height()); 136 EXPECT_EQ(251, w1->bounds().height());
137 137
138 // Maximize the window. 138 // Maximize the window.
139 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 139 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
140 140
141 // Should be 2 workspaces, the second TYPE_MAXIMIZED with w1. 141 // Should be 2 workspaces, the second TYPE_MAXIMIZED with w1.
142 ASSERT_EQ(2u, workspaces().size()); 142 ASSERT_EQ(2u, workspaces().size());
143 EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type()); 143 EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
144 ASSERT_EQ(1u, workspaces()[1]->windows().size()); 144 ASSERT_EQ(1u, workspaces()[1]->windows().size());
145 EXPECT_EQ(w1.get(), workspaces()[1]->windows()[0]); 145 EXPECT_EQ(w1.get(), workspaces()[1]->windows()[0]);
146 EXPECT_EQ(ScreenAsh::GetMaximizedWindowParentBounds(w1.get()).width(), 146 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).width(),
147 w1->bounds().width()); 147 w1->bounds().width());
148 EXPECT_EQ(ScreenAsh::GetMaximizedWindowParentBounds(w1.get()).height(), 148 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).height(),
149 w1->bounds().height()); 149 w1->bounds().height());
150 150
151 // Restore the window. 151 // Restore the window.
152 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 152 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
153 153
154 // Should be 1 workspace, TYPE_MANAGED with w1. 154 // Should be 1 workspace, TYPE_MANAGED with w1.
155 ASSERT_EQ(1u, workspaces().size()); 155 ASSERT_EQ(1u, workspaces().size());
156 EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type()); 156 EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
157 ASSERT_EQ(1u, workspaces()[0]->windows().size()); 157 ASSERT_EQ(1u, workspaces()[0]->windows().size());
158 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]); 158 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Assertions around adding a maximized window when empty. 197 // Assertions around adding a maximized window when empty.
198 TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) { 198 TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) {
199 scoped_ptr<Window> w1(CreateTestWindow()); 199 scoped_ptr<Window> w1(CreateTestWindow());
200 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); 200 w1->SetBounds(gfx::Rect(0, 0, 250, 251));
201 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 201 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
202 w1->Show(); 202 w1->Show();
203 203
204 ASSERT_TRUE(w1->layer() != NULL); 204 ASSERT_TRUE(w1->layer() != NULL);
205 EXPECT_TRUE(w1->layer()->visible()); 205 EXPECT_TRUE(w1->layer()->visible());
206 gfx::Rect work_area( 206 gfx::Rect work_area(
207 ScreenAsh::GetMaximizedWindowParentBounds(w1.get())); 207 ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()));
208 EXPECT_EQ(work_area.width(), w1->bounds().width()); 208 EXPECT_EQ(work_area.width(), w1->bounds().width());
209 EXPECT_EQ(work_area.height(), w1->bounds().height()); 209 EXPECT_EQ(work_area.height(), w1->bounds().height());
210 210
211 // Should be 1 workspace, TYPE_NORNMAL with w1. 211 // Should be 1 workspace, TYPE_NORNMAL with w1.
212 ASSERT_EQ(1u, workspaces().size()); 212 ASSERT_EQ(1u, workspaces().size());
213 EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[0]->type()); 213 EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[0]->type());
214 ASSERT_EQ(1u, workspaces()[0]->windows().size()); 214 ASSERT_EQ(1u, workspaces()[0]->windows().size());
215 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]); 215 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
216 } 216 }
217 217
(...skipping 17 matching lines...) Expand all
235 ASSERT_EQ(1u, workspaces()[0]->windows().size()); 235 ASSERT_EQ(1u, workspaces()[0]->windows().size());
236 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]); 236 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
237 EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type()); 237 EXPECT_EQ(Workspace::TYPE_MAXIMIZED, workspaces()[1]->type());
238 ASSERT_EQ(1u, workspaces()[1]->windows().size()); 238 ASSERT_EQ(1u, workspaces()[1]->windows().size());
239 EXPECT_EQ(w2.get(), workspaces()[1]->windows()[0]); 239 EXPECT_EQ(w2.get(), workspaces()[1]->windows()[0]);
240 ASSERT_TRUE(w1->layer() != NULL); 240 ASSERT_TRUE(w1->layer() != NULL);
241 EXPECT_FALSE(w1->layer()->visible()); 241 EXPECT_FALSE(w1->layer()->visible());
242 ASSERT_TRUE(w2->layer() != NULL); 242 ASSERT_TRUE(w2->layer() != NULL);
243 EXPECT_TRUE(w2->layer()->visible()); 243 EXPECT_TRUE(w2->layer()->visible());
244 244
245 gfx::Rect work_area(ScreenAsh::GetMaximizedWindowParentBounds(w1.get())); 245 gfx::Rect work_area(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()));
246 EXPECT_EQ(work_area.width(), w2->bounds().width()); 246 EXPECT_EQ(work_area.width(), w2->bounds().width());
247 EXPECT_EQ(work_area.height(), w2->bounds().height()); 247 EXPECT_EQ(work_area.height(), w2->bounds().height());
248 248
249 // Restore w2, which should then go back to one workspace. 249 // Restore w2, which should then go back to one workspace.
250 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 250 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
251 ASSERT_EQ(1u, workspaces().size()); 251 ASSERT_EQ(1u, workspaces().size());
252 EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type()); 252 EXPECT_EQ(Workspace::TYPE_MANAGED, workspaces()[0]->type());
253 ASSERT_EQ(2u, workspaces()[0]->windows().size()); 253 ASSERT_EQ(2u, workspaces()[0]->windows().size());
254 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]); 254 EXPECT_EQ(w1.get(), workspaces()[0]->windows()[0]);
255 EXPECT_EQ(w2.get(), workspaces()[0]->windows()[1]); 255 EXPECT_EQ(w2.get(), workspaces()[0]->windows()[1]);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 505 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
506 w2->Show(); 506 w2->Show();
507 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 507 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
508 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 508 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
509 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 509 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
510 510
511 // Switch to w1. 511 // Switch to w1.
512 w1->Show(); 512 w1->Show();
513 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); 513 EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
514 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 514 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
515 EXPECT_EQ(ScreenAsh::GetMaximizedWindowParentBounds(w2.get()).ToString(), 515 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
516 w2->bounds().ToString()); 516 w2->bounds().ToString());
517 517
518 // Switch to w2. 518 // Switch to w2.
519 w2->Show(); 519 w2->Show();
520 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); 520 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
521 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 521 EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
522 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 522 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
523 EXPECT_EQ(ScreenAsh::GetMaximizedWindowParentBounds(w2.get()).ToString(), 523 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(),
524 w2->bounds().ToString()); 524 w2->bounds().ToString());
525 } 525 }
526 526
527 // Verifies persist across all workspaces. 527 // Verifies persist across all workspaces.
528 TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) { 528 TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) {
529 // Create a maximized window. 529 // Create a maximized window.
530 scoped_ptr<Window> w1(CreateTestWindow()); 530 scoped_ptr<Window> w1(CreateTestWindow());
531 w1->Show(); 531 w1->Show();
532 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 532 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
533 EXPECT_TRUE(w1->layer()->IsDrawn()); 533 EXPECT_TRUE(w1->layer()->IsDrawn());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 w1->Show(); 667 w1->Show();
668 w1->SetProperty(aura::client::kAnimationsDisabledKey, true); 668 w1->SetProperty(aura::client::kAnimationsDisabledKey, true);
669 669
670 w2->Show(); 670 w2->Show();
671 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 671 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
672 EXPECT_TRUE(w1->GetProperty(aura::client::kAnimationsDisabledKey)); 672 EXPECT_TRUE(w1->GetProperty(aura::client::kAnimationsDisabledKey));
673 } 673 }
674 674
675 } // namespace internal 675 } // namespace internal
676 } // namespace ash 676 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/snap_sizer.cc ('k') | ash/wm/workspace/workspace_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698