Skip to content

Commit

Permalink
Switch to use SharedBitmapManager all the time in cc_unittests
Browse files Browse the repository at this point in the history
This matches the behavior of the browser and renderer better, and lets us use SharedBitmaps in more tests.

Review URL: https://codereview.chromium.org/202763002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258318 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jbauman@chromium.org committed Mar 20, 2014
1 parent 22e5488 commit 4e2eb35
Show file tree
Hide file tree
Showing 60 changed files with 622 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
namespace {

class ScrollbarAnimationControllerLinearFadeTest : public testing::Test {
public:
ScrollbarAnimationControllerLinearFadeTest() : host_impl_(&proxy_) {}
ScrollbarAnimationControllerLinearFadeTest()
: host_impl_(&proxy_, &shared_bitmap_manager_) {}

protected:
virtual void SetUp() {
Expand Down Expand Up @@ -48,6 +50,7 @@ class ScrollbarAnimationControllerLinearFadeTest : public testing::Test {
}

FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
scoped_ptr<ScrollbarAnimationControllerLinearFade> scrollbar_controller_;
scoped_ptr<LayerImpl> clip_layer_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
namespace {

class ScrollbarAnimationControllerThinningTest : public testing::Test {
public:
ScrollbarAnimationControllerThinningTest() : host_impl_(&proxy_) {}
ScrollbarAnimationControllerThinningTest()
: host_impl_(&proxy_, &shared_bitmap_manager_) {}

protected:
virtual void SetUp() {
Expand Down Expand Up @@ -49,6 +51,7 @@ class ScrollbarAnimationControllerThinningTest : public testing::Test {
}

FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
scoped_ptr<ScrollbarAnimationControllerThinning> scrollbar_controller_;
scoped_ptr<LayerImpl> clip_layer_;
Expand Down
2 changes: 2 additions & 0 deletions cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
'test/test_gles2_interface.cc',
'test/test_gles2_interface.h',
'test/test_occlusion_tracker.h',
'test/test_shared_bitmap_manager.cc',
'test/test_shared_bitmap_manager.h',
'test/test_texture.cc',
'test/test_texture.h',
'test/test_tile_priorities.cc',
Expand Down
6 changes: 4 additions & 2 deletions cc/debug/micro_benchmark_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class MicroBenchmarkControllerTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE {
impl_proxy_ = make_scoped_ptr(new FakeImplProxy);
layer_tree_host_impl_ =
make_scoped_ptr(new FakeLayerTreeHostImpl(impl_proxy_.get()));
shared_bitmap_manager_.reset(new TestSharedBitmapManager());
layer_tree_host_impl_ = make_scoped_ptr(new FakeLayerTreeHostImpl(
impl_proxy_.get(), shared_bitmap_manager_.get()));

layer_tree_host_ = FakeLayerTreeHost::Create();
layer_tree_host_->SetRootLayer(Layer::Create());
Expand All @@ -35,6 +36,7 @@ class MicroBenchmarkControllerTest : public testing::Test {
}

scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
scoped_ptr<FakeLayerTreeHostImpl> layer_tree_host_impl_;
scoped_ptr<FakeImplProxy> impl_proxy_;
};
Expand Down
4 changes: 3 additions & 1 deletion cc/input/top_controls_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cc/layers/layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/frame_time.h"
Expand All @@ -24,7 +25,7 @@ class MockTopControlsManagerClient : public TopControlsManagerClient {
public:
MockTopControlsManagerClient(float top_controls_show_threshold,
float top_controls_hide_threshold)
: host_impl_(&proxy_),
: host_impl_(&proxy_, &shared_bitmap_manager_),
redraw_needed_(false),
update_draw_properties_needed_(false),
top_controls_show_threshold_(top_controls_show_threshold),
Expand Down Expand Up @@ -60,6 +61,7 @@ class MockTopControlsManagerClient : public TopControlsManagerClient {

private:
FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
scoped_ptr<LayerTreeImpl> active_tree_;
scoped_ptr<LayerImpl> root_scroll_layer_;
Expand Down
5 changes: 4 additions & 1 deletion cc/layers/delegated_renderer_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "cc/test/mock_quad_culler.h"
#include "cc/test/render_pass_test_common.h"
#include "cc/test/render_pass_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/trees/layer_tree_host_impl.h"
#include "cc/trees/layer_tree_impl.h"
Expand All @@ -38,7 +39,8 @@ class DelegatedRendererLayerImplTest : public testing::Test {
LayerTreeSettings settings;
settings.minimum_occlusion_tracking_size = gfx::Size();

host_impl_.reset(new FakeLayerTreeHostImpl(settings, &proxy_));
host_impl_.reset(
new FakeLayerTreeHostImpl(settings, &proxy_, &shared_bitmap_manager_));
host_impl_->InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>());
host_impl_->SetViewportSize(gfx::Size(10, 10));
Expand All @@ -48,6 +50,7 @@ class DelegatedRendererLayerImplTest : public testing::Test {
FakeProxy proxy_;
DebugScopedSetImplThreadAndMainThreadBlocked
always_impl_thread_and_main_thread_blocked_;
TestSharedBitmapManager shared_bitmap_manager_;
scoped_ptr<LayerTreeHostImpl> host_impl_;
};

Expand Down
4 changes: 3 additions & 1 deletion cc/layers/heads_up_display_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/mock_quad_culler.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cc {
Expand All @@ -31,7 +32,8 @@ void CheckDrawLayer(HeadsUpDisplayLayerImpl* layer,

TEST(HeadsUpDisplayLayerImplTest, ResourcelessSoftwareDrawAfterResourceLoss) {
FakeImplProxy proxy;
FakeLayerTreeHostImpl host_impl(&proxy);
TestSharedBitmapManager shared_bitmap_manager;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
host_impl.CreatePendingTree();
host_impl.InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>());
Expand Down
18 changes: 12 additions & 6 deletions cc/layers/layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gmock/include/gmock/gmock.h"
Expand Down Expand Up @@ -82,7 +83,8 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
// The constructor on this will fake that we are on the correct thread.
// Create a simple LayerImpl tree:
FakeImplProxy proxy;
FakeLayerTreeHostImpl host_impl(&proxy);
TestSharedBitmapManager shared_bitmap_manager;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
EXPECT_TRUE(host_impl.InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>()));
scoped_ptr<LayerImpl> root_clip =
Expand Down Expand Up @@ -241,7 +243,8 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {

TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
FakeImplProxy proxy;
FakeLayerTreeHostImpl host_impl(&proxy);
TestSharedBitmapManager shared_bitmap_manager;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
EXPECT_TRUE(host_impl.InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>()));
host_impl.active_tree()->SetRootLayer(
Expand Down Expand Up @@ -353,7 +356,8 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {

TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
FakeImplProxy proxy;
FakeLayerTreeHostImpl host_impl(&proxy);
TestSharedBitmapManager shared_bitmap_manager;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
EXPECT_TRUE(host_impl.InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>()));
scoped_ptr<LayerImpl> layer = LayerImpl::Create(host_impl.active_tree(), 1);
Expand Down Expand Up @@ -384,9 +388,10 @@ TEST(LayerImplTest, SafeOpaqueBackgroundColor) {

class LayerImplScrollTest : public testing::Test {
public:
LayerImplScrollTest() : host_impl_(&proxy_), root_id_(7) {
host_impl_.active_tree()
->SetRootLayer(LayerImpl::Create(host_impl_.active_tree(), root_id_));
LayerImplScrollTest()
: host_impl_(&proxy_, &shared_bitmap_manager_), root_id_(7) {
host_impl_.active_tree()->SetRootLayer(
LayerImpl::Create(host_impl_.active_tree(), root_id_));
host_impl_.active_tree()->root_layer()->AddChild(
LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1));
layer()->SetScrollClipLayer(root_id_);
Expand All @@ -404,6 +409,7 @@ class LayerImplScrollTest : public testing::Test {

private:
FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
int root_id_;
};
Expand Down
3 changes: 2 additions & 1 deletion cc/layers/layer_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MockLayerPainter : public LayerPainter {
class LayerPerfTest : public testing::Test {
public:
LayerPerfTest()
: host_impl_(&proxy_),
: host_impl_(&proxy_, &shared_bitmap_manager_),
fake_client_(FakeLayerTreeHostClient::DIRECT_3D),
timer_(kWarmupRuns,
base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
Expand All @@ -50,6 +50,7 @@ class LayerPerfTest : public testing::Test {
}

FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;

FakeLayerTreeHostClient fake_client_;
Expand Down
5 changes: 3 additions & 2 deletions cc/layers/layer_position_constraint_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/trees/layer_tree_host_common.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down Expand Up @@ -64,8 +65,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root_layer) {

class LayerPositionConstraintTest : public testing::Test {
public:
LayerPositionConstraintTest()
: host_impl_(&proxy_) {
LayerPositionConstraintTest() : host_impl_(&proxy_, &shared_bitmap_manager_) {
root_ = CreateTreeForTest();
scroll_ = root_->children()[0];
fixed_to_top_left_.set_is_fixed_position(true);
Expand Down Expand Up @@ -135,6 +135,7 @@ class LayerPositionConstraintTest : public testing::Test {

protected:
FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
scoped_ptr<LayerImpl> root_;
LayerImpl* scroll_;
Expand Down
17 changes: 10 additions & 7 deletions cc/layers/layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/single_thread_proxy.h"
#include "testing/gmock/include/gmock/gmock.h"
Expand Down Expand Up @@ -59,7 +60,7 @@ class MockLayerPainter : public LayerPainter {
class LayerTest : public testing::Test {
public:
LayerTest()
: host_impl_(&proxy_),
: host_impl_(&proxy_, &shared_bitmap_manager_),
fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}

protected:
Expand Down Expand Up @@ -129,6 +130,7 @@ class LayerTest : public testing::Test {
}

FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;

FakeLayerTreeHostClient fake_client_;
Expand Down Expand Up @@ -804,24 +806,25 @@ TEST_F(LayerTest, MaskAndReplicaHasParent) {
class LayerTreeHostFactory {
public:
LayerTreeHostFactory()
: client_(FakeLayerTreeHostClient::DIRECT_3D) {}
: client_(FakeLayerTreeHostClient::DIRECT_3D),
shared_bitmap_manager_(new TestSharedBitmapManager()) {}

scoped_ptr<LayerTreeHost> Create() {
return LayerTreeHost::CreateSingleThreaded(&client_,
&client_,
NULL,
shared_bitmap_manager_.get(),
LayerTreeSettings()).Pass();
}

scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) {
return LayerTreeHost::CreateSingleThreaded(&client_,
&client_,
NULL,
settings).Pass();
return LayerTreeHost::CreateSingleThreaded(
&client_, &client_, shared_bitmap_manager_.get(), settings)
.Pass();
}

private:
FakeLayerTreeHostClient client_;
scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
};

void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) {
Expand Down
4 changes: 3 additions & 1 deletion cc/layers/layer_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/box_f.h"
#include "ui/gfx/test/gfx_util.h"
Expand All @@ -23,7 +24,7 @@ float diagonal(float width, float height) {
class LayerUtilsGetAnimationBoundsTest : public testing::Test {
public:
LayerUtilsGetAnimationBoundsTest()
: host_impl_(&proxy_),
: host_impl_(&proxy_, &shared_bitmap_manager_),
root_(CreateThreeNodeTree(host_impl_)),
parent_(root_->children()[0]),
child_(parent_->children()[0]) {}
Expand All @@ -43,6 +44,7 @@ class LayerUtilsGetAnimationBoundsTest : public testing::Test {
}

FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
scoped_ptr<LayerImpl> root_;
LayerImpl* parent_;
Expand Down
3 changes: 2 additions & 1 deletion cc/layers/nine_patch_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size,
layer_size.height() - border.height());

FakeImplProxy proxy;
FakeUIResourceLayerTreeHostImpl host_impl(&proxy);
TestSharedBitmapManager shared_bitmap_manager;
FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
scoped_ptr<NinePatchLayerImpl> layer =
NinePatchLayerImpl::Create(host_impl.active_tree(), 1);
layer->draw_properties().visible_content_rect = visible_content_rect;
Expand Down
1 change: 1 addition & 0 deletions cc/layers/nine_patch_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_output_surface_client.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/occlusion_tracker.h"
#include "cc/trees/single_thread_proxy.h"
Expand Down
6 changes: 5 additions & 1 deletion cc/layers/picture_image_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "cc/test/fake_picture_layer_tiling_client.h"
#include "cc/test/impl_side_painting_settings.h"
#include "cc/test/mock_quad_culler.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand All @@ -33,7 +34,9 @@ class PictureImageLayerImplTest : public testing::Test {
public:
PictureImageLayerImplTest()
: proxy_(base::MessageLoopProxy::current()),
host_impl_(ImplSidePaintingSettings(), &proxy_) {
host_impl_(ImplSidePaintingSettings(),
&proxy_,
&shared_bitmap_manager_) {
tiling_client_.SetTileSize(ImplSidePaintingSettings().default_tile_size);
host_impl_.CreatePendingTree();
host_impl_.InitializeRenderer(
Expand Down Expand Up @@ -70,6 +73,7 @@ class PictureImageLayerImplTest : public testing::Test {
protected:
FakeImplProxy proxy_;
FakeLayerTreeHostImpl host_impl_;
TestSharedBitmapManager shared_bitmap_manager_;
FakePictureLayerTilingClient tiling_client_;
};

Expand Down
Loading

0 comments on commit 4e2eb35

Please sign in to comment.