Index: cc/tiled_layer_impl_unittest.cc |
diff --git a/cc/tiled_layer_impl_unittest.cc b/cc/tiled_layer_impl_unittest.cc |
index 257b07c7b6fa177ced2a4974fd3deb29047b8f5c..e0f5433a9119340d9611c08a02736533c1885b2f 100644 |
--- a/cc/tiled_layer_impl_unittest.cc |
+++ b/cc/tiled_layer_impl_unittest.cc |
@@ -7,6 +7,8 @@ |
#include "cc/append_quads_data.h" |
#include "cc/layer_tiling_data.h" |
#include "cc/single_thread_proxy.h" |
+#include "cc/test/fake_impl_proxy.h" |
+#include "cc/test/fake_layer_tree_host_impl.h" |
#include "cc/test/layer_test_common.h" |
#include "cc/test/mock_quad_culler.h" |
#include "cc/tile_draw_quad.h" |
@@ -16,33 +18,58 @@ |
using namespace LayerTestCommon; |
namespace cc { |
+ |
namespace { |
-// Create a default tiled layer with textures for all tiles and a default |
-// visibility of the entire layer size. |
-static scoped_ptr<TiledLayerImpl> createLayer(const gfx::Size& tileSize, const gfx::Size& layerSize, LayerTilingData::BorderTexelOption borderTexels) |
+class TiledLayerImplTest : public testing::Test |
{ |
- scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(1); |
- scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(tileSize, borderTexels); |
- tiler->setBounds(layerSize); |
- layer->setTilingData(*tiler); |
- layer->setSkipsDraw(false); |
- layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layerSize); |
- layer->drawProperties().opacity = 1; |
- layer->setBounds(layerSize); |
- layer->setContentBounds(layerSize); |
- layer->createRenderSurface(); |
- layer->drawProperties().render_target = layer.get(); |
- |
- ResourceProvider::ResourceId resourceId = 1; |
- for (int i = 0; i < tiler->numTilesX(); ++i) |
- for (int j = 0; j < tiler->numTilesY(); ++j) |
- layer->pushTileProperties(i, j, resourceId++, gfx::Rect(0, 0, 1, 1), false); |
- |
- return layer.Pass(); |
-} |
+public: |
+ TiledLayerImplTest() |
+ : m_hostImpl(&m_proxy) |
+ { |
+ } |
+ |
+ // Create a default tiled layer with textures for all tiles and a default |
+ // visibility of the entire layer size. |
+ scoped_ptr<TiledLayerImpl> createLayer(const gfx::Size& tileSize, const gfx::Size& layerSize, LayerTilingData::BorderTexelOption borderTexels) |
+ { |
+ scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(&m_hostImpl, 1); |
+ scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(tileSize, borderTexels); |
+ tiler->setBounds(layerSize); |
+ layer->setTilingData(*tiler); |
+ layer->setSkipsDraw(false); |
+ layer->drawProperties().visible_content_rect = gfx::Rect(gfx::Point(), layerSize); |
+ layer->drawProperties().opacity = 1; |
+ layer->setBounds(layerSize); |
+ layer->setContentBounds(layerSize); |
+ layer->createRenderSurface(); |
+ layer->drawProperties().render_target = layer.get(); |
+ |
+ ResourceProvider::ResourceId resourceId = 1; |
+ for (int i = 0; i < tiler->numTilesX(); ++i) |
+ for (int j = 0; j < tiler->numTilesY(); ++j) |
+ layer->pushTileProperties(i, j, resourceId++, gfx::Rect(0, 0, 1, 1), false); |
+ |
+ return layer.Pass(); |
+ } |
+ |
+ void getQuads(QuadList& quads, SharedQuadStateList& sharedStates, gfx::Size tileSize, const gfx::Size& layerSize, LayerTilingData::BorderTexelOption borderTexelOption, const gfx::Rect& visibleContentRect) |
+ { |
+ scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexelOption); |
+ layer->drawProperties().visible_content_rect = visibleContentRect; |
+ layer->setBounds(layerSize); |
+ |
+ MockQuadCuller quadCuller(quads, sharedStates); |
+ AppendQuadsData data; |
+ layer->appendQuads(quadCuller, data); |
+ } |
-TEST(TiledLayerImplTest, emptyQuadList) |
+protected: |
+ FakeImplProxy m_proxy; |
+ FakeLayerTreeHostImpl m_hostImpl; |
+}; |
+ |
+TEST_F(TiledLayerImplTest, emptyQuadList) |
{ |
const gfx::Size tileSize(90, 90); |
const int numTilesX = 8; |
@@ -95,7 +122,7 @@ TEST(TiledLayerImplTest, emptyQuadList) |
} |
} |
-TEST(TiledLayerImplTest, checkerboarding) |
+TEST_F(TiledLayerImplTest, checkerboarding) |
{ |
const gfx::Size tileSize(10, 10); |
const int numTilesX = 2; |
@@ -132,65 +159,60 @@ TEST(TiledLayerImplTest, checkerboarding) |
} |
} |
-static void getQuads(QuadList& quads, SharedQuadStateList& sharedStates, gfx::Size tileSize, const gfx::Size& layerSize, LayerTilingData::BorderTexelOption borderTexelOption, const gfx::Rect& visibleContentRect) |
-{ |
- scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexelOption); |
- layer->drawProperties().visible_content_rect = visibleContentRect; |
- layer->setBounds(layerSize); |
- |
- MockQuadCuller quadCuller(quads, sharedStates); |
- AppendQuadsData data; |
- layer->appendQuads(quadCuller, data); |
-} |
- |
// Test with both border texels and without. |
-#define WITH_AND_WITHOUT_BORDER_TEST(testFixtureName) \ |
- TEST(TiledLayerImplTest, testFixtureName##NoBorders) \ |
- { \ |
- testFixtureName(LayerTilingData::NoBorderTexels); \ |
- } \ |
- TEST(TiledLayerImplTest, testFixtureName##HasBorders) \ |
- { \ |
- testFixtureName(LayerTilingData::HasBorderTexels);\ |
+#define WITH_AND_WITHOUT_BORDER_TEST(testFixtureName) \ |
+ TEST_F(TiledLayerImplBorderTest, testFixtureName##NoBorders) \ |
+ { \ |
+ testFixtureName(LayerTilingData::NoBorderTexels); \ |
+ } \ |
+ TEST_F(TiledLayerImplBorderTest, testFixtureName##HasBorders) \ |
+ { \ |
+ testFixtureName(LayerTilingData::HasBorderTexels); \ |
} |
-static void coverageVisibleRectOnTileBoundaries(LayerTilingData::BorderTexelOption borders) |
+class TiledLayerImplBorderTest : public TiledLayerImplTest |
{ |
- gfx::Size layerSize(1000, 1000); |
- QuadList quads; |
- SharedQuadStateList sharedStates; |
- getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, borders, gfx::Rect(gfx::Point(), layerSize)); |
- verifyQuadsExactlyCoverRect(quads, gfx::Rect(gfx::Point(), layerSize)); |
-} |
-WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectOnTileBoundaries); |
+public: |
+ void coverageVisibleRectOnTileBoundaries(LayerTilingData::BorderTexelOption borders) |
+ { |
+ gfx::Size layerSize(1000, 1000); |
+ QuadList quads; |
+ SharedQuadStateList sharedStates; |
+ getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, borders, gfx::Rect(gfx::Point(), layerSize)); |
+ verifyQuadsExactlyCoverRect(quads, gfx::Rect(gfx::Point(), layerSize)); |
+ } |
-static void coverageVisibleRectIntersectsTiles(LayerTilingData::BorderTexelOption borders) |
-{ |
- // This rect intersects the middle 3x3 of the 5x5 tiles. |
- gfx::Point topLeft(65, 73); |
- gfx::Point bottomRight(182, 198); |
- gfx::Rect visibleContentRect = gfx::BoundingRect(topLeft, bottomRight); |
+ void coverageVisibleRectIntersectsTiles(LayerTilingData::BorderTexelOption borders) |
+ { |
+ // This rect intersects the middle 3x3 of the 5x5 tiles. |
+ gfx::Point topLeft(65, 73); |
+ gfx::Point bottomRight(182, 198); |
+ gfx::Rect visibleContentRect = gfx::BoundingRect(topLeft, bottomRight); |
+ |
+ gfx::Size layerSize(250, 250); |
+ QuadList quads; |
+ SharedQuadStateList sharedStates; |
+ getQuads(quads, sharedStates, gfx::Size(50, 50), gfx::Size(250, 250), LayerTilingData::NoBorderTexels, visibleContentRect); |
+ verifyQuadsExactlyCoverRect(quads, visibleContentRect); |
+ } |
+ |
+ void coverageVisibleRectIntersectsBounds(LayerTilingData::BorderTexelOption borders) |
+ { |
+ gfx::Size layerSize(220, 210); |
+ gfx::Rect visibleContentRect(gfx::Point(), layerSize); |
+ QuadList quads; |
+ SharedQuadStateList sharedStates; |
+ getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, LayerTilingData::NoBorderTexels, visibleContentRect); |
+ verifyQuadsExactlyCoverRect(quads, visibleContentRect); |
+ } |
+}; |
+WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectOnTileBoundaries); |
- gfx::Size layerSize(250, 250); |
- QuadList quads; |
- SharedQuadStateList sharedStates; |
- getQuads(quads, sharedStates, gfx::Size(50, 50), gfx::Size(250, 250), LayerTilingData::NoBorderTexels, visibleContentRect); |
- verifyQuadsExactlyCoverRect(quads, visibleContentRect); |
-} |
WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsTiles); |
-static void coverageVisibleRectIntersectsBounds(LayerTilingData::BorderTexelOption borders) |
-{ |
- gfx::Size layerSize(220, 210); |
- gfx::Rect visibleContentRect(gfx::Point(), layerSize); |
- QuadList quads; |
- SharedQuadStateList sharedStates; |
- getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, LayerTilingData::NoBorderTexels, visibleContentRect); |
- verifyQuadsExactlyCoverRect(quads, visibleContentRect); |
-} |
WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsBounds); |
-TEST(TiledLayerImplTest, textureInfoForLayerNoBorders) |
+TEST_F(TiledLayerImplTest, textureInfoForLayerNoBorders) |
{ |
gfx::Size tileSize(50, 50); |
gfx::Size layerSize(250, 250); |