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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 EXPECT_EQ(NULL, w->GetProperty("foo")); | 926 EXPECT_EQ(NULL, w->GetProperty("foo")); |
927 EXPECT_EQ(0, w->GetIntProperty("foo")); | 927 EXPECT_EQ(0, w->GetIntProperty("foo")); |
928 | 928 |
929 // Set NULL and make sure the property is gone. | 929 // Set NULL and make sure the property is gone. |
930 w->SetProperty(key, NULL); | 930 w->SetProperty(key, NULL); |
931 EXPECT_EQ(NULL, w->GetProperty(key)); | 931 EXPECT_EQ(NULL, w->GetProperty(key)); |
932 EXPECT_EQ(0, w->GetIntProperty(key)); | 932 EXPECT_EQ(0, w->GetIntProperty(key)); |
933 } | 933 } |
934 | 934 |
935 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { | 935 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { |
936 // We cannot short-circuit animations in this test. | |
937 ui::LayerAnimator::set_disable_animations_for_test(false); | |
938 | |
939 scoped_ptr<Window> w1( | 936 scoped_ptr<Window> w1( |
940 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), NULL)); | 937 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), NULL)); |
941 | 938 |
942 EXPECT_FALSE(!w1->layer()); | 939 EXPECT_FALSE(!w1->layer()); |
943 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); | 940 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); |
944 ui::AnimationContainerElement* element = w1->layer()->GetAnimator(); | 941 ui::AnimationContainerElement* element = w1->layer()->GetAnimator(); |
945 | 942 |
946 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 943 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
947 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); | 944 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); |
948 | 945 |
(...skipping 13 matching lines...) Expand all Loading... |
962 { | 959 { |
963 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); | 960 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); |
964 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 961 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
965 } | 962 } |
966 | 963 |
967 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 964 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
968 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); | 965 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); |
969 | 966 |
970 // Confirm that the target bounds are reached. | 967 // Confirm that the target bounds are reached. |
971 base::TimeTicks start_time = | 968 base::TimeTicks start_time = |
972 w1->layer()->GetAnimator()->last_step_time(); | 969 w1->layer()->GetAnimator()->get_last_step_time_for_test(); |
973 | 970 |
974 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 971 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
975 | 972 |
976 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); | 973 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); |
977 } | 974 } |
978 | 975 |
979 | 976 |
980 class WindowObserverTest : public WindowTest, | 977 class WindowObserverTest : public WindowTest, |
981 public WindowObserver { | 978 public WindowObserver { |
982 public: | 979 public: |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 | 1554 |
1558 w1.reset(); // Deletes w11 and w111. | 1555 w1.reset(); // Deletes w11 and w111. |
1559 w11 = NULL; | 1556 w11 = NULL; |
1560 w111 = NULL; | 1557 w111 = NULL; |
1561 EXPECT_EQ(2, observer.added_count()); | 1558 EXPECT_EQ(2, observer.added_count()); |
1562 EXPECT_EQ(2, observer.removed_count()); | 1559 EXPECT_EQ(2, observer.removed_count()); |
1563 } | 1560 } |
1564 | 1561 |
1565 } // namespace test | 1562 } // namespace test |
1566 } // namespace aura | 1563 } // namespace aura |
OLD | NEW |