The open source OpenXR runtime

external/jnipp: Update

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
8279a41c c66b29d1

+108 -2
+19
src/external/jnipp/CMakeLists.txt
··· 1 + # Copyright 2021, Collabora, Ltd. 2 + # 3 + # SPDX-License-Identifier: MIT 4 + 5 + cmake_minimum_required(VERSION 3.10.2) 6 + project(jnipp) 7 + 8 + find_package(JNI REQUIRED) 9 + include(CTest) 10 + 11 + add_library(jnipp jnipp.cpp) 12 + target_include_directories( 13 + jnipp 14 + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} 15 + PRIVATE ${JNI_INCLUDE_DIRS}) 16 + target_compile_features(jnipp PUBLIC cxx_std_11) 17 + target_link_libraries(jnipp PUBLIC ${CMAKE_DL_LIBS}) 18 + 19 + add_subdirectory(tests)
+18
src/external/jnipp/tests/CMakeLists.txt
··· 1 + # Copyright 2021, Collabora, Ltd. 2 + # 3 + # SPDX-License-Identifier: MIT 4 + 5 + add_executable(main_test main.cpp testing.h) 6 + target_link_libraries(main_test PRIVATE jnipp) 7 + add_test(NAME main_test COMMAND main_test) 8 + 9 + add_executable(external_create external_create.cpp testing.h) 10 + target_link_libraries(external_create PUBLIC jnipp ${JNI_LIBRARIES}) 11 + target_include_directories(external_create PUBLIC ${JNI_INCLUDE_DIRS}) 12 + add_test(NAME external_create COMMAND external_create) 13 + 14 + 15 + add_executable(external_detach external_detach.cpp testing.h) 16 + target_link_libraries(external_detach PUBLIC jnipp ${JNI_LIBRARIES}) 17 + target_include_directories(external_detach PUBLIC ${JNI_INCLUDE_DIRS}) 18 + add_test(NAME external_detach COMMAND external_detach)
+37
src/external/jnipp/tests/external_create.cpp
··· 1 + // Project Dependencies 2 + #include <jni.h> 3 + #include <jnipp.h> 4 + 5 + // Standard Dependencies 6 + #include <cmath> 7 + 8 + // Local Dependencies 9 + #include "testing.h" 10 + 11 + /* 12 + jni::Vm Tests 13 + */ 14 + TEST(Vm_externalCreateAndAttach) { 15 + JNIEnv *env; 16 + JavaVMInitArgs args = {}; 17 + args.version = JNI_VERSION_1_2; 18 + JavaVM *javaVm{}; 19 + auto ret = JNI_CreateJavaVM(&javaVm, (void **)&env, &args); 20 + ASSERT(ret == 0); 21 + 22 + { 23 + jni::init(env); 24 + jni::Class cls("java/lang/String"); 25 + } 26 + JavaVM *localVmPointer{}; 27 + 28 + ret = env->GetJavaVM(&localVmPointer); 29 + ASSERT(ret == 0); 30 + } 31 + 32 + int main() { 33 + // jni::Vm Tests 34 + RUN_TEST(Vm_externalCreateAndAttach); 35 + 36 + return 0; 37 + }
+34
src/external/jnipp/tests/external_detach.cpp
··· 1 + // Project Dependencies 2 + #include <jni.h> 3 + #include <jnipp.h> 4 + 5 + // Standard Dependencies 6 + #include <cmath> 7 + 8 + // Local Dependencies 9 + #include "testing.h" 10 + 11 + /* 12 + jni::Vm Tests 13 + */ 14 + TEST(Vm_externalDetach) { 15 + jni::Vm vm; 16 + 17 + jni::Class cls("java/lang/String"); 18 + 19 + JNIEnv *env = (JNIEnv *)jni::env(); 20 + JavaVM *localVmPointer{}; 21 + 22 + auto ret = env->GetJavaVM(&localVmPointer); 23 + ASSERT(ret == 0); 24 + ret = localVmPointer->DetachCurrentThread(); 25 + ASSERT(ret == 0); 26 + 27 + ASSERT(1); 28 + } 29 + 30 + int main() { 31 + // jni::Vm Tests 32 + RUN_TEST(Vm_externalDetach); 33 + return 0; 34 + }
-2
src/external/jnipp/tests/main.cpp
··· 622 622 RUN_TEST(Arg_ObjectPtr); 623 623 } 624 624 625 - std::cout << "Press a key to continue..." << std::endl; 626 - std::cin.get(); 627 625 return 0; 628 626 } 629 627