| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Tests for jni_generator.py. | 6 """Tests for jni_generator.py. |
| 7 | 7 |
| 8 This test suite contains various tests for the JNI generator. | 8 This test suite contains various tests for the JNI generator. |
| 9 It exercises the low-level parser all the way up to the | 9 It exercises the low-level parser all the way up to the |
| 10 code generator and ensures the output matches a golden | 10 code generator and ensures the output matches a golden |
| 11 file. | 11 file. |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import difflib | 14 import difflib |
| 15 import inspect | 15 import inspect |
| 16 import optparse |
| 16 import os | 17 import os |
| 17 import sys | 18 import sys |
| 18 import unittest | 19 import unittest |
| 19 import jni_generator | 20 import jni_generator |
| 20 from jni_generator import CalledByNative, JniParams, NativeMethod, Param | 21 from jni_generator import CalledByNative, JniParams, NativeMethod, Param |
| 21 | 22 |
| 22 | 23 |
| 23 SCRIPT_NAME = 'base/android/jni_generator/jni_generator.py' | 24 SCRIPT_NAME = 'base/android/jni_generator/jni_generator.py' |
| 24 INCLUDES = ( | 25 INCLUDES = ( |
| 25 'base/android/jni_generator/jni_generator_helper.h' | 26 'base/android/jni_generator/jni_generator_helper.h' |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 private static native void nativeDoSomething(Bar1.Callback callback1, | 1142 private static native void nativeDoSomething(Bar1.Callback callback1, |
| 1142 Bar2.Callback callback2); | 1143 Bar2.Callback callback2); |
| 1143 } | 1144 } |
| 1144 """ | 1145 """ |
| 1145 jni_from_java = jni_generator.JNIFromJavaSource(test_data, | 1146 jni_from_java = jni_generator.JNIFromJavaSource(test_data, |
| 1146 'org/chromium/foo/Foo', | 1147 'org/chromium/foo/Foo', |
| 1147 TestOptions()) | 1148 TestOptions()) |
| 1148 self.assertGoldenTextEquals(jni_from_java.GetContent()) | 1149 self.assertGoldenTextEquals(jni_from_java.GetContent()) |
| 1149 | 1150 |
| 1150 | 1151 |
| 1152 def TouchStamp(stamp_path): |
| 1153 dir_name = os.path.dirname(stamp_path) |
| 1154 if not os.path.isdir(dir_name): |
| 1155 os.makedirs() |
| 1156 |
| 1157 with open(stamp_path, 'a'): |
| 1158 os.utime(stamp_path, None) |
| 1159 |
| 1160 |
| 1161 def main(argv): |
| 1162 parser = optparse.OptionParser() |
| 1163 parser.add_option('--stamp', help='Path to touch on success.') |
| 1164 options, _ = parser.parse_args(argv[1:]) |
| 1165 |
| 1166 test_result = unittest.main(argv=argv[0:1], exit=False) |
| 1167 |
| 1168 if test_result.result.wasSuccessful() and options.stamp: |
| 1169 TouchStamp(options.stamp) |
| 1170 |
| 1171 return not test_result.result.wasSuccessful() |
| 1172 |
| 1173 |
| 1151 if __name__ == '__main__': | 1174 if __name__ == '__main__': |
| 1152 unittest.main() | 1175 sys.exit(main(sys.argv)) |
| OLD | NEW |