| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |