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

Commit dfa9bc8e authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk Committed by Jack He
Browse files

le_audio: Limit possible scenarios to test for device tests

Patch limist scenarios for testing to only matching for required amount
of devices and ASEs.

Test: atest bluetooth_le_audio_client_test
Sponsor: @jpawlowski
Bug: 229802353
Change-Id: I009dadc994a28354460e1d16a027d092fa0eb527
Merged-In: I009dadc994a28354460e1d16a027d092fa0eb527
parent d0fe24b7
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -526,6 +526,13 @@ class LeAudioAseConfigurationTest : public Test {
    for (const auto& audio_set_conf : *configurations) {
      // the configuration should fail if there are no active ases expected
      bool success_expected = data_size > 0;
      bool not_matching_scenario = false;
      uint8_t snk_ases_cnt = 0;
      uint8_t src_ases_cnt = 0;
      PublishedAudioCapabilitiesBuilder snk_pac_builder, src_pac_builder;
      snk_pac_builder.Reset();
      src_pac_builder.Reset();

      for (int i = 0; i < data_size; i++) {
        success_expected &= (data[i].active_channel_num_snk +
                             data[i].active_channel_num_src) > 0;
@@ -536,19 +543,34 @@ class LeAudioAseConfigurationTest : public Test {
         * DualDev). This is just how the test is created and this limitation
         * should be removed b/230107540
         */
        PublishedAudioCapabilitiesBuilder snk_pac_builder, src_pac_builder;
        for (const auto& entry : (*audio_set_conf).confs) {
          /* Configuration requires more devices than are supplied */
          if (entry.device_cnt > data_size) {
            not_matching_scenario = true;
            break;
          }
          if (entry.direction == kLeAudioDirectionSink) {
            snk_ases_cnt += entry.ase_cnt;
            snk_pac_builder.Add(entry.codec, data[i].audio_channel_counts_snk);
          } else {
            src_pac_builder.Add(entry.codec, data[i].audio_channel_counts_src);
          }
        }

        /* Scenario requires more ASEs than defined requirement */
        if (snk_ases_cnt < data[i].audio_channel_counts_snk ||
            src_ases_cnt < data[i].audio_channel_counts_src) {
          not_matching_scenario = true;
        }

        if (not_matching_scenario) break;

        data[i].device->snk_pacs_ = snk_pac_builder.Get();
        data[i].device->src_pacs_ = src_pac_builder.Get();
      }

      if (not_matching_scenario) continue;

      /* Stimulate update of active context map */
      group_->UpdateActiveContextsMap(static_cast<uint16_t>(context_type));
      ASSERT_EQ(success_expected, group_->Configure(context_type));