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

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

Issue 11339013: Android: passes a list of qualified JNI parameters as a param to the generator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yaron's and Nico's comments Created 8 years, 1 month 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(View 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 OnFrameAvailableListener nativeGetInnerClass();
78 private native SQLiteCursor nativeQueryBookmarkFromAPI( 77 private native Bitmap nativeQueryBitmap(
79 int nativeChromeBrowserProvider, 78 int nativeChromeBrowserProvider,
80 String[] projection, String selection, 79 String[] projection, String selection,
81 String[] selectionArgs, String sortOrder); 80 String[] selectionArgs, String sortOrder);
82 private native void nativeGotOrientation( 81 private native void nativeGotOrientation(
83 int nativeDataFetcherImplAndroid, 82 int nativeDataFetcherImplAndroid,
84 double alpha, double beta, double gamma); 83 double alpha, double beta, double gamma);
85 """ 84 """
86 natives = jni_generator.ExtractNatives(test_data) 85 natives = jni_generator.ExtractNatives(test_data)
87 golden_natives = [ 86 golden_natives = [
88 NativeMethod(return_type='int', static=False, 87 NativeMethod(return_type='int', static=False,
(...skipping 30 matching lines...) Expand all
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='View', 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 19 matching lines...) Expand all
159 name='visits')], 158 name='visits')],
160 java_class_name=None, 159 java_class_name=None,
161 type='method', 160 type='method',
162 p0_type='ChromeBrowserProvider'), 161 p0_type='ChromeBrowserProvider'),
163 NativeMethod(return_type='int', static=False, 162 NativeMethod(return_type='int', static=False,
164 name='FindAll', 163 name='FindAll',
165 params=[Param(datatype='String', 164 params=[Param(datatype='String',
166 name='find')], 165 name='find')],
167 java_class_name=None, 166 java_class_name=None,
168 type='function'), 167 type='function'),
169 NativeMethod(return_type='BookmarkNode', static=True, 168 NativeMethod(return_type='OnFrameAvailableListener', static=True,
170 name='GetDefaultBookmarkFolder', 169 name='GetInnerClass',
171 params=[], 170 params=[],
172 java_class_name=None, 171 java_class_name=None,
173 type='function'), 172 type='function'),
174 NativeMethod(return_type='SQLiteCursor', 173 NativeMethod(return_type='Bitmap',
175 static=False, 174 static=False,
176 name='QueryBookmarkFromAPI', 175 name='QueryBitmap',
177 params=[Param(datatype='int', 176 params=[Param(datatype='int',
178 name='nativeChromeBrowserProvider'), 177 name='nativeChromeBrowserProvider'),
179 Param(datatype='String[]', 178 Param(datatype='String[]',
180 name='projection'), 179 name='projection'),
181 Param(datatype='String', 180 Param(datatype='String',
182 name='selection'), 181 name='selection'),
183 Param(datatype='String[]', 182 Param(datatype='String[]',
184 name='selectionArgs'), 183 name='selectionArgs'),
185 Param(datatype='String', 184 Param(datatype='String',
186 name='sortOrder'), 185 name='sortOrder'),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 248
250 static jobjectArray GetAutofillProfileGUIDs(JNIEnv* env, jclass clazz); 249 static jobjectArray GetAutofillProfileGUIDs(JNIEnv* env, jclass clazz);
251 250
252 static void SetRecognitionResults(JNIEnv* env, jobject obj, 251 static void SetRecognitionResults(JNIEnv* env, jobject obj,
253 jint sessionId, 252 jint sessionId,
254 jobjectArray results); 253 jobjectArray results);
255 254
256 static jint FindAll(JNIEnv* env, jobject obj, 255 static jint FindAll(JNIEnv* env, jobject obj,
257 jstring find); 256 jstring find);
258 257
259 static jobject GetDefaultBookmarkFolder(JNIEnv* env, jclass clazz); 258 static jobject GetInnerClass(JNIEnv* env, jclass clazz);
260 259
261 // Step 2: method stubs. 260 // Step 2: method stubs.
262 static void Destroy(JNIEnv* env, jobject obj, 261 static void Destroy(JNIEnv* env, jobject obj,
263 jint nativeChromeBrowserProvider) { 262 jint nativeChromeBrowserProvider) {
264 DCHECK(nativeChromeBrowserProvider) << "Destroy"; 263 DCHECK(nativeChromeBrowserProvider) << "Destroy";
265 ChromeBrowserProvider* native = 264 ChromeBrowserProvider* native =
266 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); 265 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
267 return native->Destroy(env, obj); 266 return native->Destroy(env, obj);
268 } 267 }
269 268
(...skipping 18 matching lines...) Expand all
288 jbyteArray favicon, 287 jbyteArray favicon,
289 jstring title, 288 jstring title,
290 jobject visits) { 289 jobject visits) {
291 DCHECK(nativeChromeBrowserProvider) << "AddBookmarkFromAPI"; 290 DCHECK(nativeChromeBrowserProvider) << "AddBookmarkFromAPI";
292 ChromeBrowserProvider* native = 291 ChromeBrowserProvider* native =
293 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); 292 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
294 return native->AddBookmarkFromAPI(env, obj, url, created, isBookmark, date, 293 return native->AddBookmarkFromAPI(env, obj, url, created, isBookmark, date,
295 favicon, title, visits); 294 favicon, title, visits);
296 } 295 }
297 296
298 static jobject QueryBookmarkFromAPI(JNIEnv* env, jobject obj, 297 static jobject QueryBitmap(JNIEnv* env, jobject obj,
299 jint nativeChromeBrowserProvider, 298 jint nativeChromeBrowserProvider,
300 jobjectArray projection, 299 jobjectArray projection,
301 jstring selection, 300 jstring selection,
302 jobjectArray selectionArgs, 301 jobjectArray selectionArgs,
303 jstring sortOrder) { 302 jstring sortOrder) {
304 DCHECK(nativeChromeBrowserProvider) << "QueryBookmarkFromAPI"; 303 DCHECK(nativeChromeBrowserProvider) << "QueryBitmap";
305 ChromeBrowserProvider* native = 304 ChromeBrowserProvider* native =
306 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider); 305 reinterpret_cast<ChromeBrowserProvider*>(nativeChromeBrowserProvider);
307 return native->QueryBookmarkFromAPI(env, obj, projection, selection, 306 return native->QueryBitmap(env, obj, projection, selection, selectionArgs,
308 selectionArgs, sortOrder).Release(); 307 sortOrder).Release();
309 } 308 }
310 309
311 static void GotOrientation(JNIEnv* env, jobject obj, 310 static void GotOrientation(JNIEnv* env, jobject obj,
312 jint nativeDataFetcherImplAndroid, 311 jint nativeDataFetcherImplAndroid,
313 jdouble alpha, 312 jdouble alpha,
314 jdouble beta, 313 jdouble beta,
315 jdouble gamma) { 314 jdouble gamma) {
316 DCHECK(nativeDataFetcherImplAndroid) << "GotOrientation"; 315 DCHECK(nativeDataFetcherImplAndroid) << "GotOrientation";
317 DataFetcherImplAndroid* native = 316 DataFetcherImplAndroid* native =
318 reinterpret_cast<DataFetcherImplAndroid*>(nativeDataFetcherImplAndroid); 317 reinterpret_cast<DataFetcherImplAndroid*>(nativeDataFetcherImplAndroid);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 ")" 349 ")"
351 "Ljava/lang/String;", reinterpret_cast<void*>(GetDomainAndRegistry) }, 350 "Ljava/lang/String;", reinterpret_cast<void*>(GetDomainAndRegistry) },
352 { "nativeCreateHistoricalTabFromState", 351 { "nativeCreateHistoricalTabFromState",
353 "(" 352 "("
354 "[B" 353 "[B"
355 "I" 354 "I"
356 ")" 355 ")"
357 "V", reinterpret_cast<void*>(CreateHistoricalTabFromState) }, 356 "V", reinterpret_cast<void*>(CreateHistoricalTabFromState) },
358 { "nativeGetStateAsByteArray", 357 { "nativeGetStateAsByteArray",
359 "(" 358 "("
360 "Lorg/chromium/content/browser/ContentViewCore;" 359 "Landroid/view/View;"
361 ")" 360 ")"
362 "[B", reinterpret_cast<void*>(GetStateAsByteArray) }, 361 "[B", reinterpret_cast<void*>(GetStateAsByteArray) },
363 { "nativeGetAutofillProfileGUIDs", 362 { "nativeGetAutofillProfileGUIDs",
364 "(" 363 "("
365 ")" 364 ")"
366 "[Ljava/lang/String;", reinterpret_cast<void*>(GetAutofillProfileGUIDs) }, 365 "[Ljava/lang/String;", reinterpret_cast<void*>(GetAutofillProfileGUIDs) },
367 { "nativeSetRecognitionResults", 366 { "nativeSetRecognitionResults",
368 "(" 367 "("
369 "I" 368 "I"
370 "[Ljava/lang/String;" 369 "[Ljava/lang/String;"
371 ")" 370 ")"
372 "V", reinterpret_cast<void*>(SetRecognitionResults) }, 371 "V", reinterpret_cast<void*>(SetRecognitionResults) },
373 { "nativeAddBookmarkFromAPI", 372 { "nativeAddBookmarkFromAPI",
374 "(" 373 "("
375 "I" 374 "I"
376 "Ljava/lang/String;" 375 "Ljava/lang/String;"
377 "Ljava/lang/Long;" 376 "Ljava/lang/Long;"
378 "Ljava/lang/Boolean;" 377 "Ljava/lang/Boolean;"
379 "Ljava/lang/Long;" 378 "Ljava/lang/Long;"
380 "[B" 379 "[B"
381 "Ljava/lang/String;" 380 "Ljava/lang/String;"
382 "Ljava/lang/Integer;" 381 "Ljava/lang/Integer;"
383 ")" 382 ")"
384 "J", reinterpret_cast<void*>(AddBookmarkFromAPI) }, 383 "J", reinterpret_cast<void*>(AddBookmarkFromAPI) },
385 { "nativeFindAll", 384 { "nativeFindAll",
386 "(" 385 "("
387 "Ljava/lang/String;" 386 "Ljava/lang/String;"
388 ")" 387 ")"
389 "I", reinterpret_cast<void*>(FindAll) }, 388 "I", reinterpret_cast<void*>(FindAll) },
390 { "nativeGetDefaultBookmarkFolder", 389 { "nativeGetInnerClass",
391 "(" 390 "("
392 ")" 391 ")"
393 "Lorg/chromium/chrome/browser/ChromeBrowserProvider$BookmarkNode;", 392 "Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;",
394 reinterpret_cast<void*>(GetDefaultBookmarkFolder) }, 393 reinterpret_cast<void*>(GetInnerClass) },
395 { "nativeQueryBookmarkFromAPI", 394 { "nativeQueryBitmap",
396 "(" 395 "("
397 "I" 396 "I"
398 "[Ljava/lang/String;" 397 "[Ljava/lang/String;"
399 "Ljava/lang/String;" 398 "Ljava/lang/String;"
400 "[Ljava/lang/String;" 399 "[Ljava/lang/String;"
401 "Ljava/lang/String;" 400 "Ljava/lang/String;"
402 ")" 401 ")"
403 "Lorg/chromium/chrome/browser/database/SQLiteCursor;", 402 "Landroid/graphics/Bitmap;", reinterpret_cast<void*>(QueryBitmap) },
404 reinterpret_cast<void*>(QueryBookmarkFromAPI) },
405 { "nativeGotOrientation", 403 { "nativeGotOrientation",
406 "(" 404 "("
407 "I" 405 "I"
408 "D" 406 "D"
409 "D" 407 "D"
410 "D" 408 "D"
411 ")" 409 ")"
412 "V", reinterpret_cast<void*>(GotOrientation) }, 410 "V", reinterpret_cast<void*>(GotOrientation) },
413 }; 411 };
414 const int kMethodsTestJniSize = arraysize(kMethodsTestJni); 412 const int kMethodsTestJniSize = arraysize(kMethodsTestJni);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 return true; 712 return true;
715 } 713 }
716 714
717 #endif // org_chromium_TestJni_JNI 715 #endif // org_chromium_TestJni_JNI
718 """ 716 """
719 self.assertTextEquals(golden_content, h.GetContent()) 717 self.assertTextEquals(golden_content, h.GetContent())
720 718
721 def testCalledByNatives(self): 719 def testCalledByNatives(self):
722 test_data = """" 720 test_data = """"
723 @CalledByNative 721 @CalledByNative
724 NativeInfoBar showConfirmInfoBar(int nativeInfoBar, String buttonOk, 722 OnFrameAvailableListener showConfirmInfoBar(int nativeInfoBar,
725 String buttonCancel, String title, 723 String buttonOk, String buttonCancel, String title, Bitmap icon) {
726 Bitmap icon) {
727 InfoBar infobar = new ConfirmInfoBar(nativeInfoBar, mContext, 724 InfoBar infobar = new ConfirmInfoBar(nativeInfoBar, mContext,
728 buttonOk, buttonCancel, 725 buttonOk, buttonCancel,
729 title, icon); 726 title, icon);
730 return infobar; 727 return infobar;
731 } 728 }
732 @CalledByNative 729 @CalledByNative
733 NativeInfoBar showAutoLoginInfoBar(int nativeInfoBar, 730 OnFrameAvailableListener showAutoLoginInfoBar(int nativeInfoBar,
734 String realm, String account, 731 String realm, String account, String args) {
735 String args) {
736 AutoLoginInfoBar infobar = new AutoLoginInfoBar(nativeInfoBar, mContext, 732 AutoLoginInfoBar infobar = new AutoLoginInfoBar(nativeInfoBar, mContext,
737 realm, account, args); 733 realm, account, args);
738 if (infobar.displayedAccountCount() == 0) 734 if (infobar.displayedAccountCount() == 0)
739 infobar = null; 735 infobar = null;
740 return infobar; 736 return infobar;
741 } 737 }
742 @CalledByNative("InfoBar") 738 @CalledByNative("InfoBar")
743 void dismiss(); 739 void dismiss();
744 @SuppressWarnings("unused") 740 @SuppressWarnings("unused")
745 @CalledByNative 741 @CalledByNative
746 private static boolean shouldShowAutoLogin(ContentViewCore contentView, 742 private static boolean shouldShowAutoLogin(View view,
747 String realm, String account, String args) { 743 String realm, String account, String args) {
748 AccountManagerContainer accountManagerContainer = 744 AccountManagerContainer accountManagerContainer =
749 new AccountManagerContainer((Activity)contentView.getContext(), 745 new AccountManagerContainer((Activity)contentView.getContext(),
750 realm, account, args); 746 realm, account, args);
751 String[] logins = accountManagerContainer.getAccountLogins(null); 747 String[] logins = accountManagerContainer.getAccountLogins(null);
752 return logins.length != 0; 748 return logins.length != 0;
753 } 749 }
754 @CalledByNative 750 @CalledByNative
755 static InputStream openUrl(String url) { 751 static InputStream openUrl(String url) {
756 return null; 752 return null;
757 } 753 }
758 @CalledByNative 754 @CalledByNative
759 private void activateHardwareAcceleration(final boolean activated, 755 private void activateHardwareAcceleration(final boolean activated,
760 final int iPid, final int iType, 756 final int iPid, final int iType,
761 final int iPrimaryID, final int iSecondaryID) { 757 final int iPrimaryID, final int iSecondaryID) {
762 if (!activated) { 758 if (!activated) {
763 return 759 return
764 } 760 }
765 } 761 }
766 @CalledByNativeUnchecked 762 @CalledByNativeUnchecked
767 private void uncheckedCall(int iParam); 763 private void uncheckedCall(int iParam);
768 """ 764 """
769 called_by_natives = jni_generator.ExtractCalledByNatives(test_data) 765 called_by_natives = jni_generator.ExtractCalledByNatives(test_data)
770 golden_called_by_natives = [ 766 golden_called_by_natives = [
771 CalledByNative( 767 CalledByNative(
772 return_type='NativeInfoBar', 768 return_type='OnFrameAvailableListener',
773 system_class=False, 769 system_class=False,
774 static=False, 770 static=False,
775 name='showConfirmInfoBar', 771 name='showConfirmInfoBar',
776 method_id_var_name='showConfirmInfoBar', 772 method_id_var_name='showConfirmInfoBar',
777 java_class_name='', 773 java_class_name='',
778 params=[Param(datatype='int', name='nativeInfoBar'), 774 params=[Param(datatype='int', name='nativeInfoBar'),
779 Param(datatype='String', name='buttonOk'), 775 Param(datatype='String', name='buttonOk'),
780 Param(datatype='String', name='buttonCancel'), 776 Param(datatype='String', name='buttonCancel'),
781 Param(datatype='String', name='title'), 777 Param(datatype='String', name='title'),
782 Param(datatype='Bitmap', name='icon')], 778 Param(datatype='Bitmap', name='icon')],
783 env_call=('Object', ''), 779 env_call=('Object', ''),
784 unchecked=False, 780 unchecked=False,
785 ), 781 ),
786 CalledByNative( 782 CalledByNative(
787 return_type='NativeInfoBar', 783 return_type='OnFrameAvailableListener',
788 system_class=False, 784 system_class=False,
789 static=False, 785 static=False,
790 name='showAutoLoginInfoBar', 786 name='showAutoLoginInfoBar',
791 method_id_var_name='showAutoLoginInfoBar', 787 method_id_var_name='showAutoLoginInfoBar',
792 java_class_name='', 788 java_class_name='',
793 params=[Param(datatype='int', name='nativeInfoBar'), 789 params=[Param(datatype='int', name='nativeInfoBar'),
794 Param(datatype='String', name='realm'), 790 Param(datatype='String', name='realm'),
795 Param(datatype='String', name='account'), 791 Param(datatype='String', name='account'),
796 Param(datatype='String', name='args')], 792 Param(datatype='String', name='args')],
797 env_call=('Object', ''), 793 env_call=('Object', ''),
(...skipping 10 matching lines...) Expand all
808 env_call=('Void', ''), 804 env_call=('Void', ''),
809 unchecked=False, 805 unchecked=False,
810 ), 806 ),
811 CalledByNative( 807 CalledByNative(
812 return_type='boolean', 808 return_type='boolean',
813 system_class=False, 809 system_class=False,
814 static=True, 810 static=True,
815 name='shouldShowAutoLogin', 811 name='shouldShowAutoLogin',
816 method_id_var_name='shouldShowAutoLogin', 812 method_id_var_name='shouldShowAutoLogin',
817 java_class_name='', 813 java_class_name='',
818 params=[Param(datatype='ContentViewCore', name='contentView'), 814 params=[Param(datatype='View', name='view'),
819 Param(datatype='String', name='realm'), 815 Param(datatype='String', name='realm'),
820 Param(datatype='String', name='account'), 816 Param(datatype='String', name='account'),
821 Param(datatype='String', name='args')], 817 Param(datatype='String', name='args')],
822 env_call=('Boolean', ''), 818 env_call=('Boolean', ''),
823 unchecked=False, 819 unchecked=False,
824 ), 820 ),
825 CalledByNative( 821 CalledByNative(
826 return_type='InputStream', 822 return_type='InputStream',
827 system_class=False, 823 system_class=False,
828 static=True, 824 static=True,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 env, g_TestJni_clazz, 909 env, g_TestJni_clazz,
914 "showConfirmInfoBar", 910 "showConfirmInfoBar",
915 911
916 "(" 912 "("
917 "I" 913 "I"
918 "Ljava/lang/String;" 914 "Ljava/lang/String;"
919 "Ljava/lang/String;" 915 "Ljava/lang/String;"
920 "Ljava/lang/String;" 916 "Ljava/lang/String;"
921 "Landroid/graphics/Bitmap;" 917 "Landroid/graphics/Bitmap;"
922 ")" 918 ")"
923 "Lcom/google/android/apps/chrome/infobar/InfoBarContainer$NativeInfoBar;", 919 "Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;",
924 &g_TestJni_showConfirmInfoBar); 920 &g_TestJni_showConfirmInfoBar);
925 921
926 jobject ret = 922 jobject ret =
927 env->CallObjectMethod(obj, 923 env->CallObjectMethod(obj,
928 method_id, nativeInfoBar, buttonOk, buttonCancel, title, icon); 924 method_id, nativeInfoBar, buttonOk, buttonCancel, title, icon);
929 base::android::CheckException(env); 925 base::android::CheckException(env);
930 return ScopedJavaLocalRef<jobject>(env, ret); 926 return ScopedJavaLocalRef<jobject>(env, ret);
931 } 927 }
932 928
933 static base::subtle::AtomicWord g_TestJni_showAutoLoginInfoBar = 0; 929 static base::subtle::AtomicWord g_TestJni_showAutoLoginInfoBar = 0;
934 static ScopedJavaLocalRef<jobject> Java_TestJni_showAutoLoginInfoBar(JNIEnv* 930 static ScopedJavaLocalRef<jobject> Java_TestJni_showAutoLoginInfoBar(JNIEnv*
935 env, jobject obj, jint nativeInfoBar, 931 env, jobject obj, jint nativeInfoBar,
936 jstring realm, 932 jstring realm,
937 jstring account, 933 jstring account,
938 jstring args) { 934 jstring args) {
939 /* Must call RegisterNativesImpl() */ 935 /* Must call RegisterNativesImpl() */
940 DCHECK(g_TestJni_clazz); 936 DCHECK(g_TestJni_clazz);
941 jmethodID method_id = 937 jmethodID method_id =
942 base::android::MethodID::LazyGet< 938 base::android::MethodID::LazyGet<
943 base::android::MethodID::TYPE_INSTANCE>( 939 base::android::MethodID::TYPE_INSTANCE>(
944 env, g_TestJni_clazz, 940 env, g_TestJni_clazz,
945 "showAutoLoginInfoBar", 941 "showAutoLoginInfoBar",
946 942
947 "(" 943 "("
948 "I" 944 "I"
949 "Ljava/lang/String;" 945 "Ljava/lang/String;"
950 "Ljava/lang/String;" 946 "Ljava/lang/String;"
951 "Ljava/lang/String;" 947 "Ljava/lang/String;"
952 ")" 948 ")"
953 "Lcom/google/android/apps/chrome/infobar/InfoBarContainer$NativeInfoBar;", 949 "Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;",
954 &g_TestJni_showAutoLoginInfoBar); 950 &g_TestJni_showAutoLoginInfoBar);
955 951
956 jobject ret = 952 jobject ret =
957 env->CallObjectMethod(obj, 953 env->CallObjectMethod(obj,
958 method_id, nativeInfoBar, realm, account, args); 954 method_id, nativeInfoBar, realm, account, args);
959 base::android::CheckException(env); 955 base::android::CheckException(env);
960 return ScopedJavaLocalRef<jobject>(env, ret); 956 return ScopedJavaLocalRef<jobject>(env, ret);
961 } 957 }
962 958
963 static base::subtle::AtomicWord g_InfoBar_dismiss = 0; 959 static base::subtle::AtomicWord g_InfoBar_dismiss = 0;
(...skipping 11 matching lines...) Expand all
975 "V", 971 "V",
976 &g_InfoBar_dismiss); 972 &g_InfoBar_dismiss);
977 973
978 env->CallVoidMethod(obj, 974 env->CallVoidMethod(obj,
979 method_id); 975 method_id);
980 base::android::CheckException(env); 976 base::android::CheckException(env);
981 977
982 } 978 }
983 979
984 static base::subtle::AtomicWord g_TestJni_shouldShowAutoLogin = 0; 980 static base::subtle::AtomicWord g_TestJni_shouldShowAutoLogin = 0;
985 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject 981 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject view,
986 contentView,
987 jstring realm, 982 jstring realm,
988 jstring account, 983 jstring account,
989 jstring args) { 984 jstring args) {
990 /* Must call RegisterNativesImpl() */ 985 /* Must call RegisterNativesImpl() */
991 DCHECK(g_TestJni_clazz); 986 DCHECK(g_TestJni_clazz);
992 jmethodID method_id = 987 jmethodID method_id =
993 base::android::MethodID::LazyGet< 988 base::android::MethodID::LazyGet<
994 base::android::MethodID::TYPE_STATIC>( 989 base::android::MethodID::TYPE_STATIC>(
995 env, g_TestJni_clazz, 990 env, g_TestJni_clazz,
996 "shouldShowAutoLogin", 991 "shouldShowAutoLogin",
997 992
998 "(" 993 "("
999 "Lorg/chromium/content/browser/ContentViewCore;" 994 "Landroid/view/View;"
1000 "Ljava/lang/String;" 995 "Ljava/lang/String;"
1001 "Ljava/lang/String;" 996 "Ljava/lang/String;"
1002 "Ljava/lang/String;" 997 "Ljava/lang/String;"
1003 ")" 998 ")"
1004 "Z", 999 "Z",
1005 &g_TestJni_shouldShowAutoLogin); 1000 &g_TestJni_shouldShowAutoLogin);
1006 1001
1007 jboolean ret = 1002 jboolean ret =
1008 env->CallStaticBooleanMethod(g_TestJni_clazz, 1003 env->CallStaticBooleanMethod(g_TestJni_clazz,
1009 method_id, contentView, realm, account, args); 1004 method_id, view, realm, account, args);
1010 base::android::CheckException(env); 1005 base::android::CheckException(env);
1011 return ret; 1006 return ret;
1012 } 1007 }
1013 1008
1014 static base::subtle::AtomicWord g_TestJni_openUrl = 0; 1009 static base::subtle::AtomicWord g_TestJni_openUrl = 0;
1015 static ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv* env, jstring 1010 static ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv* env, jstring
1016 url) { 1011 url) {
1017 /* Must call RegisterNativesImpl() */ 1012 /* Must call RegisterNativesImpl() */
1018 DCHECK(g_TestJni_clazz); 1013 DCHECK(g_TestJni_clazz);
1019 jmethodID method_id = 1014 jmethodID method_id =
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 """ 1520 """
1526 jni_from_java = jni_generator.JNIFromJavaSource( 1521 jni_from_java = jni_generator.JNIFromJavaSource(
1527 test_data, ('com/google/lookhowextremelylongiam/snarf/' 1522 test_data, ('com/google/lookhowextremelylongiam/snarf/'
1528 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) 1523 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage'))
1529 jni_lines = jni_from_java.GetContent().split('\n') 1524 jni_lines = jni_from_java.GetContent().split('\n')
1530 line = filter(lambda line: line.lstrip().startswith('#ifndef'), 1525 line = filter(lambda line: line.lstrip().startswith('#ifndef'),
1531 jni_lines)[0] 1526 jni_lines)[0]
1532 self.assertTrue(len(line) > 80, 1527 self.assertTrue(len(line) > 80,
1533 ('Expected #ifndef line to be > 80 chars: ', line)) 1528 ('Expected #ifndef line to be > 80 chars: ', line))
1534 1529
1530 def testExternalParamList(self):
1531 script_dir = os.path.dirname(sys.argv[0])
1532 external_param_list = [os.path.join(script_dir, 'class_list.jni')]
1533 jni_generator.JniParams.ReadExternalParamList(external_param_list)
1534 self.assertTrue('Lorg/chromium/base/SystemMessageHandler' in
1535 jni_generator.JniParams._external_param_list)
1536 self.assertRaises(AssertionError,
1537 jni_generator.JniParams.ReadExternalParamList,
1538 external_param_list)
1539
1535 if __name__ == '__main__': 1540 if __name__ == '__main__':
1536 unittest.main() 1541 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698