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

Unified Diff: cc/layers/ui_resource_layer_unittest.cc

Issue 664173002: Prevent recreation of UI resource holder when created with resource ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: verify DrawsContent() Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/ui_resource_layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/ui_resource_layer_unittest.cc
diff --git a/cc/layers/ui_resource_layer_unittest.cc b/cc/layers/ui_resource_layer_unittest.cc
index 09d57a96520de55b498ce908fe2aa487af38e858..5e49ec9c522b027551619861edd3f3992f5fb363 100644
--- a/cc/layers/ui_resource_layer_unittest.cc
+++ b/cc/layers/ui_resource_layer_unittest.cc
@@ -28,12 +28,29 @@ using ::testing::AnyNumber;
namespace cc {
namespace {
+class TestUIResourceLayer : public UIResourceLayer {
+ public:
+ static scoped_refptr<TestUIResourceLayer> Create() {
+ return make_scoped_refptr(new TestUIResourceLayer());
+ }
+
+ UIResourceId GetUIResourceId() {
+ if (ui_resource_holder_)
+ return ui_resource_holder_->id();
+ return 0;
+ }
+
+ protected:
+ TestUIResourceLayer() : UIResourceLayer() { SetIsDrawable(true); }
+ ~TestUIResourceLayer() override {}
+};
+
class UIResourceLayerTest : public testing::Test {
public:
UIResourceLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
protected:
- virtual void SetUp() {
+ void SetUp() override {
layer_tree_host_ = FakeLayerTreeHost::Create(&fake_client_);
layer_tree_host_->InitializeSingleThreaded(
&fake_client_,
@@ -41,7 +58,7 @@ class UIResourceLayerTest : public testing::Test {
nullptr);
}
- virtual void TearDown() {
+ void TearDown() override {
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
}
@@ -50,9 +67,8 @@ class UIResourceLayerTest : public testing::Test {
};
TEST_F(UIResourceLayerTest, SetBitmap) {
- scoped_refptr<UIResourceLayer> test_layer = UIResourceLayer::Create();
+ scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create();
ASSERT_TRUE(test_layer.get());
- test_layer->SetIsDrawable(true);
test_layer->SetBounds(gfx::Size(100, 100));
layer_tree_host_->SetRootLayer(test_layer);
@@ -78,9 +94,8 @@ TEST_F(UIResourceLayerTest, SetBitmap) {
}
TEST_F(UIResourceLayerTest, SetUIResourceId) {
- scoped_refptr<UIResourceLayer> test_layer = UIResourceLayer::Create();
+ scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create();
ASSERT_TRUE(test_layer.get());
- test_layer->SetIsDrawable(true);
test_layer->SetBounds(gfx::Size(100, 100));
layer_tree_host_->SetRootLayer(test_layer);
@@ -102,6 +117,16 @@ TEST_F(UIResourceLayerTest, SetUIResourceId) {
test_layer->Update(&queue, &occlusion_tracker);
EXPECT_TRUE(test_layer->DrawsContent());
+
+ // ID is preserved even when you set ID first and attach it to the tree.
+ scoped_refptr<TestUIResourceLayer> new_test_layer =
danakj 2014/11/20 22:07:26 it's a nit, but you can reuse the test_layer here
Changwan Ryu 2014/11/20 22:15:53 Done.
+ TestUIResourceLayer::Create();
+ scoped_ptr<ScopedUIResource> new_resource = ScopedUIResource::Create(
danakj 2014/11/20 22:07:26 s/new/shared/
Changwan Ryu 2014/11/20 22:15:53 Done.
+ layer_tree_host_.get(), UIResourceBitmap(gfx::Size(5, 5), is_opaque));
+ new_test_layer->SetUIResourceId(new_resource->id());
+ test_layer->AddChild(new_test_layer);
+ EXPECT_EQ(new_resource->id(), new_test_layer->GetUIResourceId());
+ EXPECT_TRUE(new_test_layer->DrawsContent());
}
} // namespace
« no previous file with comments | « cc/layers/ui_resource_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698