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

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

Add VTS tests for the primary audio hal



Test: run the vts test on target
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target

Bug: 34170075
Change-Id: I4bd6cb0aa5b7cc628537cd7c024542c4db8b592d
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 920af48d
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "VtsHalAudioV2_0TargetTest",
    gtest: true,
    srcs: ["AudioPrimaryHidlHalTest.cpp"],
    shared_libs: [
        "libbase",
        "liblog",
        "libhidlbase",
        "libutils",
        "libcutils",
        "android.hardware.audio@2.0",
        "android.hardware.audio.common@2.0",
    ],
    static_libs: ["libgtest"],
    cflags: [
        "-O0",
        "-g",
        "-Wall",
        "-Wextra",
        "-Werror",
    ],
}
+708 −0

File added.

Preview size limit exceeded, changes collapsed.

+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <hidl/Status.h>

namespace detail {

inline void assertOk(::android::hardware::Return<void> ret) {
    ASSERT_TRUE(ret.isOk());
}

inline void assertOk(::android::hardware::audio::V2_0::Result result) {
    ASSERT_EQ(decltype(result)::OK, result);
}

inline void assertOk(::android::hardware::Return<::android::hardware::audio::V2_0::Result> ret) {
    ASSERT_TRUE(ret.isOk());
    ::android::hardware::audio::V2_0::Result result = ret;
    assertOk(result);
}

}

// Test anything provided is and contains only OK
#define ASSERT_OK(ret) ASSERT_NO_FATAL_FAILURE(detail::assertOk(ret))
#define EXPECT_OK(ret) EXPECT_NO_FATAL_FAILURE(detail::assertOk(ret))
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// 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);
}
} // 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
}
}
}
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <tuple>

namespace utility {

namespace detail {
// Helper class to generate the HIDL synchronous callback
template <class... ResultStore>
class ReturnIn {
 public:
    // Provide to the constructor the variables where the output parameters must be copied
    // TODO: take pointers to match google output parameter style ?
    ReturnIn(ResultStore&... ts) : results(ts...) {}
    // Synchronous callback
    template <class... Results>
    void operator() (Results&&...results) {
        set(std::forward<Results>(results)...);
    }
 private:
    // Recursively set all output parameters
    template <class Head, class... Tail>
    void set(Head&& head, Tail&&... tail) {
        std::get<sizeof...(ResultStore) - sizeof...(Tail) - 1>(results)
                  = std::forward<Head>(head);
        set(tail...);
    }
    // Trivial case
    void set() {}

    // All variables to set are stored here
    std::tuple<ResultStore&...> results;
};
} // namespace detail

// Generate the HIDL synchronous callback with a copy policy
// Input: the variables (lvalue reference) where to save the return values
// Output: the callback to provide to a HIDL call with a synchronous callback
// The output parameters *will be copied* do not use this function if you have
// a zero copy policy
template <class... ResultStore>
detail::ReturnIn<ResultStore...> returnIn(ResultStore&... ts) { return {ts...};}

}
Loading