Chromium Code Reviews| Index: build/android/gyp/java_google_api_keys_tests.py |
| diff --git a/build/android/gyp/java_google_api_keys_tests.py b/build/android/gyp/java_google_api_keys_tests.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..9433ebfe5ed99ac18065980ab06b23c9f893298e |
| --- /dev/null |
| +++ b/build/android/gyp/java_google_api_keys_tests.py |
| @@ -0,0 +1,60 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Tests for java_google_api_keys.py. |
| + |
| +This test suite contains various tests for the C++ -> Java Google API Keys |
| +generator. |
| +""" |
| + |
| +import collections |
| +import optparse |
| +import os |
| +import sys |
| +import unittest |
| + |
| +import java_google_api_keys |
| +from java_google_api_keys import GenerateOutput, GetScriptName |
| + |
| +sys.path.append(os.path.join(os.path.dirname(__file__), "gyp")) |
| +from util import build_utils |
| + |
| +class TestJavaGoogleAPIKeys(unittest.TestCase): |
| + def testOutput(self): |
| + definition = {'E1': 'abc', 'E2': 'defgh'} |
| + output = GenerateOutput(definition) |
| + expected = """ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This file is autogenerated by |
| +// %s |
| +// From |
| +// google_api_keys/google_api_keys.h |
| + |
| +package org.chromium.chrome; |
| + |
| +public class GoogleAPIKeys { |
| + public static final String E1 = "abc"; |
| + public static final String E2 = "defgh"; |
| +} |
| +""" |
| + self.assertEqual(expected % GetScriptName(), output) |
| + |
| +def main(argv): |
| + 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.
|
| + parser.add_option("--stamp", help="File to touch on success.") |
| + options, _ = parser.parse_args(argv) |
| + |
| + suite = unittest.TestLoader().loadTestsFromTestCase(TestJavaGoogleAPIKeys) |
| + unittest.TextTestRunner(verbosity=0).run(suite) |
| + |
| + if options.stamp: |
| + build_utils.Touch(options.stamp) |
| + |
| +if __name__ == '__main__': |
| + main(sys.argv[1:]) |
| + |