| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/slide_animation.h" | 5 #include "ui/gfx/animation/slide_animation.h" | 
| 6 | 6 | 
| 7 #include <memory> | 7 #include <memory> | 
| 8 | 8 | 
| 9 #include "base/macros.h" | 9 #include "base/macros.h" | 
|  | 10 #include "base/test/scoped_task_environment.h" | 
| 10 #include "base/time/time.h" | 11 #include "base/time/time.h" | 
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" | 
| 12 #include "ui/gfx/animation/test_animation_delegate.h" | 13 #include "ui/gfx/animation/test_animation_delegate.h" | 
| 13 | 14 | 
| 14 namespace gfx { | 15 namespace gfx { | 
| 15 | 16 | 
| 16 // Class to provide access to SlideAnimation internals for testing. | 17 // Class to provide access to SlideAnimation internals for testing. | 
| 17 class SlideAnimation::TestApi { | 18 class SlideAnimation::TestApi { | 
| 18  public: | 19  public: | 
| 19   explicit TestApi(SlideAnimation* animation) : animation_(animation) {} | 20   explicit TestApi(SlideAnimation* animation) : animation_(animation) {} | 
| 20 | 21 | 
| 21   void SetStartTime(base::TimeTicks ticks) { | 22   void SetStartTime(base::TimeTicks ticks) { | 
| 22     animation_->SetStartTime(ticks); | 23     animation_->SetStartTime(ticks); | 
| 23   } | 24   } | 
| 24 | 25 | 
| 25   void Step(base::TimeTicks ticks) { | 26   void Step(base::TimeTicks ticks) { | 
| 26     animation_->Step(ticks); | 27     animation_->Step(ticks); | 
| 27   } | 28   } | 
| 28 | 29 | 
| 29  private: | 30  private: | 
| 30   SlideAnimation* animation_; | 31   SlideAnimation* animation_; | 
| 31 | 32 | 
| 32   DISALLOW_COPY_AND_ASSIGN(TestApi); | 33   DISALLOW_COPY_AND_ASSIGN(TestApi); | 
| 33 }; | 34 }; | 
| 34 | 35 | 
| 35 //////////////////////////////////////////////////////////////////////////////// | 36 //////////////////////////////////////////////////////////////////////////////// | 
| 36 // SlideAnimationTest | 37 // SlideAnimationTest | 
| 37 class SlideAnimationTest: public testing::Test { | 38 class SlideAnimationTest: public testing::Test { | 
|  | 39  protected: | 
|  | 40   SlideAnimationTest() | 
|  | 41       : scoped_task_environment_( | 
|  | 42             base::test::ScopedTaskEnvironment::MainThreadType::UI) {} | 
|  | 43 | 
| 38  private: | 44  private: | 
| 39   base::MessageLoopForUI message_loop_; | 45   base::test::ScopedTaskEnvironment scoped_task_environment_; | 
| 40 }; | 46 }; | 
| 41 | 47 | 
| 42 // Tests animation construction. | 48 // Tests animation construction. | 
| 43 TEST_F(SlideAnimationTest, InitialState) { | 49 TEST_F(SlideAnimationTest, InitialState) { | 
| 44   SlideAnimation animation(nullptr); | 50   SlideAnimation animation(nullptr); | 
| 45   // By default, slide animations are 60 Hz, so the timer interval should be | 51   // By default, slide animations are 60 Hz, so the timer interval should be | 
| 46   // 1/60th of a second. | 52   // 1/60th of a second. | 
| 47   EXPECT_EQ(1000 / 60, animation.timer_interval().InMilliseconds()); | 53   EXPECT_EQ(1000 / 60, animation.timer_interval().InMilliseconds()); | 
| 48   // Duration defaults to 120 ms. | 54   // Duration defaults to 120 ms. | 
| 49   EXPECT_EQ(120, animation.GetSlideDuration()); | 55   EXPECT_EQ(120, animation.GetSlideDuration()); | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 98 | 104 | 
| 99   // Delete the animation. | 105   // Delete the animation. | 
| 100   animation.reset(); | 106   animation.reset(); | 
| 101 | 107 | 
| 102   // Make sure the delegate wasn't notified. | 108   // Make sure the delegate wasn't notified. | 
| 103   EXPECT_FALSE(delegate.finished()); | 109   EXPECT_FALSE(delegate.finished()); | 
| 104   EXPECT_FALSE(delegate.canceled()); | 110   EXPECT_FALSE(delegate.canceled()); | 
| 105 } | 111 } | 
| 106 | 112 | 
| 107 }  // namespace gfx | 113 }  // namespace gfx | 
| OLD | NEW | 
|---|