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

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

Issue 2929493002: Plumb PaintImage for the img.decode instead of SkImage. (Closed)
Patch Set: Created 3 years, 6 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/tiles/decoded_image_tracker.cc ('k') | cc/trees/layer_tree_host.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, base::Bind([](bool* locked, bool success) { *locked = true; }, 59 PaintImage(),
60 base::Unretained(&locked))); 60 base::Bind([](bool* locked, bool success) { *locked = true; },
61 base::Unretained(&locked)));
61 EXPECT_TRUE(locked); 62 EXPECT_TRUE(locked);
62 EXPECT_EQ(1u, image_controller()->num_locked_images()); 63 EXPECT_EQ(1u, image_controller()->num_locked_images());
63 } 64 }
64 65
65 TEST_F(DecodedImageTrackerTest, NotifyFrameFinishedUnlocksImages) { 66 TEST_F(DecodedImageTrackerTest, NotifyFrameFinishedUnlocksImages) {
66 bool locked = false; 67 bool locked = false;
67 decoded_image_tracker()->QueueImageDecode( 68 decoded_image_tracker()->QueueImageDecode(
68 nullptr, base::Bind([](bool* locked, bool success) { *locked = true; }, 69 PaintImage(),
69 base::Unretained(&locked))); 70 base::Bind([](bool* locked, bool success) { *locked = true; },
71 base::Unretained(&locked)));
70 EXPECT_TRUE(locked); 72 EXPECT_TRUE(locked);
71 EXPECT_EQ(1u, image_controller()->num_locked_images()); 73 EXPECT_EQ(1u, image_controller()->num_locked_images());
72 74
73 decoded_image_tracker()->NotifyFrameFinished(); 75 decoded_image_tracker()->NotifyFrameFinished();
74 EXPECT_EQ(1u, image_controller()->num_locked_images()); 76 EXPECT_EQ(1u, image_controller()->num_locked_images());
75 77
76 locked = false; 78 locked = false;
77 decoded_image_tracker()->QueueImageDecode( 79 decoded_image_tracker()->QueueImageDecode(
78 nullptr, base::Bind([](bool* locked, bool success) { *locked = true; }, 80 PaintImage(),
79 base::Unretained(&locked))); 81 base::Bind([](bool* locked, bool success) { *locked = true; },
82 base::Unretained(&locked)));
80 EXPECT_TRUE(locked); 83 EXPECT_TRUE(locked);
81 EXPECT_EQ(2u, image_controller()->num_locked_images()); 84 EXPECT_EQ(2u, image_controller()->num_locked_images());
82 85
83 decoded_image_tracker()->NotifyFrameFinished(); 86 decoded_image_tracker()->NotifyFrameFinished();
84 EXPECT_EQ(1u, image_controller()->num_locked_images()); 87 EXPECT_EQ(1u, image_controller()->num_locked_images());
85 88
86 decoded_image_tracker()->NotifyFrameFinished(); 89 decoded_image_tracker()->NotifyFrameFinished();
87 EXPECT_EQ(0u, image_controller()->num_locked_images()); 90 EXPECT_EQ(0u, image_controller()->num_locked_images());
88 } 91 }
89 92
90 } // namespace cc 93 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/decoded_image_tracker.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698