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/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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 layer->SetBounds(bounds); | 635 layer->SetBounds(bounds); |
636 return layer; | 636 return layer; |
637 } | 637 } |
638 | 638 |
639 private: | 639 private: |
640 scoped_ptr<NullLayerDelegate> default_layer_delegate_; | 640 scoped_ptr<NullLayerDelegate> default_layer_delegate_; |
641 | 641 |
642 DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest); | 642 DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest); |
643 }; | 643 }; |
644 | 644 |
645 class FakeTexture : public Texture { | |
646 public: | |
647 FakeTexture(bool flipped, const gfx::Size& size, float device_scale_factor) | |
648 : Texture(flipped, size, device_scale_factor) {} | |
649 | |
650 virtual unsigned int PrepareTexture() OVERRIDE { return 0; } | |
651 | |
652 protected: | |
653 virtual ~FakeTexture() {} | |
654 }; | |
655 | |
656 TEST_F(LayerWithNullDelegateTest, EscapedDebugNames) { | 645 TEST_F(LayerWithNullDelegateTest, EscapedDebugNames) { |
657 scoped_ptr<Layer> layer(CreateLayer(LAYER_NOT_DRAWN)); | 646 scoped_ptr<Layer> layer(CreateLayer(LAYER_NOT_DRAWN)); |
658 std::string name = "\"\'\\/\b\f\n\r\t\n"; | 647 std::string name = "\"\'\\/\b\f\n\r\t\n"; |
659 layer->set_name(name); | 648 layer->set_name(name); |
660 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info = | 649 scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info = |
661 layer->TakeDebugInfo(); | 650 layer->TakeDebugInfo(); |
662 EXPECT_TRUE(!!debug_info); | 651 EXPECT_TRUE(!!debug_info); |
663 std::string json; | 652 std::string json; |
664 debug_info->AppendAsTraceFormat(&json); | 653 debug_info->AppendAsTraceFormat(&json); |
665 base::JSONReader json_reader; | 654 base::JSONReader json_reader; |
666 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(json)); | 655 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(json)); |
667 EXPECT_TRUE(!!debug_info_value); | 656 EXPECT_TRUE(!!debug_info_value); |
668 EXPECT_TRUE(debug_info_value->IsType(base::Value::TYPE_DICTIONARY)); | 657 EXPECT_TRUE(debug_info_value->IsType(base::Value::TYPE_DICTIONARY)); |
669 base::DictionaryValue* dictionary = 0; | 658 base::DictionaryValue* dictionary = 0; |
670 EXPECT_TRUE(debug_info_value->GetAsDictionary(&dictionary)); | 659 EXPECT_TRUE(debug_info_value->GetAsDictionary(&dictionary)); |
671 std::string roundtrip; | 660 std::string roundtrip; |
672 EXPECT_TRUE(dictionary->GetString("layer_name", &roundtrip)); | 661 EXPECT_TRUE(dictionary->GetString("layer_name", &roundtrip)); |
673 EXPECT_EQ(name, roundtrip); | 662 EXPECT_EQ(name, roundtrip); |
674 } | 663 } |
675 | 664 |
665 void ReturnMailbox(uint32 sync_point, bool is_lost) {} | |
danakj
2014/04/08 16:08:01
We should make sure this gets called in tests in t
piman
2014/04/08 23:17:46
Done.
| |
666 | |
676 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) { | 667 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) { |
677 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, | 668 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, |
678 gfx::Rect(20, 20, 400, 400))); | 669 gfx::Rect(20, 20, 400, 400))); |
679 l1->SetFillsBoundsOpaquely(true); | 670 l1->SetFillsBoundsOpaquely(true); |
680 l1->SetForceRenderSurface(true); | 671 l1->SetForceRenderSurface(true); |
681 l1->SetVisible(false); | 672 l1->SetVisible(false); |
682 | 673 |
683 EXPECT_EQ(gfx::PointF().ToString(), | 674 EXPECT_EQ(gfx::PointF().ToString(), |
684 l1->cc_layer()->anchor_point().ToString()); | 675 l1->cc_layer()->anchor_point().ToString()); |
685 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); | 676 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); |
686 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); | 677 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); |
687 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); | 678 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); |
688 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); | 679 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); |
689 | 680 |
690 cc::Layer* before_layer = l1->cc_layer(); | 681 cc::Layer* before_layer = l1->cc_layer(); |
691 | 682 |
692 scoped_refptr<Texture> texture = | 683 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), 0, 0); |
693 new FakeTexture(false, gfx::Size(10, 10), 1.f); | 684 l1->SetTextureMailbox( |
694 l1->SetExternalTexture(texture.get()); | 685 mailbox, |
686 cc::SingleReleaseCallback::Create(base::Bind(ReturnMailbox)), | |
687 gfx::Size(1, 1)); | |
695 | 688 |
696 EXPECT_NE(before_layer, l1->cc_layer()); | 689 EXPECT_NE(before_layer, l1->cc_layer()); |
697 | 690 |
698 EXPECT_EQ(gfx::PointF().ToString(), | 691 EXPECT_EQ(gfx::PointF().ToString(), |
699 l1->cc_layer()->anchor_point().ToString()); | 692 l1->cc_layer()->anchor_point().ToString()); |
700 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); | 693 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); |
701 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); | 694 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); |
702 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); | 695 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); |
703 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); | 696 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); |
704 } | 697 } |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 l1->SetOpacity(0.5f); | 1502 l1->SetOpacity(0.5f); |
1510 | 1503 |
1511 // Change l1's cc::Layer. | 1504 // Change l1's cc::Layer. |
1512 l1->SwitchCCLayerForTest(); | 1505 l1->SwitchCCLayerForTest(); |
1513 | 1506 |
1514 // Ensure that the opacity animation completed. | 1507 // Ensure that the opacity animation completed. |
1515 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); | 1508 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); |
1516 } | 1509 } |
1517 | 1510 |
1518 } // namespace ui | 1511 } // namespace ui |
OLD | NEW |