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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months 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
« no previous file with comments | « cc/layers/ui_resource_layer_impl_unittest.cc ('k') | cc/layers/video_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/resources/resource_provider.h" 8 #include "cc/resources/resource_provider.h"
9 #include "cc/resources/scoped_ui_resource.h" 9 #include "cc/resources/scoped_ui_resource.h"
10 #include "cc/test/fake_layer_tree_host.h" 10 #include "cc/test/fake_layer_tree_host.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 layer_tree_host_->InitializeSingleThreaded( 55 layer_tree_host_->InitializeSingleThreaded(
56 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); 56 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr);
57 } 57 }
58 58
59 void TearDown() override { 59 void TearDown() override {
60 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 60 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
61 } 61 }
62 62
63 FakeLayerTreeHostClient fake_client_; 63 FakeLayerTreeHostClient fake_client_;
64 TestTaskGraphRunner task_graph_runner_; 64 TestTaskGraphRunner task_graph_runner_;
65 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; 65 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_;
66 }; 66 };
67 67
68 TEST_F(UIResourceLayerTest, SetBitmap) { 68 TEST_F(UIResourceLayerTest, SetBitmap) {
69 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create(); 69 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create();
70 ASSERT_TRUE(test_layer.get()); 70 ASSERT_TRUE(test_layer.get());
71 test_layer->SetBounds(gfx::Size(100, 100)); 71 test_layer->SetBounds(gfx::Size(100, 100));
72 72
73 layer_tree_host_->SetRootLayer(test_layer); 73 layer_tree_host_->SetRootLayer(test_layer);
74 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 74 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
75 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); 75 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
(...skipping 21 matching lines...) Expand all
97 layer_tree_host_->SetRootLayer(test_layer); 97 layer_tree_host_->SetRootLayer(test_layer);
98 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 98 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
99 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); 99 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
100 100
101 test_layer->SavePaintProperties(); 101 test_layer->SavePaintProperties();
102 test_layer->Update(); 102 test_layer->Update();
103 103
104 EXPECT_FALSE(test_layer->DrawsContent()); 104 EXPECT_FALSE(test_layer->DrawsContent());
105 105
106 bool is_opaque = false; 106 bool is_opaque = false;
107 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create( 107 std::unique_ptr<ScopedUIResource> resource = ScopedUIResource::Create(
108 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(10, 10), is_opaque)); 108 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(10, 10), is_opaque));
109 test_layer->SetUIResourceId(resource->id()); 109 test_layer->SetUIResourceId(resource->id());
110 test_layer->Update(); 110 test_layer->Update();
111 111
112 EXPECT_TRUE(test_layer->DrawsContent()); 112 EXPECT_TRUE(test_layer->DrawsContent());
113 113
114 // ID is preserved even when you set ID first and attach it to the tree. 114 // ID is preserved even when you set ID first and attach it to the tree.
115 layer_tree_host_->SetRootLayer(nullptr); 115 layer_tree_host_->SetRootLayer(nullptr);
116 scoped_ptr<ScopedUIResource> shared_resource = ScopedUIResource::Create( 116 std::unique_ptr<ScopedUIResource> shared_resource = ScopedUIResource::Create(
117 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(5, 5), is_opaque)); 117 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(5, 5), is_opaque));
118 test_layer->SetUIResourceId(shared_resource->id()); 118 test_layer->SetUIResourceId(shared_resource->id());
119 layer_tree_host_->SetRootLayer(test_layer); 119 layer_tree_host_->SetRootLayer(test_layer);
120 EXPECT_EQ(shared_resource->id(), test_layer->GetUIResourceId()); 120 EXPECT_EQ(shared_resource->id(), test_layer->GetUIResourceId());
121 EXPECT_TRUE(test_layer->DrawsContent()); 121 EXPECT_TRUE(test_layer->DrawsContent());
122 } 122 }
123 123
124 TEST_F(UIResourceLayerTest, BitmapClearedOnSetUIResourceId) { 124 TEST_F(UIResourceLayerTest, BitmapClearedOnSetUIResourceId) {
125 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create(); 125 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create();
126 ASSERT_TRUE(test_layer.get()); 126 ASSERT_TRUE(test_layer.get());
127 test_layer->SetBounds(gfx::Size(100, 100)); 127 test_layer->SetBounds(gfx::Size(100, 100));
128 128
129 SkBitmap bitmap; 129 SkBitmap bitmap;
130 bitmap.allocN32Pixels(10, 10); 130 bitmap.allocN32Pixels(10, 10);
131 bitmap.setImmutable(); 131 bitmap.setImmutable();
132 ASSERT_FALSE(bitmap.isNull()); 132 ASSERT_FALSE(bitmap.isNull());
133 ASSERT_TRUE(bitmap.pixelRef()->unique()); 133 ASSERT_TRUE(bitmap.pixelRef()->unique());
134 134
135 test_layer->SetBitmap(bitmap); 135 test_layer->SetBitmap(bitmap);
136 ASSERT_FALSE(bitmap.pixelRef()->unique()); 136 ASSERT_FALSE(bitmap.pixelRef()->unique());
137 137
138 test_layer->SetUIResourceId(0); 138 test_layer->SetUIResourceId(0);
139 EXPECT_TRUE(bitmap.pixelRef()->unique()); 139 EXPECT_TRUE(bitmap.pixelRef()->unique());
140 } 140 }
141 141
142 } // namespace 142 } // namespace
143 } // namespace cc 143 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/ui_resource_layer_impl_unittest.cc ('k') | cc/layers/video_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698