1 /*
2 * Copyright (C) 2021 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 #include <aidl/Vintf.h>
18 #include <aidl/android/frameworks/automotive/powerpolicy/ICarPowerPolicyServer.h>
19 #include <binder/ProcessState.h>
20
21 #include "PowerPolicyInterfaceTest.h"
22
23 namespace {
24
25 using ::aidl::android::frameworks::automotive::powerpolicy::ICarPowerPolicyServer;
26 using ::android::ProcessState;
27
28 } // namespace
29
30 class PowerPolicyAidlTest : public ::testing::TestWithParam<std::string> {
31 public:
SetUp()32 virtual void SetUp() override { powerPolicyTest.SetUp(GetParam()); }
33
34 PowerPolicyInterfaceTest<ICarPowerPolicyServer> powerPolicyTest;
35 };
36
TEST_P(PowerPolicyAidlTest,TestGetCurrentPowerPolicy)37 TEST_P(PowerPolicyAidlTest, TestGetCurrentPowerPolicy) {
38 powerPolicyTest.TestGetCurrentPowerPolicy();
39 }
40
TEST_P(PowerPolicyAidlTest,TestGetPowerComponentState)41 TEST_P(PowerPolicyAidlTest, TestGetPowerComponentState) {
42 powerPolicyTest.TestGetPowerComponentState();
43 }
44
TEST_P(PowerPolicyAidlTest,TestGetPowerComponentState_invalidComponent)45 TEST_P(PowerPolicyAidlTest, TestGetPowerComponentState_invalidComponent) {
46 powerPolicyTest.TestGetPowerComponentState_invalidComponent();
47 }
48
TEST_P(PowerPolicyAidlTest,TestRegisterPowerPolicyCallback)49 TEST_P(PowerPolicyAidlTest, TestRegisterPowerPolicyCallback) {
50 powerPolicyTest.TestRegisterPowerPolicyCallback();
51 }
52
TEST_P(PowerPolicyAidlTest,TestRegisterPowerPolicyCallback_doubleRegistering)53 TEST_P(PowerPolicyAidlTest, TestRegisterPowerPolicyCallback_doubleRegistering) {
54 powerPolicyTest.TestRegisterPowerPolicyCallback_doubleRegistering();
55 }
56
TEST_P(PowerPolicyAidlTest,TestUnegisterNotRegisteredPowerPolicyCallback)57 TEST_P(PowerPolicyAidlTest, TestUnegisterNotRegisteredPowerPolicyCallback) {
58 powerPolicyTest.TestUnegisterNotRegisteredPowerPolicyCallback();
59 }
60
61 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PowerPolicyAidlTest);
62 INSTANTIATE_TEST_SUITE_P(
63 CarPowerPolicyServer, PowerPolicyAidlTest,
64 ::testing::ValuesIn(android::getAidlHalInstanceNames(ICarPowerPolicyServer::descriptor)),
65 android::PrintInstanceNameToString);
66
main(int argc,char ** argv)67 int main(int argc, char** argv) {
68 ::testing::InitGoogleTest(&argc, argv);
69 ProcessState::self()->setThreadPoolMaxThreadCount(1);
70 ProcessState::self()->startThreadPool();
71 return RUN_ALL_TESTS();
72 }
73