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

Side by Side Diff: app/animation_unittest.cc

Issue 1575011: Adds AnimationContainer, which can be used to group a set of (Closed)
Patch Set: Incorporated review feedback Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/animation.h" 5 #include "app/animation.h"
6 #include "base/message_loop.h" 6 #include "app/test_animation_delegate.h"
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include "base/win_util.h" 8 #include "base/win_util.h"
9 #endif 9 #endif
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class AnimationTest: public testing::Test { 12 class AnimationTest: public testing::Test {
13 private: 13 private:
14 MessageLoopForUI message_loop_; 14 MessageLoopForUI message_loop_;
15 }; 15 };
16 16
(...skipping 23 matching lines...) Expand all
40 40
41 virtual void AnimateToState(double state) { 41 virtual void AnimateToState(double state) {
42 if (state >= 0.5) 42 if (state >= 0.5)
43 Stop(); 43 Stop();
44 } 44 }
45 }; 45 };
46 46
47 /////////////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////////////
48 // LinearCase 48 // LinearCase
49 49
50 class TestAnimationDelegate : public AnimationDelegate {
51 public:
52 TestAnimationDelegate() :
53 canceled_(false),
54 finished_(false) {
55 }
56
57 virtual void AnimationStarted(const Animation* animation) {
58 }
59
60 virtual void AnimationEnded(const Animation* animation) {
61 finished_ = true;
62 MessageLoop::current()->Quit();
63 }
64
65 virtual void AnimationCanceled(const Animation* animation) {
66 finished_ = true;
67 canceled_ = true;
68 MessageLoop::current()->Quit();
69 }
70
71 bool finished() {
72 return finished_;
73 }
74
75 bool canceled() {
76 return canceled_;
77 }
78
79 private:
80 bool canceled_;
81 bool finished_;
82 };
83
84 TEST_F(AnimationTest, RunCase) { 50 TEST_F(AnimationTest, RunCase) {
85 TestAnimationDelegate ad; 51 TestAnimationDelegate ad;
86 RunAnimation a1(150, &ad); 52 RunAnimation a1(150, &ad);
87 a1.SetDuration(2000); 53 a1.SetDuration(2000);
88 a1.Start(); 54 a1.Start();
89 MessageLoop::current()->Run(); 55 MessageLoop::current()->Run();
90 56
91 EXPECT_TRUE(ad.finished()); 57 EXPECT_TRUE(ad.finished());
92 EXPECT_FALSE(ad.canceled()); 58 EXPECT_FALSE(ad.canceled());
93 } 59 }
(...skipping 19 matching lines...) Expand all
113 EXPECT_EQ(!!result, Animation::ShouldRenderRichAnimation()); 79 EXPECT_EQ(!!result, Animation::ShouldRenderRichAnimation());
114 } else { 80 } else {
115 // On XP, the function should check the SM_REMOTESESSION value. 81 // On XP, the function should check the SM_REMOTESESSION value.
116 EXPECT_EQ(!::GetSystemMetrics(SM_REMOTESESSION), 82 EXPECT_EQ(!::GetSystemMetrics(SM_REMOTESESSION),
117 Animation::ShouldRenderRichAnimation()); 83 Animation::ShouldRenderRichAnimation());
118 } 84 }
119 #else 85 #else
120 EXPECT_TRUE(Animation::ShouldRenderRichAnimation()); 86 EXPECT_TRUE(Animation::ShouldRenderRichAnimation());
121 #endif 87 #endif
122 } 88 }
123
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698