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

Commit a4a52e1d authored by David Duarte's avatar David Duarte
Browse files

GD: Use gtest ASSERT in SetCommandFuture

Test: None
Change-Id: Ic3add8e1925ab4b1deddd32ae9fe23a2edb3e1a6
parent 2749dae5
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ class TestHciLayer : public HciLayer {
  }

  void SetCommandFuture() {
    ASSERT_LOG(command_promise_ == nullptr, "Promises, Promises, ... Only one at a time.");
    ASSERT_EQ(command_promise_, nullptr) << "Promises, Promises, ... Only one at a time.";
    command_promise_ = std::make_unique<std::promise<void>>();
    command_future_ = std::make_unique<std::future<void>>(command_promise_->get_future());
  }
@@ -447,7 +447,7 @@ class LeImplTest : public ::testing::Test {

  void set_random_device_address_policy() {
    // Set address policy
    hci_layer_->SetCommandFuture();
    ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
    hci::Address address;
    Address::FromString("D0:05:04:03:02:01", address);
    hci::AddressWithType address_with_type(address, hci::AddressType::RANDOM_DEVICE_ADDRESS);
@@ -649,11 +649,11 @@ TEST_F(LeImplTest, connection_complete_with_periperal_role) {
  set_random_device_address_policy();

  // Create connection
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  le_impl_->create_le_connection(
      {{0x21, 0x22, 0x23, 0x24, 0x25, 0x26}, AddressType::PUBLIC_DEVICE_ADDRESS}, true, false);
  hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST);
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  hci_layer_->CommandCompleteCallback(LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
  hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION);
  hci_layer_->CommandStatusCallback(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));
@@ -688,11 +688,11 @@ TEST_F(LeImplTest, enhanced_connection_complete_with_periperal_role) {

  controller_->AddSupported(OpCode::LE_EXTENDED_CREATE_CONNECTION);
  // Create connection
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  le_impl_->create_le_connection(
      {{0x21, 0x22, 0x23, 0x24, 0x25, 0x26}, AddressType::PUBLIC_DEVICE_ADDRESS}, true, false);
  hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST);
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  hci_layer_->CommandCompleteCallback(LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
  hci_layer_->GetCommand(OpCode::LE_EXTENDED_CREATE_CONNECTION);
  hci_layer_->CommandStatusCallback(LeExtendedCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));
@@ -731,10 +731,10 @@ TEST_F(LeImplTest, connection_complete_with_central_role) {
  Address::FromString("D0:05:04:03:02:01", remote_address);
  hci::AddressWithType address_with_type(remote_address, hci::AddressType::PUBLIC_DEVICE_ADDRESS);
  // Create connection
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  le_impl_->create_le_connection(address_with_type, true, false);
  hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST);
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  hci_layer_->CommandCompleteCallback(LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
  hci_layer_->GetCommand(OpCode::LE_CREATE_CONNECTION);
  hci_layer_->CommandStatusCallback(LeCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));
@@ -769,10 +769,10 @@ TEST_F(LeImplTest, enhanced_connection_complete_with_central_role) {
  Address::FromString("D0:05:04:03:02:01", remote_address);
  hci::AddressWithType address_with_type(remote_address, hci::AddressType::PUBLIC_DEVICE_ADDRESS);
  // Create connection
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  le_impl_->create_le_connection(address_with_type, true, false);
  hci_layer_->GetCommand(OpCode::LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST);
  hci_layer_->SetCommandFuture();
  ASSERT_NO_FATAL_FAILURE(hci_layer_->SetCommandFuture());
  hci_layer_->CommandCompleteCallback(LeAddDeviceToFilterAcceptListCompleteBuilder::Create(0x01, ErrorCode::SUCCESS));
  hci_layer_->GetCommand(OpCode::LE_EXTENDED_CREATE_CONNECTION);
  hci_layer_->CommandStatusCallback(LeExtendedCreateConnectionStatusBuilder::Create(ErrorCode::SUCCESS, 0x01));
+9 −8
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ class RoundRobinSchedulerTest : public ::testing::Test {
  }

  void SetPacketFuture(uint16_t count) {
    ASSERT_LOG(packet_promise_ == nullptr, "Promises, Promises, ... Only one at a time.");
    ASSERT_EQ(packet_promise_, nullptr) << "Promises, Promises, ... Only one at a time.";
    packet_count_ = count;
    packet_promise_ = std::make_unique<std::promise<void>>();
    packet_future_ = std::make_unique<std::future<void>>(packet_promise_->get_future());
@@ -186,7 +186,7 @@ TEST_F(RoundRobinSchedulerTest, buffer_packet) {
  auto connection_queue = std::make_shared<AclConnection::Queue>(10);
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::CLASSIC, handle, connection_queue);

  SetPacketFuture(2);
  ASSERT_NO_FATAL_FAILURE(SetPacketFuture(2));
  AclConnection::QueueUpEnd* queue_up_end = connection_queue->GetUpEnd();
  std::vector<uint8_t> packet1 = {0x01, 0x02, 0x03};
  std::vector<uint8_t> packet2 = {0x04, 0x05, 0x06};
@@ -210,7 +210,7 @@ TEST_F(RoundRobinSchedulerTest, buffer_packet_from_two_connections) {
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::CLASSIC, handle, connection_queue);
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::LE, le_handle, le_connection_queue);

  SetPacketFuture(2);
  ASSERT_NO_FATAL_FAILURE(SetPacketFuture(2));
  AclConnection::QueueUpEnd* queue_up_end = connection_queue->GetUpEnd();
  AclConnection::QueueUpEnd* le_queue_up_end = le_connection_queue->GetUpEnd();
  std::vector<uint8_t> packet = {0x01, 0x02, 0x03};
@@ -233,7 +233,7 @@ TEST_F(RoundRobinSchedulerTest, do_not_register_when_credits_is_zero) {
  auto connection_queue = std::make_shared<AclConnection::Queue>(15);
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::CLASSIC, handle, connection_queue);

  SetPacketFuture(10);
  ASSERT_NO_FATAL_FAILURE(SetPacketFuture(10));
  AclConnection::QueueUpEnd* queue_up_end = connection_queue->GetUpEnd();
  for (uint8_t i = 0; i < 15; i++) {
    std::vector<uint8_t> packet = {0x01, 0x02, 0x03, i};
@@ -247,7 +247,7 @@ TEST_F(RoundRobinSchedulerTest, do_not_register_when_credits_is_zero) {
  }
  ASSERT_EQ(round_robin_scheduler_->GetCredits(), 0);

  SetPacketFuture(5);
  ASSERT_NO_FATAL_FAILURE(SetPacketFuture(5));
  controller_->SendCompletedAclPacketsCallback(0x01, 10);
  sync_handler();
  packet_future_->wait();
@@ -277,7 +277,7 @@ TEST_F(RoundRobinSchedulerTest, buffer_packet_intervally) {
  auto le_connection_queue1 = std::make_shared<AclConnection::Queue>(10);
  auto le_connection_queue2 = std::make_shared<AclConnection::Queue>(10);

  SetPacketFuture(18);
  ASSERT_NO_FATAL_FAILURE(SetPacketFuture(18));
  AclConnection::QueueUpEnd* queue_up_end1 = connection_queue1->GetUpEnd();
  AclConnection::QueueUpEnd* queue_up_end2 = connection_queue2->GetUpEnd();
  AclConnection::QueueUpEnd* le_queue_up_end1 = le_connection_queue1->GetUpEnd();
@@ -334,7 +334,7 @@ TEST_F(RoundRobinSchedulerTest, send_fragments_without_interval) {
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::CLASSIC, handle, connection_queue);
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::LE, le_handle, le_connection_queue);

  SetPacketFuture(5);
  ASSERT_NO_FATAL_FAILURE(SetPacketFuture(5));
  AclConnection::QueueUpEnd* queue_up_end = connection_queue->GetUpEnd();
  AclConnection::QueueUpEnd* le_queue_up_end = le_connection_queue->GetUpEnd();
  std::vector<uint8_t> packet(controller_->hci_mtu_, 0xff);
@@ -380,7 +380,8 @@ TEST_F(RoundRobinSchedulerTest, receive_le_credit_when_next_fragment_is_classic)
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::CLASSIC, handle, connection_queue);
  round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::LE, le_handle, le_connection_queue);

  SetPacketFuture(controller_->le_max_acl_packet_credits_ + controller_->max_acl_packet_credits_);
  ASSERT_NO_FATAL_FAILURE(
      SetPacketFuture(controller_->le_max_acl_packet_credits_ + controller_->max_acl_packet_credits_));
  AclConnection::QueueUpEnd* queue_up_end = connection_queue->GetUpEnd();
  AclConnection::QueueUpEnd* le_queue_up_end = le_connection_queue->GetUpEnd();
  std::vector<uint8_t> huge_packet(2000);
Loading