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

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

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 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 unified diff | Download patch
« no previous file with comments | « cc/layers/layer_iterator_unittest.cc ('k') | cc/layers/layer_utils_unittest.cc » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/animation/keyframed_animation_curve.h" 8 #include "cc/animation/keyframed_animation_curve.h"
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 layer_tree_host->SetRootLayer(root); 1146 layer_tree_host->SetRootLayer(root);
1147 } 1147 }
1148 1148
1149 static bool AddTestAnimation(Layer* layer) { 1149 static bool AddTestAnimation(Layer* layer) {
1150 scoped_ptr<KeyframedFloatAnimationCurve> curve = 1150 scoped_ptr<KeyframedFloatAnimationCurve> curve =
1151 KeyframedFloatAnimationCurve::Create(); 1151 KeyframedFloatAnimationCurve::Create();
1152 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.3f, nullptr)); 1152 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.3f, nullptr));
1153 curve->AddKeyframe( 1153 curve->AddKeyframe(
1154 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr)); 1154 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr));
1155 scoped_ptr<Animation> animation = 1155 scoped_ptr<Animation> animation =
1156 Animation::Create(curve.Pass(), 0, 0, Animation::OPACITY); 1156 Animation::Create(std::move(curve), 0, 0, Animation::OPACITY);
1157 1157
1158 return layer->AddAnimation(animation.Pass()); 1158 return layer->AddAnimation(std::move(animation));
1159 } 1159 }
1160 1160
1161 TEST_F(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { 1161 TEST_F(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) {
1162 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); 1162 scoped_refptr<Layer> layer = Layer::Create(layer_settings_);
1163 1163
1164 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the 1164 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the
1165 // animation should not be accepted. 1165 // animation should not be accepted.
1166 EXPECT_FALSE(AddTestAnimation(layer.get())); 1166 EXPECT_FALSE(AddTestAnimation(layer.get()));
1167 1167
1168 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); 1168 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 } 1267 }
1268 1268
1269 TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) { 1269 TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) {
1270 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); 1270 scoped_refptr<Layer> layer = Layer::Create(layer_settings_);
1271 int result_count = 0; 1271 int result_count = 0;
1272 1272
1273 // Create identical requests without the source being set, and expect the 1273 // Create identical requests without the source being set, and expect the
1274 // layer does not abort either one. 1274 // layer does not abort either one.
1275 scoped_ptr<CopyOutputRequest> request = CopyOutputRequest::CreateRequest( 1275 scoped_ptr<CopyOutputRequest> request = CopyOutputRequest::CreateRequest(
1276 base::Bind(&ReceiveCopyOutputResult, &result_count)); 1276 base::Bind(&ReceiveCopyOutputResult, &result_count));
1277 layer->RequestCopyOfOutput(request.Pass()); 1277 layer->RequestCopyOfOutput(std::move(request));
1278 EXPECT_EQ(0, result_count); 1278 EXPECT_EQ(0, result_count);
1279 request = CopyOutputRequest::CreateRequest( 1279 request = CopyOutputRequest::CreateRequest(
1280 base::Bind(&ReceiveCopyOutputResult, &result_count)); 1280 base::Bind(&ReceiveCopyOutputResult, &result_count));
1281 layer->RequestCopyOfOutput(request.Pass()); 1281 layer->RequestCopyOfOutput(std::move(request));
1282 EXPECT_EQ(0, result_count); 1282 EXPECT_EQ(0, result_count);
1283 1283
1284 // When the layer is destroyed, expect both requests to be aborted. 1284 // When the layer is destroyed, expect both requests to be aborted.
1285 layer = nullptr; 1285 layer = nullptr;
1286 EXPECT_EQ(2, result_count); 1286 EXPECT_EQ(2, result_count);
1287 1287
1288 layer = Layer::Create(layer_settings_); 1288 layer = Layer::Create(layer_settings_);
1289 result_count = 0; 1289 result_count = 0;
1290 1290
1291 // Create identical requests, but this time the source is being set. Expect 1291 // Create identical requests, but this time the source is being set. Expect
1292 // the first request from |this| source aborts immediately when the second 1292 // the first request from |this| source aborts immediately when the second
1293 // request from |this| source is made. 1293 // request from |this| source is made.
1294 int did_receive_first_result_from_this_source = 0; 1294 int did_receive_first_result_from_this_source = 0;
1295 request = CopyOutputRequest::CreateRequest(base::Bind( 1295 request = CopyOutputRequest::CreateRequest(base::Bind(
1296 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source)); 1296 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source));
1297 request->set_source(this); 1297 request->set_source(this);
1298 layer->RequestCopyOfOutput(request.Pass()); 1298 layer->RequestCopyOfOutput(std::move(request));
1299 EXPECT_EQ(0, did_receive_first_result_from_this_source); 1299 EXPECT_EQ(0, did_receive_first_result_from_this_source);
1300 // Make a request from a different source. 1300 // Make a request from a different source.
1301 int did_receive_result_from_different_source = 0; 1301 int did_receive_result_from_different_source = 0;
1302 request = CopyOutputRequest::CreateRequest(base::Bind( 1302 request = CopyOutputRequest::CreateRequest(base::Bind(
1303 &ReceiveCopyOutputResult, &did_receive_result_from_different_source)); 1303 &ReceiveCopyOutputResult, &did_receive_result_from_different_source));
1304 request->set_source(reinterpret_cast<void*>(0xdeadbee0)); 1304 request->set_source(reinterpret_cast<void*>(0xdeadbee0));
1305 layer->RequestCopyOfOutput(request.Pass()); 1305 layer->RequestCopyOfOutput(std::move(request));
1306 EXPECT_EQ(0, did_receive_result_from_different_source); 1306 EXPECT_EQ(0, did_receive_result_from_different_source);
1307 // Make a request without specifying the source. 1307 // Make a request without specifying the source.
1308 int did_receive_result_from_anonymous_source = 0; 1308 int did_receive_result_from_anonymous_source = 0;
1309 request = CopyOutputRequest::CreateRequest(base::Bind( 1309 request = CopyOutputRequest::CreateRequest(base::Bind(
1310 &ReceiveCopyOutputResult, &did_receive_result_from_anonymous_source)); 1310 &ReceiveCopyOutputResult, &did_receive_result_from_anonymous_source));
1311 layer->RequestCopyOfOutput(request.Pass()); 1311 layer->RequestCopyOfOutput(std::move(request));
1312 EXPECT_EQ(0, did_receive_result_from_anonymous_source); 1312 EXPECT_EQ(0, did_receive_result_from_anonymous_source);
1313 // Make the second request from |this| source. 1313 // Make the second request from |this| source.
1314 int did_receive_second_result_from_this_source = 0; 1314 int did_receive_second_result_from_this_source = 0;
1315 request = CopyOutputRequest::CreateRequest(base::Bind( 1315 request = CopyOutputRequest::CreateRequest(base::Bind(
1316 &ReceiveCopyOutputResult, &did_receive_second_result_from_this_source)); 1316 &ReceiveCopyOutputResult, &did_receive_second_result_from_this_source));
1317 request->set_source(this); 1317 request->set_source(this);
1318 layer->RequestCopyOfOutput(request.Pass()); // First request to be aborted. 1318 layer->RequestCopyOfOutput(
1319 std::move(request)); // First request to be aborted.
1319 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1320 EXPECT_EQ(1, did_receive_first_result_from_this_source);
1320 EXPECT_EQ(0, did_receive_result_from_different_source); 1321 EXPECT_EQ(0, did_receive_result_from_different_source);
1321 EXPECT_EQ(0, did_receive_result_from_anonymous_source); 1322 EXPECT_EQ(0, did_receive_result_from_anonymous_source);
1322 EXPECT_EQ(0, did_receive_second_result_from_this_source); 1323 EXPECT_EQ(0, did_receive_second_result_from_this_source);
1323 1324
1324 // When the layer is destroyed, the other three requests should be aborted. 1325 // When the layer is destroyed, the other three requests should be aborted.
1325 layer = nullptr; 1326 layer = nullptr;
1326 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1327 EXPECT_EQ(1, did_receive_first_result_from_this_source);
1327 EXPECT_EQ(1, did_receive_result_from_different_source); 1328 EXPECT_EQ(1, did_receive_result_from_different_source);
1328 EXPECT_EQ(1, did_receive_result_from_anonymous_source); 1329 EXPECT_EQ(1, did_receive_result_from_anonymous_source);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 1698
1698 properties.set_needs_push_properties(true); 1699 properties.set_needs_push_properties(true);
1699 properties.mutable_base(); 1700 properties.mutable_base();
1700 layer->FromLayerPropertiesProto(properties); 1701 layer->FromLayerPropertiesProto(properties);
1701 EXPECT_TRUE(layer->needs_push_properties()); 1702 EXPECT_TRUE(layer->needs_push_properties());
1702 EXPECT_FALSE(layer->descendant_needs_push_properties()); 1703 EXPECT_FALSE(layer->descendant_needs_push_properties());
1703 } 1704 }
1704 1705
1705 } // namespace 1706 } // namespace
1706 } // namespace cc 1707 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_iterator_unittest.cc ('k') | cc/layers/layer_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698