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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 428443002: Cleanup: Rename SkOSPath functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 4 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 | « tests/FontHostTest.cpp ('k') | tests/OSPathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // This test cannot run if there is no resource path. 151 // This test cannot run if there is no resource path.
152 SkString resourcePath = GetResourcePath(); 152 SkString resourcePath = GetResourcePath();
153 if (resourcePath.isEmpty()) { 153 if (resourcePath.isEmpty()) {
154 SkDebugf("Could not run unpremul test because resourcePath not specified ."); 154 SkDebugf("Could not run unpremul test because resourcePath not specified .");
155 return; 155 return;
156 } 156 }
157 SkOSFile::Iter iter(resourcePath.c_str()); 157 SkOSFile::Iter iter(resourcePath.c_str());
158 SkString basename; 158 SkString basename;
159 if (iter.next(&basename)) { 159 if (iter.next(&basename)) {
160 do { 160 do {
161 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basen ame.c_str()); 161 SkString filename = SkOSPath::Join(resourcePath.c_str(), basename.c_ str());
162 // SkDebugf("about to decode \"%s\"\n", filename.c_str()); 162 // SkDebugf("about to decode \"%s\"\n", filename.c_str());
163 compare_unpremul(reporter, filename); 163 compare_unpremul(reporter, filename);
164 } while (iter.next(&basename)); 164 } while (iter.next(&basename));
165 } else { 165 } else {
166 SkDebugf("Failed to find any files :(\n"); 166 SkDebugf("Failed to find any files :(\n");
167 } 167 }
168 } 168 }
169 169
170 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX) 170 #if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
171 // Test that the alpha type is what we expect. 171 // Test that the alpha type is what we expect.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 SkString resourcePath = GetResourcePath(); 234 SkString resourcePath = GetResourcePath();
235 if (resourcePath.isEmpty()) { 235 if (resourcePath.isEmpty()) {
236 SkDebugf("Could not run alphaType test because resourcePath not specifie d."); 236 SkDebugf("Could not run alphaType test because resourcePath not specifie d.");
237 return; 237 return;
238 } 238 }
239 239
240 SkOSFile::Iter iter(resourcePath.c_str()); 240 SkOSFile::Iter iter(resourcePath.c_str());
241 SkString basename; 241 SkString basename;
242 if (iter.next(&basename)) { 242 if (iter.next(&basename)) {
243 do { 243 do {
244 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basen ame.c_str()); 244 SkString filename = SkOSPath::Join(resourcePath.c_str(), basename.c_ str());
245 for (int truth = 0; truth <= 1; ++truth) { 245 for (int truth = 0; truth <= 1; ++truth) {
246 test_alphaType(reporter, filename, SkToBool(truth)); 246 test_alphaType(reporter, filename, SkToBool(truth));
247 } 247 }
248 } while (iter.next(&basename)); 248 } while (iter.next(&basename));
249 } else { 249 } else {
250 SkDebugf("Failed to find any files :(\n"); 250 SkDebugf("Failed to find any files :(\n");
251 } 251 }
252 252
253 } 253 }
254 254
255 // Using known images, test that decoding into unpremul and premul behave as exp ected. 255 // Using known images, test that decoding into unpremul and premul behave as exp ected.
256 DEF_TEST(ImageDecoding_unpremul, reporter) { 256 DEF_TEST(ImageDecoding_unpremul, reporter) {
257 SkString resourcePath = GetResourcePath(); 257 SkString resourcePath = GetResourcePath();
258 if (resourcePath.isEmpty()) { 258 if (resourcePath.isEmpty()) {
259 SkDebugf("Could not run unpremul test because resourcePath not specified ."); 259 SkDebugf("Could not run unpremul test because resourcePath not specified .");
260 return; 260 return;
261 } 261 }
262 const char* root = "half-transparent-white-pixel"; 262 const char* root = "half-transparent-white-pixel";
263 const char* suffixes[] = { ".png", ".webp" }; 263 const char* suffixes[] = { ".png", ".webp" };
264 264
265 for (size_t i = 0; i < SK_ARRAY_COUNT(suffixes); ++i) { 265 for (size_t i = 0; i < SK_ARRAY_COUNT(suffixes); ++i) {
266 SkString basename = SkStringPrintf("%s%s", root, suffixes[i]); 266 SkString basename = SkStringPrintf("%s%s", root, suffixes[i]);
267 SkString fullName = SkOSPath::SkPathJoin(resourcePath.c_str(), basename. c_str()); 267 SkString fullName = SkOSPath::Join(resourcePath.c_str(), basename.c_str( ));
268 268
269 SkBitmap bm; 269 SkBitmap bm;
270 SkFILEStream stream(fullName.c_str()); 270 SkFILEStream stream(fullName.c_str());
271 271
272 if (!stream.isValid()) { 272 if (!stream.isValid()) {
273 SkDebugf("file %s missing from resource directoy %s\n", 273 SkDebugf("file %s missing from resource directoy %s\n",
274 basename.c_str(), resourcePath.c_str()); 274 basename.c_str(), resourcePath.c_str());
275 continue; 275 continue;
276 } 276 }
277 277
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 kAlpha_8_SkColorType, 685 kAlpha_8_SkColorType,
686 kRGB_565_SkColorType, 686 kRGB_565_SkColorType,
687 kARGB_4444_SkColorType, // Most decoders will fail on 4444. 687 kARGB_4444_SkColorType, // Most decoders will fail on 4444.
688 kN32_SkColorType 688 kN32_SkColorType
689 // Note that indexed color is left out of the list. Lazy 689 // Note that indexed color is left out of the list. Lazy
690 // decoding doesn't do indexed color. 690 // decoding doesn't do indexed color.
691 }; 691 };
692 const bool useDataList[] = {true, false}; 692 const bool useDataList[] = {true, false};
693 693
694 for (size_t fidx = 0; fidx < SK_ARRAY_COUNT(files); ++fidx) { 694 for (size_t fidx = 0; fidx < SK_ARRAY_COUNT(files); ++fidx) {
695 SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), files[fidx]); 695 SkString path = SkOSPath::Join(resourceDir.c_str(), files[fidx]);
696 if (!sk_exists(path.c_str())) { 696 if (!sk_exists(path.c_str())) {
697 continue; 697 continue;
698 } 698 }
699 699
700 SkAutoDataUnref encodedData(SkData::NewFromFileName(path.c_str())); 700 SkAutoDataUnref encodedData(SkData::NewFromFileName(path.c_str()));
701 REPORTER_ASSERT(reporter, encodedData.get() != NULL); 701 REPORTER_ASSERT(reporter, encodedData.get() != NULL);
702 SkAutoTUnref<SkStreamRewindable> encodedStream( 702 SkAutoTUnref<SkStreamRewindable> encodedStream(
703 SkStream::NewFromFile(path.c_str())); 703 SkStream::NewFromFile(path.c_str()));
704 REPORTER_ASSERT(reporter, encodedStream.get() != NULL); 704 REPORTER_ASSERT(reporter, encodedStream.get() != NULL);
705 705
(...skipping 13 matching lines...) Expand all
719 test_options(reporter, options, encodedStream, encodedData, 719 test_options(reporter, options, encodedStream, encodedData,
720 useDataList[m], path); 720 useDataList[m], path);
721 } 721 }
722 } 722 }
723 } 723 }
724 } 724 }
725 } 725 }
726 726
727 DEF_TEST(DiscardablePixelRef_SecondLockColorTableCheck, r) { 727 DEF_TEST(DiscardablePixelRef_SecondLockColorTableCheck, r) {
728 SkString resourceDir = GetResourcePath(); 728 SkString resourceDir = GetResourcePath();
729 SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), "randPixels.gif"); 729 SkString path = SkOSPath::Join(resourceDir.c_str(), "randPixels.gif");
730 if (!sk_exists(path.c_str())) { 730 if (!sk_exists(path.c_str())) {
731 return; 731 return;
732 } 732 }
733 SkAutoDataUnref encoded(SkData::NewFromFileName(path.c_str())); 733 SkAutoDataUnref encoded(SkData::NewFromFileName(path.c_str()));
734 SkBitmap bitmap; 734 SkBitmap bitmap;
735 if (!SkInstallDiscardablePixelRef( 735 if (!SkInstallDiscardablePixelRef(
736 SkDecodingImageGenerator::Create( 736 SkDecodingImageGenerator::Create(
737 encoded, SkDecodingImageGenerator::Options()), &bitmap)) { 737 encoded, SkDecodingImageGenerator::Options()), &bitmap)) {
738 #ifndef SK_BUILD_FOR_WIN 738 #ifndef SK_BUILD_FOR_WIN
739 ERRORF(r, "SkInstallDiscardablePixelRef [randPixels.gif] failed."); 739 ERRORF(r, "SkInstallDiscardablePixelRef [randPixels.gif] failed.");
740 #endif 740 #endif
741 return; 741 return;
742 } 742 }
743 if (kIndex_8_SkColorType != bitmap.colorType()) { 743 if (kIndex_8_SkColorType != bitmap.colorType()) {
744 return; 744 return;
745 } 745 }
746 { 746 {
747 SkAutoLockPixels alp(bitmap); 747 SkAutoLockPixels alp(bitmap);
748 REPORTER_ASSERT(r, bitmap.getColorTable() && "first pass"); 748 REPORTER_ASSERT(r, bitmap.getColorTable() && "first pass");
749 } 749 }
750 { 750 {
751 SkAutoLockPixels alp(bitmap); 751 SkAutoLockPixels alp(bitmap);
752 REPORTER_ASSERT(r, bitmap.getColorTable() && "second pass"); 752 REPORTER_ASSERT(r, bitmap.getColorTable() && "second pass");
753 } 753 }
754 } 754 }
OLDNEW
« no previous file with comments | « tests/FontHostTest.cpp ('k') | tests/OSPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698