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

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

Issue 2849603003: Use ScopedTaskEnvironment instead of MessageLoopForUI in ui tests. (Closed)
Patch Set: CR-add-newline-after-include Created 3 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
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 "base/run_loop.h"
11 #include "base/test/scoped_task_environment.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/animation/animation_container_observer.h" 13 #include "ui/gfx/animation/animation_container_observer.h"
13 #include "ui/gfx/animation/linear_animation.h" 14 #include "ui/gfx/animation/linear_animation.h"
14 #include "ui/gfx/animation/test_animation_delegate.h" 15 #include "ui/gfx/animation/test_animation_delegate.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 18
18 namespace { 19 namespace {
19 20
20 class FakeAnimationContainerObserver : public AnimationContainerObserver { 21 class FakeAnimationContainerObserver : public AnimationContainerObserver {
(...skipping 30 matching lines...) Expand all
51 52
52 void AnimateToState(double state) override {} 53 void AnimateToState(double state) override {}
53 54
54 private: 55 private:
55 DISALLOW_COPY_AND_ASSIGN(TestAnimation); 56 DISALLOW_COPY_AND_ASSIGN(TestAnimation);
56 }; 57 };
57 58
58 } // namespace 59 } // namespace
59 60
60 class AnimationContainerTest: public testing::Test { 61 class AnimationContainerTest: public testing::Test {
62 protected:
63 AnimationContainerTest()
64 : scoped_task_environment_(
65 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
66
61 private: 67 private:
62 base::MessageLoopForUI message_loop_; 68 base::test::ScopedTaskEnvironment scoped_task_environment_;
63 }; 69 };
64 70
65 // Makes sure the animation ups the ref count of the container and releases it 71 // Makes sure the animation ups the ref count of the container and releases it
66 // appropriately. 72 // appropriately.
67 TEST_F(AnimationContainerTest, Ownership) { 73 TEST_F(AnimationContainerTest, Ownership) {
68 TestAnimationDelegate delegate; 74 TestAnimationDelegate delegate;
69 scoped_refptr<AnimationContainer> container(new AnimationContainer()); 75 scoped_refptr<AnimationContainer> container(new AnimationContainer());
70 std::unique_ptr<Animation> animation(new TestAnimation(&delegate)); 76 std::unique_ptr<Animation> animation(new TestAnimation(&delegate));
71 animation->SetContainer(container.get()); 77 animation->SetContainer(container.get());
72 // Setting the container should up the ref count. 78 // Setting the container should up the ref count.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 136
131 EXPECT_TRUE(observer.empty()); 137 EXPECT_TRUE(observer.empty());
132 138
133 // And the container should no longer be running. 139 // And the container should no longer be running.
134 EXPECT_FALSE(container->is_running()); 140 EXPECT_FALSE(container->is_running());
135 141
136 container->set_observer(NULL); 142 container->set_observer(NULL);
137 } 143 }
138 144
139 } // namespace gfx 145 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698