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

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

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