diff options
| author | Patrick Venture <venture@google.com> | 2018-04-16 11:38:16 -0700 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-05-30 13:38:35 +0000 |
| commit | ead7ea7a5a6dc00f4c264060cfd1e81021e51da0 (patch) | |
| tree | a460d8bd8c033591ff4422c0a1f3a61a25fb7a34 | |
| parent | 8e20cfbd745db524fdc2ee9f1ee13b3852313f6d (diff) | |
| download | sdbusplus-ead7ea7a5a6dc00f4c264060cfd1e81021e51da0.tar.gz sdbusplus-ead7ea7a5a6dc00f4c264060cfd1e81021e51da0.zip | |
sdbusplus testing add new_mock method
This method returns an sdbusplus::bus::bus using the mock
provided and adds the necessary EXPECT_CALL ahead saving
a line of code in all unit-tests using this.
Change-Id: Icc07405eb0bd4e4dca6c28fdb71e7ff2e5c06c3f
Signed-off-by: Patrick Venture <venture@google.com>
| -rw-r--r-- | sdbusplus/test/sdbus_mock.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sdbusplus/test/sdbus_mock.hpp b/sdbusplus/test/sdbus_mock.hpp index c3b5454..059eae6 100644 --- a/sdbusplus/test/sdbus_mock.hpp +++ b/sdbusplus/test/sdbus_mock.hpp @@ -87,4 +87,15 @@ class SdBusMock : public SdBusInterface MOCK_METHOD2(sd_bus_wait, int(sd_bus *, uint64_t)); }; +bus::bus get_mocked_new(SdBusMock *sdbus) +{ + using ::testing::IsNull; + using ::testing::Return; + + EXPECT_CALL(*sdbus, sd_bus_ref(IsNull())).WillRepeatedly(Return(nullptr)); + bus::bus bus_mock(nullptr, sdbus); + + return bus_mock; +} + } // namespace sdbusplus |

