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

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

Issue 10693134: Revert 146000 - Split out ContentViewCore from ContentView for embedders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if stripped_golden != stripped_generated: 47 if stripped_golden != stripped_generated:
48 print self.id() 48 print self.id()
49 for line in difflib.context_diff(stripped_golden, stripped_generated): 49 for line in difflib.context_diff(stripped_golden, stripped_generated):
50 print line 50 print line
51 print '\n\nGenerated' 51 print '\n\nGenerated'
52 print '=' * 80 52 print '=' * 80
53 print generated_text 53 print generated_text
54 print '=' * 80 54 print '=' * 80
55 self.fail('Golden text mismatch') 55 self.fail('Golden text mismatch')
56 56
57 # TODO(bulach): Detangle these tests from knowing about classes from Content.
58 def testNatives(self): 57 def testNatives(self):
59 test_data = """" 58 test_data = """"
60 private native int nativeInit(); 59 private native int nativeInit();
61 private native void nativeDestroy(int nativeChromeBrowserProvider); 60 private native void nativeDestroy(int nativeChromeBrowserProvider);
62 private native long nativeAddBookmark( 61 private native long nativeAddBookmark(
63 int nativeChromeBrowserProvider, 62 int nativeChromeBrowserProvider,
64 String url, String title, boolean isFolder, long parentId); 63 String url, String title, boolean isFolder, long parentId);
65 private static native String nativeGetDomainAndRegistry(String url); 64 private static native String nativeGetDomainAndRegistry(String url);
66 private static native void nativeCreateHistoricalTabFromState( 65 private static native void nativeCreateHistoricalTabFromState(
67 byte[] state, int tab_index); 66 byte[] state, int tab_index);
68 private native byte[] nativeGetStateAsByteArray(ContentViewCore view); 67 private native byte[] nativeGetStateAsByteArray(ContentView view);
69 private static native String[] nativeGetAutofillProfileGUIDs(); 68 private static native String[] nativeGetAutofillProfileGUIDs();
70 private native void nativeSetRecognitionResults( 69 private native void nativeSetRecognitionResults(
71 int sessionId, String[] results); 70 int sessionId, String[] results);
72 private native long nativeAddBookmarkFromAPI( 71 private native long nativeAddBookmarkFromAPI(
73 int nativeChromeBrowserProvider, 72 int nativeChromeBrowserProvider,
74 String url, Long created, Boolean isBookmark, 73 String url, Long created, Boolean isBookmark,
75 Long date, byte[] favicon, String title, Integer visits); 74 Long date, byte[] favicon, String title, Integer visits);
76 native int nativeFindAll(String find); 75 native int nativeFindAll(String find);
77 private static native BookmarkNode nativeGetDefaultBookmarkFolder(); 76 private static native BookmarkNode nativeGetDefaultBookmarkFolder();
78 private native SQLiteCursor nativeQueryBookmarkFromAPI( 77 private native SQLiteCursor nativeQueryBookmarkFromAPI(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 NativeMethod(return_type='void', static=True, 118 NativeMethod(return_type='void', static=True,
120 name='CreateHistoricalTabFromState', 119 name='CreateHistoricalTabFromState',
121 params=[Param(datatype='byte[]', 120 params=[Param(datatype='byte[]',
122 name='state'), 121 name='state'),
123 Param(datatype='int', 122 Param(datatype='int',
124 name='tab_index')], 123 name='tab_index')],
125 java_class_name=None, 124 java_class_name=None,
126 type='function'), 125 type='function'),
127 NativeMethod(return_type='byte[]', static=False, 126 NativeMethod(return_type='byte[]', static=False,
128 name='GetStateAsByteArray', 127 name='GetStateAsByteArray',
129 params=[Param(datatype='ContentViewCore', name='view')], 128 params=[Param(datatype='ContentView', name='view')],
130 java_class_name=None, 129 java_class_name=None,
131 type='function'), 130 type='function'),
132 NativeMethod(return_type='String[]', static=True, 131 NativeMethod(return_type='String[]', static=True,
133 name='GetAutofillProfileGUIDs', params=[], 132 name='GetAutofillProfileGUIDs', params=[],
134 java_class_name=None, 133 java_class_name=None,
135 type='function'), 134 type='function'),
136 NativeMethod(return_type='void', static=False, 135 NativeMethod(return_type='void', static=False,
137 name='SetRecognitionResults', 136 name='SetRecognitionResults',
138 params=[Param(datatype='int', name='sessionId'), 137 params=[Param(datatype='int', name='sessionId'),
139 Param(datatype='String[]', name='results')], 138 Param(datatype='String[]', name='results')],
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 ")" 352 ")"
354 "Ljava/lang/String;", reinterpret_cast<void*>(GetDomainAndRegistry) }, 353 "Ljava/lang/String;", reinterpret_cast<void*>(GetDomainAndRegistry) },
355 { "nativeCreateHistoricalTabFromState", 354 { "nativeCreateHistoricalTabFromState",
356 "(" 355 "("
357 "[B" 356 "[B"
358 "I" 357 "I"
359 ")" 358 ")"
360 "V", reinterpret_cast<void*>(CreateHistoricalTabFromState) }, 359 "V", reinterpret_cast<void*>(CreateHistoricalTabFromState) },
361 { "nativeGetStateAsByteArray", 360 { "nativeGetStateAsByteArray",
362 "(" 361 "("
363 "Lorg/chromium/content/browser/ContentViewCore;" 362 "Lorg/chromium/content/browser/ContentView;"
364 ")" 363 ")"
365 "[B", reinterpret_cast<void*>(GetStateAsByteArray) }, 364 "[B", reinterpret_cast<void*>(GetStateAsByteArray) },
366 { "nativeGetAutofillProfileGUIDs", 365 { "nativeGetAutofillProfileGUIDs",
367 "(" 366 "("
368 ")" 367 ")"
369 "[Ljava/lang/String;", reinterpret_cast<void*>(GetAutofillProfileGUIDs) }, 368 "[Ljava/lang/String;", reinterpret_cast<void*>(GetAutofillProfileGUIDs) },
370 { "nativeSetRecognitionResults", 369 { "nativeSetRecognitionResults",
371 "(" 370 "("
372 "I" 371 "I"
373 "[Ljava/lang/String;" 372 "[Ljava/lang/String;"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 AutoLoginInfoBar infobar = new AutoLoginInfoBar(nativeInfoBar, mContext, 747 AutoLoginInfoBar infobar = new AutoLoginInfoBar(nativeInfoBar, mContext,
749 realm, account, args); 748 realm, account, args);
750 if (infobar.displayedAccountCount() == 0) 749 if (infobar.displayedAccountCount() == 0)
751 infobar = null; 750 infobar = null;
752 return infobar; 751 return infobar;
753 } 752 }
754 @CalledByNative("InfoBar") 753 @CalledByNative("InfoBar")
755 void dismiss(); 754 void dismiss();
756 @SuppressWarnings("unused") 755 @SuppressWarnings("unused")
757 @CalledByNative 756 @CalledByNative
758 private static boolean shouldShowAutoLogin(ContentViewCore contentView, 757 private static boolean shouldShowAutoLogin(ContentView contentView,
759 String realm, String account, String args) { 758 String realm, String account, String args) {
760 AccountManagerContainer accountManagerContainer = 759 AccountManagerContainer accountManagerContainer =
761 new AccountManagerContainer((Activity)contentView.getContext(), 760 new AccountManagerContainer((Activity)contentView.getContext(),
762 realm, account, args); 761 realm, account, args);
763 String[] logins = accountManagerContainer.getAccountLogins(null); 762 String[] logins = accountManagerContainer.getAccountLogins(null);
764 return logins.length != 0; 763 return logins.length != 0;
765 } 764 }
766 @CalledByNative 765 @CalledByNative
767 static InputStream openUrl(String url) { 766 static InputStream openUrl(String url) {
768 return null; 767 return null;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 env_call=('Void', ''), 819 env_call=('Void', ''),
821 unchecked=False, 820 unchecked=False,
822 ), 821 ),
823 CalledByNative( 822 CalledByNative(
824 return_type='boolean', 823 return_type='boolean',
825 system_class=False, 824 system_class=False,
826 static=True, 825 static=True,
827 name='shouldShowAutoLogin', 826 name='shouldShowAutoLogin',
828 method_id_var_name='shouldShowAutoLogin', 827 method_id_var_name='shouldShowAutoLogin',
829 java_class_name='', 828 java_class_name='',
830 params=[Param(datatype='ContentViewCore', name='contentView'), 829 params=[Param(datatype='ContentView', name='contentView'),
831 Param(datatype='String', name='realm'), 830 Param(datatype='String', name='realm'),
832 Param(datatype='String', name='account'), 831 Param(datatype='String', name='account'),
833 Param(datatype='String', name='args')], 832 Param(datatype='String', name='args')],
834 env_call=('Boolean', ''), 833 env_call=('Boolean', ''),
835 unchecked=False, 834 unchecked=False,
836 ), 835 ),
837 CalledByNative( 836 CalledByNative(
838 return_type='InputStream', 837 return_type='InputStream',
839 system_class=False, 838 system_class=False,
840 static=True, 839 static=True,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 "(" 1054 "("
1056 ")" 1055 ")"
1057 "V"); 1056 "V");
1058 1057
1059 g_TestJni_shouldShowAutoLogin = 1058 g_TestJni_shouldShowAutoLogin =
1060 base::android::GetStaticMethodID( 1059 base::android::GetStaticMethodID(
1061 env, g_TestJni_clazz, 1060 env, g_TestJni_clazz,
1062 "shouldShowAutoLogin", 1061 "shouldShowAutoLogin",
1063 1062
1064 "(" 1063 "("
1065 "Lorg/chromium/content/browser/ContentViewCore;" 1064 "Lorg/chromium/content/browser/ContentView;"
1066 "Ljava/lang/String;" 1065 "Ljava/lang/String;"
1067 "Ljava/lang/String;" 1066 "Ljava/lang/String;"
1068 "Ljava/lang/String;" 1067 "Ljava/lang/String;"
1069 ")" 1068 ")"
1070 "Z"); 1069 "Z");
1071 1070
1072 g_TestJni_openUrl = 1071 g_TestJni_openUrl =
1073 base::android::GetStaticMethodID( 1072 base::android::GetStaticMethodID(
1074 env, g_TestJni_clazz, 1073 env, g_TestJni_clazz,
1075 "openUrl", 1074 "openUrl",
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 self.assertRaises(SystemExit, jni_generator.CheckFilenames, 1498 self.assertRaises(SystemExit, jni_generator.CheckFilenames,
1500 ['NotTheSame.java'], ['not_good.h']) 1499 ['NotTheSame.java'], ['not_good.h'])
1501 self.assertRaises(SystemExit, jni_generator.CheckFilenames, 1500 self.assertRaises(SystemExit, jni_generator.CheckFilenames,
1502 ['MissingJniSuffix.java'], ['missing_jni_suffix.h']) 1501 ['MissingJniSuffix.java'], ['missing_jni_suffix.h'])
1503 jni_generator.CheckFilenames(['ThisIsFine.java'], ['this_is_fine_jni.h']) 1502 jni_generator.CheckFilenames(['ThisIsFine.java'], ['this_is_fine_jni.h'])
1504 jni_generator.CheckFilenames([], []) 1503 jni_generator.CheckFilenames([], [])
1505 1504
1506 1505
1507 if __name__ == '__main__': 1506 if __name__ == '__main__':
1508 unittest.main() 1507 unittest.main()
OLDNEW
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | content/browser/android/browser_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698