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  def tearDown(self):
41    # Remove self.__tmp_dir, which is no longer needed.
42    shutil.rmtree(self.__tmp_dir)
43
44
45def main():
46  loader = unittest.TestLoader()
47  suite = loader.loadTestsFromTestCase(AndroidMkCreationTest)
48  unittest.TextTestRunner(verbosity=2).run(suite)
49
50if __name__ == "__main__":
51  main()
52