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 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 g_HashSet_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 1651 g_HashSet_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
1652 base::android::GetClass(env, kHashSetClassPath).obj())); | 1652 base::android::GetClass(env, kHashSetClassPath).obj())); |
1653 return true; | 1653 return true; |
1654 } | 1654 } |
1655 } // namespace JNI_HashSet | 1655 } // namespace JNI_HashSet |
1656 | 1656 |
1657 #endif // java_util_HashSet_JNI | 1657 #endif // java_util_HashSet_JNI |
1658 """ | 1658 """ |
1659 self.assertTextEquals(golden_content, jni_from_javap.GetContent()) | 1659 self.assertTextEquals(golden_content, jni_from_javap.GetContent()) |
1660 | 1660 |
| 1661 def testSnippnetJavap6_7(self): |
| 1662 content_javap6 = """ |
| 1663 public class java.util.HashSet { |
| 1664 public boolean add(java.lang.Object); |
| 1665 Signature: (Ljava/lang/Object;)Z |
| 1666 } |
| 1667 """ |
| 1668 |
| 1669 content_javap7 = """ |
| 1670 public class java.util.HashSet { |
| 1671 public boolean add(E); |
| 1672 Signature: (Ljava/lang/Object;)Z |
| 1673 } |
| 1674 """ |
| 1675 jni_from_javap6 = jni_generator.JNIFromJavaP(content_javap6.split('\n'), |
| 1676 TestOptions()) |
| 1677 jni_from_javap7 = jni_generator.JNIFromJavaP(content_javap7.split('\n'), |
| 1678 TestOptions()) |
| 1679 self.assertTrue(jni_from_javap6.GetContent()) |
| 1680 self.assertTrue(jni_from_javap7.GetContent()) |
| 1681 # Ensure the javap7 is correctly parsed and uses the Signature field rather |
| 1682 # than the "E" parameter. |
| 1683 self.assertTextEquals(jni_from_javap6.GetContent(), |
| 1684 jni_from_javap7.GetContent()) |
| 1685 |
1661 def testFromJavaP(self): | 1686 def testFromJavaP(self): |
1662 contents = """ | 1687 contents = """ |
1663 public abstract class java.io.InputStream extends java.lang.Object | 1688 public abstract class java.io.InputStream extends java.lang.Object |
1664 implements java.io.Closeable{ | 1689 implements java.io.Closeable{ |
1665 public java.io.InputStream(); | 1690 public java.io.InputStream(); |
1666 public int available() throws java.io.IOException; | 1691 public int available() throws java.io.IOException; |
1667 public void close() throws java.io.IOException; | 1692 public void close() throws java.io.IOException; |
1668 public void mark(int); | 1693 public void mark(int); |
1669 public boolean markSupported(); | 1694 public boolean markSupported(); |
1670 public abstract int read() throws java.io.IOException; | 1695 public abstract int read() throws java.io.IOException; |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 | 2196 |
2172 def testJniParamsJavaToJni(self): | 2197 def testJniParamsJavaToJni(self): |
2173 self.assertTextEquals('I', JniParams.JavaToJni('int')) | 2198 self.assertTextEquals('I', JniParams.JavaToJni('int')) |
2174 self.assertTextEquals('[B', JniParams.JavaToJni('byte[]')) | 2199 self.assertTextEquals('[B', JniParams.JavaToJni('byte[]')) |
2175 self.assertTextEquals( | 2200 self.assertTextEquals( |
2176 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]')) | 2201 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]')) |
2177 | 2202 |
2178 | 2203 |
2179 if __name__ == '__main__': | 2204 if __name__ == '__main__': |
2180 unittest.main() | 2205 unittest.main() |
OLD | NEW |