OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/web_contents/aura/overscroll_window_animation.h" | 5 #include "content/browser/web_contents/aura/overscroll_window_animation.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 10 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
11 #include "ui/compositor/scoped_layer_animation_settings.h" | 11 #include "ui/compositor/scoped_layer_animation_settings.h" |
12 #include "ui/compositor/test/layer_animator_test_controller.h" | 12 #include "ui/compositor/test/layer_animator_test_controller.h" |
13 #include "ui/gfx/frame_time.h" | |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 class OverscrollWindowAnimationTest | 16 class OverscrollWindowAnimationTest |
18 : public OverscrollWindowAnimation::Delegate, | 17 : public OverscrollWindowAnimation::Delegate, |
19 public aura::test::AuraTestBase { | 18 public aura::test::AuraTestBase { |
20 public: | 19 public: |
21 OverscrollWindowAnimationTest() | 20 OverscrollWindowAnimationTest() |
22 : create_window_(true), | 21 : create_window_(true), |
23 overscroll_started_(false), | 22 overscroll_started_(false), |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 EXPECT_TRUE(overscroll_completing()); | 196 EXPECT_TRUE(overscroll_completing()); |
198 EXPECT_TRUE(overscroll_completed()); | 197 EXPECT_TRUE(overscroll_completed()); |
199 EXPECT_FALSE(overscroll_aborted()); | 198 EXPECT_FALSE(overscroll_aborted()); |
200 | 199 |
201 // Complete the overscroll gesture. | 200 // Complete the overscroll gesture. |
202 ResetFlags(); | 201 ResetFlags(); |
203 owa()->OnOverscrollComplete(OVERSCROLL_EAST); | 202 owa()->OnOverscrollComplete(OVERSCROLL_EAST); |
204 | 203 |
205 base::TimeDelta duration = settings.GetTransitionDuration(); | 204 base::TimeDelta duration = settings.GetTransitionDuration(); |
206 test_controller.StartThreadedAnimationsIfNeeded(); | 205 test_controller.StartThreadedAnimationsIfNeeded(); |
207 base::TimeTicks start_time = gfx::FrameTime::Now(); | 206 base::TimeTicks start_time = base::TimeTicks::Now(); |
208 | 207 |
209 // Halfway through the animation, OverscrollCompleting should have been fired. | 208 // Halfway through the animation, OverscrollCompleting should have been fired. |
210 animator->Step(start_time + duration / 2); | 209 animator->Step(start_time + duration / 2); |
211 EXPECT_TRUE(owa()->is_active()); | 210 EXPECT_TRUE(owa()->is_active()); |
212 EXPECT_FALSE(overscroll_started()); | 211 EXPECT_FALSE(overscroll_started()); |
213 EXPECT_TRUE(overscroll_completing()); | 212 EXPECT_TRUE(overscroll_completing()); |
214 EXPECT_FALSE(overscroll_completed()); | 213 EXPECT_FALSE(overscroll_completed()); |
215 EXPECT_FALSE(overscroll_aborted()); | 214 EXPECT_FALSE(overscroll_aborted()); |
216 | 215 |
217 // The animation has finished, OverscrollCompleted should have been fired. | 216 // The animation has finished, OverscrollCompleted should have been fired. |
218 animator->Step(start_time + duration); | 217 animator->Step(start_time + duration); |
219 EXPECT_FALSE(owa()->is_active()); | 218 EXPECT_FALSE(owa()->is_active()); |
220 EXPECT_FALSE(overscroll_started()); | 219 EXPECT_FALSE(overscroll_started()); |
221 EXPECT_TRUE(overscroll_completing()); | 220 EXPECT_TRUE(overscroll_completing()); |
222 EXPECT_TRUE(overscroll_completed()); | 221 EXPECT_TRUE(overscroll_completed()); |
223 EXPECT_FALSE(overscroll_aborted()); | 222 EXPECT_FALSE(overscroll_aborted()); |
224 } | 223 } |
225 | 224 |
226 } // namespace content | 225 } // namespace content |
OLD | NEW |