OLD | NEW |
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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 639 |
640 NullLayerDelegate delegate; | 640 NullLayerDelegate delegate; |
641 l1->set_delegate(&delegate); | 641 l1->set_delegate(&delegate); |
642 l2->set_delegate(&delegate); | 642 l2->set_delegate(&delegate); |
643 l3->set_delegate(&delegate); | 643 l3->set_delegate(&delegate); |
644 | 644 |
645 // Layers should initially be drawn. | 645 // Layers should initially be drawn. |
646 EXPECT_TRUE(l1->IsDrawn()); | 646 EXPECT_TRUE(l1->IsDrawn()); |
647 EXPECT_TRUE(l2->IsDrawn()); | 647 EXPECT_TRUE(l2->IsDrawn()); |
648 EXPECT_TRUE(l3->IsDrawn()); | 648 EXPECT_TRUE(l3->IsDrawn()); |
649 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); | 649 EXPECT_FALSE(l1->cc_layer()->hide_layer_and_subtree()); |
650 EXPECT_TRUE(l2->cc_layer()->DrawsContent()); | 650 EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree()); |
651 EXPECT_TRUE(l3->cc_layer()->DrawsContent()); | 651 EXPECT_FALSE(l3->cc_layer()->hide_layer_and_subtree()); |
652 | 652 |
653 compositor()->SetRootLayer(l1.get()); | 653 compositor()->SetRootLayer(l1.get()); |
654 | 654 |
655 Draw(); | 655 Draw(); |
656 | 656 |
657 l1->SetVisible(false); | 657 l1->SetVisible(false); |
658 EXPECT_FALSE(l1->IsDrawn()); | 658 EXPECT_FALSE(l1->IsDrawn()); |
659 EXPECT_FALSE(l2->IsDrawn()); | 659 EXPECT_FALSE(l2->IsDrawn()); |
660 EXPECT_FALSE(l3->IsDrawn()); | 660 EXPECT_FALSE(l3->IsDrawn()); |
661 EXPECT_FALSE(l1->cc_layer()->DrawsContent()); | 661 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); |
662 EXPECT_FALSE(l2->cc_layer()->DrawsContent()); | 662 EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree()); |
663 EXPECT_FALSE(l3->cc_layer()->DrawsContent()); | 663 EXPECT_FALSE(l3->cc_layer()->hide_layer_and_subtree()); |
664 | 664 |
665 l3->SetVisible(false); | 665 l3->SetVisible(false); |
666 EXPECT_FALSE(l1->IsDrawn()); | 666 EXPECT_FALSE(l1->IsDrawn()); |
667 EXPECT_FALSE(l2->IsDrawn()); | 667 EXPECT_FALSE(l2->IsDrawn()); |
668 EXPECT_FALSE(l3->IsDrawn()); | 668 EXPECT_FALSE(l3->IsDrawn()); |
669 EXPECT_FALSE(l1->cc_layer()->DrawsContent()); | 669 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); |
670 EXPECT_FALSE(l2->cc_layer()->DrawsContent()); | 670 EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree()); |
671 EXPECT_FALSE(l3->cc_layer()->DrawsContent()); | 671 EXPECT_TRUE(l3->cc_layer()->hide_layer_and_subtree()); |
672 | 672 |
673 l1->SetVisible(true); | 673 l1->SetVisible(true); |
674 EXPECT_TRUE(l1->IsDrawn()); | 674 EXPECT_TRUE(l1->IsDrawn()); |
675 EXPECT_TRUE(l2->IsDrawn()); | 675 EXPECT_TRUE(l2->IsDrawn()); |
676 EXPECT_FALSE(l3->IsDrawn()); | 676 EXPECT_FALSE(l3->IsDrawn()); |
677 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); | 677 EXPECT_FALSE(l1->cc_layer()->hide_layer_and_subtree()); |
678 EXPECT_TRUE(l2->cc_layer()->DrawsContent()); | 678 EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree()); |
679 EXPECT_FALSE(l3->cc_layer()->DrawsContent()); | 679 EXPECT_TRUE(l3->cc_layer()->hide_layer_and_subtree()); |
680 } | 680 } |
681 | 681 |
682 // Checks that stacking-related methods behave as advertised. | 682 // Checks that stacking-related methods behave as advertised. |
683 TEST_F(LayerWithNullDelegateTest, Stacking) { | 683 TEST_F(LayerWithNullDelegateTest, Stacking) { |
684 scoped_ptr<Layer> root(new Layer(LAYER_NOT_DRAWN)); | 684 scoped_ptr<Layer> root(new Layer(LAYER_NOT_DRAWN)); |
685 scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED)); | 685 scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED)); |
686 scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED)); | 686 scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED)); |
687 scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED)); | 687 scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED)); |
688 l1->set_name("1"); | 688 l1->set_name("1"); |
689 l2->set_name("2"); | 689 l2->set_name("2"); |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 l1->SetOpacity(0.5f); | 1375 l1->SetOpacity(0.5f); |
1376 | 1376 |
1377 // Change l1's cc::Layer. | 1377 // Change l1's cc::Layer. |
1378 l1->SwitchCCLayerForTest(); | 1378 l1->SwitchCCLayerForTest(); |
1379 | 1379 |
1380 // Ensure that the opacity animation completed. | 1380 // Ensure that the opacity animation completed. |
1381 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); | 1381 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); |
1382 } | 1382 } |
1383 | 1383 |
1384 } // namespace ui | 1384 } // namespace ui |
OLD | NEW |