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

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

Issue 1912893002: cc : Stop pushing properties not used by LayerImpl to LayerImpl. (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | 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 "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 base::DictionaryValue* dictionary = 0; 727 base::DictionaryValue* dictionary = 0;
728 EXPECT_TRUE(debug_info_value->GetAsDictionary(&dictionary)); 728 EXPECT_TRUE(debug_info_value->GetAsDictionary(&dictionary));
729 std::string roundtrip; 729 std::string roundtrip;
730 EXPECT_TRUE(dictionary->GetString("layer_name", &roundtrip)); 730 EXPECT_TRUE(dictionary->GetString("layer_name", &roundtrip));
731 EXPECT_EQ(name, roundtrip); 731 EXPECT_EQ(name, roundtrip);
732 } 732 }
733 733
734 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) { 734 TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) {
735 std::unique_ptr<Layer> l1(CreateLayer(LAYER_SOLID_COLOR)); 735 std::unique_ptr<Layer> l1(CreateLayer(LAYER_SOLID_COLOR));
736 l1->SetFillsBoundsOpaquely(true); 736 l1->SetFillsBoundsOpaquely(true);
737 l1->SetForceRenderSurface(true);
738 l1->SetVisible(false); 737 l1->SetVisible(false);
739 l1->SetBounds(gfx::Rect(4, 5)); 738 l1->SetBounds(gfx::Rect(4, 5));
740 739
741 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin()); 740 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
742 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent()); 741 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
743 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque()); 742 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
744 EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
745 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree()); 743 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
746 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds()); 744 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
747 745
748 cc::Layer* before_layer = l1->cc_layer_for_testing(); 746 cc::Layer* before_layer = l1->cc_layer_for_testing();
749 747
750 bool callback1_run = false; 748 bool callback1_run = false;
751 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0); 749 cc::TextureMailbox mailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0);
752 l1->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create( 750 l1->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(
753 base::Bind(ReturnMailbox, &callback1_run)), 751 base::Bind(ReturnMailbox, &callback1_run)),
754 gfx::Size(10, 10)); 752 gfx::Size(10, 10));
755 753
756 EXPECT_NE(before_layer, l1->cc_layer_for_testing()); 754 EXPECT_NE(before_layer, l1->cc_layer_for_testing());
757 755
758 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin()); 756 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
759 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent()); 757 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
760 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque()); 758 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
761 EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
762 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree()); 759 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
763 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds()); 760 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
764 EXPECT_FALSE(callback1_run); 761 EXPECT_FALSE(callback1_run);
765 762
766 bool callback2_run = false; 763 bool callback2_run = false;
767 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0); 764 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0);
768 l1->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create( 765 l1->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(
769 base::Bind(ReturnMailbox, &callback2_run)), 766 base::Bind(ReturnMailbox, &callback2_run)),
770 gfx::Size(10, 10)); 767 gfx::Size(10, 10));
771 EXPECT_TRUE(callback1_run); 768 EXPECT_TRUE(callback1_run);
772 EXPECT_FALSE(callback2_run); 769 EXPECT_FALSE(callback2_run);
773 770
774 // Show solid color instead. 771 // Show solid color instead.
775 l1->SetShowSolidColorContent(); 772 l1->SetShowSolidColorContent();
776 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin()); 773 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
777 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent()); 774 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
778 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque()); 775 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
779 EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
780 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree()); 776 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
781 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds()); 777 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
782 EXPECT_TRUE(callback2_run); 778 EXPECT_TRUE(callback2_run);
783 779
784 before_layer = l1->cc_layer_for_testing(); 780 before_layer = l1->cc_layer_for_testing();
785 781
786 // Back to a texture, without changing the bounds of the layer or the texture. 782 // Back to a texture, without changing the bounds of the layer or the texture.
787 bool callback3_run = false; 783 bool callback3_run = false;
788 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0); 784 mailbox = cc::TextureMailbox(gpu::Mailbox::Generate(), gpu::SyncToken(), 0);
789 l1->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create( 785 l1->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create(
790 base::Bind(ReturnMailbox, &callback3_run)), 786 base::Bind(ReturnMailbox, &callback3_run)),
791 gfx::Size(10, 10)); 787 gfx::Size(10, 10));
792 788
793 EXPECT_NE(before_layer, l1->cc_layer_for_testing()); 789 EXPECT_NE(before_layer, l1->cc_layer_for_testing());
794 790
795 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin()); 791 EXPECT_EQ(gfx::Point3F(), l1->cc_layer_for_testing()->transform_origin());
796 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent()); 792 EXPECT_TRUE(l1->cc_layer_for_testing()->DrawsContent());
797 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque()); 793 EXPECT_TRUE(l1->cc_layer_for_testing()->contents_opaque());
798 EXPECT_TRUE(l1->cc_layer_for_testing()->force_render_surface());
799 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree()); 794 EXPECT_TRUE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
800 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds()); 795 EXPECT_EQ(gfx::Size(4, 5), l1->cc_layer_for_testing()->bounds());
801 EXPECT_FALSE(callback3_run); 796 EXPECT_FALSE(callback3_run);
802 797
803 // Release the on |l1| mailbox to clean up the test. 798 // Release the on |l1| mailbox to clean up the test.
804 l1->SetShowSolidColorContent(); 799 l1->SetShowSolidColorContent();
805 } 800 }
806 801
807 // Various visibile/drawn assertions. 802 // Various visibile/drawn assertions.
808 TEST_F(LayerWithNullDelegateTest, Visibility) { 803 TEST_F(LayerWithNullDelegateTest, Visibility) {
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 root->SetOpacity(0.5f); 1877 root->SetOpacity(0.5f);
1883 WaitForSwap(); 1878 WaitForSwap();
1884 EXPECT_EQ(1u, animation_observer.animation_step_count()); 1879 EXPECT_EQ(1u, animation_observer.animation_step_count());
1885 1880
1886 EXPECT_FALSE(animation_observer.shutdown()); 1881 EXPECT_FALSE(animation_observer.shutdown());
1887 ResetCompositor(); 1882 ResetCompositor();
1888 EXPECT_TRUE(animation_observer.shutdown()); 1883 EXPECT_TRUE(animation_observer.shutdown());
1889 } 1884 }
1890 1885
1891 } // namespace ui 1886 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698