| 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 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Long date, byte[] favicon, String title, Integer visits); | 142 Long date, byte[] favicon, String title, Integer visits); |
| 143 native int nativeFindAll(String find); | 143 native int nativeFindAll(String find); |
| 144 private static native OnFrameAvailableListener nativeGetInnerClass(); | 144 private static native OnFrameAvailableListener nativeGetInnerClass(); |
| 145 private native Bitmap nativeQueryBitmap( | 145 private native Bitmap nativeQueryBitmap( |
| 146 int nativeChromeBrowserProvider, | 146 int nativeChromeBrowserProvider, |
| 147 String[] projection, String selection, | 147 String[] projection, String selection, |
| 148 String[] selectionArgs, String sortOrder); | 148 String[] selectionArgs, String sortOrder); |
| 149 private native void nativeGotOrientation( | 149 private native void nativeGotOrientation( |
| 150 int nativeDataFetcherImplAndroid, | 150 int nativeDataFetcherImplAndroid, |
| 151 double alpha, double beta, double gamma); | 151 double alpha, double beta, double gamma); |
| 152 private static native Throwable nativeMessWithJavaException(Throwable e); |
| 152 """ | 153 """ |
| 153 jni_generator.JniParams.SetFullyQualifiedClass( | 154 jni_generator.JniParams.SetFullyQualifiedClass( |
| 154 'org/chromium/example/jni_generator/SampleForTests') | 155 'org/chromium/example/jni_generator/SampleForTests') |
| 155 jni_generator.JniParams.ExtractImportsAndInnerClasses(test_data) | 156 jni_generator.JniParams.ExtractImportsAndInnerClasses(test_data) |
| 156 natives = jni_generator.ExtractNatives(test_data, 'int') | 157 natives = jni_generator.ExtractNatives(test_data, 'int') |
| 157 golden_natives = [ | 158 golden_natives = [ |
| 158 NativeMethod(return_type='int', static=False, | 159 NativeMethod(return_type='int', static=False, |
| 159 name='Init', | 160 name='Init', |
| 160 params=[], | 161 params=[], |
| 161 java_class_name=None, | 162 java_class_name=None, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 Param(datatype='double', | 266 Param(datatype='double', |
| 266 name='alpha'), | 267 name='alpha'), |
| 267 Param(datatype='double', | 268 Param(datatype='double', |
| 268 name='beta'), | 269 name='beta'), |
| 269 Param(datatype='double', | 270 Param(datatype='double', |
| 270 name='gamma'), | 271 name='gamma'), |
| 271 ], | 272 ], |
| 272 java_class_name=None, | 273 java_class_name=None, |
| 273 type='method', | 274 type='method', |
| 274 p0_type='content::DataFetcherImplAndroid'), | 275 p0_type='content::DataFetcherImplAndroid'), |
| 276 NativeMethod(return_type='Throwable', static=True, |
| 277 name='MessWithJavaException', |
| 278 params=[Param(datatype='Throwable', name='e')], |
| 279 java_class_name=None, |
| 280 type='function') |
| 275 ] | 281 ] |
| 276 self.assertListEquals(golden_natives, natives) | 282 self.assertListEquals(golden_natives, natives) |
| 277 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 283 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
| 278 natives, [], [], TestOptions()) | 284 natives, [], [], TestOptions()) |
| 279 self.assertGoldenTextEquals(h.GetContent()) | 285 self.assertGoldenTextEquals(h.GetContent()) |
| 280 | 286 |
| 281 def testInnerClassNatives(self): | 287 def testInnerClassNatives(self): |
| 282 test_data = """ | 288 test_data = """ |
| 283 class MyInnerClass { | 289 class MyInnerClass { |
| 284 @NativeCall("MyInnerClass") | 290 @NativeCall("MyInnerClass") |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 test_result = unittest.main(argv=argv[0:1], exit=False) | 1149 test_result = unittest.main(argv=argv[0:1], exit=False) |
| 1144 | 1150 |
| 1145 if test_result.result.wasSuccessful() and options.stamp: | 1151 if test_result.result.wasSuccessful() and options.stamp: |
| 1146 TouchStamp(options.stamp) | 1152 TouchStamp(options.stamp) |
| 1147 | 1153 |
| 1148 return not test_result.result.wasSuccessful() | 1154 return not test_result.result.wasSuccessful() |
| 1149 | 1155 |
| 1150 | 1156 |
| 1151 if __name__ == '__main__': | 1157 if __name__ == '__main__': |
| 1152 sys.exit(main(sys.argv)) | 1158 sys.exit(main(sys.argv)) |
| OLD | NEW |