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

Commit fd74320a authored by Rahul Arya's avatar Rahul Arya
Browse files

Simplify TestHciLayer

Automatically record promises when enqueuing commands. This removes the
SetCommandFuture stuff that is confusing and bug-prone.

Test: le_advertising_manager gd unit tests
Bug: 247839849
Change-Id: Ica34fcfbb79a245f477266b686df0b31354334f8
parent 4514897e
Loading
Loading
Loading
Loading
+29 −27
Original line number Diff line number Diff line
@@ -40,41 +40,34 @@ PacketView<packet::kLittleEndian> GetPacketView(std::unique_ptr<packet::BasePack
void TestHciLayer::EnqueueCommand(
    std::unique_ptr<CommandBuilder> command, common::ContextualOnceCallback<void(CommandStatusView)> on_status) {
  std::lock_guard<std::mutex> lock(mutex_);

  command_queue_.push(std::move(command));
  command_status_callbacks.push_back(std::move(on_status));
  command_count_--;
  if (command_promise_ != nullptr && command_count_ == 0) {
    command_promise_->set_value();
    command_promise_.reset();

  if (command_queue_.size() == 1) {
    // since GetCommand may replace this promise, we have to do this inside the lock
    command_promise_.set_value();
  }
}

void TestHciLayer::EnqueueCommand(
    std::unique_ptr<CommandBuilder> command, common::ContextualOnceCallback<void(CommandCompleteView)> on_complete) {
  std::lock_guard<std::mutex> lock(mutex_);

  command_queue_.push(std::move(command));
  command_complete_callbacks.push_back(std::move(on_complete));
  command_count_--;
  if (command_promise_ != nullptr && command_count_ == 0) {
    command_promise_->set_value();
    command_promise_.reset();
  }
}

void TestHciLayer::SetCommandFuture(uint16_t num_command) {
  ASSERT_TRUE(command_promise_ == nullptr) << "Promises, Promises, ... Only one at a time.";
  command_count_ = num_command;
  command_promise_ = std::make_unique<std::promise<void>>();
  command_future_ = std::make_unique<std::future<void>>(command_promise_->get_future());
  if (command_queue_.size() == 1) {
    // since GetCommand may replace this promise, we have to do this inside the lock
    command_promise_.set_value();
  }
}

CommandView TestHciLayer::GetCommand() {
  // Wait for EnqueueCommand if command_queue_ is empty
  if (command_queue_.empty() && command_future_ != nullptr) {
    command_future_->wait_for(std::chrono::milliseconds(1000));
  }
  EXPECT_EQ(command_future_.wait_for(std::chrono::milliseconds(1000)), std::future_status::ready);

  std::lock_guard<std::mutex> lock(mutex_);

  if (command_queue_.empty()) {
    LOG_ERROR("Command queue is empty");
    return empty_command_view_;
@@ -82,11 +75,14 @@ CommandView TestHciLayer::GetCommand() {

  auto last = std::move(command_queue_.front());
  command_queue_.pop();
  CommandView command_packet_view = CommandView::Create(GetPacketView(std::move(last)));
  if (!command_packet_view.IsValid()) {
    LOG_ERROR("Got invalid command");
    return empty_command_view_;

  if (command_queue_.empty()) {
    command_promise_ = {};
    command_future_ = command_promise_.get_future();
  }

  CommandView command_packet_view = CommandView::Create(GetPacketView(std::move(last)));
  ASSERT_LOG(command_packet_view.IsValid(), "Got invalid command");
  return command_packet_view;
}

@@ -113,9 +109,15 @@ void TestHciLayer::IncomingEvent(std::unique_ptr<EventBuilder> event_builder) {
  EventView event = EventView::Create(packet);
  ASSERT_TRUE(event.IsValid());
  EventCode event_code = event.GetEventCode();
  if (event_code == EventCode::COMMAND_COMPLETE) {
    CommandCompleteCallback(event);
  } else if (event_code == EventCode::COMMAND_STATUS) {
    CommandStatusCallback(event);
  } else {
    ASSERT_NE(registered_events_.find(event_code), registered_events_.end()) << EventCodeText(event_code);
    registered_events_[event_code].Invoke(event);
  }
}

void TestHciLayer::IncomingLeMetaEvent(std::unique_ptr<LeMetaEventBuilder> event_builder) {
  auto packet = GetPacketView(std::move(event_builder));
@@ -150,9 +152,9 @@ void TestHciLayer::InitEmptyCommand() {

void TestHciLayer::ListDependencies(ModuleList* list) const {}
void TestHciLayer::Start() {
  std::lock_guard<std::mutex> lock(mutex_);

  InitEmptyCommand();
  RegisterEventHandler(EventCode::COMMAND_COMPLETE, GetHandler()->BindOn(this, &TestHciLayer::CommandCompleteCallback));
  RegisterEventHandler(EventCode::COMMAND_STATUS, GetHandler()->BindOn(this, &TestHciLayer::CommandStatusCallback));
}
void TestHciLayer::Stop() {}

+20 −11
Original line number Diff line number Diff line
@@ -40,9 +40,6 @@ class TestHciLayer : public HciLayer {
      std::unique_ptr<CommandBuilder> command,
      common::ContextualOnceCallback<void(CommandCompleteView)> on_complete) override;

  // Set command future for 'num_command' commands are expected
  void SetCommandFuture(uint16_t num_command);

  CommandView GetCommand();

  void RegisterEventHandler(EventCode event_code, common::ContextualCallback<void(EventView)> event_handler) override;
@@ -62,23 +59,35 @@ class TestHciLayer : public HciLayer {

  void CommandStatusCallback(EventView event);

  void InitEmptyCommand();

 protected:
  void ListDependencies(ModuleList* list) const override;
  void Start() override;
  void Stop() override;

 private:
  std::map<EventCode, common::ContextualCallback<void(EventView)>> registered_events_;
  std::map<SubeventCode, common::ContextualCallback<void(LeMetaEventView)>> registered_le_events_;
  void InitEmptyCommand();

  // Handler-only state. Mutexes are not needed when accessing these fields.
  std::list<common::ContextualOnceCallback<void(CommandCompleteView)>> command_complete_callbacks;
  std::list<common::ContextualOnceCallback<void(CommandStatusView)>> command_status_callbacks;
  std::map<EventCode, common::ContextualCallback<void(EventView)>> registered_events_;
  std::map<SubeventCode, common::ContextualCallback<void(LeMetaEventView)>> registered_le_events_;

  // Most operations must acquire this mutex before manipulating shared state. The ONLY exception is blocking on a
  // promise, IF your thread is the only one mutating it. Note that SETTING a promise REQUIRES a lock, since another
  // thread may replace the promise while you are doing so.
  mutable std::mutex mutex_{};

  // Shared state between the test and stack threads
  std::queue<std::unique_ptr<CommandBuilder>> command_queue_;
  std::unique_ptr<std::promise<void>> command_promise_;
  std::unique_ptr<std::future<void>> command_future_;
  mutable std::mutex mutex_;
  uint16_t command_count_ = 0;

  // We start with Consumed=Set, Command=Unset.
  // When a command is enqueued, we set Command=set
  // When a command is popped, we block until Command=Set, then (if the queue is now empty) we reset Command=Unset and
  // set Consumed=Set. This way we emulate a blocking queue.
  std::promise<void> command_promise_{};                              // Set when at least one command is in the queue
  std::future<void> command_future_ = command_promise_.get_future();  // GetCommand() blocks until this is fulfilled

  CommandView empty_command_view_ =
      CommandView::Create(PacketView<packet::kLittleEndian>(std::make_shared<std::vector<uint8_t>>()));
};
+0 −34
Original line number Diff line number Diff line
@@ -271,7 +271,6 @@ class LeAdvertisingAPITest : public LeAdvertisingManagerTest {
    advertising_config.scan_response = gap_data;
    advertising_config.channel_map = 1;

    ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(4));
    advertiser_id_ = le_advertising_manager_->ExtendedCreateAdvertiser(
        0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
    ASSERT_NE(LeAdvertisingManager::kInvalidId, advertiser_id_);
@@ -329,7 +328,6 @@ class LeAndroidHciAdvertisingAPITest : public LeAndroidHciAdvertisingManagerTest
    advertising_config.scan_response = gap_data;
    advertising_config.channel_map = 1;

    ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(5));
    advertiser_id_ = le_advertising_manager_->ExtendedCreateAdvertiser(
        0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
    ASSERT_NE(LeAdvertisingManager::kInvalidId, advertiser_id_);
@@ -376,7 +374,6 @@ class LeAndroidHciAdvertisingAPIPublicAddressTest : public LeAndroidHciAdvertisi
    advertising_config.channel_map = 1;

    test_acl_manager_->SetAddressPolicy(LeAddressManager::AddressPolicy::USE_PUBLIC_ADDRESS);
    ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(4));
    advertiser_id_ = le_advertising_manager_->ExtendedCreateAdvertiser(
        0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
    ASSERT_NE(LeAdvertisingManager::kInvalidId, advertiser_id_);
@@ -432,7 +429,6 @@ class LeExtendedAdvertisingAPITest : public LeExtendedAdvertisingManagerTest {
    advertising_config.channel_map = 1;
    advertising_config.sid = 0x01;

    ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(4));
    advertiser_id_ = le_advertising_manager_->ExtendedCreateAdvertiser(
        0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
    ASSERT_NE(LeAdvertisingManager::kInvalidId, advertiser_id_);
@@ -484,7 +480,6 @@ TEST_F(LeAdvertisingManagerTest, create_advertiser_test) {
  advertising_config.scan_response = gap_data;
  advertising_config.channel_map = 1;

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(4));
  auto id = le_advertising_manager_->ExtendedCreateAdvertiser(
      0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
  ASSERT_NE(LeAdvertisingManager::kInvalidId, id);
@@ -511,7 +506,6 @@ TEST_F(LeAdvertisingManagerTest, create_advertiser_test) {
  }

  // Disable the advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->RemoveAdvertiser(id);
  ASSERT_EQ(OpCode::LE_SET_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
}
@@ -532,7 +526,6 @@ TEST_F(LeAndroidHciAdvertisingManagerTest, create_advertiser_test) {
  advertising_config.scan_response = gap_data;
  advertising_config.channel_map = 1;

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(5));
  auto id = le_advertising_manager_->ExtendedCreateAdvertiser(
      0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
  ASSERT_NE(LeAdvertisingManager::kInvalidId, id);
@@ -554,7 +547,6 @@ TEST_F(LeAndroidHciAdvertisingManagerTest, create_advertiser_test) {
  }

  // Disable the advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->RemoveAdvertiser(id);
  ASSERT_EQ(OpCode::LE_MULTI_ADVT, test_hci_layer_->GetCommand().GetOpCode());
  test_hci_layer_->IncomingEvent(LeMultiAdvtSetEnableCompleteBuilder::Create(uint8_t{1}, ErrorCode::SUCCESS));
@@ -577,7 +569,6 @@ TEST_F(LeExtendedAdvertisingManagerTest, create_advertiser_test) {
  advertising_config.channel_map = 1;
  advertising_config.sid = 0x01;

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(4));
  auto id = le_advertising_manager_->ExtendedCreateAdvertiser(
      0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
  ASSERT_NE(LeAdvertisingManager::kInvalidId, id);
@@ -604,7 +595,6 @@ TEST_F(LeExtendedAdvertisingManagerTest, create_advertiser_test) {
  sync_client_handler();

  // Remove the advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(3));
  le_advertising_manager_->RemoveAdvertiser(id);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
@@ -632,7 +622,6 @@ TEST_F(LeExtendedAdvertisingManagerTest, ignore_on_pause_on_resume_after_unregis
  advertising_config.channel_map = 1;
  advertising_config.sid = 0x01;

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(4));
  auto id = le_advertising_manager_->ExtendedCreateAdvertiser(
      0x00, advertising_config, scan_callback, set_terminated_callback, 0, 0, client_handler_);
  ASSERT_NE(LeAdvertisingManager::kInvalidId, id);
@@ -659,7 +648,6 @@ TEST_F(LeExtendedAdvertisingManagerTest, ignore_on_pause_on_resume_after_unregis
  sync_client_handler();

  // Unregister LeAddressManager vai RemoveAdvertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(3));
  le_advertising_manager_->RemoveAdvertiser(id);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
@@ -694,7 +682,6 @@ TEST_F(LeAdvertisingAPITest, set_parameter) {
  gap_data.push_back(data_item);
  advertising_config.advertisement = gap_data;
  advertising_config.channel_map = 1;
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetParameters(advertiser_id_, advertising_config);
  ASSERT_EQ(OpCode::LE_SET_ADVERTISING_PARAMETERS, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -714,7 +701,6 @@ TEST_F(LeAndroidHciAdvertisingAPITest, set_parameter) {
  gap_data.push_back(data_item);
  advertising_config.advertisement = gap_data;
  advertising_config.channel_map = 1;
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetParameters(advertiser_id_, advertising_config);
  auto packet = test_hci_layer_->GetCommand();
  auto sub_packet = LeMultiAdvtView::Create(LeAdvertisingCommandView::Create(packet));
@@ -739,7 +725,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_parameter) {
  advertising_config.channel_map = 1;
  advertising_config.sid = 0x01;
  advertising_config.tx_power = 0x08;
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetParameters(advertiser_id_, advertising_config);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_PARAMETERS, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -756,7 +741,6 @@ TEST_F(LeAdvertisingAPITest, set_data_test) {
  data_item.data_type_ = GapDataType::TX_POWER_LEVEL;
  data_item.data_ = {0x00};
  advertising_data.push_back(data_item);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetData(advertiser_id_, false, advertising_data);
  ASSERT_EQ(OpCode::LE_SET_ADVERTISING_DATA, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -770,7 +754,6 @@ TEST_F(LeAdvertisingAPITest, set_data_test) {
  data_item2.data_type_ = GapDataType::COMPLETE_LOCAL_NAME;
  data_item2.data_ = {'t', 'e', 's', 't', ' ', 'd', 'e', 'v', 'i', 'c', 'e'};
  response_data.push_back(data_item2);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetData(advertiser_id_, true, response_data);
  ASSERT_EQ(OpCode::LE_SET_SCAN_RESPONSE_DATA, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -786,7 +769,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_data_test) {
  data_item.data_type_ = GapDataType::TX_POWER_LEVEL;
  data_item.data_ = {0x00};
  advertising_data.push_back(data_item);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetData(advertiser_id_, false, advertising_data);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_DATA, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -800,7 +782,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_data_test) {
  data_item2.data_type_ = GapDataType::COMPLETE_LOCAL_NAME;
  data_item2.data_ = {'t', 'e', 's', 't', ' ', 'd', 'e', 'v', 'i', 'c', 'e'};
  response_data.push_back(data_item2);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetData(advertiser_id_, true, response_data);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_SCAN_RESPONSE_DATA, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -816,7 +797,6 @@ TEST_F(LeAndroidHciAdvertisingAPITest, set_data_test) {
  data_item.data_type_ = GapDataType::TX_POWER_LEVEL;
  data_item.data_ = {0x00};
  advertising_data.push_back(data_item);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetData(advertiser_id_, false, advertising_data);
  auto packet = test_hci_layer_->GetCommand();
  auto sub_packet = LeMultiAdvtView::Create(LeAdvertisingCommandView::Create(packet));
@@ -833,7 +813,6 @@ TEST_F(LeAndroidHciAdvertisingAPITest, set_data_test) {
  data_item2.data_type_ = GapDataType::COMPLETE_LOCAL_NAME;
  data_item2.data_ = {'t', 'e', 's', 't', ' ', 'd', 'e', 'v', 'i', 'c', 'e'};
  response_data.push_back(data_item2);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetData(advertiser_id_, true, response_data);
  packet = test_hci_layer_->GetCommand();
  sub_packet = LeMultiAdvtView::Create(LeAdvertisingCommandView::Create(packet));
@@ -861,7 +840,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_data_fragments_test) {
  }
  le_advertising_manager_->SetData(advertiser_id_, false, advertising_data);

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(3));
  // First fragment
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_DATA, test_hci_layer_->GetCommand().GetOpCode());
  // Intermediate fragment
@@ -892,7 +870,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_scan_response_fragments_test) {
  }
  le_advertising_manager_->SetData(advertiser_id_, true, advertising_data);

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(3));
  // First fragment
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_SCAN_RESPONSE_DATA, test_hci_layer_->GetCommand().GetOpCode());
  // Intermediate fragment
@@ -963,7 +940,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_data_with_invalid_length) {

TEST_F(LeAdvertisingAPITest, disable_enable_advertiser_test) {
  // disable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnableAdvertiser(advertiser_id_, false, 0x00, 0x00);
  ASSERT_EQ(OpCode::LE_SET_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -973,7 +949,6 @@ TEST_F(LeAdvertisingAPITest, disable_enable_advertiser_test) {
  sync_client_handler();

  // enable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnableAdvertiser(advertiser_id_, true, 0x00, 0x00);
  ASSERT_EQ(OpCode::LE_SET_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -984,7 +959,6 @@ TEST_F(LeAdvertisingAPITest, disable_enable_advertiser_test) {

TEST_F(LeAndroidHciAdvertisingAPITest, disable_enable_advertiser_test) {
  // disable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnableAdvertiser(advertiser_id_, false, 0x00, 0x00);
  auto packet = test_hci_layer_->GetCommand();
  auto sub_packet = LeMultiAdvtView::Create(LeAdvertisingCommandView::Create(packet));
@@ -998,7 +972,6 @@ TEST_F(LeAndroidHciAdvertisingAPITest, disable_enable_advertiser_test) {
  sync_client_handler();

  // enable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnableAdvertiser(advertiser_id_, true, 0x00, 0x00);
  packet = test_hci_layer_->GetCommand();
  sub_packet = LeMultiAdvtView::Create(LeAdvertisingCommandView::Create(packet));
@@ -1013,7 +986,6 @@ TEST_F(LeAndroidHciAdvertisingAPITest, disable_enable_advertiser_test) {

TEST_F(LeExtendedAdvertisingAPITest, disable_enable_advertiser_test) {
  // disable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnableAdvertiser(advertiser_id_, false, 0x00, 0x00);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -1023,7 +995,6 @@ TEST_F(LeExtendedAdvertisingAPITest, disable_enable_advertiser_test) {
  sync_client_handler();

  // enable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnableAdvertiser(advertiser_id_, true, 0x00, 0x00);
  ASSERT_EQ(OpCode::LE_SET_EXTENDED_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -1036,7 +1007,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_periodic_parameter) {
  PeriodicAdvertisingParameters advertising_config{};
  advertising_config.max_interval = 0x1000;
  advertising_config.min_interval = 0x0006;
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetPeriodicParameters(advertiser_id_, advertising_config);
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_PARAM, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -1053,7 +1023,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_periodic_data_test) {
  data_item.data_type_ = GapDataType::TX_POWER_LEVEL;
  data_item.data_ = {0x00};
  advertising_data.push_back(data_item);
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->SetPeriodicData(advertiser_id_, advertising_data);
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_DATA, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -1078,7 +1047,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_periodic_data_fragments_test) {
  }
  le_advertising_manager_->SetPeriodicData(advertiser_id_, advertising_data);

  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(3));
  // First fragment
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_DATA, test_hci_layer_->GetCommand().GetOpCode());
  // Intermediate fragment
@@ -1137,7 +1105,6 @@ TEST_F(LeExtendedAdvertisingAPITest, set_perodic_data_with_invalid_length) {

TEST_F(LeExtendedAdvertisingAPITest, disable_enable_periodic_advertiser_test) {
  // disable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnablePeriodicAdvertising(advertiser_id_, false, false);
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(
@@ -1147,7 +1114,6 @@ TEST_F(LeExtendedAdvertisingAPITest, disable_enable_periodic_advertiser_test) {
  sync_client_handler();

  // enable advertiser
  ASSERT_NO_FATAL_FAILURE(test_hci_layer_->SetCommandFuture(1));
  le_advertising_manager_->EnablePeriodicAdvertising(advertiser_id_, true, false);
  ASSERT_EQ(OpCode::LE_SET_PERIODIC_ADVERTISING_ENABLE, test_hci_layer_->GetCommand().GetOpCode());
  EXPECT_CALL(