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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 class WorkspaceControllerTest : public test::AshTestBase { | 80 class WorkspaceControllerTest : public test::AshTestBase { |
81 public: | 81 public: |
82 WorkspaceControllerTest() {} | 82 WorkspaceControllerTest() {} |
83 virtual ~WorkspaceControllerTest() {} | 83 virtual ~WorkspaceControllerTest() {} |
84 | 84 |
85 aura::Window* CreateTestWindowUnparented() { | 85 aura::Window* CreateTestWindowUnparented() { |
86 aura::Window* window = new aura::Window(NULL); | 86 aura::Window* window = new aura::Window(NULL); |
87 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 87 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
88 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 88 window->SetType(ui::wm::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(ui::wm::WINDOW_TYPE_NORMAL); |
97 window->Init(ui::LAYER_TEXTURED); | 97 window->Init(ui::LAYER_TEXTURED); |
98 ParentWindowInPrimaryRootWindow(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->set_window_position_managed(true); | 106 window_state->set_window_position_managed(true); |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 ",32 640x320", window1->bounds().ToString()); | 1107 ",32 640x320", window1->bounds().ToString()); |
1108 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); | 1108 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); |
1109 } | 1109 } |
1110 | 1110 |
1111 // This tests simulates a browser and an app and verifies the ordering of the | 1111 // This tests simulates a browser and an app and verifies the ordering of the |
1112 // windows and layers doesn't get out of sync as various operations occur. Its | 1112 // windows and layers doesn't get out of sync as various operations occur. Its |
1113 // really testing code in FocusController, but easier to simulate here. Just as | 1113 // really testing code in FocusController, but easier to simulate here. Just as |
1114 // with a real browser the browser here has a transient child window | 1114 // with a real browser the browser here has a transient child window |
1115 // (corresponds to the status bubble). | 1115 // (corresponds to the status bubble). |
1116 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { | 1116 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { |
1117 scoped_ptr<Window> browser( | 1117 scoped_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate( |
1118 aura::test::CreateTestWindowWithDelegate( | 1118 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); |
1119 NULL, | |
1120 aura::client::WINDOW_TYPE_NORMAL, | |
1121 gfx::Rect(5, 6, 7, 8), | |
1122 NULL)); | |
1123 browser->SetName("browser"); | 1119 browser->SetName("browser"); |
1124 ParentWindowInPrimaryRootWindow(browser.get()); | 1120 ParentWindowInPrimaryRootWindow(browser.get()); |
1125 browser->Show(); | 1121 browser->Show(); |
1126 wm::ActivateWindow(browser.get()); | 1122 wm::ActivateWindow(browser.get()); |
1127 | 1123 |
1128 // |status_bubble| is made a transient child of |browser| and as a result | 1124 // |status_bubble| is made a transient child of |browser| and as a result |
1129 // owned by |browser|. | 1125 // owned by |browser|. |
1130 aura::test::TestWindowDelegate* status_bubble_delegate = | 1126 aura::test::TestWindowDelegate* status_bubble_delegate = |
1131 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); | 1127 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); |
1132 status_bubble_delegate->set_can_focus(false); | 1128 status_bubble_delegate->set_can_focus(false); |
1133 Window* status_bubble = | 1129 Window* status_bubble = |
1134 aura::test::CreateTestWindowWithDelegate( | 1130 aura::test::CreateTestWindowWithDelegate(status_bubble_delegate, |
1135 status_bubble_delegate, | 1131 ui::wm::WINDOW_TYPE_POPUP, |
1136 aura::client::WINDOW_TYPE_POPUP, | 1132 gfx::Rect(5, 6, 7, 8), |
1137 gfx::Rect(5, 6, 7, 8), | 1133 NULL); |
1138 NULL); | |
1139 browser->AddTransientChild(status_bubble); | 1134 browser->AddTransientChild(status_bubble); |
1140 ParentWindowInPrimaryRootWindow(status_bubble); | 1135 ParentWindowInPrimaryRootWindow(status_bubble); |
1141 status_bubble->SetName("status_bubble"); | 1136 status_bubble->SetName("status_bubble"); |
1142 | 1137 |
1143 scoped_ptr<Window> app( | 1138 scoped_ptr<Window> app(aura::test::CreateTestWindowWithDelegate( |
1144 aura::test::CreateTestWindowWithDelegate( | 1139 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); |
1145 NULL, | |
1146 aura::client::WINDOW_TYPE_NORMAL, | |
1147 gfx::Rect(5, 6, 7, 8), | |
1148 NULL)); | |
1149 app->SetName("app"); | 1140 app->SetName("app"); |
1150 ParentWindowInPrimaryRootWindow(app.get()); | 1141 ParentWindowInPrimaryRootWindow(app.get()); |
1151 | 1142 |
1152 aura::Window* parent = browser->parent(); | 1143 aura::Window* parent = browser->parent(); |
1153 | 1144 |
1154 app->Show(); | 1145 app->Show(); |
1155 wm::ActivateWindow(app.get()); | 1146 wm::ActivateWindow(app.get()); |
1156 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); | 1147 EXPECT_EQ(GetWindowNames(parent), GetLayerNames(parent)); |
1157 | 1148 |
1158 // Minimize the app, focus should go the browser. | 1149 // Minimize the app, focus should go the browser. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); | 1265 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); |
1275 }; | 1266 }; |
1276 | 1267 |
1277 } // namespace | 1268 } // namespace |
1278 | 1269 |
1279 // Verifies that when dragging a window over the shelf overlap is detected | 1270 // Verifies that when dragging a window over the shelf overlap is detected |
1280 // during and after the drag. | 1271 // during and after the drag. |
1281 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { | 1272 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { |
1282 aura::test::TestWindowDelegate delegate; | 1273 aura::test::TestWindowDelegate delegate; |
1283 delegate.set_window_component(HTCAPTION); | 1274 delegate.set_window_component(HTCAPTION); |
1284 scoped_ptr<Window> w1( | 1275 scoped_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( |
1285 aura::test::CreateTestWindowWithDelegate(&delegate, | 1276 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); |
1286 aura::client::WINDOW_TYPE_NORMAL, | |
1287 gfx::Rect(5, 5, 100, 50), | |
1288 NULL)); | |
1289 ParentWindowInPrimaryRootWindow(w1.get()); | 1277 ParentWindowInPrimaryRootWindow(w1.get()); |
1290 | 1278 |
1291 ShelfLayoutManager* shelf = shelf_layout_manager(); | 1279 ShelfLayoutManager* shelf = shelf_layout_manager(); |
1292 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1280 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1293 | 1281 |
1294 // Drag near the shelf | 1282 // Drag near the shelf |
1295 aura::test::EventGenerator generator( | 1283 aura::test::EventGenerator generator( |
1296 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1284 Shell::GetPrimaryRootWindow(), gfx::Point()); |
1297 generator.MoveMouseTo(10, 10); | 1285 generator.MoveMouseTo(10, 10); |
1298 generator.PressLeftButton(); | 1286 generator.PressLeftButton(); |
1299 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); | 1287 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 70); |
1300 | 1288 |
1301 // Shelf should not be in overlapped state. | 1289 // Shelf should not be in overlapped state. |
1302 EXPECT_FALSE(GetWindowOverlapsShelf()); | 1290 EXPECT_FALSE(GetWindowOverlapsShelf()); |
1303 | 1291 |
1304 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); | 1292 generator.MoveMouseTo(100, shelf->GetIdealBounds().y() - 20); |
1305 | 1293 |
1306 // Shelf should detect overlap. Overlap state stays after mouse is released. | 1294 // Shelf should detect overlap. Overlap state stays after mouse is released. |
1307 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1295 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1308 generator.ReleaseLeftButton(); | 1296 generator.ReleaseLeftButton(); |
1309 EXPECT_TRUE(GetWindowOverlapsShelf()); | 1297 EXPECT_TRUE(GetWindowOverlapsShelf()); |
1310 } | 1298 } |
1311 | 1299 |
1312 INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging, | 1300 INSTANTIATE_TEST_CASE_P(DockedOrNot, WorkspaceControllerTestDragging, |
1313 ::testing::Bool()); | 1301 ::testing::Bool()); |
1314 | 1302 |
1315 } // namespace internal | 1303 } // namespace internal |
1316 } // namespace ash | 1304 } // namespace ash |
OLD | NEW |