aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar tfarina <tfarina@chromium.org>2014-06-18 14:32:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-18 14:32:49 -0700
commitbcbc1788b478b1e54079318ad073e8490aa66fae (patch)
tree5492557ad07a5917364b69721788bc5ec471954a /tests
parent6518eaaefac27a823c55c16c12b3c698f09aabf5 (diff)
Refactor how we handle resources path in Tests.
This idea emerged while doing https://codereview.chromium.org/321723002/ (commit 880914c35c8f7fc2e9c57134134c883baf66e538). BUG=None TEST=make tests && out/Debug/tests R=mtklein@google.com Author: tfarina@chromium.org Review URL: https://codereview.chromium.org/346453002
Diffstat (limited to 'tests')
-rw-r--r--tests/FontHostTest.cpp3
-rw-r--r--tests/ImageDecodingTest.cpp11
-rw-r--r--tests/KtxTest.cpp3
-rw-r--r--tests/Test.cpp10
-rw-r--r--tests/Test.h5
-rw-r--r--tests/skia_test.cpp5
6 files changed, 12 insertions, 25 deletions
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index bc87aaa754..23625b3874 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "Resources.h"
#include "SkEndian.h"
#include "SkFontStream.h"
#include "SkOSFile.h"
@@ -149,7 +150,7 @@ static void test_fontstream(skiatest::Reporter* reporter, SkStream* stream) {
static void test_fontstream(skiatest::Reporter* reporter) {
// This test cannot run if there is no resource path.
- SkString resourcePath = skiatest::Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
if (resourcePath.isEmpty()) {
SkDebugf("Could not run fontstream test because resourcePath not specified.");
return;
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index 3b9c194929..89db3990e4 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "Resources.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColor.h"
@@ -148,7 +149,7 @@ static void compare_unpremul(skiatest::Reporter* reporter, const SkString& filen
static void test_unpremul(skiatest::Reporter* reporter) {
// This test cannot run if there is no resource path.
- SkString resourcePath = skiatest::Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
if (resourcePath.isEmpty()) {
SkDebugf("Could not run unpremul test because resourcePath not specified.");
return;
@@ -230,7 +231,7 @@ static void test_alphaType(skiatest::Reporter* reporter, const SkString& filenam
}
DEF_TEST(ImageDecoding_alphaType, reporter) {
- SkString resourcePath = skiatest::Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
if (resourcePath.isEmpty()) {
SkDebugf("Could not run alphaType test because resourcePath not specified.");
return;
@@ -253,7 +254,7 @@ DEF_TEST(ImageDecoding_alphaType, reporter) {
// Using known images, test that decoding into unpremul and premul behave as expected.
DEF_TEST(ImageDecoding_unpremul, reporter) {
- SkString resourcePath = skiatest::Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
if (resourcePath.isEmpty()) {
SkDebugf("Could not run unpremul test because resourcePath not specified.");
return;
@@ -502,7 +503,7 @@ static SkPixelRef* install_pixel_ref(SkBitmap* bitmap,
* SkInstallDiscardablePixelRef functions.
*/
DEF_TEST(ImprovedBitmapFactory, reporter) {
- SkString resourcePath = skiatest::Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
SkString path = SkOSPath::SkPathJoin(
resourcePath.c_str(), "randPixels.png");
SkAutoTUnref<SkStreamRewindable> stream(
@@ -676,7 +677,7 @@ DEF_TEST(ImageDecoderOptions, reporter) {
#endif
};
- SkString resourceDir = skiatest::Test::GetResourcePath();
+ SkString resourceDir = GetResourcePath();
if (!sk_exists(resourceDir.c_str())) {
return;
}
diff --git a/tests/KtxTest.cpp b/tests/KtxTest.cpp
index 5cec2bf297..e9c4217ead 100644
--- a/tests/KtxTest.cpp
+++ b/tests/KtxTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "Resources.h"
#include "SkBitmap.h"
#include "SkData.h"
#include "SkDecodingImageGenerator.h"
@@ -140,7 +141,7 @@ DEF_TEST(KtxReadUnpremul, reporter) {
* the PKM to the KTX should produce an identical KTX to the one we have on file)
*/
DEF_TEST(KtxReexportPKM, reporter) {
- SkString resourcePath = skiatest::Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill_128.pkm");
// Load PKM file into a bitmap
diff --git a/tests/Test.cpp b/tests/Test.cpp
index b904d5a76d..20afd45561 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -41,8 +41,6 @@ void Reporter::endTest(Test* test) {
///////////////////////////////////////////////////////////////////////////////
-const char* Test::gResourcePath;
-
Test::Test() : fReporter(NULL), fPassed(true) {}
Test::~Test() {
@@ -122,11 +120,3 @@ SkString Test::GetTmpDir() {
const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0];
return SkString(tmpDir);
}
-
-void Test::SetResourcePath(const char* resourcePath) {
- gResourcePath = resourcePath;
-}
-
-SkString Test::GetResourcePath() {
- return SkString(gResourcePath);
-}
diff --git a/tests/Test.h b/tests/Test.h
index 90d072ef66..fc1890096e 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -62,9 +62,6 @@ namespace skiatest {
static SkString GetTmpDir();
- static void SetResourcePath(const char*);
- static SkString GetResourcePath();
-
virtual bool isGPUTest() const { return false; }
virtual void setGrContextFactory(GrContextFactory* factory) {}
@@ -73,8 +70,6 @@ namespace skiatest {
virtual void onRun(Reporter*) = 0;
private:
- static const char* gResourcePath;
-
Reporter* fReporter;
SkString fName;
bool fPassed;
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index f70a7fab62..f4b67c9bc4 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -7,6 +7,7 @@
#include "CrashHandler.h"
#include "OverwriteLine.h"
+#include "Resources.h"
#include "SkCommandLineFlags.h"
#include "SkGraphics.h"
#include "SkOSFile.h"
@@ -40,7 +41,6 @@ DEFINE_bool(cpu, true, "whether or not to run CPU tests.");
DEFINE_bool(gpu, true, "whether or not to run GPU tests.");
DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
"Run threadsafe tests on a threadpool with this many threads.");
-DEFINE_string2(resourcePath, i, "resources", "directory for test resources.");
// need to explicitly declare this, or we get some weird infinite loop llist
template TestRegistry* TestRegistry::gHead;
@@ -136,7 +136,6 @@ int tool_main(int argc, char** argv) {
SetupCrashHandler();
SkCommandLineFlags::SetUsage("");
SkCommandLineFlags::Parse(argc, argv);
- Test::SetResourcePath(FLAGS_resourcePath[0]);
#if SK_ENABLE_INST_COUNT
if (FLAGS_leaks) {
@@ -158,7 +157,7 @@ int tool_main(int argc, char** argv) {
if (!tmpDir.isEmpty()) {
header.appendf(" --tmpDir %s", tmpDir.c_str());
}
- SkString resourcePath = Test::GetResourcePath();
+ SkString resourcePath = GetResourcePath();
if (!resourcePath.isEmpty()) {
header.appendf(" --resourcePath %s", resourcePath.c_str());
}