1 /*
2 * Copyright 2020 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 <thread>
18
19 #include <gtest/gtest.h>
20
21 #include <gui/AidlStatusUtil.h>
22 #include <gui/SurfaceComposerClient.h>
23 #include <private/gui/ComposerService.h>
24 #include <private/gui/ComposerServiceAIDL.h>
25 #include <chrono>
26
27 namespace android {
28
29 using gui::aidl_utils::statusTFromBinderStatus;
30
TEST(BootDisplayModeTest,setBootDisplayMode)31 TEST(BootDisplayModeTest, setBootDisplayMode) {
32 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
33
34 const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
35 ASSERT_FALSE(ids.empty());
36 auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
37 bool bootModeSupport = false;
38 binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
39 ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status));
40 if (bootModeSupport) {
41 status = sf->setBootDisplayMode(displayToken, 0);
42 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
43 }
44 }
45
TEST(BootDisplayModeTest,clearBootDisplayMode)46 TEST(BootDisplayModeTest, clearBootDisplayMode) {
47 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
48 const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
49 ASSERT_FALSE(ids.empty());
50 auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
51 bool bootModeSupport = false;
52 binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
53 ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status));
54 if (bootModeSupport) {
55 status = sf->clearBootDisplayMode(displayToken);
56 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
57 }
58 }
59
60 } // namespace android
61