blob: f2874ae0e130be154285a4348e8aa9d156ac623b [file] [log] [blame]
Kriti Dang59ff1e72022-02-10 12:41:00 +01001/*
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
Huihong Luo3bdef862022-03-03 11:57:19 -080021#include <gui/AidlStatusUtil.h>
Kriti Dang59ff1e72022-02-10 12:41:00 +010022#include <gui/SurfaceComposerClient.h>
23#include <private/gui/ComposerService.h>
Huihong Luo37396db2022-02-15 10:43:00 -080024#include <private/gui/ComposerServiceAIDL.h>
Kriti Dang59ff1e72022-02-10 12:41:00 +010025#include <chrono>
26
27namespace android {
28
Huihong Luo3bdef862022-03-03 11:57:19 -080029using gui::aidl_utils::statusTFromBinderStatus;
30
Kriti Dang59ff1e72022-02-10 12:41:00 +010031TEST(BootDisplayModeTest, setBootDisplayMode) {
Huihong Luoca3d9a42022-02-22 11:07:34 -080032 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
Huihong Luo31b5ac22022-08-15 20:38:10 -070033
34 const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
35 ASSERT_FALSE(ids.empty());
36 auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
Kriti Dang59ff1e72022-02-10 12:41:00 +010037 bool bootModeSupport = false;
Huihong Luoca3d9a42022-02-22 11:07:34 -080038 binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
Huihong Luo3bdef862022-03-03 11:57:19 -080039 ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status));
Kriti Dang59ff1e72022-02-10 12:41:00 +010040 if (bootModeSupport) {
Huihong Luoca3d9a42022-02-22 11:07:34 -080041 status = sf->setBootDisplayMode(displayToken, 0);
Huihong Luo3bdef862022-03-03 11:57:19 -080042 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
Kriti Dang59ff1e72022-02-10 12:41:00 +010043 }
44}
45
46TEST(BootDisplayModeTest, clearBootDisplayMode) {
Huihong Luo37396db2022-02-15 10:43:00 -080047 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
Huihong Luo31b5ac22022-08-15 20:38:10 -070048 const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
49 ASSERT_FALSE(ids.empty());
50 auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
Kriti Dang59ff1e72022-02-10 12:41:00 +010051 bool bootModeSupport = false;
Huihong Luo37396db2022-02-15 10:43:00 -080052 binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
Huihong Luo3bdef862022-03-03 11:57:19 -080053 ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status));
Kriti Dang59ff1e72022-02-10 12:41:00 +010054 if (bootModeSupport) {
Huihong Luo37396db2022-02-15 10:43:00 -080055 status = sf->clearBootDisplayMode(displayToken);
Huihong Luo3bdef862022-03-03 11:57:19 -080056 ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status));
Kriti Dang59ff1e72022-02-10 12:41:00 +010057 }
58}
59
Huihong Luo37396db2022-02-15 10:43:00 -080060} // namespace android