From 3ef9a3f614e434a8a55c2ddc9f15335762df4311 Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Wed, 1 Sep 2021 00:39:30 +0900 Subject: [PATCH] Enable mock test on demand [Version] 0.0.14 [Issue Type] Feature Change-Id: I490ebf8af361edb3bc8e910cbf6f28c588effe9d --- packaging/hal-api-audio.spec | 2 +- testcase/audio_haltests.cpp | 4 ++++ testcase/parser.hh | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packaging/hal-api-audio.spec b/packaging/hal-api-audio.spec index 6366983..1ad7dae 100644 --- a/packaging/hal-api-audio.spec +++ b/packaging/hal-api-audio.spec @@ -1,6 +1,6 @@ Name: hal-api-audio Summary: TIZEN Audio HAL -Version: 0.0.13 +Version: 0.0.14 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/testcase/audio_haltests.cpp b/testcase/audio_haltests.cpp index e246dfa..d783863 100644 --- a/testcase/audio_haltests.cpp +++ b/testcase/audio_haltests.cpp @@ -865,12 +865,16 @@ TEST_F(AudioHalTest, PcmGetFdP) { pcm_handle pcm_h = nullptr; +#ifdef USE_MOCK MockDeviceMapParser parser; EXPECT_CALL(parser, get_playback()) .Times(1) .WillOnce(testing::Return(make_tuple("0", "0", AudioHalTest::default_rate, AudioHalTest::default_channels))); auto [ card, device, rate, channels ] = parser.get_playback(); +#else + auto [ card, device, rate, channels ] = CDeviceMapParser().get_playback(); +#endif /* USE_MOCK */ m_spec = { AUDIO_SAMPLE_S16LE, diff --git a/testcase/parser.hh b/testcase/parser.hh index ecaedb5..bd2845e 100644 --- a/testcase/parser.hh +++ b/testcase/parser.hh @@ -19,8 +19,10 @@ #include #include #include -#include #include +#ifdef USE_MOCK +#include +#endif using namespace std; @@ -34,12 +36,14 @@ public: virtual DeviceInfo get_capture() = 0; }; +#ifdef USE_MOCK class MockDeviceMapParser : public DeviceMapParser { public: MOCK_METHOD(DeviceInfo, get_playback, (), (override)); MOCK_METHOD(DeviceInfo, get_capture, (), (override)); }; +#endif /* USE_MOCK */ class CDeviceMapParser : public DeviceMapParser { -- 2.34.1