Michael Wright | 795990c | 2018-06-21 02:42:31 +0100 | [diff] [blame] | 1 | /* |
| 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> |
Dan Shi | 6ac30ad | 2019-10-17 16:25:51 -0700 | [diff] [blame^] | 20 | #include <gtest/gtest.h> |
| 21 | #include <hidl/GtestPrinter.h> |
| 22 | #include <hidl/ServiceManagement.h> |
Michael Wright | 795990c | 2018-06-21 02:42:31 +0100 | [diff] [blame] | 23 | |
| 24 | using ::android::sp; |
| 25 | using ::android::hardware::hidl_vec; |
| 26 | using ::android::hardware::Return; |
| 27 | using ::android::hardware::power::V1_3::IPower; |
| 28 | using ::android::hardware::power::V1_3::PowerHint; |
| 29 | |
Dan Shi | 6ac30ad | 2019-10-17 16:25:51 -0700 | [diff] [blame^] | 30 | class PowerHidlTest : public testing::TestWithParam<std::string> { |
Michael Wright | 795990c | 2018-06-21 02:42:31 +0100 | [diff] [blame] | 31 | public: |
| 32 | virtual void SetUp() override { |
Dan Shi | 6ac30ad | 2019-10-17 16:25:51 -0700 | [diff] [blame^] | 33 | power = IPower::getService(GetParam()); |
Michael Wright | 795990c | 2018-06-21 02:42:31 +0100 | [diff] [blame] | 34 | ASSERT_NE(power, nullptr); |
| 35 | } |
| 36 | |
| 37 | sp<IPower> power; |
| 38 | }; |
| 39 | |
Dan Shi | 6ac30ad | 2019-10-17 16:25:51 -0700 | [diff] [blame^] | 40 | TEST_P(PowerHidlTest, PowerHintAsync_1_3) { |
Michael Wright | 795990c | 2018-06-21 02:42:31 +0100 | [diff] [blame] | 41 | ASSERT_TRUE(power->powerHintAsync_1_3(PowerHint::EXPENSIVE_RENDERING, 0).isOk()); |
| 42 | } |
| 43 | |
Dan Shi | 6ac30ad | 2019-10-17 16:25:51 -0700 | [diff] [blame^] | 44 | INSTANTIATE_TEST_SUITE_P( |
| 45 | PerInstance, PowerHidlTest, |
| 46 | testing::ValuesIn(android::hardware::getAllHalInstanceNames(IPower::descriptor)), |
| 47 | android::hardware::PrintInstanceNameToString); |