#include "base/native_library.h"
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/test/native_library_test_utils.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
const FilePath::CharType kDummyLibraryPath[] = …);
TEST(NativeLibraryTest, LoadFailure) { … }
TEST(NativeLibraryTest, LoadFailureWithNullError) { … }
#if BUILDFLAG(IS_FUCHSIA)
TEST(NativeLibraryTest, LoadAbsolutePath) {
EXPECT_TRUE(LoadNativeLibrary(FilePath("/pkg/lib/libtest_shared_library.so"),
nullptr));
}
TEST(NativeLibraryTest, LoadAbsolutePath_OutsideLibraryRoot) {
NativeLibraryLoadError error;
EXPECT_FALSE(LoadNativeLibrary(FilePath("/pkg/tmp/libtest_shared_library.so"),
&error));
std::string expected_error =
"Absolute library paths must begin with /pkg/lib";
EXPECT_EQ(error.ToString(), expected_error);
}
#endif
TEST(NativeLibraryTest, GetNativeLibraryName) { … }
TEST(NativeLibraryTest, GetLoadableModuleName) { … }
#if !BUILDFLAG(IS_IOS) && !defined(ADDRESS_SANITIZER)
const char kTestLibraryName[] = …"test_shared_library.dll";
#elif BUILDFLAG(IS_MAC)
"libtest_shared_library.dylib";
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
"libtest_shared_library.so";
#endif
class TestLibrary { … };
#if !BUILDFLAG(IS_ANDROID)
TEST(NativeLibraryTest, LoadLibrary) { … }
#endif
#if !BUILDFLAG(IS_ANDROID) && !defined(THREAD_SANITIZER) && \
!defined(MEMORY_SANITIZER)
TEST(NativeLibraryTest, LoadLibraryPreferOwnSymbols) { … }
#endif
#endif
}