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 Options(object): | |
rmcilroy
2013/09/27 13:07:56
nit - MockOptions? or maybe TestOptions?
bulach
2013/09/30 09:04:50
Done.
| |
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, [], Options()) |
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, [], Options()) |
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, [], Options()) |
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, [], Options()) |
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, Options()) |
1028 golden_content = """\ | 1039 golden_content = """\ |
1029 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1040 // 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 | 1041 // Use of this source code is governed by a BSD-style license that can be |
1031 // found in the LICENSE file. | 1042 // found in the LICENSE file. |
1032 | 1043 |
1033 // This file is autogenerated by | 1044 // This file is autogenerated by |
1034 // base/android/jni_generator/jni_generator_tests.py | 1045 // base/android/jni_generator/jni_generator.py |
1035 // For | 1046 // For |
1036 // org/chromium/TestJni | 1047 // org/chromium/TestJni |
1037 | 1048 |
1038 #ifndef org_chromium_TestJni_JNI | 1049 #ifndef org_chromium_TestJni_JNI |
1039 #define org_chromium_TestJni_JNI | 1050 #define org_chromium_TestJni_JNI |
1040 | 1051 |
1041 #include <jni.h> | 1052 #include <jni.h> |
1042 | 1053 |
1043 #include "base/android/jni_android.h" | 1054 #include "base/android/jni_android.h" |
1044 #include "base/android/scoped_java_ref.h" | 1055 #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'),], | 1577 datatype='java/lang/String'),], |
1567 'java/io/InputStream')) | 1578 'java/io/InputStream')) |
1568 | 1579 |
1569 def testFromJavaPGenerics(self): | 1580 def testFromJavaPGenerics(self): |
1570 contents = """ | 1581 contents = """ |
1571 public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E> | 1582 public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E> |
1572 implements java.util.Set<E>, java.lang.Cloneable, java.io.Serializable { | 1583 implements java.util.Set<E>, java.lang.Cloneable, java.io.Serializable { |
1573 public void dummy(); | 1584 public void dummy(); |
1574 } | 1585 } |
1575 """ | 1586 """ |
1576 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None) | 1587 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), Options()) |
1577 self.assertEquals(1, len(jni_from_javap.called_by_natives)) | 1588 self.assertEquals(1, len(jni_from_javap.called_by_natives)) |
1578 golden_content = """\ | 1589 golden_content = """\ |
1579 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1590 // 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 | 1591 // Use of this source code is governed by a BSD-style license that can be |
1581 // found in the LICENSE file. | 1592 // found in the LICENSE file. |
1582 | 1593 |
1583 // This file is autogenerated by | 1594 // This file is autogenerated by |
1584 // base/android/jni_generator/jni_generator_tests.py | 1595 // base/android/jni_generator/jni_generator.py |
1585 // For | 1596 // For |
1586 // java/util/HashSet | 1597 // java/util/HashSet |
1587 | 1598 |
1588 #ifndef java_util_HashSet_JNI | 1599 #ifndef java_util_HashSet_JNI |
1589 #define java_util_HashSet_JNI | 1600 #define java_util_HashSet_JNI |
1590 | 1601 |
1591 #include <jni.h> | 1602 #include <jni.h> |
1592 | 1603 |
1593 #include "base/android/jni_android.h" | 1604 #include "base/android/jni_android.h" |
1594 #include "base/android/scoped_java_ref.h" | 1605 #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; | 1665 public void close() throws java.io.IOException; |
1655 public void mark(int); | 1666 public void mark(int); |
1656 public boolean markSupported(); | 1667 public boolean markSupported(); |
1657 public abstract int read() throws java.io.IOException; | 1668 public abstract int read() throws java.io.IOException; |
1658 public int read(byte[]) throws java.io.IOException; | 1669 public int read(byte[]) throws java.io.IOException; |
1659 public int read(byte[], int, int) throws java.io.IOException; | 1670 public int read(byte[], int, int) throws java.io.IOException; |
1660 public synchronized void reset() throws java.io.IOException; | 1671 public synchronized void reset() throws java.io.IOException; |
1661 public long skip(long) throws java.io.IOException; | 1672 public long skip(long) throws java.io.IOException; |
1662 } | 1673 } |
1663 """ | 1674 """ |
1664 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None) | 1675 jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), Options()) |
1665 self.assertEquals(10, len(jni_from_javap.called_by_natives)) | 1676 self.assertEquals(10, len(jni_from_javap.called_by_natives)) |
1666 golden_content = """\ | 1677 golden_content = """\ |
1667 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1678 // 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 | 1679 // Use of this source code is governed by a BSD-style license that can be |
1669 // found in the LICENSE file. | 1680 // found in the LICENSE file. |
1670 | 1681 |
1671 // This file is autogenerated by | 1682 // This file is autogenerated by |
1672 // base/android/jni_generator/jni_generator_tests.py | 1683 // base/android/jni_generator/jni_generator.py |
1673 // For | 1684 // For |
1674 // java/io/InputStream | 1685 // java/io/InputStream |
1675 | 1686 |
1676 #ifndef java_io_InputStream_JNI | 1687 #ifndef java_io_InputStream_JNI |
1677 #define java_io_InputStream_JNI | 1688 #define java_io_InputStream_JNI |
1678 | 1689 |
1679 #include <jni.h> | 1690 #include <jni.h> |
1680 | 1691 |
1681 #include "base/android/jni_android.h" | 1692 #include "base/android/jni_android.h" |
1682 #include "base/android/scoped_java_ref.h" | 1693 #include "base/android/scoped_java_ref.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1968 public void destroy() { | 1979 public void destroy() { |
1969 Log.v(TAG, "Destroying native SyncSetupFlow"); | 1980 Log.v(TAG, "Destroying native SyncSetupFlow"); |
1970 if (mNativeSyncSetupFlow != 0) { | 1981 if (mNativeSyncSetupFlow != 0) { |
1971 nativeSyncSetupEnded(mNativeSyncSetupFlow); | 1982 nativeSyncSetupEnded(mNativeSyncSetupFlow); |
1972 mNativeSyncSetupFlow = 0; | 1983 mNativeSyncSetupFlow = 0; |
1973 } | 1984 } |
1974 } | 1985 } |
1975 private native void nativeSyncSetupEnded( | 1986 private native void nativeSyncSetupEnded( |
1976 int nativeAndroidSyncSetupFlowHandler); | 1987 int nativeAndroidSyncSetupFlowHandler); |
1977 """ | 1988 """ |
1978 jni_from_java = jni_generator.JNIFromJavaSource(test_data, 'foo/bar') | 1989 jni_from_java = jni_generator.JNIFromJavaSource( |
1990 test_data, 'foo/bar', Options()) | |
1979 | 1991 |
1980 def testRaisesOnNonJNIMethod(self): | 1992 def testRaisesOnNonJNIMethod(self): |
1981 test_data = """ | 1993 test_data = """ |
1982 class MyInnerClass { | 1994 class MyInnerClass { |
1983 private int Foo(int p0) { | 1995 private int Foo(int p0) { |
1984 } | 1996 } |
1985 } | 1997 } |
1986 """ | 1998 """ |
1987 self.assertRaises(SyntaxError, | 1999 self.assertRaises(SyntaxError, |
1988 jni_generator.JNIFromJavaSource, | 2000 jni_generator.JNIFromJavaSource, |
1989 test_data, 'foo/bar') | 2001 test_data, 'foo/bar', Options()) |
1990 | 2002 |
1991 def testJniSelfDocumentingExample(self): | 2003 def testJniSelfDocumentingExample(self): |
1992 script_dir = os.path.dirname(sys.argv[0]) | 2004 script_dir = os.path.dirname(sys.argv[0]) |
1993 content = file(os.path.join(script_dir, | 2005 content = file(os.path.join(script_dir, |
1994 'java/src/org/chromium/example/jni_generator/SampleForTests.java') | 2006 'java/src/org/chromium/example/jni_generator/SampleForTests.java') |
1995 ).read() | 2007 ).read() |
1996 golden_content = file(os.path.join(script_dir, | 2008 golden_content = file(os.path.join(script_dir, |
1997 'golden_sample_for_tests_jni.h')).read() | 2009 'golden_sample_for_tests_jni.h')).read() |
1998 jni_from_java = jni_generator.JNIFromJavaSource( | 2010 jni_from_java = jni_generator.JNIFromJavaSource( |
1999 content, 'org/chromium/example/jni_generator/SampleForTests') | 2011 content, 'org/chromium/example/jni_generator/SampleForTests', Options()) |
2000 self.assertTextEquals(golden_content, jni_from_java.GetContent()) | 2012 self.assertTextEquals(golden_content, jni_from_java.GetContent()) |
2001 | 2013 |
2002 def testNoWrappingPreprocessorLines(self): | 2014 def testNoWrappingPreprocessorLines(self): |
2003 test_data = """ | 2015 test_data = """ |
2004 package com.google.lookhowextremelylongiam.snarf.icankeepthisupallday; | 2016 package com.google.lookhowextremelylongiam.snarf.icankeepthisupallday; |
2005 | 2017 |
2006 class ReallyLongClassNamesAreAllTheRage { | 2018 class ReallyLongClassNamesAreAllTheRage { |
2007 private static native int nativeTest(); | 2019 private static native int nativeTest(); |
2008 } | 2020 } |
2009 """ | 2021 """ |
2010 jni_from_java = jni_generator.JNIFromJavaSource( | 2022 jni_from_java = jni_generator.JNIFromJavaSource( |
2011 test_data, ('com/google/lookhowextremelylongiam/snarf/' | 2023 test_data, ('com/google/lookhowextremelylongiam/snarf/' |
2012 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) | 2024 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage'), |
2025 Options()) | |
2013 jni_lines = jni_from_java.GetContent().split('\n') | 2026 jni_lines = jni_from_java.GetContent().split('\n') |
2014 line = filter(lambda line: line.lstrip().startswith('#ifndef'), | 2027 line = filter(lambda line: line.lstrip().startswith('#ifndef'), |
2015 jni_lines)[0] | 2028 jni_lines)[0] |
2016 self.assertTrue(len(line) > 80, | 2029 self.assertTrue(len(line) > 80, |
2017 ('Expected #ifndef line to be > 80 chars: ', line)) | 2030 ('Expected #ifndef line to be > 80 chars: ', line)) |
2018 | 2031 |
2019 def testJarJarRemapping(self): | 2032 def testJarJarRemapping(self): |
2020 test_data = """ | 2033 test_data = """ |
2021 package org.chromium.example.jni_generator; | 2034 package org.chromium.example.jni_generator; |
2022 | 2035 |
2023 import org.chromium.example2.Test; | 2036 import org.chromium.example2.Test; |
2024 | 2037 |
2025 class Example { | 2038 class Example { |
2026 private static native void nativeTest(Test t); | 2039 private static native void nativeTest(Test t); |
2027 } | 2040 } |
2028 """ | 2041 """ |
2029 jni_generator.JniParams.SetJarJarMappings( | 2042 jni_generator.JniParams.SetJarJarMappings( |
2030 """rule org.chromium.example.** com.test.@1 | 2043 """rule org.chromium.example.** com.test.@1 |
2031 rule org.chromium.example2.** org.test2.@0""") | 2044 rule org.chromium.example2.** org.test2.@0""") |
2032 jni_from_java = jni_generator.JNIFromJavaSource( | 2045 jni_from_java = jni_generator.JNIFromJavaSource( |
2033 test_data, 'org/chromium/example/jni_generator/Example') | 2046 test_data, 'org/chromium/example/jni_generator/Example', Options()) |
2034 jni_generator.JniParams.SetJarJarMappings('') | 2047 jni_generator.JniParams.SetJarJarMappings('') |
2035 golden_content = """\ | 2048 golden_content = """\ |
2036 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2049 // 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 | 2050 // Use of this source code is governed by a BSD-style license that can be |
2038 // found in the LICENSE file. | 2051 // found in the LICENSE file. |
2039 | 2052 |
2040 // This file is autogenerated by | 2053 // This file is autogenerated by |
2041 // base/android/jni_generator/jni_generator_tests.py | 2054 // base/android/jni_generator/jni_generator.py |
2042 // For | 2055 // For |
2043 // org/chromium/example/jni_generator/Example | 2056 // org/chromium/example/jni_generator/Example |
2044 | 2057 |
2045 #ifndef org_chromium_example_jni_generator_Example_JNI | 2058 #ifndef org_chromium_example_jni_generator_Example_JNI |
2046 #define org_chromium_example_jni_generator_Example_JNI | 2059 #define org_chromium_example_jni_generator_Example_JNI |
2047 | 2060 |
2048 #include <jni.h> | 2061 #include <jni.h> |
2049 | 2062 |
2050 #include "base/android/jni_android.h" | 2063 #include "base/android/jni_android.h" |
2051 #include "base/android/scoped_java_ref.h" | 2064 #include "base/android/scoped_java_ref.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2154 | 2167 |
2155 def testJniParamsJavaToJni(self): | 2168 def testJniParamsJavaToJni(self): |
2156 self.assertTextEquals('I', JniParams.JavaToJni('int')) | 2169 self.assertTextEquals('I', JniParams.JavaToJni('int')) |
2157 self.assertTextEquals('[B', JniParams.JavaToJni('byte[]')) | 2170 self.assertTextEquals('[B', JniParams.JavaToJni('byte[]')) |
2158 self.assertTextEquals( | 2171 self.assertTextEquals( |
2159 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]')) | 2172 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]')) |
2160 | 2173 |
2161 | 2174 |
2162 if __name__ == '__main__': | 2175 if __name__ == '__main__': |
2163 unittest.main() | 2176 unittest.main() |
OLD | NEW |