TEST_F(NativeBridgeTest, V3_UnloadLibrary) { // Init ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary3, nullptr)); ASSERT_TRUE(NativeBridgeAvailable()); ASSERT_TRUE(PreInitializeNativeBridge(".", "isa")); ASSERT_TRUE(NativeBridgeAvailable()); ASSERT_TRUE(InitializeNativeBridge(nullptr, nullptr)); ASSERT_TRUE(NativeBridgeAvailable()); ASSERT_EQ(3U, NativeBridgeGetVersion()); ASSERT_EQ(0, NativeBridgeUnloadLibrary(nullptr)); // Clean-up code_cache ASSERT_EQ(0, rmdir(kCodeCache)); }
// Tests that the bridge initialization creates the code_cache if it doesn't // exists. TEST_F(NativeBridgeTest, CodeCacheCreate) { // Make sure that code_cache does not exists struct stat st; ASSERT_EQ(-1, stat(kCodeCache, &st)); ASSERT_EQ(ENOENT, errno); // Init ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary, nullptr)); ASSERT_TRUE(PreInitializeNativeBridge(".", "isa")); ASSERT_TRUE(InitializeNativeBridge(nullptr, nullptr)); ASSERT_TRUE(NativeBridgeAvailable()); ASSERT_FALSE(NativeBridgeError()); // Check that code_cache was created ASSERT_EQ(0, stat(kCodeCache, &st)); ASSERT_TRUE(S_ISDIR(st.st_mode)); // Clean up UnloadNativeBridge(); ASSERT_EQ(0, rmdir(kCodeCache)); ASSERT_FALSE(NativeBridgeError()); }
TEST_F(NativeBridgeTest, CompleteFlow) { // Init ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary, nullptr)); ASSERT_TRUE(NativeBridgeAvailable()); ASSERT_TRUE(PreInitializeNativeBridge(".", "isa")); ASSERT_TRUE(NativeBridgeAvailable()); ASSERT_TRUE(InitializeNativeBridge(nullptr, nullptr)); ASSERT_TRUE(NativeBridgeAvailable()); // Basic calls to check that nothing crashes ASSERT_FALSE(NativeBridgeIsSupported(nullptr)); ASSERT_EQ(nullptr, NativeBridgeLoadLibrary(nullptr, 0)); ASSERT_EQ(nullptr, NativeBridgeGetTrampoline(nullptr, nullptr, nullptr, 0)); // Unload UnloadNativeBridge(); ASSERT_FALSE(NativeBridgeAvailable()); ASSERT_FALSE(NativeBridgeError()); // Clean-up code_cache ASSERT_EQ(0, rmdir(kCodeCache)); }
TEST_F(NativeBridgeTest, PreInitializeNativeBridgeFail1) { // Needs a valid application directory. ASSERT_TRUE(LoadNativeBridge(kNativeBridgeLibrary, nullptr)); ASSERT_FALSE(PreInitializeNativeBridge(nullptr, "isa")); ASSERT_TRUE(NativeBridgeError()); }