OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 "public/platform/WebImage.h" | 31 #include "public/platform/WebImage.h" |
32 | 32 |
33 #include "platform/SharedBuffer.h" | 33 #include "platform/SharedBuffer.h" |
34 #include "platform/testing/UnitTestHelpers.h" | 34 #include "platform/testing/UnitTestHelpers.h" |
35 #include "public/platform/Platform.h" | |
36 #include "public/platform/WebData.h" | 35 #include "public/platform/WebData.h" |
37 #include "public/platform/WebSize.h" | 36 #include "public/platform/WebSize.h" |
38 #include "public/platform/WebUnitTestSupport.h" | |
39 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
40 | 38 |
41 namespace blink { | 39 namespace blink { |
42 | 40 |
43 static PassRefPtr<SharedBuffer> readFile(const char* fileName) | 41 static PassRefPtr<SharedBuffer> readFile(const char* fileName) |
44 { | 42 { |
45 String filePath = testing::blinkRootDir(); | 43 String filePath = testing::blinkRootDir(); |
46 filePath.append("/Source/web/tests/data/"); | 44 filePath.append("/Source/web/tests/data/"); |
47 filePath.append(fileName); | 45 filePath.append(fileName); |
48 | 46 |
49 return Platform::current()->unitTestSupport()->readFromFile(filePath); | 47 return testing::readFromFile(filePath); |
50 } | 48 } |
51 | 49 |
52 TEST(WebImageTest, PNGImage) | 50 TEST(WebImageTest, PNGImage) |
53 { | 51 { |
54 RefPtr<SharedBuffer> data = readFile("white-1x1.png"); | 52 RefPtr<SharedBuffer> data = readFile("white-1x1.png"); |
55 ASSERT_TRUE(data.get()); | 53 ASSERT_TRUE(data.get()); |
56 | 54 |
57 WebImage image = WebImage::fromData(WebData(data), WebSize()); | 55 WebImage image = WebImage::fromData(WebData(data), WebSize()); |
58 EXPECT_TRUE(image.size() == WebSize(1, 1)); | 56 EXPECT_TRUE(image.size() == WebSize(1, 1)); |
59 SkAutoLockPixels autoLock(image.getSkBitmap()); | 57 SkAutoLockPixels autoLock(image.getSkBitmap()); |
(...skipping 29 matching lines...) Expand all Loading... |
89 const char badImage[] = "hello world"; | 87 const char badImage[] = "hello world"; |
90 WebVector<WebImage> images = WebImage::framesFromData(WebData(badImage)); | 88 WebVector<WebImage> images = WebImage::framesFromData(WebData(badImage)); |
91 ASSERT_EQ(0u, images.size()); | 89 ASSERT_EQ(0u, images.size()); |
92 | 90 |
93 WebImage image = WebImage::fromData(WebData(badImage), WebSize()); | 91 WebImage image = WebImage::fromData(WebData(badImage), WebSize()); |
94 EXPECT_TRUE(image.getSkBitmap().empty()); | 92 EXPECT_TRUE(image.getSkBitmap().empty()); |
95 EXPECT_TRUE(image.getSkBitmap().isNull()); | 93 EXPECT_TRUE(image.getSkBitmap().isNull()); |
96 } | 94 } |
97 | 95 |
98 } // namespace blink | 96 } // namespace blink |
OLD | NEW |