Chromium Code Reviews| 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..bc3ce4117e302066263549cfe6499de91f4fc50b 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 Options(object): |
|
rmcilroy
2013/09/27 13:07:56
nit - MockOptions? or maybe TestOptions?
bulach
2013/09/30 09:04:50
Done.
|
| + """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, [], Options()) |
| 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, [], Options()) |
| 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, [], Options()) |
| 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, [], Options()) |
| 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,14 @@ 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, Options()) |
| 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 +1584,7 @@ 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'), Options()) |
| self.assertEquals(1, len(jni_from_javap.called_by_natives)) |
| golden_content = """\ |
| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| @@ -1581,7 +1592,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 +1672,7 @@ 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'), Options()) |
| self.assertEquals(10, len(jni_from_javap.called_by_natives)) |
| golden_content = """\ |
| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| @@ -1669,7 +1680,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 +1986,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', Options()) |
| def testRaisesOnNonJNIMethod(self): |
| test_data = """ |
| @@ -1986,7 +1998,7 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
| """ |
| self.assertRaises(SyntaxError, |
| jni_generator.JNIFromJavaSource, |
| - test_data, 'foo/bar') |
| + test_data, 'foo/bar', Options()) |
| def testJniSelfDocumentingExample(self): |
| script_dir = os.path.dirname(sys.argv[0]) |
| @@ -1996,7 +2008,7 @@ 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', Options()) |
| self.assertTextEquals(golden_content, jni_from_java.GetContent()) |
| def testNoWrappingPreprocessorLines(self): |
| @@ -2009,7 +2021,8 @@ static bool RegisterNativesImpl(JNIEnv* env) { |
| """ |
| jni_from_java = jni_generator.JNIFromJavaSource( |
| test_data, ('com/google/lookhowextremelylongiam/snarf/' |
| - 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) |
| + 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage'), |
| + Options()) |
| jni_lines = jni_from_java.GetContent().split('\n') |
| line = filter(lambda line: line.lstrip().startswith('#ifndef'), |
| jni_lines)[0] |
| @@ -2030,7 +2043,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', Options()) |
| jni_generator.JniParams.SetJarJarMappings('') |
| golden_content = """\ |
| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| @@ -2038,7 +2051,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 |