| OLD | NEW |
| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 scoped_ptr<Window> w1(CreateTestWindow()); | 309 scoped_ptr<Window> w1(CreateTestWindow()); |
| 310 | 310 |
| 311 w1->Show(); | 311 w1->Show(); |
| 312 | 312 |
| 313 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 313 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 314 EXPECT_FALSE(w1->layer()->IsDrawn()); | 314 EXPECT_FALSE(w1->layer()->IsDrawn()); |
| 315 EXPECT_TRUE(w1->layer()->GetTargetTransform().IsIdentity()); | 315 EXPECT_TRUE(w1->layer()->GetTargetTransform().IsIdentity()); |
| 316 | 316 |
| 317 // Show the window. | 317 // Show the window. |
| 318 w1->Show(); | 318 w1->Show(); |
| 319 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalShowState()); | 319 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalShowType()); |
| 320 EXPECT_TRUE(w1->layer()->IsDrawn()); | 320 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 // Assertions around minimizing a fullscreen window. | 323 // Assertions around minimizing a fullscreen window. |
| 324 TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) { | 324 TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) { |
| 325 // Two windows, w1 normal, w2 fullscreen. | 325 // Two windows, w1 normal, w2 fullscreen. |
| 326 scoped_ptr<Window> w1(CreateTestWindow()); | 326 scoped_ptr<Window> w1(CreateTestWindow()); |
| 327 scoped_ptr<Window> w2(CreateTestWindow()); | 327 scoped_ptr<Window> w2(CreateTestWindow()); |
| 328 w1->Show(); | 328 w1->Show(); |
| 329 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 329 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 | 990 |
| 991 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 991 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
| 992 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 992 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
| 993 window2_state->set_window_position_managed(true); | 993 window2_state->set_window_position_managed(true); |
| 994 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 994 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
| 995 | 995 |
| 996 window1_state->Minimize(); | 996 window1_state->Minimize(); |
| 997 | 997 |
| 998 // |window2| should be centered now. | 998 // |window2| should be centered now. |
| 999 EXPECT_TRUE(window2->IsVisible()); | 999 EXPECT_TRUE(window2->IsVisible()); |
| 1000 EXPECT_TRUE(window2_state->IsNormalShowState()); | 1000 EXPECT_TRUE(window2_state->IsNormalShowType()); |
| 1001 EXPECT_EQ(base::IntToString( | 1001 EXPECT_EQ(base::IntToString( |
| 1002 (desktop_area.width() - window2->bounds().width()) / 2) + | 1002 (desktop_area.width() - window2->bounds().width()) / 2) + |
| 1003 ",48 256x512", window2->bounds().ToString()); | 1003 ",48 256x512", window2->bounds().ToString()); |
| 1004 | 1004 |
| 1005 window1_state->Restore(); | 1005 window1_state->Restore(); |
| 1006 // |window1| should be flush right and |window3| flush left. | 1006 // |window1| should be flush right and |window3| flush left. |
| 1007 EXPECT_EQ(base::IntToString( | 1007 EXPECT_EQ(base::IntToString( |
| 1008 desktop_area.width() - window1->bounds().width()) + | 1008 desktop_area.width() - window1->bounds().width()) + |
| 1009 ",32 640x320", window1->bounds().ToString()); | 1009 ",32 640x320", window1->bounds().ToString()); |
| 1010 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); | 1010 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 // Test that minimizing an initially maximized window will repos the remaining. | 1013 // Test that minimizing an initially maximized window will repos the remaining. |
| 1014 TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { | 1014 TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { |
| 1015 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1015 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
| 1016 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1016 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| 1017 window1_state->set_window_position_managed(true); | 1017 window1_state->set_window_position_managed(true); |
| 1018 gfx::Rect desktop_area = window1->parent()->bounds(); | 1018 gfx::Rect desktop_area = window1->parent()->bounds(); |
| 1019 | 1019 |
| 1020 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); | 1020 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); |
| 1021 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 1021 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
| 1022 window2_state->set_window_position_managed(true); | 1022 window2_state->set_window_position_managed(true); |
| 1023 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 1023 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
| 1024 | 1024 |
| 1025 window1_state->Maximize(); | 1025 window1_state->Maximize(); |
| 1026 window1_state->Minimize(); | 1026 window1_state->Minimize(); |
| 1027 | 1027 |
| 1028 // |window2| should be centered now. | 1028 // |window2| should be centered now. |
| 1029 EXPECT_TRUE(window2->IsVisible()); | 1029 EXPECT_TRUE(window2->IsVisible()); |
| 1030 EXPECT_TRUE(window2_state->IsNormalShowState()); | 1030 EXPECT_TRUE(window2_state->IsNormalShowType()); |
| 1031 EXPECT_EQ(base::IntToString( | 1031 EXPECT_EQ(base::IntToString( |
| 1032 (desktop_area.width() - window2->bounds().width()) / 2) + | 1032 (desktop_area.width() - window2->bounds().width()) / 2) + |
| 1033 ",48 256x512", window2->bounds().ToString()); | 1033 ",48 256x512", window2->bounds().ToString()); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 // Test that nomral, maximize, minimizing will repos the remaining. | 1036 // Test that nomral, maximize, minimizing will repos the remaining. |
| 1037 TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { | 1037 TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { |
| 1038 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1038 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
| 1039 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1039 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
| 1040 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1040 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1054 EXPECT_EQ(base::IntToString( | 1054 EXPECT_EQ(base::IntToString( |
| 1055 desktop_area.width() - window1->bounds().width()) + | 1055 desktop_area.width() - window1->bounds().width()) + |
| 1056 ",32 640x320", window1->bounds().ToString()); | 1056 ",32 640x320", window1->bounds().ToString()); |
| 1057 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); | 1057 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); |
| 1058 | 1058 |
| 1059 window1_state->Maximize(); | 1059 window1_state->Maximize(); |
| 1060 window1_state->Minimize(); | 1060 window1_state->Minimize(); |
| 1061 | 1061 |
| 1062 // |window2| should be centered now. | 1062 // |window2| should be centered now. |
| 1063 EXPECT_TRUE(window2->IsVisible()); | 1063 EXPECT_TRUE(window2->IsVisible()); |
| 1064 EXPECT_TRUE(window2_state->IsNormalShowState()); | 1064 EXPECT_TRUE(window2_state->IsNormalShowType()); |
| 1065 EXPECT_EQ(base::IntToString( | 1065 EXPECT_EQ(base::IntToString( |
| 1066 (desktop_area.width() - window2->bounds().width()) / 2) + | 1066 (desktop_area.width() - window2->bounds().width()) / 2) + |
| 1067 ",40 256x512", window2->bounds().ToString()); | 1067 ",40 256x512", window2->bounds().ToString()); |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 // Test that nomral, maximize, normal will repos the remaining. | 1070 // Test that nomral, maximize, normal will repos the remaining. |
| 1071 TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { | 1071 TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { |
| 1072 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1072 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
| 1073 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1073 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
| 1074 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 1074 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 target = targeter->FindTargetForEvent(root, &touch); | 1498 target = targeter->FindTargetForEvent(root, &touch); |
| 1499 if (points[i].is_target_hit) | 1499 if (points[i].is_target_hit) |
| 1500 EXPECT_EQ(window.get(), target); | 1500 EXPECT_EQ(window.get(), target); |
| 1501 else | 1501 else |
| 1502 EXPECT_NE(window.get(), target); | 1502 EXPECT_NE(window.get(), target); |
| 1503 } | 1503 } |
| 1504 } | 1504 } |
| 1505 | 1505 |
| 1506 } // namespace internal | 1506 } // namespace internal |
| 1507 } // namespace ash | 1507 } // namespace ash |
| OLD | NEW |