aboutsummaryrefslogtreecommitdiffhomepage
path: root/platform_tools/android/tests
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-21 14:45:01 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-21 14:45:01 +0000
commitec68ee9d569907672fb3e57333b23096e4185799 (patch)
treea139c06e8525cbde289f8e2c7789f4767faa39e9 /platform_tools/android/tests
parent1d0b68c495a8a18e5e51115dd1ef5392a93eec2a (diff)
Allow running gyp_to_android without SkUserConfig.
The old code requires that include/config/SkUserConfig.h exists, to ensure that it gets copied into Android's include/core/SkUserConfig.h when we do a merge. However, if a developer wants to make changes and rerun the script, they should not have to recreate include/config/SkUserConfig.h just to rerun the script. By default, allow the original to not exist and just skip the copy. Update tests to pass. Also add tests to support this use case. Make gyp_to_android.py executable. R=robertphillips@google.com, halcanary@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/242203008 git-svn-id: http://skia.googlecode.com/svn/trunk@14273 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'platform_tools/android/tests')
-rw-r--r--platform_tools/android/tests/expectations/missing-filename.xxx33
-rw-r--r--platform_tools/android/tests/generate_user_config_tests.py31
2 files changed, 58 insertions, 6 deletions
diff --git a/platform_tools/android/tests/expectations/missing-filename.xxx b/platform_tools/android/tests/expectations/missing-filename.xxx
new file mode 100644
index 0000000000..d0d70d7792
--- /dev/null
+++ b/platform_tools/android/tests/expectations/missing-filename.xxx
@@ -0,0 +1,33 @@
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// THIS FILE IS AUTOGENERATED BY GYP_TO_ANDROID.PY. DO NOT EDIT.
+//
+// This file contains Skia's upstream include/config/SkUserConfig.h as a
+// reference, followed by the actual defines set for Android.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+// Android defines:
+#ifndef SkUserConfig_Android_DEFINED
+#define SkUserConfig_Android_DEFINED
+#ifdef ANDROID
+ #include <utils/misc.h>
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+ #define SK_CPU_BENDIAN
+ #undef SK_CPU_LENDIAN
+#else
+ #define SK_CPU_LENDIAN
+ #undef SK_CPU_BENDIAN
+#endif
+
+#define SK_BUILD_FOR_ANDROID
+#define SK_BUILD_FOR_ANDROID_FRAMEWORK
+#define SK_SCALAR_IS_FLOAT
+#define foo
+#define bar
+
+#endif // SkUserConfig_Android_DEFINED
diff --git a/platform_tools/android/tests/generate_user_config_tests.py b/platform_tools/android/tests/generate_user_config_tests.py
index 503a154d6d..660757d2be 100644
--- a/platform_tools/android/tests/generate_user_config_tests.py
+++ b/platform_tools/android/tests/generate_user_config_tests.py
@@ -24,13 +24,15 @@ from generate_user_config import generate_user_config as gen_config
# Name of SkUserConfig file.
USER_CONFIG_NAME = 'SkUserConfig-h.txt'
+MISSING_FILENAME = 'missing-filename.xxx'
# Path to unchanging Dummy SkUserConfig file.
FULL_DUMMY_PATH = os.path.join(os.path.dirname(__file__), 'inputs',
USER_CONFIG_NAME)
REBASELINE_MSG = ('If you\'ve modified generate_user_config.py, run '
'"generate_user_config_tests.py --rebaseline" to rebaseline')
-def generate_dummy_user_config(original_sk_user_config, target_dir):
+def generate_dummy_user_config(original_sk_user_config,
+ require_sk_user_config, target_dir):
# Add an arbitrary set of defines
defines = [ 'SK_BUILD_FOR_ANDROID',
'SK_BUILD_FOR_ANDROID_FRAMEWORK',
@@ -38,6 +40,7 @@ def generate_dummy_user_config(original_sk_user_config, target_dir):
'foo',
'bar' ]
gen_config(original_sk_user_config=original_sk_user_config,
+ require_sk_user_config=require_sk_user_config,
target_dir=target_dir, ordered_set=defines)
@@ -45,18 +48,33 @@ class GenUserConfigTest(unittest.TestCase):
def test_missing_sk_user_config(self):
tmp = tempfile.mkdtemp()
- original = os.path.join(tmp, 'filename')
+ original = os.path.join(tmp, MISSING_FILENAME)
assert not os.path.exists(original)
+
+ # With require_sk_user_config set to True, an AssertionError will be
+ # thrown when original_sk_user_config is missing.
with self.assertRaises(AssertionError):
ordered_set = [ 'define' ]
- gen_config(original_sk_user_config=original, target_dir=tmp,
- ordered_set=ordered_set)
+ gen_config(original_sk_user_config=original,
+ require_sk_user_config=True,
+ target_dir=tmp, ordered_set=ordered_set)
+
+ # With require_sk_user_config set to False, it is okay for
+ # original_sk_user_config to be missing.
+ generate_dummy_user_config(original_sk_user_config=original,
+ require_sk_user_config=False, target_dir=tmp)
+ actual_name = os.path.join(tmp, MISSING_FILENAME)
+ utils.compare_to_expectation(actual_name=actual_name,
+ expectation_name=MISSING_FILENAME,
+ assert_true=self.assertTrue,
+ msg=REBASELINE_MSG)
+
shutil.rmtree(tmp)
def test_gen_config(self):
tmp = tempfile.mkdtemp()
- generate_dummy_user_config(FULL_DUMMY_PATH, tmp)
+ generate_dummy_user_config(FULL_DUMMY_PATH, True, tmp)
actual_name = os.path.join(tmp, USER_CONFIG_NAME)
utils.compare_to_expectation(actual_name=actual_name,
expectation_name=USER_CONFIG_NAME,
@@ -74,7 +92,8 @@ def main():
def rebaseline():
- generate_dummy_user_config(FULL_DUMMY_PATH, utils.EXPECTATIONS_DIR)
+ generate_dummy_user_config(FULL_DUMMY_PATH, True, utils.EXPECTATIONS_DIR)
+ generate_dummy_user_config(MISSING_FILENAME, False, utils.EXPECTATIONS_DIR)
if __name__ == "__main__":
parser = argparse.ArgumentParser()