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

Commit e823e910 authored by Hansong Zhang's avatar Hansong Zhang Committed by android-build-merger
Browse files

MockAclConnection: Use a real queue for testing am: 1543a7d5 am: 0bdf3ed7

am: 1d867d35

Change-Id: Ib38cb30028a94ccbfe4ee77fb555fb5d5c8a3118
parents 30da4035 1d867d35
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -32,7 +32,10 @@ class MockAclConnection : public AclConnection {
              (common::OnceCallback<void(ErrorCode)> on_disconnect, os::Handler* handler), (override));
  MOCK_METHOD(bool, Disconnect, (DisconnectReason reason), (override));
  MOCK_METHOD(void, Finish, (), (override));
  MOCK_METHOD(QueueUpEnd*, GetAclQueueEnd, (), (const, override));
  QueueUpEnd* GetAclQueueEnd() const override {
    return acl_queue_.GetUpEnd();
  }
  mutable common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder> acl_queue_{10};
};

class MockAclManager : public AclManager {
+0 −8
Original line number Diff line number Diff line
@@ -119,8 +119,6 @@ TEST_F(L2capClassicLinkManagerTest, connect_fixed_channel_service_without_acl) {
  // Step 3: ACL connection success event should trigger channel creation for all registered services

  std::unique_ptr<MockAclConnection> acl_connection = std::make_unique<MockAclConnection>();
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, RegisterDisconnectCallback(_, l2cap_handler_)).Times(1);
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(device));
  std::unique_ptr<FixedChannel> channel_1, channel_2;
@@ -279,8 +277,6 @@ TEST_F(L2capClassicLinkManagerTest, not_acquiring_channels_should_disconnect_acl
  // Step 3: ACL connection success event should trigger channel creation for all registered services
  auto* raw_acl_connection = new MockAclConnection();
  std::unique_ptr<MockAclConnection> acl_connection(raw_acl_connection);
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(device));
  std::unique_ptr<FixedChannel> channel_1, channel_2;
  EXPECT_CALL(mock_service_1, NotifyChannelCreation(_)).WillOnce([&channel_1](std::unique_ptr<FixedChannel> channel) {
@@ -349,8 +345,6 @@ TEST_F(L2capClassicLinkManagerTest, acquiring_channels_should_not_disconnect_acl
  // Step 3: ACL connection success event should trigger channel creation for all registered services
  auto* raw_acl_connection = new MockAclConnection();
  std::unique_ptr<MockAclConnection> acl_connection(raw_acl_connection);
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(device));
  std::unique_ptr<FixedChannel> channel_1, channel_2;
  EXPECT_CALL(mock_service_1, NotifyChannelCreation(_)).WillOnce([&channel_1](std::unique_ptr<FixedChannel> channel) {
@@ -421,8 +415,6 @@ TEST_F(L2capClassicLinkManagerTest, acquiring_and_releasing_channels_should_even
  // Step 3: ACL connection success event should trigger channel creation for all registered services
  auto* raw_acl_connection = new MockAclConnection();
  std::unique_ptr<MockAclConnection> acl_connection(raw_acl_connection);
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(device));
  std::unique_ptr<FixedChannel> channel_1, channel_2;
  EXPECT_CALL(mock_service_1, NotifyChannelCreation(_)).WillOnce([&channel_1](std::unique_ptr<FixedChannel> channel) {
+0 −8
Original line number Diff line number Diff line
@@ -117,8 +117,6 @@ TEST_F(L2capLeLinkManagerTest, connect_fixed_channel_service_without_acl) {
  // Step 3: ACL connection success event should trigger channel creation for all registered services

  std::unique_ptr<MockAclConnection> acl_connection = std::make_unique<MockAclConnection>();
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, RegisterDisconnectCallback(_, l2cap_handler_)).Times(1);
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(address_with_type.GetAddress()));
  EXPECT_CALL(*acl_connection, GetAddressType()).WillRepeatedly(Return(address_with_type.GetAddressType()));
@@ -282,8 +280,6 @@ TEST_F(L2capLeLinkManagerTest, not_acquiring_channels_should_disconnect_acl_afte
  // Step 3: ACL connection success event should trigger channel creation for all registered services
  auto* raw_acl_connection = new MockAclConnection();
  std::unique_ptr<MockAclConnection> acl_connection(raw_acl_connection);
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(address_with_type.GetAddress()));
  EXPECT_CALL(*acl_connection, GetAddressType()).WillRepeatedly(Return(address_with_type.GetAddressType()));
  std::unique_ptr<FixedChannel> channel_1, channel_2;
@@ -355,8 +351,6 @@ TEST_F(L2capLeLinkManagerTest, acquiring_channels_should_not_disconnect_acl_afte
  // Step 3: ACL connection success event should trigger channel creation for all registered services
  auto* raw_acl_connection = new MockAclConnection();
  std::unique_ptr<MockAclConnection> acl_connection(raw_acl_connection);
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(address_with_type.GetAddress()));
  EXPECT_CALL(*acl_connection, GetAddressType()).WillRepeatedly(Return(address_with_type.GetAddressType()));
  std::unique_ptr<FixedChannel> channel_1, channel_2;
@@ -430,8 +424,6 @@ TEST_F(L2capLeLinkManagerTest, acquiring_and_releasing_channels_should_eventuall
  // Step 3: ACL connection success event should trigger channel creation for all registered services
  auto* raw_acl_connection = new MockAclConnection();
  std::unique_ptr<MockAclConnection> acl_connection(raw_acl_connection);
  hci::AclConnection::Queue link_queue{10};
  EXPECT_CALL(*acl_connection, GetAclQueueEnd()).WillRepeatedly((Return(link_queue.GetUpEnd())));
  EXPECT_CALL(*acl_connection, GetAddress()).WillRepeatedly(Return(address_with_type.GetAddress()));
  EXPECT_CALL(*acl_connection, GetAddressType()).WillRepeatedly(Return(address_with_type.GetAddressType()));
  std::unique_ptr<FixedChannel> channel_1, channel_2;