aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-06 15:07:44 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-06 15:07:44 +0000
commit1f0121af495e5a70ecff2521729b7749c81a20b2 (patch)
treea48e5ba75ef0fb82510ee51823f9ac7879a47c20 /tests
parent137577861db78d6a4a63e8adbf54467557d2b26a (diff)
New SkRTConf macro SK_CONF_TRY_SET: no complaint on missing configuration
SK_CONF_TRY_SET() is like SK_CONF_SET(), but doesn't complain if confname can't be found. This is useful if the SK_CONF_DECLARE is inside a source file whose linkage is dependent on the system. Internally to the SkRTConf system, SkRTConfRegistry::set() was given an additional parameter controling wanrings. A new RuntimeConfig unit test was introduced. It should run silently. In the future, it should be expanded to cover all of the SkRTConf functionality. (For example, the images.jpeg.suppressDecoderWarnings variable is defined and used only in SkImageDecoder_libjpeg.cpp, but on MacOS, we use Core Graphics via SkImageDecoder_CG.cpp - SkImageDecoder_libjpeg is never linked in. The same is true of the Windows Imaging Component on Windows.) BUG= R=reed@google.com Review URL: https://codereview.chromium.org/54503007 git-svn-id: http://skia.googlecode.com/svn/trunk@12155 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/RuntimeConfigTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/RuntimeConfigTest.cpp b/tests/RuntimeConfigTest.cpp
new file mode 100644
index 0000000000..b2e179cfff
--- /dev/null
+++ b/tests/RuntimeConfigTest.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "SkRTConf.h"
+#include "Test.h"
+#include "TestClassDef.h"
+
+SK_CONF_DECLARE(int, c_RTConfTestVariable,
+ "test.utils.rtconf.testVariable", 1,
+ "This is only a test. Do not be alarmed.");
+// TODO(skia-team): more comprehensive unit tests of the SkRTConf
+// system.
+DEF_TEST(RuntimeConfig, reporter) {
+ REPORTER_ASSERT(reporter, 1 == c_RTConfTestVariable);
+
+ SK_CONF_SET("test.utils.rtconf.testVariable", 2);
+#ifdef SK_DEVELOPER
+ REPORTER_ASSERT(reporter, 2 == c_RTConfTestVariable);
+#else // not SK_DEVELOPER
+ // Can not change RTConf variables in Release.
+ REPORTER_ASSERT(reporter, 1 == c_RTConfTestVariable);
+#endif // SK_DEVELOPER
+
+ // This should not give a warning.
+ SK_CONF_TRY_SET("test.utils.rtconf.nonexistentVariable", 7);
+}