OLD | NEW |
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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 selectionArgs, sortOrder).Release(); | 308 selectionArgs, sortOrder).Release(); |
309 } | 309 } |
310 | 310 |
311 static void GotOrientation(JNIEnv* env, jobject obj, | 311 static void GotOrientation(JNIEnv* env, jobject obj, |
312 jint nativeDataFetcherImplAndroid, | 312 jint nativeDataFetcherImplAndroid, |
313 jdouble alpha, | 313 jdouble alpha, |
314 jdouble beta, | 314 jdouble beta, |
315 jdouble gamma) { | 315 jdouble gamma) { |
316 DCHECK(nativeDataFetcherImplAndroid) << "GotOrientation"; | 316 DCHECK(nativeDataFetcherImplAndroid) << "GotOrientation"; |
317 DataFetcherImplAndroid* native = | 317 DataFetcherImplAndroid* native = |
318 reinterpret_cast<DataFetcherImplAndroid*>(nativeDataFetcherImplAndroid); | 318 reinterpret_cast<DataFetcherImplAndroid*>(nativeDataFetcherImplAndroid); |
319 return native->GotOrientation(env, obj, alpha, beta, gamma); | 319 return native->GotOrientation(env, obj, alpha, beta, gamma); |
320 } | 320 } |
321 | 321 |
322 // Step 3: GetMethodIDs and RegisterNatives. | 322 // Step 3: RegisterNatives. |
323 static void GetMethodIDsImpl(JNIEnv* env) { | 323 |
| 324 static bool RegisterNativesImpl(JNIEnv* env) { |
| 325 |
324 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 326 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
325 base::android::GetUnscopedClass(env, kTestJniClassPath))); | 327 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
326 } | |
327 | |
328 static bool RegisterNativesImpl(JNIEnv* env) { | |
329 GetMethodIDsImpl(env); | |
330 | |
331 static const JNINativeMethod kMethodsTestJni[] = { | 328 static const JNINativeMethod kMethodsTestJni[] = { |
332 { "nativeInit", | 329 { "nativeInit", |
333 "(" | 330 "(" |
334 ")" | 331 ")" |
335 "I", reinterpret_cast<void*>(Init) }, | 332 "I", reinterpret_cast<void*>(Init) }, |
336 { "nativeDestroy", | 333 { "nativeDestroy", |
337 "(" | 334 "(" |
338 "I" | 335 "I" |
339 ")" | 336 ")" |
340 "V", reinterpret_cast<void*>(Destroy) }, | 337 "V", reinterpret_cast<void*>(Destroy) }, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 const char kTestJniClassPath[] = "org/chromium/TestJni"; | 471 const char kTestJniClassPath[] = "org/chromium/TestJni"; |
475 const char kMyInnerClassClassPath[] = "org/chromium/TestJni$MyInnerClass"; | 472 const char kMyInnerClassClassPath[] = "org/chromium/TestJni$MyInnerClass"; |
476 // Leaking this jclass as we cannot use LazyInstance from some threads. | 473 // Leaking this jclass as we cannot use LazyInstance from some threads. |
477 jclass g_TestJni_clazz = NULL; | 474 jclass g_TestJni_clazz = NULL; |
478 } // namespace | 475 } // namespace |
479 | 476 |
480 static jint Init(JNIEnv* env, jobject obj); | 477 static jint Init(JNIEnv* env, jobject obj); |
481 | 478 |
482 // Step 2: method stubs. | 479 // Step 2: method stubs. |
483 | 480 |
484 // Step 3: GetMethodIDs and RegisterNatives. | 481 // Step 3: RegisterNatives. |
485 static void GetMethodIDsImpl(JNIEnv* env) { | 482 |
| 483 static bool RegisterNativesImpl(JNIEnv* env) { |
| 484 |
486 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 485 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
487 base::android::GetUnscopedClass(env, kTestJniClassPath))); | 486 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
488 } | |
489 | |
490 static bool RegisterNativesImpl(JNIEnv* env) { | |
491 GetMethodIDsImpl(env); | |
492 | |
493 static const JNINativeMethod kMethodsMyInnerClass[] = { | 487 static const JNINativeMethod kMethodsMyInnerClass[] = { |
494 { "nativeInit", | 488 { "nativeInit", |
495 "(" | 489 "(" |
496 ")" | 490 ")" |
497 "I", reinterpret_cast<void*>(Init) }, | 491 "I", reinterpret_cast<void*>(Init) }, |
498 }; | 492 }; |
499 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); | 493 const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); |
500 | 494 |
501 if (env->RegisterNatives(g_MyInnerClass_clazz, | 495 if (env->RegisterNatives(g_MyInnerClass_clazz, |
502 kMethodsMyInnerClass, | 496 kMethodsMyInnerClass, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 // Leaking this jclass as we cannot use LazyInstance from some threads. | 562 // Leaking this jclass as we cannot use LazyInstance from some threads. |
569 jclass g_TestJni_clazz = NULL; | 563 jclass g_TestJni_clazz = NULL; |
570 } // namespace | 564 } // namespace |
571 | 565 |
572 static jint Init(JNIEnv* env, jobject obj); | 566 static jint Init(JNIEnv* env, jobject obj); |
573 | 567 |
574 static jint Init(JNIEnv* env, jobject obj); | 568 static jint Init(JNIEnv* env, jobject obj); |
575 | 569 |
576 // Step 2: method stubs. | 570 // Step 2: method stubs. |
577 | 571 |
578 // Step 3: GetMethodIDs and RegisterNatives. | 572 // Step 3: RegisterNatives. |
579 static void GetMethodIDsImpl(JNIEnv* env) { | 573 |
| 574 static bool RegisterNativesImpl(JNIEnv* env) { |
| 575 |
580 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 576 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
581 base::android::GetUnscopedClass(env, kTestJniClassPath))); | 577 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
582 } | |
583 | |
584 static bool RegisterNativesImpl(JNIEnv* env) { | |
585 GetMethodIDsImpl(env); | |
586 | |
587 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | 578 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
588 { "nativeInit", | 579 { "nativeInit", |
589 "(" | 580 "(" |
590 ")" | 581 ")" |
591 "I", reinterpret_cast<void*>(Init) }, | 582 "I", reinterpret_cast<void*>(Init) }, |
592 }; | 583 }; |
593 const int kMethodsMyOtherInnerClassSize = | 584 const int kMethodsMyOtherInnerClassSize = |
594 arraysize(kMethodsMyOtherInnerClass); | 585 arraysize(kMethodsMyOtherInnerClass); |
595 | 586 |
596 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, | 587 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 // Leaking this jclass as we cannot use LazyInstance from some threads. | 667 // Leaking this jclass as we cannot use LazyInstance from some threads. |
677 jclass g_TestJni_clazz = NULL; | 668 jclass g_TestJni_clazz = NULL; |
678 } // namespace | 669 } // namespace |
679 | 670 |
680 static jint Init(JNIEnv* env, jobject obj); | 671 static jint Init(JNIEnv* env, jobject obj); |
681 | 672 |
682 static jint Init(JNIEnv* env, jobject obj); | 673 static jint Init(JNIEnv* env, jobject obj); |
683 | 674 |
684 // Step 2: method stubs. | 675 // Step 2: method stubs. |
685 | 676 |
686 // Step 3: GetMethodIDs and RegisterNatives. | 677 // Step 3: RegisterNatives. |
687 static void GetMethodIDsImpl(JNIEnv* env) { | 678 |
| 679 static bool RegisterNativesImpl(JNIEnv* env) { |
| 680 |
688 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | 681 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
689 base::android::GetUnscopedClass(env, kTestJniClassPath))); | 682 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
690 } | |
691 | |
692 static bool RegisterNativesImpl(JNIEnv* env) { | |
693 GetMethodIDsImpl(env); | |
694 | |
695 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { | 683 static const JNINativeMethod kMethodsMyOtherInnerClass[] = { |
696 { "nativeInit", | 684 { "nativeInit", |
697 "(" | 685 "(" |
698 ")" | 686 ")" |
699 "I", reinterpret_cast<void*>(Init) }, | 687 "I", reinterpret_cast<void*>(Init) }, |
700 }; | 688 }; |
701 const int kMethodsMyOtherInnerClassSize = | 689 const int kMethodsMyOtherInnerClassSize = |
702 arraysize(kMethodsMyOtherInnerClass); | 690 arraysize(kMethodsMyOtherInnerClass); |
703 | 691 |
704 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, | 692 if (env->RegisterNatives(g_MyOtherInnerClass_clazz, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 const char kTestJniClassPath[] = "org/chromium/TestJni"; | 891 const char kTestJniClassPath[] = "org/chromium/TestJni"; |
904 const char kInfoBarClassPath[] = "org/chromium/TestJni$InfoBar"; | 892 const char kInfoBarClassPath[] = "org/chromium/TestJni$InfoBar"; |
905 // Leaking this jclass as we cannot use LazyInstance from some threads. | 893 // Leaking this jclass as we cannot use LazyInstance from some threads. |
906 jclass g_TestJni_clazz = NULL; | 894 jclass g_TestJni_clazz = NULL; |
907 // Leaking this jclass as we cannot use LazyInstance from some threads. | 895 // Leaking this jclass as we cannot use LazyInstance from some threads. |
908 jclass g_InfoBar_clazz = NULL; | 896 jclass g_InfoBar_clazz = NULL; |
909 } // namespace | 897 } // namespace |
910 | 898 |
911 // Step 2: method stubs. | 899 // Step 2: method stubs. |
912 | 900 |
913 static jmethodID g_TestJni_showConfirmInfoBar = 0; | 901 static base::subtle::AtomicWord g_TestJni_showConfirmInfoBar = 0; |
914 static ScopedJavaLocalRef<jobject> Java_TestJni_showConfirmInfoBar(JNIEnv* env, | 902 static ScopedJavaLocalRef<jobject> Java_TestJni_showConfirmInfoBar(JNIEnv* env, |
915 jobject obj, jint nativeInfoBar, | 903 jobject obj, jint nativeInfoBar, |
916 jstring buttonOk, | 904 jstring buttonOk, |
917 jstring buttonCancel, | 905 jstring buttonCancel, |
918 jstring title, | 906 jstring title, |
919 jobject icon) { | 907 jobject icon) { |
920 /* Must call RegisterNativesImpl() */ | 908 /* Must call RegisterNativesImpl() */ |
921 DCHECK(g_TestJni_clazz); | 909 DCHECK(g_TestJni_clazz); |
922 DCHECK(g_TestJni_showConfirmInfoBar); | 910 jmethodID method_id = |
| 911 |
| 912 base::android::MethodID::LazyGet< |
| 913 base::android::MethodID::METHODTYPE_NORMAL, |
| 914 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 915 env, g_TestJni_clazz, |
| 916 "showConfirmInfoBar", |
| 917 |
| 918 "(" |
| 919 "I" |
| 920 "Ljava/lang/String;" |
| 921 "Ljava/lang/String;" |
| 922 "Ljava/lang/String;" |
| 923 "Landroid/graphics/Bitmap;" |
| 924 ")" |
| 925 "Lcom/google/android/apps/chrome/infobar/InfoBarContainer$NativeInfoBar;", |
| 926 &g_TestJni_showConfirmInfoBar); |
| 927 |
923 jobject ret = | 928 jobject ret = |
924 env->CallObjectMethod(obj, | 929 env->CallObjectMethod(obj, |
925 g_TestJni_showConfirmInfoBar, nativeInfoBar, buttonOk, buttonCancel, | 930 method_id, nativeInfoBar, buttonOk, buttonCancel, title, icon); |
926 title, icon); | |
927 base::android::CheckException(env); | 931 base::android::CheckException(env); |
928 return ScopedJavaLocalRef<jobject>(env, ret); | 932 return ScopedJavaLocalRef<jobject>(env, ret); |
929 } | 933 } |
930 | 934 |
931 static jmethodID g_TestJni_showAutoLoginInfoBar = 0; | 935 static base::subtle::AtomicWord g_TestJni_showAutoLoginInfoBar = 0; |
932 static ScopedJavaLocalRef<jobject> Java_TestJni_showAutoLoginInfoBar(JNIEnv* | 936 static ScopedJavaLocalRef<jobject> Java_TestJni_showAutoLoginInfoBar(JNIEnv* |
933 env, jobject obj, jint nativeInfoBar, | 937 env, jobject obj, jint nativeInfoBar, |
934 jstring realm, | 938 jstring realm, |
935 jstring account, | 939 jstring account, |
936 jstring args) { | 940 jstring args) { |
937 /* Must call RegisterNativesImpl() */ | 941 /* Must call RegisterNativesImpl() */ |
938 DCHECK(g_TestJni_clazz); | 942 DCHECK(g_TestJni_clazz); |
939 DCHECK(g_TestJni_showAutoLoginInfoBar); | 943 jmethodID method_id = |
| 944 |
| 945 base::android::MethodID::LazyGet< |
| 946 base::android::MethodID::METHODTYPE_NORMAL, |
| 947 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 948 env, g_TestJni_clazz, |
| 949 "showAutoLoginInfoBar", |
| 950 |
| 951 "(" |
| 952 "I" |
| 953 "Ljava/lang/String;" |
| 954 "Ljava/lang/String;" |
| 955 "Ljava/lang/String;" |
| 956 ")" |
| 957 "Lcom/google/android/apps/chrome/infobar/InfoBarContainer$NativeInfoBar;", |
| 958 &g_TestJni_showAutoLoginInfoBar); |
| 959 |
940 jobject ret = | 960 jobject ret = |
941 env->CallObjectMethod(obj, | 961 env->CallObjectMethod(obj, |
942 g_TestJni_showAutoLoginInfoBar, nativeInfoBar, realm, account, args); | 962 method_id, nativeInfoBar, realm, account, args); |
943 base::android::CheckException(env); | 963 base::android::CheckException(env); |
944 return ScopedJavaLocalRef<jobject>(env, ret); | 964 return ScopedJavaLocalRef<jobject>(env, ret); |
945 } | 965 } |
946 | 966 |
947 static jmethodID g_InfoBar_dismiss = 0; | 967 static base::subtle::AtomicWord g_InfoBar_dismiss = 0; |
948 static void Java_InfoBar_dismiss(JNIEnv* env, jobject obj) { | 968 static void Java_InfoBar_dismiss(JNIEnv* env, jobject obj) { |
949 /* Must call RegisterNativesImpl() */ | 969 /* Must call RegisterNativesImpl() */ |
950 DCHECK(g_InfoBar_clazz); | 970 DCHECK(g_InfoBar_clazz); |
951 DCHECK(g_InfoBar_dismiss); | 971 jmethodID method_id = |
| 972 |
| 973 base::android::MethodID::LazyGet< |
| 974 base::android::MethodID::METHODTYPE_NORMAL, |
| 975 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 976 env, g_InfoBar_clazz, |
| 977 "dismiss", |
| 978 |
| 979 "(" |
| 980 ")" |
| 981 "V", |
| 982 &g_InfoBar_dismiss); |
952 | 983 |
953 env->CallVoidMethod(obj, | 984 env->CallVoidMethod(obj, |
954 g_InfoBar_dismiss); | 985 method_id); |
955 base::android::CheckException(env); | 986 base::android::CheckException(env); |
956 | 987 |
957 } | 988 } |
958 | 989 |
959 static jmethodID g_TestJni_shouldShowAutoLogin = 0; | 990 static base::subtle::AtomicWord g_TestJni_shouldShowAutoLogin = 0; |
960 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject | 991 static jboolean Java_TestJni_shouldShowAutoLogin(JNIEnv* env, jobject |
961 contentView, | 992 contentView, |
962 jstring realm, | 993 jstring realm, |
963 jstring account, | 994 jstring account, |
964 jstring args) { | 995 jstring args) { |
965 /* Must call RegisterNativesImpl() */ | 996 /* Must call RegisterNativesImpl() */ |
966 DCHECK(g_TestJni_clazz); | 997 DCHECK(g_TestJni_clazz); |
967 DCHECK(g_TestJni_shouldShowAutoLogin); | 998 jmethodID method_id = |
| 999 |
| 1000 base::android::MethodID::LazyGet< |
| 1001 base::android::MethodID::METHODTYPE_STATIC, |
| 1002 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 1003 env, g_TestJni_clazz, |
| 1004 "shouldShowAutoLogin", |
| 1005 |
| 1006 "(" |
| 1007 "Lorg/chromium/content/browser/ContentViewCore;" |
| 1008 "Ljava/lang/String;" |
| 1009 "Ljava/lang/String;" |
| 1010 "Ljava/lang/String;" |
| 1011 ")" |
| 1012 "Z", |
| 1013 &g_TestJni_shouldShowAutoLogin); |
| 1014 |
968 jboolean ret = | 1015 jboolean ret = |
969 env->CallStaticBooleanMethod(g_TestJni_clazz, | 1016 env->CallStaticBooleanMethod(g_TestJni_clazz, |
970 g_TestJni_shouldShowAutoLogin, contentView, realm, account, args); | 1017 method_id, contentView, realm, account, args); |
971 base::android::CheckException(env); | 1018 base::android::CheckException(env); |
972 return ret; | 1019 return ret; |
973 } | 1020 } |
974 | 1021 |
975 static jmethodID g_TestJni_openUrl = 0; | 1022 static base::subtle::AtomicWord g_TestJni_openUrl = 0; |
976 static ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv* env, jstring | 1023 static ScopedJavaLocalRef<jobject> Java_TestJni_openUrl(JNIEnv* env, jstring |
977 url) { | 1024 url) { |
978 /* Must call RegisterNativesImpl() */ | 1025 /* Must call RegisterNativesImpl() */ |
979 DCHECK(g_TestJni_clazz); | 1026 DCHECK(g_TestJni_clazz); |
980 DCHECK(g_TestJni_openUrl); | 1027 jmethodID method_id = |
| 1028 |
| 1029 base::android::MethodID::LazyGet< |
| 1030 base::android::MethodID::METHODTYPE_STATIC, |
| 1031 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 1032 env, g_TestJni_clazz, |
| 1033 "openUrl", |
| 1034 |
| 1035 "(" |
| 1036 "Ljava/lang/String;" |
| 1037 ")" |
| 1038 "Ljava/io/InputStream;", |
| 1039 &g_TestJni_openUrl); |
| 1040 |
981 jobject ret = | 1041 jobject ret = |
982 env->CallStaticObjectMethod(g_TestJni_clazz, | 1042 env->CallStaticObjectMethod(g_TestJni_clazz, |
983 g_TestJni_openUrl, url); | 1043 method_id, url); |
984 base::android::CheckException(env); | 1044 base::android::CheckException(env); |
985 return ScopedJavaLocalRef<jobject>(env, ret); | 1045 return ScopedJavaLocalRef<jobject>(env, ret); |
986 } | 1046 } |
987 | 1047 |
988 static jmethodID g_TestJni_activateHardwareAcceleration = 0; | 1048 static base::subtle::AtomicWord g_TestJni_activateHardwareAcceleration = 0; |
989 static void Java_TestJni_activateHardwareAcceleration(JNIEnv* env, jobject obj, | 1049 static void Java_TestJni_activateHardwareAcceleration(JNIEnv* env, jobject obj, |
990 jboolean activated, | 1050 jboolean activated, |
991 jint iPid, | 1051 jint iPid, |
992 jint iType, | 1052 jint iType, |
993 jint iPrimaryID, | 1053 jint iPrimaryID, |
994 jint iSecondaryID) { | 1054 jint iSecondaryID) { |
995 /* Must call RegisterNativesImpl() */ | 1055 /* Must call RegisterNativesImpl() */ |
996 DCHECK(g_TestJni_clazz); | 1056 DCHECK(g_TestJni_clazz); |
997 DCHECK(g_TestJni_activateHardwareAcceleration); | 1057 jmethodID method_id = |
998 | 1058 |
999 env->CallVoidMethod(obj, | 1059 base::android::MethodID::LazyGet< |
1000 g_TestJni_activateHardwareAcceleration, activated, iPid, iType, | 1060 base::android::MethodID::METHODTYPE_NORMAL, |
1001 iPrimaryID, iSecondaryID); | 1061 base::android::MethodID::EXCEPTIONCHECK_YES>( |
1002 base::android::CheckException(env); | 1062 env, g_TestJni_clazz, |
1003 | 1063 "activateHardwareAcceleration", |
1004 } | |
1005 | |
1006 static jmethodID g_TestJni_uncheckedCall = 0; | |
1007 static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, jint iParam) { | |
1008 /* Must call RegisterNativesImpl() */ | |
1009 DCHECK(g_TestJni_clazz); | |
1010 DCHECK(g_TestJni_uncheckedCall); | |
1011 | |
1012 env->CallVoidMethod(obj, | |
1013 g_TestJni_uncheckedCall, iParam); | |
1014 | |
1015 } | |
1016 | |
1017 // Step 3: GetMethodIDs and RegisterNatives. | |
1018 static void GetMethodIDsImpl(JNIEnv* env) { | |
1019 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
1020 base::android::GetUnscopedClass(env, kTestJniClassPath))); | |
1021 g_InfoBar_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
1022 base::android::GetUnscopedClass(env, kInfoBarClassPath))); | |
1023 g_TestJni_showConfirmInfoBar = | |
1024 base::android::GetMethodID( | |
1025 env, g_TestJni_clazz, | |
1026 "showConfirmInfoBar", | |
1027 | |
1028 "(" | |
1029 "I" | |
1030 "Ljava/lang/String;" | |
1031 "Ljava/lang/String;" | |
1032 "Ljava/lang/String;" | |
1033 "Landroid/graphics/Bitmap;" | |
1034 ")" | |
1035 "Lcom/google/android/apps/chrome/infobar/InfoBarContainer$NativeInfoBar;"); | |
1036 | |
1037 g_TestJni_showAutoLoginInfoBar = | |
1038 base::android::GetMethodID( | |
1039 env, g_TestJni_clazz, | |
1040 "showAutoLoginInfoBar", | |
1041 | |
1042 "(" | |
1043 "I" | |
1044 "Ljava/lang/String;" | |
1045 "Ljava/lang/String;" | |
1046 "Ljava/lang/String;" | |
1047 ")" | |
1048 "Lcom/google/android/apps/chrome/infobar/InfoBarContainer$NativeInfoBar;"); | |
1049 | |
1050 g_InfoBar_dismiss = | |
1051 base::android::GetMethodID( | |
1052 env, g_InfoBar_clazz, | |
1053 "dismiss", | |
1054 | |
1055 "(" | |
1056 ")" | |
1057 "V"); | |
1058 | |
1059 g_TestJni_shouldShowAutoLogin = | |
1060 base::android::GetStaticMethodID( | |
1061 env, g_TestJni_clazz, | |
1062 "shouldShowAutoLogin", | |
1063 | |
1064 "(" | |
1065 "Lorg/chromium/content/browser/ContentViewCore;" | |
1066 "Ljava/lang/String;" | |
1067 "Ljava/lang/String;" | |
1068 "Ljava/lang/String;" | |
1069 ")" | |
1070 "Z"); | |
1071 | |
1072 g_TestJni_openUrl = | |
1073 base::android::GetStaticMethodID( | |
1074 env, g_TestJni_clazz, | |
1075 "openUrl", | |
1076 | |
1077 "(" | |
1078 "Ljava/lang/String;" | |
1079 ")" | |
1080 "Ljava/io/InputStream;"); | |
1081 | |
1082 g_TestJni_activateHardwareAcceleration = | |
1083 base::android::GetMethodID( | |
1084 env, g_TestJni_clazz, | |
1085 "activateHardwareAcceleration", | |
1086 | 1064 |
1087 "(" | 1065 "(" |
1088 "Z" | 1066 "Z" |
1089 "I" | 1067 "I" |
1090 "I" | 1068 "I" |
1091 "I" | 1069 "I" |
1092 "I" | 1070 "I" |
1093 ")" | 1071 ")" |
1094 "V"); | 1072 "V", |
| 1073 &g_TestJni_activateHardwareAcceleration); |
1095 | 1074 |
1096 g_TestJni_uncheckedCall = | 1075 env->CallVoidMethod(obj, |
1097 base::android::GetMethodID( | 1076 method_id, activated, iPid, iType, iPrimaryID, iSecondaryID); |
1098 env, g_TestJni_clazz, | 1077 base::android::CheckException(env); |
1099 "uncheckedCall", | 1078 |
| 1079 } |
| 1080 |
| 1081 static base::subtle::AtomicWord g_TestJni_uncheckedCall = 0; |
| 1082 static void Java_TestJni_uncheckedCall(JNIEnv* env, jobject obj, jint iParam) { |
| 1083 /* Must call RegisterNativesImpl() */ |
| 1084 DCHECK(g_TestJni_clazz); |
| 1085 jmethodID method_id = |
| 1086 |
| 1087 base::android::MethodID::LazyGet< |
| 1088 base::android::MethodID::METHODTYPE_NORMAL, |
| 1089 base::android::MethodID::EXCEPTIONCHECK_YES>( |
| 1090 env, g_TestJni_clazz, |
| 1091 "uncheckedCall", |
1100 | 1092 |
1101 "(" | 1093 "(" |
1102 "I" | 1094 "I" |
1103 ")" | 1095 ")" |
1104 "V"); | 1096 "V", |
| 1097 &g_TestJni_uncheckedCall); |
| 1098 |
| 1099 env->CallVoidMethod(obj, |
| 1100 method_id, iParam); |
1105 | 1101 |
1106 } | 1102 } |
1107 | 1103 |
| 1104 // Step 3: RegisterNatives. |
| 1105 |
1108 static bool RegisterNativesImpl(JNIEnv* env) { | 1106 static bool RegisterNativesImpl(JNIEnv* env) { |
1109 GetMethodIDsImpl(env); | |
1110 | 1107 |
| 1108 g_TestJni_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 1109 base::android::GetUnscopedClass(env, kTestJniClassPath))); |
| 1110 g_InfoBar_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 1111 base::android::GetUnscopedClass(env, kInfoBarClassPath))); |
1111 return true; | 1112 return true; |
1112 } | 1113 } |
1113 | 1114 |
1114 #endif // org_chromium_TestJni_JNI | 1115 #endif // org_chromium_TestJni_JNI |
1115 """ | 1116 """ |
1116 self.assertTextEquals(golden_content, h.GetContent()) | 1117 self.assertTextEquals(golden_content, h.GetContent()) |
1117 | 1118 |
1118 def testCalledByNativeParseError(self): | 1119 def testCalledByNativeParseError(self): |
1119 try: | 1120 try: |
1120 jni_generator.ExtractCalledByNatives(""" | 1121 jni_generator.ExtractCalledByNatives(""" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 namespace { | 1211 namespace { |
1211 const char kInputStreamClassPath[] = "java/io/InputStream"; | 1212 const char kInputStreamClassPath[] = "java/io/InputStream"; |
1212 // Leaking this jclass as we cannot use LazyInstance from some threads. | 1213 // Leaking this jclass as we cannot use LazyInstance from some threads. |
1213 jclass g_InputStream_clazz = NULL; | 1214 jclass g_InputStream_clazz = NULL; |
1214 } // namespace | 1215 } // namespace |
1215 | 1216 |
1216 namespace JNI_InputStream { | 1217 namespace JNI_InputStream { |
1217 | 1218 |
1218 // Step 2: method stubs. | 1219 // Step 2: method stubs. |
1219 | 1220 |
1220 static jmethodID g_InputStream_available = 0; | 1221 static base::subtle::AtomicWord g_InputStream_available = 0; |
1221 static jint Java_InputStream_available(JNIEnv* env, jobject obj) __attribute__ | 1222 static jint Java_InputStream_available(JNIEnv* env, jobject obj) __attribute__ |
1222 ((unused)); | 1223 ((unused)); |
1223 static jint Java_InputStream_available(JNIEnv* env, jobject obj) { | 1224 static jint Java_InputStream_available(JNIEnv* env, jobject obj) { |
1224 /* Must call RegisterNativesImpl() */ | 1225 /* Must call RegisterNativesImpl() */ |
1225 DCHECK(g_InputStream_clazz); | 1226 DCHECK(g_InputStream_clazz); |
1226 DCHECK(g_InputStream_available); | 1227 jmethodID method_id = |
| 1228 |
| 1229 base::android::MethodID::LazyGet< |
| 1230 base::android::MethodID::METHODTYPE_NORMAL, |
| 1231 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1232 env, g_InputStream_clazz, |
| 1233 "available", |
| 1234 |
| 1235 "(" |
| 1236 ")" |
| 1237 "I", |
| 1238 &g_InputStream_available); |
| 1239 |
1227 jint ret = | 1240 jint ret = |
1228 env->CallIntMethod(obj, | 1241 env->CallIntMethod(obj, |
1229 g_InputStream_available); | 1242 method_id); |
1230 base::android::CheckException(env); | 1243 base::android::CheckException(env); |
1231 return ret; | 1244 return ret; |
1232 } | 1245 } |
1233 | 1246 |
1234 static jmethodID g_InputStream_close = 0; | 1247 static base::subtle::AtomicWord g_InputStream_close = 0; |
1235 static void Java_InputStream_close(JNIEnv* env, jobject obj) __attribute__ | 1248 static void Java_InputStream_close(JNIEnv* env, jobject obj) __attribute__ |
1236 ((unused)); | 1249 ((unused)); |
1237 static void Java_InputStream_close(JNIEnv* env, jobject obj) { | 1250 static void Java_InputStream_close(JNIEnv* env, jobject obj) { |
1238 /* Must call RegisterNativesImpl() */ | 1251 /* Must call RegisterNativesImpl() */ |
1239 DCHECK(g_InputStream_clazz); | 1252 DCHECK(g_InputStream_clazz); |
1240 DCHECK(g_InputStream_close); | 1253 jmethodID method_id = |
| 1254 |
| 1255 base::android::MethodID::LazyGet< |
| 1256 base::android::MethodID::METHODTYPE_NORMAL, |
| 1257 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1258 env, g_InputStream_clazz, |
| 1259 "close", |
| 1260 |
| 1261 "(" |
| 1262 ")" |
| 1263 "V", |
| 1264 &g_InputStream_close); |
1241 | 1265 |
1242 env->CallVoidMethod(obj, | 1266 env->CallVoidMethod(obj, |
1243 g_InputStream_close); | 1267 method_id); |
1244 base::android::CheckException(env); | 1268 base::android::CheckException(env); |
1245 | 1269 |
1246 } | 1270 } |
1247 | 1271 |
1248 static jmethodID g_InputStream_mark = 0; | 1272 static base::subtle::AtomicWord g_InputStream_mark = 0; |
1249 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) | 1273 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) |
1250 __attribute__ ((unused)); | 1274 __attribute__ ((unused)); |
1251 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) { | 1275 static void Java_InputStream_mark(JNIEnv* env, jobject obj, jint p0) { |
1252 /* Must call RegisterNativesImpl() */ | 1276 /* Must call RegisterNativesImpl() */ |
1253 DCHECK(g_InputStream_clazz); | 1277 DCHECK(g_InputStream_clazz); |
1254 DCHECK(g_InputStream_mark); | 1278 jmethodID method_id = |
| 1279 |
| 1280 base::android::MethodID::LazyGet< |
| 1281 base::android::MethodID::METHODTYPE_NORMAL, |
| 1282 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1283 env, g_InputStream_clazz, |
| 1284 "mark", |
| 1285 |
| 1286 "(" |
| 1287 "I" |
| 1288 ")" |
| 1289 "V", |
| 1290 &g_InputStream_mark); |
1255 | 1291 |
1256 env->CallVoidMethod(obj, | 1292 env->CallVoidMethod(obj, |
1257 g_InputStream_mark, p0); | 1293 method_id, p0); |
1258 base::android::CheckException(env); | 1294 base::android::CheckException(env); |
1259 | 1295 |
1260 } | 1296 } |
1261 | 1297 |
1262 static jmethodID g_InputStream_markSupported = 0; | 1298 static base::subtle::AtomicWord g_InputStream_markSupported = 0; |
1263 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) | 1299 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) |
1264 __attribute__ ((unused)); | 1300 __attribute__ ((unused)); |
1265 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) { | 1301 static jboolean Java_InputStream_markSupported(JNIEnv* env, jobject obj) { |
1266 /* Must call RegisterNativesImpl() */ | 1302 /* Must call RegisterNativesImpl() */ |
1267 DCHECK(g_InputStream_clazz); | 1303 DCHECK(g_InputStream_clazz); |
1268 DCHECK(g_InputStream_markSupported); | 1304 jmethodID method_id = |
| 1305 |
| 1306 base::android::MethodID::LazyGet< |
| 1307 base::android::MethodID::METHODTYPE_NORMAL, |
| 1308 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1309 env, g_InputStream_clazz, |
| 1310 "markSupported", |
| 1311 |
| 1312 "(" |
| 1313 ")" |
| 1314 "Z", |
| 1315 &g_InputStream_markSupported); |
| 1316 |
1269 jboolean ret = | 1317 jboolean ret = |
1270 env->CallBooleanMethod(obj, | 1318 env->CallBooleanMethod(obj, |
1271 g_InputStream_markSupported); | 1319 method_id); |
1272 base::android::CheckException(env); | 1320 base::android::CheckException(env); |
1273 return ret; | 1321 return ret; |
1274 } | 1322 } |
1275 | 1323 |
1276 static jmethodID g_InputStream_readI = 0; | 1324 static base::subtle::AtomicWord g_InputStream_readI = 0; |
1277 static jint Java_InputStream_readI(JNIEnv* env, jobject obj) __attribute__ | 1325 static jint Java_InputStream_readI(JNIEnv* env, jobject obj) __attribute__ |
1278 ((unused)); | 1326 ((unused)); |
1279 static jint Java_InputStream_readI(JNIEnv* env, jobject obj) { | 1327 static jint Java_InputStream_readI(JNIEnv* env, jobject obj) { |
1280 /* Must call RegisterNativesImpl() */ | 1328 /* Must call RegisterNativesImpl() */ |
1281 DCHECK(g_InputStream_clazz); | 1329 DCHECK(g_InputStream_clazz); |
1282 DCHECK(g_InputStream_readI); | 1330 jmethodID method_id = |
| 1331 |
| 1332 base::android::MethodID::LazyGet< |
| 1333 base::android::MethodID::METHODTYPE_NORMAL, |
| 1334 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1335 env, g_InputStream_clazz, |
| 1336 "read", |
| 1337 |
| 1338 "(" |
| 1339 ")" |
| 1340 "I", |
| 1341 &g_InputStream_readI); |
| 1342 |
1283 jint ret = | 1343 jint ret = |
1284 env->CallIntMethod(obj, | 1344 env->CallIntMethod(obj, |
1285 g_InputStream_readI); | 1345 method_id); |
1286 base::android::CheckException(env); | 1346 base::android::CheckException(env); |
1287 return ret; | 1347 return ret; |
1288 } | 1348 } |
1289 | 1349 |
1290 static jmethodID g_InputStream_readI_AB = 0; | 1350 static base::subtle::AtomicWord g_InputStream_readI_AB = 0; |
1291 static jint Java_InputStream_readI_AB(JNIEnv* env, jobject obj, jbyteArray p0) | 1351 static jint Java_InputStream_readI_AB(JNIEnv* env, jobject obj, jbyteArray p0) |
1292 __attribute__ ((unused)); | 1352 __attribute__ ((unused)); |
1293 static jint Java_InputStream_readI_AB(JNIEnv* env, jobject obj, jbyteArray p0) { | 1353 static jint Java_InputStream_readI_AB(JNIEnv* env, jobject obj, jbyteArray p0) { |
1294 /* Must call RegisterNativesImpl() */ | 1354 /* Must call RegisterNativesImpl() */ |
1295 DCHECK(g_InputStream_clazz); | 1355 DCHECK(g_InputStream_clazz); |
1296 DCHECK(g_InputStream_readI_AB); | 1356 jmethodID method_id = |
| 1357 |
| 1358 base::android::MethodID::LazyGet< |
| 1359 base::android::MethodID::METHODTYPE_NORMAL, |
| 1360 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1361 env, g_InputStream_clazz, |
| 1362 "read", |
| 1363 |
| 1364 "(" |
| 1365 "[B" |
| 1366 ")" |
| 1367 "I", |
| 1368 &g_InputStream_readI_AB); |
| 1369 |
1297 jint ret = | 1370 jint ret = |
1298 env->CallIntMethod(obj, | 1371 env->CallIntMethod(obj, |
1299 g_InputStream_readI_AB, p0); | 1372 method_id, p0); |
1300 base::android::CheckException(env); | 1373 base::android::CheckException(env); |
1301 return ret; | 1374 return ret; |
1302 } | 1375 } |
1303 | 1376 |
1304 static jmethodID g_InputStream_readI_AB_I_I = 0; | 1377 static base::subtle::AtomicWord g_InputStream_readI_AB_I_I = 0; |
1305 static jint Java_InputStream_readI_AB_I_I(JNIEnv* env, jobject obj, jbyteArray | 1378 static jint Java_InputStream_readI_AB_I_I(JNIEnv* env, jobject obj, jbyteArray |
1306 p0, | 1379 p0, |
1307 jint p1, | 1380 jint p1, |
1308 jint p2) __attribute__ ((unused)); | 1381 jint p2) __attribute__ ((unused)); |
1309 static jint Java_InputStream_readI_AB_I_I(JNIEnv* env, jobject obj, jbyteArray | 1382 static jint Java_InputStream_readI_AB_I_I(JNIEnv* env, jobject obj, jbyteArray |
1310 p0, | 1383 p0, |
1311 jint p1, | 1384 jint p1, |
1312 jint p2) { | 1385 jint p2) { |
1313 /* Must call RegisterNativesImpl() */ | 1386 /* Must call RegisterNativesImpl() */ |
1314 DCHECK(g_InputStream_clazz); | 1387 DCHECK(g_InputStream_clazz); |
1315 DCHECK(g_InputStream_readI_AB_I_I); | 1388 jmethodID method_id = |
1316 jint ret = | |
1317 env->CallIntMethod(obj, | |
1318 g_InputStream_readI_AB_I_I, p0, p1, p2); | |
1319 base::android::CheckException(env); | |
1320 return ret; | |
1321 } | |
1322 | 1389 |
1323 static jmethodID g_InputStream_reset = 0; | 1390 base::android::MethodID::LazyGet< |
1324 static void Java_InputStream_reset(JNIEnv* env, jobject obj) __attribute__ | 1391 base::android::MethodID::METHODTYPE_NORMAL, |
1325 ((unused)); | 1392 base::android::MethodID::EXCEPTIONCHECK_NO>( |
1326 static void Java_InputStream_reset(JNIEnv* env, jobject obj) { | 1393 env, g_InputStream_clazz, |
1327 /* Must call RegisterNativesImpl() */ | 1394 "read", |
1328 DCHECK(g_InputStream_clazz); | |
1329 DCHECK(g_InputStream_reset); | |
1330 | |
1331 env->CallVoidMethod(obj, | |
1332 g_InputStream_reset); | |
1333 base::android::CheckException(env); | |
1334 | |
1335 } | |
1336 | |
1337 static jmethodID g_InputStream_skip = 0; | |
1338 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) | |
1339 __attribute__ ((unused)); | |
1340 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) { | |
1341 /* Must call RegisterNativesImpl() */ | |
1342 DCHECK(g_InputStream_clazz); | |
1343 DCHECK(g_InputStream_skip); | |
1344 jlong ret = | |
1345 env->CallLongMethod(obj, | |
1346 g_InputStream_skip, p0); | |
1347 base::android::CheckException(env); | |
1348 return ret; | |
1349 } | |
1350 | |
1351 static jmethodID g_InputStream_Constructor = 0; | |
1352 static ScopedJavaLocalRef<jobject> Java_InputStream_Constructor(JNIEnv* env) | |
1353 __attribute__ ((unused)); | |
1354 static ScopedJavaLocalRef<jobject> Java_InputStream_Constructor(JNIEnv* env) { | |
1355 /* Must call RegisterNativesImpl() */ | |
1356 DCHECK(g_InputStream_clazz); | |
1357 DCHECK(g_InputStream_Constructor); | |
1358 jobject ret = | |
1359 env->NewObject(g_InputStream_clazz, | |
1360 g_InputStream_Constructor); | |
1361 base::android::CheckException(env); | |
1362 return ScopedJavaLocalRef<jobject>(env, ret); | |
1363 } | |
1364 | |
1365 // Step 3: GetMethodIDs and RegisterNatives. | |
1366 static void GetMethodIDsImpl(JNIEnv* env) { | |
1367 g_InputStream_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( | |
1368 base::android::GetUnscopedClass(env, kInputStreamClassPath))); | |
1369 g_InputStream_available = | |
1370 base::android::GetMethodIDOrNull( | |
1371 env, g_InputStream_clazz, | |
1372 "available", | |
1373 | |
1374 "(" | |
1375 ")" | |
1376 "I"); | |
1377 | |
1378 g_InputStream_close = | |
1379 base::android::GetMethodIDOrNull( | |
1380 env, g_InputStream_clazz, | |
1381 "close", | |
1382 | |
1383 "(" | |
1384 ")" | |
1385 "V"); | |
1386 | |
1387 g_InputStream_mark = | |
1388 base::android::GetMethodIDOrNull( | |
1389 env, g_InputStream_clazz, | |
1390 "mark", | |
1391 | |
1392 "(" | |
1393 "I" | |
1394 ")" | |
1395 "V"); | |
1396 | |
1397 g_InputStream_markSupported = | |
1398 base::android::GetMethodIDOrNull( | |
1399 env, g_InputStream_clazz, | |
1400 "markSupported", | |
1401 | |
1402 "(" | |
1403 ")" | |
1404 "Z"); | |
1405 | |
1406 g_InputStream_readI = | |
1407 base::android::GetMethodIDOrNull( | |
1408 env, g_InputStream_clazz, | |
1409 "read", | |
1410 | |
1411 "(" | |
1412 ")" | |
1413 "I"); | |
1414 | |
1415 g_InputStream_readI_AB = | |
1416 base::android::GetMethodIDOrNull( | |
1417 env, g_InputStream_clazz, | |
1418 "read", | |
1419 | |
1420 "(" | |
1421 "[B" | |
1422 ")" | |
1423 "I"); | |
1424 | |
1425 g_InputStream_readI_AB_I_I = | |
1426 base::android::GetMethodIDOrNull( | |
1427 env, g_InputStream_clazz, | |
1428 "read", | |
1429 | 1395 |
1430 "(" | 1396 "(" |
1431 "[B" | 1397 "[B" |
1432 "I" | 1398 "I" |
1433 "I" | 1399 "I" |
1434 ")" | 1400 ")" |
1435 "I"); | 1401 "I", |
| 1402 &g_InputStream_readI_AB_I_I); |
1436 | 1403 |
1437 g_InputStream_reset = | 1404 jint ret = |
1438 base::android::GetMethodIDOrNull( | 1405 env->CallIntMethod(obj, |
1439 env, g_InputStream_clazz, | 1406 method_id, p0, p1, p2); |
1440 "reset", | 1407 base::android::CheckException(env); |
| 1408 return ret; |
| 1409 } |
| 1410 |
| 1411 static base::subtle::AtomicWord g_InputStream_reset = 0; |
| 1412 static void Java_InputStream_reset(JNIEnv* env, jobject obj) __attribute__ |
| 1413 ((unused)); |
| 1414 static void Java_InputStream_reset(JNIEnv* env, jobject obj) { |
| 1415 /* Must call RegisterNativesImpl() */ |
| 1416 DCHECK(g_InputStream_clazz); |
| 1417 jmethodID method_id = |
| 1418 |
| 1419 base::android::MethodID::LazyGet< |
| 1420 base::android::MethodID::METHODTYPE_NORMAL, |
| 1421 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1422 env, g_InputStream_clazz, |
| 1423 "reset", |
1441 | 1424 |
1442 "(" | 1425 "(" |
1443 ")" | 1426 ")" |
1444 "V"); | 1427 "V", |
| 1428 &g_InputStream_reset); |
1445 | 1429 |
1446 g_InputStream_skip = | 1430 env->CallVoidMethod(obj, |
1447 base::android::GetMethodIDOrNull( | 1431 method_id); |
1448 env, g_InputStream_clazz, | 1432 base::android::CheckException(env); |
1449 "skip", | 1433 |
| 1434 } |
| 1435 |
| 1436 static base::subtle::AtomicWord g_InputStream_skip = 0; |
| 1437 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) |
| 1438 __attribute__ ((unused)); |
| 1439 static jlong Java_InputStream_skip(JNIEnv* env, jobject obj, jlong p0) { |
| 1440 /* Must call RegisterNativesImpl() */ |
| 1441 DCHECK(g_InputStream_clazz); |
| 1442 jmethodID method_id = |
| 1443 |
| 1444 base::android::MethodID::LazyGet< |
| 1445 base::android::MethodID::METHODTYPE_NORMAL, |
| 1446 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1447 env, g_InputStream_clazz, |
| 1448 "skip", |
1450 | 1449 |
1451 "(" | 1450 "(" |
1452 "J" | 1451 "J" |
1453 ")" | 1452 ")" |
1454 "J"); | 1453 "J", |
| 1454 &g_InputStream_skip); |
1455 | 1455 |
1456 g_InputStream_Constructor = | 1456 jlong ret = |
1457 base::android::GetMethodIDOrNull( | 1457 env->CallLongMethod(obj, |
1458 env, g_InputStream_clazz, | 1458 method_id, p0); |
1459 "<init>", | 1459 base::android::CheckException(env); |
| 1460 return ret; |
| 1461 } |
| 1462 |
| 1463 static base::subtle::AtomicWord g_InputStream_Constructor = 0; |
| 1464 static ScopedJavaLocalRef<jobject> Java_InputStream_Constructor(JNIEnv* env) |
| 1465 __attribute__ ((unused)); |
| 1466 static ScopedJavaLocalRef<jobject> Java_InputStream_Constructor(JNIEnv* env) { |
| 1467 /* Must call RegisterNativesImpl() */ |
| 1468 DCHECK(g_InputStream_clazz); |
| 1469 jmethodID method_id = |
| 1470 |
| 1471 base::android::MethodID::LazyGet< |
| 1472 base::android::MethodID::METHODTYPE_NORMAL, |
| 1473 base::android::MethodID::EXCEPTIONCHECK_NO>( |
| 1474 env, g_InputStream_clazz, |
| 1475 "<init>", |
1460 | 1476 |
1461 "(" | 1477 "(" |
1462 ")" | 1478 ")" |
1463 "V"); | 1479 "V", |
| 1480 &g_InputStream_Constructor); |
1464 | 1481 |
| 1482 jobject ret = |
| 1483 env->NewObject(g_InputStream_clazz, |
| 1484 method_id); |
| 1485 base::android::CheckException(env); |
| 1486 return ScopedJavaLocalRef<jobject>(env, ret); |
1465 } | 1487 } |
1466 | 1488 |
| 1489 // Step 3: RegisterNatives. |
| 1490 |
1467 static bool RegisterNativesImpl(JNIEnv* env) { | 1491 static bool RegisterNativesImpl(JNIEnv* env) { |
1468 GetMethodIDsImpl(env); | |
1469 | 1492 |
| 1493 g_InputStream_clazz = reinterpret_cast<jclass>(env->NewGlobalRef( |
| 1494 base::android::GetUnscopedClass(env, kInputStreamClassPath))); |
1470 return true; | 1495 return true; |
1471 } | 1496 } |
1472 } // namespace JNI_InputStream | 1497 } // namespace JNI_InputStream |
1473 | 1498 |
1474 #endif // java_io_InputStream_JNI | 1499 #endif // java_io_InputStream_JNI |
1475 """ | 1500 """ |
1476 self.assertTextEquals(golden_content, jni_from_javap.GetContent()) | 1501 self.assertTextEquals(golden_content, jni_from_javap.GetContent()) |
1477 | 1502 |
1478 def testREForNatives(self): | 1503 def testREForNatives(self): |
1479 # We should not match "native SyncSetupFlow" inside the comment. | 1504 # We should not match "native SyncSetupFlow" inside the comment. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 test_data, ('com/google/lookhowextremelylongiam/snarf/' | 1561 test_data, ('com/google/lookhowextremelylongiam/snarf/' |
1537 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) | 1562 'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage')) |
1538 jni_lines = jni_from_java.GetContent().split('\n') | 1563 jni_lines = jni_from_java.GetContent().split('\n') |
1539 line = filter(lambda line: line.lstrip().startswith('#ifndef'), | 1564 line = filter(lambda line: line.lstrip().startswith('#ifndef'), |
1540 jni_lines)[0] | 1565 jni_lines)[0] |
1541 self.assertTrue(len(line) > 80, | 1566 self.assertTrue(len(line) > 80, |
1542 ('Expected #ifndef line to be > 80 chars: ', line)) | 1567 ('Expected #ifndef line to be > 80 chars: ', line)) |
1543 | 1568 |
1544 if __name__ == '__main__': | 1569 if __name__ == '__main__': |
1545 unittest.main() | 1570 unittest.main() |
OLD | NEW |