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

Commit df089051 authored by Chris Manton's avatar Chris Manton
Browse files

net_test_btif_rc: Add jni shutdown and proper initialization

Bug: 312991023
Test: atest net_test_btif_rc

Change-Id: I84a0d6189fccbdf72fffc544d221aa5a1a804249
parent 0aaf9419
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <stdio.h>

#include <cstdint>
#include <future>

#include "bta/include/bta_av_api.h"
#include "btif/include/btif_common.h"
@@ -26,7 +27,6 @@
#include "device/include/interop.h"
#include "include/hardware/bt_rc.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_api_types.h"
#include "test/common/mock_functions.h"
#include "test/mock/mock_osi_alarm.h"
#include "test/mock/mock_osi_allocator.h"
@@ -151,7 +151,11 @@ bool interop_match_addr(const interop_feature_t feature,
/**
 * Test class to test selected functionality in hci/src/hci_layer.cc
 */
class BtifRcTest : public ::testing::Test {};
class BtifRcTest : public ::testing::Test {
 protected:
  void SetUp() override { reset_mock_function_count_map(); }
  void TearDown() override {}
};

TEST_F(BtifRcTest, get_element_attr_rsp) {
  RawAddress bd_addr;
@@ -238,6 +242,7 @@ class BtifRcFeatureTest : public BtifRcTest {
  }

  void TearDown() override {
    jni_thread.ShutDown();
    bt_rc_ctrl_callbacks->getrcfeatures_cb = [](const RawAddress& bd_addr,
                                                int features) {};
    BtifRcTest::TearDown();
@@ -284,6 +289,7 @@ class BtifRcBrowseConnectionTest : public BtifRcTest {
  }

  void TearDown() override {
    jni_thread.ShutDown();
    bt_rc_ctrl_callbacks->connection_state_cb =
        [](bool rc_state, bool bt_state, const RawAddress& bd_addr) {};
    BtifRcTest::TearDown();
@@ -298,6 +304,7 @@ TEST_F(BtifRcBrowseConnectionTest, handle_rc_browse_connect) {

  tBTA_AV_RC_BROWSE_OPEN browse_data = {
      .rc_handle = 0,
      .peer_addr = {},
      .status = BTA_AV_SUCCESS,
  };

@@ -331,6 +338,7 @@ class BtifRcConnectionTest : public BtifRcTest {
  }

  void TearDown() override {
    jni_thread.ShutDown();
    bt_rc_ctrl_callbacks->connection_state_cb =
        [](bool rc_state, bool bt_state, const RawAddress& bd_addr) {};
    BtifRcTest::TearDown();
@@ -404,6 +412,7 @@ class BtifTrackChangeCBTest : public BtifRcTest {
  }

  void TearDown() override {
    jni_thread.ShutDown();
    btrc_ctrl_callbacks.track_changed_cb = [](const RawAddress& bd_addr,
                       uint8_t num_attr, btrc_element_attr_val_t* p_attrs) {};
    BtifRcTest::TearDown();
@@ -413,11 +422,20 @@ class BtifTrackChangeCBTest : public BtifRcTest {
TEST_F(BtifTrackChangeCBTest, handle_get_metadata_attr_response) {
  tBTA_AV_META_MSG meta_msg = {
      .rc_handle = 0,
      .len = 0,
      .label = 0,
      .code{},
      .company_id = 0,
      .p_data = {},
      .p_msg = nullptr,
  };

  tAVRC_GET_ATTRS_RSP rsp = {
      .pdu = 0,
      .status = AVRC_STS_NO_ERROR,
      .opcode = 0,
      .num_attrs = 0,
      .p_attrs = nullptr,
  };

  btif_rc_cb.rc_multi_cb[0].rc_handle = 0;