JNI for test coverage #3965

This commit is contained in:
rusefillc 2022-04-04 22:33:30 -04:00
parent 7a0cb64b95
commit b005a049e2
3 changed files with 24 additions and 1 deletions

View File

@ -12,6 +12,8 @@ public class EngineLogic {
public native void setConfiguration(byte[] content, int offset, int size);
public native void setEngineType(int engineType);
public native void invokePeriodicCallback();
public native byte[] getOutputs();

View File

@ -39,6 +39,14 @@ JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getConfigurati
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setConfiguration
(JNIEnv *, jobject, jbyteArray, jint, jint);
/*
* Class: com_rusefi_native__EngineLogic
* Method: setEngineType
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setEngineType
(JNIEnv *, jobject, jint);
/*
* Class: com_rusefi_native__EngineLogic
* Method: invokePeriodicCallback

View File

@ -30,7 +30,14 @@ JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion(JNIEnv
}
JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getConfiguration(JNIEnv *env, jobject instance) {
return nullptr;
jbyteArray retVal = env->NewByteArray(sizeof(engine_configuration_s));
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
EngineTestHelper* eth = getEth();
memcpy(buf, (const void*)&eth->persistentConfig.engineConfiguration, sizeof(engine_configuration_s));
env->ReleaseByteArrayElements(retVal, buf, 0);
return retVal;
}
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setConfiguration(JNIEnv *env, jobject instance,
@ -53,6 +60,12 @@ JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setSensor
env->ReleaseStringUTFChars(sensorName, sensorNameNative);
}
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setEngineType
(JNIEnv *, jobject, jint engineType) {
EngineTestHelper* eth = getEth();
resetConfigurationExt((engine_type_e)engineType);
}
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_invokePeriodicCallback
(JNIEnv *, jobject) {