Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 666c804f authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Do not init the stack twice in tests"

parents c0cd3f2e d77b5ed8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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");
  }
@@ -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");
  }
+2 −4
Original line number Diff line number Diff line
@@ -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());

@@ -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());

+4 −0
Original line number Diff line number Diff line
@@ -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([] {});
}
+1 −0
Original line number Diff line number Diff line
@@ -15,3 +15,4 @@
 */

void InitializeCoreInterface();
void CleanCoreInterface();