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

Side by Side Diff: cc/tiles/checker_image_tracker_unittest.cc

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Other platforms compilation 2. Created 3 years, 5 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/output/direct_renderer.cc ('k') | components/exo/layer_tree_frame_sink_holder.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/tiles/checker_image_tracker.h" 5 #include "cc/tiles/checker_image_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 CheckerImageTracker::ImageDecodeQueue image_decode_queue; 307 CheckerImageTracker::ImageDecodeQueue image_decode_queue;
308 image_decode_queue = 308 image_decode_queue =
309 BuildImageDecodeQueue(draw_images, WhichTree::PENDING_TREE); 309 BuildImageDecodeQueue(draw_images, WhichTree::PENDING_TREE);
310 EXPECT_EQ(image_decode_queue.size(), 2U); 310 EXPECT_EQ(image_decode_queue.size(), 2U);
311 checker_image_tracker_->ScheduleImageDecodeQueue( 311 checker_image_tracker_->ScheduleImageDecodeQueue(
312 std::move(image_decode_queue)); 312 std::move(image_decode_queue));
313 313
314 // Only the first image in the queue should have been decoded. 314 // Only the first image in the queue should have been decoded.
315 EXPECT_EQ(image_controller_.decodes_requested().size(), 1U); 315 EXPECT_EQ(image_controller_.decodes_requested().size(), 1U);
316 EXPECT_EQ(image_controller_.decodes_requested().count( 316 EXPECT_EQ(
317 checkerable_image1.image()->uniqueID()), 317 image_controller_.decodes_requested().count(
318 1U); 318 static_cast<PaintImage::Id>(checkerable_image1.image()->uniqueID())),
319 1U);
319 320
320 // Rebuild the queue before the tracker is notified of decode completion, 321 // Rebuild the queue before the tracker is notified of decode completion,
321 // removing the second image and adding a new one. 322 // removing the second image and adding a new one.
322 DrawImage checkerable_image3 = CreateImage(ImageType::CHECKERABLE); 323 DrawImage checkerable_image3 = CreateImage(ImageType::CHECKERABLE);
323 draw_images = {checkerable_image1, checkerable_image3}; 324 draw_images = {checkerable_image1, checkerable_image3};
324 image_decode_queue = 325 image_decode_queue =
325 BuildImageDecodeQueue(draw_images, WhichTree::PENDING_TREE); 326 BuildImageDecodeQueue(draw_images, WhichTree::PENDING_TREE);
326 327
327 // The queue has 2 decodes because we are still checkering on the first one. 328 // The queue has 2 decodes because we are still checkering on the first one.
328 EXPECT_EQ(image_decode_queue.size(), 2U); 329 EXPECT_EQ(image_decode_queue.size(), 2U);
329 checker_image_tracker_->ScheduleImageDecodeQueue( 330 checker_image_tracker_->ScheduleImageDecodeQueue(
330 std::move(image_decode_queue)); 331 std::move(image_decode_queue));
331 332
332 // We still have only one decode because the tracker keeps only one decode 333 // We still have only one decode because the tracker keeps only one decode
333 // pending at a time. 334 // pending at a time.
334 EXPECT_EQ(image_controller_.decodes_requested().size(), 1U); 335 EXPECT_EQ(image_controller_.decodes_requested().size(), 1U);
335 EXPECT_EQ(image_controller_.decodes_requested().count( 336 EXPECT_EQ(
336 checkerable_image1.image()->uniqueID()), 337 image_controller_.decodes_requested().count(
337 1U); 338 static_cast<PaintImage::Id>(checkerable_image1.image()->uniqueID())),
339 1U);
338 340
339 // Trigger completion for all decodes. Only 2 images should have been decoded 341 // Trigger completion for all decodes. Only 2 images should have been decoded
340 // since the second image was cancelled. 342 // since the second image was cancelled.
341 base::RunLoop().RunUntilIdle(); 343 base::RunLoop().RunUntilIdle();
342 EXPECT_EQ(image_controller_.decodes_requested().size(), 2U); 344 EXPECT_EQ(image_controller_.decodes_requested().size(), 2U);
343 EXPECT_EQ(image_controller_.decodes_requested().count( 345 EXPECT_EQ(
344 checkerable_image3.image()->uniqueID()), 346 image_controller_.decodes_requested().count(
345 1U); 347 static_cast<PaintImage::Id>(checkerable_image3.image()->uniqueID())),
348 1U);
346 EXPECT_EQ(image_controller_.num_of_locked_images(), 2); 349 EXPECT_EQ(image_controller_.num_of_locked_images(), 2);
347 } 350 }
348 351
349 TEST_F(CheckerImageTrackerTest, ClearsTracker) { 352 TEST_F(CheckerImageTrackerTest, ClearsTracker) {
350 SetUpTracker(true); 353 SetUpTracker(true);
351 354
352 DrawImage checkerable_image = CreateImage(ImageType::CHECKERABLE); 355 DrawImage checkerable_image = CreateImage(ImageType::CHECKERABLE);
353 CheckerImageTracker::ImageDecodeQueue image_decode_queue = 356 CheckerImageTracker::ImageDecodeQueue image_decode_queue =
354 BuildImageDecodeQueue({checkerable_image}, WhichTree::PENDING_TREE); 357 BuildImageDecodeQueue({checkerable_image}, WhichTree::PENDING_TREE);
355 EXPECT_EQ(image_decode_queue.size(), 1U); 358 EXPECT_EQ(image_decode_queue.size(), 1U);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 CheckerImageTracker::DecodeType::kPreDecode); 529 CheckerImageTracker::DecodeType::kPreDecode);
527 base::RunLoop().RunUntilIdle(); 530 base::RunLoop().RunUntilIdle();
528 EXPECT_EQ(image_controller_.decoded_images()[0], image1); 531 EXPECT_EQ(image_controller_.decoded_images()[0], image1);
529 EXPECT_EQ(image_controller_.decoded_images()[1], image2); 532 EXPECT_EQ(image_controller_.decoded_images()[1], image2);
530 EXPECT_EQ(image_controller_.decoded_images()[2], image3); 533 EXPECT_EQ(image_controller_.decoded_images()[2], image3);
531 EXPECT_EQ(image_controller_.decoded_images()[3], image4); 534 EXPECT_EQ(image_controller_.decoded_images()[3], image4);
532 } 535 }
533 536
534 } // namespace 537 } // namespace
535 } // namespace cc 538 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.cc ('k') | components/exo/layer_tree_frame_sink_holder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698