blob: af1a1d86ab487225ceecd4c6db2e24f71febe6d6 [file] [log] [blame]
Michael Wright795990c2018-06-21 02:42:31 +01001/*
2 * Copyright (C) 2018 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 "power_hidl_hal_test"
18#include <android-base/logging.h>
19#include <android/hardware/power/1.3/IPower.h>
20
21#include <VtsHalHidlTargetTestBase.h>
22#include <VtsHalHidlTargetTestEnvBase.h>
23
24using ::android::sp;
25using ::android::hardware::hidl_vec;
26using ::android::hardware::Return;
27using ::android::hardware::power::V1_3::IPower;
28using ::android::hardware::power::V1_3::PowerHint;
29
30// Test environment for Power HIDL HAL.
31class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
32 public:
33 // get the test environment singleton
34 static PowerHidlEnvironment* Instance() {
35 static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
36 return instance;
37 }
38
39 virtual void registerTestServices() override { registerTestService<IPower>(); }
40};
41
42class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
43 public:
44 virtual void SetUp() override {
45 power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
46 PowerHidlEnvironment::Instance()->getServiceName<IPower>());
47 ASSERT_NE(power, nullptr);
48 }
49
50 sp<IPower> power;
51};
52
53TEST_F(PowerHidlTest, PowerHintAsync_1_3) {
54 ASSERT_TRUE(power->powerHintAsync_1_3(PowerHint::EXPENSIVE_RENDERING, 0).isOk());
55}
56
57int main(int argc, char** argv) {
58 ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
59 ::testing::InitGoogleTest(&argc, argv);
60 PowerHidlEnvironment::Instance()->init(&argc, argv);
61 int status = RUN_ALL_TESTS();
62 LOG(INFO) << "Test result = " << status;
63 return status;
64}