OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Tests for java_google_api_keys.py. | |
7 | |
8 This test suite contains various tests for the C++ -> Java Google API Keys | |
9 generator. | |
10 """ | |
11 | |
12 import collections | |
13 import optparse | |
14 import os | |
15 import sys | |
16 import unittest | |
17 | |
18 import java_google_api_keys | |
19 from java_google_api_keys import GenerateOutput, GetScriptName | |
20 | |
21 sys.path.append(os.path.join(os.path.dirname(__file__), "gyp")) | |
22 from util import build_utils | |
23 | |
24 class TestJavaGoogleAPIKeys(unittest.TestCase): | |
25 def testOutput(self): | |
26 definition = {'E1': 'abc', 'E2': 'defgh'} | |
27 output = GenerateOutput(definition) | |
28 expected = """ | |
29 // Copyright 2015 The Chromium Authors. All rights reserved. | |
30 // Use of this source code is governed by a BSD-style license that can be | |
31 // found in the LICENSE file. | |
32 | |
33 // This file is autogenerated by | |
34 // %s | |
35 // From | |
36 // google_api_keys/google_api_keys.h | |
37 | |
38 package org.chromium.chrome; | |
39 | |
40 public class GoogleAPIKeys { | |
41 public static final String E1 = "abc"; | |
42 public static final String E2 = "defgh"; | |
43 } | |
44 """ | |
45 self.assertEqual(expected % GetScriptName(), output) | |
46 | |
47 def main(argv): | |
48 parser = optparse.OptionParser() | |
agrieve
2015/10/30 00:55:13
nit: optparse is deprecated, use argparse (almost
dvh
2015/10/30 20:56:20
Done.
| |
49 parser.add_option("--stamp", help="File to touch on success.") | |
50 options, _ = parser.parse_args(argv) | |
51 | |
52 suite = unittest.TestLoader().loadTestsFromTestCase(TestJavaGoogleAPIKeys) | |
53 unittest.TextTestRunner(verbosity=0).run(suite) | |
54 | |
55 if options.stamp: | |
56 build_utils.Touch(options.stamp) | |
57 | |
58 if __name__ == '__main__': | |
59 main(sys.argv[1:]) | |
60 | |
OLD | NEW |