From 132c841fc55a0a7f4142a07710a6ba44e2a05995 Mon Sep 17 00:00:00 2001 From: Cassio Romanin de Lazaro Date: Thu, 19 Dec 2024 10:39:00 +0000 Subject: [PATCH] Changes after sync up with Oguzcan --- services/ble/Gap.cpp | 2 +- services/ble/Gap.hpp | 5 +++-- services/ble/test/TestGapCentral.cpp | 7 +++++-- services/ble/test_doubles/GapCentralMock.hpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/services/ble/Gap.cpp b/services/ble/Gap.cpp index 65275dca7..0f885ca7a 100644 --- a/services/ble/Gap.cpp +++ b/services/ble/Gap.cpp @@ -183,7 +183,7 @@ namespace services GapCentralObserver::Subject().StopDeviceDiscovery(); } - hal::MacAddress GapCentralDecorator::ResolveDeviceAddress(hal::MacAddress deviceAddress) const + infra::Optional GapCentralDecorator::ResolveDeviceAddress(hal::MacAddress deviceAddress) const { return GapCentralObserver::Subject().ResolveDeviceAddress(deviceAddress); } diff --git a/services/ble/Gap.hpp b/services/ble/Gap.hpp index ae2c807d6..518c32350 100644 --- a/services/ble/Gap.hpp +++ b/services/ble/Gap.hpp @@ -5,6 +5,7 @@ #include "infra/timer/Timer.hpp" #include "infra/util/EnumCast.hpp" #include "infra/util/Observer.hpp" +#include "infra/util/Optional.hpp" namespace services { @@ -319,7 +320,7 @@ namespace services virtual void SetAddress(hal::MacAddress macAddress, GapDeviceAddressType addressType) = 0; virtual void StartDeviceDiscovery() = 0; virtual void StopDeviceDiscovery() = 0; - virtual hal::MacAddress ResolveDeviceAddress(hal::MacAddress deviceAddress) const = 0; + virtual infra::Optional ResolveDeviceAddress(hal::MacAddress deviceAddress) const = 0; }; class GapCentralDecorator @@ -340,7 +341,7 @@ namespace services void SetAddress(hal::MacAddress macAddress, GapDeviceAddressType addressType) override; void StartDeviceDiscovery() override; void StopDeviceDiscovery() override; - hal::MacAddress ResolveDeviceAddress(hal::MacAddress deviceAddress) const override; + infra::Optional ResolveDeviceAddress(hal::MacAddress deviceAddress) const override; }; } diff --git a/services/ble/test/TestGapCentral.cpp b/services/ble/test/TestGapCentral.cpp index 6649f9a9d..495cfceb5 100644 --- a/services/ble/test/TestGapCentral.cpp +++ b/services/ble/test/TestGapCentral.cpp @@ -81,8 +81,11 @@ namespace services decorator.StopDeviceDiscovery(); hal::MacAddress mac = { 0x00, 0x1A, 0x7D, 0xDA, 0x71, 0x13 }; - EXPECT_CALL(gap, ResolveDeviceAddress(mac)); - decorator.ResolveDeviceAddress(mac); + EXPECT_CALL(gap, ResolveDeviceAddress(mac)).WillOnce(testing::Return(infra::none)); + EXPECT_EQ(decorator.ResolveDeviceAddress(mac), infra::none); + + EXPECT_CALL(gap, ResolveDeviceAddress(mac)).WillOnce(testing::Return(infra::MakeOptional(mac))); + EXPECT_EQ(decorator.ResolveDeviceAddress(mac), mac); } TEST(GapAdvertisingDataParserTest, payload_too_small) diff --git a/services/ble/test_doubles/GapCentralMock.hpp b/services/ble/test_doubles/GapCentralMock.hpp index edbb126f6..1d03b3acd 100644 --- a/services/ble/test_doubles/GapCentralMock.hpp +++ b/services/ble/test_doubles/GapCentralMock.hpp @@ -16,7 +16,7 @@ namespace services MOCK_METHOD(void, SetAddress, (hal::MacAddress macAddress, GapDeviceAddressType addressType)); MOCK_METHOD(void, StartDeviceDiscovery, ()); MOCK_METHOD(void, StopDeviceDiscovery, ()); - MOCK_METHOD(hal::MacAddress, ResolveDeviceAddress, (hal::MacAddress deviceAddress), (const)); + MOCK_METHOD(infra::Optional, ResolveDeviceAddress, (hal::MacAddress deviceAddress), (const)); }; }