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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/compositor/layer_owner.h » ('j') | 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 <memory>
8
7 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "cc/animation/animation_events.h" 13 #include "cc/animation/animation_events.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/compositor/layer.h" 15 #include "ui/compositor/layer.h"
15 #include "ui/compositor/layer_animation_delegate.h" 16 #include "ui/compositor/layer_animation_delegate.h"
16 #include "ui/compositor/layer_animation_element.h" 17 #include "ui/compositor/layer_animation_element.h"
17 #include "ui/compositor/layer_animation_sequence.h" 18 #include "ui/compositor/layer_animation_sequence.h"
18 #include "ui/compositor/layer_animator_collection.h" 19 #include "ui/compositor/layer_animator_collection.h"
19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 20 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 573 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
573 574
574 delegate.SetGrayscaleFromAnimation(start_grayscale); 575 delegate.SetGrayscaleFromAnimation(start_grayscale);
575 delegate.SetBoundsFromAnimation(start_bounds); 576 delegate.SetBoundsFromAnimation(start_bounds);
576 577
577 animator->ScheduleAnimation( 578 animator->ScheduleAnimation(
578 new LayerAnimationSequence( 579 new LayerAnimationSequence(
579 LayerAnimationElement::CreateGrayscaleElement(target_grayscale, 580 LayerAnimationElement::CreateGrayscaleElement(target_grayscale,
580 delta))); 581 delta)));
581 582
582 scoped_ptr<LayerAnimationSequence> bounds_and_grayscale( 583 std::unique_ptr<LayerAnimationSequence> bounds_and_grayscale(
583 new LayerAnimationSequence( 584 new LayerAnimationSequence(LayerAnimationElement::CreateGrayscaleElement(
584 LayerAnimationElement::CreateGrayscaleElement(start_grayscale, 585 start_grayscale, delta)));
585 delta)));
586 586
587 bounds_and_grayscale->AddElement( 587 bounds_and_grayscale->AddElement(
588 LayerAnimationElement::CreateBoundsElement(target_bounds, delta)); 588 LayerAnimationElement::CreateBoundsElement(target_bounds, delta));
589 589
590 animator->ScheduleAnimation(bounds_and_grayscale.release()); 590 animator->ScheduleAnimation(bounds_and_grayscale.release());
591 591
592 animator->ScheduleAnimation( 592 animator->ScheduleAnimation(
593 new LayerAnimationSequence( 593 new LayerAnimationSequence(
594 LayerAnimationElement::CreateBoundsElement(start_bounds, delta))); 594 LayerAnimationElement::CreateBoundsElement(start_bounds, delta)));
595 595
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 TestLayerAnimationDelegate delegate; 1380 TestLayerAnimationDelegate delegate;
1381 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator(&delegate)); 1381 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator(&delegate));
1382 1382
1383 double start_brightness(0.0); 1383 double start_brightness(0.0);
1384 double target_brightness(1.0); 1384 double target_brightness(1.0);
1385 1385
1386 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 1386 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1387 1387
1388 delegate.SetBrightnessFromAnimation(start_brightness); 1388 delegate.SetBrightnessFromAnimation(start_brightness);
1389 1389
1390 scoped_ptr<LayerAnimationSequence> sequence( 1390 std::unique_ptr<LayerAnimationSequence> sequence(
1391 new LayerAnimationSequence( 1391 new LayerAnimationSequence(LayerAnimationElement::CreateBrightnessElement(
1392 LayerAnimationElement::CreateBrightnessElement(target_brightness, 1392 target_brightness, delta)));
1393 delta)));
1394 1393
1395 sequence->AddElement( 1394 sequence->AddElement(
1396 LayerAnimationElement::CreateBrightnessElement(start_brightness, delta)); 1395 LayerAnimationElement::CreateBrightnessElement(start_brightness, delta));
1397 1396
1398 sequence->set_is_cyclic(true); 1397 sequence->set_is_cyclic(true);
1399 1398
1400 animator->StartAnimation(sequence.release()); 1399 animator->StartAnimation(sequence.release());
1401 1400
1402 base::TimeTicks start_time = animator->last_step_time(); 1401 base::TimeTicks start_time = animator->last_step_time();
1403 1402
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 CreateDefaultTestAnimator(&delegate)); 1439 CreateDefaultTestAnimator(&delegate));
1441 LayerAnimator* animator = test_controller.animator(); 1440 LayerAnimator* animator = test_controller.animator();
1442 1441
1443 double start_opacity(0.0); 1442 double start_opacity(0.0);
1444 double target_opacity(1.0); 1443 double target_opacity(1.0);
1445 1444
1446 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 1445 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1447 1446
1448 delegate.SetOpacityFromAnimation(start_opacity); 1447 delegate.SetOpacityFromAnimation(start_opacity);
1449 1448
1450 scoped_ptr<LayerAnimationSequence> sequence( 1449 std::unique_ptr<LayerAnimationSequence> sequence(new LayerAnimationSequence(
1451 new LayerAnimationSequence( 1450 LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
1452 LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
1453 1451
1454 sequence->AddElement( 1452 sequence->AddElement(
1455 LayerAnimationElement::CreateOpacityElement(start_opacity, delta)); 1453 LayerAnimationElement::CreateOpacityElement(start_opacity, delta));
1456 1454
1457 sequence->set_is_cyclic(true); 1455 sequence->set_is_cyclic(true);
1458 1456
1459 test_controller.animator()->StartAnimation(sequence.release()); 1457 test_controller.animator()->StartAnimation(sequence.release());
1460 1458
1461 base::TimeTicks start_time = test_controller.animator()->last_step_time(); 1459 base::TimeTicks start_time = test_controller.animator()->last_step_time();
1462 base::TimeTicks effective_start = start_time + delta; 1460 base::TimeTicks effective_start = start_time + delta;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 base::TimeTicks start_time = animator->last_step_time(); 1729 base::TimeTicks start_time = animator->last_step_time();
1732 1730
1733 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 1731 animator->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
1734 1732
1735 EXPECT_EQ(observer.last_ended_sequence(), sequence); 1733 EXPECT_EQ(observer.last_ended_sequence(), sequence);
1736 EXPECT_TRUE(!removed_observer.last_ended_sequence()); 1734 EXPECT_TRUE(!removed_observer.last_ended_sequence());
1737 } 1735 }
1738 1736
1739 TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) { 1737 TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) {
1740 TestLayerAnimationDelegate delegate; 1738 TestLayerAnimationDelegate delegate;
1741 scoped_ptr<TestLayerAnimationObserver> observer( 1739 std::unique_ptr<TestLayerAnimationObserver> observer(
1742 new TestLayerAnimationObserver); 1740 new TestLayerAnimationObserver);
1743 scoped_refptr<LayerAnimator> animator( 1741 scoped_refptr<LayerAnimator> animator(
1744 CreateDefaultTestAnimator(&delegate, observer.get())); 1742 CreateDefaultTestAnimator(&delegate, observer.get()));
1745 1743
1746 delegate.SetOpacityFromAnimation(0.0f); 1744 delegate.SetOpacityFromAnimation(0.0f);
1747 1745
1748 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 1746 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
1749 LayerAnimationSequence* sequence = new LayerAnimationSequence( 1747 LayerAnimationSequence* sequence = new LayerAnimationSequence(
1750 LayerAnimationElement::CreateOpacityElement(1.0f, delta)); 1748 LayerAnimationElement::CreateOpacityElement(1.0f, delta));
1751 1749
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 gfx::Rect start_bounds(0, 0, 50, 50); 1844 gfx::Rect start_bounds(0, 0, 50, 50);
1847 gfx::Rect target_bounds(5, 5, 5, 5); 1845 gfx::Rect target_bounds(5, 5, 5, 5);
1848 1846
1849 delegate.SetBrightnessFromAnimation(start_brightness); 1847 delegate.SetBrightnessFromAnimation(start_brightness);
1850 delegate.SetBoundsFromAnimation(start_bounds); 1848 delegate.SetBoundsFromAnimation(start_bounds);
1851 1849
1852 base::TimeDelta brightness_delta = base::TimeDelta::FromSeconds(1); 1850 base::TimeDelta brightness_delta = base::TimeDelta::FromSeconds(1);
1853 base::TimeDelta halfway_delta = base::TimeDelta::FromSeconds(2); 1851 base::TimeDelta halfway_delta = base::TimeDelta::FromSeconds(2);
1854 base::TimeDelta bounds_delta = base::TimeDelta::FromSeconds(3); 1852 base::TimeDelta bounds_delta = base::TimeDelta::FromSeconds(3);
1855 1853
1856 scoped_ptr<DeletingLayerAnimationObserver> observer( 1854 std::unique_ptr<DeletingLayerAnimationObserver> observer(
1857 new DeletingLayerAnimationObserver(animator.get())); 1855 new DeletingLayerAnimationObserver(animator.get()));
1858 1856
1859 animator->AddObserver(observer.get()); 1857 animator->AddObserver(observer.get());
1860 1858
1861 animator->StartAnimation( 1859 animator->StartAnimation(
1862 new LayerAnimationSequence( 1860 new LayerAnimationSequence(
1863 LayerAnimationElement::CreateBrightnessElement( 1861 LayerAnimationElement::CreateBrightnessElement(
1864 target_brightness, brightness_delta))); 1862 target_brightness, brightness_delta)));
1865 1863
1866 animator->StartAnimation(new LayerAnimationSequence( 1864 animator->StartAnimation(new LayerAnimationSequence(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 double start_brightness(0.0); 1951 double start_brightness(0.0);
1954 double target_brightness(1.0); 1952 double target_brightness(1.0);
1955 gfx::Rect start_bounds(0, 0, 50, 50); 1953 gfx::Rect start_bounds(0, 0, 50, 50);
1956 gfx::Rect target_bounds(5, 5, 5, 5); 1954 gfx::Rect target_bounds(5, 5, 5, 5);
1957 base::TimeDelta brightness_delta = base::TimeDelta::FromSeconds(1); 1955 base::TimeDelta brightness_delta = base::TimeDelta::FromSeconds(1);
1958 base::TimeDelta bounds_delta = base::TimeDelta::FromSeconds(2); 1956 base::TimeDelta bounds_delta = base::TimeDelta::FromSeconds(2);
1959 1957
1960 delegate.SetBrightnessFromAnimation(start_brightness); 1958 delegate.SetBrightnessFromAnimation(start_brightness);
1961 delegate.SetBoundsFromAnimation(start_bounds); 1959 delegate.SetBoundsFromAnimation(start_bounds);
1962 1960
1963 scoped_ptr<DeletingLayerAnimationObserver> observer( 1961 std::unique_ptr<DeletingLayerAnimationObserver> observer(
1964 new DeletingLayerAnimationObserver(animator.get())); 1962 new DeletingLayerAnimationObserver(animator.get()));
1965 animator->AddObserver(observer.get()); 1963 animator->AddObserver(observer.get());
1966 1964
1967 animator->StartAnimation( 1965 animator->StartAnimation(
1968 new LayerAnimationSequence( 1966 new LayerAnimationSequence(
1969 LayerAnimationElement::CreateBrightnessElement( 1967 LayerAnimationElement::CreateBrightnessElement(
1970 target_brightness, brightness_delta))); 1968 target_brightness, brightness_delta)));
1971 animator->StartAnimation(new LayerAnimationSequence( 1969 animator->StartAnimation(new LayerAnimationSequence(
1972 LayerAnimationElement::CreateBoundsElement( 1970 LayerAnimationElement::CreateBoundsElement(
1973 target_bounds, bounds_delta))); 1971 target_bounds, bounds_delta)));
(...skipping 20 matching lines...) Expand all
1994 TestLayerAnimationDelegate delegate; 1992 TestLayerAnimationDelegate delegate;
1995 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator(&delegate)); 1993 scoped_refptr<LayerAnimator> animator(CreateDefaultTestAnimator(&delegate));
1996 1994
1997 double start_opacity(0.0); 1995 double start_opacity(0.0);
1998 double target_opacity(1.0); 1996 double target_opacity(1.0);
1999 1997
2000 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 1998 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
2001 1999
2002 delegate.SetOpacityFromAnimation(start_opacity); 2000 delegate.SetOpacityFromAnimation(start_opacity);
2003 2001
2004 scoped_ptr<LayerAnimationSequence> sequence( 2002 std::unique_ptr<LayerAnimationSequence> sequence(new LayerAnimationSequence(
2005 new LayerAnimationSequence( 2003 LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
2006 LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
2007 2004
2008 animator->StartAnimation(sequence.release()); 2005 animator->StartAnimation(sequence.release());
2009 2006
2010 animator->SetOpacity(0.5); 2007 animator->SetOpacity(0.5);
2011 2008
2012 EXPECT_FALSE(animator->is_animating()); 2009 EXPECT_FALSE(animator->is_animating());
2013 EXPECT_EQ(0.5, animator->GetTargetOpacity()); 2010 EXPECT_EQ(0.5, animator->GetTargetOpacity());
2014 } 2011 }
2015 2012
2016 // Tests that the preemption mode IMMEDIATELY_SET_NEW_TARGET, doesn't cause the 2013 // Tests that the preemption mode IMMEDIATELY_SET_NEW_TARGET, doesn't cause the
(...skipping 12 matching lines...) Expand all
2029 { 2026 {
2030 // start an implicit bounds animation. 2027 // start an implicit bounds animation.
2031 ScopedLayerAnimationSettings settings(animator.get()); 2028 ScopedLayerAnimationSettings settings(animator.get());
2032 animator->SetBounds(middle_bounds); 2029 animator->SetBounds(middle_bounds);
2033 } 2030 }
2034 2031
2035 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS)); 2032 EXPECT_TRUE(animator->IsAnimatingProperty(LayerAnimationElement::BOUNDS));
2036 2033
2037 int num_live_instances = 0; 2034 int num_live_instances = 0;
2038 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 2035 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
2039 scoped_ptr<TestLayerAnimationSequence> sequence( 2036 std::unique_ptr<TestLayerAnimationSequence> sequence(
2040 new TestLayerAnimationSequence( 2037 new TestLayerAnimationSequence(
2041 LayerAnimationElement::CreateBoundsElement(target_bounds, delta), 2038 LayerAnimationElement::CreateBoundsElement(target_bounds, delta),
2042 &num_live_instances)); 2039 &num_live_instances));
2043 2040
2044 EXPECT_EQ(1, num_live_instances); 2041 EXPECT_EQ(1, num_live_instances);
2045 2042
2046 // This should interrupt the running sequence causing us to immediately set 2043 // This should interrupt the running sequence causing us to immediately set
2047 // the target value. The sequence should alse be destructed. 2044 // the target value. The sequence should alse be destructed.
2048 animator->StartAnimation(sequence.release()); 2045 animator->StartAnimation(sequence.release());
2049 2046
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 if (delete_on_animation_aborted_) 2216 if (delete_on_animation_aborted_)
2220 delete this; 2217 delete this;
2221 } 2218 }
2222 2219
2223 void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override { 2220 void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override {
2224 if (delete_on_animation_scheduled_) 2221 if (delete_on_animation_scheduled_)
2225 delete this; 2222 delete this;
2226 } 2223 }
2227 2224
2228 private: 2225 private:
2229 scoped_ptr<AnimatorOwner> animator_owner_; 2226 std::unique_ptr<AnimatorOwner> animator_owner_;
2230 bool delete_on_animation_ended_; 2227 bool delete_on_animation_ended_;
2231 bool delete_on_animation_aborted_; 2228 bool delete_on_animation_aborted_;
2232 bool delete_on_animation_scheduled_; 2229 bool delete_on_animation_scheduled_;
2233 bool* was_deleted_; 2230 bool* was_deleted_;
2234 2231
2235 DISALLOW_COPY_AND_ASSIGN(DeletingObserver); 2232 DISALLOW_COPY_AND_ASSIGN(DeletingObserver);
2236 }; 2233 };
2237 2234
2238 TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) { 2235 TEST(LayerAnimatorTest, ObserverDeletesAnimatorAfterFinishingAnimation) {
2239 bool observer_was_deleted = false; 2236 bool observer_was_deleted = false;
2240 DeletingObserver* observer = new DeletingObserver(&observer_was_deleted); 2237 DeletingObserver* observer = new DeletingObserver(&observer_was_deleted);
2241 observer->set_delete_on_animation_ended(true); 2238 observer->set_delete_on_animation_ended(true);
2242 observer->set_delete_on_animation_aborted(true); 2239 observer->set_delete_on_animation_aborted(true);
2243 LayerAnimator* animator = observer->animator(); 2240 LayerAnimator* animator = observer->animator();
2244 TestLayerAnimationDelegate delegate; 2241 TestLayerAnimationDelegate delegate;
2245 animator->SetDelegate(&delegate); 2242 animator->SetDelegate(&delegate);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2472 EXPECT_FALSE(animator->is_started_); 2469 EXPECT_FALSE(animator->is_started_);
2473 2470
2474 CollectionLayerAnimationDelegate collection_delegate; 2471 CollectionLayerAnimationDelegate collection_delegate;
2475 animator->SetDelegate(&collection_delegate); 2472 animator->SetDelegate(&collection_delegate);
2476 animator->UpdateAnimationState(); 2473 animator->UpdateAnimationState();
2477 EXPECT_TRUE(animator->is_started_); 2474 EXPECT_TRUE(animator->is_started_);
2478 animator->SetDelegate(NULL); 2475 animator->SetDelegate(NULL);
2479 } 2476 }
2480 2477
2481 TEST(LayerAnimatorTest, AnimatorRemovedFromCollectionWhenLayerIsDestroyed) { 2478 TEST(LayerAnimatorTest, AnimatorRemovedFromCollectionWhenLayerIsDestroyed) {
2482 scoped_ptr<Layer> layer(new Layer(LAYER_TEXTURED)); 2479 std::unique_ptr<Layer> layer(new Layer(LAYER_TEXTURED));
2483 LayerAnimatorTestController test_controller(layer->GetAnimator()); 2480 LayerAnimatorTestController test_controller(layer->GetAnimator());
2484 scoped_refptr<LayerAnimator> animator = test_controller.animator(); 2481 scoped_refptr<LayerAnimator> animator = test_controller.animator();
2485 CollectionLayerAnimationDelegate collection_delegate; 2482 CollectionLayerAnimationDelegate collection_delegate;
2486 animator->SetDelegate(&collection_delegate); 2483 animator->SetDelegate(&collection_delegate);
2487 2484
2488 double target_opacity = 1.0; 2485 double target_opacity = 1.0;
2489 base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1); 2486 base::TimeDelta time_delta = base::TimeDelta::FromSeconds(1);
2490 animator->ScheduleAnimation(new LayerAnimationSequence( 2487 animator->ScheduleAnimation(new LayerAnimationSequence(
2491 LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta))); 2488 LayerAnimationElement::CreateOpacityElement(target_opacity, time_delta)));
2492 2489
2493 EXPECT_TRUE( 2490 EXPECT_TRUE(
2494 collection_delegate.GetLayerAnimatorCollection()->HasActiveAnimators()); 2491 collection_delegate.GetLayerAnimatorCollection()->HasActiveAnimators());
2495 2492
2496 layer.reset(); 2493 layer.reset();
2497 EXPECT_EQ(NULL, animator->delegate()); 2494 EXPECT_EQ(NULL, animator->delegate());
2498 EXPECT_FALSE( 2495 EXPECT_FALSE(
2499 collection_delegate.GetLayerAnimatorCollection()->HasActiveAnimators()); 2496 collection_delegate.GetLayerAnimatorCollection()->HasActiveAnimators());
2500 } 2497 }
2501 2498
2502 TEST(LayerAnimatorTest, LayerMovedBetweenCompositorsDuringAnimation) { 2499 TEST(LayerAnimatorTest, LayerMovedBetweenCompositorsDuringAnimation) {
2503 bool enable_pixel_output = false; 2500 bool enable_pixel_output = false;
2504 ui::ContextFactory* context_factory = 2501 ui::ContextFactory* context_factory =
2505 InitializeContextFactoryForTests(enable_pixel_output); 2502 InitializeContextFactoryForTests(enable_pixel_output);
2506 const gfx::Rect bounds(10, 10, 100, 100); 2503 const gfx::Rect bounds(10, 10, 100, 100);
2507 scoped_ptr<TestCompositorHost> host_1( 2504 std::unique_ptr<TestCompositorHost> host_1(
2508 TestCompositorHost::Create(bounds, context_factory)); 2505 TestCompositorHost::Create(bounds, context_factory));
2509 scoped_ptr<TestCompositorHost> host_2( 2506 std::unique_ptr<TestCompositorHost> host_2(
2510 TestCompositorHost::Create(bounds, context_factory)); 2507 TestCompositorHost::Create(bounds, context_factory));
2511 host_1->Show(); 2508 host_1->Show();
2512 host_2->Show(); 2509 host_2->Show();
2513 2510
2514 Compositor* compositor_1 = host_1->GetCompositor(); 2511 Compositor* compositor_1 = host_1->GetCompositor();
2515 Layer root_1; 2512 Layer root_1;
2516 compositor_1->SetRootLayer(&root_1); 2513 compositor_1->SetRootLayer(&root_1);
2517 2514
2518 Compositor* compositor_2 = host_2->GetCompositor(); 2515 Compositor* compositor_2 = host_2->GetCompositor();
2519 Layer root_2; 2516 Layer root_2;
(...skipping 25 matching lines...) Expand all
2545 host_2.reset(); 2542 host_2.reset();
2546 host_1.reset(); 2543 host_1.reset();
2547 TerminateContextFactoryForTests(); 2544 TerminateContextFactoryForTests();
2548 } 2545 }
2549 2546
2550 TEST(LayerAnimatorTest, ThreadedAnimationSurvivesIfLayerRemovedAdded) { 2547 TEST(LayerAnimatorTest, ThreadedAnimationSurvivesIfLayerRemovedAdded) {
2551 bool enable_pixel_output = false; 2548 bool enable_pixel_output = false;
2552 ui::ContextFactory* context_factory = 2549 ui::ContextFactory* context_factory =
2553 InitializeContextFactoryForTests(enable_pixel_output); 2550 InitializeContextFactoryForTests(enable_pixel_output);
2554 const gfx::Rect bounds(10, 10, 100, 100); 2551 const gfx::Rect bounds(10, 10, 100, 100);
2555 scoped_ptr<TestCompositorHost> host( 2552 std::unique_ptr<TestCompositorHost> host(
2556 TestCompositorHost::Create(bounds, context_factory)); 2553 TestCompositorHost::Create(bounds, context_factory));
2557 host->Show(); 2554 host->Show();
2558 2555
2559 Compositor* compositor = host->GetCompositor(); 2556 Compositor* compositor = host->GetCompositor();
2560 2557
2561 Layer root; 2558 Layer root;
2562 compositor->SetRootLayer(&root); 2559 compositor->SetRootLayer(&root);
2563 2560
2564 Layer layer; 2561 Layer layer;
2565 root.Add(&layer); 2562 root.Add(&layer);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 animator_layer_.reset(); 2598 animator_layer_.reset();
2602 } 2599 }
2603 2600
2604 LayerAnimationDelegate* animator_layer() { 2601 LayerAnimationDelegate* animator_layer() {
2605 return animator_layer_.get(); 2602 return animator_layer_.get();
2606 } 2603 }
2607 2604
2608 void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override {} 2605 void OnLayerAnimationScheduled(LayerAnimationSequence* sequence) override {}
2609 2606
2610 private: 2607 private:
2611 scoped_ptr<Layer> animator_layer_; 2608 std::unique_ptr<Layer> animator_layer_;
2612 2609
2613 DISALLOW_COPY_AND_ASSIGN(LayerOwnerAnimationObserver); 2610 DISALLOW_COPY_AND_ASSIGN(LayerOwnerAnimationObserver);
2614 }; 2611 };
2615 2612
2616 TEST(LayerAnimatorTest, ObserverDeletesLayerInStopAnimating) { 2613 TEST(LayerAnimatorTest, ObserverDeletesLayerInStopAnimating) {
2617 scoped_refptr<LayerAnimator> animator(CreateImplicitTestAnimator()); 2614 scoped_refptr<LayerAnimator> animator(CreateImplicitTestAnimator());
2618 LayerOwnerAnimationObserver observer(animator.get()); 2615 LayerOwnerAnimationObserver observer(animator.get());
2619 LayerAnimationDelegate* delegate = observer.animator_layer(); 2616 LayerAnimationDelegate* delegate = observer.animator_layer();
2620 2617
2621 const gfx::Rect start_bounds(0, 0, 50, 50); 2618 const gfx::Rect start_bounds(0, 0, 50, 50);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 EXPECT_EQ(observer.last_ended_sequence(), nullptr); 2836 EXPECT_EQ(observer.last_ended_sequence(), nullptr);
2840 EXPECT_EQ(observer.last_detached_sequence(), first_sequence); 2837 EXPECT_EQ(observer.last_detached_sequence(), first_sequence);
2841 2838
2842 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch()); 2839 EXPECT_TRUE(observer.AbortedEpochIsBeforeDetachedEpoch());
2843 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch()); 2840 EXPECT_TRUE(observer.AbortedEpochIsBeforeStartedEpoch());
2844 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch()); 2841 EXPECT_TRUE(observer.AttachedEpochIsBeforeScheduledEpoch());
2845 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch()); 2842 EXPECT_TRUE(observer.ScheduledEpochIsBeforeStartedEpoch());
2846 } 2843 }
2847 2844
2848 } // namespace ui 2845 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator.cc ('k') | ui/compositor/layer_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698