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

Unified Diff: cc/layers/ui_resource_layer_unittest.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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') | cc/output/begin_frame_args.h » ('j') | 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..239efb8d9bb121c059ae6671b250763890ee24c8 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<TestUIResourceLayer> 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,15 @@ 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.
+ layer_tree_host_->SetRootLayer(nullptr);
+ scoped_ptr<ScopedUIResource> shared_resource = ScopedUIResource::Create(
+ layer_tree_host_.get(), UIResourceBitmap(gfx::Size(5, 5), is_opaque));
+ test_layer->SetUIResourceId(shared_resource->id());
+ layer_tree_host_->SetRootLayer(test_layer);
+ EXPECT_EQ(shared_resource->id(), test_layer->GetUIResourceId());
+ EXPECT_TRUE(test_layer->DrawsContent());
}
} // namespace
« no previous file with comments | « cc/layers/ui_resource_layer.cc ('k') | cc/output/begin_frame_args.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698