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 8This test suite contains various tests for the C++ -> Java Google API Keys 9generator. 10""" 11 12import collections 13import argparse 14import os 15import sys 16import unittest 17 18import java_google_api_keys 19 20sys.path.append(os.path.join(os.path.dirname(__file__), "gyp")) 21from util import build_utils 22 23 24class 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 38package org.chromium.chrome; 39 40public 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 48def 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 59if __name__ == '__main__': 60 main(sys.argv[1:]) 61 62