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

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

Issue 2718243002: cc: Regenerate image decode requests tasks when cache switches. (Closed)
Patch Set: update Created 3 years, 9 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 | « no previous file | cc/tiles/image_controller.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/tiles/decoded_image_tracker.h" 8 #include "cc/tiles/decoded_image_tracker.h"
9 #include "cc/tiles/image_controller.h" 9 #include "cc/tiles/image_controller.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 private: 51 private:
52 TestImageController image_controller_; 52 TestImageController image_controller_;
53 DecodedImageTracker decoded_image_tracker_; 53 DecodedImageTracker decoded_image_tracker_;
54 }; 54 };
55 55
56 TEST_F(DecodedImageTrackerTest, QueueImageLocksImages) { 56 TEST_F(DecodedImageTrackerTest, QueueImageLocksImages) {
57 bool locked = false; 57 bool locked = false;
58 decoded_image_tracker()->QueueImageDecode( 58 decoded_image_tracker()->QueueImageDecode(
59 nullptr, 59 nullptr, base::Bind([](bool* locked, bool success) { *locked = true; },
60 base::Bind([](bool* locked, bool success) { *locked = true; }, 60 base::Unretained(&locked)));
61 base::Unretained(&locked)));
62 EXPECT_TRUE(locked); 61 EXPECT_TRUE(locked);
63 EXPECT_EQ(1u, image_controller()->num_locked_images()); 62 EXPECT_EQ(1u, image_controller()->num_locked_images());
64 } 63 }
65 64
66 TEST_F(DecodedImageTrackerTest, NotifyFrameFinishedUnlocksImages) { 65 TEST_F(DecodedImageTrackerTest, NotifyFrameFinishedUnlocksImages) {
67 bool locked = false; 66 bool locked = false;
68 decoded_image_tracker()->QueueImageDecode( 67 decoded_image_tracker()->QueueImageDecode(
69 nullptr, 68 nullptr, base::Bind([](bool* locked, bool success) { *locked = true; },
70 base::Bind([](bool* locked, bool success) { *locked = true; }, 69 base::Unretained(&locked)));
71 base::Unretained(&locked)));
72 EXPECT_TRUE(locked); 70 EXPECT_TRUE(locked);
73 EXPECT_EQ(1u, image_controller()->num_locked_images()); 71 EXPECT_EQ(1u, image_controller()->num_locked_images());
74 72
75 decoded_image_tracker()->NotifyFrameFinished(); 73 decoded_image_tracker()->NotifyFrameFinished();
76 EXPECT_EQ(1u, image_controller()->num_locked_images()); 74 EXPECT_EQ(1u, image_controller()->num_locked_images());
77 75
78 locked = false; 76 locked = false;
79 decoded_image_tracker()->QueueImageDecode( 77 decoded_image_tracker()->QueueImageDecode(
80 nullptr, 78 nullptr, base::Bind([](bool* locked, bool success) { *locked = true; },
81 base::Bind([](bool* locked, bool success) { *locked = true; }, 79 base::Unretained(&locked)));
82 base::Unretained(&locked)));
83 EXPECT_TRUE(locked); 80 EXPECT_TRUE(locked);
84 EXPECT_EQ(2u, image_controller()->num_locked_images()); 81 EXPECT_EQ(2u, image_controller()->num_locked_images());
85 82
86 decoded_image_tracker()->NotifyFrameFinished(); 83 decoded_image_tracker()->NotifyFrameFinished();
87 EXPECT_EQ(1u, image_controller()->num_locked_images()); 84 EXPECT_EQ(1u, image_controller()->num_locked_images());
88 85
89 decoded_image_tracker()->NotifyFrameFinished(); 86 decoded_image_tracker()->NotifyFrameFinished();
90 EXPECT_EQ(0u, image_controller()->num_locked_images()); 87 EXPECT_EQ(0u, image_controller()->num_locked_images());
91 } 88 }
92 89
93 } // namespace cc 90 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/image_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698