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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 java_class_name=None, | 943 java_class_name=None, |
944 type='method', | 944 type='method', |
945 p0_type='ChromeBrowserProvider', | 945 p0_type='ChromeBrowserProvider', |
946 ptr_type=test_options.ptr_type), | 946 ptr_type=test_options.ptr_type), |
947 ] | 947 ] |
948 self.assertListEquals(golden_natives, natives) | 948 self.assertListEquals(golden_natives, natives) |
949 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 949 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
950 natives, [], [], test_options) | 950 natives, [], [], test_options) |
951 self.assertGoldenTextEquals(h.GetContent()) | 951 self.assertGoldenTextEquals(h.GetContent()) |
952 | 952 |
| 953 def testMainDexFile(self): |
| 954 test_data = """ |
| 955 package org.chromium.example.jni_generator; |
| 956 |
| 957 @MainDex |
| 958 class Test { |
| 959 private static native int nativeStaticMethod(long nativeTest, int arg1); |
| 960 } |
| 961 """ |
| 962 options = TestOptions() |
| 963 jni_from_java = jni_generator.JNIFromJavaSource( |
| 964 test_data, 'org/chromium/foo/Bar', options) |
| 965 self.assertGoldenTextEquals(jni_from_java.GetContent()) |
| 966 |
| 967 def testNonMainDexFile(self): |
| 968 test_data = """ |
| 969 package org.chromium.example.jni_generator; |
| 970 |
| 971 class Test { |
| 972 private static native int nativeStaticMethod(long nativeTest, int arg1); |
| 973 } |
| 974 """ |
| 975 options = TestOptions() |
| 976 jni_from_java = jni_generator.JNIFromJavaSource( |
| 977 test_data, 'org/chromium/foo/Bar', options) |
| 978 self.assertGoldenTextEquals(jni_from_java.GetContent()) |
| 979 |
953 def testNativeExportsOnlyOption(self): | 980 def testNativeExportsOnlyOption(self): |
954 test_data = """ | 981 test_data = """ |
955 package org.chromium.example.jni_generator; | 982 package org.chromium.example.jni_generator; |
956 | 983 |
957 /** The pointer to the native Test. */ | 984 /** The pointer to the native Test. */ |
958 long nativeTest; | 985 long nativeTest; |
959 | 986 |
960 class Test { | 987 class Test { |
961 private static native int nativeStaticMethod(long nativeTest, int arg1); | 988 private static native int nativeStaticMethod(long nativeTest, int arg1); |
962 private native int nativeMethod(long nativeTest, int arg1); | 989 private native int nativeMethod(long nativeTest, int arg1); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 test_result = unittest.main(argv=argv[0:1], exit=False) | 1088 test_result = unittest.main(argv=argv[0:1], exit=False) |
1062 | 1089 |
1063 if test_result.result.wasSuccessful() and options.stamp: | 1090 if test_result.result.wasSuccessful() and options.stamp: |
1064 TouchStamp(options.stamp) | 1091 TouchStamp(options.stamp) |
1065 | 1092 |
1066 return not test_result.result.wasSuccessful() | 1093 return not test_result.result.wasSuccessful() |
1067 | 1094 |
1068 | 1095 |
1069 if __name__ == '__main__': | 1096 if __name__ == '__main__': |
1070 sys.exit(main(sys.argv)) | 1097 sys.exit(main(sys.argv)) |
OLD | NEW |