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

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

Issue 12094008: Bugfix: to add missing prefix for return type from javap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding unittests Created 7 years, 11 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
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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, NativeMethod, Param 19 from jni_generator import CalledByNative, JniParams, NativeMethod, Param
20 20
21 21
22 class TestGenerator(unittest.TestCase): 22 class TestGenerator(unittest.TestCase):
23 def assertObjEquals(self, first, second): 23 def assertObjEquals(self, first, second):
24 dict_first = first.__dict__ 24 dict_first = first.__dict__
25 dict_second = second.__dict__ 25 dict_second = second.__dict__
26 self.assertEquals(dict_first.keys(), dict_second.keys()) 26 self.assertEquals(dict_first.keys(), dict_second.keys())
27 for key, value in dict_first.iteritems(): 27 for key, value in dict_first.iteritems():
28 if (type(value) is list and len(value) and 28 if (type(value) is list and len(value) and
29 isinstance(type(value[0]), object)): 29 isinstance(type(value[0]), object)):
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 self.assertTrue('Lorg/chromium/content/app/Foo$BookmarkNode' in 1911 self.assertTrue('Lorg/chromium/content/app/Foo$BookmarkNode' in
1912 jni_generator.JniParams._inner_classes) 1912 jni_generator.JniParams._inner_classes)
1913 self.assertTrue('Lorg/chromium/content/app/Foo$PasswordListObserver' in 1913 self.assertTrue('Lorg/chromium/content/app/Foo$PasswordListObserver' in
1914 jni_generator.JniParams._inner_classes) 1914 jni_generator.JniParams._inner_classes)
1915 self.assertEquals('Lorg/chromium/content/app/ContentMain$Inner;', 1915 self.assertEquals('Lorg/chromium/content/app/ContentMain$Inner;',
1916 jni_generator.JniParams.JavaToJni('ContentMain.Inner')) 1916 jni_generator.JniParams.JavaToJni('ContentMain.Inner'))
1917 self.assertRaises(SyntaxError, 1917 self.assertRaises(SyntaxError,
1918 jni_generator.JniParams.JavaToJni, 1918 jni_generator.JniParams.JavaToJni,
1919 'AnException') 1919 'AnException')
1920 1920
1921 def testJniParamsJavaToJni(self):
1922 self.assertTextEquals( 'I', JniParams.JavaToJni('int'))
bulach 2013/02/04 14:44:24 nit: remove space before the first param here and
dwkang1 2013/02/05 01:46:28 Done.
1923 self.assertTextEquals( '[B', JniParams.JavaToJni('byte[]'))
1924 self.assertTextEquals(
1925 '[Ljava/nio/ByteBuffer;', JniParams.JavaToJni('java/nio/ByteBuffer[]'))
1926
1921 1927
1922 if __name__ == '__main__': 1928 if __name__ == '__main__':
1923 unittest.main() 1929 unittest.main()
OLDNEW
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698