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

Side by Side Diff: ui/base/animation/animation_container_unittest.cc

Issue 14061025: ui: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « ui/aura/root_window_host_x11.cc ('k') | ui/base/animation/animation_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "testing/gmock/include/gmock/gmock.h" 6 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/base/animation/animation_container.h" 8 #include "ui/base/animation/animation_container.h"
9 #include "ui/base/animation/animation_container_observer.h" 9 #include "ui/base/animation/animation_container_observer.h"
10 #include "ui/base/animation/linear_animation.h" 10 #include "ui/base/animation/linear_animation.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 private: 39 private:
40 DISALLOW_COPY_AND_ASSIGN(TestAnimation); 40 DISALLOW_COPY_AND_ASSIGN(TestAnimation);
41 }; 41 };
42 42
43 } // namespace 43 } // namespace
44 44
45 class AnimationContainerTest: public testing::Test { 45 class AnimationContainerTest: public testing::Test {
46 private: 46 private:
47 MessageLoopForUI message_loop_; 47 base::MessageLoopForUI message_loop_;
48 }; 48 };
49 49
50 // Makes sure the animation ups the ref count of the container and releases it 50 // Makes sure the animation ups the ref count of the container and releases it
51 // appropriately. 51 // appropriately.
52 TEST_F(AnimationContainerTest, Ownership) { 52 TEST_F(AnimationContainerTest, Ownership) {
53 TestAnimationDelegate delegate; 53 TestAnimationDelegate delegate;
54 scoped_refptr<AnimationContainer> container(new AnimationContainer()); 54 scoped_refptr<AnimationContainer> container(new AnimationContainer());
55 scoped_ptr<Animation> animation(new TestAnimation(&delegate)); 55 scoped_ptr<Animation> animation(new TestAnimation(&delegate));
56 animation->SetContainer(container.get()); 56 animation->SetContainer(container.get());
57 // Setting the container should up the ref count. 57 // Setting the container should up the ref count.
(...skipping 16 matching lines...) Expand all
74 animation1.SetContainer(container.get()); 74 animation1.SetContainer(container.get());
75 animation2.SetContainer(container.get()); 75 animation2.SetContainer(container.get());
76 76
77 // Start both animations. 77 // Start both animations.
78 animation1.Start(); 78 animation1.Start();
79 EXPECT_TRUE(container->is_running()); 79 EXPECT_TRUE(container->is_running());
80 animation2.Start(); 80 animation2.Start();
81 EXPECT_TRUE(container->is_running()); 81 EXPECT_TRUE(container->is_running());
82 82
83 // Run the message loop the delegate quits the message loop when notified. 83 // Run the message loop the delegate quits the message loop when notified.
84 MessageLoop::current()->Run(); 84 base::MessageLoop::current()->Run();
85 85
86 // Both timers should have finished. 86 // Both timers should have finished.
87 EXPECT_TRUE(delegate1.finished()); 87 EXPECT_TRUE(delegate1.finished());
88 EXPECT_TRUE(delegate2.finished()); 88 EXPECT_TRUE(delegate2.finished());
89 89
90 // And the container should no longer be runnings. 90 // And the container should no longer be runnings.
91 EXPECT_FALSE(container->is_running()); 91 EXPECT_FALSE(container->is_running());
92 } 92 }
93 93
94 // Makes sure observer is notified appropriately. 94 // Makes sure observer is notified appropriately.
(...skipping 10 matching lines...) Expand all
105 // the animation completed the container went empty. 105 // the animation completed the container went empty.
106 EXPECT_CALL(observer, AnimationContainerProgressed(container.get())).Times( 106 EXPECT_CALL(observer, AnimationContainerProgressed(container.get())).Times(
107 AtLeast(1)); 107 AtLeast(1));
108 EXPECT_CALL(observer, AnimationContainerEmpty(container.get())).Times(1); 108 EXPECT_CALL(observer, AnimationContainerEmpty(container.get())).Times(1);
109 109
110 // Start the animation. 110 // Start the animation.
111 animation1.Start(); 111 animation1.Start();
112 EXPECT_TRUE(container->is_running()); 112 EXPECT_TRUE(container->is_running());
113 113
114 // Run the message loop. The delegate quits the message loop when notified. 114 // Run the message loop. The delegate quits the message loop when notified.
115 MessageLoop::current()->Run(); 115 base::MessageLoop::current()->Run();
116 116
117 // The timer should have finished. 117 // The timer should have finished.
118 EXPECT_TRUE(delegate1.finished()); 118 EXPECT_TRUE(delegate1.finished());
119 119
120 // And the container should no longer be running. 120 // And the container should no longer be running.
121 EXPECT_FALSE(container->is_running()); 121 EXPECT_FALSE(container->is_running());
122 122
123 container->set_observer(NULL); 123 container->set_observer(NULL);
124 } 124 }
125 125
126 } // namespace ui 126 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/root_window_host_x11.cc ('k') | ui/base/animation/animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698