Loading system/btif/test/btif_core_test.cc +2 −3 Original line number Diff line number Diff line Loading @@ -124,13 +124,12 @@ class BtifCoreTest : public ::testing::Test { void SetUp() override { callback_map_.clear(); set_hal_cbacks(&callbacks); InitializeCoreInterface(); auto promise = std::promise<void>(); auto future = promise.get_future(); callback_map_["callback_thread_event"] = [&promise]() { promise.set_value(); }; btif_init_bluetooth(); InitializeCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(timeout_time)); callback_map_.erase("callback_thread_event"); } Loading @@ -141,7 +140,7 @@ class BtifCoreTest : public ::testing::Test { callback_map_["callback_thread_event"] = [&promise]() { promise.set_value(); }; btif_cleanup_bluetooth(); CleanCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(timeout_time)); callback_map_.erase("callback_thread_event"); } Loading system/btif/test/btif_hh_test.cc +2 −4 Original line number Diff line number Diff line Loading @@ -181,9 +181,8 @@ class BtifHhWithHalCallbacksTest : public BtifHhWithMockTest { g_thread_evt_promise.set_value(evt); }; set_hal_cbacks(&bt_callbacks); InitializeCoreInterface(); // Start the jni callback thread ASSERT_EQ(BT_STATUS_SUCCESS, btif_init_bluetooth()); InitializeCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(2s)); ASSERT_EQ(ASSOCIATE_JVM, future.get()); Loading @@ -196,8 +195,7 @@ class BtifHhWithHalCallbacksTest : public BtifHhWithMockTest { bt_callbacks.thread_evt_cb = [](bt_cb_thread_evt evt) { g_thread_evt_promise.set_value(evt); }; // Shutdown the jni callback thread ASSERT_EQ(BT_STATUS_SUCCESS, btif_cleanup_bluetooth()); CleanCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(2s)); ASSERT_EQ(DISASSOCIATE_JVM, future.get()); Loading system/test/common/core_interface.cc +4 −0 Original line number Diff line number Diff line Loading @@ -71,3 +71,7 @@ void InitializeCoreInterface() { static auto mockCoreInterface = MockCoreInterface{}; stack_manager_get_interface()->init_stack(&mockCoreInterface); } void CleanCoreInterface() { stack_manager_get_interface()->clean_up_stack([] {}); } system/test/common/core_interface.h +1 −0 Original line number Diff line number Diff line Loading @@ -15,3 +15,4 @@ */ void InitializeCoreInterface(); void CleanCoreInterface(); Loading
system/btif/test/btif_core_test.cc +2 −3 Original line number Diff line number Diff line Loading @@ -124,13 +124,12 @@ class BtifCoreTest : public ::testing::Test { void SetUp() override { callback_map_.clear(); set_hal_cbacks(&callbacks); InitializeCoreInterface(); auto promise = std::promise<void>(); auto future = promise.get_future(); callback_map_["callback_thread_event"] = [&promise]() { promise.set_value(); }; btif_init_bluetooth(); InitializeCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(timeout_time)); callback_map_.erase("callback_thread_event"); } Loading @@ -141,7 +140,7 @@ class BtifCoreTest : public ::testing::Test { callback_map_["callback_thread_event"] = [&promise]() { promise.set_value(); }; btif_cleanup_bluetooth(); CleanCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(timeout_time)); callback_map_.erase("callback_thread_event"); } Loading
system/btif/test/btif_hh_test.cc +2 −4 Original line number Diff line number Diff line Loading @@ -181,9 +181,8 @@ class BtifHhWithHalCallbacksTest : public BtifHhWithMockTest { g_thread_evt_promise.set_value(evt); }; set_hal_cbacks(&bt_callbacks); InitializeCoreInterface(); // Start the jni callback thread ASSERT_EQ(BT_STATUS_SUCCESS, btif_init_bluetooth()); InitializeCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(2s)); ASSERT_EQ(ASSOCIATE_JVM, future.get()); Loading @@ -196,8 +195,7 @@ class BtifHhWithHalCallbacksTest : public BtifHhWithMockTest { bt_callbacks.thread_evt_cb = [](bt_cb_thread_evt evt) { g_thread_evt_promise.set_value(evt); }; // Shutdown the jni callback thread ASSERT_EQ(BT_STATUS_SUCCESS, btif_cleanup_bluetooth()); CleanCoreInterface(); ASSERT_EQ(std::future_status::ready, future.wait_for(2s)); ASSERT_EQ(DISASSOCIATE_JVM, future.get()); Loading
system/test/common/core_interface.cc +4 −0 Original line number Diff line number Diff line Loading @@ -71,3 +71,7 @@ void InitializeCoreInterface() { static auto mockCoreInterface = MockCoreInterface{}; stack_manager_get_interface()->init_stack(&mockCoreInterface); } void CleanCoreInterface() { stack_manager_get_interface()->clean_up_stack([] {}); }
system/test/common/core_interface.h +1 −0 Original line number Diff line number Diff line Loading @@ -15,3 +15,4 @@ */ void InitializeCoreInterface(); void CleanCoreInterface();