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

Side by Side Diff: cc/layers/ui_resource_layer_unittest.cc

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/ui_resource_layer.h" 5 #include "cc/layers/ui_resource_layer.h"
6 6
7 #include "cc/resources/prioritized_resource_manager.h" 7 #include "cc/resources/prioritized_resource_manager.h"
8 #include "cc/resources/resource_provider.h" 8 #include "cc/resources/resource_provider.h"
9 #include "cc/resources/resource_update_queue.h" 9 #include "cc/resources/resource_update_queue.h"
10 #include "cc/resources/scoped_ui_resource.h" 10 #include "cc/resources/scoped_ui_resource.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // ID is preserved even when you set ID first and attach it to the tree. 121 // ID is preserved even when you set ID first and attach it to the tree.
122 layer_tree_host_->SetRootLayer(nullptr); 122 layer_tree_host_->SetRootLayer(nullptr);
123 scoped_ptr<ScopedUIResource> shared_resource = ScopedUIResource::Create( 123 scoped_ptr<ScopedUIResource> shared_resource = ScopedUIResource::Create(
124 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(5, 5), is_opaque)); 124 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(5, 5), is_opaque));
125 test_layer->SetUIResourceId(shared_resource->id()); 125 test_layer->SetUIResourceId(shared_resource->id());
126 layer_tree_host_->SetRootLayer(test_layer); 126 layer_tree_host_->SetRootLayer(test_layer);
127 EXPECT_EQ(shared_resource->id(), test_layer->GetUIResourceId()); 127 EXPECT_EQ(shared_resource->id(), test_layer->GetUIResourceId());
128 EXPECT_TRUE(test_layer->DrawsContent()); 128 EXPECT_TRUE(test_layer->DrawsContent());
129 } 129 }
130 130
131 TEST_F(UIResourceLayerTest, BitmapClearedOnSetUIResourceId) {
132 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create();
133 ASSERT_TRUE(test_layer.get());
134 test_layer->SetBounds(gfx::Size(100, 100));
135
136 SkBitmap bitmap;
137 bitmap.allocN32Pixels(10, 10);
138 bitmap.setImmutable();
139 ASSERT_FALSE(bitmap.isNull());
140 ASSERT_TRUE(bitmap.pixelRef()->unique());
141
142 test_layer->SetBitmap(bitmap);
143 ASSERT_FALSE(bitmap.pixelRef()->unique());
144
145 test_layer->SetUIResourceId(0);
146 EXPECT_TRUE(bitmap.pixelRef()->unique());
147 }
148
131 } // namespace 149 } // namespace
132 } // namespace cc 150 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698