Loading system/stack/acl/peer_packet_types.h +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ class PeerPacketTypes { struct { uint16_t supported{0}; uint16_t unsupported{0}; } acl, sco; } acl{.supported = (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1)}, sco{}; PeerPacketTypes(const BD_FEATURES& features) { /* 3 and 5 slot packets? */ Loading system/stack/test/btm/peer_packet_types_test.cc +5 −5 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ TEST_F(PeerPacketTest, all_ones) { const BD_FEATURES bd_features = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0xcc00); ASSERT_EQ(peer_packet_types.acl.supported, 0xcc18); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x0); } Loading @@ -55,7 +55,7 @@ TEST_F(PeerPacketTest, 3SLOT_DH3_DM3) { const BD_FEATURES bd_features = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0x0c00); ASSERT_EQ(peer_packet_types.acl.supported, 0x0c18); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3306); } Loading @@ -63,7 +63,7 @@ TEST_F(PeerPacketTest, 5SLOT_DH5_DM5) { const BD_FEATURES bd_features = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0xc000); ASSERT_EQ(peer_packet_types.acl.supported, 0xc018); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3306); } Loading @@ -71,7 +71,7 @@ TEST_F(PeerPacketTest, 2Mb_support) { const BD_FEATURES bd_features = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0x0000); ASSERT_EQ(peer_packet_types.acl.supported, 0x0018); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3304); } Loading @@ -79,7 +79,7 @@ TEST_F(PeerPacketTest, 3Mb_support) { const BD_FEATURES bd_features = {0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0x0000); ASSERT_EQ(peer_packet_types.acl.supported, 0x0018); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3302); } Loading system/stack/test/btm/stack_btm_test.cc +14 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> #include <iomanip> #include <iostream> #include <map> #include <vector> Loading @@ -33,6 +35,7 @@ #include "stack/include/acl_api.h" #include "stack/include/acl_hci_link_interface.h" #include "stack/include/btm_client_interface.h" #include "stack/include/hcidefs.h" #include "stack/l2cap/l2c_int.h" #include "test/mock/mock_hcic_hcicmds.h" #include "types/raw_address.h" Loading Loading @@ -95,6 +98,12 @@ using testing::StrEq; using testing::StrictMock; using testing::Test; std::string Hex16(int n) { std::ostringstream oss; oss << "0x" << std::hex << std::setw(4) << std::setfill('0') << n; return oss.str(); } class StackBtmTest : public Test { public: protected: Loading Loading @@ -168,20 +177,21 @@ TEST_F(StackBtmTest, change_packet_type) { btm_set_packet_types_from_address(bda, pkt_types); ASSERT_EQ(++cnt, mock_function_count_map["btsnd_hcic_change_conn_type"]); ASSERT_EQ(0x123, mock::btsnd_hcic_change_conn_type.handle); ASSERT_EQ(0x4400, mock::btsnd_hcic_change_conn_type.packet_types); ASSERT_EQ(Hex16(0x4400 | HCI_PKT_TYPES_MASK_DM1), Hex16(mock::btsnd_hcic_change_conn_type.packet_types)); mock::btsnd_hcic_change_conn_type = {}; btm_set_packet_types_from_address(bda, 0xffff); ASSERT_EQ(++cnt, mock_function_count_map["btsnd_hcic_change_conn_type"]); ASSERT_EQ(0x123, mock::btsnd_hcic_change_conn_type.handle); ASSERT_EQ(0xcc00, mock::btsnd_hcic_change_conn_type.packet_types); ASSERT_EQ(Hex16(0xcc00 | HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1), Hex16(mock::btsnd_hcic_change_conn_type.packet_types)); mock::btsnd_hcic_change_conn_type = {}; btm_set_packet_types_from_address(bda, 0x0); // NOTE: The call should not be executed with no bits set ASSERT_EQ(0x0, mock::btsnd_hcic_change_conn_type.handle); ASSERT_EQ(0x0, mock::btsnd_hcic_change_conn_type.packet_types); ASSERT_EQ(Hex16(0x0), Hex16(mock::btsnd_hcic_change_conn_type.packet_types)); get_btm_client_interface().lifecycle.btm_free(); } Loading Loading
system/stack/acl/peer_packet_types.h +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ class PeerPacketTypes { struct { uint16_t supported{0}; uint16_t unsupported{0}; } acl, sco; } acl{.supported = (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1)}, sco{}; PeerPacketTypes(const BD_FEATURES& features) { /* 3 and 5 slot packets? */ Loading
system/stack/test/btm/peer_packet_types_test.cc +5 −5 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ TEST_F(PeerPacketTest, all_ones) { const BD_FEATURES bd_features = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0xcc00); ASSERT_EQ(peer_packet_types.acl.supported, 0xcc18); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x0); } Loading @@ -55,7 +55,7 @@ TEST_F(PeerPacketTest, 3SLOT_DH3_DM3) { const BD_FEATURES bd_features = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0x0c00); ASSERT_EQ(peer_packet_types.acl.supported, 0x0c18); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3306); } Loading @@ -63,7 +63,7 @@ TEST_F(PeerPacketTest, 5SLOT_DH5_DM5) { const BD_FEATURES bd_features = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0xc000); ASSERT_EQ(peer_packet_types.acl.supported, 0xc018); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3306); } Loading @@ -71,7 +71,7 @@ TEST_F(PeerPacketTest, 2Mb_support) { const BD_FEATURES bd_features = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0x0000); ASSERT_EQ(peer_packet_types.acl.supported, 0x0018); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3304); } Loading @@ -79,7 +79,7 @@ TEST_F(PeerPacketTest, 3Mb_support) { const BD_FEATURES bd_features = {0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; PeerPacketTypes peer_packet_types(bd_features); ASSERT_EQ(peer_packet_types.acl.supported, 0x0000); ASSERT_EQ(peer_packet_types.acl.supported, 0x0018); ASSERT_EQ(peer_packet_types.acl.unsupported, 0x3302); } Loading
system/stack/test/btm/stack_btm_test.cc +14 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> #include <iomanip> #include <iostream> #include <map> #include <vector> Loading @@ -33,6 +35,7 @@ #include "stack/include/acl_api.h" #include "stack/include/acl_hci_link_interface.h" #include "stack/include/btm_client_interface.h" #include "stack/include/hcidefs.h" #include "stack/l2cap/l2c_int.h" #include "test/mock/mock_hcic_hcicmds.h" #include "types/raw_address.h" Loading Loading @@ -95,6 +98,12 @@ using testing::StrEq; using testing::StrictMock; using testing::Test; std::string Hex16(int n) { std::ostringstream oss; oss << "0x" << std::hex << std::setw(4) << std::setfill('0') << n; return oss.str(); } class StackBtmTest : public Test { public: protected: Loading Loading @@ -168,20 +177,21 @@ TEST_F(StackBtmTest, change_packet_type) { btm_set_packet_types_from_address(bda, pkt_types); ASSERT_EQ(++cnt, mock_function_count_map["btsnd_hcic_change_conn_type"]); ASSERT_EQ(0x123, mock::btsnd_hcic_change_conn_type.handle); ASSERT_EQ(0x4400, mock::btsnd_hcic_change_conn_type.packet_types); ASSERT_EQ(Hex16(0x4400 | HCI_PKT_TYPES_MASK_DM1), Hex16(mock::btsnd_hcic_change_conn_type.packet_types)); mock::btsnd_hcic_change_conn_type = {}; btm_set_packet_types_from_address(bda, 0xffff); ASSERT_EQ(++cnt, mock_function_count_map["btsnd_hcic_change_conn_type"]); ASSERT_EQ(0x123, mock::btsnd_hcic_change_conn_type.handle); ASSERT_EQ(0xcc00, mock::btsnd_hcic_change_conn_type.packet_types); ASSERT_EQ(Hex16(0xcc00 | HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1), Hex16(mock::btsnd_hcic_change_conn_type.packet_types)); mock::btsnd_hcic_change_conn_type = {}; btm_set_packet_types_from_address(bda, 0x0); // NOTE: The call should not be executed with no bits set ASSERT_EQ(0x0, mock::btsnd_hcic_change_conn_type.handle); ASSERT_EQ(0x0, mock::btsnd_hcic_change_conn_type.packet_types); ASSERT_EQ(Hex16(0x0), Hex16(mock::btsnd_hcic_change_conn_type.packet_types)); get_btm_client_interface().lifecycle.btm_free(); } Loading