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: cc/test/animation_timelines_test_common.h

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ElementAnimations. MutatorHostClient. cc/public. Animation timelines test common. Created 5 years, 5 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
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 #ifndef CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_
6 #define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_
7
8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_host.h"
11 #include "cc/public/mutator_host_client.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gfx/geometry/scroll_offset.h"
14
15 namespace cc {
16
17 struct TestLayer {
18 TestLayer();
19
20 void ClearMutatedProperties();
21
22 int transform_x_;
23 int transform_y_;
24
25 float opacity_;
26 float brightness_;
27 gfx::ScrollOffset scroll_offset_;
28
29 bool mutated_properties_[Animation::LAST_TARGET_PROPERTY + 1];
30 };
31
32 class TestHostClient : public MutatorHostClient {
33 public:
34 explicit TestHostClient(ThreadInstance thread_instance);
35 ~TestHostClient();
36
37 void ClearMutatedProperties();
38
39 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override;
40
41 void SetMutatorsNeedCommit() override;
42
43 void SetLayerFilterMutated(int layer_id,
44 LayerTreeType tree_type,
45 const FilterOperations& filters) override;
46
47 void SetLayerOpacityMutated(int layer_id,
48 LayerTreeType tree_type,
49 float opacity) override;
50
51 void SetLayerTransformMutated(int layer_id,
52 LayerTreeType tree_type,
53 const gfx::Transform& transform) override;
54
55 void SetLayerScrollOffsetMutated(
56 int layer_id,
57 LayerTreeType tree_type,
58 const gfx::ScrollOffset& scroll_offset) override;
59
60 bool mutators_need_commit() const { return mutators_need_commit_; }
61 void set_mutators_need_commit(bool need) { mutators_need_commit_ = need; }
62
63 void RegisterLayer(int layer_id, LayerTreeType tree_type);
64 void UnregisterLayer(int layer_id, LayerTreeType tree_type);
65
66 AnimationHost* host() {
67 DCHECK(host_);
68 return host_.get();
69 }
70
71 bool IsPropertyMutated(int layer_id,
72 LayerTreeType tree_type,
73 Animation::TargetProperty property) const;
74
75 void ExpectFilterPropertyMutated(int layer_id,
76 LayerTreeType tree_type,
77 float brightness) const;
78 void ExpectOpacityPropertyMutated(int layer_id,
79 LayerTreeType tree_type,
80 float opacity) const;
81 void ExpectTransformPropertyMutated(int layer_id,
82 LayerTreeType tree_type,
83 int transform_x,
84 int transform_y) const;
85 void ExpectScrollOffsetPropertyMutated(
86 int layer_id,
87 LayerTreeType tree_type,
88 const gfx::ScrollOffset& scroll_offset) const;
89
90 TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const;
91
92 private:
93 scoped_ptr<AnimationHost> host_;
94
95 typedef base::hash_map<int, TestLayer*> LayerIdToTestLayer;
96 LayerIdToTestLayer layers_in_active_tree_;
97 LayerIdToTestLayer layers_in_pending_tree_;
98
99 bool mutators_need_commit_;
100 };
101
102 class TestAnimationDelegate : public AnimationDelegate {
103 public:
104 TestAnimationDelegate();
105
106 void NotifyAnimationStarted(base::TimeTicks monotonic_time,
107 Animation::TargetProperty target_property,
108 int group) override;
109 void NotifyAnimationFinished(base::TimeTicks monotonic_time,
110 Animation::TargetProperty target_property,
111 int group) override;
112 bool started_;
113 bool finished_;
114 };
115
116 class AnimationTimelinesTest : public testing::Test {
117 public:
118 AnimationTimelinesTest();
119 ~AnimationTimelinesTest() override;
120
121 protected:
122 void SetUp() override;
123
124 void GetImplTimelineAndPlayerByID();
125
126 void ReleaseRefPtrs();
127
128 void AnimateLayersTransferEvents(base::TimeTicks time,
129 unsigned expect_events);
130
131 AnimationPlayer* GetPlayerForLayerId(int layer_id);
132 AnimationPlayer* GetImplPlayerForLayerId(int layer_id);
133
134 TestHostClient client_;
135 TestHostClient client_impl_;
136
137 AnimationHost* host_;
138 AnimationHost* host_impl_;
139
140 const int timeline_id_;
141 const int player_id_;
142 const int layer_id_;
143
144 scoped_refptr<AnimationTimeline> timeline_;
145 scoped_refptr<AnimationPlayer> player_;
146
147 scoped_refptr<AnimationTimeline> timeline_impl_;
148 scoped_refptr<AnimationPlayer> player_impl_;
149 };
150
151 } // namespace cc
152
153 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698