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

Side by Side Diff: ash/rotator/screen_rotation_animation_unittest.cc

Issue 1315573003: Snap screen rotation animation layers to final position if the animation is aborted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added // AshTestBase: to override list. Created 5 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 unified diff | Download patch
« no previous file with comments | « ash/rotator/screen_rotation_animation.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/rotator/screen_rotation_animation.h"
6 #include "ash/test/ash_test_base.h"
7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/aura/window.h"
12 #include "ui/compositor/layer.h"
13 #include "ui/compositor/layer_animation_sequence.h"
14 #include "ui/compositor/layer_animator.h"
15 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
16 #include "ui/gfx/animation/tween.h"
17 #include "ui/gfx/transform.h"
18
19 namespace ash {
20 namespace test {
21
22 class ScreenRotationAnimationTest : public AshTestBase {
23 public:
24 ScreenRotationAnimationTest() {}
25 ~ScreenRotationAnimationTest() override {}
26
27 // AshTestBase:
28 void SetUp() override;
29
30 private:
31 scoped_ptr<ui::ScopedAnimationDurationScaleMode> non_zero_duration_mode_;
32
33 DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimationTest);
34 };
35
36 void ScreenRotationAnimationTest::SetUp() {
37 AshTestBase::SetUp();
38 non_zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
39 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION));
40 }
41
42 TEST_F(ScreenRotationAnimationTest, LayerTransformGetsSetToTargetWhenAborted) {
43 scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(9));
44 ui::Layer* layer = window->layer();
45
46 scoped_ptr<ScreenRotationAnimation> screen_rotation(
47 new ScreenRotationAnimation(
48 layer, 45 /* start_degrees */, 0 /* end_degrees */,
49 0.5f /* initial_opacity */, 1.0f /* target_opacity */,
50 gfx::Point(10, 10) /* pivot */,
51 base::TimeDelta::FromSeconds(10) /* duration */, gfx::Tween::LINEAR));
52
53 ui::LayerAnimator* animator = layer->GetAnimator();
54 animator->set_preemption_strategy(
55 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
56 scoped_ptr<ui::LayerAnimationSequence> animation_sequence(
57 new ui::LayerAnimationSequence(screen_rotation.release()));
58 animator->StartAnimation(animation_sequence.release());
59
60 const gfx::Transform identity_transform;
61
62 ASSERT_EQ(identity_transform, layer->GetTargetTransform());
63 ASSERT_NE(identity_transform, layer->transform());
64
65 layer->GetAnimator()->AbortAllAnimations();
66
67 EXPECT_EQ(identity_transform, layer->transform());
68 }
69
70 } // namespace test
71 } // namespace ash
OLDNEW
« no previous file with comments | « ash/rotator/screen_rotation_animation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698