Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 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 | |
Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame^] | 21 | #include <gui/AidlStatusUtil.h> |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 22 | #include <gui/SurfaceComposerClient.h> |
| 23 | #include <private/gui/ComposerService.h> |
Huihong Luo | 37396db | 2022-02-15 10:43:00 -0800 | [diff] [blame] | 24 | #include <private/gui/ComposerServiceAIDL.h> |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 25 | #include <chrono> |
| 26 | |
| 27 | namespace android { |
| 28 | |
Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame^] | 29 | using gui::aidl_utils::statusTFromBinderStatus; |
| 30 | |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 31 | TEST(BootDisplayModeTest, setBootDisplayMode) { |
Huihong Luo | ca3d9a4 | 2022-02-22 11:07:34 -0800 | [diff] [blame] | 32 | sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService()); |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 33 | auto displayToken = SurfaceComposerClient::getInternalDisplayToken(); |
| 34 | bool bootModeSupport = false; |
Huihong Luo | ca3d9a4 | 2022-02-22 11:07:34 -0800 | [diff] [blame] | 35 | binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport); |
Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame^] | 36 | ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status)); |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 37 | if (bootModeSupport) { |
Huihong Luo | ca3d9a4 | 2022-02-22 11:07:34 -0800 | [diff] [blame] | 38 | status = sf->setBootDisplayMode(displayToken, 0); |
Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame^] | 39 | ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status)); |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | |
| 43 | TEST(BootDisplayModeTest, clearBootDisplayMode) { |
Huihong Luo | 37396db | 2022-02-15 10:43:00 -0800 | [diff] [blame] | 44 | sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService()); |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 45 | auto displayToken = SurfaceComposerClient::getInternalDisplayToken(); |
| 46 | bool bootModeSupport = false; |
Huihong Luo | 37396db | 2022-02-15 10:43:00 -0800 | [diff] [blame] | 47 | binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport); |
Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame^] | 48 | ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status)); |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 49 | if (bootModeSupport) { |
Huihong Luo | 37396db | 2022-02-15 10:43:00 -0800 | [diff] [blame] | 50 | status = sf->clearBootDisplayMode(displayToken); |
Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame^] | 51 | ASSERT_EQ(NO_ERROR, statusTFromBinderStatus(status)); |
Kriti Dang | 59ff1e7 | 2022-02-10 12:41:00 +0100 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
Huihong Luo | 37396db | 2022-02-15 10:43:00 -0800 | [diff] [blame] | 55 | } // namespace android |