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

Side by Side Diff: ui/compositor/layer_animator_unittest.cc

Issue 23190045: Switch ObserverList::size() to ObserverList::might_have_observers() Pt.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « sync/js/sync_js_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/compositor/layer_animator.h" 5 #include "ui/compositor/layer_animator.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 1757
1758 delegate.SetOpacityFromAnimation(0.0f); 1758 delegate.SetOpacityFromAnimation(0.0f);
1759 1759
1760 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 1760 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1761 LayerAnimationSequence* sequence = new LayerAnimationSequence( 1761 LayerAnimationSequence* sequence = new LayerAnimationSequence(
1762 LayerAnimationElement::CreateOpacityElement(1.0f, delta)); 1762 LayerAnimationElement::CreateOpacityElement(1.0f, delta));
1763 1763
1764 animator->StartAnimation(sequence); 1764 animator->StartAnimation(sequence);
1765 1765
1766 // |observer| should be attached to |sequence|. 1766 // |observer| should be attached to |sequence|.
1767 EXPECT_EQ(static_cast<size_t>(1), sequence->observers_.size()); 1767 EXPECT_TRUE(sequence->observers_.might_have_observers());
1768 1768
1769 // Now, release |observer| 1769 // Now, release |observer|
1770 observer.reset(); 1770 observer.reset();
1771 1771
1772 // And |sequence| should no longer be attached to |observer|. 1772 // And |sequence| should no longer be attached to |observer|.
1773 EXPECT_EQ(static_cast<size_t>(0), sequence->observers_.size()); 1773 EXPECT_FALSE(sequence->observers_.might_have_observers());
1774 } 1774 }
1775 1775
1776 TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { 1776 TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) {
1777 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator()); 1777 scoped_refptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
1778 AnimationContainerElement* element = animator.get(); 1778 AnimationContainerElement* element = animator.get();
1779 animator->set_disable_timer_for_test(true); 1779 animator->set_disable_timer_for_test(true);
1780 1780
1781 TestImplicitAnimationObserver observer(false); 1781 TestImplicitAnimationObserver observer(false);
1782 TestLayerAnimationDelegate delegate; 1782 TestLayerAnimationDelegate delegate;
1783 animator->SetDelegate(&delegate); 1783 animator->SetDelegate(&delegate);
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 2370
2371 settings.SetPreemptionStrategy( 2371 settings.SetPreemptionStrategy(
2372 LayerAnimator::ENQUEUE_NEW_ANIMATION); 2372 LayerAnimator::ENQUEUE_NEW_ANIMATION);
2373 settings.SetTransitionDuration(base::TimeDelta()); 2373 settings.SetTransitionDuration(base::TimeDelta());
2374 animator->SetOpacity(magic_opacity); 2374 animator->SetOpacity(magic_opacity);
2375 2375
2376 EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation()); 2376 EXPECT_EQ(start_opacity, delegate.GetOpacityForAnimation());
2377 } 2377 }
2378 2378
2379 } // namespace ui 2379 } // namespace ui
OLDNEW
« no previous file with comments | « sync/js/sync_js_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698