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

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

Issue 228083002: Make ReflectorImpl use mailboxes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/compositor/layer_owner_delegate.h ('k') | ui/views/view.cc » ('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 "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
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(bool* run, uint32 sync_point, bool is_lost) {
666 *run = true;
667 }
668
676 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) { 669 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
677 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, 670 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
678 gfx::Rect(20, 20, 400, 400))); 671 gfx::Rect(20, 20, 400, 400)));
679 l1->SetFillsBoundsOpaquely(true); 672 l1->SetFillsBoundsOpaquely(true);
680 l1->SetForceRenderSurface(true); 673 l1->SetForceRenderSurface(true);
681 l1->SetVisible(false); 674 l1->SetVisible(false);
682 675
683 EXPECT_EQ(gfx::PointF().ToString(), 676 EXPECT_EQ(gfx::PointF().ToString(),
684 l1->cc_layer()->anchor_point().ToString()); 677 l1->cc_layer()->anchor_point().ToString());
685 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); 678 EXPECT_TRUE(l1->cc_layer()->DrawsContent());
686 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); 679 EXPECT_TRUE(l1->cc_layer()->contents_opaque());
687 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); 680 EXPECT_TRUE(l1->cc_layer()->force_render_surface());
688 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); 681 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
689 682
690 cc::Layer* before_layer = l1->cc_layer(); 683 cc::Layer* before_layer = l1->cc_layer();
691 684
692 scoped_refptr<Texture> texture = 685 bool callback1_run = false;
693 new FakeTexture(false, gfx::Size(10, 10), 1.f); 686 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), 0, 0);
694 l1->SetExternalTexture(texture.get()); 687 l1->SetTextureMailbox(mailbox,
688 cc::SingleReleaseCallback::Create(
689 base::Bind(ReturnMailbox, &callback1_run)),
690 gfx::Size(1, 1));
695 691
696 EXPECT_NE(before_layer, l1->cc_layer()); 692 EXPECT_NE(before_layer, l1->cc_layer());
697 693
698 EXPECT_EQ(gfx::PointF().ToString(), 694 EXPECT_EQ(gfx::PointF().ToString(),
699 l1->cc_layer()->anchor_point().ToString()); 695 l1->cc_layer()->anchor_point().ToString());
700 EXPECT_TRUE(l1->cc_layer()->DrawsContent()); 696 EXPECT_TRUE(l1->cc_layer()->DrawsContent());
701 EXPECT_TRUE(l1->cc_layer()->contents_opaque()); 697 EXPECT_TRUE(l1->cc_layer()->contents_opaque());
702 EXPECT_TRUE(l1->cc_layer()->force_render_surface()); 698 EXPECT_TRUE(l1->cc_layer()->force_render_surface());
703 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); 699 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
700 EXPECT_FALSE(callback1_run);
701
702 bool callback2_run = false;
703 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), 0, 0);
704 l1->SetTextureMailbox(mailbox,
705 cc::SingleReleaseCallback::Create(
706 base::Bind(ReturnMailbox, &callback2_run)),
707 gfx::Size(1, 1));
708 EXPECT_TRUE(callback1_run);
709 EXPECT_FALSE(callback2_run);
710
711 l1->SetShowPaintedContent();
712 EXPECT_EQ(gfx::PointF().ToString(),
713 l1->cc_layer()->anchor_point().ToString());
714 EXPECT_TRUE(l1->cc_layer()->DrawsContent());
715 EXPECT_TRUE(l1->cc_layer()->contents_opaque());
716 EXPECT_TRUE(l1->cc_layer()->force_render_surface());
717 EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
718 EXPECT_TRUE(callback2_run);
704 } 719 }
705 720
706 // Various visibile/drawn assertions. 721 // Various visibile/drawn assertions.
707 TEST_F(LayerWithNullDelegateTest, Visibility) { 722 TEST_F(LayerWithNullDelegateTest, Visibility) {
708 scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED)); 723 scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED));
709 scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED)); 724 scoped_ptr<Layer> l2(new Layer(LAYER_TEXTURED));
710 scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED)); 725 scoped_ptr<Layer> l3(new Layer(LAYER_TEXTURED));
711 l1->Add(l2.get()); 726 l1->Add(l2.get());
712 l2->Add(l3.get()); 727 l2->Add(l3.get());
713 728
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 l1->SetOpacity(0.5f); 1524 l1->SetOpacity(0.5f);
1510 1525
1511 // Change l1's cc::Layer. 1526 // Change l1's cc::Layer.
1512 l1->SwitchCCLayerForTest(); 1527 l1->SwitchCCLayerForTest();
1513 1528
1514 // Ensure that the opacity animation completed. 1529 // Ensure that the opacity animation completed.
1515 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); 1530 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f);
1516 } 1531 }
1517 1532
1518 } // namespace ui 1533 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_owner_delegate.h ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698