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

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

Issue 36473003: Rename StackingClient -> WindowTreeClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: done. Created 7 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
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"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 88 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
89 window->Init(ui::LAYER_TEXTURED); 89 window->Init(ui::LAYER_TEXTURED);
90 return window; 90 return window;
91 } 91 }
92 92
93 aura::Window* CreateTestWindow() { 93 aura::Window* CreateTestWindow() {
94 aura::Window* window = new aura::Window(NULL); 94 aura::Window* window = new aura::Window(NULL);
95 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 95 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
96 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 96 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
97 window->Init(ui::LAYER_TEXTURED); 97 window->Init(ui::LAYER_TEXTURED);
98 SetDefaultParentByPrimaryRootWindow(window); 98 ParentWindowInPrimaryRootWindow(window);
99 return window; 99 return window;
100 } 100 }
101 101
102 aura::Window* CreateBrowserLikeWindow(const gfx::Rect& bounds) { 102 aura::Window* CreateBrowserLikeWindow(const gfx::Rect& bounds) {
103 aura::Window* window = CreateTestWindow(); 103 aura::Window* window = CreateTestWindow();
104 window->SetBounds(bounds); 104 window->SetBounds(bounds);
105 wm::WindowState* window_state = wm::GetWindowState(window); 105 wm::WindowState* window_state = wm::GetWindowState(window);
106 window_state->SetTrackedByWorkspace(true); 106 window_state->SetTrackedByWorkspace(true);
107 window_state->set_window_position_managed(true); 107 window_state->set_window_position_managed(true);
108 window->Show(); 108 window->Show();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // workspace. 234 // workspace.
235 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); 235 w1->SetBounds(gfx::Rect(0, 0, 200, 500));
236 EXPECT_EQ(200, w1->bounds().width()); 236 EXPECT_EQ(200, w1->bounds().width());
237 EXPECT_EQ(500, w1->bounds().height()); 237 EXPECT_EQ(500, w1->bounds().height());
238 } 238 }
239 239
240 // Verifies the bounds is not altered when showing and grid is enabled. 240 // Verifies the bounds is not altered when showing and grid is enabled.
241 TEST_F(WorkspaceControllerTest, SnapToGrid) { 241 TEST_F(WorkspaceControllerTest, SnapToGrid) {
242 scoped_ptr<Window> w1(CreateTestWindowUnparented()); 242 scoped_ptr<Window> w1(CreateTestWindowUnparented());
243 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); 243 w1->SetBounds(gfx::Rect(1, 6, 25, 30));
244 SetDefaultParentByPrimaryRootWindow(w1.get()); 244 ParentWindowInPrimaryRootWindow(w1.get());
245 // We are not aligning this anymore this way. When the window gets shown 245 // We are not aligning this anymore this way. When the window gets shown
246 // the window is expected to be handled differently, but this cannot be 246 // the window is expected to be handled differently, but this cannot be
247 // tested with this test. So the result of this test should be that the 247 // tested with this test. So the result of this test should be that the
248 // bounds are exactly as passed in. 248 // bounds are exactly as passed in.
249 EXPECT_EQ("1,6 25x30", w1->bounds().ToString()); 249 EXPECT_EQ("1,6 25x30", w1->bounds().ToString());
250 } 250 }
251 251
252 // Assertions around a fullscreen window. 252 // Assertions around a fullscreen window.
253 TEST_F(WorkspaceControllerTest, SingleFullscreenWindow) { 253 TEST_F(WorkspaceControllerTest, SingleFullscreenWindow) {
254 scoped_ptr<Window> w1(CreateTestWindow()); 254 scoped_ptr<Window> w1(CreateTestWindow());
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 w1_state->Activate(); 654 w1_state->Activate();
655 w1_state->Maximize(); 655 w1_state->Maximize();
656 w1_state->Minimize(); 656 w1_state->Minimize();
657 657
658 w1->parent()->RemoveChild(w1.get()); 658 w1->parent()->RemoveChild(w1.get());
659 659
660 // Do this so that when we Show() the window a resize occurs and we make the 660 // Do this so that when we Show() the window a resize occurs and we make the
661 // window active. 661 // window active.
662 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 662 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
663 663
664 SetDefaultParentByPrimaryRootWindow(w1.get()); 664 ParentWindowInPrimaryRootWindow(w1.get());
665 delegate.set_window(w1.get()); 665 delegate.set_window(w1.get());
666 w1->Show(); 666 w1->Show();
667 } 667 }
668 668
669 // Verifies a window with a transient parent not managed by workspace works. 669 // Verifies a window with a transient parent not managed by workspace works.
670 TEST_F(WorkspaceControllerTest, TransientParent) { 670 TEST_F(WorkspaceControllerTest, TransientParent) {
671 // Normal window with no transient parent. 671 // Normal window with no transient parent.
672 scoped_ptr<Window> w2(CreateTestWindow()); 672 scoped_ptr<Window> w2(CreateTestWindow());
673 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 673 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
674 w2->Show(); 674 w2->Show();
675 wm::ActivateWindow(w2.get()); 675 wm::ActivateWindow(w2.get());
676 676
677 // Window with a transient parent. We set the transient parent to the root, 677 // Window with a transient parent. We set the transient parent to the root,
678 // which would never happen but is enough to exercise the bug. 678 // which would never happen but is enough to exercise the bug.
679 scoped_ptr<Window> w1(CreateTestWindowUnparented()); 679 scoped_ptr<Window> w1(CreateTestWindowUnparented());
680 Shell::GetInstance()->GetPrimaryRootWindow()->AddTransientChild(w1.get()); 680 Shell::GetInstance()->GetPrimaryRootWindow()->AddTransientChild(w1.get());
681 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); 681 w1->SetBounds(gfx::Rect(10, 11, 250, 251));
682 SetDefaultParentByPrimaryRootWindow(w1.get()); 682 ParentWindowInPrimaryRootWindow(w1.get());
683 w1->Show(); 683 w1->Show();
684 wm::ActivateWindow(w1.get()); 684 wm::ActivateWindow(w1.get());
685 685
686 // The window with the transient parent should get added to the same parent as 686 // The window with the transient parent should get added to the same parent as
687 // the normal window. 687 // the normal window.
688 EXPECT_EQ(w2->parent(), w1->parent()); 688 EXPECT_EQ(w2->parent(), w1->parent());
689 } 689 }
690 690
691 // Verifies changing TrackedByWorkspace works. 691 // Verifies changing TrackedByWorkspace works.
692 TEST_F(WorkspaceControllerTest, TrackedByWorkspace) { 692 TEST_F(WorkspaceControllerTest, TrackedByWorkspace) {
693 // Create a fullscreen window. 693 // Create a fullscreen window.
694 scoped_ptr<Window> w1(CreateTestWindow()); 694 scoped_ptr<Window> w1(CreateTestWindow());
695 w1->Show(); 695 w1->Show();
696 wm::ActivateWindow(w1.get()); 696 wm::ActivateWindow(w1.get());
697 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 697 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
698 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 698 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
699 EXPECT_TRUE(w1->IsVisible()); 699 EXPECT_TRUE(w1->IsVisible());
700 700
701 // Create a second fullscreen window and mark it not tracked by workspace 701 // Create a second fullscreen window and mark it not tracked by workspace
702 // manager. 702 // manager.
703 scoped_ptr<Window> w2(CreateTestWindowUnparented()); 703 scoped_ptr<Window> w2(CreateTestWindowUnparented());
704 w2->SetBounds(gfx::Rect(1, 6, 25, 30)); 704 w2->SetBounds(gfx::Rect(1, 6, 25, 30));
705 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 705 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
706 SetDefaultParentByPrimaryRootWindow(w2.get()); 706 ParentWindowInPrimaryRootWindow(w2.get());
707 w2->Show(); 707 w2->Show();
708 wm::GetWindowState(w2.get())->SetTrackedByWorkspace(false); 708 wm::GetWindowState(w2.get())->SetTrackedByWorkspace(false);
709 wm::ActivateWindow(w2.get()); 709 wm::ActivateWindow(w2.get());
710 710
711 // Activating |w2| should force it to have the same parent as |w1|. 711 // Activating |w2| should force it to have the same parent as |w1|.
712 EXPECT_EQ(w1->parent(), w2->parent()); 712 EXPECT_EQ(w1->parent(), w2->parent());
713 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 713 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
714 EXPECT_TRUE(w1->IsVisible()); 714 EXPECT_TRUE(w1->IsVisible());
715 EXPECT_TRUE(w2->IsVisible()); 715 EXPECT_TRUE(w2->IsVisible());
716 716
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 // with a real browser the browser here has a transient child window 1156 // with a real browser the browser here has a transient child window
1157 // (corresponds to the status bubble). 1157 // (corresponds to the status bubble).
1158 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { 1158 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) {
1159 scoped_ptr<Window> browser( 1159 scoped_ptr<Window> browser(
1160 aura::test::CreateTestWindowWithDelegate( 1160 aura::test::CreateTestWindowWithDelegate(
1161 NULL, 1161 NULL,
1162 aura::client::WINDOW_TYPE_NORMAL, 1162 aura::client::WINDOW_TYPE_NORMAL,
1163 gfx::Rect(5, 6, 7, 8), 1163 gfx::Rect(5, 6, 7, 8),
1164 NULL)); 1164 NULL));
1165 browser->SetName("browser"); 1165 browser->SetName("browser");
1166 SetDefaultParentByPrimaryRootWindow(browser.get()); 1166 ParentWindowInPrimaryRootWindow(browser.get());
1167 browser->Show(); 1167 browser->Show();
1168 wm::ActivateWindow(browser.get()); 1168 wm::ActivateWindow(browser.get());
1169 1169
1170 // |status_bubble| is made a transient child of |browser| and as a result 1170 // |status_bubble| is made a transient child of |browser| and as a result
1171 // owned by |browser|. 1171 // owned by |browser|.
1172 aura::test::TestWindowDelegate* status_bubble_delegate = 1172 aura::test::TestWindowDelegate* status_bubble_delegate =
1173 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); 1173 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate();
1174 status_bubble_delegate->set_can_focus(false); 1174 status_bubble_delegate->set_can_focus(false);
1175 Window* status_bubble = 1175 Window* status_bubble =
1176 aura::test::CreateTestWindowWithDelegate( 1176 aura::test::CreateTestWindowWithDelegate(
1177 status_bubble_delegate, 1177 status_bubble_delegate,
1178 aura::client::WINDOW_TYPE_POPUP, 1178 aura::client::WINDOW_TYPE_POPUP,
1179 gfx::Rect(5, 6, 7, 8), 1179 gfx::Rect(5, 6, 7, 8),
1180 NULL); 1180 NULL);
1181 browser->AddTransientChild(status_bubble); 1181 browser->AddTransientChild(status_bubble);
1182 SetDefaultParentByPrimaryRootWindow(status_bubble); 1182 ParentWindowInPrimaryRootWindow(status_bubble);
1183 status_bubble->SetName("status_bubble"); 1183 status_bubble->SetName("status_bubble");
1184 1184
1185 scoped_ptr<Window> app( 1185 scoped_ptr<Window> app(
1186 aura::test::CreateTestWindowWithDelegate( 1186 aura::test::CreateTestWindowWithDelegate(
1187 NULL, 1187 NULL,
1188 aura::client::WINDOW_TYPE_NORMAL, 1188 aura::client::WINDOW_TYPE_NORMAL,
1189 gfx::Rect(5, 6, 7, 8), 1189 gfx::Rect(5, 6, 7, 8),
1190 NULL)); 1190 NULL));
1191 app->SetName("app"); 1191 app->SetName("app");
1192 SetDefaultParentByPrimaryRootWindow(app.get()); 1192 ParentWindowInPrimaryRootWindow(app.get());
1193 1193
1194 aura::Window* parent = browser->parent(); 1194 aura::Window* parent = browser->parent();
1195 1195
1196 app->Show(); 1196 app->Show();
1197 wm::ActivateWindow(app.get()); 1197 wm::ActivateWindow(app.get());
1198 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); 1198 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent));
1199 1199
1200 // Minimize the app, focus should go the browser. 1200 // Minimize the app, focus should go the browser.
1201 app->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 1201 app->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
1202 EXPECT_TRUE(wm::IsActiveWindow(browser.get())); 1202 EXPECT_TRUE(wm::IsActiveWindow(browser.get()));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 Shell::GetPrimaryRootWindow(), gfx::Point()); 1275 Shell::GetPrimaryRootWindow(), gfx::Point());
1276 generator.MoveMouseTo(5, 5); 1276 generator.MoveMouseTo(5, 5);
1277 1277
1278 aura::test::TestWindowDelegate delegate; 1278 aura::test::TestWindowDelegate delegate;
1279 delegate.set_window_component(HTCAPTION); 1279 delegate.set_window_component(HTCAPTION);
1280 scoped_ptr<Window> w1( 1280 scoped_ptr<Window> w1(
1281 aura::test::CreateTestWindowWithDelegate(&delegate, 1281 aura::test::CreateTestWindowWithDelegate(&delegate,
1282 aura::client::WINDOW_TYPE_NORMAL, 1282 aura::client::WINDOW_TYPE_NORMAL,
1283 gfx::Rect(5, 6, 7, 8), 1283 gfx::Rect(5, 6, 7, 8),
1284 NULL)); 1284 NULL));
1285 SetDefaultParentByPrimaryRootWindow(w1.get()); 1285 ParentWindowInPrimaryRootWindow(w1.get());
1286 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1286 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1287 w1->Show(); 1287 w1->Show();
1288 wm::ActivateWindow(w1.get()); 1288 wm::ActivateWindow(w1.get());
1289 DragMaximizedNonTrackedWindowObserver observer; 1289 DragMaximizedNonTrackedWindowObserver observer;
1290 w1->parent()->parent()->AddObserver(&observer); 1290 w1->parent()->parent()->AddObserver(&observer);
1291 const gfx::Rect max_bounds(w1->bounds()); 1291 const gfx::Rect max_bounds(w1->bounds());
1292 1292
1293 generator.PressLeftButton(); 1293 generator.PressLeftButton();
1294 generator.MoveMouseTo(100, 100); 1294 generator.MoveMouseTo(100, 100);
1295 // The bounds shouldn't change (drag should result in nothing happening 1295 // The bounds shouldn't change (drag should result in nothing happening
(...skipping 28 matching lines...) Expand all
1324 Shell::GetPrimaryRootWindow(), gfx::Point()); 1324 Shell::GetPrimaryRootWindow(), gfx::Point());
1325 generator.MoveMouseTo(5, 5); 1325 generator.MoveMouseTo(5, 5);
1326 1326
1327 aura::test::TestWindowDelegate delegate; 1327 aura::test::TestWindowDelegate delegate;
1328 delegate.set_window_component(HTCAPTION); 1328 delegate.set_window_component(HTCAPTION);
1329 scoped_ptr<Window> w1( 1329 scoped_ptr<Window> w1(
1330 aura::test::CreateTestWindowWithDelegate(&delegate, 1330 aura::test::CreateTestWindowWithDelegate(&delegate,
1331 aura::client::WINDOW_TYPE_NORMAL, 1331 aura::client::WINDOW_TYPE_NORMAL,
1332 gfx::Rect(5, 6, 7, 8), 1332 gfx::Rect(5, 6, 7, 8),
1333 NULL)); 1333 NULL));
1334 SetDefaultParentByPrimaryRootWindow(w1.get()); 1334 ParentWindowInPrimaryRootWindow(w1.get());
1335 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1335 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1336 w1->Show(); 1336 w1->Show();
1337 wm::ActivateWindow(w1.get()); 1337 wm::ActivateWindow(w1.get());
1338 DragMaximizedNonTrackedWindowObserver observer; 1338 DragMaximizedNonTrackedWindowObserver observer;
1339 w1->parent()->parent()->AddObserver(&observer); 1339 w1->parent()->parent()->AddObserver(&observer);
1340 const gfx::Rect max_bounds(w1->bounds()); 1340 const gfx::Rect max_bounds(w1->bounds());
1341 1341
1342 generator.PressLeftButton(); 1342 generator.PressLeftButton();
1343 generator.MoveMouseTo(100, 100); 1343 generator.MoveMouseTo(100, 100);
1344 // The bounds shouldn't change (drag should result in nothing happening 1344 // The bounds shouldn't change (drag should result in nothing happening
(...skipping 21 matching lines...) Expand all
1366 w1->parent()->parent()->RemoveObserver(&observer); 1366 w1->parent()->parent()->RemoveObserver(&observer);
1367 } 1367 }
1368 1368
1369 // Verifies that a new maximized window becomes visible after its activation 1369 // Verifies that a new maximized window becomes visible after its activation
1370 // is requested, even though it does not become activated because a system 1370 // is requested, even though it does not become activated because a system
1371 // modal window is active. 1371 // modal window is active.
1372 TEST_F(WorkspaceControllerTest, SwitchFromModal) { 1372 TEST_F(WorkspaceControllerTest, SwitchFromModal) {
1373 scoped_ptr<Window> modal_window(CreateTestWindowUnparented()); 1373 scoped_ptr<Window> modal_window(CreateTestWindowUnparented());
1374 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); 1374 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22));
1375 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 1375 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
1376 SetDefaultParentByPrimaryRootWindow(modal_window.get()); 1376 ParentWindowInPrimaryRootWindow(modal_window.get());
1377 modal_window->Show(); 1377 modal_window->Show();
1378 wm::ActivateWindow(modal_window.get()); 1378 wm::ActivateWindow(modal_window.get());
1379 1379
1380 scoped_ptr<Window> maximized_window(CreateTestWindow()); 1380 scoped_ptr<Window> maximized_window(CreateTestWindow());
1381 maximized_window->SetProperty( 1381 maximized_window->SetProperty(
1382 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1382 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1383 maximized_window->Show(); 1383 maximized_window->Show();
1384 wm::ActivateWindow(maximized_window.get()); 1384 wm::ActivateWindow(maximized_window.get());
1385 EXPECT_TRUE(maximized_window->IsVisible()); 1385 EXPECT_TRUE(maximized_window->IsVisible());
1386 } 1386 }
1387 1387
1388 } // namespace internal 1388 } // namespace internal
1389 } // namespace ash 1389 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer_unittest.cc ('k') | chrome/browser/ui/views/apps/native_app_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698