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 |
11 file. | 11 file. |
12 """ | 12 """ |
13 | 13 |
14 import difflib | 14 import difflib |
15 import os | 15 import os |
16 import sys | 16 import sys |
17 import unittest | 17 import unittest |
18 import jni_generator | 18 import jni_generator |
19 from jni_generator import CalledByNative, JniParams, NativeMethod, Param | 19 from jni_generator import CalledByNative, JniParams, NativeMethod, Param |
20 | 20 |
21 | 21 |
| 22 SCRIPT_NAME = 'base/android/jni_generator/jni_generator.py' |
| 23 |
| 24 |
| 25 class TestOptions(object): |
| 26 """The mock options object which is passed to the jni_generator.py script.""" |
| 27 |
| 28 def __init__(self): |
| 29 self.namespace = None |
| 30 self.script_name = SCRIPT_NAME |
| 31 |
| 32 |
22 class TestGenerator(unittest.TestCase): | 33 class TestGenerator(unittest.TestCase): |
23 def assertObjEquals(self, first, second): | 34 def assertObjEquals(self, first, second): |
24 dict_first = first.__dict__ | 35 dict_first = first.__dict__ |
25 dict_second = second.__dict__ | 36 dict_second = second.__dict__ |
26 self.assertEquals(dict_first.keys(), dict_second.keys()) | 37 self.assertEquals(dict_first.keys(), dict_second.keys()) |
27 for key, value in dict_first.iteritems(): | 38 for key, value in dict_first.iteritems(): |
28 if (type(value) is list and len(value) and | 39 if (type(value) is list and len(value) and |
29 isinstance(type(value[0]), object)): | 40 isinstance(type(value[0]), object)): |
30 self.assertListEquals(value, second.__getattribute__(key)) | 41 self.assertListEquals(value, second.__getattribute__(key)) |
31 else: | 42 else: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 name='beta'), | 210 name='beta'), |
200 Param(datatype='double', | 211 Param(datatype='double', |
201 name='gamma'), | 212 name='gamma'), |
202 ], | 213 ], |
203 java_class_name=None, | 214 java_class_name=None, |
204 type='method', | 215 type='method', |
205 p0_type='content::DataFetcherImplAndroid'), | 216 p0_type='content::DataFetcherImplAndroid'), |
206 ] | 217 ] |
207 self.assertListEquals(golden_natives, natives) | 218 self.assertListEquals(golden_natives, natives) |
208 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 219 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
209 natives, []) | 220 natives, [], TestOptions()) |
210 golden_content = """\ | 221 golden_content = """\ |
211 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 222 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
212 // Use of this source code is governed by a BSD-style license that can be | 223 // Use of this source code is governed by a BSD-style license that can be |
213 // found in the LICENSE file. | 224 // found in the LICENSE file. |
214 | 225 |
215 // This file is autogenerated by | 226 // This file is autogenerated by |
216 // base/android/jni_generator/jni_generator_tests.py | 227 // base/android/jni_generator/jni_generator.py |
217 // For | 228 // For |
218 // org/chromium/TestJni | 229 // org/chromium/TestJni |
219 | 230 |
220 #ifndef org_chromium_TestJni_JNI | 231 #ifndef org_chromium_TestJni_JNI |
221 #define org_chromium_TestJni_JNI | 232 #define org_chromium_TestJni_JNI |
222 | 233 |
223 #include <jni.h> | 234 #include <jni.h> |
224 | 235 |
225 #include "base/android/jni_android.h" | 236 #include "base/android/jni_android.h" |
226 #include "base/android/scoped_java_ref.h" | 237 #include "base/android/scoped_java_ref.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 """ | 447 """ |
437 natives = jni_generator.ExtractNatives(test_data) | 448 natives = jni_generator.ExtractNatives(test_data) |
438 golden_natives = [ | 449 golden_natives = [ |
439 NativeMethod(return_type='int', static=False, | 450 NativeMethod(return_type='int', static=False, |
440 name='Init', params=[], | 451 name='Init', params=[], |
441 java_class_name='MyInnerClass', | 452 java_class_name='MyInnerClass', |
442 type='function') | 453 type='function') |
443 ] | 454 ] |
444 self.assertListEquals(golden_natives, natives) | 455 self.assertListEquals(golden_natives, natives) |
445 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 456 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
446 natives, []) | 457 natives, [], TestOptions()) |
447 golden_content = """\ | 458 golden_content = """\ |
448 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 459 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
449 // Use of this source code is governed by a BSD-style license that can be | 460 // Use of this source code is governed by a BSD-style license that can be |
450 // found in the LICENSE file. | 461 // found in the LICENSE file. |
451 | 462 |
452 // This file is autogenerated by | 463 // This file is autogenerated by |
453 // base/android/jni_generator/jni_generator_tests.py | 464 // base/android/jni_generator/jni_generator.py |
454 // For | 465 // For |
455 // org/chromium/TestJni | 466 // org/chromium/TestJni |
456 | 467 |
457 #ifndef org_chromium_TestJni_JNI | 468 #ifndef org_chromium_TestJni_JNI |
458 #define org_chromium_TestJni_JNI | 469 #define org_chromium_TestJni_JNI |
459 | 470 |
460 #include <jni.h> | 471 #include <jni.h> |
461 | 472 |
462 #include "base/android/jni_android.h" | 473 #include "base/android/jni_android.h" |
463 #include "base/android/scoped_java_ref.h" | 474 #include "base/android/scoped_java_ref.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 name='Init', params=[], | 534 name='Init', params=[], |
524 java_class_name='MyInnerClass', | 535 java_class_name='MyInnerClass', |
525 type='function'), | 536 type='function'), |
526 NativeMethod(return_type='int', static=False, | 537 NativeMethod(return_type='int', static=False, |
527 name='Init', params=[], | 538 name='Init', params=[], |
528 java_class_name='MyOtherInnerClass', | 539 java_class_name='MyOtherInnerClass', |
529 type='function') | 540 type='function') |
530 ] | 541 ] |
531 self.assertListEquals(golden_natives, natives) | 542 self.assertListEquals(golden_natives, natives) |
532 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 543 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
533 natives, []) | 544 natives, [], TestOptions()) |
534 golden_content = """\ | 545 golden_content = """\ |
535 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 546 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
536 // Use of this source code is governed by a BSD-style license that can be | 547 // Use of this source code is governed by a BSD-style license that can be |
537 // found in the LICENSE file. | 548 // found in the LICENSE file. |
538 | 549 |
539 // This file is autogenerated by | 550 // This file is autogenerated by |
540 // base/android/jni_generator/jni_generator_tests.py | 551 // base/android/jni_generator/jni_generator.py |
541 // For | 552 // For |
542 // org/chromium/TestJni | 553 // org/chromium/TestJni |
543 | 554 |
544 #ifndef org_chromium_TestJni_JNI | 555 #ifndef org_chromium_TestJni_JNI |
545 #define org_chromium_TestJni_JNI | 556 #define org_chromium_TestJni_JNI |
546 | 557 |
547 #include <jni.h> | 558 #include <jni.h> |
548 | 559 |
549 #include "base/android/jni_android.h" | 560 #include "base/android/jni_android.h" |
550 #include "base/android/scoped_java_ref.h" | 561 #include "base/android/scoped_java_ref.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 name='Init', params=[], | 640 name='Init', params=[], |
630 java_class_name=None, | 641 java_class_name=None, |
631 type='function'), | 642 type='function'), |
632 NativeMethod(return_type='int', static=False, | 643 NativeMethod(return_type='int', static=False, |
633 name='Init', params=[], | 644 name='Init', params=[], |
634 java_class_name='MyOtherInnerClass', | 645 java_class_name='MyOtherInnerClass', |
635 type='function') | 646 type='function') |
636 ] | 647 ] |
637 self.assertListEquals(golden_natives, natives) | 648 self.assertListEquals(golden_natives, natives) |
638 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 649 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
639 natives, []) | 650 natives, [], TestOptions()) |
640 golden_content = """\ | 651 golden_content = """\ |
641 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 652 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
642 // Use of this source code is governed by a BSD-style license that can be | 653 // Use of this source code is governed by a BSD-style license that can be |
643 // found in the LICENSE file. | 654 // found in the LICENSE file. |
644 | 655 |
645 // This file is autogenerated by | 656 // This file is autogenerated by |
646 // base/android/jni_generator/jni_generator_tests.py | 657 // base/android/jni_generator/jni_generator.py |
647 // For | 658 // For |
648 // org/chromium/TestJni | 659 // org/chromium/TestJni |
649 | 660 |
650 #ifndef org_chromium_TestJni_JNI | 661 #ifndef org_chromium_TestJni_JNI |
651 #define org_chromium_TestJni_JNI | 662 #define org_chromium_TestJni_JNI |
652 | 663 |
653 #include <jni.h> | 664 #include <jni.h> |
654 | 665 |
655 #include "base/android/jni_android.h" | 666 #include "base/android/jni_android.h" |
656 #include "base/android/scoped_java_ref.h" | 667 #include "base/android/scoped_java_ref.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 name='getCompressFormatList', | 1028 name='getCompressFormatList', |
1018 method_id_var_name='getCompressFormatList', | 1029 method_id_var_name='getCompressFormatList', |
1019 java_class_name='', | 1030 java_class_name='', |
1020 params=[], | 1031 params=[], |
1021 env_call=('Void', ''), | 1032 env_call=('Void', ''), |
1022 unchecked=False, | 1033 unchecked=False, |
1023 ), | 1034 ), |
1024 ] | 1035 ] |
1025 self.assertListEquals(golden_called_by_natives, called_by_natives) | 1036 self.assertListEquals(golden_called_by_natives, called_by_natives) |
1026 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', | 1037 h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
1027 [], called_by_natives) | 1038 [], called_by_natives, |
| 1039 TestOptions()) |
1028 golden_content = """\ | 1040 golden_content = """\ |
1029 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1041 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
1030 // Use of this source code is governed by a BSD-style license that can be | 1042 // Use of this source code is governed by a BSD-style license that can be |
1031 // found in the LICENSE file. | 1043 // found in the LICENSE file. |
1032 | 1044 |
1033 // This file is autogenerated by | 1045 // This file is autogenerated by |
1034 // base/android/jni_generator/jni_generator_tests.py | 1046 // base/android/jni_generator/jni_generator.py |
1035 // For | 1047 // For |
1036 // org/chromium/TestJni | 1048 // org/chromium/TestJni |
1037 | 1049 |
1038 #ifndef org_chromium_TestJni_JNI | 1050 #ifndef org_chromium_TestJni_JNI |
1039 #define org_chromium_TestJni_JNI | 1051 #define org_chromium_TestJni_JNI |
1040 | 1052 |
1041 #include <jni.h> | 1053 #include <jni.h> |
1042 | 1054 |
1043 #include "base/android/jni_android.h" | 1055 #include "base/android/jni_android.h" |
1044 #include "base/android/scoped_java_ref.h" | 1056 #include "base/android/scoped_java_ref.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 datatype='java/lang/String'),], | 1578 datatype='java/lang/String'),], |
1567 'java/io/InputStream')) | 1579 'java/io/InputStream')) |
1568 | 1580 |
1569 def testFromJavaPGenerics(self): | 1581 def testFromJavaPGenerics(self): |
1570 contents = """ | 1582 contents = """ |
1571 public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E> | 1583 public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E> |
1572 implements java.util.Set<E>, java.lang.Cloneable, java.io.Serializable { | 1584 implements java.util.Set<E>, java.lang.Cloneable, java.io.Serializable { |
1573 public void dummy(); | 1585 public void dummy(); |
1574 } | 1586 } |
1575 """ | 1587 """ |
1576 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None) | 1588 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), |
| 1589 TestOptions()) |
1577 self.assertEquals(1, len(jni_from_javap.called_by_natives)) | 1590 self.assertEquals(1, len(jni_from_javap.called_by_natives)) |
1578 golden_content = """\ | 1591 golden_content = """\ |
1579 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1592 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
1580 // Use of this source code is governed by a BSD-style license that can be | 1593 // Use of this source code is governed by a BSD-style license that can be |
1581 // found in the LICENSE file. | 1594 // found in the LICENSE file. |
1582 | 1595 |
1583 // This file is autogenerated by | 1596 // This file is autogenerated by |
1584 // base/android/jni_generator/jni_generator_tests.py | 1597 // base/android/jni_generator/jni_generator.py |
1585 // For | 1598 // For |
1586 // java/util/HashSet | 1599 // java/util/HashSet |
1587 | 1600 |
1588 #ifndef java_util_HashSet_JNI | 1601 #ifndef java_util_HashSet_JNI |
1589 #define java_util_HashSet_JNI | 1602 #define java_util_HashSet_JNI |
1590 | 1603 |
1591 #include <jni.h> | 1604 #include <jni.h> |
1592 | 1605 |
1593 #include "base/android/jni_android.h" | 1606 #include "base/android/jni_android.h" |
1594 #include "base/android/scoped_java_ref.h" | 1607 #include "base/android/scoped_java_ref.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 public void close() throws java.io.IOException; | 1667 public void close() throws java.io.IOException; |
1655 public void mark(int); | 1668 public void mark(int); |
1656 public boolean markSupported(); | 1669 public boolean markSupported(); |
1657 public abstract int read() throws java.io.IOException; | 1670 public abstract int read() throws java.io.IOException; |
1658 public int read(byte[]) throws java.io.IOException; | 1671 public int read(byte[]) throws java.io.IOException; |
1659 public int read(byte[], int, int) throws java.io.IOException; | 1672 public int read(byte[], int, int) throws java.io.IOException; |
1660 public synchronized void reset() throws java.io.IOException; | 1673 public synchronized void reset() throws java.io.IOException; |
1661 public long skip(long) throws java.io.IOException; | 1674 public long skip(long) throws java.io.IOException; |
1662 } | 1675 } |
1663 """ | 1676 """ |
1664 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None) | 1677 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), |
| 1678 TestOptions()) |
1665 self.assertEquals(10, len(jni_from_javap.called_by_natives)) | 1679 self.assertEquals(10, len(jni_from_javap.called_by_natives)) |
1666 golden_content = """\ | 1680 golden_content = """\ |
1667 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1681 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
1668 // Use of this source code is governed by a BSD-style license that can be | 1682 // Use of this source code is governed by a BSD-style license that can be |
1669 // found in the LICENSE file. | 1683 // found in the LICENSE file. |
1670 | 1684 |
1671 // This file is autogenerated by | 1685 // This file is autogenerated by |
1672 // base/android/jni_generator/jni_generator_tests.py | 1686 // base/android/jni_generator/jni_generator.py |
1673 // For | 1687 // For |
1674 // java/io/InputStream | 1688 // java/io/InputStream |
1675 | 1689 |
1676 #ifndef java_io_InputStream_JNI | 1690 #ifndef java_io_InputStream_JNI |
1677 #define java_io_InputStream_JNI | 1691 #define java_io_InputStream_JNI |
1678 | 1692 |
1679 #include <jni.h> | 1693 #include <jni.h> |
1680 | 1694 |
1681 #include "base/android/jni_android.h" | 1695 #include "base/android/jni_android.h" |
1682 #include "base/android/scoped_java_ref.h" | 1696 #include "base/android/scoped_java_ref.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 public void destroy() { | 1982 public void destroy() { |
1969 Log.v(TAG, "Destroying native SyncSetupFlow"); | 1983 Log.v(TAG, "Destroying native SyncSetupFlow"); |
1970 if (mNativeSyncSetupFlow != 0) { | 1984 if (mNativeSyncSetupFlow != 0) { |
1971 nativeSyncSetupEnded(mNativeSyncSetupFlow); | 1985 nativeSyncSetupEnded(mNativeSyncSetupFlow); |
1972 mNativeSyncSetupFlow = 0; | 1986 mNativeSyncSetupFlow = 0; |
1973 } | 1987 } |
1974 } | 1988 } |
1975 private native void nativeSyncSetupEnded( | 1989 private native void nativeSyncSetupEnded( |
1976 int nativeAndroidSyncSetupFlowHandler); | 1990 int nativeAndroidSyncSetupFlowHandler); |
1977 """ | 1991 """ |
1978 jni_from_java = jni_generator.JNIFromJavaSource(test_data, 'foo/bar') | 1992 jni_from_java = jni_generator.JNIFromJavaSource( |
| 1993 test_data, 'foo/bar', TestOptions()) |
1979 | 1994 |
1980 def testRaisesOnNonJNIMethod(self): | 1995 def testRaisesOnNonJNIMethod(self): |
1981 test_data = """ | 1996 test_data = """ |
1982 class MyInnerClass { | 1997 class MyInnerClass { |
1983 private int Foo(int p0) { | 1998 private int Foo(int p0) { |
1984 } | 1999 } |
1985 } | 2000 } |
1986 """ | 2001 """ |
1987 self.assertRaises(SyntaxError, | 2002 self.assertRaises(SyntaxError, |
1988 jni_generator.JNIFromJavaSource, | 2003 jni_generator.JNIFromJavaSource, |
1989 test_data, 'foo/bar') | 2004 test_data, 'foo/bar', TestOptions()) |
1990 | 2005 |
1991 def testJniSelfDocumentingExample(self): | 2006 def testJniSelfDocumentingExample(self): |
1992 script_dir = os.path.dirname(sys.argv[0]) | 2007 script_dir = os.path.dirname(sys.argv[0]) |
1993 content = file(os.path.join(script_dir, | 2008 content = file(os.path.join(script_dir, |
1994 'java/src/org/chromium/example/jni_generator/SampleForTests.java') | 2009 'java/src/org/chromium/example/jni_generator/SampleForTests.java') |
1995 ).read() | 2010 ).read() |
1996 golden_content = file(os.path.join(script_dir, | 2011 golden_content = file(os.path.join(script_dir, |
1997 'golden_sample_for_tests_jni.h')).read() | 2012 'golden_sample_for_tests_jni.h')).read() |
1998 jni_from_java = jni_generator.JNIFromJavaSource( | 2013 jni_from_java = jni_generator.JNIFromJavaSource( |
1999 content, 'org/chromium/example/jni_generator/SampleForTests') | 2014 content, 'org/chromium/example/jni_generator/SampleForTests', |
| 2015 TestOptions()) |
2000 self.assertTextEquals(golden_content, jni_from_java.GetContent()) | 2016 self.assertTextEquals(golden_content, jni_from_java.GetContent()) |
2001 | 2017 |
2002 def testNoWrappingPreprocessorLines(self): | 2018 def testNoWrappingPreprocessorLines(self): |
2003 test_data = """ | 2019 test_data = """ |
2004 package com.google.lookhowextremelylongiam.snarf.icankeepthisupallday; | 2020 package com.google.lookhowextremelylongiam.snarf.icankeepthisupallday; |
2005 | 2021 |
2006 class ReallyLongClassNamesAreAllTheRage { | 2022 class ReallyLongClassNamesAreAllTheRage { |
2007 private static native int nativeTest(); | 2023 private static native int nativeTest(); |
2008 } | 2024 } |
2009 """ | 2025 """ |
2010 jni_from_java = jni_generator.JNIFromJavaSource( | 2026 jni_from_java = jni_generator.JNIFromJavaSource( |
2011 test_data, ('com/google/lookhowextremelylongiam/snarf/' | 2027 test_data, ('com/google/lookhowextremelylongiam/snarf/' |
2012 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) | 2028 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage'), |
| 2029 TestOptions()) |
2013 jni_lines = jni_from_java.GetContent().split('\n') | 2030 jni_lines = jni_from_java.GetContent().split('\n') |
2014 line = filter(lambda line: line.lstrip().startswith('#ifndef'), | 2031 line = filter(lambda line: line.lstrip().startswith('#ifndef'), |
2015 jni_lines)[0] | 2032 jni_lines)[0] |
2016 self.assertTrue(len(line) > 80, | 2033 self.assertTrue(len(line) > 80, |
2017 ('Expected #ifndef line to be > 80 chars: ', line)) | 2034 ('Expected #ifndef line to be > 80 chars: ', line)) |
2018 | 2035 |
2019 def testJarJarRemapping(self): | 2036 def testJarJarRemapping(self): |
2020 test_data = """ | 2037 test_data = """ |
2021 package org.chromium.example.jni_generator; | 2038 package org.chromium.example.jni_generator; |
2022 | 2039 |
2023 import org.chromium.example2.Test; | 2040 import org.chromium.example2.Test; |
2024 | 2041 |
2025 class Example { | 2042 class Example { |
2026 private static native void nativeTest(Test t); | 2043 private static native void nativeTest(Test t); |
2027 } | 2044 } |
2028 """ | 2045 """ |
2029 jni_generator.JniParams.SetJarJarMappings( | 2046 jni_generator.JniParams.SetJarJarMappings( |
2030 """rule org.chromium.example.** com.test.@1 | 2047 """rule org.chromium.example.** com.test.@1 |
2031 rule org.chromium.example2.** org.test2.@0""") | 2048 rule org.chromium.example2.** org.test2.@0""") |
2032 jni_from_java = jni_generator.JNIFromJavaSource( | 2049 jni_from_java = jni_generator.JNIFromJavaSource( |
2033 test_data, 'org/chromium/example/jni_generator/Example') | 2050 test_data, 'org/chromium/example/jni_generator/Example', TestOptions()) |
2034 jni_generator.JniParams.SetJarJarMappings('') | 2051 jni_generator.JniParams.SetJarJarMappings('') |
2035 golden_content = """\ | 2052 golden_content = """\ |
2036 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2053 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2037 // Use of this source code is governed by a BSD-style license that can be | 2054 // Use of this source code is governed by a BSD-style license that can be |
2038 // found in the LICENSE file. | 2055 // found in the LICENSE file. |
2039 | 2056 |
2040 // This file is autogenerated by | 2057 // This file is autogenerated by |
2041 // base/android/jni_generator/jni_generator_tests.py | 2058 // base/android/jni_generator/jni_generator.py |
2042 // For | 2059 // For |
2043 // org/chromium/example/jni_generator/Example | 2060 // org/chromium/example/jni_generator/Example |
2044 | 2061 |
2045 #ifndef org_chromium_example_jni_generator_Example_JNI | 2062 #ifndef org_chromium_example_jni_generator_Example_JNI |
2046 #define org_chromium_example_jni_generator_Example_JNI | 2063 #define org_chromium_example_jni_generator_Example_JNI |
2047 | 2064 |
2048 #include <jni.h> | 2065 #include <jni.h> |
2049 | 2066 |
2050 #include "base/android/jni_android.h" | 2067 #include "base/android/jni_android.h" |
2051 #include "base/android/scoped_java_ref.h" | 2068 #include "base/android/scoped_java_ref.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 | 2171 |
2155 def testJniParamsJavaToJni(self): | 2172 def testJniParamsJavaToJni(self): |
2156 self.assertTextEquals('I', JniParams.JavaToJni('int')) | 2173 self.assertTextEquals('I', JniParams.JavaToJni('int')) |
2157 self.assertTextEquals('[B', JniParams.JavaToJni('byte[]')) | 2174 self.assertTextEquals('[B', JniParams.JavaToJni('byte[]')) |
2158 self.assertTextEquals( | 2175 self.assertTextEquals( |
2159 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]')) | 2176 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]')) |
2160 | 2177 |
2161 | 2178 |
2162 if __name__ == '__main__': | 2179 if __name__ == '__main__': |
2163 unittest.main() | 2180 unittest.main() |
OLD | NEW |