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

Unified Diff: platform_tools/android/tests/var_dict_tests.py

Issue 140503007: Scripts to generate Android.mk for framework Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Respond to Elliot's comments in patch set 20. Created 6 years, 10 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
« no previous file with comments | « platform_tools/android/tests/test_variables.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/tests/var_dict_tests.py
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 0000000000000000000000000000000000000000..8cd96770682cfc30d9c38c22d5fbfe9a206c559a
--- /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()
+
« no previous file with comments | « platform_tools/android/tests/test_variables.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698