Index: base/android/jni_generator/jni_generator_tests.py |
diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py |
index 3ce58f1d95a6cde7b26010edad2a9a9b5fce6408..eaa3f7309e82ad45fe78ec380efbe4f2934c8d3d 100755 |
--- a/base/android/jni_generator/jni_generator_tests.py |
+++ b/base/android/jni_generator/jni_generator_tests.py |
@@ -19,6 +19,17 @@ import jni_generator |
from jni_generator import CalledByNative, JniParams, NativeMethod, Param |
+SCRIPT_NAME = 'base/android/jni_generator/jni_generator.py' |
+ |
+ |
+class TestOptions(object): |
+ """The mock options object which is passed to the jni_generator.py script.""" |
+ |
+ def __init__(self): |
+ self.namespace = None |
+ self.script_name = SCRIPT_NAME |
+ |
+ |
class TestGenerator(unittest.TestCase): |
def assertObjEquals(self, first, second): |
dict_first = first.__dict__ |
@@ -206,14 +217,14 @@ class TestGenerator(unittest.TestCase): |
] |
self.assertListEquals(golden_natives, natives) |
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
- natives, []) |
+ natives, [], TestOptions()) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// org/chromium/TestJni |
@@ -443,14 +454,14 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
] |
self.assertListEquals(golden_natives, natives) |
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
- natives, []) |
+ natives, [], TestOptions()) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// org/chromium/TestJni |
@@ -530,14 +541,14 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
] |
self.assertListEquals(golden_natives, natives) |
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
- natives, []) |
+ natives, [], TestOptions()) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// org/chromium/TestJni |
@@ -636,14 +647,14 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
] |
self.assertListEquals(golden_natives, natives) |
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
- natives, []) |
+ natives, [], TestOptions()) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// org/chromium/TestJni |
@@ -1024,14 +1035,15 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
] |
self.assertListEquals(golden_called_by_natives, called_by_natives) |
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', |
- [], called_by_natives) |
+ [], called_by_natives, |
+ TestOptions()) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// org/chromium/TestJni |
@@ -1573,7 +1585,8 @@ public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E> |
public void dummy(); |
} |
""" |
- jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None) |
+ jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), |
+ TestOptions()) |
self.assertEquals(1, len(jni_from_javap.called_by_natives)) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
@@ -1581,7 +1594,7 @@ public abstract class java.util.HashSet<T> extends java.util.AbstractSet<E> |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// java/util/HashSet |
@@ -1661,7 +1674,8 @@ public abstract class java.io.InputStream extends java.lang.Object |
public long skip(long) throws java.io.IOException; |
} |
""" |
- jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), None) |
+ jni_from_javap = jni_generator.JNIFromJavaP(contents.split('\n'), |
+ TestOptions()) |
self.assertEquals(10, len(jni_from_javap.called_by_natives)) |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
@@ -1669,7 +1683,7 @@ public abstract class java.io.InputStream extends java.lang.Object |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// java/io/InputStream |
@@ -1975,7 +1989,8 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
private native void nativeSyncSetupEnded( |
int nativeAndroidSyncSetupFlowHandler); |
""" |
- jni_from_java = jni_generator.JNIFromJavaSource(test_data, 'foo/bar') |
+ jni_from_java = jni_generator.JNIFromJavaSource( |
+ test_data, 'foo/bar', TestOptions()) |
def testRaisesOnNonJNIMethod(self): |
test_data = """ |
@@ -1986,7 +2001,7 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
""" |
self.assertRaises(SyntaxError, |
jni_generator.JNIFromJavaSource, |
- test_data, 'foo/bar') |
+ test_data, 'foo/bar', TestOptions()) |
def testJniSelfDocumentingExample(self): |
script_dir = os.path.dirname(sys.argv[0]) |
@@ -1996,7 +2011,8 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
golden_content = file(os.path.join(script_dir, |
'golden_sample_for_tests_jni.h')).read() |
jni_from_java = jni_generator.JNIFromJavaSource( |
- content, 'org/chromium/example/jni_generator/SampleForTests') |
+ content, 'org/chromium/example/jni_generator/SampleForTests', |
+ TestOptions()) |
self.assertTextEquals(golden_content, jni_from_java.GetContent()) |
def testNoWrappingPreprocessorLines(self): |
@@ -2009,7 +2025,8 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
""" |
jni_from_java = jni_generator.JNIFromJavaSource( |
test_data, ('com/google/lookhowextremelylongiam/snarf/' |
- 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) |
+ 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage'), |
+ TestOptions()) |
jni_lines = jni_from_java.GetContent().split('\n') |
line = filter(lambda line: line.lstrip().startswith('#ifndef'), |
jni_lines)[0] |
@@ -2030,7 +2047,7 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
"""rule org.chromium.example.** com.test.@1 |
rule org.chromium.example2.** org.test2.@0""") |
jni_from_java = jni_generator.JNIFromJavaSource( |
- test_data, 'org/chromium/example/jni_generator/Example') |
+ test_data, 'org/chromium/example/jni_generator/Example', TestOptions()) |
jni_generator.JniParams.SetJarJarMappings('') |
golden_content = """\ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
@@ -2038,7 +2055,7 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
// found in the LICENSE file. |
// This file is autogenerated by |
-// base/android/jni_generator/jni_generator_tests.py |
+// base/android/jni_generator/jni_generator.py |
// For |
// org/chromium/example/jni_generator/Example |