| 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 25 matching lines...) Expand all Loading... |
| 36 self.namespace = None | 36 self.namespace = None |
| 37 self.script_name = SCRIPT_NAME | 37 self.script_name = SCRIPT_NAME |
| 38 self.includes = INCLUDES | 38 self.includes = INCLUDES |
| 39 self.pure_native_methods = False | 39 self.pure_native_methods = False |
| 40 self.ptr_type = 'long' | 40 self.ptr_type = 'long' |
| 41 self.jni_init_native_name = None | 41 self.jni_init_native_name = None |
| 42 self.eager_called_by_natives = False | 42 self.eager_called_by_natives = False |
| 43 self.cpp = 'cpp' | 43 self.cpp = 'cpp' |
| 44 self.javap = 'javap' | 44 self.javap = 'javap' |
| 45 self.native_exports = False | 45 self.native_exports = False |
| 46 self.native_exports_optional = False |
| 46 | 47 |
| 47 class TestGenerator(unittest.TestCase): | 48 class TestGenerator(unittest.TestCase): |
| 48 def assertObjEquals(self, first, second): | 49 def assertObjEquals(self, first, second): |
| 49 dict_first = first.__dict__ | 50 dict_first = first.__dict__ |
| 50 dict_second = second.__dict__ | 51 dict_second = second.__dict__ |
| 51 self.assertEquals(dict_first.keys(), dict_second.keys()) | 52 self.assertEquals(dict_first.keys(), dict_second.keys()) |
| 52 for key, value in dict_first.iteritems(): | 53 for key, value in dict_first.iteritems(): |
| 53 if (type(value) is list and len(value) and | 54 if (type(value) is list and len(value) and |
| 54 isinstance(type(value[0]), object)): | 55 isinstance(type(value[0]), object)): |
| 55 self.assertListEquals(value, second.__getattribute__(key)) | 56 self.assertListEquals(value, second.__getattribute__(key)) |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 } | 1134 } |
| 1134 """ | 1135 """ |
| 1135 jni_from_java = jni_generator.JNIFromJavaSource(test_data, | 1136 jni_from_java = jni_generator.JNIFromJavaSource(test_data, |
| 1136 'org/chromium/foo/Foo', | 1137 'org/chromium/foo/Foo', |
| 1137 TestOptions()) | 1138 TestOptions()) |
| 1138 self.assertGoldenTextEquals(jni_from_java.GetContent()) | 1139 self.assertGoldenTextEquals(jni_from_java.GetContent()) |
| 1139 | 1140 |
| 1140 | 1141 |
| 1141 if __name__ == '__main__': | 1142 if __name__ == '__main__': |
| 1142 unittest.main() | 1143 unittest.main() |
| OLD | NEW |