class MockJni { public: virtual ~MockJni() {}
MOCK_METHOD1(JniObject_getParent, constchar*(constchar*));
};
static std::unique_ptr<MockJni> jni_mock;
// A very simple JNI mock. // jstring is a pointer to utf8 char array. We don't need utf16 char here. // jobject, jclass, and jmethodID are also a pointer to utf8 char array // Only a few JNI methods that are actually used in libnativeloader are mocked.
JNINativeInterface* CreateJNINativeInterface() {
JNINativeInterface* inf = new JNINativeInterface();
memset(inf, 0, sizeof(JNINativeInterface));
inf->CallObjectMethodV = [](JNIEnv*, jobject obj, jmethodID mid, va_list) -> jobject { if (strcmp("getParent", reinterpret_cast<constchar*>(mid)) == 0) { // JniObject_getParent can be a valid jobject or nullptr if there is // no parent classloader. constchar* ret = jni_mock->JniObject_getParent(reinterpret_cast<constchar*>(obj)); returnreinterpret_cast<jobject>(const_cast<char*>(ret));
} return nullptr;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.