mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 22:04:26 +00:00
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 <krocard@google.com>
This commit is contained in:
@@ -13,23 +13,50 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <type_traits>
|
||||
|
||||
/** @file Use HIDL generated toString methods to pretty print gtest errors */
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Print the value of an enum as hex
|
||||
template <class Enum>
|
||||
inline void printUnderlyingValue(Enum value, ::std::ostream* os) {
|
||||
*os << std::hex << " (0x" << static_cast<std::underlying_type_t<Enum>>(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
|
||||
|
||||
Reference in New Issue
Block a user