blob: 5934e14fc8daf21e7dce0464af720a1e92244cf4 [file] [log] [blame]
Haofan Wange02b8092024-10-28 21:47:27 +00001/*
2 * Copyright (C) 2024 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 "ambient_intelligence_light_aidl_hal_test"
18
19#include <aidl/Gtest.h>
20#include <aidl/Vintf.h>
21#include <android/hardware/tv/mediaquality/IMediaQuality.h>
22#include <binder/IServiceManager.h>
23#include <binder/ProcessState.h>
24#include <gtest/gtest.h>
25#include <hidl/GtestPrinter.h>
26#include <hidl/ServiceManagement.h>
27
28using android::ProcessState;
29using android::sp;
30using android::String16;
31using android::binder::Status;
32using android::hardware::hidl_vec;
33using android::hardware::Return;
34using android::hardware::Void;
35using android::hardware::tv::mediaquality::IMediaQuality;
36
37#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
38#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
39
40class MediaQualityAidl : public testing::TestWithParam<std::string> {
41 public:
42 void SetUp() override {
43 mediaquality = android::waitForDeclaredService<IMediaQuality>(String16(GetParam().c_str()));
44 ASSERT_NE(mediaquality, nullptr);
45 }
46
47 sp<IMediaQuality> mediaquality;
48
49 void TearDown() override {}
50};
51
52TEST_P(MediaQualityAidl, TestSetAmbientLightDetectionEnabled) {
53 ASSERT_OK(mediaquality->setAmbientLightDetectionEnabled(true));
54}
55
56TEST_P(MediaQualityAidl, TestGetAmbientLightDetectionEnabled) {
57 bool enabled;
58 Status status = mediaquality->getAmbientLightDetectionEnabled(&enabled);
59 ASSERT_TRUE(status.isOk());
60 ASSERT_TRUE(enabled);
61}
62
63GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MediaQualityAidl);
64
65INSTANTIATE_TEST_SUITE_P(
66 PerInstance, MediaQualityAidl,
67 testing::ValuesIn(android::getAidlHalInstanceNames(IMediaQuality::descriptor)),
68 android::PrintInstanceNameToString);
69
70int main(int argc, char** argv) {
71 ::testing::InitGoogleTest(&argc, argv);
72 ProcessState::self()->setThreadPoolMaxThreadCount(1);
73 ProcessState::self()->startThreadPool();
74 return RUN_ALL_TESTS();
75}