forked from BabylonJS/JsRuntimeHost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJNI.cpp
More file actions
34 lines (26 loc) · 1.17 KB
/
JNI.cpp
File metadata and controls
34 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <jni.h>
#include <android/log.h>
#include <AndroidExtensions/Globals.h>
#include <AndroidExtensions/JavaWrappers.h>
#include <AndroidExtensions/StdoutLogger.h>
#include "Babylon/DebugTrace.h"
#include <Shared/Shared.h>
extern "C" JNIEXPORT jint JNICALL
Java_com_jsruntimehost_unittests_Native_javaScriptTests(JNIEnv* env, jclass clazz, jobject context) {
JavaVM* javaVM{};
if (env->GetJavaVM(&javaVM) != JNI_OK)
{
throw std::runtime_error{"Failed to get Java VM"};
}
jclass webSocketClass{env->FindClass("com/jsruntimehost/unittests/WebSocket")};
java::websocket::WebSocketClient::InitializeJavaWebSocketClass(webSocketClass, env);
// Temporarily disable StdoutLogger due to fdsan issue with NDK 28
// android::StdoutLogger::Start();
android::global::Initialize(javaVM, context);
Babylon::DebugTrace::EnableDebugTrace(true);
Babylon::DebugTrace::SetTraceOutput([](const char* trace) { __android_log_print(ANDROID_LOG_INFO, "JsRuntimeHost", "%s", trace); });
auto testResult = RunTests();
// android::StdoutLogger::Stop();
java::websocket::WebSocketClient::DestructJavaWebSocketClass(env);
return testResult;
}