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

Commit 531d04c7 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

audio: Add test utility to print AIDL types and use it

Add printing of the value that can't be found in
AudioCoreConfig::validateAudioHalCapRule.

Bug: 370824008
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ib82b690922dbad634c37b07a25f3862972dedf34
parent bcf8e249
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -124,3 +124,30 @@ inline ::testing::AssertionResult assertResultOrUnknownTransaction(
    EXPECT_PRED_FORMAT2(                                                                           \
            ::android::hardware::audio::common::testing::detail::assertResultOrUnknownTransaction, \
            expected, ret)

namespace android::hardware::audio::common::testing::detail {

template <typename>
struct mf_traits {};
template <class T, class U>
struct mf_traits<U T::*> {
    using member_type = U;
};

}  // namespace android::hardware::audio::common::testing::detail

namespace aidl::android::media::audio::common {

template <typename P>
std::enable_if_t<std::is_function_v<typename ::android::hardware::audio::common::testing::detail::
                                            mf_traits<decltype(&P::toString)>::member_type>,
                 std::ostream&>
operator<<(std::ostream& os, const P& p) {
    return os << p.toString();
}
template <typename E>
std::enable_if_t<std::is_enum_v<E>, std::ostream&> operator<<(std::ostream& os, const E& e) {
    return os << toString(e);
}

}  // namespace aidl::android::media::audio::common
+1 −1
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ class AudioCoreConfig : public testing::TestWithParam<std::string> {
        auto values = criterionV2.values;
        auto valueIt = find_if(values.begin(), values.end(),
                               [&](const auto& typedValue) { return typedValue == value; });
        EXPECT_NE(valueIt, values.end());
        EXPECT_NE(valueIt, values.end()) << "Not found: \"" << value << "\"";
    }

    /**