1 /*
2 * Copyright 2023 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 #undef LOG_TAG
18 #define LOG_TAG "LibSurfaceFlingerUnittests"
19
20 #include <gtest/gtest.h>
21 #include <gui/AidlStatusUtil.h>
22 #include <private/gui/ComposerService.h>
23 #include <private/gui/ComposerServiceAIDL.h>
24
25 #include "DisplayTransactionTestHelpers.h"
26
27 namespace android {
28
29 using GuiHdrConversionStrategyTag = gui::HdrConversionStrategy::Tag;
30 using gui::aidl_utils::statusTFromBinderStatus;
31
TEST(HdrOutputControlTest,testGetHdrOutputConversionSupport)32 TEST(HdrOutputControlTest, testGetHdrOutputConversionSupport) {
33 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
34
35 bool hdrOutputConversionSupport;
36 binder::Status status = sf->getHdrOutputConversionSupport(&hdrOutputConversionSupport);
37
38 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
39 }
40
TEST(HdrOutputControlTest,testGetHdrConversionCapabilities)41 TEST(HdrOutputControlTest, testGetHdrConversionCapabilities) {
42 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
43
44 bool hdrOutputConversionSupport;
45 binder::Status getSupportStatus =
46 sf->getHdrOutputConversionSupport(&hdrOutputConversionSupport);
47 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(getSupportStatus));
48
49 std::vector<gui::HdrConversionCapability> capabilities;
50 binder::Status status = sf->getHdrConversionCapabilities(&capabilities);
51
52 if (hdrOutputConversionSupport) {
53 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
54 } else {
55 ASSERT_EQ(INVALID_OPERATION, statusTFromBinderStatus(status));
56 }
57 }
58
TEST(HdrOutputControlTest,testSetHdrConversionStrategy)59 TEST(HdrOutputControlTest, testSetHdrConversionStrategy) {
60 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
61
62 bool hdrOutputConversionSupport;
63 binder::Status getSupportStatus =
64 sf->getHdrOutputConversionSupport(&hdrOutputConversionSupport);
65 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(getSupportStatus));
66
67 std::vector<gui::HdrConversionStrategy> strategies = {
68 gui::HdrConversionStrategy::make<GuiHdrConversionStrategyTag::passthrough>(),
69 gui::HdrConversionStrategy::make<GuiHdrConversionStrategyTag::autoAllowedHdrTypes>(),
70 gui::HdrConversionStrategy::make<GuiHdrConversionStrategyTag::forceHdrConversion>(),
71 };
72 int32_t outPreferredHdrOutputType = 0;
73
74 for (const gui::HdrConversionStrategy& strategy : strategies) {
75 binder::Status status = sf->setHdrConversionStrategy(strategy, &outPreferredHdrOutputType);
76
77 if (hdrOutputConversionSupport) {
78 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
79 } else {
80 ASSERT_EQ(INVALID_OPERATION, statusTFromBinderStatus(status));
81 }
82 }
83 }
84
85 } // namespace android
86