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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1026 jni_generator.JNIFromJavaSource( | 1026 jni_generator.JNIFromJavaSource( |
1027 test_data % {'IMPORT': import_clause}, | 1027 test_data % {'IMPORT': import_clause}, |
1028 'org/chromium/android_webview/AwContentStatics', | 1028 'org/chromium/android_webview/AwContentStatics', |
1029 TestOptions()) | 1029 TestOptions()) |
1030 # Ensure it raises without the import. | 1030 # Ensure it raises without the import. |
1031 self.assertRaises(SyntaxError, lambda: generate('')) | 1031 self.assertRaises(SyntaxError, lambda: generate('')) |
1032 | 1032 |
1033 # Ensure it's fine with the import. | 1033 # Ensure it's fine with the import. |
1034 generate('import java.lang.Runnable;') | 1034 generate('import java.lang.Runnable;') |
1035 | 1035 |
1036 def testJNIAdditionalImport(self): | |
1037 test_data = """ | |
1038 package org.chromium.foo; | |
1039 | |
1040 @JNIAdditionalImport(Bar.class) | |
1041 | |
bulach
2014/05/19 11:54:59
nit: just for documentation, could do with the cla
qsr
2014/05/19 12:07:47
Done.
| |
1042 @CalledByNative | |
1043 private static void calledByNative(Bar.Callback callback) { | |
1044 } | |
1045 """ | |
1046 jni_from_java = jni_generator.JNIFromJavaSource(test_data, | |
1047 'org/chromium/foo/Foo', | |
1048 TestOptions()) | |
1049 self.assertGoldenTextEquals(jni_from_java.GetContent()) | |
1050 | |
1036 | 1051 |
1037 if __name__ == '__main__': | 1052 if __name__ == '__main__': |
1038 unittest.main() | 1053 unittest.main() |
OLD | NEW |