Chromium Code Reviews| Index: tests/GrUnitTests.cpp |
| diff --git a/src/gpu/gr_unittests.cpp b/tests/GrUnitTests.cpp |
| similarity index 67% |
| rename from src/gpu/gr_unittests.cpp |
| rename to tests/GrUnitTests.cpp |
| index ae9f67f28e4c68143bdf1d07c30f1cc922936308..9f2341dd1bc975d171f47293a6f3296d698f92d2 100644 |
| --- a/src/gpu/gr_unittests.cpp |
| +++ b/tests/GrUnitTests.cpp |
| @@ -5,19 +5,17 @@ |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| - |
| +#include "Test.h" |
|
mtklein
2013/11/26 14:20:43
Given the opportunity to start fresh, personally I
Kimmo Kinnunen
2013/11/27 08:16:54
Done.
|
| +// This is a GPU-backend specific test |
| +#if SK_SUPPORT_GPU |
|
mtklein
2013/11/26 14:20:43
Do any of these actually require SK_SUPPORT_GPU?
Kimmo Kinnunen
2013/11/27 08:16:54
Well, I thought the general line of thought is:
-
|
| #include "GrBinHashKey.h" |
| #include "GrDrawTarget.h" |
| #include "SkMatrix.h" |
| #include "GrRedBlackTree.h" |
| -// FIXME: needs to be in a header |
| -void gr_run_unittests(); |
| - |
| // If we aren't inheriting these as #defines from elsewhere, |
| // clang demands they be declared before we #include the template |
| // that relies on them. |
| -#ifdef SK_DEBUG |
| static bool LT(const int& elem, int value) { |
| return elem < value; |
| } |
| @@ -26,7 +24,7 @@ static bool EQ(const int& elem, int value) { |
| } |
| #include "GrTBSearch.h" |
| -static void test_bsearch() { |
| +static void test_bsearch(skiatest::Reporter* reporter) { |
| const int array[] = { |
| 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99 |
| }; |
| @@ -34,18 +32,17 @@ static void test_bsearch() { |
| for (int n = 0; n < static_cast<int>(GR_ARRAY_COUNT(array)); ++n) { |
| for (int i = 0; i < n; i++) { |
| int index = GrTBSearch<int, int>(array, n, array[i]); |
| - SkASSERT(index == (int) i); |
| + REPORTER_ASSERT(reporter, index == (int) i); |
| index = GrTBSearch<int, int>(array, n, -array[i]); |
| - SkASSERT(index < 0); |
| + REPORTER_ASSERT(reporter, index < 0); |
| } |
| } |
| } |
| -#endif |
| // bogus empty class for GrBinHashKey |
| class BogusEntry {}; |
| -static void test_binHashKey() |
| +static void test_binHashKey(skiatest::Reporter* reporter) |
| { |
| const char* testStringA_ = "abcdABCD"; |
| const char* testStringB_ = "abcdBBCD"; |
| @@ -59,22 +56,27 @@ static void test_binHashKey() |
| keyA.setKeyData(testStringA); |
| // test copy constructor and comparison |
| GrTBinHashKey<BogusEntry, kDataLenUsedForKey> keyA2(keyA); |
| - SkASSERT(keyA.compare(keyA2) == 0); |
| - SkASSERT(keyA.getHash() == keyA2.getHash()); |
| + REPORTER_ASSERT(reporter, keyA.EQ(keyA2)); |
| + REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); |
| // test re-init |
| keyA2.setKeyData(testStringA); |
| - SkASSERT(keyA.compare(keyA2) == 0); |
| - SkASSERT(keyA.getHash() == keyA2.getHash()); |
| + REPORTER_ASSERT(reporter, keyA.EQ(keyA2)); |
| + REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); |
| // test sorting |
| GrTBinHashKey<BogusEntry, kDataLenUsedForKey> keyB; |
| keyB.setKeyData(testStringB); |
| - SkASSERT(keyA.compare(keyB) < 0); |
| - SkASSERT(keyA.getHash() != keyB.getHash()); |
| + REPORTER_ASSERT(reporter, keyA.LT(keyB)); |
| + REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash()); |
| } |
| -void gr_run_unittests() { |
| - SkDEBUGCODE(test_bsearch();) |
| - test_binHashKey(); |
| +static void test_gr(skiatest::Reporter* reporter) { |
| + test_bsearch(reporter); |
| + test_binHashKey(reporter); |
| GrRedBlackTree<int>::UnitTest(); |
| } |
| + |
| +#include "TestClassDef.h" |
| +DEFINE_TESTCLASS("GrUnitTests", GrUnitTests, test_gr) |
| + |
| +#endif |