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

Commit 2bf0f5dc authored by William Escande's avatar William Escande Committed by Android (Google) Code Review
Browse files

Merge "Revert "leaudio: Make sure all unit tests depeds on flags are tested"" into aosp-main-future

parents 8d8476da e1504952
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -881,7 +881,6 @@ cc_test {
    ],
    srcs: [
        ":TestCommonMockFunctions",
        ":TestFakeComAndroidBluetoothFlags",
        ":TestMockBtaLeAudioHalVerifier",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
@@ -981,7 +980,6 @@ cc_test {
    ],
    srcs: [
        ":TestCommonMockFunctions",
        ":TestFakeComAndroidBluetoothFlags",
        ":TestMockBtaLeAudioHalVerifier",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
@@ -1022,7 +1020,6 @@ cc_test {
        "libaconfig_storage_read_api_cc",
        "libbase",
        "libcrypto",
        "libcutils",
        "libhidlbase",
        "liblog",
        "server_configurable_flags",
@@ -1118,7 +1115,6 @@ cc_test {
    shared_libs: [
        "libbase",
        "libcrypto",
        "libcutils",
        "liblog",
        "server_configurable_flags",
    ],
@@ -1173,7 +1169,6 @@ cc_test {
    srcs: [
        ":TestCommonMockFunctions",
        ":TestCommonStackConfig",
        ":TestFakeComAndroidBluetoothFlags",
        ":TestFakeOsi",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
@@ -1193,11 +1188,9 @@ cc_test {
        "libbase",
        "libbinder_ndk",
        "libcrypto",
        "libcutils",
        "libfmq",
        "libhidlbase",
        "liblog",
        "server_configurable_flags",
    ],
    static_libs: [
        "libbluetooth-types",
+13 −23
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include "bta/le_audio/content_control_id_keeper.h"
#include "bta/le_audio/le_audio_types.h"
#include "bta/le_audio/mock_codec_manager.h"
#include "gd/os/system_properties.h"
#include "hci/controller_interface_mock.h"
#include "stack/include/btm_iso_api.h"
#include "test/common/mock_functions.h"
@@ -89,9 +88,7 @@ namespace server_configurable_flags {
std::string GetServerConfigurableFlag(const std::string& experiment_category_name,
                                      const std::string& experiment_flag_name,
                                      const std::string& default_value) {
  std::string prop_name =
          "persist.device_config." + experiment_category_name + "." + experiment_flag_name;
  return bluetooth::os::GetSystemProperty(prop_name).value_or(default_value);
  return "";
}
}  // namespace server_configurable_flags

@@ -100,9 +97,6 @@ bluetooth::common::MessageLoopThread message_loop_thread("test message loop");
bluetooth::common::MessageLoopThread* get_main_thread() { return &message_loop_thread; }
void invoke_switch_buffer_size_cb(bool is_low_latency_buffer_size) {}

static std::string kFlagPrefix(
        "persist.device_config.aconfig_flags.bluetooth.com.android.bluetooth.flags.");

bt_status_t do_in_main_thread(base::OnceClosure task) {
  // Wrap the task with task counter so we could later know if there are
  // any callbacks scheduled and we should wait before performing some actions
@@ -1149,10 +1143,9 @@ TEST_F(BroadcasterTest, VendorCodecConfig) {
                      subgroup.bis_configs.at(1).vendor_codec_specific_params->size()));
}

TEST_F(BroadcasterTest, AudioActiveState) {
  std::string flagString = kFlagPrefix + "leaudio_big_depends_on_audio_state";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(BroadcasterTest, AudioActiveState,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
  std::vector<uint8_t> updated_public_meta;
  PublicBroadcastAnnouncementData pb_announcement;

@@ -1230,10 +1223,9 @@ TEST_F(BroadcasterTest, AudioActiveState) {
  ASSERT_EQ(updated_public_meta, public_metadata_audio_false);
}

TEST_F(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundFromTheBeginning) {
  std::string flagString = kFlagPrefix + "leaudio_big_depends_on_audio_state";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundFromTheBeginning,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
  // Timers created
  ASSERT_TRUE(big_terminate_timer_ != nullptr);
  ASSERT_TRUE(broadcast_stop_timer_ != nullptr);
@@ -1273,10 +1265,9 @@ TEST_F(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundFromTheBeginnin
  broadcast_stop_timer_->cb(broadcast_stop_timer_->data);
}

TEST_F(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundAfterSuspend) {
  std::string flagString = kFlagPrefix + "leaudio_big_depends_on_audio_state";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundAfterSuspend,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
  // Timers created
  ASSERT_TRUE(big_terminate_timer_ != nullptr);
  ASSERT_TRUE(broadcast_stop_timer_ != nullptr);
@@ -1344,10 +1335,9 @@ TEST_F(BroadcasterTest, BigTerminationAndBroadcastStopWhenNoSoundAfterSuspend) {
  broadcast_stop_timer_->cb(broadcast_stop_timer_->data);
}

TEST_F(BroadcasterTest, BigCreationTerminationDependsOnAudioResumeSuspend) {
  std::string flagString = kFlagPrefix + "leaudio_big_depends_on_audio_state";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(BroadcasterTest, BigCreationTerminationDependsOnAudioResumeSuspend,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_big_depends_on_audio_state))) {
  // Timers created
  ASSERT_TRUE(big_terminate_timer_ != nullptr);
  ASSERT_TRUE(broadcast_stop_timer_ != nullptr);
+6 −12
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include "../le_audio_types.h"
#include "broadcast_configuration_provider.h"
#include "btm_iso_api.h"
#include "gd/os/system_properties.h"
#include "stack/include/btm_ble_api_types.h"
#include "state_machine.h"
#include "test/common/mock_functions.h"
@@ -48,9 +47,6 @@ using testing::Test;
// Disables most likely false-positives from base::SplitString()
extern "C" const char* __asan_default_options() { return "detect_container_overflow=0"; }

static std::string kFlagPrefix(
        "persist.device_config.aconfig_flags.bluetooth.com.android.bluetooth.flags.");

void btsnd_hcic_ble_rand(base::Callback<void(BT_OCTET8)> cb) {}

namespace bluetooth::le_audio {
@@ -516,10 +512,9 @@ TEST_F(StateMachineTest, UpdateAnnouncement) {
  ASSERT_EQ(first_len + types::LeAudioLtvMap(metadata).RawPacketSize(), second_len);
}

TEST_F(StateMachineTest, UpdateBroadcastAnnouncementWithCallback) {
  std::string flagString = kFlagPrefix + "leaudio_broadcast_update_metadata_callback";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(
        StateMachineTest, UpdateBroadcastAnnouncementWithCallback,
        REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, leaudio_broadcast_update_metadata_callback))) {
  EXPECT_CALL(*(sm_callbacks_.get()), OnStateMachineCreateStatus(_, true)).Times(1);

  auto broadcast_id = InstantiateStateMachine();
@@ -539,10 +534,9 @@ TEST_F(StateMachineTest, UpdateBroadcastAnnouncementWithCallback) {
  ASSERT_EQ(announcement, broadcasts_[broadcast_id]->GetBroadcastAnnouncement());
}

TEST_F(StateMachineTest, UpdatePublicBroadcastAnnouncementWithCallback) {
  std::string flagString = kFlagPrefix + "leaudio_broadcast_update_metadata_callback";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(
        StateMachineTest, UpdatePublicBroadcastAnnouncementWithCallback,
        REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT, leaudio_broadcast_update_metadata_callback))) {
  EXPECT_CALL(*(sm_callbacks_.get()), OnStateMachineCreateStatus(_, true)).Times(1);

  auto broadcast_id = InstantiateStateMachine();
+43 −63
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include "common/message_loop_thread.h"
#include "fake_osi.h"
#include "gatt/database_builder.h"
#include "gd/os/system_properties.h"
#include "gmock/gmock.h"
#include "hardware/bt_gatt_types.h"
#include "hci/controller_interface_mock.h"
@@ -94,9 +93,6 @@ using bluetooth::le_audio::types::LeAudioContextType;

extern struct fake_osi_alarm_set_on_mloop fake_osi_alarm_set_on_mloop_;

static std::string kFlagPrefix(
        "persist.device_config.aconfig_flags.bluetooth.com.android.bluetooth.flags.");

constexpr int max_num_of_ases = 5;
constexpr bluetooth::le_audio::types::LeAudioContextType kLeAudioDefaultConfigurationContext =
        bluetooth::le_audio::types::LeAudioContextType::UNSPECIFIED;
@@ -209,9 +205,7 @@ namespace server_configurable_flags {
std::string GetServerConfigurableFlag(const std::string& experiment_category_name,
                                      const std::string& experiment_flag_name,
                                      const std::string& default_value) {
  std::string prop_name =
          "persist.device_config." + experiment_category_name + "." + experiment_flag_name;
  return bluetooth::os::GetSystemProperty(prop_name).value_or(default_value);
  return "";
}
}  // namespace server_configurable_flags

@@ -4488,13 +4482,12 @@ TEST_F(UnicastTest, GroupSetActiveNonConnectedGroup) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
}

TEST_F(UnicastTest, GroupSetActive_CurrentCodecSentOfActive) {
TEST_F_WITH_FLAGS(UnicastTest, GroupSetActive_CurrentCodecSentOfActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_codec_config_callback_order_fix))) {
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

  std::string flagString = kFlagPrefix + "leaudio_codec_config_callback_order_fix";
  os::SetSystemProperty(flagString, std::string("true"));

  /**
   * In this test we want to make sure that Available context change reach Java
   * when group is in Configured state
@@ -5818,13 +5811,12 @@ TEST_F(UnicastTest, SpeakerStreamingNonDefault) {
  LocalAudioSourceResume();
}

TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Sink) {
TEST_F_WITH_FLAGS(UnicastTest, TestUnidirectionalVoiceAssistant_Sink,
                  REQUIRES_FLAGS_ENABLED(
                          ACONFIG_FLAG(TEST_BT, le_audio_support_unidirectional_voice_assistant))) {
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

  std::string flagString = kFlagPrefix + "le_audio_support_unidirectional_voice_assistant";
  os::SetSystemProperty(flagString, std::string("true"));

  /**
   * Scenario test steps
   * 1. Configure group to support VOICEASSISTANT only on SINK
@@ -5892,13 +5884,12 @@ TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Sink) {
  SyncOnMainLoop();
}

TEST_F(UnicastTest, TestUnidirectionalVoiceAssistant_Source) {
TEST_F_WITH_FLAGS(UnicastTest, TestUnidirectionalVoiceAssistant_Source,
                  REQUIRES_FLAGS_ENABLED(
                          ACONFIG_FLAG(TEST_BT, le_audio_support_unidirectional_voice_assistant))) {
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

  std::string flagString = kFlagPrefix + "le_audio_support_unidirectional_voice_assistant";
  os::SetSystemProperty(flagString, std::string("true"));

  /**
   * Scenario test steps
   * 1. Configure group to support VOICEASSISTANT only on SOURCE
@@ -9051,12 +9042,11 @@ TEST_F(UnicastTest, DisconnectAclBeforeGettingReadResponses) {
  SyncOnMainLoop();
}

TEST_F(UnicastTest, GroupStreamStatus) {
TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatus,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_callback_on_group_stream_status))) {
  int group_id = bluetooth::groups::kGroupUnknown;

  std::string flagString = kFlagPrefix + "leaudio_callback_on_group_stream_status";
  os::SetSystemProperty(flagString, std::string("true"));

  InSequence s;

  /* Check if all states are properly notified */
@@ -9140,14 +9130,13 @@ TEST_F(UnicastTest, GroupStreamStatus) {
  state_machine_callbacks_->StatusReportCb(group_id, GroupStreamStatus::STREAMING);
}

TEST_F(UnicastTest, GroupStreamStatusManyGroups) {
TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatusManyGroups,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_callback_on_group_stream_status))) {
  uint8_t group_size = 2;
  int group_id_1 = 1;
  int group_id_2 = 2;

  std::string flagString = kFlagPrefix + "leaudio_callback_on_group_stream_status";
  os::SetSystemProperty(flagString, std::string("true"));

  // Report working CSIS
  ON_CALL(mock_csis_client_module_, IsCsisClientRunning()).WillByDefault(Return(true));

@@ -9222,13 +9211,12 @@ TEST_F(UnicastTest, GroupStreamStatusManyGroups) {
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F(UnicastTest, GroupStreamStatusResendAfterRemove) {
TEST_F_WITH_FLAGS(UnicastTest, GroupStreamStatusResendAfterRemove,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_callback_on_group_stream_status))) {
  uint8_t group_size = 2;
  int group_id = 1;

  std::string flagString = kFlagPrefix + "leaudio_callback_on_group_stream_status";
  os::SetSystemProperty(flagString, std::string("true"));

  // Report working CSIS
  ON_CALL(mock_csis_client_module_, IsCsisClientRunning()).WillByDefault(Return(true));

@@ -9306,13 +9294,12 @@ TEST_F(UnicastTest, GroupStreamStatusResendAfterRemove) {
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsActive) {
TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  uint8_t group_size = 2;
  int group_id = 2;

  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

  // Report working CSIS
  ON_CALL(mock_csis_client_module_, IsCsisClientRunning()).WillByDefault(Return(true));

@@ -9450,13 +9437,12 @@ TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsActive) {
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
}

TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInactive) {
TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInactive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  uint8_t group_size = 2;
  int group_id = 2;

  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

  // Imitate activation of monitor mode
  do_in_main_thread(base::BindOnce(
          &LeAudioClient::SetUnicastMonitorMode, base::Unretained(LeAudioClient::Get()),
@@ -9547,13 +9533,12 @@ TEST_F(UnicastTestHandoverMode, SetSinkMonitorModeWhileUnicastIsInactive) {
                      .size());
}

TEST_F(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsActive) {
TEST_F_WITH_FLAGS(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  uint8_t group_size = 2;
  int group_id = 2;

  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

  // Imitate activation of monitor mode
  do_in_main_thread(base::BindOnce(
          &LeAudioClient::SetUnicastMonitorMode, base::Unretained(LeAudioClient::Get()),
@@ -9643,10 +9628,9 @@ TEST_F(UnicastTestHandoverMode, ClearSinkMonitorModeWhileUnicastIsActive) {
                      .size());
}

TEST_F(UnicastTestHandoverMode, SetAndClearSinkMonitorModeWhileUnicastIsInactive) {
  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetAndClearSinkMonitorModeWhileUnicastIsInactive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  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);
@@ -9668,10 +9652,9 @@ TEST_F(UnicastTestHandoverMode, SetAndClearSinkMonitorModeWhileUnicastIsInactive
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
}

TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsInactive) {
  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsInactive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  /* Enabling monitor mode for source while group is not active should result in
   * sending STREAMING_SUSPENDED notification.
   */
@@ -9688,10 +9671,9 @@ TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsInactive) {
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsNotStreaming) {
  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsNotStreaming,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  int group_id = 2;

  LeAudioClient::Get()->GroupSetActive(group_id);
@@ -9712,10 +9694,9 @@ TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsNotStreaming)
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
}

TEST_F(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsActive) {
  std::string flagString = kFlagPrefix + "leaudio_broadcast_audio_handover_policies";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(UnicastTestHandoverMode, SetSourceMonitorModeWhileUnicastIsActive,
                  REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(TEST_BT,
                                                      leaudio_broadcast_audio_handover_policies))) {
  uint8_t group_size = 2;
  int group_id = 2;

@@ -9919,10 +9900,9 @@ TEST_F(UnicastTestHandoverMode, SetAllowedContextMask) {
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
}

TEST_F(UnicastTest, NoContextvalidateStreamingRequest) {
  std::string flagString = kFlagPrefix + "leaudio_no_context_validate_streaming_request";
  os::SetSystemProperty(flagString, std::string("true"));

TEST_F_WITH_FLAGS(UnicastTest, NoContextvalidateStreamingRequest,
                  REQUIRES_FLAGS_ENABLED(
                          ACONFIG_FLAG(TEST_BT, leaudio_no_context_validate_streaming_request))) {
  const RawAddress test_address0 = GetTestAddress(0);
  int group_id = bluetooth::groups::kGroupUnknown;

+0 −7
Original line number Diff line number Diff line
@@ -594,13 +594,6 @@ filegroup {
    ],
}

filegroup {
    name: "TestFakeComAndroidBluetoothFlags",
    srcs: [
        "fake/fake_com_android_bluetooth_flags.cc",
    ],
}

filegroup {
    name: "TestFakeOsi",
    srcs: [
Loading