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

Side by Side Diff: ui/views/animation/ink_drop_animation_unittest.cc

Issue 1757993004: Added ink drop hover/ripple to menu hosting bookmark buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sky@ & varkha@ comments. Created 4 years, 9 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
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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); 262 EXPECT_EQ(2, observer_.last_animation_ended_ordinal());
263 EXPECT_EQ(InkDropState::ACTION_PENDING, 263 EXPECT_EQ(InkDropState::ACTION_PENDING,
264 observer_.last_animation_state_ended()); 264 observer_.last_animation_state_ended());
265 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::PRE_EMPTED, 265 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::PRE_EMPTED,
266 observer_.last_animation_ended_reason()); 266 observer_.last_animation_ended_reason());
267 267
268 EXPECT_EQ(InkDropAnimation::kHiddenOpacity, test_api_->GetCurrentOpacity()); 268 EXPECT_EQ(InkDropAnimation::kHiddenOpacity, test_api_->GetCurrentOpacity());
269 EXPECT_FALSE(ink_drop_animation_->IsVisible()); 269 EXPECT_FALSE(ink_drop_animation_->IsVisible());
270 } 270 }
271 271
272 TEST_P(InkDropAnimationTest, SnapToActivatedWithoutActiveAnimations) {
273 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING);
274 test_api_->CompleteAnimations();
275 EXPECT_EQ(1, observer_.last_animation_started_ordinal());
276 EXPECT_EQ(2, observer_.last_animation_ended_ordinal());
277
278 EXPECT_FALSE(test_api_->HasActiveAnimations());
279 EXPECT_NE(InkDropState::ACTIVATED,
280 ink_drop_animation_->target_ink_drop_state());
281
282 ink_drop_animation_->SnapToActivated();
283
284 EXPECT_FALSE(test_api_->HasActiveAnimations());
285 EXPECT_EQ(views::InkDropState::ACTIVATED,
286 ink_drop_animation_->target_ink_drop_state());
287 EXPECT_EQ(3, observer_.last_animation_started_ordinal());
288 EXPECT_EQ(4, observer_.last_animation_ended_ordinal());
289
290 EXPECT_EQ(InkDropAnimation::kVisibleOpacity, test_api_->GetCurrentOpacity());
291 EXPECT_TRUE(ink_drop_animation_->IsVisible());
292 }
293
294 // Verifies all active animations are aborted and the InkDropState is set to
295 // ACTIVATED after invoking SnapToActivated().
296 TEST_P(InkDropAnimationTest, SnapToActivatedWithActiveAnimations) {
297 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING);
298 EXPECT_TRUE(test_api_->HasActiveAnimations());
299 EXPECT_NE(InkDropState::ACTIVATED,
300 ink_drop_animation_->target_ink_drop_state());
301 EXPECT_EQ(1, observer_.last_animation_started_ordinal());
302
303 ink_drop_animation_->SnapToActivated();
304
305 EXPECT_FALSE(test_api_->HasActiveAnimations());
306 EXPECT_EQ(views::InkDropState::ACTIVATED,
307 ink_drop_animation_->target_ink_drop_state());
308 EXPECT_EQ(3, observer_.last_animation_started_ordinal());
309 EXPECT_EQ(4, observer_.last_animation_ended_ordinal());
310 EXPECT_EQ(InkDropState::ACTIVATED, observer_.last_animation_state_ended());
311 EXPECT_EQ(InkDropAnimationObserver::InkDropAnimationEndedReason::SUCCESS,
312 observer_.last_animation_ended_reason());
313
314 EXPECT_EQ(InkDropAnimation::kVisibleOpacity, test_api_->GetCurrentOpacity());
315 EXPECT_TRUE(ink_drop_animation_->IsVisible());
316 }
317
272 TEST_P(InkDropAnimationTest, AnimateToVisibleFromHidden) { 318 TEST_P(InkDropAnimationTest, AnimateToVisibleFromHidden) {
273 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_animation_->target_ink_drop_state()); 319 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_animation_->target_ink_drop_state());
274 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING); 320 ink_drop_animation_->AnimateToState(views::InkDropState::ACTION_PENDING);
275 EXPECT_TRUE(ink_drop_animation_->IsVisible()); 321 EXPECT_TRUE(ink_drop_animation_->IsVisible());
276 } 322 }
277 323
278 // Verifies that the value of InkDropAnimation::target_ink_drop_state() returns 324 // Verifies that the value of InkDropAnimation::target_ink_drop_state() returns
279 // the most recent value passed to AnimateToState() when notifying observers 325 // the most recent value passed to AnimateToState() when notifying observers
280 // that an animation has started within the AnimateToState() function call. 326 // that an animation has started within the AnimateToState() function call.
281 TEST_P(InkDropAnimationTest, TargetInkDropStateOnAnimationStarted) { 327 TEST_P(InkDropAnimationTest, TargetInkDropStateOnAnimationStarted) {
(...skipping 14 matching lines...) Expand all
296 342
297 EXPECT_EQ(2, observer_.last_animation_ended_ordinal()); 343 EXPECT_EQ(2, observer_.last_animation_ended_ordinal());
298 EXPECT_EQ(views::InkDropState::HIDDEN, 344 EXPECT_EQ(views::InkDropState::HIDDEN,
299 observer_.target_state_at_last_animation_ended()); 345 observer_.target_state_at_last_animation_ended());
300 } 346 }
301 347
302 } // namespace test 348 } // namespace test
303 } // namespace views 349 } // namespace views
304 350
305 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_ 351 #endif // UI_VIEWS_ANIMATION_INK_DROP_ANIMATION_UNITTEST_H_
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_animation_controller_impl_unittest.cc ('k') | ui/views/animation/ink_drop_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698