diff options
author | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 18:56:53 +0000 |
---|---|---|
committer | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 18:56:53 +0000 |
commit | d13419c201aecdaa5571bf14da4c2762c1641985 (patch) | |
tree | f1d038543ea1c1936fb200763f64b6f90935e7c0 /ui/compositor | |
parent | 30cdbab5d787827d376faca6ccd02b6df7f9d8a1 (diff) | |
download | chromium_src-d13419c201aecdaa5571bf14da4c2762c1641985.zip chromium_src-d13419c201aecdaa5571bf14da4c2762c1641985.tar.gz chromium_src-d13419c201aecdaa5571bf14da4c2762c1641985.tar.bz2 |
ui::ThreadedOpacityTransition::OnAbort should depend on tween_type()
ui::ThreadedOpacityTransition::OnAbort currently ignores tween_type(),
and hence effectively assumes tween_type() is LINEAR.
BUG=164206
Review URL: https://chromiumcodereview.appspot.com/12310115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184997 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/compositor')
-rw-r--r-- | ui/compositor/layer_animation_element.cc | 6 | ||||
-rw-r--r-- | ui/compositor/layer_animation_element_unittest.cc | 30 |
2 files changed, 34 insertions, 2 deletions
diff --git a/ui/compositor/layer_animation_element.cc b/ui/compositor/layer_animation_element.cc index 81aeca5..79f4a7f 100644 --- a/ui/compositor/layer_animation_element.cc +++ b/ui/compositor/layer_animation_element.cc @@ -444,8 +444,10 @@ class ThreadedOpacityTransition : public ThreadedLayerAnimationElement { virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE { if (delegate && Started()) { ThreadedLayerAnimationElement::OnAbort(delegate); - delegate->SetOpacityFromAnimation( - Tween::ValueBetween(last_progressed_fraction(), start_, target_)); + delegate->SetOpacityFromAnimation(Tween::ValueBetween( + Tween::CalculateValue(tween_type(), last_progressed_fraction()), + start_, + target_)); } } diff --git a/ui/compositor/layer_animation_element_unittest.cc b/ui/compositor/layer_animation_element_unittest.cc index 9964436..1b22094 100644 --- a/ui/compositor/layer_animation_element_unittest.cc +++ b/ui/compositor/layer_animation_element_unittest.cc @@ -283,6 +283,36 @@ TEST(LayerAnimationElementTest, PauseElement) { copy.GetGrayscaleForAnimation()); } +// Check that a threaded element updates the delegate as expected when aborted. +TEST(LayerAnimationElementTest, AbortOpacityElement) { + TestLayerAnimationDelegate delegate; + float start = 0.0; + float target = 1.0; + base::TimeTicks start_time; + base::TimeTicks effective_start_time; + base::TimeDelta delta = base::TimeDelta::FromSeconds(1); + scoped_ptr<LayerAnimationElement> element( + LayerAnimationElement::CreateOpacityElement(target, delta)); + + // Choose a non-linear Tween type. + Tween::Type tween_type = Tween::EASE_IN; + element->set_tween_type(tween_type); + + start_time += delta; + element->set_requested_start_time(start_time); + delegate.SetOpacityFromAnimation(start); + element->Start(&delegate, 1); + element->Progress(start_time, &delegate); + effective_start_time = start_time + delta; + element->set_effective_start_time(effective_start_time); + element->Progress(effective_start_time, &delegate); + element->Progress(effective_start_time + delta/2, &delegate); + + element->Abort(&delegate); + EXPECT_FLOAT_EQ(Tween::CalculateValue(tween_type, 0.5), + delegate.GetOpacityForAnimation()); +} + } // namespace } // namespace ui |