blob: 1d0d50fd45a4b5aebdf0934ae7750daae0a1e49a [file] [log] [blame]
Kumar Anandfc72a8d2017-01-26 12:23:09 -08001/*
2 * Copyright (C) 2017 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.1/IPower.h>
20
21#include <VtsHalHidlTargetTestBase.h>
22
23using ::android::hardware::power::V1_1::IPower;
24using ::android::hardware::power::V1_1::PowerStateSubsystem;
25using ::android::hardware::power::V1_0::Status;
26using ::android::hardware::hidl_vec;
27using ::android::hardware::Return;
28using ::android::sp;
29
30class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
31 public:
32 virtual void SetUp() override {
33 power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
34 ASSERT_NE(power, nullptr);
35 }
36
37 virtual void TearDown() override {}
38
39 sp<IPower> power;
40};
41
42// Sanity check Power::getSubsystemLowPowerStats().
43TEST_F(PowerHidlTest, GetSubsystemLowPowerStats) {
44 hidl_vec<PowerStateSubsystem> vec;
45 Status s;
46 auto cb = [&vec, &s](hidl_vec<PowerStateSubsystem> subsystems,
47 Status status) {
48 vec = subsystems;
49 s = status;
50 };
51
52 Return<void> ret = power->getSubsystemLowPowerStats(cb);
53 ASSERT_TRUE(ret.isOk());
54 ASSERT_TRUE(s == Status::SUCCESS || s == Status::FILESYSTEM_ERROR);
55}
56
57int main(int argc, char **argv) {
58 ::testing::InitGoogleTest(&argc, argv);
59 int status = RUN_ALL_TESTS();
60 LOG(INFO) << "Test result = " << status;
61 return status;
62}