blob: d70908e390b5b225e9ef296c48afa4e2e7d183ae [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
21#include <gui/SurfaceComposerClient.h>
22#include <private/gui/ComposerService.h>
Huihong Luo37396db2022-02-15 10:43:00 -080023#include <private/gui/ComposerServiceAIDL.h>
Kriti Dang59ff1e72022-02-10 12:41:00 +010024#include <chrono>
25
26namespace android {
27
28TEST(BootDisplayModeTest, setBootDisplayMode) {
29 sp<ISurfaceComposer> sf(ComposerService::getComposerService());
Huihong Luo37396db2022-02-15 10:43:00 -080030 sp<gui::ISurfaceComposer> sf_aidl(ComposerServiceAIDL::getComposerService());
Kriti Dang59ff1e72022-02-10 12:41:00 +010031 auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
32 bool bootModeSupport = false;
Huihong Luo37396db2022-02-15 10:43:00 -080033 binder::Status status = sf_aidl->getBootDisplayModeSupport(&bootModeSupport);
34 ASSERT_NO_FATAL_FAILURE(status.transactionError());
Kriti Dang59ff1e72022-02-10 12:41:00 +010035 if (bootModeSupport) {
36 ASSERT_EQ(NO_ERROR, sf->setBootDisplayMode(displayToken, 0));
37 }
38}
39
40TEST(BootDisplayModeTest, clearBootDisplayMode) {
Huihong Luo37396db2022-02-15 10:43:00 -080041 sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
Kriti Dang59ff1e72022-02-10 12:41:00 +010042 auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
43 bool bootModeSupport = false;
Huihong Luo37396db2022-02-15 10:43:00 -080044 binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
45 ASSERT_NO_FATAL_FAILURE(status.transactionError());
Kriti Dang59ff1e72022-02-10 12:41:00 +010046 if (bootModeSupport) {
Huihong Luo37396db2022-02-15 10:43:00 -080047 status = sf->clearBootDisplayMode(displayToken);
48 ASSERT_EQ(NO_ERROR, status.transactionError());
Kriti Dang59ff1e72022-02-10 12:41:00 +010049 }
50}
51
Huihong Luo37396db2022-02-15 10:43:00 -080052} // namespace android