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

Unified Diff: platform_tools/android/tests/gyp_to_android_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/gyp_gen/vars_dict_lib.py ('k') | platform_tools/android/tests/ordered_set_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/tests/gyp_to_android_tests.py
diff --git a/platform_tools/android/tests/gyp_to_android_tests.py b/platform_tools/android/tests/gyp_to_android_tests.py
new file mode 100644
index 0000000000000000000000000000000000000000..cb2a3e0c8ce44125d43022af2ac382c355ae513f
--- /dev/null
+++ b/platform_tools/android/tests/gyp_to_android_tests.py
@@ -0,0 +1,105 @@
+#!/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 gyp_to_android.py
+"""
+
+import os
+import shutil
+import sys
+import tempfile
+import test_variables
+import unittest
+
+# Path to gyp_to_android
+sys.path.append(test_variables.BIN_DIR)
+
+import gyp_to_android
+
+class AndroidMkCreationTest(unittest.TestCase):
+
+ def setUp(self):
+ # Create a temporary directory for storing the output (Android.mk)
+ self.__tmp_dir = tempfile.mkdtemp()
+
+ def test_create(self):
+ gyp_to_android.main(self.__tmp_dir)
+
+ # Now there should be a file named 'Android.mk' inside __tmp_dir
+ path_to_android_mk = os.path.join(self.__tmp_dir, 'Android.mk')
+ self.assertTrue(os.path.exists(path_to_android_mk))
+
+ def tearDown(self):
+ # Remove self.__tmp_dir, which is no longer needed.
+ shutil.rmtree(self.__tmp_dir)
+
+
+GYPD_SUFFIX = ".gypd"
+GYP_SUFFIX = ".gyp"
+GYPI_SUFFIX = ".gypi"
+OTHER_SUFFIX = ".txt"
+
+class CleanGypdTest(unittest.TestCase):
+
+ def setUp(self):
+ self.__tmp_dir = tempfile.mkdtemp()
+ self.__num_files = 10
+ # Fill the dir with four types of files. .gypd files should be deleted by
+ # clean_gypd_files(), while the rest should be left alone.
+ for i in range(self.__num_files):
+ self.create_file('%s%s' % (str(i), GYPD_SUFFIX))
+ self.create_file('%s%s' % (str(i), GYPI_SUFFIX))
+ self.create_file('%s%s' % (str(i), GYP_SUFFIX))
+ self.create_file('%s%s' % (str(i), OTHER_SUFFIX))
+
+ def create_file(self, basename):
+ """
+ Create a file named 'basename' in self.__tmp_dir.
+ """
+ f = tempfile.mkstemp(dir=self.__tmp_dir)
+ os.rename(f[1], os.path.join(self.__tmp_dir, basename))
+ self.assert_file_exists(basename)
+
+ def assert_file_exists(self, basename):
+ """
+ Assert that 'basename' exists in self.__tmp_dir.
+ """
+ full_name = os.path.join(self.__tmp_dir, basename)
+ self.assertTrue(os.path.exists(full_name))
+
+ def assert_file_does_not_exist(self, basename):
+ """
+ Assert that 'basename' does not exist in self.__tmp_dir.
+ """
+ full_name = os.path.join(self.__tmp_dir, basename)
+ self.assertFalse(os.path.exists(full_name))
+
+ def test_clean(self):
+ """
+ Test that clean_gypd_files() deletes .gypd files, and leaves others.
+ """
+ gyp_to_android.clean_gypd_files(self.__tmp_dir)
+ for i in range(self.__num_files):
+ self.assert_file_exists('%s%s' % (str(i), GYPI_SUFFIX))
+ self.assert_file_exists('%s%s' % (str(i), GYP_SUFFIX))
+ self.assert_file_exists('%s%s' % (str(i), OTHER_SUFFIX))
+ # Only the GYPD files should have been deleted.
+ self.assert_file_does_not_exist('%s%s' % (str(i), GYPD_SUFFIX))
+
+ def tearDown(self):
+ shutil.rmtree(self.__tmp_dir)
+
+
+def main():
+ loader = unittest.TestLoader()
+ suite = loader.loadTestsFromTestCase(AndroidMkCreationTest)
+ suite.addTest(loader.loadTestsFromTestCase(CleanGypdTest))
+ unittest.TextTestRunner(verbosity=2).run(suite)
+
+if __name__ == "__main__":
+ main()
« no previous file with comments | « platform_tools/android/gyp_gen/vars_dict_lib.py ('k') | platform_tools/android/tests/ordered_set_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698