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

Side by Side Diff: tests/KtxTest.cpp

Issue 346453002: Refactor how we handle resources path in Tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix rebase conflict Created 6 years, 6 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/ImageDecodingTest.cpp ('k') | tests/Test.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 "SkBitmap.h" 9 #include "SkBitmap.h"
9 #include "SkData.h" 10 #include "SkData.h"
10 #include "SkDecodingImageGenerator.h" 11 #include "SkDecodingImageGenerator.h"
11 #include "SkForceLinking.h" 12 #include "SkForceLinking.h"
12 #include "SkImageDecoder.h" 13 #include "SkImageDecoder.h"
13 #include "SkOSFile.h" 14 #include "SkOSFile.h"
14 #include "SkRandom.h" 15 #include "SkRandom.h"
15 #include "SkStream.h" 16 #include "SkStream.h"
16 #include "Test.h" 17 #include "Test.h"
17 18
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 row += decodedBitmap.rowBytes(); 134 row += decodedBitmap.rowBytes();
134 } 135 }
135 } 136 }
136 137
137 /** 138 /**
138 * Finally, make sure that if we get ETC1 data from a PKM file that we can then 139 * Finally, make sure that if we get ETC1 data from a PKM file that we can then
139 * accurately write it out into a KTX file (i.e. transferring the ETC1 data from 140 * accurately write it out into a KTX file (i.e. transferring the ETC1 data from
140 * the PKM to the KTX should produce an identical KTX to the one we have on file ) 141 * the PKM to the KTX should produce an identical KTX to the one we have on file )
141 */ 142 */
142 DEF_TEST(KtxReexportPKM, reporter) { 143 DEF_TEST(KtxReexportPKM, reporter) {
143 SkString resourcePath = skiatest::Test::GetResourcePath(); 144 SkString resourcePath = GetResourcePath();
144 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128 .pkm"); 145 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128 .pkm");
145 146
146 // Load PKM file into a bitmap 147 // Load PKM file into a bitmap
147 SkBitmap etcBitmap; 148 SkBitmap etcBitmap;
148 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())); 149 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str()));
149 REPORTER_ASSERT(reporter, NULL != fileData); 150 REPORTER_ASSERT(reporter, NULL != fileData);
150 151
151 bool installDiscardablePixelRefSuccess = 152 bool installDiscardablePixelRefSuccess =
152 SkInstallDiscardablePixelRef( 153 SkInstallDiscardablePixelRef(
153 SkDecodingImageGenerator::Create( 154 SkDecodingImageGenerator::Create(
154 fileData, SkDecodingImageGenerator::Options()), &etcBitmap); 155 fileData, SkDecodingImageGenerator::Options()), &etcBitmap);
155 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess); 156 REPORTER_ASSERT(reporter, installDiscardablePixelRefSuccess);
156 157
157 // Write the bitmap out to a KTX file. 158 // Write the bitmap out to a KTX file.
158 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0); 159 SkData *ktxDataPtr = SkImageEncoder::EncodeData(etcBitmap, SkImageEncoder::k KTX_Type, 0);
159 SkAutoDataUnref newKtxData(ktxDataPtr); 160 SkAutoDataUnref newKtxData(ktxDataPtr);
160 REPORTER_ASSERT(reporter, NULL != ktxDataPtr); 161 REPORTER_ASSERT(reporter, NULL != ktxDataPtr);
161 162
162 // See is this data is identical to data in existing ktx file. 163 // See is this data is identical to data in existing ktx file.
163 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_ 128.ktx"); 164 SkString ktxFilename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_ 128.ktx");
164 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str())); 165 SkAutoDataUnref oldKtxData(SkData::NewFromFileName(ktxFilename.c_str()));
165 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData)); 166 REPORTER_ASSERT(reporter, oldKtxData->equals(newKtxData));
166 } 167 }
OLDNEW
« no previous file with comments | « tests/ImageDecodingTest.cpp ('k') | tests/Test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698