add unit test for NP v0 advertisement parsing

PiperOrigin-RevId: 523153029
This commit is contained in:
Hai Shang
2023-04-10 10:41:05 -07:00
committed by Copybara-Service
parent 665a334d0d
commit 574b88d7ef
@@ -242,6 +242,22 @@ TEST(AdvertisementDecoder, DecodeBaseNpWithTxActionField) {
DataElement(DataElement(ActionBit::kNearbyShareAction))));
}
TEST(AdvertisementDecoder, DecodeBaseNpV0PublicIdentityWithTxAndActionField) {
AdvertisementDecoder decoder(GetScanRequest());
auto result = decoder.DecodeAdvertisement(
// v0 public identity, power and action, action value 8 for active unlock.
absl::HexStringToBytes("000336FF0080"));
EXPECT_OK(result);
EXPECT_THAT(result->data_elements,
UnorderedElementsAre(
DataElement(DataElement::kPublicIdentityFieldType, ""),
DataElement(DataElement::kTxPowerFieldType,
absl::HexStringToBytes("ff")),
DataElement(DataElement(ActionBit::kActiveUnlockAction))));
}
TEST(AdvertisementDecoder,
ScanForEncryptedIdentityIgnoresPublicIdentityAdvertisement) {
AdvertisementDecoder decoder(