mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
external/jnipp: Update
This commit is contained in:
parent
c66b29d117
commit
8279a41c78
19
src/external/jnipp/CMakeLists.txt
vendored
Normal file
19
src/external/jnipp/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Copyright 2021, Collabora, Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.10.2)
|
||||
project(jnipp)
|
||||
|
||||
find_package(JNI REQUIRED)
|
||||
include(CTest)
|
||||
|
||||
add_library(jnipp jnipp.cpp)
|
||||
target_include_directories(
|
||||
jnipp
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${JNI_INCLUDE_DIRS})
|
||||
target_compile_features(jnipp PUBLIC cxx_std_11)
|
||||
target_link_libraries(jnipp PUBLIC ${CMAKE_DL_LIBS})
|
||||
|
||||
add_subdirectory(tests)
|
18
src/external/jnipp/tests/CMakeLists.txt
vendored
Normal file
18
src/external/jnipp/tests/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Copyright 2021, Collabora, Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
add_executable(main_test main.cpp testing.h)
|
||||
target_link_libraries(main_test PRIVATE jnipp)
|
||||
add_test(NAME main_test COMMAND main_test)
|
||||
|
||||
add_executable(external_create external_create.cpp testing.h)
|
||||
target_link_libraries(external_create PUBLIC jnipp ${JNI_LIBRARIES})
|
||||
target_include_directories(external_create PUBLIC ${JNI_INCLUDE_DIRS})
|
||||
add_test(NAME external_create COMMAND external_create)
|
||||
|
||||
|
||||
add_executable(external_detach external_detach.cpp testing.h)
|
||||
target_link_libraries(external_detach PUBLIC jnipp ${JNI_LIBRARIES})
|
||||
target_include_directories(external_detach PUBLIC ${JNI_INCLUDE_DIRS})
|
||||
add_test(NAME external_detach COMMAND external_detach)
|
37
src/external/jnipp/tests/external_create.cpp
vendored
Normal file
37
src/external/jnipp/tests/external_create.cpp
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Project Dependencies
|
||||
#include <jni.h>
|
||||
#include <jnipp.h>
|
||||
|
||||
// Standard Dependencies
|
||||
#include <cmath>
|
||||
|
||||
// Local Dependencies
|
||||
#include "testing.h"
|
||||
|
||||
/*
|
||||
jni::Vm Tests
|
||||
*/
|
||||
TEST(Vm_externalCreateAndAttach) {
|
||||
JNIEnv *env;
|
||||
JavaVMInitArgs args = {};
|
||||
args.version = JNI_VERSION_1_2;
|
||||
JavaVM *javaVm{};
|
||||
auto ret = JNI_CreateJavaVM(&javaVm, (void **)&env, &args);
|
||||
ASSERT(ret == 0);
|
||||
|
||||
{
|
||||
jni::init(env);
|
||||
jni::Class cls("java/lang/String");
|
||||
}
|
||||
JavaVM *localVmPointer{};
|
||||
|
||||
ret = env->GetJavaVM(&localVmPointer);
|
||||
ASSERT(ret == 0);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// jni::Vm Tests
|
||||
RUN_TEST(Vm_externalCreateAndAttach);
|
||||
|
||||
return 0;
|
||||
}
|
34
src/external/jnipp/tests/external_detach.cpp
vendored
Normal file
34
src/external/jnipp/tests/external_detach.cpp
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Project Dependencies
|
||||
#include <jni.h>
|
||||
#include <jnipp.h>
|
||||
|
||||
// Standard Dependencies
|
||||
#include <cmath>
|
||||
|
||||
// Local Dependencies
|
||||
#include "testing.h"
|
||||
|
||||
/*
|
||||
jni::Vm Tests
|
||||
*/
|
||||
TEST(Vm_externalDetach) {
|
||||
jni::Vm vm;
|
||||
|
||||
jni::Class cls("java/lang/String");
|
||||
|
||||
JNIEnv *env = (JNIEnv *)jni::env();
|
||||
JavaVM *localVmPointer{};
|
||||
|
||||
auto ret = env->GetJavaVM(&localVmPointer);
|
||||
ASSERT(ret == 0);
|
||||
ret = localVmPointer->DetachCurrentThread();
|
||||
ASSERT(ret == 0);
|
||||
|
||||
ASSERT(1);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// jni::Vm Tests
|
||||
RUN_TEST(Vm_externalDetach);
|
||||
return 0;
|
||||
}
|
2
src/external/jnipp/tests/main.cpp
vendored
2
src/external/jnipp/tests/main.cpp
vendored
|
@ -622,8 +622,6 @@ int main()
|
|||
RUN_TEST(Arg_ObjectPtr);
|
||||
}
|
||||
|
||||
std::cout << "Press a key to continue..." << std::endl;
|
||||
std::cin.get();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue