OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { | 1618 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { |
1619 // We cannot short-circuit animations in this test. | 1619 // We cannot short-circuit animations in this test. |
1620 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 1620 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
1621 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 1621 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
1622 | 1622 |
1623 scoped_ptr<Window> w1( | 1623 scoped_ptr<Window> w1( |
1624 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); | 1624 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); |
1625 | 1625 |
1626 EXPECT_FALSE(!w1->layer()); | 1626 EXPECT_FALSE(!w1->layer()); |
1627 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); | 1627 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); |
1628 ui::LayerAnimator* animator = w1->layer()->GetAnimator(); | 1628 gfx::AnimationContainerElement* element = w1->layer()->GetAnimator(); |
1629 | 1629 |
1630 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 1630 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
1631 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); | 1631 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); |
1632 | 1632 |
1633 // Animate to a different position. | 1633 // Animate to a different position. |
1634 { | 1634 { |
1635 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); | 1635 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); |
1636 w1->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1636 w1->SetBounds(gfx::Rect(100, 100, 100, 100)); |
1637 } | 1637 } |
1638 | 1638 |
1639 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 1639 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
1640 EXPECT_EQ("100,100 100x100", w1->layer()->GetTargetBounds().ToString()); | 1640 EXPECT_EQ("100,100 100x100", w1->layer()->GetTargetBounds().ToString()); |
1641 | 1641 |
1642 // Animate back to the first position. The animation hasn't started yet, so | 1642 // Animate back to the first position. The animation hasn't started yet, so |
1643 // the current bounds are still (0, 0, 100, 100), but the target bounds are | 1643 // the current bounds are still (0, 0, 100, 100), but the target bounds are |
1644 // (100, 100, 100, 100). If we step the animator ahead, we should find that | 1644 // (100, 100, 100, 100). If we step the animator ahead, we should find that |
1645 // we're at (0, 0, 100, 100). That is, the second animation should be applied. | 1645 // we're at (0, 0, 100, 100). That is, the second animation should be applied. |
1646 { | 1646 { |
1647 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); | 1647 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); |
1648 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1648 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1649 } | 1649 } |
1650 | 1650 |
1651 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 1651 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
1652 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); | 1652 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); |
1653 | 1653 |
1654 // Confirm that the target bounds are reached. | 1654 // Confirm that the target bounds are reached. |
1655 base::TimeTicks start_time = | 1655 base::TimeTicks start_time = |
1656 w1->layer()->GetAnimator()->last_step_time(); | 1656 w1->layer()->GetAnimator()->last_step_time(); |
1657 | 1657 |
1658 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 1658 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
1659 | 1659 |
1660 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 1660 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
1661 } | 1661 } |
1662 | 1662 |
1663 | 1663 |
1664 typedef std::pair<const void*, intptr_t> PropertyChangeInfo; | 1664 typedef std::pair<const void*, intptr_t> PropertyChangeInfo; |
1665 | 1665 |
1666 class WindowObserverTest : public WindowTest, | 1666 class WindowObserverTest : public WindowTest, |
1667 public WindowObserver { | 1667 public WindowObserver { |
1668 public: | 1668 public: |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 window->SetBounds(gfx::Rect(100, 100, 100, 100)); | 2367 window->SetBounds(gfx::Rect(100, 100, 100, 100)); |
2368 } | 2368 } |
2369 | 2369 |
2370 // Bounds shouldn't immediately have changed. | 2370 // Bounds shouldn't immediately have changed. |
2371 EXPECT_EQ("0,0 100x100", window->bounds().ToString()); | 2371 EXPECT_EQ("0,0 100x100", window->bounds().ToString()); |
2372 EXPECT_FALSE(delegate.bounds_changed()); | 2372 EXPECT_FALSE(delegate.bounds_changed()); |
2373 | 2373 |
2374 // Animate to the end, which should notify of the change. | 2374 // Animate to the end, which should notify of the change. |
2375 base::TimeTicks start_time = | 2375 base::TimeTicks start_time = |
2376 window->layer()->GetAnimator()->last_step_time(); | 2376 window->layer()->GetAnimator()->last_step_time(); |
2377 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 2377 gfx::AnimationContainerElement* element = window->layer()->GetAnimator(); |
2378 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2378 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
2379 EXPECT_TRUE(delegate.bounds_changed()); | 2379 EXPECT_TRUE(delegate.bounds_changed()); |
2380 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2380 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
2381 } | 2381 } |
2382 | 2382 |
2383 // Verifies the delegate is notified when the actual bounds of the layer | 2383 // Verifies the delegate is notified when the actual bounds of the layer |
2384 // change even when the window is not the layer's delegate | 2384 // change even when the window is not the layer's delegate |
2385 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { | 2385 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { |
2386 BoundsChangeDelegate delegate; | 2386 BoundsChangeDelegate delegate; |
2387 | 2387 |
2388 // We cannot short-circuit animations in this test. | 2388 // We cannot short-circuit animations in this test. |
(...skipping 20 matching lines...) Expand all Loading... |
2409 | 2409 |
2410 // Layer delegate is NULL but we should still get bounds changed notification. | 2410 // Layer delegate is NULL but we should still get bounds changed notification. |
2411 EXPECT_EQ("100,100 110x100", window->GetTargetBounds().ToString()); | 2411 EXPECT_EQ("100,100 110x100", window->GetTargetBounds().ToString()); |
2412 EXPECT_TRUE(delegate.bounds_changed()); | 2412 EXPECT_TRUE(delegate.bounds_changed()); |
2413 | 2413 |
2414 delegate.clear_bounds_changed(); | 2414 delegate.clear_bounds_changed(); |
2415 | 2415 |
2416 // Animate to the end: will *not* notify of the change since we are hidden. | 2416 // Animate to the end: will *not* notify of the change since we are hidden. |
2417 base::TimeTicks start_time = | 2417 base::TimeTicks start_time = |
2418 window->layer()->GetAnimator()->last_step_time(); | 2418 window->layer()->GetAnimator()->last_step_time(); |
2419 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 2419 gfx::AnimationContainerElement* element = window->layer()->GetAnimator(); |
2420 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2420 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
2421 | 2421 |
2422 // No bounds changed notification at the end of animation since layer | 2422 // No bounds changed notification at the end of animation since layer |
2423 // delegate is NULL. | 2423 // delegate is NULL. |
2424 EXPECT_FALSE(delegate.bounds_changed()); | 2424 EXPECT_FALSE(delegate.bounds_changed()); |
2425 EXPECT_NE("0,0 100x100", window->layer()->bounds().ToString()); | 2425 EXPECT_NE("0,0 100x100", window->layer()->bounds().ToString()); |
2426 } | 2426 } |
2427 | 2427 |
2428 namespace { | 2428 namespace { |
2429 | 2429 |
2430 // Used by AddChildNotifications to track notification counts. | 2430 // Used by AddChildNotifications to track notification counts. |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3342 BuildRootLayerTreeDescription(*root.layer())) | 3342 BuildRootLayerTreeDescription(*root.layer())) |
3343 << "layer tree doesn't match at " << i; | 3343 << "layer tree doesn't match at " << i; |
3344 EXPECT_EQ(data[i].expected_description, | 3344 EXPECT_EQ(data[i].expected_description, |
3345 BuildRootWindowTreeDescription(root)) | 3345 BuildRootWindowTreeDescription(root)) |
3346 << "window tree doesn't match at " << i; | 3346 << "window tree doesn't match at " << i; |
3347 } | 3347 } |
3348 } | 3348 } |
3349 | 3349 |
3350 } // namespace test | 3350 } // namespace test |
3351 } // namespace aura | 3351 } // namespace aura |
OLD | NEW |