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 argparse |
| 14 import os |
| 15 import sys |
| 16 import unittest |
| 17 |
| 18 import java_google_api_keys |
| 19 |
| 20 sys.path.append(os.path.join(os.path.dirname(__file__), "gyp")) |
| 21 from util import build_utils |
| 22 |
| 23 |
| 24 class TestJavaGoogleAPIKeys(unittest.TestCase): |
| 25 def testOutput(self): |
| 26 definition = {'E1': 'abc', 'E2': 'defgh'} |
| 27 output = java_google_api_keys.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 % java_google_api_keys.GetScriptName(), output) |
| 46 |
| 47 |
| 48 def main(argv): |
| 49 parser = argparse.ArgumentParser() |
| 50 parser.add_argument("--stamp", help="File to touch on success.") |
| 51 options = parser.parse_args(argv) |
| 52 |
| 53 suite = unittest.TestLoader().loadTestsFromTestCase(TestJavaGoogleAPIKeys) |
| 54 unittest.TextTestRunner(verbosity=0).run(suite) |
| 55 |
| 56 if options.stamp: |
| 57 build_utils.Touch(options.stamp) |
| 58 |
| 59 if __name__ == '__main__': |
| 60 main(sys.argv[1:]) |
| 61 |
OLD | NEW |