1 #include <jni.h> 2 3 #include "utils/testing/logging_event_listener.h" 4 #include "gtest/gtest.h" 5 6 JNIEnv* g_jenv = nullptr; 7 jobject g_context = nullptr; 8 9 // This method is called from Java to trigger running of all the tests. 10 extern "C" JNIEXPORT jboolean JNICALL Java_com_google_android_textclassifier_tests_JvmTestLauncher_testsMain(JNIEnv * env,jclass clazz,jobject context)11Java_com_google_android_textclassifier_tests_JvmTestLauncher_testsMain( 12 JNIEnv* env, jclass clazz, jobject context) { 13 g_jenv = env; 14 g_context = context; 15 16 char arg[] = "jvm_test_launcher"; 17 std::vector<char*> argv = {arg}; 18 int argc = 1; 19 testing::InitGoogleTest(&argc, argv.data()); 20 testing::UnitTest::GetInstance()->listeners().Append( 21 new libtextclassifier3::LoggingEventListener()); 22 return RUN_ALL_TESTS() == 0; 23 }