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

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

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP Created 7 years, 1 month 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
« no previous file with comments | « ui/gfx/animation/multi_animation_unittest.cc ('k') | ui/gfx/animation/throb_animation.h » ('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) 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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/animation/test_animation_delegate.h" 10 #include "ui/gfx/animation/test_animation_delegate.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 13
14 // Class to provide access to SlideAnimation internals for testing. 14 // Class to provide access to SlideAnimation internals for testing.
15 class SlideAnimation::TestApi { 15 class SlideAnimation::TestApi {
16 public: 16 public:
17 explicit TestApi(SlideAnimation* animation) : animation_(animation) {} 17 explicit TestApi(SlideAnimation* animation) : animation_(animation) {}
18 18
19 void SetStartTime(base::TimeTicks ticks) { 19 void SetStartTime(gfx::FrameTime ticks) {
20 animation_->SetStartTime(ticks); 20 animation_->SetStartTime(ticks);
21 } 21 }
22 22
23 void Step(base::TimeTicks ticks) { 23 void Step(gfx::FrameTime ticks) {
24 animation_->Step(ticks); 24 animation_->Step(ticks);
25 } 25 }
26 26
27 private: 27 private:
28 SlideAnimation* animation_; 28 SlideAnimation* animation_;
29 29
30 DISALLOW_COPY_AND_ASSIGN(TestApi); 30 DISALLOW_COPY_AND_ASSIGN(TestApi);
31 }; 31 };
32 32
33 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
(...skipping 28 matching lines...) Expand all
62 // Duration can be set after construction. 62 // Duration can be set after construction.
63 animation.SetSlideDuration(100); 63 animation.SetSlideDuration(100);
64 EXPECT_EQ(100, animation.GetSlideDuration()); 64 EXPECT_EQ(100, animation.GetSlideDuration());
65 65
66 // Show toggles the appropriate state. 66 // Show toggles the appropriate state.
67 animation.Show(); 67 animation.Show();
68 EXPECT_TRUE(animation.IsShowing()); 68 EXPECT_TRUE(animation.IsShowing());
69 EXPECT_FALSE(animation.IsClosing()); 69 EXPECT_FALSE(animation.IsClosing());
70 70
71 // Simulate running the animation. 71 // Simulate running the animation.
72 test_api.SetStartTime(base::TimeTicks()); 72 test_api.SetStartTime(gfx::FrameTime());
73 test_api.Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(50)); 73 test_api.Step(gfx::FrameTime() + base::TimeDelta::FromMilliseconds(50));
74 EXPECT_EQ(0.5, animation.GetCurrentValue()); 74 EXPECT_EQ(0.5, animation.GetCurrentValue());
75 75
76 // We can start hiding mid-way through the animation. 76 // We can start hiding mid-way through the animation.
77 animation.Hide(); 77 animation.Hide();
78 EXPECT_FALSE(animation.IsShowing()); 78 EXPECT_FALSE(animation.IsShowing());
79 EXPECT_TRUE(animation.IsClosing()); 79 EXPECT_TRUE(animation.IsClosing());
80 80
81 // Reset stops the animation. 81 // Reset stops the animation.
82 animation.Reset(); 82 animation.Reset();
83 EXPECT_EQ(0.0, animation.GetCurrentValue()); 83 EXPECT_EQ(0.0, animation.GetCurrentValue());
(...skipping 12 matching lines...) Expand all
96 96
97 // Delete the animation. 97 // Delete the animation.
98 animation.reset(); 98 animation.reset();
99 99
100 // Make sure the delegate wasn't notified. 100 // Make sure the delegate wasn't notified.
101 EXPECT_FALSE(delegate.finished()); 101 EXPECT_FALSE(delegate.finished());
102 EXPECT_FALSE(delegate.canceled()); 102 EXPECT_FALSE(delegate.canceled());
103 } 103 }
104 104
105 } // namespace gfx 105 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/animation/multi_animation_unittest.cc ('k') | ui/gfx/animation/throb_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698