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

Side by Side Diff: ash/wm/dock/docked_window_resizer_unittest.cc

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded parens Created 6 years, 11 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/dock/docked_window_layout_manager.cc ('k') | ash/wm/drag_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) 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/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
(...skipping 14 matching lines...) Expand all
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 "ash/wm/workspace/snap_sizer.h"
28 #include "base/command_line.h" 28 #include "base/command_line.h"
29 #include "ui/aura/client/aura_constants.h" 29 #include "ui/aura/client/aura_constants.h"
30 #include "ui/aura/client/window_tree_client.h" 30 #include "ui/aura/client/window_tree_client.h"
31 #include "ui/aura/root_window.h" 31 #include "ui/aura/root_window.h"
32 #include "ui/aura/test/test_window_delegate.h" 32 #include "ui/aura/test/test_window_delegate.h"
33 #include "ui/base/hit_test.h" 33 #include "ui/base/hit_test.h"
34 #include "ui/base/ui_base_types.h" 34 #include "ui/base/ui_base_types.h"
35 #include "ui/views/corewm/window_util.h"
35 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
36 37
37 namespace ash { 38 namespace ash {
38 namespace internal { 39 namespace internal {
39 40
40 class DockedWindowResizerTest 41 class DockedWindowResizerTest
41 : public test::AshTestBase, 42 : public test::AshTestBase,
42 public testing::WithParamInterface<ui::wm::WindowType> { 43 public testing::WithParamInterface<ui::wm::WindowType> {
43 public: 44 public:
44 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {} 45 DockedWindowResizerTest() : model_(NULL), window_type_(GetParam()) {}
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 // Tests that docking and undocking a |window| with a transient child properly 1289 // Tests that docking and undocking a |window| with a transient child properly
1289 // maintains the parent of that transient child to be the same as the |window|. 1290 // maintains the parent of that transient child to be the same as the |window|.
1290 TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) { 1291 TEST_P(DockedWindowResizerTest, DragWindowWithTransientChild) {
1291 if (!SupportsHostWindowResize()) 1292 if (!SupportsHostWindowResize())
1292 return; 1293 return;
1293 1294
1294 // Create a window with a transient child. 1295 // Create a window with a transient child.
1295 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1296 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1296 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType( 1297 scoped_ptr<aura::Window> child(CreateTestWindowInShellWithDelegateAndType(
1297 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20))); 1298 NULL, ui::wm::WINDOW_TYPE_NORMAL, 0, gfx::Rect(20, 20, 150, 20)));
1298 window->AddTransientChild(child.get()); 1299 views::corewm::AddTransientChild(window.get(), child.get());
1299 if (window->parent() != child->parent()) 1300 if (window->parent() != child->parent())
1300 window->parent()->AddChild(child.get()); 1301 window->parent()->AddChild(child.get());
1301 EXPECT_EQ(window.get(), child->transient_parent()); 1302 EXPECT_EQ(window.get(), views::corewm::GetTransientParent(child.get()));
1302 1303
1303 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); 1304 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20);
1304 1305
1305 // A window should be docked at the right edge. 1306 // A window should be docked at the right edge.
1306 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 1307 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
1307 EXPECT_EQ(internal::kShellWindowId_DockedContainer, child->parent()->id()); 1308 EXPECT_EQ(internal::kShellWindowId_DockedContainer, child->parent()->id());
1308 1309
1309 // Drag the child - it should move freely and stay where it is dragged. 1310 // Drag the child - it should move freely and stay where it is dragged.
1310 ASSERT_NO_FATAL_FAILURE(DragStart(child.get())); 1311 ASSERT_NO_FATAL_FAILURE(DragStart(child.get()));
1311 DragMove(500, 20); 1312 DragMove(500, 20);
(...skipping 26 matching lines...) Expand all
1338 1339
1339 // Start dragging the window. 1340 // Start dragging the window.
1340 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 1341 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
1341 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60); 1342 gfx::Vector2d move_vector(40, test_panels() ? -60 : 60);
1342 DragMove(move_vector.x(), move_vector.y()); 1343 DragMove(move_vector.x(), move_vector.y());
1343 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 1344 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
1344 1345
1345 // While still dragging create a modal window and make it a transient child of 1346 // While still dragging create a modal window and make it a transient child of
1346 // the |window|. 1347 // the |window|.
1347 scoped_ptr<aura::Window> child(CreateModalWindow(gfx::Rect(20, 20, 150, 20))); 1348 scoped_ptr<aura::Window> child(CreateModalWindow(gfx::Rect(20, 20, 150, 20)));
1348 window->AddTransientChild(child.get()); 1349 views::corewm::AddTransientChild(window.get(), child.get());
1349 EXPECT_EQ(window.get(), child->transient_parent()); 1350 EXPECT_EQ(window.get(), views::corewm::GetTransientParent(child.get()));
1350 EXPECT_EQ(internal::kShellWindowId_SystemModalContainer, 1351 EXPECT_EQ(internal::kShellWindowId_SystemModalContainer,
1351 child->parent()->id()); 1352 child->parent()->id());
1352 1353
1353 // End the drag, the |window| should have moved (if it is a panel it will 1354 // End the drag, the |window| should have moved (if it is a panel it will
1354 // no longer be attached to the shelf since we dragged it above). 1355 // no longer be attached to the shelf since we dragged it above).
1355 DragEnd(); 1356 DragEnd();
1356 bounds.Offset(move_vector); 1357 bounds.Offset(move_vector);
1357 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); 1358 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString());
1358 1359
1359 // The original |window| should be in the default container (not docked or 1360 // The original |window| should be in the default container (not docked or
1360 // attached). 1361 // attached).
1361 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id()); 1362 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, window->parent()->id());
1362 // The transient |child| should still be in system modal container. 1363 // The transient |child| should still be in system modal container.
1363 EXPECT_EQ(internal::kShellWindowId_SystemModalContainer, 1364 EXPECT_EQ(internal::kShellWindowId_SystemModalContainer,
1364 child->parent()->id()); 1365 child->parent()->id());
1365 // The |child| should not have moved. 1366 // The |child| should not have moved.
1366 EXPECT_EQ(gfx::Point(20, 20).ToString(), 1367 EXPECT_EQ(gfx::Point(20, 20).ToString(),
1367 child->GetBoundsInScreen().origin().ToString()); 1368 child->GetBoundsInScreen().origin().ToString());
1368 // The |child| should still be a transient child of |window|. 1369 // The |child| should still be a transient child of |window|.
1369 EXPECT_EQ(window.get(), child->transient_parent()); 1370 EXPECT_EQ(window.get(), views::corewm::GetTransientParent(child.get()));
1370 } 1371 }
1371 1372
1372 // Tests that side snapping a window undocks it, closes the dock and then snaps. 1373 // Tests that side snapping a window undocks it, closes the dock and then snaps.
1373 TEST_P(DockedWindowResizerTest, SideSnapDocked) { 1374 TEST_P(DockedWindowResizerTest, SideSnapDocked) {
1374 if (!SupportsHostWindowResize() || test_panels()) 1375 if (!SupportsHostWindowResize() || test_panels())
1375 return; 1376 return;
1376 1377
1377 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 1378 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
1378 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1379 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1379 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); 1380 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 EXPECT_TRUE(window_state->IsSnapped()); 1426 EXPECT_TRUE(window_state->IsSnapped());
1426 } 1427 }
1427 1428
1428 // Tests run twice - on both panels and normal windows 1429 // Tests run twice - on both panels and normal windows
1429 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1430 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1430 DockedWindowResizerTest, 1431 DockedWindowResizerTest,
1431 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 1432 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
1432 ui::wm::WINDOW_TYPE_PANEL)); 1433 ui::wm::WINDOW_TYPE_PANEL));
1433 } // namespace internal 1434 } // namespace internal
1434 } // namespace ash 1435 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager.cc ('k') | ash/wm/drag_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698