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

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

Issue 311783002: Revert r274404 and r274409: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 // Trigger a threaded animation. 1500 // Trigger a threaded animation.
1501 l1->SetOpacity(0.5f); 1501 l1->SetOpacity(0.5f);
1502 1502
1503 // Change l1's cc::Layer. 1503 // Change l1's cc::Layer.
1504 l1->SwitchCCLayerForTest(); 1504 l1->SwitchCCLayerForTest();
1505 1505
1506 // Ensure that the opacity animation completed. 1506 // Ensure that the opacity animation completed.
1507 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); 1507 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f);
1508 } 1508 }
1509 1509
1510 // Tests that the animators in the layer tree is added to the
1511 // animator-collection when the root-layer is set to the compositor.
1512 TEST_F(LayerWithDelegateTest, RootLayerAnimatorsInCompositor) {
1513 scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
1514 scoped_ptr<Layer> child(CreateColorLayer(SK_ColorRED, gfx::Rect(10, 10)));
1515 child->SetAnimator(LayerAnimator::CreateImplicitAnimator());
1516 child->SetOpacity(0.5f);
1517 root->Add(child.get());
1518
1519 EXPECT_FALSE(compositor()->layer_animator_collection()->HasActiveAnimators());
1520 compositor()->SetRootLayer(root.get());
1521 EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
1522 }
1523
1524 // Tests that adding/removing a layer adds/removes the animator from its entire
1525 // subtree from the compositor's animator-collection.
1526 TEST_F(LayerWithDelegateTest, AddRemoveLayerUpdatesAnimatorsFromSubtree) {
1527 scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
1528 scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
1529 scoped_ptr<Layer> grandchild(CreateColorLayer(SK_ColorRED,
1530 gfx::Rect(10, 10)));
1531 root->Add(child.get());
1532 child->Add(grandchild.get());
1533 compositor()->SetRootLayer(root.get());
1534
1535 grandchild->SetAnimator(LayerAnimator::CreateImplicitAnimator());
1536 grandchild->SetOpacity(0.5f);
1537 EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
1538
1539 root->Remove(child.get());
1540 EXPECT_FALSE(compositor()->layer_animator_collection()->HasActiveAnimators());
1541
1542 root->Add(child.get());
1543 EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
1544 }
1545
1546 TEST_F(LayerWithDelegateTest, DestroyingLayerRemovesTheAnimatorFromCollection) {
1547 scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
1548 scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
1549 root->Add(child.get());
1550 compositor()->SetRootLayer(root.get());
1551
1552 child->SetAnimator(LayerAnimator::CreateImplicitAnimator());
1553 child->SetOpacity(0.5f);
1554 EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
1555
1556 child.reset();
1557 EXPECT_FALSE(compositor()->layer_animator_collection()->HasActiveAnimators());
1558 }
1559
1560 } // namespace ui 1510 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animator_unittest.cc ('k') | ui/compositor/test/test_layer_animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698