From e337c94fc7245e60ce09815faedd59b26406f160 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Thu, 18 Apr 2024 21:26:10 +0100 Subject: Clean up the test mocks. Split them up so that the API tests only have the JNI mock that they need, and the "platform" mock - which is nonfunctional there - is not present. Also a few other code cleanups. Test: atest libnativeloader_test \ art_libnativeloader_cts_test \ libnativeloader_lazy_test Bug: 335224367 Change-Id: Ifabc64db43e0346d5aefc9809266190690178ebf --- libnativeloader/native_loader_api_test.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libnativeloader/native_loader_api_test.cpp') diff --git a/libnativeloader/native_loader_api_test.cpp b/libnativeloader/native_loader_api_test.cpp index 78fb29f91d..aeda1cc2a7 100644 --- a/libnativeloader/native_loader_api_test.cpp +++ b/libnativeloader/native_loader_api_test.cpp @@ -14,9 +14,12 @@ * limitations under the License. */ -#if defined(ART_TARGET_ANDROID) +#include +#include +#include "gmock/gmock.h" #include "gtest/gtest.h" +#include "jni.h" #include "native_loader_test.h" #include "nativehelper/scoped_utf_chars.h" #include "nativeloader/native_loader.h" @@ -35,7 +38,7 @@ using ::testing::StrEq; class NativeLoaderLazyTest : public ::testing::Test { protected: void SetUp() override { - mock = std::make_unique>(false); + jni_mock = std::make_unique>(); env = std::make_unique(); env->functions = CreateJNINativeInterface(); } @@ -45,11 +48,11 @@ class NativeLoaderLazyTest : public ::testing::Test { // reset libnativeloader internal state. Hence be sure to not reuse the same // class loader/namespace names. delete env->functions; - mock.reset(); + jni_mock.reset(); } void CallCreateClassLoaderNamespace(const char* class_loader) { - ON_CALL(*mock, JniObject_getParent(StrEq(class_loader))).WillByDefault(Return(nullptr)); + ON_CALL(*jni_mock, JniObject_getParent(StrEq(class_loader))).WillByDefault(Return(nullptr)); jstring err = CreateClassLoaderNamespace(env.get(), 17, @@ -123,5 +126,3 @@ TEST_F(NativeLoaderLazyTest, NativeLoaderFreeErrorMessage) { } // namespace nativeloader } // namespace android - -#endif // defined(ART_TARGET_ANDROID) -- cgit v1.2.3-59-g8ed1b