Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [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 | #include <composer-vts/2.3/ComposerVts.h> |
| 18 | |
| 19 | #include <VtsHalHidlTargetTestBase.h> |
| 20 | |
| 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | namespace graphics { |
| 24 | namespace composer { |
| 25 | namespace V2_3 { |
| 26 | namespace vts { |
| 27 | |
| 28 | using V2_1::Error; |
| 29 | |
| 30 | Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {} |
| 31 | |
| 32 | Composer::Composer(const std::string& name) |
| 33 | : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {} |
| 34 | |
| 35 | Composer::Composer(const sp<IComposer>& composer) |
| 36 | : V2_2::vts::Composer(composer), mComposer(composer) {} |
| 37 | |
| 38 | std::unique_ptr<ComposerClient> Composer::createClient() { |
| 39 | std::unique_ptr<ComposerClient> client; |
| 40 | mComposer->createClient_2_3([&client](const auto& tmpError, const auto& tmpClient) { |
| 41 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create client"; |
| 42 | client = std::make_unique<ComposerClient>(tmpClient); |
| 43 | }); |
| 44 | |
| 45 | return client; |
| 46 | } |
| 47 | |
| 48 | bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort, |
| 49 | std::vector<uint8_t>* outData) { |
| 50 | bool supported = true; |
| 51 | mClient->getDisplayIdentificationData( |
| 52 | display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) { |
| 53 | if (tmpError == Error::UNSUPPORTED) { |
| 54 | supported = false; |
| 55 | return; |
| 56 | } |
| 57 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data"; |
| 58 | |
| 59 | *outPort = tmpPort; |
| 60 | *outData = tmpData; |
| 61 | ASSERT_FALSE(outData->empty()) << "data is empty"; |
| 62 | }); |
| 63 | |
| 64 | return supported; |
| 65 | } |
| 66 | |
| 67 | } // namespace vts |
| 68 | } // namespace V2_3 |
| 69 | } // namespace composer |
| 70 | } // namespace graphics |
| 71 | } // namespace hardware |
| 72 | } // namespace android |