blob: ee5b7d3cd5bcaa20a5a3a40e2fc477091b768711 [file] [log] [blame]
Brian Duddie01eb01a2020-02-14 15:35:57 -08001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <android/hardware/contexthub/1.0/IContexthubCallback.h>
19#include <gtest/gtest.h>
20
21#include <string>
22#include <tuple>
23
24namespace android {
25namespace hardware {
26namespace contexthub {
27namespace vts_utils {
28
29// Base fixture for Context Hub HAL tests. Parameterized by service name and hub ID.
30template <class IContexthubVersion>
31class ContexthubHidlTestBase
32 : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
33 public:
34 virtual void SetUp() override { fetchHubApi(); }
35
36 void fetchHubApi() {
37 hubApi = IContexthubVersion::getService(std::get<0>(GetParam()));
38 ASSERT_NE(hubApi, nullptr);
39 }
40
41 uint32_t getHubId() { return std::stoi(std::get<1>(GetParam())); }
42
43 V1_0::Result registerCallback(sp<V1_0::IContexthubCallback> cb) {
44 return hubApi->registerCallback(getHubId(), cb);
45 }
46
47 sp<IContexthubVersion> hubApi;
48};
49
50} // namespace vts_utils
51} // namespace contexthub
52} // namespace hardware
53} // namespace android