blob: 0589fd81509de348a44100ac95cf10172694fb67 [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
17#define LOG_TAG "contexthub_hidl_hal_test"
18
19#include "ContexthubCallbackBase.h"
20#include "ContexthubHidlTestBase.h"
Arthur Ishigurofe0f98e2021-08-12 14:43:39 -070021#include "VtsHalContexthubUtilsCommon.h"
22#include "VtsHalContexthubUtilsHidl.h"
Brian Duddie01eb01a2020-02-14 15:35:57 -080023
24#include <android-base/logging.h>
25#include <android/hardware/contexthub/1.0/IContexthub.h>
26#include <android/hardware/contexthub/1.1/IContexthub.h>
27#include <android/log.h>
28#include <gtest/gtest.h>
29#include <hidl/GtestPrinter.h>
30#include <hidl/ServiceManagement.h>
31#include <log/log.h>
32
33#include <cinttypes>
34
Anthony Stangea2c3db12020-12-16 15:04:02 -050035using ::android::hardware::contexthub::V1_0::IContexthubCallback;
Brian Duddie01eb01a2020-02-14 15:35:57 -080036using ::android::hardware::contexthub::V1_1::IContexthub;
37using ::android::hardware::contexthub::V1_1::Setting;
38using ::android::hardware::contexthub::V1_1::SettingValue;
39using ::android::hardware::contexthub::vts_utils::ContexthubCallbackBase;
40using ::android::hardware::contexthub::vts_utils::ContexthubHidlTestBase;
41using ::android::hardware::contexthub::vts_utils::getHalAndHubIdList;
42
43namespace {
44
45const std::vector<std::tuple<std::string, std::string>> kTestParameters =
46 getHalAndHubIdList<IContexthub>();
47
48class ContexthubHidlTest : public ContexthubHidlTestBase<IContexthub> {};
49
Anthony Stangea2c3db12020-12-16 15:04:02 -050050class ContexthubCallbackV1_0 : public ContexthubCallbackBase<IContexthubCallback> {};
51
Brian Duddie01eb01a2020-02-14 15:35:57 -080052TEST_P(ContexthubHidlTest, TestOnSettingChanged) {
53 // In VTS, we only test that sending the values doesn't cause things to blow up - other test
54 // suites verify the expected E2E behavior in CHRE
Anthony Stangea2c3db12020-12-16 15:04:02 -050055 ASSERT_OK(registerCallback(new ContexthubCallbackV1_0()));
Brian Duddie01eb01a2020-02-14 15:35:57 -080056 hubApi->onSettingChanged(Setting::LOCATION, SettingValue::DISABLED);
57 hubApi->onSettingChanged(Setting::LOCATION, SettingValue::ENABLED);
58 ASSERT_OK(registerCallback(nullptr));
59}
60
Dan Shiff985a82020-07-29 09:45:03 -070061GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ContexthubHidlTest);
Brian Duddie01eb01a2020-02-14 15:35:57 -080062INSTANTIATE_TEST_SUITE_P(HubIdSpecificTests, ContexthubHidlTest, testing::ValuesIn(kTestParameters),
63 android::hardware::PrintInstanceTupleNameToString<>);
64
65} // anonymous namespace