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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 9222018: reland -- Disable animations during aura tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 8 years, 10 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
OLDNEW
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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 EXPECT_EQ(NULL, w->GetProperty("foo")); 879 EXPECT_EQ(NULL, w->GetProperty("foo"));
880 EXPECT_EQ(0, w->GetIntProperty("foo")); 880 EXPECT_EQ(0, w->GetIntProperty("foo"));
881 881
882 // Set NULL and make sure the property is gone. 882 // Set NULL and make sure the property is gone.
883 w->SetProperty(key, NULL); 883 w->SetProperty(key, NULL);
884 EXPECT_EQ(NULL, w->GetProperty(key)); 884 EXPECT_EQ(NULL, w->GetProperty(key));
885 EXPECT_EQ(0, w->GetIntProperty(key)); 885 EXPECT_EQ(0, w->GetIntProperty(key));
886 } 886 }
887 887
888 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) { 888 TEST_F(WindowTest, SetBoundsInternalShouldCheckTargetBounds) {
889 // We cannot short-circuit animations in this test.
890 ui::LayerAnimator::set_disable_animations_for_test(false);
891
889 scoped_ptr<Window> w1( 892 scoped_ptr<Window> w1(
890 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), NULL)); 893 CreateTestWindowWithBounds(gfx::Rect(0, 0, 100, 100), NULL));
891 894
892 EXPECT_FALSE(!w1->layer()); 895 EXPECT_FALSE(!w1->layer());
893 w1->layer()->GetAnimator()->set_disable_timer_for_test(true); 896 w1->layer()->GetAnimator()->set_disable_timer_for_test(true);
894 ui::AnimationContainerElement* element = w1->layer()->GetAnimator(); 897 ui::AnimationContainerElement* element = w1->layer()->GetAnimator();
895 898
896 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); 899 EXPECT_EQ("0,0 100x100", w1->bounds().ToString());
897 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); 900 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString());
898 901
(...skipping 13 matching lines...) Expand all
912 { 915 {
913 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator()); 916 ui::ScopedLayerAnimationSettings settings(w1->layer()->GetAnimator());
914 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); 917 w1->SetBounds(gfx::Rect(0, 0, 100, 100));
915 } 918 }
916 919
917 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); 920 EXPECT_EQ("0,0 100x100", w1->bounds().ToString());
918 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString()); 921 EXPECT_EQ("0,0 100x100", w1->layer()->GetTargetBounds().ToString());
919 922
920 // Confirm that the target bounds are reached. 923 // Confirm that the target bounds are reached.
921 base::TimeTicks start_time = 924 base::TimeTicks start_time =
922 w1->layer()->GetAnimator()->get_last_step_time_for_test(); 925 w1->layer()->GetAnimator()->last_step_time();
923 926
924 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 927 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
925 928
926 EXPECT_EQ("0,0 100x100", w1->bounds().ToString()); 929 EXPECT_EQ("0,0 100x100", w1->bounds().ToString());
927 } 930 }
928 931
929 932
930 class WindowObserverTest : public WindowTest, 933 class WindowObserverTest : public WindowTest,
931 public WindowObserver { 934 public WindowObserver {
932 public: 935 public:
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 LayerGrabber grabber(window.get()); 1152 LayerGrabber grabber(window.get());
1150 window.reset(); 1153 window.reset();
1151 EXPECT_FALSE(grabber.layer() == NULL); 1154 EXPECT_FALSE(grabber.layer() == NULL);
1152 EXPECT_FALSE(grabber.layer()->visible()); 1155 EXPECT_FALSE(grabber.layer()->visible());
1153 // This should be set by the window's destructor. 1156 // This should be set by the window's destructor.
1154 EXPECT_TRUE(grabber.layer()->delegate() == NULL); 1157 EXPECT_TRUE(grabber.layer()->delegate() == NULL);
1155 } 1158 }
1156 1159
1157 } // namespace test 1160 } // namespace test
1158 } // namespace aura 1161 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698