1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/compositor/test/test_layer_animation_observer.h"
#include <cstddef>
namespace ui {
TestLayerAnimationObserver::TestLayerAnimationObserver()
: next_epoch_(0),
last_attached_sequence_(nullptr),
last_attached_sequence_epoch_(-1),
last_scheduled_sequence_(nullptr),
last_scheduled_sequence_epoch_(-1),
last_started_sequence_(nullptr),
last_started_sequence_epoch_(-1),
last_aborted_sequence_(nullptr),
last_aborted_sequence_epoch_(-1),
last_ended_sequence_(nullptr),
last_ended_sequence_epoch_(-1),
last_detached_sequence_(nullptr),
last_detached_sequence_epoch_(-1),
requires_notification_when_animator_destroyed_(false) {}
TestLayerAnimationObserver::~TestLayerAnimationObserver() {
}
void TestLayerAnimationObserver::ResetLayerAnimationObserverations() {
next_epoch_ = 0;
last_attached_sequence_ = nullptr;
last_attached_sequence_epoch_ = -1;
last_scheduled_sequence_ = nullptr;
last_scheduled_sequence_epoch_ = -1;
last_started_sequence_ = nullptr;
last_started_sequence_epoch_ = -1;
last_aborted_sequence_ = nullptr;
last_aborted_sequence_epoch_ = -1;
last_ended_sequence_ = nullptr;
last_ended_sequence_epoch_ = -1;
last_detached_sequence_ = nullptr;
last_detached_sequence_epoch_ = -1;
}
void TestLayerAnimationObserver::OnAttachedToSequence(
LayerAnimationSequence* sequence) {
last_attached_sequence_ = sequence;
last_attached_sequence_epoch_ = next_epoch_++;
}
void TestLayerAnimationObserver::OnLayerAnimationScheduled(
LayerAnimationSequence* sequence) {
last_scheduled_sequence_ = sequence;
last_scheduled_sequence_epoch_ = next_epoch_++;
}
void TestLayerAnimationObserver::OnLayerAnimationStarted(
LayerAnimationSequence* sequence) {
last_started_sequence_ = sequence;
last_started_sequence_epoch_ = next_epoch_++;
}
void TestLayerAnimationObserver::OnLayerAnimationAborted(
LayerAnimationSequence* sequence) {
last_aborted_sequence_ = sequence;
last_aborted_sequence_epoch_ = next_epoch_++;
}
void TestLayerAnimationObserver::OnLayerAnimationEnded(
LayerAnimationSequence* sequence) {
last_ended_sequence_ = sequence;
last_ended_sequence_epoch_ = next_epoch_++;
}
void TestLayerAnimationObserver::OnDetachedFromSequence(
LayerAnimationSequence* sequence) {
last_detached_sequence_ = sequence;
last_detached_sequence_epoch_ = next_epoch_++;
}
bool
TestLayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const {
return requires_notification_when_animator_destroyed_;
}
testing::AssertionResult TestLayerAnimationObserver::NoEventsObserved() {
if (!last_attached_sequence_ && !last_scheduled_sequence_ &&
!last_started_sequence_ && !last_aborted_sequence_ &&
!last_ended_sequence_ && !last_detached_sequence_) {
return testing::AssertionSuccess();
} else {
testing::AssertionResult assertion_failure = testing::AssertionFailure();
assertion_failure << "The following events have been observed:";
if (last_attached_sequence_) {
assertion_failure << "\n\tlast_attached_sequence_="
<< last_attached_sequence_;
}
if (last_scheduled_sequence_) {
assertion_failure << "\n\tlast_scheduled_sequence_="
<< last_scheduled_sequence_;
}
if (last_started_sequence_) {
assertion_failure << "\n\tlast_started_sequence_="
<< last_started_sequence_;
}
if (last_aborted_sequence_) {
assertion_failure << "\n\tlast_aborted_sequence_="
<< last_aborted_sequence_;
}
if (last_ended_sequence_) {
assertion_failure << "\n\tlast_ended_sequence_" << last_ended_sequence_;
}
if (last_detached_sequence_) {
assertion_failure << "\n\tlast_detached_sequence_="
<< last_detached_sequence_;
}
return assertion_failure;
}
}
testing::AssertionResult
TestLayerAnimationObserver::AttachedEpochIsBeforeScheduledEpoch() {
if (last_attached_sequence_epoch_ < last_scheduled_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The attached epoch=" << last_attached_sequence_epoch_
<< " is NOT before the scheduled epoch="
<< last_scheduled_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::ScheduledEpochIsBeforeStartedEpoch() {
if (last_scheduled_sequence_epoch_ < last_started_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The scheduled epoch=" << last_scheduled_sequence_epoch_
<< " is NOT before the started epoch="
<< last_started_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::StartedEpochIsBeforeEndedEpoch() {
if (last_started_sequence_epoch_ < last_ended_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The started epoch=" << last_started_sequence_epoch_
<< " is NOT before the ended epoch=" << last_ended_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::StartedEpochIsBeforeAbortedEpoch() {
if (last_started_sequence_epoch_ < last_aborted_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The started epoch=" << last_started_sequence_epoch_
<< " is NOT before the aborted epoch="
<< last_aborted_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::AbortedEpochIsBeforeStartedEpoch() {
if (last_aborted_sequence_epoch_ < last_started_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The aborted epoch=" << last_aborted_sequence_epoch_
<< " is NOT before the started epoch="
<< last_started_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::AbortedEpochIsBeforeDetachedEpoch() {
if (last_aborted_sequence_epoch_ < last_detached_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The aborted epoch=" << last_aborted_sequence_epoch_
<< " is NOT before the detached epoch="
<< last_detached_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::EndedEpochIsBeforeStartedEpoch() {
if (last_ended_sequence_epoch_ < last_started_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The ended epoch=" << last_ended_sequence_epoch_
<< " is NOT before the started epoch="
<< last_started_sequence_epoch_;
}
}
testing::AssertionResult
TestLayerAnimationObserver::EndedEpochIsBeforeDetachedEpoch() {
if (last_ended_sequence_epoch_ < last_detached_sequence_epoch_) {
return testing::AssertionSuccess();
} else {
return testing::AssertionFailure()
<< "The ended epoch=" << last_ended_sequence_epoch_
<< " is NOT before the detached epoch="
<< last_detached_sequence_epoch_;
}
}
} // namespace ui
|