diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-24 23:15:27 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-24 23:15:27 +0000 |
commit | 3b4b2f071a372d1645ab6d121c37c18c29458705 (patch) | |
tree | 83e5f0c5869e2bed76e98430c0146cd011cde76c /ui | |
parent | 1b1ae7a610c367b24272bfa12dd915a721ba3c9e (diff) | |
download | chromium_src-3b4b2f071a372d1645ab6d121c37c18c29458705.zip chromium_src-3b4b2f071a372d1645ab6d121c37c18c29458705.tar.gz chromium_src-3b4b2f071a372d1645ab6d121c37c18c29458705.tar.bz2 |
ui: Add LayerWithDelegateTest.SwitchLayerPreservesCCLayerState test
Add a test that verifies that ui::Layer's SwitchLayer() method, which
replaces its backing cc::Layer with a new instance, preserves states
that the ui::Layer had set on the old cc::Layer.
R=backer, piman
BUG=252494,242572
Review URL: https://chromiumcodereview.appspot.com/17602002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/layer_unittest.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc index 0be8a0a..8188cd6 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc @@ -629,6 +629,50 @@ class LayerWithNullDelegateTest : public LayerWithDelegateTest { DISALLOW_COPY_AND_ASSIGN(LayerWithNullDelegateTest); }; +class FakeTexture : public Texture { + public: + FakeTexture(bool flipped, const gfx::Size& size, float device_scale_factor) + : Texture(flipped, size, device_scale_factor) {} + + virtual unsigned int PrepareTexture() OVERRIDE { return 0; } + virtual WebKit::WebGraphicsContext3D* HostContext3D() OVERRIDE { + return NULL; + } + + protected: + virtual ~FakeTexture() {} +}; + +TEST_F(LayerWithNullDelegateTest, SwitchLayerPreservesCCLayerState) { + scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, + gfx::Rect(20, 20, 400, 400))); + l1->SetFillsBoundsOpaquely(true); + l1->SetForceRenderSurface(true); + l1->SetVisible(false); + + EXPECT_EQ(gfx::PointF().ToString(), + l1->cc_layer()->anchor_point().ToString()); + EXPECT_TRUE(l1->cc_layer()->DrawsContent()); + EXPECT_TRUE(l1->cc_layer()->contents_opaque()); + EXPECT_TRUE(l1->cc_layer()->force_render_surface()); + EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); + + cc::Layer* before_layer = l1->cc_layer(); + + scoped_refptr<Texture> texture = + new FakeTexture(false, gfx::Size(10, 10), 1.f); + l1->SetExternalTexture(texture.get()); + + EXPECT_NE(before_layer, l1->cc_layer()); + + EXPECT_EQ(gfx::PointF().ToString(), + l1->cc_layer()->anchor_point().ToString()); + EXPECT_TRUE(l1->cc_layer()->DrawsContent()); + EXPECT_TRUE(l1->cc_layer()->contents_opaque()); + EXPECT_TRUE(l1->cc_layer()->force_render_surface()); + EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree()); +} + // Various visibile/drawn assertions. TEST_F(LayerWithNullDelegateTest, Visibility) { scoped_ptr<Layer> l1(new Layer(LAYER_TEXTURED)); |