From de8cbffd47684b9bd16eb407902da0a860bf9f12 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Fri, 10 Mar 2017 17:42:46 -0800 Subject: [PATCH] Audio hal VTS: pretty print AudioDevice and ChannelMask This eases the debuging of failing tests. Also print hex value of the enums as well of their literal values. Test: run the test on target Bug: 34170075 Change-Id: Iea1d7d2269e0e5b413240aaa905daae755846e74 Signed-off-by: Kevin Rocard --- .../utility/PrettyPrintAudioTypes.h | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h b/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h index 8dfcb29472..025cd1c6a4 100644 --- a/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h +++ b/audio/2.0/vts/functional/utility/PrettyPrintAudioTypes.h @@ -13,23 +13,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include + +/** @file Use HIDL generated toString methods to pretty print gtest errors */ + +namespace detail { + +// Print the value of an enum as hex +template +inline void printUnderlyingValue(Enum value, ::std::ostream* os) { + *os << std::hex << " (0x" << static_cast>(value) << ")"; +} + +} // namespace detail -// Use HIDL generated toString methods to pretty print gtest errors namespace android { namespace hardware { namespace audio { namespace V2_0 { + inline void PrintTo(const Result& result, ::std::ostream* os) { *os << toString(result); + detail::printUnderlyingValue(result, os); } + } // namespace V2_0 namespace common { namespace V2_0 { + inline void PrintTo(const AudioConfig& config, ::std::ostream* os) { *os << toString(config); } + +inline void PrintTo(const AudioDevice& device, ::std::ostream* os) { + *os << toString(device); + detail::printUnderlyingValue(device, os); +} + +inline void PrintTo(const AudioChannelMask& channelMask, ::std::ostream* os) { + *os << toString(channelMask); + detail::printUnderlyingValue(channelMask, os); +} + } // namespace V2_0 } // namespace common -} -} -} +} // namespace audio +} // namespace hardware +} // namespace android