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

Commit 12503e70 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Łukasz Rymanowski
Browse files

LE Audio: Improve unit tests

Avoid sharing variables between tests and move these to the test class.
This prevents any potential data leaks from one test to the other and
makes them more independent.

Bug: 274106369
Test: atest bluetooth_le_audio_client_test
Change-Id: I05d1b67a84139ea19618d9613f6f5fad7d5aa919
parent dad41504
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -89,11 +89,6 @@ constexpr le_audio::types::LeAudioContextType
    kLeAudioDefaultConfigurationContext =
        le_audio::types::LeAudioContextType::UNSPECIFIED;

static tGATT_STATUS gatt_read_ctp_ccc_status_ = GATT_SUCCESS;
static uint8_t ccc_stored_byte_val_ = 0x01;

static char* test_tags_ptr_ = nullptr;

static constexpr char kNotifyUpperLayerAboutGroupBeingInIdleDuringCall[] =
    "persist.bluetooth.leaudio.notify.idle.during.call";
const char* test_flags[] = {
@@ -1404,10 +1399,6 @@ class UnicastTestNoInit : public Test {
            SupportsBleConnectedIsochronousStreamPeripheral)
        .WillByDefault(Return(true));

    gatt_read_ctp_ccc_status_ = GATT_SUCCESS;
    ccc_stored_byte_val_ = 0x01;
    test_tags_ptr_ = nullptr;

    controller::SetMockControllerInterface(&controller_interface_);
    bluetooth::manager::SetMockBtmInterface(&mock_btm_interface_);
    gatt::SetMockBtaGattInterface(&mock_gatt_interface_);
@@ -2611,6 +2602,13 @@ class UnicastTestNoInit : public Test {
  std::map<uint16_t, std::unique_ptr<NiceMock<MockDeviceWrapper>>> peer_devices;
  std::list<int> group_locks;
  std::map<RawAddress, int> groups;

  /* CCC descriptor data */
  tGATT_STATUS gatt_read_ctp_ccc_status_ = GATT_SUCCESS;
  uint8_t ccc_stored_byte_val_ = 0x01;

  /* Audio track metadata */
  char* test_tags_ptr_ = nullptr;
};

class UnicastTest : public UnicastTestNoInit {