Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: base/android/jni_generator/jni_generator_tests.py

Issue 290403002: Adding JNIAdditionalImport annotation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Follow review Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 jni_generator.JNIFromJavaSource( 1026 jni_generator.JNIFromJavaSource(
1027 test_data % {'IMPORT': import_clause}, 1027 test_data % {'IMPORT': import_clause},
1028 'org/chromium/android_webview/AwContentStatics', 1028 'org/chromium/android_webview/AwContentStatics',
1029 TestOptions()) 1029 TestOptions())
1030 # Ensure it raises without the import. 1030 # Ensure it raises without the import.
1031 self.assertRaises(SyntaxError, lambda: generate('')) 1031 self.assertRaises(SyntaxError, lambda: generate(''))
1032 1032
1033 # Ensure it's fine with the import. 1033 # Ensure it's fine with the import.
1034 generate('import java.lang.Runnable;') 1034 generate('import java.lang.Runnable;')
1035 1035
1036 def testJNIAdditionalImport(self):
1037 test_data = """
1038 package org.chromium.foo;
1039
1040 @JNIAdditionalImport(Bar.class)
1041 class Foo {
1042
1043 @CalledByNative
1044 private static void calledByNative(Bar.Callback callback) {
1045 }
1046
1047 private static native void nativeDoSomething(Bar.Callback callback);
1048 }
1049 """
1050 jni_from_java = jni_generator.JNIFromJavaSource(test_data,
1051 'org/chromium/foo/Foo',
1052 TestOptions())
1053 self.assertGoldenTextEquals(jni_from_java.GetContent())
1054
1036 1055
1037 if __name__ == '__main__': 1056 if __name__ == '__main__':
1038 unittest.main() 1057 unittest.main()
OLDNEW
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | base/android/jni_generator/testJNIAdditionalImport.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698