OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/dock/docked_window_resizer.h" | 5 #include "ash/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_model.h" | 12 #include "ash/shelf/shelf_model.h" |
13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
14 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
16 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
17 #include "ash/test/ash_test_base.h" | 17 #include "ash/test/ash_test_base.h" |
18 #include "ash/test/cursor_manager_test_api.h" | 18 #include "ash/test/cursor_manager_test_api.h" |
19 #include "ash/test/shell_test_api.h" | 19 #include "ash/test/shell_test_api.h" |
20 #include "ash/test/test_launcher_delegate.h" | 20 #include "ash/test/test_launcher_delegate.h" |
21 #include "ash/wm/coordinate_conversion.h" | 21 #include "ash/wm/coordinate_conversion.h" |
22 #include "ash/wm/dock/docked_window_layout_manager.h" | 22 #include "ash/wm/dock/docked_window_layout_manager.h" |
23 #include "ash/wm/drag_window_resizer.h" | 23 #include "ash/wm/drag_window_resizer.h" |
24 #include "ash/wm/panels/panel_layout_manager.h" | 24 #include "ash/wm/panels/panel_layout_manager.h" |
25 #include "ash/wm/window_state.h" | 25 #include "ash/wm/window_state.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "ash/wm/workspace/snap_sizer.h" | |
27 #include "base/command_line.h" | 28 #include "base/command_line.h" |
28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
29 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
30 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
31 #include "ui/base/hit_test.h" | 32 #include "ui/base/hit_test.h" |
32 #include "ui/base/ui_base_types.h" | 33 #include "ui/base/ui_base_types.h" |
33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
34 | 35 |
35 namespace ash { | 36 namespace ash { |
36 namespace internal { | 37 namespace internal { |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1295 DragEnd(); | 1296 DragEnd(); |
1296 | 1297 |
1297 // The window should be undocked and the transient child should be reparented. | 1298 // The window should be undocked and the transient child should be reparented. |
1298 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); | 1299 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); |
1299 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); | 1300 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, child->parent()->id()); |
1300 // The child should not have moved. | 1301 // The child should not have moved. |
1301 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), | 1302 EXPECT_EQ(gfx::Point(20 + 500, 20 + 20).ToString(), |
1302 child->GetBoundsInScreen().origin().ToString()); | 1303 child->GetBoundsInScreen().origin().ToString()); |
1303 } | 1304 } |
1304 | 1305 |
1306 // Tests that side snapping a window undocks it, closes the dock and then snaps. | |
1307 TEST_P(DockedWindowResizerTest, SideSnapDocked) { | |
1308 if (!SupportsHostWindowResize() || test_panels()) | |
1309 return; | |
1310 | |
1311 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | |
1312 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | |
1313 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | |
1314 // A window should be attached and snapped to the right edge. | |
pkotwicz
2013/11/27 20:24:43
For the sake of sanity a window is either docked o
varkha
2013/11/28 01:09:37
Done.
| |
1315 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | |
1316 w1->GetBoundsInScreen().right()); | |
1317 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | |
1318 DockedWindowLayoutManager* manager = | |
1319 static_cast<DockedWindowLayoutManager*>(w1->parent()->layout_manager()); | |
1320 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | |
1321 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | |
1322 EXPECT_TRUE(window_state->IsDocked()); | |
1323 EXPECT_FALSE(window_state->IsSnapped()); | |
1324 | |
1325 // Side snap at right edge. | |
1326 internal::SnapSizer::SnapWindow(window_state, | |
1327 internal::SnapSizer::RIGHT_EDGE); | |
1328 // The window should be snapped at the right edge and the dock should close. | |
1329 EXPECT_EQ(0, docked_width(manager)); | |
1330 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(), | |
1331 w1->bounds().height()); | |
1332 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).right(), | |
1333 w1->bounds().right()); | |
1334 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); | |
1335 EXPECT_FALSE(window_state->IsDocked()); | |
1336 EXPECT_TRUE(window_state->IsSnapped()); | |
1337 | |
1338 // Dock again. | |
1339 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | |
1340 // A window should be attached and snapped to the right edge. | |
pkotwicz
2013/11/27 20:24:43
Can you change this comment too?
varkha
2013/11/28 01:09:37
Done. Also changed throughout this file. Seems lik
| |
1341 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | |
1342 w1->GetBoundsInScreen().right()); | |
1343 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); | |
1344 EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); | |
1345 EXPECT_EQ(w1->bounds().width(), docked_width(manager)); | |
1346 EXPECT_TRUE(window_state->IsDocked()); | |
1347 EXPECT_FALSE(window_state->IsSnapped()); | |
1348 | |
1349 // Side snap at left edge. | |
1350 internal::SnapSizer::SnapWindow(window_state, | |
1351 internal::SnapSizer::LEFT_EDGE); | |
1352 // The window should be snapped at the right edge and the dock should close. | |
1353 EXPECT_EQ(0, docked_width(manager)); | |
1354 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).height(), | |
1355 w1->bounds().height()); | |
1356 EXPECT_EQ(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).x(), | |
1357 w1->bounds().x()); | |
1358 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w1->parent()->id()); | |
1359 EXPECT_FALSE(window_state->IsDocked()); | |
1360 EXPECT_TRUE(window_state->IsSnapped()); | |
1361 } | |
1362 | |
1305 // Tests run twice - on both panels and normal windows | 1363 // Tests run twice - on both panels and normal windows |
1306 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1364 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
1307 DockedWindowResizerTest, | 1365 DockedWindowResizerTest, |
1308 testing::Values(aura::client::WINDOW_TYPE_NORMAL, | 1366 testing::Values(aura::client::WINDOW_TYPE_NORMAL, |
1309 aura::client::WINDOW_TYPE_PANEL)); | 1367 aura::client::WINDOW_TYPE_PANEL)); |
1310 } // namespace internal | 1368 } // namespace internal |
1311 } // namespace ash | 1369 } // namespace ash |
OLD | NEW |