| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { | 1773 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { |
| 1774 // We cannot short-circuit animations in this test. | 1774 // We cannot short-circuit animations in this test. |
| 1775 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 1775 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
| 1776 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 1776 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
| 1777 | 1777 |
| 1778 scoped_ptr<Window> w1( | 1778 scoped_ptr<Window> w1( |
| 1779 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); | 1779 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), root_window())); |
| 1780 | 1780 |
| 1781 EXPECT_FALSE(!w1->layer()); | 1781 EXPECT_FALSE(!w1->layer()); |
| 1782 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); | 1782 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); |
| 1783 ui::AnimationContainerElement* element = w1->layer()->GetAnimator(); | 1783 gfx::AnimationContainerElement* element = w1->layer()->GetAnimator(); |
| 1784 | 1784 |
| 1785 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 1785 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
| 1786 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); | 1786 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); |
| 1787 | 1787 |
| 1788 // Animate to a different position. | 1788 // Animate to a different position. |
| 1789 { | 1789 { |
| 1790 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); | 1790 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); |
| 1791 w1->SetBounds(gfx::Rect(100, 100, 100, 100)); | 1791 w1->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 1792 } | 1792 } |
| 1793 | 1793 |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 window->SetBounds(gfx::Rect(100, 100, 100, 100)); | 2733 window->SetBounds(gfx::Rect(100, 100, 100, 100)); |
| 2734 } | 2734 } |
| 2735 | 2735 |
| 2736 // Bounds shouldn't immediately have changed. | 2736 // Bounds shouldn't immediately have changed. |
| 2737 EXPECT_EQ("0,0 100x100", window->bounds().ToString()); | 2737 EXPECT_EQ("0,0 100x100", window->bounds().ToString()); |
| 2738 EXPECT_FALSE(delegate.bounds_changed()); | 2738 EXPECT_FALSE(delegate.bounds_changed()); |
| 2739 | 2739 |
| 2740 // Animate to the end, which should notify of the change. | 2740 // Animate to the end, which should notify of the change. |
| 2741 base::TimeTicks start_time = | 2741 base::TimeTicks start_time = |
| 2742 window->layer()->GetAnimator()->last_step_time(); | 2742 window->layer()->GetAnimator()->last_step_time(); |
| 2743 ui::AnimationContainerElement* element = window->layer()->GetAnimator(); | 2743 gfx::AnimationContainerElement* element = window->layer()->GetAnimator(); |
| 2744 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2744 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
| 2745 EXPECT_TRUE(delegate.bounds_changed()); | 2745 EXPECT_TRUE(delegate.bounds_changed()); |
| 2746 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2746 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
| 2747 } | 2747 } |
| 2748 | 2748 |
| 2749 // Verifies the delegate is notified when the actual bounds of the layer | 2749 // Verifies the delegate is notified when the actual bounds of the layer |
| 2750 // change even when the window is not the layer's delegate | 2750 // change even when the window is not the layer's delegate |
| 2751 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { | 2751 TEST_F(WindowTest, DelegateNotifiedAsBoundsChangeInHiddenLayer) { |
| 2752 BoundsChangeDelegate delegate; | 2752 BoundsChangeDelegate delegate; |
| 2753 | 2753 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2775 | 2775 |
| 2776 // Layer delegate is NULL but we should still get bounds changed notification. | 2776 // Layer delegate is NULL but we should still get bounds changed notification. |
| 2777 EXPECT_EQ("100,100 110x100", window->GetTargetBounds().ToString()); | 2777 EXPECT_EQ("100,100 110x100", window->GetTargetBounds().ToString()); |
| 2778 EXPECT_TRUE(delegate.bounds_changed()); | 2778 EXPECT_TRUE(delegate.bounds_changed()); |
| 2779 | 2779 |
| 2780 delegate.clear_bounds_changed(); | 2780 delegate.clear_bounds_changed(); |
| 2781 | 2781 |
| 2782 // Animate to the end: will *not* notify of the change since we are hidden. | 2782 // Animate to the end: will *not* notify of the change since we are hidden. |
| 2783 base::TimeTicks start_time = | 2783 base::TimeTicks start_time = |
| 2784 window->layer()->GetAnimator()->last_step_time(); | 2784 window->layer()->GetAnimator()->last_step_time(); |
| 2785 ui::AnimationContainerElement* element = window->layer()->GetAnimator(); | 2785 gfx::AnimationContainerElement* element = window->layer()->GetAnimator(); |
| 2786 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2786 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
| 2787 | 2787 |
| 2788 // No bounds changed notification at the end of animation since layer | 2788 // No bounds changed notification at the end of animation since layer |
| 2789 // delegate is NULL. | 2789 // delegate is NULL. |
| 2790 EXPECT_FALSE(delegate.bounds_changed()); | 2790 EXPECT_FALSE(delegate.bounds_changed()); |
| 2791 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2791 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
| 2792 } | 2792 } |
| 2793 | 2793 |
| 2794 namespace { | 2794 namespace { |
| 2795 | 2795 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3045 o.ValidateState(index++, params); | 3045 o.ValidateState(index++, params); |
| 3046 | 3046 |
| 3047 w1.reset(); | 3047 w1.reset(); |
| 3048 w2.reset(); | 3048 w2.reset(); |
| 3049 } | 3049 } |
| 3050 | 3050 |
| 3051 } | 3051 } |
| 3052 | 3052 |
| 3053 } // namespace test | 3053 } // namespace test |
| 3054 } // namespace aura | 3054 } // namespace aura |
| OLD | NEW |