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/snap_sizer.h" | 5 #include "ash/wm/workspace/snap_sizer.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 sizer1.SelectDefaultSizeAndDisableResize(); | 316 sizer1.SelectDefaultSizeAndDisableResize(); |
317 sizer1.SnapWindowToTargetBounds(); | 317 sizer1.SnapWindowToTargetBounds(); |
318 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 318 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
319 | 319 |
320 // Snapping to a SnapSizer's initial bounds snaps to 50% too. | 320 // Snapping to a SnapSizer's initial bounds snaps to 50% too. |
321 SnapSizer sizer2(window_state, gfx::Point(), SnapSizer::LEFT_EDGE, | 321 SnapSizer sizer2(window_state, gfx::Point(), SnapSizer::LEFT_EDGE, |
322 SnapSizer::OTHER_INPUT); | 322 SnapSizer::OTHER_INPUT); |
323 sizer2.SnapWindowToTargetBounds(); | 323 sizer2.SnapWindowToTargetBounds(); |
324 expected.set_x(kWorkAreaBounds.x()); | 324 expected.set_x(kWorkAreaBounds.x()); |
325 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); | 325 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
| 326 EXPECT_EQ(wm::SHOW_TYPE_LEFT_SNAPPED, window_state->window_show_type()); |
| 327 |
| 328 // Setting bounds should keep the window snapped. |
| 329 expected = kWorkAreaBounds; |
| 330 expected.set_width(500); |
| 331 window->SetBounds(gfx::Rect(10, 10, 500, 300)); |
| 332 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); |
326 } | 333 } |
327 | 334 |
328 // Test that snapping left/right preserves the restore bounds. | 335 // Test that snapping left/right preserves the restore bounds. |
329 TEST_F(SnapSizerTest, RestoreBounds) { | 336 TEST_F(SnapSizerTest, RestoreBounds) { |
330 scoped_ptr<aura::Window> window( | 337 scoped_ptr<aura::Window> window( |
331 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); | 338 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); |
332 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 339 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
333 | 340 |
334 EXPECT_TRUE(window_state->IsNormalShowState()); | 341 EXPECT_TRUE(window_state->IsNormalShowState()); |
335 | 342 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 window->bounds().width(), // No expectation for the width. | 391 window->bounds().width(), // No expectation for the width. |
385 kWorkAreaBounds.height()); | 392 kWorkAreaBounds.height()); |
386 EXPECT_EQ(expected_snapped_bounds.ToString(), | 393 EXPECT_EQ(expected_snapped_bounds.ToString(), |
387 window->GetBoundsInScreen().ToString()); | 394 window->GetBoundsInScreen().ToString()); |
388 | 395 |
389 // The window should still be auto managed despite being right maximized. | 396 // The window should still be auto managed despite being right maximized. |
390 EXPECT_TRUE(window_state->window_position_managed()); | 397 EXPECT_TRUE(window_state->window_position_managed()); |
391 } | 398 } |
392 | 399 |
393 } // namespace ash | 400 } // namespace ash |
OLD | NEW |