diff options
-rw-r--r-- | gyp/tests.gyp | 27 | ||||
-rw-r--r-- | src/utils/SkBase64.cpp | 21 | ||||
-rw-r--r-- | src/utils/SkBase64.h | 5 | ||||
-rw-r--r-- | tests/SkBase64Test.cpp | 28 |
4 files changed, 42 insertions, 39 deletions
diff --git a/gyp/tests.gyp b/gyp/tests.gyp index 2edb03f522..827ba3f7f2 100644 --- a/gyp/tests.gyp +++ b/gyp/tests.gyp @@ -28,21 +28,21 @@ ], 'sources': [ '../tests/AAClipTest.cpp', + '../tests/ARGBImageEncoderTest.cpp', '../tests/AndroidPaintTest.cpp', '../tests/AnnotationTest.cpp', - '../tests/ARGBImageEncoderTest.cpp', '../tests/AtomicTest.cpp', - '../tests/BitmapTest.cpp', + '../tests/BitSetTest.cpp', '../tests/BitmapCopyTest.cpp', '../tests/BitmapGetColorTest.cpp', '../tests/BitmapHasherTest.cpp', '../tests/BitmapHeapTest.cpp', - '../tests/BitSetTest.cpp', + '../tests/BitmapTest.cpp', '../tests/BlitRowTest.cpp', '../tests/BlurTest.cpp', '../tests/CachedDecodingPixelRefTest.cpp', - '../tests/CanvasTest.cpp', '../tests/CanvasStateTest.cpp', + '../tests/CanvasTest.cpp', '../tests/ChecksumTest.cpp', '../tests/ClampRangeTest.cpp', '../tests/ClipCacheTest.cpp', @@ -74,9 +74,9 @@ '../tests/FontMgrTest.cpp', '../tests/FontNamesTest.cpp', '../tests/FrontBufferedStreamTest.cpp', - '../tests/GeometryTest.cpp', '../tests/GLInterfaceValidation.cpp', '../tests/GLProgramsTest.cpp', + '../tests/GeometryTest.cpp', '../tests/GifTest.cpp', '../tests/GpuBitmapCopyTest.cpp', '../tests/GpuColorFilterTest.cpp', @@ -99,15 +99,16 @@ '../tests/MD5Test.cpp', '../tests/MallocPixelRefTest.cpp', '../tests/MathTest.cpp', - '../tests/MatrixTest.cpp', '../tests/Matrix44Test.cpp', + '../tests/MatrixTest.cpp', '../tests/MemoryTest.cpp', '../tests/MemsetTest.cpp', '../tests/MessageBusTest.cpp', '../tests/MetaDataTest.cpp', '../tests/MipMapTest.cpp', - '../tests/OnceTest.cpp', '../tests/OSPathTest.cpp', + '../tests/OnceTest.cpp', + '../tests/PDFPrimitivesTest.cpp', '../tests/PackBitsTest.cpp', '../tests/PaintTest.cpp', '../tests/ParsePathTest.cpp', @@ -115,7 +116,6 @@ '../tests/PathMeasureTest.cpp', '../tests/PathTest.cpp', '../tests/PathUtilsTest.cpp', - '../tests/PDFPrimitivesTest.cpp', '../tests/PictureTest.cpp', '../tests/PictureUtilsTest.cpp', '../tests/PipeTest.cpp', @@ -123,35 +123,35 @@ '../tests/PointTest.cpp', '../tests/PremulAlphaRoundTripTest.cpp', '../tests/QuickRejectTest.cpp', + '../tests/RTreeTest.cpp', '../tests/RandomTest.cpp', - '../tests/Reader32Test.cpp', '../tests/ReadPixelsTest.cpp', '../tests/ReadWriteAlphaTest.cpp', + '../tests/Reader32Test.cpp', '../tests/RefCntTest.cpp', '../tests/RefDictTest.cpp', '../tests/RegionTest.cpp', '../tests/ResourceCacheTest.cpp', '../tests/RoundRectTest.cpp', '../tests/RuntimeConfigTest.cpp', - '../tests/RTreeTest.cpp', '../tests/SHA1Test.cpp', '../tests/ScalarTest.cpp', '../tests/SerializationTest.cpp', '../tests/ShaderImageFilterTest.cpp', '../tests/ShaderOpacityTest.cpp', - '../tests/skia_test.cpp', + '../tests/SkBase64Test.cpp', '../tests/SortTest.cpp', '../tests/SrcOverTest.cpp', '../tests/StreamTest.cpp', '../tests/StringTest.cpp', '../tests/StrokeTest.cpp', '../tests/SurfaceTest.cpp', + '../tests/TLSTest.cpp', + '../tests/TSetTest.cpp', '../tests/Test.cpp', '../tests/Test.h', '../tests/TestSize.cpp', '../tests/TileGridTest.cpp', - '../tests/TLSTest.cpp', - '../tests/TSetTest.cpp', '../tests/ToUnicode.cpp', '../tests/Typeface.cpp', '../tests/UnicodeTest.cpp', @@ -161,6 +161,7 @@ '../tests/WritePixelsTest.cpp', '../tests/Writer32Test.cpp', '../tests/XfermodeTest.cpp', + '../tests/skia_test.cpp', '../experimental/PdfViewer/src/SkTDStackNester.h', '../tests/TDStackNesterTest.cpp', diff --git a/src/utils/SkBase64.cpp b/src/utils/SkBase64.cpp index 11b647fe9a..545a8ebb21 100644 --- a/src/utils/SkBase64.cpp +++ b/src/utils/SkBase64.cpp @@ -162,24 +162,3 @@ SkBase64::Error SkBase64::decode(const char* src, size_t len) { decode(src, len, true); return kNoError; } - -#ifdef SK_SUPPORT_UNITTEST -void SkBase64::UnitTest() { - signed char all[256]; - for (int index = 0; index < 256; index++) - all[index] = (signed char) (index + 1); - for (int offset = 0; offset < 6; offset++) { - size_t length = 256 - offset; - size_t encodeLength = Encode(all + offset, length, NULL); - char* src = (char*)sk_malloc_throw(encodeLength + 1); - Encode(all + offset, length, src); - src[encodeLength] = '\0'; - SkBase64 tryMe; - tryMe.decode(src, encodeLength); - SkASSERT(length == tryMe.fLength); - SkASSERT(strcmp((const char*) (all + offset), tryMe.fData) == 0); - sk_free(src); - delete[] tryMe.fData; - } -} -#endif diff --git a/src/utils/SkBase64.h b/src/utils/SkBase64.h index 5bf9006632..ba66dd2f47 100644 --- a/src/utils/SkBase64.h +++ b/src/utils/SkBase64.h @@ -1,4 +1,3 @@ - /* * Copyright 2006 The Android Open Source Project * @@ -6,7 +5,6 @@ * found in the LICENSE file. */ - #ifndef SkBase64_DEFINED #define SkBase64_DEFINED @@ -30,9 +28,6 @@ public: */ static size_t Encode(const void* src, size_t length, void* dest, const char* encode = NULL); -#ifdef SK_SUPPORT_UNITTEST - static void UnitTest(); -#endif private: Error decode(const void* srcPtr, size_t length, bool writeDestination); diff --git a/tests/SkBase64Test.cpp b/tests/SkBase64Test.cpp new file mode 100644 index 0000000000..aba9691106 --- /dev/null +++ b/tests/SkBase64Test.cpp @@ -0,0 +1,28 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkBase64.h" + +#include "Test.h" + +DEF_TEST(SkBase64Test, reporter) { + char all[256]; + for (int index = 0; index < 256; index++) { + all[index] = (signed char) (index + 1); + } + + for (int offset = 0; offset < 6; offset++) { + size_t length = 256 - offset; + size_t encodeLength = SkBase64::Encode(all + offset, length, NULL); + SkAutoTMalloc<char> src(encodeLength + 1); + SkBase64::Encode(all + offset, length, src.get()); + SkBase64 tryMe; + tryMe.decode(src.get(), encodeLength); + REPORTER_ASSERT(reporter, (strcmp((const char*) (all + offset), tryMe.getData()) == 0)); + delete[] tryMe.getData(); + } +} |