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

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

Issue 2086093003: Remove calls to deprecated MessageLoop methods in ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 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 "ui/gfx/animation/animation_container.h" 5 #include "ui/gfx/animation/animation_container.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/gfx/animation/animation_container_observer.h" 12 #include "ui/gfx/animation/animation_container_observer.h"
12 #include "ui/gfx/animation/linear_animation.h" 13 #include "ui/gfx/animation/linear_animation.h"
13 #include "ui/gfx/animation/test_animation_delegate.h" 14 #include "ui/gfx/animation/test_animation_delegate.h"
14 15
15 namespace gfx { 16 namespace gfx {
16 17
17 namespace { 18 namespace {
18 19
19 class FakeAnimationContainerObserver : public AnimationContainerObserver { 20 class FakeAnimationContainerObserver : public AnimationContainerObserver {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 animation1.SetContainer(container.get()); 89 animation1.SetContainer(container.get());
89 animation2.SetContainer(container.get()); 90 animation2.SetContainer(container.get());
90 91
91 // Start both animations. 92 // Start both animations.
92 animation1.Start(); 93 animation1.Start();
93 EXPECT_TRUE(container->is_running()); 94 EXPECT_TRUE(container->is_running());
94 animation2.Start(); 95 animation2.Start();
95 EXPECT_TRUE(container->is_running()); 96 EXPECT_TRUE(container->is_running());
96 97
97 // Run the message loop the delegate quits the message loop when notified. 98 // Run the message loop the delegate quits the message loop when notified.
98 base::MessageLoop::current()->Run(); 99 base::RunLoop().Run();
99 100
100 // Both timers should have finished. 101 // Both timers should have finished.
101 EXPECT_TRUE(delegate1.finished()); 102 EXPECT_TRUE(delegate1.finished());
102 EXPECT_TRUE(delegate2.finished()); 103 EXPECT_TRUE(delegate2.finished());
103 104
104 // And the container should no longer be runnings. 105 // And the container should no longer be runnings.
105 EXPECT_FALSE(container->is_running()); 106 EXPECT_FALSE(container->is_running());
106 } 107 }
107 108
108 // Makes sure observer is notified appropriately. 109 // Makes sure observer is notified appropriately.
109 TEST_F(AnimationContainerTest, Observer) { 110 TEST_F(AnimationContainerTest, Observer) {
110 FakeAnimationContainerObserver observer; 111 FakeAnimationContainerObserver observer;
111 TestAnimationDelegate delegate1; 112 TestAnimationDelegate delegate1;
112 113
113 scoped_refptr<AnimationContainer> container(new AnimationContainer()); 114 scoped_refptr<AnimationContainer> container(new AnimationContainer());
114 container->set_observer(&observer); 115 container->set_observer(&observer);
115 TestAnimation animation1(&delegate1); 116 TestAnimation animation1(&delegate1);
116 animation1.SetContainer(container.get()); 117 animation1.SetContainer(container.get());
117 118
118 // Start the animation. 119 // Start the animation.
119 animation1.Start(); 120 animation1.Start();
120 EXPECT_TRUE(container->is_running()); 121 EXPECT_TRUE(container->is_running());
121 122
122 // Run the message loop. The delegate quits the message loop when notified. 123 // Run the message loop. The delegate quits the message loop when notified.
123 base::MessageLoop::current()->Run(); 124 base::RunLoop().Run();
124 125
125 EXPECT_EQ(1, observer.progressed_count()); 126 EXPECT_EQ(1, observer.progressed_count());
126 127
127 // The timer should have finished. 128 // The timer should have finished.
128 EXPECT_TRUE(delegate1.finished()); 129 EXPECT_TRUE(delegate1.finished());
129 130
130 EXPECT_TRUE(observer.empty()); 131 EXPECT_TRUE(observer.empty());
131 132
132 // And the container should no longer be running. 133 // And the container should no longer be running.
133 EXPECT_FALSE(container->is_running()); 134 EXPECT_FALSE(container->is_running());
134 135
135 container->set_observer(NULL); 136 container->set_observer(NULL);
136 } 137 }
137 138
138 } // namespace gfx 139 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/events/platform/platform_event_source_unittest.cc ('k') | ui/gfx/animation/animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698