parent
2a0756c95d
commit
6eed99a646
|
@ -7,10 +7,10 @@ package com.rusefi.native_;
|
|||
* See native_impl.cpp
|
||||
*/
|
||||
public class EngineLogic {
|
||||
public native String getVersion();
|
||||
public static native String getVersion();
|
||||
|
||||
// huh? I am having trouble making this method static?
|
||||
public native void resetTest();
|
||||
public static native void resetTest();
|
||||
|
||||
public native void setSensor(String sensorTypeName, double value);
|
||||
|
||||
|
|
|
@ -18,17 +18,16 @@ import static junit.framework.Assert.*;
|
|||
public class JniUnitTest {
|
||||
@Before
|
||||
public void reset() {
|
||||
// new EngineLogic().resetTest();
|
||||
JniSandbox.loadLibrary();
|
||||
EngineLogic.resetTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run() {
|
||||
JniSandbox.loadLibrary();
|
||||
|
||||
EngineLogic engineLogic = new EngineLogic();
|
||||
String version = engineLogic.getVersion();
|
||||
String version = EngineLogic.getVersion();
|
||||
assertTrue("Got " + version, version.contains("Hello"));
|
||||
|
||||
EngineLogic engineLogic = new EngineLogic();
|
||||
engineLogic.invokePeriodicCallback();
|
||||
|
||||
assertEquals(TS_FILE_VERSION, (int) getValue(engineLogic.getOutputs(), Sensor.FIRMWARE_VERSION));
|
||||
|
@ -54,8 +53,6 @@ public class JniUnitTest {
|
|||
|
||||
@Test
|
||||
public void testEtbStuff() {
|
||||
JniSandbox.loadLibrary();
|
||||
|
||||
EngineLogic engineLogic = new EngineLogic();
|
||||
|
||||
engineLogic.setSensor(SensorType.Tps1Primary.name(), 30);
|
||||
|
@ -71,12 +68,12 @@ public class JniUnitTest {
|
|||
engineLogic.setConfiguration(new byte[]{3}, Fields.THROTTLEPEDALPOSITIONADCCHANNEL.getTotalOffset(), 1);
|
||||
engineLogic.setConfiguration(new byte[]{3}, Fields.THROTTLEPEDALPOSITIONSECONDADCCHANNEL.getTotalOffset(), 1);
|
||||
|
||||
// engineLogic.initTps();
|
||||
// engineLogic.burnRequest();
|
||||
// System.out.println("engineLogic.invokeEtbCycle");
|
||||
// engineLogic.invokeEtbCycle();
|
||||
//
|
||||
// assertEquals(120.36, getValue(engineLogic.getOutputs(), Sensor.etb1DutyCycle));
|
||||
engineLogic.initTps();
|
||||
engineLogic.burnRequest();
|
||||
System.out.println("engineLogic.invokeEtbCycle");
|
||||
engineLogic.invokeEtbCycle();
|
||||
|
||||
assertEquals(120.36, getValue(engineLogic.getOutputs(), Sensor.etb1DutyCycle));
|
||||
}
|
||||
|
||||
private double getField(EngineLogic engineLogic, Field field) {
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion
|
||||
(JNIEnv *, jobject);
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: com_rusefi_native__EngineLogic
|
||||
|
@ -21,7 +21,7 @@ JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion
|
|||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_resetTest
|
||||
(JNIEnv *, jobject);
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: com_rusefi_native__EngineLogic
|
||||
|
|
|
@ -25,12 +25,12 @@ static EngineTestHelper* getEth() {
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_resetTest
|
||||
(JNIEnv *, jobject) {
|
||||
(JNIEnv *, jclass) {
|
||||
printf("[native] resetTest\n");
|
||||
ethPtr = nullptr;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion(JNIEnv * env, jobject) {
|
||||
JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion(JNIEnv * env, jclass) {
|
||||
const char msg[60] = "Hello from unit tests";
|
||||
const char* fileName = msg;
|
||||
jstring result = env->NewStringUTF(msg);
|
||||
|
@ -116,6 +116,12 @@ JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_initTps
|
|||
initTps();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_initTps2
|
||||
(JNIEnv *, jobject) {
|
||||
printf("[native] initTps2\n");
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getOutputs(JNIEnv * env, jobject instance) {
|
||||
jbyteArray retVal = env->NewByteArray(TS_TOTAL_OUTPUT_SIZE);
|
||||
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
|
||||
|
|
Loading…
Reference in New Issue