90 EXPECT_CALL(mock_env, GetObjectRefType(_))
91 .WillRepeatedly(Return(JNILocalRefType));
92 EXPECT_CALL(mock_env, NewLocalRef(_)).WillRepeatedly(ReturnArg<0>());
93 EXPECT_CALL(mock_env, DeleteLocalRef(_)).WillRepeatedly(Return());
94 EXPECT_CALL(mock_env, CallObjectMethodV(_, _, _))
95 .WillRepeatedly(Return(
nullptr));
96 EXPECT_CALL(mock_env, ExceptionCheck()).WillOnce(Return(JNI_TRUE));
97 EXPECT_CALL(mock_env, ExceptionDescribe()).WillOnce(Return());
98 EXPECT_CALL(mock_env, ExceptionClear()).Times(1).WillOnce(Return());
104 reinterpret_cast<jobject
>(123));
112 typedef void (*SetViewportMetricsFn)(
113 JNIEnv*, jobject, jlong, jfloat, jint, jint, jint, jint, jint, jint, jint,
114 jint, jint, jint, jint, jint, jint, jint, jint, jintArray, jintArray,
115 jintArray, jint, jint, jint, jint, jint, jint, jint, jint);
117 SetViewportMetricsFn set_viewport_metrics =
nullptr;
119 const jclass kPlaceholderClass =
reinterpret_cast<jclass
>(100);
120 const jfieldID kPlaceholderFieldID =
reinterpret_cast<jfieldID
>(200);
121 const jmethodID kPlaceholderMethodID =
reinterpret_cast<jmethodID
>(300);
123 EXPECT_CALL(mock_env, GetObjectRefType(_))
124 .WillRepeatedly(Return(JNILocalRefType));
125 EXPECT_CALL(mock_env, NewLocalRef(_)).WillRepeatedly(ReturnArg<0>());
126 EXPECT_CALL(mock_env, DeleteLocalRef(_)).WillRepeatedly(Return());
127 EXPECT_CALL(mock_env, NewGlobalRef(_)).WillRepeatedly(ReturnArg<0>());
128 EXPECT_CALL(mock_env, DeleteGlobalRef(_)).WillRepeatedly(Return());
129 EXPECT_CALL(mock_env, FindClass(_)).WillRepeatedly(Return(kPlaceholderClass));
130 EXPECT_CALL(mock_env, GetFieldID(_, _, _))
131 .WillRepeatedly(Return(kPlaceholderFieldID));
132 EXPECT_CALL(mock_env, GetMethodID(_, _, _))
133 .WillRepeatedly(Return(kPlaceholderMethodID));
134 EXPECT_CALL(mock_env, GetStaticFieldID(_, _, _))
135 .WillRepeatedly(Return(kPlaceholderFieldID));
136 EXPECT_CALL(mock_env, GetStaticMethodID(_, _, _))
137 .WillRepeatedly(Return(kPlaceholderMethodID));
138 EXPECT_CALL(mock_env, ExceptionCheck()).WillRepeatedly(Return(JNI_FALSE));
140 EXPECT_CALL(mock_env, RegisterNatives(_, _, _))
142 [&](jclass clazz,
const JNINativeMethod* methods, jint nMethods) {
143 for (jint
i = 0;
i < nMethods; ++
i) {
144 if (strcmp(methods[
i].
name,
"nativeSetViewportMetrics") == 0) {
145 set_viewport_metrics =
146 reinterpret_cast<SetViewportMetricsFn
>(methods[
i].fnPtr);
154 ASSERT_NE(set_viewport_metrics,
nullptr);
156 EXPECT_CALL(mock_env, GetArrayLength(_)).WillRepeatedly(Return(0));
157 EXPECT_CALL(mock_env, GetIntArrayRegion(_, _, _, _)).Times(0);
161 auto jni = std::make_shared<JNIMock>();
162 auto holder = std::make_unique<AndroidShellHolder>(
165 jobject jcaller =
reinterpret_cast<jobject
>(123);
166 jintArray bounds =
reinterpret_cast<jintArray
>(456);
167 jintArray
type =
reinterpret_cast<jintArray
>(789);
168 jintArray state =
reinterpret_cast<jintArray
>(1011);
170 set_viewport_metrics(&mock_env, jcaller,
171 reinterpret_cast<jlong
>(holder.get()), 1.0f, 100, 100, 0,
172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, bounds,
type, state,
173 0, 0, 0, 0, 0, 0, 0, 0);