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

Unified Diff: ui/base/animation/animation_container_unittest.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/animation/animation_container_observer.h ('k') | ui/base/animation/animation_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/animation/animation_container_unittest.cc
diff --git a/ui/base/animation/animation_container_unittest.cc b/ui/base/animation/animation_container_unittest.cc
deleted file mode 100644
index c516cf325f8c9f60399e7eafd214dbfe5ce558d1..0000000000000000000000000000000000000000
--- a/ui/base/animation/animation_container_unittest.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/memory/scoped_ptr.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/animation/animation_container.h"
-#include "ui/base/animation/animation_container_observer.h"
-#include "ui/base/animation/linear_animation.h"
-#include "ui/base/animation/test_animation_delegate.h"
-
-using testing::AtLeast;
-
-namespace ui {
-
-namespace {
-
-class MockObserver : public AnimationContainerObserver {
- public:
- MockObserver() {}
-
- MOCK_METHOD1(AnimationContainerProgressed, void(AnimationContainer*));
- MOCK_METHOD1(AnimationContainerEmpty, void(AnimationContainer*));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockObserver);
-};
-
-class TestAnimation : public LinearAnimation {
- public:
- explicit TestAnimation(AnimationDelegate* delegate)
- : LinearAnimation(20, 20, delegate) {
- }
-
- virtual void AnimateToState(double state) OVERRIDE {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestAnimation);
-};
-
-} // namespace
-
-class AnimationContainerTest: public testing::Test {
- private:
- base::MessageLoopForUI message_loop_;
-};
-
-// Makes sure the animation ups the ref count of the container and releases it
-// appropriately.
-TEST_F(AnimationContainerTest, Ownership) {
- TestAnimationDelegate delegate;
- scoped_refptr<AnimationContainer> container(new AnimationContainer());
- scoped_ptr<Animation> animation(new TestAnimation(&delegate));
- animation->SetContainer(container.get());
- // Setting the container should up the ref count.
- EXPECT_FALSE(container->HasOneRef());
-
- animation.reset();
-
- // Releasing the animation should decrement the ref count.
- EXPECT_TRUE(container->HasOneRef());
-}
-
-// Makes sure multiple animations are managed correctly.
-TEST_F(AnimationContainerTest, Multi) {
- TestAnimationDelegate delegate1;
- TestAnimationDelegate delegate2;
-
- scoped_refptr<AnimationContainer> container(new AnimationContainer());
- TestAnimation animation1(&delegate1);
- TestAnimation animation2(&delegate2);
- animation1.SetContainer(container.get());
- animation2.SetContainer(container.get());
-
- // Start both animations.
- animation1.Start();
- EXPECT_TRUE(container->is_running());
- animation2.Start();
- EXPECT_TRUE(container->is_running());
-
- // Run the message loop the delegate quits the message loop when notified.
- base::MessageLoop::current()->Run();
-
- // Both timers should have finished.
- EXPECT_TRUE(delegate1.finished());
- EXPECT_TRUE(delegate2.finished());
-
- // And the container should no longer be runnings.
- EXPECT_FALSE(container->is_running());
-}
-
-// Makes sure observer is notified appropriately.
-TEST_F(AnimationContainerTest, Observer) {
- MockObserver observer;
- TestAnimationDelegate delegate1;
-
- scoped_refptr<AnimationContainer> container(new AnimationContainer());
- container->set_observer(&observer);
- TestAnimation animation1(&delegate1);
- animation1.SetContainer(container.get());
-
- // We expect to get these two calls: the animation progressed, and then when
- // the animation completed the container went empty.
- EXPECT_CALL(observer, AnimationContainerProgressed(container.get())).Times(
- AtLeast(1));
- EXPECT_CALL(observer, AnimationContainerEmpty(container.get())).Times(1);
-
- // Start the animation.
- animation1.Start();
- EXPECT_TRUE(container->is_running());
-
- // Run the message loop. The delegate quits the message loop when notified.
- base::MessageLoop::current()->Run();
-
- // The timer should have finished.
- EXPECT_TRUE(delegate1.finished());
-
- // And the container should no longer be running.
- EXPECT_FALSE(container->is_running());
-
- container->set_observer(NULL);
-}
-
-} // namespace ui
« no previous file with comments | « ui/base/animation/animation_container_observer.h ('k') | ui/base/animation/animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698