OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/graphics/BitmapImage.h" | 31 #include "platform/graphics/BitmapImage.h" |
32 | 32 |
33 #include "platform/SharedBuffer.h" | 33 #include "platform/SharedBuffer.h" |
34 #include "platform/graphics/BitmapImageMetrics.h" | 34 #include "platform/graphics/BitmapImageMetrics.h" |
35 #include "platform/graphics/DeferredImageDecoder.h" | 35 #include "platform/graphics/DeferredImageDecoder.h" |
36 #include "platform/graphics/ImageObserver.h" | 36 #include "platform/graphics/ImageObserver.h" |
37 #include "platform/testing/HistogramTester.h" | 37 #include "platform/testing/HistogramTester.h" |
38 #include "platform/testing/TestingPlatformSupport.h" | |
39 #include "platform/testing/UnitTestHelpers.h" | 38 #include "platform/testing/UnitTestHelpers.h" |
40 #include "platform/wtf/StdLibExtras.h" | 39 #include "platform/wtf/StdLibExtras.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "third_party/skia/include/core/SkImage.h" | 41 #include "third_party/skia/include/core/SkImage.h" |
43 | 42 |
44 namespace blink { | 43 namespace blink { |
45 | 44 |
46 class BitmapImageTest : public ::testing::Test { | 45 class BitmapImageTest : public ::testing::Test { |
47 public: | 46 public: |
48 class FakeImageObserver : public GarbageCollectedFinalized<FakeImageObserver>, | 47 class FakeImageObserver : public GarbageCollectedFinalized<FakeImageObserver>, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 PassRefPtr<SharedBuffer> Data() { return image_->Data(); } | 133 PassRefPtr<SharedBuffer> Data() { return image_->Data(); } |
135 | 134 |
136 protected: | 135 protected: |
137 void SetUp() override { | 136 void SetUp() override { |
138 image_observer_ = new FakeImageObserver; | 137 image_observer_ = new FakeImageObserver; |
139 image_ = BitmapImage::Create(image_observer_.Get()); | 138 image_ = BitmapImage::Create(image_observer_.Get()); |
140 } | 139 } |
141 | 140 |
142 Persistent<FakeImageObserver> image_observer_; | 141 Persistent<FakeImageObserver> image_observer_; |
143 RefPtr<BitmapImage> image_; | 142 RefPtr<BitmapImage> image_; |
144 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler> | |
145 platform_; | |
146 }; | 143 }; |
147 | 144 |
148 TEST_F(BitmapImageTest, destroyDecodedData) { | 145 TEST_F(BitmapImageTest, destroyDecodedData) { |
149 LoadImage("/LayoutTests/images/resources/animated-10color.gif"); | 146 LoadImage("/LayoutTests/images/resources/animated-10color.gif"); |
150 size_t total_size = DecodedSize(); | 147 size_t total_size = DecodedSize(); |
151 EXPECT_GT(total_size, 0u); | 148 EXPECT_GT(total_size, 0u); |
152 DestroyDecodedData(); | 149 DestroyDecodedData(); |
153 EXPECT_EQ(-static_cast<int>(total_size), LastDecodedSizeChange()); | 150 EXPECT_EQ(-static_cast<int>(total_size), LastDecodedSizeChange()); |
154 EXPECT_EQ(0u, DecodedSize()); | 151 EXPECT_EQ(0u, DecodedSize()); |
155 } | 152 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 kOriginRightBottom}, | 328 kOriginRightBottom}, |
332 {"/LayoutTests/images/resources/exif-orientation-8-llo.jpg", | 329 {"/LayoutTests/images/resources/exif-orientation-8-llo.jpg", |
333 kOriginLeftBottom}}; | 330 kOriginLeftBottom}}; |
334 | 331 |
335 INSTANTIATE_TEST_CASE_P( | 332 INSTANTIATE_TEST_CASE_P( |
336 DecodedImageOrientationHistogramTest, | 333 DecodedImageOrientationHistogramTest, |
337 DecodedImageOrientationHistogramTest, | 334 DecodedImageOrientationHistogramTest, |
338 ::testing::ValuesIn(kDecodedImageOrientationHistogramTestParams)); | 335 ::testing::ValuesIn(kDecodedImageOrientationHistogramTestParams)); |
339 | 336 |
340 } // namespace blink | 337 } // namespace blink |
OLD | NEW |