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/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 622 |
623 NullLayerDelegate delegate; | 623 NullLayerDelegate delegate; |
624 l1->set_delegate(&delegate); | 624 l1->set_delegate(&delegate); |
625 l2->set_delegate(&delegate); | 625 l2->set_delegate(&delegate); |
626 l3->set_delegate(&delegate); | 626 l3->set_delegate(&delegate); |
627 | 627 |
628 // Layers should initially be drawn. | 628 // Layers should initially be drawn. |
629 EXPECT_TRUE(l1->IsDrawn()); | 629 EXPECT_TRUE(l1->IsDrawn()); |
630 EXPECT_TRUE(l2->IsDrawn()); | 630 EXPECT_TRUE(l2->IsDrawn()); |
631 EXPECT_TRUE(l3->IsDrawn()); | 631 EXPECT_TRUE(l3->IsDrawn()); |
632 EXPECT_EQ(1.f, l1->cc_layer()->opacity()); | 632 EXPECT_TRUE(l1->cc_layer()->drawsContent()); |
633 EXPECT_EQ(1.f, l2->cc_layer()->opacity()); | 633 EXPECT_TRUE(l2->cc_layer()->drawsContent()); |
634 EXPECT_EQ(1.f, l3->cc_layer()->opacity()); | 634 EXPECT_TRUE(l3->cc_layer()->drawsContent()); |
635 | 635 |
636 compositor()->SetRootLayer(l1.get()); | 636 compositor()->SetRootLayer(l1.get()); |
637 | 637 |
638 Draw(); | 638 Draw(); |
639 | 639 |
640 l1->SetVisible(false); | 640 l1->SetVisible(false); |
641 EXPECT_FALSE(l1->IsDrawn()); | 641 EXPECT_FALSE(l1->IsDrawn()); |
642 EXPECT_FALSE(l2->IsDrawn()); | 642 EXPECT_FALSE(l2->IsDrawn()); |
643 EXPECT_FALSE(l3->IsDrawn()); | 643 EXPECT_FALSE(l3->IsDrawn()); |
644 EXPECT_EQ(0.f, l1->cc_layer()->opacity()); | 644 EXPECT_FALSE(l1->cc_layer()->drawsContent()); |
| 645 EXPECT_FALSE(l2->cc_layer()->drawsContent()); |
| 646 EXPECT_FALSE(l3->cc_layer()->drawsContent()); |
645 | 647 |
646 l3->SetVisible(false); | 648 l3->SetVisible(false); |
647 EXPECT_FALSE(l1->IsDrawn()); | 649 EXPECT_FALSE(l1->IsDrawn()); |
648 EXPECT_FALSE(l2->IsDrawn()); | 650 EXPECT_FALSE(l2->IsDrawn()); |
649 EXPECT_FALSE(l3->IsDrawn()); | 651 EXPECT_FALSE(l3->IsDrawn()); |
650 EXPECT_EQ(0.f, l3->cc_layer()->opacity()); | 652 EXPECT_FALSE(l1->cc_layer()->drawsContent()); |
| 653 EXPECT_FALSE(l2->cc_layer()->drawsContent()); |
| 654 EXPECT_FALSE(l3->cc_layer()->drawsContent()); |
651 | 655 |
652 l1->SetVisible(true); | 656 l1->SetVisible(true); |
653 EXPECT_TRUE(l1->IsDrawn()); | 657 EXPECT_TRUE(l1->IsDrawn()); |
654 EXPECT_TRUE(l2->IsDrawn()); | 658 EXPECT_TRUE(l2->IsDrawn()); |
655 EXPECT_FALSE(l3->IsDrawn()); | 659 EXPECT_FALSE(l3->IsDrawn()); |
656 EXPECT_EQ(1.f, l1->cc_layer()->opacity()); | 660 EXPECT_TRUE(l1->cc_layer()->drawsContent()); |
| 661 EXPECT_TRUE(l2->cc_layer()->drawsContent()); |
| 662 EXPECT_FALSE(l3->cc_layer()->drawsContent()); |
657 } | 663 } |
658 | 664 |
659 // Checks that stacking-related methods behave as advertised. | 665 // Checks that stacking-related methods behave as advertised. |
660 TEST_F(LayerWithNullDelegateTest, Stacking) { | 666 TEST_F(LayerWithNullDelegateTest, Stacking) { |
661 scoped_ptr<Layer> root(new Layer(LAYER_NOT_DRAWN)); | 667 scoped_ptr<Layer> root(new Layer(LAYER_NOT_DRAWN)); |
662 scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED)); | 668 scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED)); |
663 scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED)); | 669 scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED)); |
664 scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED)); | 670 scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED)); |
665 l1->set_name("1"); | 671 l1->set_name("1"); |
666 l2->set_name("2"); | 672 l2->set_name("2"); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 | 1239 |
1234 // Resize layer. | 1240 // Resize layer. |
1235 child->SetBounds(gfx::Rect(200, 200, 400, 400)); | 1241 child->SetBounds(gfx::Rect(200, 200, 400, 400)); |
1236 child->SetVisible(true); | 1242 child->SetVisible(true); |
1237 EXPECT_TRUE(schedule_draw_invoked_); | 1243 EXPECT_TRUE(schedule_draw_invoked_); |
1238 DrawTree(root.get()); | 1244 DrawTree(root.get()); |
1239 EXPECT_TRUE(delegate.painted()); | 1245 EXPECT_TRUE(delegate.painted()); |
1240 } | 1246 } |
1241 | 1247 |
1242 } // namespace ui | 1248 } // namespace ui |
OLD | NEW |