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

Commit f2d60893 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Łukasz Rymanowski (xWF)
Browse files

leaudio: Make sure all unit tests depeds on flags are tested

This patch removes all the TEST_F_WITH_FLAG test cases and configures
flag properly for given tests.

It uses bluetooth_flags_c_lib_for_test for that.

Bug: 331775328
Flag: TEST_ONLY
Test: atest bluetooth_le_audio_test bluetooth_le_audio_client_test
bluetooth_test_broadcaster

Change-Id: I338fceea491dd7dad35dc7e6a8c9faf7758fdd1b
parent 968f1e5a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -941,7 +941,7 @@ cc_test {
        "server_configurable_flags",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "bluetooth_flags_c_lib_for_test",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_gd",
@@ -1029,7 +1029,7 @@ cc_test {
        "liblog",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "bluetooth_flags_c_lib_for_test",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_gd",
@@ -1125,7 +1125,7 @@ cc_test {
        "server_configurable_flags",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "bluetooth_flags_c_lib_for_test",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_gd",
@@ -1202,7 +1202,7 @@ cc_test {
        "server_configurable_flags",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "bluetooth_flags_c_lib_for_test",
        "libbluetooth-types",
        "libbluetooth_gd",
        "libbluetooth_hci_pdl",
+13 −12
Original line number Diff line number Diff line
@@ -356,6 +356,7 @@ protected:
  }

  void TearDown() override {
    com::android::bluetooth::flags::provider_->reset_flags();
    // Message loop cleanup should wait for all the 'till now' scheduled calls
    // so it should be called right at the very begginning of teardown.
    cleanup_message_loop_thread();
@@ -1157,9 +1158,9 @@ TEST_F(BroadcasterTest, VendorCodecConfig) {
                      subgroup.bis_configs.at(1).vendor_codec_specific_params->size()));
}

TEST_F_WITH_FLAGS(BroadcasterTest, AudioActiveState,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
TEST_F(BroadcasterTest, AudioActiveState) {
  com::android::bluetooth::flags::provider_->leaudio_big_depends_on_audio_state(true);

  std::vector<uint8_t> updated_public_meta;
  PublicBroadcastAnnouncementData pb_announcement;

@@ -1237,9 +1238,9 @@ TEST_F_WITH_FLAGS(BroadcasterTest, AudioActiveState,
  ASSERT_EQ(updated_public_meta, public_metadata_audio_false);
}

TEST_F_WITH_FLAGS(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundFromTheBeginning,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
TEST_F(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundFromTheBeginning) {
  com::android::bluetooth::flags::provider_->leaudio_big_depends_on_audio_state(true);

  // Timers created
  ASSERT_TRUE(big_terminate_timer_ != nullptr);
  ASSERT_TRUE(broadcast_stop_timer_ != nullptr);
@@ -1279,9 +1280,9 @@ TEST_F_WITH_FLAGS(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundFrom
  broadcast_stop_timer_->cb(broadcast_stop_timer_->data);
}

TEST_F_WITH_FLAGS(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundAfterSuspend,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
TEST_F(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundAfterSuspend) {
  com::android::bluetooth::flags::provider_->leaudio_big_depends_on_audio_state(true);

  // Timers created
  ASSERT_TRUE(big_terminate_timer_ != nullptr);
  ASSERT_TRUE(broadcast_stop_timer_ != nullptr);
@@ -1349,9 +1350,9 @@ TEST_F_WITH_FLAGS(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundAfte
  broadcast_stop_timer_->cb(broadcast_stop_timer_->data);
}

TEST_F_WITH_FLAGS(BroadcasterTest, BigCreationTerminationDependsOnAudioResumeSuspend,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
TEST_F(BroadcasterTest, BigCreationTerminationDependsOnAudioResumeSuspend) {
  com::android::bluetooth::flags::provider_->leaudio_big_depends_on_audio_state(true);

  // Timers created
  ASSERT_TRUE(big_terminate_timer_ != nullptr);
  ASSERT_TRUE(broadcast_stop_timer_ != nullptr);
+7 −6
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ protected:
  }

  void TearDown() override {
    com::android::bluetooth::flags::provider_->reset_flags();
    iso_manager_->Stop();
    mock_iso_manager_ = nullptr;
    Mock::VerifyAndClearExpectations(sm_callbacks_.get());
@@ -512,9 +513,9 @@ TEST_F(StateMachineTest, UpdateAnnouncement) {
  ASSERT_EQ(first_len + types::LeAudioLtvMap(metadata).RawPacketSize(), second_len);
}

TEST_F_WITH_FLAGS(
        StateMachineTest, UpdateBroadcastAnnouncementWithCallback,
        REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, leaudio_broadcast_update_metadata_callback))) {
TEST_F(StateMachineTest, UpdateBroadcastAnnouncementWithCallback) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_update_metadata_callback(true);

  EXPECT_CALL(*(sm_callbacks_.get()), OnStateMachineCreateStatus(_, true)).Times(1);

  auto broadcast_id = InstantiateStateMachine();
@@ -534,9 +535,9 @@ TEST_F_WITH_FLAGS(
  ASSERT_EQ(announcement, broadcasts_[broadcast_id]->GetBroadcastAnnouncement());
}

TEST_F_WITH_FLAGS(
        StateMachineTest, UpdatePublicBroadcastAnnouncementWithCallback,
        REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, leaudio_broadcast_update_metadata_callback))) {
TEST_F(StateMachineTest, UpdatePublicBroadcastAnnouncementWithCallback) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_update_metadata_callback(true);

  EXPECT_CALL(*(sm_callbacks_.get()), OnStateMachineCreateStatus(_, true)).Times(1);

  auto broadcast_id = InstantiateStateMachine();
+39 −42
Original line number Diff line number Diff line
@@ -1474,6 +1474,8 @@ protected:
  }

  void TearDown() override {
    com::android::bluetooth::flags::provider_->reset_flags();

    if (is_audio_unicast_source_acquired) {
      if (unicast_source_hal_cb_ != nullptr) {
        EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop).Times(1);
@@ -4474,9 +4476,8 @@ TEST_F(UnicastTest, GroupSetActiveNonConnectedGroup) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
}

TEST_F_WITH_FLAGS(UnicastTest, GroupSetActive_CurrentCodecSentOfActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_codec_config_callback_order_fix))) {
TEST_F(UnicastTest, GroupSetActive_CurrentCodecSentOfActive) {
  com::android::bluetooth::flags::provider_->leaudio_codec_config_callback_order_fix(true);
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

@@ -5803,9 +5804,8 @@ TEST_F(UnicastTest, SpeakerStreamingNonDefault) {
  LocalAudioSourceResume();
}

TEST_F_WITH_FLAGS(UnicastTest, TestUnidirectionalVoiceAssistant_Sink,
                  REQUIRES_FLAGS_ENABLED(
                          ACONFIG_FLAG(TEST_BT, le_audio_support_unidirectional_voice_assistant))) {
TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Sink) {
  com::android::bluetooth::flags::provider_->le_audio_support_unidirectional_voice_assistant(true);
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

@@ -5876,9 +5876,8 @@ TEST_F_WITH_FLAGS(UnicastTest, TestUnidirectionalVoiceAssistant_Sink,
  SyncOnMainLoop();
}

TEST_F_WITH_FLAGS(UnicastTest, TestUnidirectionalVoiceAssistant_Source,
                  REQUIRES_FLAGS_ENABLED(
                          ACONFIG_FLAG(TEST_BT, le_audio_support_unidirectional_voice_assistant))) {
TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Source) {
  com::android::bluetooth::flags::provider_->le_audio_support_unidirectional_voice_assistant(true);
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

@@ -9034,9 +9033,8 @@ TEST_F(UnicastTest, DisconnectAclBeforeGettingReadResponses) {
  SyncOnMainLoop();
}

TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatus,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_callback_on_group_stream_status))) {
TEST_F(UnicastTest, GroupStreamStatus) {
  com::android::bluetooth::flags::provider_->leaudio_callback_on_group_stream_status(true);
  int group_id = bluetooth::groups::kGroupUnknown;

  InSequence s;
@@ -9122,9 +9120,9 @@ TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatus,
  state_machine_callbacks_->StatusReportCb(group_id, GroupStreamStatus::STREAMING);
}

TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatusManyGroups,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_callback_on_group_stream_status))) {
TEST_F(UnicastTest, GroupStreamStatusManyGroups) {
  com::android::bluetooth::flags::provider_->leaudio_callback_on_group_stream_status(true);

  uint8_t group_size = 2;
  int group_id_1 = 1;
  int group_id_2 = 2;
@@ -9203,9 +9201,9 @@ TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatusManyGroups,
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatusResendAfterRemove,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_callback_on_group_stream_status))) {
TEST_F(UnicastTest, GroupStreamStatusResendAfterRemove) {
  com::android::bluetooth::flags::provider_->leaudio_callback_on_group_stream_status(true);

  uint8_t group_size = 2;
  int group_id = 1;

@@ -9286,9 +9284,9 @@ TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatusResendAfterRemove,
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsActive) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);

  uint8_t group_size = 2;
  int group_id = 2;

@@ -9429,9 +9427,8 @@ TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsActiv
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInactive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInactive) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);
  uint8_t group_size = 2;
  int group_id = 2;

@@ -9525,9 +9522,9 @@ TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInact
                      .size());
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsActive) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);

  uint8_t group_size = 2;
  int group_id = 2;

@@ -9620,9 +9617,9 @@ TEST_F_WITH_FLAGS(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsAct
                      .size());
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetAndClearSinkMonitorModeWhileUnicastIsInactive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, SetAndClearSinkMonitorModeWhileUnicastIsInactive) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);

  EXPECT_CALL(*mock_le_audio_source_hal_client_, Start(_, _, _)).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(0);
  EXPECT_CALL(*mock_le_audio_source_hal_client_, OnDestroyed()).Times(0);
@@ -9644,9 +9641,9 @@ TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetAndClearSinkMonitorModeWhileUnicas
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsInactive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsInactive) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);

  /* Enabling monitor mode for source while group is not active should result in
   * sending STREAMING_SUSPENDED notification.
   */
@@ -9663,9 +9660,9 @@ TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsIna
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsNotStreaming,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsNotStreaming) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);

  int group_id = 2;

  LeAudioClient::Get()->GroupSetActive(group_id);
@@ -9686,9 +9683,9 @@ TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsNot
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsActive) {
  com::android::bluetooth::flags::provider_->leaudio_broadcast_audio_handover_policies(true);

  uint8_t group_size = 2;
  int group_id = 2;

@@ -9892,9 +9889,9 @@ TEST_F(UnicastTestHandoverMode, SetAllowedContextMask) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
}

TEST_F_WITH_FLAGS(UnicastTest, NoContextvalidateStreamingRequest,
                  REQUIRES_FLAGS_ENABLED(
                          ACONFIG_FLAG(TEST_BT, leaudio_no_context_validate_streaming_request))) {
TEST_F(UnicastTest, NoContextvalidateStreamingRequest) {
  com::android::bluetooth::flags::provider_->leaudio_no_context_validate_streaming_request(true);

  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

+2 −0
Original line number Diff line number Diff line
@@ -602,6 +602,8 @@ protected:
  }

  void TearDown() override {
    com::android::bluetooth::flags::provider_->reset_flags();

    /* Clear the alarm on tear down in case test case ends when the
     * alarm is scheduled
     */