diff options
author | 2014-02-06 16:13:00 +0000 | |
---|---|---|
committer | 2014-02-06 16:13:00 +0000 | |
commit | 89335631749b29ea92e55ed710f030692aa13297 (patch) | |
tree | 07ecc92f1ea39df152bda0c10d42c4b3563f96db /platform_tools/android/tests/var_dict_tests.py | |
parent | 1c188ed9fa70e50db1471bdbf683135c39ea85be (diff) |
Scripts to generate Android.mk for framework Skia.
In order to create Android.mk, run
>> python platform_tools/android/bin/gyp_to_android.py
For the change in the Android.mk file, see
https://googleplex-android-review.git.corp.google.com/#/c/408170/
(SkipBuildbotRuns)
BUG=skia:1975
R=djsollen@google.com, epoger@google.com
Author: scroggo@google.com
Review URL: https://codereview.chromium.org/140503007
git-svn-id: http://skia.googlecode.com/svn/trunk@13344 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'platform_tools/android/tests/var_dict_tests.py')
-rw-r--r-- | platform_tools/android/tests/var_dict_tests.py | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/platform_tools/android/tests/var_dict_tests.py b/platform_tools/android/tests/var_dict_tests.py new file mode 100644 index 0000000000..8cd9677068 --- /dev/null +++ b/platform_tools/android/tests/var_dict_tests.py @@ -0,0 +1,110 @@ +#!/usr/bin/python + +# Copyright 2014 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Test the VarsDict. +""" + +import sys +import test_variables +import unittest + +sys.path.append(test_variables.GYP_GEN_DIR) + +import vars_dict_lib +from vars_dict_lib import OrderedSet +from vars_dict_lib import VarsDict +from vars_dict_lib import VAR_NAMES + +class VarsDictTest(unittest.TestCase): + """ + Tests for the VarsDict class. + """ + + # May not be needed. + def setUp(self): + self.__vars_dict = VarsDict() + + def assert_consistency(self, v_dict): + self.assertIs(v_dict.LOCAL_CFLAGS, v_dict['LOCAL_CFLAGS']) + self.assertIs(v_dict.LOCAL_CPPFLAGS, v_dict['LOCAL_CPPFLAGS']) + self.assertIs(v_dict.LOCAL_SRC_FILES, v_dict['LOCAL_SRC_FILES']) + self.assertIs(v_dict.LOCAL_SHARED_LIBRARIES, + v_dict['LOCAL_SHARED_LIBRARIES']) + self.assertIs(v_dict.LOCAL_STATIC_LIBRARIES, + v_dict['LOCAL_STATIC_LIBRARIES']) + self.assertIs(v_dict.LOCAL_C_INCLUDES, v_dict['LOCAL_C_INCLUDES']) + self.assertIs(v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS, + v_dict['LOCAL_EXPORT_C_INCLUDE_DIRS']) + self.assertIs(v_dict.KNOWN_TARGETS, v_dict['KNOWN_TARGETS']) + + def test_creation(self): + v_dict = VarsDict() + # VarsDict has one entry for each label in VAR_NAMES + self.assertEqual(len(v_dict.keys()), len(VAR_NAMES)) + for key in v_dict.keys(): + self.assertIn(key, VAR_NAMES) + # Each entry is an empty OrderedSet + self.assertIsNotNone(v_dict[key]) + self.assertIsInstance(v_dict[key], OrderedSet) + self.assertEqual(len(v_dict[key]), 0) + self.assert_consistency(v_dict) + + def test_intersection(self): + v_dict_list = [] + RANGE = 10 + for i in range(RANGE): + v_dict = VarsDict() + # Add something common to each field, as well as a unique entry + v_dict.LOCAL_CFLAGS.add('cflag') + v_dict.LOCAL_CFLAGS.add(str(i)) + + v_dict.LOCAL_CPPFLAGS.add('cppflag') + v_dict.LOCAL_CPPFLAGS.add(str(i)) + + v_dict.LOCAL_SRC_FILES.add('src') + v_dict.LOCAL_SRC_FILES.add(str(i)) + + v_dict.LOCAL_SHARED_LIBRARIES.add('shared') + v_dict.LOCAL_SHARED_LIBRARIES.add(str(i)) + + v_dict.LOCAL_STATIC_LIBRARIES.add('static') + v_dict.LOCAL_STATIC_LIBRARIES.add(str(i)) + + v_dict.LOCAL_C_INCLUDES.add('includes') + v_dict.LOCAL_C_INCLUDES.add(str(i)) + + v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add('exports') + v_dict.LOCAL_EXPORT_C_INCLUDE_DIRS.add(str(i)) + + v_dict.KNOWN_TARGETS.add('known') + v_dict.KNOWN_TARGETS.add(str(i)) + + self.assert_consistency(v_dict) + + v_dict_list.append(v_dict) + + intersection = vars_dict_lib.intersect(v_dict_list) + + self.assert_consistency(intersection) + + for key in intersection.keys(): + # Each field had one common item + self.assertEqual(len(intersection[key]), 1) + for item in intersection[key]: + for other_v_dict in v_dict_list: + self.assertNotIn(item, other_v_dict[key]) + + +def main(): + loader = unittest.TestLoader() + suite = loader.loadTestsFromTestCase(VarsDictTest) + unittest.TextTestRunner(verbosity=2).run(suite) + +if __name__ == "__main__": + main() + |