Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de8cbffd authored by Kevin Rocard's avatar Kevin Rocard
Browse files

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: default avatarKevin Rocard <krocard@google.com>
parent 20e7af61
Loading
Loading
Loading
Loading
+31 −4
Original line number Diff line number Diff line
@@ -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);
}
} // namespace V2_0
} // namespace common
}

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