diff options
author | wjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-20 01:41:58 +0000 |
---|---|---|
committer | wjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-20 01:41:58 +0000 |
commit | f250da5b5963b560199fba444e7bc1276a2a96a1 (patch) | |
tree | bc1956eff93aca613b1911e34caebc498c21f2fc /cc | |
parent | e570ec1d84afa826f9fadb44f467765e73ff1a0d (diff) | |
download | chromium_src-f250da5b5963b560199fba444e7bc1276a2a96a1.zip chromium_src-f250da5b5963b560199fba444e7bc1276a2a96a1.tar.gz chromium_src-f250da5b5963b560199fba444e7bc1276a2a96a1.tar.bz2 |
Chromify solid_color_layer_impl_unittest.cc
BUG=none
Review URL: https://chromiumcodereview.appspot.com/12600032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/solid_color_layer_impl_unittest.cc | 241 |
1 files changed, 122 insertions, 119 deletions
diff --git a/cc/layers/solid_color_layer_impl_unittest.cc b/cc/layers/solid_color_layer_impl_unittest.cc index 039732e..8943035 100644 --- a/cc/layers/solid_color_layer_impl_unittest.cc +++ b/cc/layers/solid_color_layer_impl_unittest.cc @@ -4,6 +4,8 @@ #include "cc/layers/solid_color_layer_impl.h" +#include <vector> + #include "cc/layers/append_quads_data.h" #include "cc/layers/solid_color_layer.h" #include "cc/quads/solid_color_draw_quad.h" @@ -18,145 +20,146 @@ namespace cc { namespace { -TEST(SolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) -{ - MockQuadCuller quadCuller; - gfx::Size layerSize = gfx::Size(800, 600); - gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); - - FakeImplProxy proxy; - FakeLayerTreeHostImpl hostImpl(&proxy); - scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl.active_tree(), 1); - layer->draw_properties().visible_content_rect = visibleContentRect; - layer->SetBounds(layerSize); - layer->SetContentBounds(layerSize); - layer->CreateRenderSurface(); - layer->draw_properties().render_target = layer.get(); - - AppendQuadsData data; - layer->AppendQuads(&quadCuller, &data); - - LayerTestCommon::verifyQuadsExactlyCoverRect(quadCuller.quadList(), visibleContentRect); +TEST(SolidColorLayerImplTest, VerifyTilingCompleteAndNoOverlap) { + MockQuadCuller quad_culler; + gfx::Size layer_size = gfx::Size(800, 600); + gfx::Rect visible_content_rect = gfx::Rect(gfx::Point(), layer_size); + + FakeImplProxy proxy; + FakeLayerTreeHostImpl host_impl(&proxy); + scoped_ptr<SolidColorLayerImpl> layer = + SolidColorLayerImpl::Create(host_impl.active_tree(), 1); + layer->draw_properties().visible_content_rect = visible_content_rect; + layer->SetBounds(layer_size); + layer->SetContentBounds(layer_size); + layer->CreateRenderSurface(); + layer->draw_properties().render_target = layer.get(); + + AppendQuadsData data; + layer->AppendQuads(&quad_culler, &data); + + LayerTestCommon::verifyQuadsExactlyCoverRect(quad_culler.quadList(), + visible_content_rect); } -TEST(SolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) -{ - SkColor testColor = 0xFFA55AFF; - - MockQuadCuller quadCuller; - gfx::Size layerSize = gfx::Size(100, 100); - gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); - - FakeImplProxy proxy; - FakeLayerTreeHostImpl hostImpl(&proxy); - scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl.active_tree(), 1); - layer->draw_properties().visible_content_rect = visibleContentRect; - layer->SetBounds(layerSize); - layer->SetContentBounds(layerSize); - layer->SetBackgroundColor(testColor); - layer->CreateRenderSurface(); - layer->draw_properties().render_target = layer.get(); - - AppendQuadsData data; - layer->AppendQuads(&quadCuller, &data); - - ASSERT_EQ(quadCuller.quadList().size(), 1U); - EXPECT_EQ(SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0])->color, testColor); +TEST(SolidColorLayerImplTest, VerifyCorrectBackgroundColorInQuad) { + SkColor test_color = 0xFFA55AFF; + + MockQuadCuller quad_culler; + gfx::Size layer_size = gfx::Size(100, 100); + gfx::Rect visible_content_rect = gfx::Rect(gfx::Point(), layer_size); + + FakeImplProxy proxy; + FakeLayerTreeHostImpl host_impl(&proxy); + scoped_ptr<SolidColorLayerImpl> layer = + SolidColorLayerImpl::Create(host_impl.active_tree(), 1); + layer->draw_properties().visible_content_rect = visible_content_rect; + layer->SetBounds(layer_size); + layer->SetContentBounds(layer_size); + layer->SetBackgroundColor(test_color); + layer->CreateRenderSurface(); + layer->draw_properties().render_target = layer.get(); + + AppendQuadsData data; + layer->AppendQuads(&quad_culler, &data); + + ASSERT_EQ(quad_culler.quadList().size(), 1U); + EXPECT_EQ(SolidColorDrawQuad::MaterialCast(quad_culler.quadList()[0])->color, + test_color); } -TEST(SolidColorLayerImplTest, verifyCorrectOpacityInQuad) -{ - const float opacity = 0.5f; - - MockQuadCuller quadCuller; - gfx::Size layerSize = gfx::Size(100, 100); - gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); - - FakeImplProxy proxy; - FakeLayerTreeHostImpl hostImpl(&proxy); - scoped_ptr<SolidColorLayerImpl> layer = SolidColorLayerImpl::Create(hostImpl.active_tree(), 1); - layer->draw_properties().visible_content_rect = visibleContentRect; - layer->SetBounds(layerSize); - layer->SetContentBounds(layerSize); - layer->draw_properties().opacity = opacity; - layer->CreateRenderSurface(); - layer->draw_properties().render_target = layer.get(); - - AppendQuadsData data; - layer->AppendQuads(&quadCuller, &data); - - ASSERT_EQ(quadCuller.quadList().size(), 1U); - EXPECT_EQ(opacity, SolidColorDrawQuad::MaterialCast(quadCuller.quadList()[0])->opacity()); +TEST(SolidColorLayerImplTest, VerifyCorrectOpacityInQuad) { + const float opacity = 0.5f; + + MockQuadCuller quad_culler; + gfx::Size layer_size = gfx::Size(100, 100); + gfx::Rect visible_content_rect = gfx::Rect(gfx::Point(), layer_size); + + FakeImplProxy proxy; + FakeLayerTreeHostImpl host_impl(&proxy); + scoped_ptr<SolidColorLayerImpl> layer = + SolidColorLayerImpl::Create(host_impl.active_tree(), 1); + layer->draw_properties().visible_content_rect = visible_content_rect; + layer->SetBounds(layer_size); + layer->SetContentBounds(layer_size); + layer->draw_properties().opacity = opacity; + layer->CreateRenderSurface(); + layer->draw_properties().render_target = layer.get(); + + AppendQuadsData data; + layer->AppendQuads(&quad_culler, &data); + + ASSERT_EQ(quad_culler.quadList().size(), 1U); + EXPECT_EQ(opacity, + SolidColorDrawQuad::MaterialCast(quad_culler.quadList()[0]) + ->opacity()); } -TEST(SolidColorLayerImplTest, verifyOpaqueRect) -{ - FakeImplProxy proxy; - FakeLayerTreeHostImpl hostImpl(&proxy); +TEST(SolidColorLayerImplTest, VerifyOpaqueRect) { + FakeImplProxy proxy; + FakeLayerTreeHostImpl host_impl(&proxy); - gfx::Size layerSize = gfx::Size(100, 100); - gfx::Rect visibleContentRect = gfx::Rect(gfx::Point(), layerSize); + gfx::Size layer_size = gfx::Size(100, 100); + gfx::Rect visible_content_rect = gfx::Rect(gfx::Point(), layer_size); - scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create(); - layer->SetBounds(layerSize); - layer->SetForceRenderSurface(true); + scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create(); + layer->SetBounds(layer_size); + layer->SetForceRenderSurface(true); - scoped_refptr<Layer> root = Layer::Create(); - root->AddChild(layer); + scoped_refptr<Layer> root = Layer::Create(); + root->AddChild(layer); - std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; - LayerTreeHostCommon::calculateDrawProperties( - root, - gfx::Size(500, 500), - 1, - 1, - 1024, - false, - renderSurfaceLayerList); + std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; + LayerTreeHostCommon::calculateDrawProperties( + root, gfx::Size(500, 500), 1, 1, 1024, false, renderSurfaceLayerList); - EXPECT_FALSE(layer->contents_opaque()); - layer->SetBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30)); - EXPECT_TRUE(layer->contents_opaque()); + EXPECT_FALSE(layer->contents_opaque()); + layer->SetBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30)); + EXPECT_TRUE(layer->contents_opaque()); + { + scoped_ptr<SolidColorLayerImpl> layer_impl = + SolidColorLayerImpl::Create(host_impl.active_tree(), layer->id()); + layer->PushPropertiesTo(layer_impl.get()); - { - scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::Create(hostImpl.active_tree(), layer->id()); - layer->PushPropertiesTo(layerImpl.get()); + // The impl layer should call itself opaque as well. + EXPECT_TRUE(layer_impl->contents_opaque()); - // The impl layer should call itself opaque as well. - EXPECT_TRUE(layerImpl->contents_opaque()); + // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect + // should be the full tile. + layer_impl->draw_properties().opacity = 1; - // Impl layer has 1 opacity, and the color is opaque, so the opaqueRect should be the full tile. - layerImpl->draw_properties().opacity = 1; - - MockQuadCuller quadCuller; - AppendQuadsData data; - layerImpl->AppendQuads(&quadCuller, &data); - - ASSERT_EQ(quadCuller.quadList().size(), 1U); - EXPECT_EQ(visibleContentRect.ToString(), quadCuller.quadList()[0]->opaque_rect.ToString()); - } + MockQuadCuller quad_culler; + AppendQuadsData data; + layer_impl->AppendQuads(&quad_culler, &data); - EXPECT_TRUE(layer->contents_opaque()); - layer->SetBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30)); - EXPECT_FALSE(layer->contents_opaque()); + ASSERT_EQ(quad_culler.quadList().size(), 1U); + EXPECT_EQ(visible_content_rect.ToString(), + quad_culler.quadList()[0]->opaque_rect.ToString()); + } - { - scoped_ptr<SolidColorLayerImpl> layerImpl = SolidColorLayerImpl::Create(hostImpl.active_tree(), layer->id()); - layer->PushPropertiesTo(layerImpl.get()); + EXPECT_TRUE(layer->contents_opaque()); + layer->SetBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30)); + EXPECT_FALSE(layer->contents_opaque()); + { + scoped_ptr<SolidColorLayerImpl> layer_impl = + SolidColorLayerImpl::Create(host_impl.active_tree(), layer->id()); + layer->PushPropertiesTo(layer_impl.get()); - // The impl layer should callnot itself opaque anymore. - EXPECT_FALSE(layerImpl->contents_opaque()); + // The impl layer should callnot itself opaque anymore. + EXPECT_FALSE(layer_impl->contents_opaque()); - // Impl layer has 1 opacity, but the color is not opaque, so the opaque_rect should be empty. - layerImpl->draw_properties().opacity = 1; + // Impl layer has 1 opacity, but the color is not opaque, so the opaque_rect + // should be empty. + layer_impl->draw_properties().opacity = 1; - MockQuadCuller quadCuller; - AppendQuadsData data; - layerImpl->AppendQuads(&quadCuller, &data); + MockQuadCuller quad_culler; + AppendQuadsData data; + layer_impl->AppendQuads(&quad_culler, &data); - ASSERT_EQ(quadCuller.quadList().size(), 1U); - EXPECT_EQ(gfx::Rect().ToString(), quadCuller.quadList()[0]->opaque_rect.ToString()); - } + ASSERT_EQ(quad_culler.quadList().size(), 1U); + EXPECT_EQ(gfx::Rect().ToString(), + quad_culler.quadList()[0]->opaque_rect.ToString()); + } } } // namespace |