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