Use art::CommonRuntimeTest to set up a test with a runtime.
This is hopefully a better way than a plain call to JNI_CreateJavaVM to
set up a runtime that works in all the various test environments.
Test: m cts cts-tradefed
cts-tradefed run commandAndExit cts \
--module art_standalone_libartpalette_tests
Test: art/tools/run-gtests.sh \
/apex/com.android.art/bin/art/{x86,x86_64}/art_libartpalette_tests
in device chroot test environment
Test: m test-art-host-gtest-art_libartpalette_tests
Bug: 216838549
Change-Id: I763dbaa6f449b58fb1b060054618b8b48507fce2
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 78ff90e..853dc29 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -21,6 +21,7 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include "common_runtime_test.h"
#include "gtest/gtest.h"
namespace {
@@ -68,3 +69,15 @@
EXPECT_EQ(0, close(fd));
#endif
}
+
+class PaletteClientJniTest : public art::CommonRuntimeTest {};
+
+TEST_F(PaletteClientJniTest, JniInvocation) {
+ bool enabled;
+ EXPECT_EQ(PALETTE_STATUS_OK, PaletteShouldReportJniInvocations(&enabled));
+
+ JNIEnv* env = art::Thread::Current()->GetJniEnv();
+ ASSERT_NE(nullptr, env);
+ PaletteNotifyBeginJniInvocation(env);
+ PaletteNotifyEndJniInvocation(env);
+}