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 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ | 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ |
6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ | 6 #define UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ |
7 | 7 |
8 #include "ui/views/animation/ink_drop_animation.h" | 8 #include "ui/views/animation/ink_drop_animation.h" |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 | 175 |
176 // Verify animations are aborted during deletion and the | 176 // Verify animations are aborted during deletion and the |
177 // InkDropAnimationObservers are notified. | 177 // InkDropAnimationObservers are notified. |
178 TEST_P(InkDropAnimationTest, AnimationsAbortedDuringDeletion) { | 178 TEST_P(InkDropAnimationTest, AnimationsAbortedDuringDeletion) { |
179 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); | 179 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); |
180 ink_drop_animation_.reset(); | 180 ink_drop_animation_.reset(); |
181 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 181 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
182 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); | 182 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); |
183 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 183 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
184 observer_.last_animation_state_ended()); | 184 observer_.last_animation_ended_context()); |
185 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::PRE_EMPTED, | 185 EXPECT_EQ(InkDropAnimationEndedReason::PRE_EMPTED, |
186 observer_.last_animation_ended_reason()); | 186 observer_.last_animation_ended_reason()); |
187 } | 187 } |
188 | 188 |
189 TEST_P(InkDropAnimationTest, VerifyObserversAreNotified) { | 189 TEST_P(InkDropAnimationTest, VerifyObserversAreNotified) { |
190 ink_drop_animation_->AnimateToState(InkDropState::ACTION_PENDING); | 190 ink_drop_animation_->AnimateToState(InkDropState::ACTION_PENDING); |
191 | 191 |
192 EXPECT_TRUE(test_api_->HasActiveAnimations()); | 192 EXPECT_TRUE(test_api_->HasActiveAnimations()); |
193 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 193 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
194 EXPECT_TRUE(observer_.AnimationHasNotEnded()); | 194 EXPECT_TRUE(observer_.AnimationHasNotEnded()); |
195 EXPECT_EQ(InkDropState::ACTION_PENDING, | 195 EXPECT_EQ(InkDropState::ACTION_PENDING, |
196 observer_.last_animation_state_started()); | 196 observer_.last_animation_started_context()); |
197 | 197 |
198 test_api_->CompleteAnimations(); | 198 test_api_->CompleteAnimations(); |
199 | 199 |
200 EXPECT_FALSE(test_api_->HasActiveAnimations()); | 200 EXPECT_FALSE(test_api_->HasActiveAnimations()); |
201 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 201 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
202 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); | 202 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); |
203 EXPECT_EQ(InkDropState::ACTION_PENDING, | 203 EXPECT_EQ(InkDropState::ACTION_PENDING, |
204 observer_.last_animation_state_ended()); | 204 observer_.last_animation_ended_context()); |
205 } | 205 } |
206 | 206 |
207 TEST_P(InkDropAnimationTest, VerifyObserversAreNotifiedOfSuccessfulAnimations) { | 207 TEST_P(InkDropAnimationTest, VerifyObserversAreNotifiedOfSuccessfulAnimations) { |
208 ink_drop_animation_->AnimateToState(InkDropState::ACTION_PENDING); | 208 ink_drop_animation_->AnimateToState(InkDropState::ACTION_PENDING); |
209 test_api_->CompleteAnimations(); | 209 test_api_->CompleteAnimations(); |
210 | 210 |
211 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); | 211 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); |
212 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::SUCCESS, | 212 EXPECT_EQ(InkDropAnimationEndedReason::SUCCESS, |
213 observer_.last_animation_ended_reason()); | 213 observer_.last_animation_ended_reason()); |
214 } | 214 } |
215 | 215 |
216 TEST_P(InkDropAnimationTest, VerifyObserversAreNotifiedOfPreemptedAnimations) { | 216 TEST_P(InkDropAnimationTest, VerifyObserversAreNotifiedOfPreemptedAnimations) { |
217 ink_drop_animation_->AnimateToState(InkDropState::ACTION_PENDING); | 217 ink_drop_animation_->AnimateToState(InkDropState::ACTION_PENDING); |
218 ink_drop_animation_->AnimateToState(InkDropState::ALTERNATE_ACTION_PENDING); | 218 ink_drop_animation_->AnimateToState(InkDropState::ALTERNATE_ACTION_PENDING); |
219 | 219 |
220 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); | 220 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); |
221 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::PRE_EMPTED, | 221 EXPECT_EQ(InkDropAnimationEndedReason::PRE_EMPTED, |
222 observer_.last_animation_ended_reason()); | 222 observer_.last_animation_ended_reason()); |
223 } | 223 } |
224 | 224 |
225 TEST_P(InkDropAnimationTest, InkDropStatesPersistWhenCallingAnimateToState) { | 225 TEST_P(InkDropAnimationTest, InkDropStatesPersistWhenCallingAnimateToState) { |
226 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); | 226 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); |
227 ink_drop_animation_->AnimateToState(views::InkDropState::ACTIVATED); | 227 ink_drop_animation_->AnimateToState(views::InkDropState::ACTIVATED); |
228 EXPECT_EQ(views::InkDropState::ACTIVATED, | 228 EXPECT_EQ(views::InkDropState::ACTIVATED, |
229 ink_drop_animation_->target_ink_drop_state()); | 229 ink_drop_animation_->target_ink_drop_state()); |
230 } | 230 } |
231 | 231 |
(...skipping 27 matching lines...) Expand all Loading... |
259 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 259 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
260 | 260 |
261 ink_drop_animation_->HideImmediately(); | 261 ink_drop_animation_->HideImmediately(); |
262 | 262 |
263 EXPECT_FALSE(test_api_->HasActiveAnimations()); | 263 EXPECT_FALSE(test_api_->HasActiveAnimations()); |
264 EXPECT_EQ(views::InkDropState::HIDDEN, | 264 EXPECT_EQ(views::InkDropState::HIDDEN, |
265 ink_drop_animation_->target_ink_drop_state()); | 265 ink_drop_animation_->target_ink_drop_state()); |
266 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 266 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
267 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); | 267 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); |
268 EXPECT_EQ(InkDropState::ACTION_PENDING, | 268 EXPECT_EQ(InkDropState::ACTION_PENDING, |
269 observer_.last_animation_state_ended()); | 269 observer_.last_animation_ended_context()); |
270 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::PRE_EMPTED, | 270 EXPECT_EQ(InkDropAnimationEndedReason::PRE_EMPTED, |
271 observer_.last_animation_ended_reason()); | 271 observer_.last_animation_ended_reason()); |
272 | 272 |
273 EXPECT_EQ(InkDropAnimation::kHiddenOpacity, test_api_->GetCurrentOpacity()); | 273 EXPECT_EQ(InkDropAnimation::kHiddenOpacity, test_api_->GetCurrentOpacity()); |
274 EXPECT_FALSE(ink_drop_animation_->IsVisible()); | 274 EXPECT_FALSE(ink_drop_animation_->IsVisible()); |
275 } | 275 } |
276 | 276 |
277 TEST_P(InkDropAnimationTest, SnapToActivatedWithoutActiveAnimations) { | 277 TEST_P(InkDropAnimationTest, SnapToActivatedWithoutActiveAnimations) { |
278 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); | 278 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); |
279 test_api_->CompleteAnimations(); | 279 test_api_->CompleteAnimations(); |
280 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 280 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
(...skipping 24 matching lines...) Expand all Loading... |
305 ink_drop_animation_->target_ink_drop_state()); | 305 ink_drop_animation_->target_ink_drop_state()); |
306 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); | 306 EXPECT_EQ(1, observer_.last_animation_started_ordinal()); |
307 | 307 |
308 ink_drop_animation_->SnapToActivated(); | 308 ink_drop_animation_->SnapToActivated(); |
309 | 309 |
310 EXPECT_FALSE(test_api_->HasActiveAnimations()); | 310 EXPECT_FALSE(test_api_->HasActiveAnimations()); |
311 EXPECT_EQ(views::InkDropState::ACTIVATED, | 311 EXPECT_EQ(views::InkDropState::ACTIVATED, |
312 ink_drop_animation_->target_ink_drop_state()); | 312 ink_drop_animation_->target_ink_drop_state()); |
313 EXPECT_EQ(3, observer_.last_animation_started_ordinal()); | 313 EXPECT_EQ(3, observer_.last_animation_started_ordinal()); |
314 EXPECT_EQ(4, observer_.last_animation_ended_ordinal()); | 314 EXPECT_EQ(4, observer_.last_animation_ended_ordinal()); |
315 EXPECT_EQ(InkDropState::ACTIVATED, observer_.last_animation_state_ended()); | 315 EXPECT_EQ(InkDropState::ACTIVATED, observer_.last_animation_ended_context()); |
316 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::SUCCESS, | 316 EXPECT_EQ(InkDropAnimationEndedReason::SUCCESS, |
317 observer_.last_animation_ended_reason()); | 317 observer_.last_animation_ended_reason()); |
318 | 318 |
319 EXPECT_EQ(InkDropAnimation::kVisibleOpacity, test_api_->GetCurrentOpacity()); | 319 EXPECT_EQ(InkDropAnimation::kVisibleOpacity, test_api_->GetCurrentOpacity()); |
320 EXPECT_TRUE(ink_drop_animation_->IsVisible()); | 320 EXPECT_TRUE(ink_drop_animation_->IsVisible()); |
321 } | 321 } |
322 | 322 |
323 TEST_P(InkDropAnimationTest, AnimateToVisibleFromHidden) { | 323 TEST_P(InkDropAnimationTest, AnimateToVisibleFromHidden) { |
324 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_animation_->target_ink_drop_state()); | 324 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_animation_->target_ink_drop_state()); |
325 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); | 325 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); |
326 EXPECT_TRUE(ink_drop_animation_->IsVisible()); | 326 EXPECT_TRUE(ink_drop_animation_->IsVisible()); |
(...skipping 20 matching lines...) Expand all Loading... |
347 | 347 |
348 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); | 348 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); |
349 EXPECT_EQ(views::InkDropState::HIDDEN, | 349 EXPECT_EQ(views::InkDropState::HIDDEN, |
350 observer_.target_state_at_last_animation_ended()); | 350 observer_.target_state_at_last_animation_ended()); |
351 } | 351 } |
352 | 352 |
353 } // namespace test | 353 } // namespace test |
354 } // namespace views | 354 } // namespace views |
355 | 355 |
356 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ | 356 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ |
OLD | NEW |