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

Unified Diff: tests/ImageDecodingTest.cpp

Issue 18083026: Allow decoding JPEG into A8. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Naming improvements, remove obsolete, add a test. Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« include/core/SkImageDecoder.h ('K') | « src/images/SkScaledBitmapSampler.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageDecodingTest.cpp
diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
index 9a5d45bcfa7f34a5f0951bdeb2f3aa75b1034fcc..76308c9d9782a92398ccf206c3f3fa0dff5b2de6 100644
--- a/tests/ImageDecodingTest.cpp
+++ b/tests/ImageDecodingTest.cpp
@@ -132,7 +132,41 @@ static void compare_unpremul(skiatest::Reporter* reporter, const SkString& filen
}
}
-static void test_imageDecodingTests(skiatest::Reporter* reporter) {
+// Create a fake ImageDecoder to test setPrefConfigTable for
+// backwards compatibility.
+class PrefConfigTestingImageDecoder : public SkImageDecoder {
+public:
+ void testPrefConfigTable(skiatest::Reporter* reporter) {
scroggo 2013/07/11 20:37:29 New test confirms that using the old API still beh
+ // Arbitrary list of Configs. The important thing about
+ // the list is that each one is different, so we can test
+ // to make sure the correct config is chosen.
+ const SkBitmap::Config configs[] = {
+ SkBitmap::kA1_Config,
+ SkBitmap::kA8_Config,
+ SkBitmap::kIndex8_Config,
+ SkBitmap::kRGB_565_Config,
+ SkBitmap::kARGB_4444_Config,
+ SkBitmap::kARGB_8888_Config,
+ };
+ this->setPrefConfigTable(configs);
+ REPORTER_ASSERT(reporter, configs[0] == this->getPrefConfig(kIndex_SrcDepth, false));
+ REPORTER_ASSERT(reporter, configs[1] == this->getPrefConfig(kIndex_SrcDepth, true));
+ REPORTER_ASSERT(reporter, configs[4] == this->getPrefConfig(k32Bit_SrcDepth, false));
+ REPORTER_ASSERT(reporter, configs[5] == this->getPrefConfig(k32Bit_SrcDepth, true));
+ }
+
+protected:
+ virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) SK_OVERRIDE {
+ return false;
+ }
+};
+
+static void test_pref_config_table(skiatest::Reporter* reporter) {
+ PrefConfigTestingImageDecoder decoder;
+ decoder.testPrefConfigTable(reporter);
+}
+
+static void test_unpremul(skiatest::Reporter* reporter) {
// This test cannot run if there is no resource path.
SkString resourcePath = skiatest::Test::GetResourcePath();
if (resourcePath.isEmpty()) {
@@ -151,6 +185,11 @@ static void test_imageDecodingTests(skiatest::Reporter* reporter) {
}
}
+static void test_imageDecodingTests(skiatest::Reporter* reporter) {
+ test_unpremul(reporter);
+ test_pref_config_table(reporter);
+}
+
#include "TestClassDef.h"
DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass,
test_imageDecodingTests)
« include/core/SkImageDecoder.h ('K') | « src/images/SkScaledBitmapSampler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698