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 21 matching lines...) Expand all Loading... |
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/WebData.h" | 35 #include "public/platform/WebData.h" |
36 #include "public/platform/WebSize.h" | 36 #include "public/platform/WebSize.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 static PassRefPtr<SharedBuffer> readFile(const char* fileName) { | 41 static PassRefPtr<SharedBuffer> readFile(const char* fileName) { |
42 String filePath = testing::blinkRootDir(); | 42 String filePath = testing::webTestDataPath(fileName); |
43 filePath.append("/Source/web/tests/data/"); | |
44 filePath.append(fileName); | |
45 | 43 |
46 return testing::readFromFile(filePath); | 44 return testing::readFromFile(filePath); |
47 } | 45 } |
48 | 46 |
49 TEST(WebImageTest, PNGImage) { | 47 TEST(WebImageTest, PNGImage) { |
50 RefPtr<SharedBuffer> data = readFile("white-1x1.png"); | 48 RefPtr<SharedBuffer> data = readFile("white-1x1.png"); |
51 ASSERT_TRUE(data.get()); | 49 ASSERT_TRUE(data.get()); |
52 | 50 |
53 WebImage image = WebImage::fromData(WebData(data), WebSize()); | 51 WebImage image = WebImage::fromData(WebData(data), WebSize()); |
54 EXPECT_TRUE(image.size() == WebSize(1, 1)); | 52 EXPECT_TRUE(image.size() == WebSize(1, 1)); |
(...skipping 30 matching lines...) Expand all Loading... |
85 const char badImage[] = "hello world"; | 83 const char badImage[] = "hello world"; |
86 WebVector<WebImage> images = WebImage::framesFromData(WebData(badImage)); | 84 WebVector<WebImage> images = WebImage::framesFromData(WebData(badImage)); |
87 ASSERT_EQ(0u, images.size()); | 85 ASSERT_EQ(0u, images.size()); |
88 | 86 |
89 WebImage image = WebImage::fromData(WebData(badImage), WebSize()); | 87 WebImage image = WebImage::fromData(WebData(badImage), WebSize()); |
90 EXPECT_TRUE(image.getSkBitmap().empty()); | 88 EXPECT_TRUE(image.getSkBitmap().empty()); |
91 EXPECT_TRUE(image.getSkBitmap().isNull()); | 89 EXPECT_TRUE(image.getSkBitmap().isNull()); |
92 } | 90 } |
93 | 91 |
94 } // namespace blink | 92 } // namespace blink |
OLD | NEW |