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