Loading system/gd/l2cap/le/internal/fixed_channel_impl_test.cc +54 −9 Original line number Original line Diff line number Diff line Loading @@ -62,7 +62,12 @@ class L2capLeFixedChannelImplTest : public ::testing::Test { TEST_F(L2capLeFixedChannelImplTest, get_device) { TEST_F(L2capLeFixedChannelImplTest, get_device) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); LOG_INFO("------------------"); LOG_INFO("------------------"); Loading @@ -72,7 +77,12 @@ TEST_F(L2capLeFixedChannelImplTest, get_device) { TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) { TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -93,7 +103,12 @@ TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) { TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_immediately) { TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_immediately) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -114,7 +129,12 @@ TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_im TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) { TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -138,7 +158,12 @@ TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) { TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -158,7 +183,12 @@ TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -167,7 +197,12 @@ TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fai TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -176,7 +211,12 @@ TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fai TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) { TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading Loading @@ -204,7 +244,12 @@ TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) { TEST_F(L2capLeFixedChannelImplTest, test_acquire_after_close) { TEST_F(L2capLeFixedChannelImplTest, test_acquire_after_close) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading system/gd/l2cap/le/internal/link_mock.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -33,8 +33,10 @@ using hci::testing::MockAclConnection; class MockLink : public Link { class MockLink : public Link { public: public: explicit MockLink(os::Handler* handler, l2cap::internal::ParameterProvider* parameter_provider) explicit MockLink(os::Handler* handler, l2cap::internal::ParameterProvider* parameter_provider, : Link(handler, std::make_unique<MockAclConnection>(), parameter_provider, nullptr, nullptr){}; std::unique_ptr<MockAclConnection> mock_acl_connection) : Link(handler, std::move(mock_acl_connection), parameter_provider, nullptr, nullptr){}; MOCK_METHOD(hci::AddressWithType, GetDevice, (), (override)); MOCK_METHOD(hci::AddressWithType, GetDevice, (), (override)); MOCK_METHOD(hci::Role, GetRole, (), (override)); MOCK_METHOD(hci::Role, GetRole, (), (override)); MOCK_METHOD(void, OnAclDisconnected, (hci::ErrorCode status), (override)); MOCK_METHOD(void, OnAclDisconnected, (hci::ErrorCode status), (override)); Loading Loading
system/gd/l2cap/le/internal/fixed_channel_impl_test.cc +54 −9 Original line number Original line Diff line number Diff line Loading @@ -62,7 +62,12 @@ class L2capLeFixedChannelImplTest : public ::testing::Test { TEST_F(L2capLeFixedChannelImplTest, get_device) { TEST_F(L2capLeFixedChannelImplTest, get_device) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); LOG_INFO("------------------"); LOG_INFO("------------------"); Loading @@ -72,7 +77,12 @@ TEST_F(L2capLeFixedChannelImplTest, get_device) { TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) { TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -93,7 +103,12 @@ TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) { TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_immediately) { TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_immediately) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -114,7 +129,12 @@ TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_im TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) { TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -138,7 +158,12 @@ TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) { TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -158,7 +183,12 @@ TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -167,7 +197,12 @@ TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fai TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fail) { TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fail) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading @@ -176,7 +211,12 @@ TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fai TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) { TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading Loading @@ -204,7 +244,12 @@ TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) { TEST_F(L2capLeFixedChannelImplTest, test_acquire_after_close) { TEST_F(L2capLeFixedChannelImplTest, test_acquire_after_close) { MockParameterProvider mock_parameter_provider; MockParameterProvider mock_parameter_provider; MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider); EXPECT_CALL(mock_parameter_provider, GetLeLinkIdleDisconnectTimeout()).Times(1); testing::MockAclConnection* mock_acl_connection = new testing::MockAclConnection(); EXPECT_CALL(*mock_acl_connection, GetAddress()).Times(1); EXPECT_CALL(*mock_acl_connection, GetAddressType()).Times(1); MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider, std::unique_ptr<testing::MockAclConnection>(mock_acl_connection)); AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS}; EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device)); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_); Loading
system/gd/l2cap/le/internal/link_mock.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -33,8 +33,10 @@ using hci::testing::MockAclConnection; class MockLink : public Link { class MockLink : public Link { public: public: explicit MockLink(os::Handler* handler, l2cap::internal::ParameterProvider* parameter_provider) explicit MockLink(os::Handler* handler, l2cap::internal::ParameterProvider* parameter_provider, : Link(handler, std::make_unique<MockAclConnection>(), parameter_provider, nullptr, nullptr){}; std::unique_ptr<MockAclConnection> mock_acl_connection) : Link(handler, std::move(mock_acl_connection), parameter_provider, nullptr, nullptr){}; MOCK_METHOD(hci::AddressWithType, GetDevice, (), (override)); MOCK_METHOD(hci::AddressWithType, GetDevice, (), (override)); MOCK_METHOD(hci::Role, GetRole, (), (override)); MOCK_METHOD(hci::Role, GetRole, (), (override)); MOCK_METHOD(void, OnAclDisconnected, (hci::ErrorCode status), (override)); MOCK_METHOD(void, OnAclDisconnected, (hci::ErrorCode status), (override)); Loading