1#!/usr/bin/python 2 3# Copyright 2014 Google Inc. 4# 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8""" 9Test gyp_to_android.py 10""" 11 12import os 13import shutil 14import sys 15import tempfile 16import test_variables 17import unittest 18 19# Path to gyp_to_android 20sys.path.append(test_variables.BIN_DIR) 21 22import gyp_to_android 23 24 25 26class AndroidMkCreationTest(unittest.TestCase): 27 28 def setUp(self): 29 # Create a temporary directory for storing the output (Android.mk) 30 self.__tmp_dir = tempfile.mkdtemp() 31 32 def test_create(self): 33 gyp_to_android.main(self.__tmp_dir) 34 35 # Now there should be a file named 'Android.mk' inside __tmp_dir 36 path_to_android_mk = os.path.join(self.__tmp_dir, 37 test_variables.ANDROID_MK) 38 self.assertTrue(os.path.exists(path_to_android_mk)) 39 40 # In addition, there should be an 'Android.mk' inside /tests/ 41 path_to_tests_android_mk = os.path.join(self.__tmp_dir, 'tests', 42 test_variables.ANDROID_MK) 43 self.assertTrue(os.path.exists(path_to_tests_android_mk)) 44 45 def tearDown(self): 46 # Remove self.__tmp_dir, which is no longer needed. 47 shutil.rmtree(self.__tmp_dir) 48 49 50def main(): 51 loader = unittest.TestLoader() 52 suite = loader.loadTestsFromTestCase(AndroidMkCreationTest) 53 unittest.TextTestRunner(verbosity=2).run(suite) 54 55if __name__ == "__main__": 56 main() 57