blob: 77883c24235c1f86d2d0927d83237e0d9229a20a [file] [log] [blame]
Arthur Ishigurod06c45e2020-10-06 13:24:29 -07001/*
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"
21#include "VtsHalContexthubUtils.h"
22
23#include <android-base/logging.h>
24#include <android/hardware/contexthub/1.0/IContexthub.h>
25#include <android/hardware/contexthub/1.1/IContexthub.h>
26#include <android/hardware/contexthub/1.2/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
35using ::android::hardware::contexthub::V1_1::SettingValue;
36using ::android::hardware::contexthub::V1_2::IContexthub;
37using ::android::hardware::contexthub::V1_2::Setting;
38using ::android::hardware::contexthub::vts_utils::ContexthubCallbackBase;
39using ::android::hardware::contexthub::vts_utils::ContexthubHidlTestBase;
40using ::android::hardware::contexthub::vts_utils::getHalAndHubIdList;
41
42namespace {
43
44const std::vector<std::tuple<std::string, std::string>> kTestParameters =
45 getHalAndHubIdList<IContexthub>();
46
47class ContexthubHidlTest : public ContexthubHidlTestBase<IContexthub> {};
48
49// In VTS, we only test that sending the values doesn't cause things to blow up - other test
50// suites verify the expected E2E behavior in CHRE
51TEST_P(ContexthubHidlTest, TestOnWifiSettingChanged) {
52 ASSERT_OK(registerCallback(new ContexthubCallbackBase()));
53 hubApi->onSettingChanged_1_2(Setting::WIFI_AVAILABLE, SettingValue::DISABLED);
54 hubApi->onSettingChanged_1_2(Setting::WIFI_AVAILABLE, SettingValue::ENABLED);
55 ASSERT_OK(registerCallback(nullptr));
56}
57
58TEST_P(ContexthubHidlTest, TestOnAirplaneModeSettingChanged) {
59 ASSERT_OK(registerCallback(new ContexthubCallbackBase()));
60 hubApi->onSettingChanged_1_2(Setting::AIRPLANE_MODE, SettingValue::DISABLED);
61 hubApi->onSettingChanged_1_2(Setting::AIRPLANE_MODE, SettingValue::ENABLED);
62 ASSERT_OK(registerCallback(nullptr));
63}
64
65GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ContexthubHidlTest);
66INSTANTIATE_TEST_SUITE_P(HubIdSpecificTests, ContexthubHidlTest, testing::ValuesIn(kTestParameters),
67 android::hardware::PrintInstanceTupleNameToString<>);
68
69} // anonymous namespace