已合并
delete redundant code #18378
wulong158创建于 3月10日
delete redundant code #18378
已合并
共 16 个文件变更+4-2267
| @@ -92,8 +92,7 @@ | |||
| 92 | "runtime_core", | 92 | "runtime_core", |
| 93 | "zlib", | 93 | "zlib", |
| 94 | "screenlock_mgr", | 94 | "screenlock_mgr", |
| 95 | - "os_account", | 95 | + "os_account" |
| 96 | - "time_service" | ||
| 97 | ], | 96 | ], |
| 98 | "third_party": [ | 97 | "third_party": [ |
| 99 | ] | 98 | ] |
| @@ -108,7 +108,6 @@ ohos_static_library("libwmutil_static") { | |||
| 108 | "src/window_drawing_content_info.cpp", | 108 | "src/window_drawing_content_info.cpp", |
| 109 | "src/window_frame_trace_impl.cpp", | 109 | "src/window_frame_trace_impl.cpp", |
| 110 | "src/window_property.cpp", | 110 | "src/window_property.cpp", |
| 111 | - "src/window_system_timer.cpp", | ||
| 112 | "src/window_transition_info.cpp", | 111 | "src/window_transition_info.cpp", |
| 113 | "src/window_visibility_info.cpp", | 112 | "src/window_visibility_info.cpp", |
| 114 | "src/wm_math.cpp", | 113 | "src/wm_math.cpp", |
| @@ -145,7 +144,6 @@ ohos_static_library("libwmutil_static") { | |||
| 145 | "ipc:ipc_single", | 144 | "ipc:ipc_single", |
| 146 | "preferences:native_preferences", | 145 | "preferences:native_preferences", |
| 147 | "samgr:samgr_proxy", | 146 | "samgr:samgr_proxy", |
| 148 | - "time_service:time_client", | ||
| 149 | "ability_runtime:wantagent_innerkits", | 147 | "ability_runtime:wantagent_innerkits", |
| 150 | ] | 148 | ] |
| 151 | 149 | ||
| @@ -233,7 +231,6 @@ ohos_shared_library("libwmutil") { | |||
| 233 | "src/vsync_station.cpp", | 231 | "src/vsync_station.cpp", |
| 234 | "src/window_frame_trace_impl.cpp", | 232 | "src/window_frame_trace_impl.cpp", |
| 235 | "src/window_property.cpp", | 233 | "src/window_property.cpp", |
| 236 | - "src/window_system_timer.cpp", | ||
| 237 | "src/window_transition_info.cpp", | 234 | "src/window_transition_info.cpp", |
| 238 | "src/ffrt_queue_helper.cpp", | 235 | "src/ffrt_queue_helper.cpp", |
| 239 | "src/ffrt_serial_queue_helper.cpp", | 236 | "src/ffrt_serial_queue_helper.cpp", |
| @@ -271,7 +268,6 @@ ohos_shared_library("libwmutil") { | |||
| 271 | "input:libmmi-client", | 268 | "input:libmmi-client", |
| 272 | "ipc:ipc_single", | 269 | "ipc:ipc_single", |
| 273 | "samgr:samgr_proxy", | 270 | "samgr:samgr_proxy", |
| 274 | - "time_service:time_client", | ||
| 275 | "ability_runtime:wantagent_innerkits", | 271 | "ability_runtime:wantagent_innerkits", |
| 276 | ] | 272 | ] |
| 277 | if (!(host_os == "linux" && host_cpu == "arm64")) { | 273 | if (!(host_os == "linux" && host_cpu == "arm64")) { |
| @@ -1,48 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (C) 2025-2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | -namespace OHOS { | ||
| 29 | -namespace Rosen { | ||
| 30 | -class WindowSysTimer : public MiscServices::ITimerInfo { | ||
| 31 | -public: | ||
| 32 | - WindowSysTimer(); | ||
| 33 | - WindowSysTimer(bool repeat, uint64_t interval, bool isExact = false); | ||
| 34 | - virtual ~WindowSysTimer(); | ||
| 35 | - void OnTrigger() override; | ||
| 36 | - void SetType(const int &type) override; | ||
| 37 | - void SetRepeat(bool repeat) override; | ||
| 38 | - void SetInterval(const uint64_t &interval) override; | ||
| 39 | - void SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent) override; | ||
| 40 | - void SetCallbackInfo(const std::function<void()> &callBack); | ||
| 41 | - | ||
| 42 | -private: | ||
| 43 | - std::function<void()> callBack_ = nullptr; | ||
| 44 | -}; | ||
| 45 | - | ||
| 46 | -} // namespace Rosen | ||
| 47 | -} // namespace OHOS | ||
| 48 | - | ||
| @@ -1,69 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (C) 2025-2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | -namespace OHOS { | ||
| 20 | -namespace Rosen { | ||
| 21 | - | ||
| 22 | -WindowSysTimer::WindowSysTimer() {} | ||
| 23 | - | ||
| 24 | -WindowSysTimer::~WindowSysTimer() {} | ||
| 25 | - | ||
| 26 | -WindowSysTimer::WindowSysTimer(bool repeat, uint64_t interval, bool isExact) | ||
| 27 | -{ | ||
| 28 | - this->repeat = repeat; | ||
| 29 | - this->interval = interval; | ||
| 30 | - this->type = TIMER_TYPE_REALTIME + TIMER_TYPE_WAKEUP; | ||
| 31 | - if (isExact) { | ||
| 32 | - this->type = | ||
| 33 | - static_cast<int32_t>(static_cast<uint32_t>(TIMER_TYPE_WAKEUP) | static_cast<uint32_t>(TIMER_TYPE_EXACT)); | ||
| 34 | - } | ||
| 35 | -} | ||
| 36 | - | ||
| 37 | -void WindowSysTimer::OnTrigger() | ||
| 38 | -{ | ||
| 39 | - if (callBack_ != nullptr) { | ||
| 40 | - callBack_(); | ||
| 41 | - } | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -void WindowSysTimer::SetCallbackInfo(const std::function<void()> &callBack) | ||
| 45 | -{ | ||
| 46 | - this->callBack_ = callBack; | ||
| 47 | -} | ||
| 48 | - | ||
| 49 | -void WindowSysTimer::SetType(const int &type) | ||
| 50 | -{ | ||
| 51 | - this->type = type; | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -void WindowSysTimer::SetRepeat(bool repeat) | ||
| 55 | -{ | ||
| 56 | - this->repeat = repeat; | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -void WindowSysTimer::SetInterval(const uint64_t &interval) | ||
| 60 | -{ | ||
| 61 | - this->interval = interval; | ||
| 62 | -} | ||
| 63 | - | ||
| 64 | -void WindowSysTimer::SetWantAgent(std::shared_ptr<OHOS::AbilityRuntime::WantAgent::WantAgent> wantAgent) | ||
| 65 | -{ | ||
| 66 | - this->wantAgent = wantAgent; | ||
| 67 | -} | ||
| 68 | -} // namespace Rosen | ||
| 69 | -} // namespace OHOS | ||
| @@ -70,7 +70,6 @@ test_external_deps = [ | |||
| 70 | "init:libbegetutil", | 70 | "init:libbegetutil", |
| 71 | "input:libmmi-client", | 71 | "input:libmmi-client", |
| 72 | "preferences:native_preferences", | 72 | "preferences:native_preferences", |
| 73 | - "time_service:time_client", | ||
| 74 | ] | 73 | ] |
| 75 | 74 | ||
| 76 | ohos_unittest("utils_task_sequence_process_test") { | 75 | ohos_unittest("utils_task_sequence_process_test") { |
| @@ -144,8 +144,6 @@ ohos_shared_library("screen_session_manager") { | |||
| 144 | "safwk:system_ability_fwk", | 144 | "safwk:system_ability_fwk", |
| 145 | "samgr:samgr_proxy", | 145 | "samgr:samgr_proxy", |
| 146 | "screenlock_mgr:screenlock_client", | 146 | "screenlock_mgr:screenlock_client", |
| 147 | - "time_service:time_client", | ||
| 148 | - "ability_runtime:wantagent_innerkits", | ||
| 149 | ] | 147 | ] |
| 150 | 148 | ||
| 151 | defines = [] | 149 | defines = [] |
| @@ -208,10 +206,8 @@ ohos_shared_library("screen_session_manager") { | |||
| 208 | "src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp", | 206 | "src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp", |
| 209 | "src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_fold_state_manager.cpp", | 207 | "src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_fold_state_manager.cpp", |
| 210 | "src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_pocket_fold_state_manager.cpp", | 208 | "src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_pocket_fold_state_manager.cpp", |
| 211 | - "src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_super_fold_state_manager.cpp", | ||
| 212 | "src/fold_screen_controller/single_display_fold_policy.cpp", | 209 | "src/fold_screen_controller/single_display_fold_policy.cpp", |
| 213 | "src/fold_screen_controller/single_display_pocket_fold_policy.cpp", | 210 | "src/fold_screen_controller/single_display_pocket_fold_policy.cpp", |
| 214 | - "src/fold_screen_controller/single_display_super_fold_policy.cpp", | ||
| 215 | "src/fold_screen_controller/super_fold_policy.cpp", | 211 | "src/fold_screen_controller/super_fold_policy.cpp", |
| 216 | "src/fold_screen_controller/super_fold_sensor_manager.cpp", | 212 | "src/fold_screen_controller/super_fold_sensor_manager.cpp", |
| 217 | "src/fold_screen_controller/super_fold_state_manager.cpp", | 213 | "src/fold_screen_controller/super_fold_state_manager.cpp", |
| @@ -1,48 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | -namespace OHOS { | ||
| 24 | -namespace Rosen { | ||
| 25 | -class SingleDisplaySensorSuperFoldStateManager : public SensorFoldStateManager { | ||
| 26 | -public: | ||
| 27 | - SingleDisplaySensorSuperFoldStateManager(); | ||
| 28 | - virtual ~SingleDisplaySensorSuperFoldStateManager(); | ||
| 29 | - | ||
| 30 | - void HandleAngleChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) override; | ||
| 31 | - void HandleHallChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy) override; | ||
| 32 | - void HandleTentChange(int tentType, sptr<FoldScreenPolicy> foldScreenPolicy, int32_t hall = -1) override; | ||
| 33 | - void RegisterApplicationStateObserver() override; | ||
| 34 | - | ||
| 35 | -private: | ||
| 36 | - FoldStatus GetNextFoldState(float angle, int hall); | ||
| 37 | - void UpdateSwitchScreenBoundaryForLargeFoldDevice(float, int); | ||
| 38 | - int allowUserSensorForLargeFoldDevice = 0; | ||
| 39 | - bool TriggerTentExit(float angle, int hall); | ||
| 40 | - void TentModeHandleSensorChange(float angle, int hall, sptr<FoldScreenPolicy> foldScreenPolicy); | ||
| 41 | - void ReportTentStatusChange(ReportTentModeStatus tentStatus); | ||
| 42 | - void SetDeviceStatusAndParam(uint32_t deviceStatus); | ||
| 43 | - float currentAngle_ = -1.0F; | ||
| 44 | - int currentHall_ = -1; | ||
| 45 | -}; | ||
| 46 | -} // namespace Rosen | ||
| 47 | -} // namespace OHOS | ||
| 48 | - | ||
| @@ -1,85 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | -namespace OHOS::Rosen { | ||
| 27 | -class SingleDisplaySuperFoldPolicy : public FoldScreenPolicy { | ||
| 28 | -public: | ||
| 29 | - SingleDisplaySuperFoldPolicy(std::recursive_mutex& displayInfoMutex, | ||
| 30 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler); | ||
| 31 | - ~SingleDisplaySuperFoldPolicy() = default; | ||
| 32 | - void ChangeScreenDisplayMode(FoldDisplayMode displayMode, | ||
| 33 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT) override; | ||
| 34 | - void SendSensorResult(FoldStatus foldStatus) override; | ||
| 35 | - sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() override; | ||
| 36 | - FoldCreaseRegion GetLiveCreaseRegion() override; | ||
| 37 | - void LockDisplayStatus(bool locked) override; | ||
| 38 | - void SetOnBootAnimation(bool onBootAnimation) override; | ||
| 39 | - void UpdateForPhyScreenPropertyChange() override; | ||
| 40 | - void ExitCoordination() override; | ||
| 41 | - void AddOrRemoveDisplayNodeToTree(ScreenId screenId, int32_t command) override; | ||
| 42 | - FoldDisplayMode GetModeMatchStatus() override; | ||
| 43 | - FoldDisplayMode GetModeMatchStatus(FoldStatus targetFoldStatus) override; | ||
| 44 | - void SetIsClearingBootAnimation(bool isClearingBootAnimation) override; | ||
| 45 | - void GetAllCreaseRegion(std::vector<FoldCreaseRegionItem>& foldCreaseRegionItems) const override; | ||
| 46 | -private: | ||
| 47 | - bool CheckDisplayModeChange(FoldDisplayMode displayMode, bool isForce, | ||
| 48 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT); | ||
| 49 | - void ChangeScreenDisplayMode(FoldDisplayMode displayMode, bool isForce, | ||
| 50 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT); | ||
| 51 | - void ChangeScreenDisplayModeToMain(sptr<ScreenSession> screenSession, | ||
| 52 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT); | ||
| 53 | - void ChangeScreenDisplayModeToFull(sptr<ScreenSession> screenSession, | ||
| 54 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT); | ||
| 55 | - void ChangeScreenDisplayModeToMainWhenFoldScreenOn(sptr<ScreenSession> screenSession); | ||
| 56 | - void ChangeScreenDisplayModeToMainWhenFoldScreenOff(sptr<ScreenSession> screenSession); | ||
| 57 | - void ChangeScreenDisplayModeToFullWhenFoldScreenOn(sptr<ScreenSession> screenSession); | ||
| 58 | - void ChangeScreenDisplayModeToFullWhenFoldScreenOff(sptr<ScreenSession> screenSession, | ||
| 59 | - DisplayModeChangeReason reason); | ||
| 60 | - void ChangeScreenDisplayModeToMainOnBootAnimation(sptr<ScreenSession> screenSession); | ||
| 61 | - void ChangeScreenDisplayModeToFullOnBootAnimation(sptr<ScreenSession> screenSession); | ||
| 62 | - void ChangeScreenDisplayModePower(ScreenId screenId, ScreenPowerStatus screenPowerStatus); | ||
| 63 | - void RecoverWhenBootAnimationExit(); | ||
| 64 | - void ReportFoldDisplayModeChange(FoldDisplayMode displayMode); | ||
| 65 | - void ReportFoldStatusChangeBegin(int32_t offScreen, int32_t onScreen); | ||
| 66 | - void SendPropertyChangeResult(sptr<ScreenSession> screenSession, ScreenId screenId, | ||
| 67 | - ScreenPropertyChangeReason reason); | ||
| 68 | - void SetdisplayModeChangeStatus(bool status, bool isOnBootAnimation = false) override; | ||
| 69 | - void ChangeScreenDisplayModeInner(FoldDisplayMode displayMode, DisplayModeChangeReason reason); | ||
| 70 | - FoldCreaseRegion GetFoldCreaseRegion(bool isVertical) const; | ||
| 71 | - void GetFoldCreaseRect(bool isVertical, const std::vector<int32_t>& foldRect, | ||
| 72 | - std::vector<DMRect>& foldCreaseRect) const; | ||
| 73 | - void ChangeScreenDisplayModeToCoordination(); | ||
| 74 | - void CloseCoordinationScreen(); | ||
| 75 | - void NotifyRefreshRateEvent(bool isEventStatus); | ||
| 76 | - void UpdateDeviceStatus(FoldDisplayMode displayMode); | ||
| 77 | - void ChangeOnTentMode(FoldStatus currentState) override; | ||
| 78 | - void ChangeOffTentMode() override; | ||
| 79 | - std::vector<DMRect> GetFoldCreaseRegionRect(bool isVertical) const; | ||
| 80 | - std::mutex coordinationMutex_; | ||
| 81 | - std::recursive_mutex& displayInfoMutex_; | ||
| 82 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler_; | ||
| 83 | -}; | ||
| 84 | -} // namespace OHOS::Rosen | ||
| 85 | - | ||
| @@ -17,12 +17,10 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | - | ||
| 21 | 20 | ||
| 22 | 21 | ||
| 23 | 22 | ||
| 24 | 23 | ||
| 25 | - | ||
| 26 | 24 | ||
| 27 | 25 | ||
| 28 | 26 | ||
| @@ -134,10 +132,6 @@ sptr<FoldScreenPolicy> FoldScreenController::GetFoldScreenPolicy(DisplayDeviceTy | |||
| 134 | tempPolicy = new SecondaryDisplayFoldPolicy(displayInfoMutex_, screenPowerTaskScheduler_); | 132 | tempPolicy = new SecondaryDisplayFoldPolicy(displayInfoMutex_, screenPowerTaskScheduler_); |
| 135 | break; | 133 | break; |
| 136 | } | 134 | } |
| 137 | - case DisplayDeviceType::SINGLE_DISPLAY_SUPER_DEVICE:{ | ||
| 138 | - tempPolicy = new SingleDisplaySuperFoldPolicy(displayInfoMutex_, screenPowerTaskScheduler_); | ||
| 139 | - break; | ||
| 140 | - } | ||
| 141 | default: { | 135 | default: { |
| 142 | TLOGE(WmsLogTag::DMS, "DisplayDeviceType is invalid"); | 136 | TLOGE(WmsLogTag::DMS, "DisplayDeviceType is invalid"); |
| 143 | break; | 137 | break; |
| @@ -1,227 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | -namespace OHOS::Rosen { | ||
| 36 | -namespace { | ||
| 37 | -constexpr int32_t LARGER_BOUNDARY_FLAG = 1; | ||
| 38 | -constexpr int32_t SMALLER_BOUNDARY_FLAG = 0; | ||
| 39 | -constexpr int32_t HALL_THRESHOLD = 1; | ||
| 40 | -constexpr int32_t HALL_FOLDED_THRESHOLD = 0; | ||
| 41 | -constexpr float TENT_MODE_EXIT_MIN_THRESHOLD = 5.0F; | ||
| 42 | -constexpr float TENT_MODE_EXIT_MAX_THRESHOLD = 175.0F; | ||
| 43 | -constexpr int32_t TENT_MODE_OFF = 0; | ||
| 44 | -constexpr int32_t TENT_MODE_ON = 1; | ||
| 45 | -} // namespace | ||
| 46 | - | ||
| 47 | -SingleDisplaySensorSuperFoldStateManager::SingleDisplaySensorSuperFoldStateManager() {} | ||
| 48 | -SingleDisplaySensorSuperFoldStateManager::~SingleDisplaySensorSuperFoldStateManager() {} | ||
| 49 | - | ||
| 50 | -void SingleDisplaySensorSuperFoldStateManager::HandleAngleChange(float angle, int hall, | ||
| 51 | - sptr<FoldScreenPolicy> foldScreenPolicy) | ||
| 52 | -{ | ||
| 53 | - currentAngle_ = angle; | ||
| 54 | - if (IsTentMode()) { | ||
| 55 | - return TentModeHandleSensorChange(angle, hall, foldScreenPolicy); | ||
| 56 | - } | ||
| 57 | - FoldStatus nextState = GetNextFoldState(angle, hall); | ||
| 58 | - HandleSensorChange(nextState, angle, foldScreenPolicy); | ||
| 59 | -} | ||
| 60 | - | ||
| 61 | -void SingleDisplaySensorSuperFoldStateManager::HandleHallChange(float angle, int hall, | ||
| 62 | - sptr<FoldScreenPolicy> foldScreenPolicy) | ||
| 63 | -{ | ||
| 64 | - currentHall_ = hall; | ||
| 65 | - if (IsTentMode()) { | ||
| 66 | - return TentModeHandleSensorChange(angle, hall, foldScreenPolicy); | ||
| 67 | - } | ||
| 68 | - FoldStatus nextState = GetNextFoldState(angle, hall); | ||
| 69 | - HandleSensorChange(nextState, angle, foldScreenPolicy); | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -void SingleDisplaySensorSuperFoldStateManager::UpdateSwitchScreenBoundaryForLargeFoldDevice(float angle, int hall) | ||
| 73 | -{ | ||
| 74 | - if (hall == HALL_FOLDED_THRESHOLD) { | ||
| 75 | - allowUserSensorForLargeFoldDevice = SMALLER_BOUNDARY_FLAG; | ||
| 76 | - } else if (std::isgreaterequal(angle, LARGER_BOUNDARY_FOR_THRESHOLD)) { | ||
| 77 | - allowUserSensorForLargeFoldDevice = LARGER_BOUNDARY_FLAG; | ||
| 78 | - } | ||
| 79 | -} | ||
| 80 | - | ||
| 81 | -FoldStatus SingleDisplaySensorSuperFoldStateManager::GetNextFoldState(float angle, int hall) | ||
| 82 | -{ | ||
| 83 | - UpdateSwitchScreenBoundaryForLargeFoldDevice(angle, hall); | ||
| 84 | - FoldStatus currentState = GetCurrentState(); | ||
| 85 | - if (std::isless(angle, ANGLE_MIN_VAL)) { | ||
| 86 | - return currentState; | ||
| 87 | - } | ||
| 88 | - FoldStatus state; | ||
| 89 | - | ||
| 90 | - if (allowUserSensorForLargeFoldDevice == SMALLER_BOUNDARY_FLAG) { | ||
| 91 | - if (std::islessequal(angle, OPEN_HALF_FOLDED_MIN_THRESHOLD) && hall == HALL_FOLDED_THRESHOLD) { | ||
| 92 | - state = FoldStatus::FOLDED; | ||
| 93 | - } else if (std::isgreaterequal(angle, OPEN_HALF_FOLDED_MIN_THRESHOLD + HALF_FOLDED_BUFFER) && | ||
| 94 | - hall == HALL_FOLDED_THRESHOLD) { | ||
| 95 | - state = FoldStatus::HALF_FOLD; | ||
| 96 | - } else if (std::islessequal(angle, HALF_FOLDED_MAX_THRESHOLD - HALF_FOLDED_BUFFER) && | ||
| 97 | - hall == HALL_THRESHOLD) { | ||
| 98 | - state = FoldStatus::HALF_FOLD; | ||
| 99 | - } else if (std::isgreaterequal(angle, HALF_FOLDED_MAX_THRESHOLD)) { | ||
| 100 | - state = FoldStatus::EXPAND; | ||
| 101 | - } else { | ||
| 102 | - state = currentState; | ||
| 103 | - if (state == FoldStatus::UNKNOWN) { | ||
| 104 | - state = FoldStatus::HALF_FOLD; | ||
| 105 | - } | ||
| 106 | - } | ||
| 107 | - return state; | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - if (hall == HALL_THRESHOLD && (std::fabs(angle - OPEN_HALF_FOLDED_MIN_THRESHOLD) < 1e-3)) { | ||
| 111 | - state = currentState; | ||
| 112 | - } else if (std::islessequal(angle, CLOSE_HALF_FOLDED_MIN_THRESHOLD)) { | ||
| 113 | - state = FoldStatus::FOLDED; | ||
| 114 | - } else if (std::islessequal(angle, HALF_FOLDED_MAX_THRESHOLD - HALF_FOLDED_BUFFER) && | ||
| 115 | - std::isgreater(angle, CLOSE_HALF_FOLDED_MIN_THRESHOLD + HALF_FOLDED_BUFFER)) { | ||
| 116 | - state = FoldStatus::HALF_FOLD; | ||
| 117 | - } else if (std::isgreaterequal(angle, HALF_FOLDED_MAX_THRESHOLD)) { | ||
| 118 | - state = FoldStatus::EXPAND; | ||
| 119 | - } else { | ||
| 120 | - state = currentState; | ||
| 121 | - if (state == FoldStatus::UNKNOWN) { | ||
| 122 | - state = FoldStatus::HALF_FOLD; | ||
| 123 | - } | ||
| 124 | - } | ||
| 125 | - return state; | ||
| 126 | -} | ||
| 127 | - | ||
| 128 | -void SingleDisplaySensorSuperFoldStateManager::RegisterApplicationStateObserver() {} | ||
| 129 | - | ||
| 130 | -void SingleDisplaySensorSuperFoldStateManager::HandleTentChange(int tentType, | ||
| 131 | - sptr<FoldScreenPolicy> foldScreenPolicy, int32_t hall) | ||
| 132 | -{ | ||
| 133 | - if (tentType == tentModeType_) { | ||
| 134 | - TLOGI(WmsLogTag::DMS, "Repeat reporting tent mode:%{public}d, no processing", tentModeType_); | ||
| 135 | - return; | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - SetTentMode(tentType); | ||
| 139 | - if (foldScreenPolicy == nullptr) { | ||
| 140 | - TLOGE(WmsLogTag::DMS, "foldScreenPolicy is nullptr"); | ||
| 141 | - return; | ||
| 142 | - } | ||
| 143 | - if (tentType != TENT_MODE_OFF) { | ||
| 144 | - ReportTentStatusChange(ReportTentModeStatus::NORMAL_ENTER_TENT_MODE); | ||
| 145 | - HandleSensorChange(FoldStatus::FOLDED, currentAngle_, foldScreenPolicy); | ||
| 146 | - foldScreenPolicy->ChangeOnTentMode(FoldStatus::FOLDED); | ||
| 147 | - if (tentType == TENT_MODE_ON) { | ||
| 148 | - SetDeviceStatusAndParam(static_cast<uint32_t>(DMDeviceStatus::STATUS_TENT)); | ||
| 149 | - ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::TENT_STATUS); | ||
| 150 | - } | ||
| 151 | - } else { | ||
| 152 | - if (hall == HALL_FOLDED_THRESHOLD) { | ||
| 153 | - currentAngle_ = ANGLE_MIN_VAL; | ||
| 154 | - } | ||
| 155 | - FoldStatus nextState = FoldStatus::UNKNOWN; | ||
| 156 | - if (hall == -1) { | ||
| 157 | - nextState = GetNextFoldState(currentAngle_, currentHall_); | ||
| 158 | - } else { | ||
| 159 | - nextState = GetNextFoldState(currentAngle_, hall); | ||
| 160 | - } | ||
| 161 | - if (nextState == FoldStatus::FOLDED) { | ||
| 162 | - SetDeviceStatusAndParam(static_cast<uint32_t>(DMDeviceStatus::STATUS_FOLDED)); | ||
| 163 | - } else { | ||
| 164 | - SetDeviceStatusAndParam(static_cast<uint32_t>(DMDeviceStatus::UNKNOWN)); | ||
| 165 | - } | ||
| 166 | - HandleSensorChange(nextState, currentAngle_, foldScreenPolicy); | ||
| 167 | - ReportTentStatusChange(ReportTentModeStatus::NORMAL_EXIT_TENT_MODE); | ||
| 168 | - foldScreenPolicy->ChangeOffTentMode(); | ||
| 169 | - ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::TENT_STATUS_CANCEL); | ||
| 170 | - } | ||
| 171 | -} | ||
| 172 | - | ||
| 173 | -bool SingleDisplaySensorSuperFoldStateManager::TriggerTentExit(float angle, int hall) | ||
| 174 | -{ | ||
| 175 | - if (hall == HALL_FOLDED_THRESHOLD) { | ||
| 176 | - ReportTentStatusChange(ReportTentModeStatus::ABNORMAL_EXIT_TENT_MODE_DUE_TO_HALL); | ||
| 177 | - TLOGI(WmsLogTag::DMS, "Exit tent mode due to hall sensor report folded"); | ||
| 178 | - return true; | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - if (std::isless(angle, TENT_MODE_EXIT_MIN_THRESHOLD) || std::isgreater(angle, TENT_MODE_EXIT_MAX_THRESHOLD)) { | ||
| 182 | - ReportTentStatusChange(ReportTentModeStatus::ABNORMAL_EXIT_TENT_MODE_DUE_TO_ANGLE); | ||
| 183 | - TLOGI(WmsLogTag::DMS, "Exit tent mode due to angle sensor report angle:%{public}f", angle); | ||
| 184 | - return true; | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - return false; | ||
| 188 | -} | ||
| 189 | - | ||
| 190 | -void SingleDisplaySensorSuperFoldStateManager::TentModeHandleSensorChange(float angle, int hall, | ||
| 191 | - sptr<FoldScreenPolicy> foldScreenPolicy) | ||
| 192 | -{ | ||
| 193 | - if (TriggerTentExit(angle, hall)) { | ||
| 194 | - FoldStatus nextState = GetNextFoldState(angle, hall); | ||
| 195 | - HandleSensorChange(nextState, angle, foldScreenPolicy); | ||
| 196 | - TLOGI(WmsLogTag::DMS, "exit tent mode. angle: %{public}f, hall: %{public}d", angle, hall); | ||
| 197 | - SetTentMode(TENT_MODE_OFF); | ||
| 198 | - if (nextState == FoldStatus::FOLDED) { | ||
| 199 | - SetDeviceStatusAndParam(static_cast<uint32_t>(DMDeviceStatus::STATUS_FOLDED)); | ||
| 200 | - } else { | ||
| 201 | - SetDeviceStatusAndParam(static_cast<uint32_t>(DMDeviceStatus::UNKNOWN)); | ||
| 202 | - } | ||
| 203 | - ScreenRotationProperty::HandleHoverStatusEventInput(DeviceHoverStatus::TENT_STATUS_CANCEL); | ||
| 204 | - } | ||
| 205 | -} | ||
| 206 | - | ||
| 207 | -void SingleDisplaySensorSuperFoldStateManager::ReportTentStatusChange(ReportTentModeStatus tentStatus) | ||
| 208 | -{ | ||
| 209 | - int32_t status = static_cast<int32_t>(tentStatus); | ||
| 210 | - TLOGI(WmsLogTag::DMS, "report tentStatus: %{public}d", status); | ||
| 211 | - int32_t ret = HiSysEventWrite( | ||
| 212 | - OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER, | ||
| 213 | - "FOLD_TENT_MODE", | ||
| 214 | - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, | ||
| 215 | - "FOLD_TENT_STATUS", status); | ||
| 216 | - if (ret != 0) { | ||
| 217 | - TLOGE(WmsLogTag::DMS, "Write HiSysEvent error, ret: %{public}d", ret); | ||
| 218 | - } | ||
| 219 | -} | ||
| 220 | - | ||
| 221 | -void SingleDisplaySensorSuperFoldStateManager::SetDeviceStatusAndParam(uint32_t deviceStatus) | ||
| 222 | -{ | ||
| 223 | - TLOGI(WmsLogTag::DMS, "Set device status to: %{public}u", deviceStatus); | ||
| 224 | - SetDeviceStatus(deviceStatus); | ||
| 225 | - system::SetParameter("persist.dms.device.status", std::to_string(deviceStatus)); | ||
| 226 | -} | ||
| 227 | -} // namespace OHOS::Rosen | ||
Dwindow_scene/screen_session_manager/src/fold_screen_controller/single_display_super_fold_policy.cpp+0-741
| @@ -343,7 +343,9 @@ void ScreenSessionManager::LoadDmsExtension() | |||
| 343 | } | 343 | } |
| 344 | bool ScreenSessionManager::GetScreenSessionMngSystemAbility() | 344 | bool ScreenSessionManager::GetScreenSessionMngSystemAbility() |
| 345 | { | 345 | { |
| 346 | - ScreenSessionManager::LoadDmsExtension(); | 346 | + if (DEVICE_TYPE != "phone") { |
| 347 | + ScreenSessionManager::LoadDmsExtension(); | ||
| 348 | + } | ||
| 347 | return SystemAbility::MakeAndRegisterAbility(&ScreenSessionManager::GetInstance()); | 349 | return SystemAbility::MakeAndRegisterAbility(&ScreenSessionManager::GetInstance()); |
| 348 | } | 350 | } |
| 349 | const bool REGISTER_RESULT = !SceneBoardJudgement::IsSceneBoardEnabled() ? false : ScreenSessionManager::GetScreenSessionMngSystemAbility(); | 351 | const bool REGISTER_RESULT = !SceneBoardJudgement::IsSceneBoardEnabled() ? false : ScreenSessionManager::GetScreenSessionMngSystemAbility(); |
| @@ -83,10 +83,8 @@ group("unittest") { | |||
| 83 | ":ws_sensor_fold_state_manager_test", | 83 | ":ws_sensor_fold_state_manager_test", |
| 84 | ":ws_single_display_fold_policy_test", | 84 | ":ws_single_display_fold_policy_test", |
| 85 | ":ws_single_display_pocket_fold_policy_test", | 85 | ":ws_single_display_pocket_fold_policy_test", |
| 86 | - ":ws_single_display_super_fold_policy_test", | ||
| 87 | ":ws_single_display_sensor_fold_state_manager_test", | 86 | ":ws_single_display_sensor_fold_state_manager_test", |
| 88 | ":ws_single_display_sensor_pocket_fold_state_manager_test", | 87 | ":ws_single_display_sensor_pocket_fold_state_manager_test", |
| 89 | - ":ws_single_display_sensor_super_fold_state_manager_test", | ||
| 90 | ":ws_super_fold_sensor_manager_test", | 88 | ":ws_super_fold_sensor_manager_test", |
| 91 | ":ws_super_fold_state_manager_test", | 89 | ":ws_super_fold_state_manager_test", |
| 92 | ":ws_screen_sensor_mgr_test", | 90 | ":ws_screen_sensor_mgr_test", |
| @@ -1231,17 +1229,6 @@ if (window_manager_fold_ability) { | |||
| 1231 | ] | 1229 | ] |
| 1232 | } | 1230 | } |
| 1233 | 1231 | ||
| 1234 | - ohos_unittest("ws_single_display_super_fold_policy_test") { | ||
| 1235 | - module_out_path = module_out_path | ||
| 1236 | - | ||
| 1237 | - sources = [ "single_display_super_fold_policy_test.cpp" ] | ||
| 1238 | - | ||
| 1239 | - deps = [ ":ws_unittest_common" ] | ||
| 1240 | - | ||
| 1241 | - external_deps = test_external_deps | ||
| 1242 | - external_deps += [ "init:libbegetutil" ] | ||
| 1243 | - } | ||
| 1244 | - | ||
| 1245 | ohos_unittest("ws_sensor_fold_state_manager_test") { | 1232 | ohos_unittest("ws_sensor_fold_state_manager_test") { |
| 1246 | module_out_path = module_out_path | 1233 | module_out_path = module_out_path |
| 1247 | 1234 | ||
| @@ -1375,20 +1362,6 @@ if (window_manager_fold_ability) { | |||
| 1375 | external_deps += [ "init:libbegetutil" ] | 1362 | external_deps += [ "init:libbegetutil" ] |
| 1376 | } | 1363 | } |
| 1377 | 1364 | ||
| 1378 | - ohos_unittest("ws_single_display_sensor_super_fold_state_manager_test") { | ||
| 1379 | - module_out_path = module_out_path | ||
| 1380 | - | ||
| 1381 | - sources = [ "single_display_sensor_super_fold_state_manager_test.cpp" ] | ||
| 1382 | - | ||
| 1383 | - deps = [ | ||
| 1384 | - ":ws_unittest_common", | ||
| 1385 | - "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", | ||
| 1386 | - ] | ||
| 1387 | - | ||
| 1388 | - external_deps = test_external_deps | ||
| 1389 | - external_deps += [ "init:libbegetutil" ] | ||
| 1390 | - } | ||
| 1391 | - | ||
| 1392 | ohos_unittest("ws_super_fold_state_manager_test") { | 1365 | ohos_unittest("ws_super_fold_state_manager_test") { |
| 1393 | module_out_path = module_out_path | 1366 | module_out_path = module_out_path |
| 1394 | 1367 | ||
| @@ -64,8 +64,6 @@ test_external_deps = [ | |||
| 64 | "hitrace:hitrace_meter", | 64 | "hitrace:hitrace_meter", |
| 65 | "ipc:ipc_core", | 65 | "ipc:ipc_core", |
| 66 | "samgr:samgr_proxy", | 66 | "samgr:samgr_proxy", |
| 67 | - "time_service:time_client", | ||
| 68 | - "ability_runtime:wantagent_innerkits", | ||
| 69 | "init:libbegetutil", | 67 | "init:libbegetutil", |
| 70 | ] | 68 | ] |
| 71 | 69 | ||
| @@ -109,10 +107,8 @@ test_source_common = [ | |||
| 109 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp", | 107 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp", |
| 110 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_fold_state_manager.cpp", | 108 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_fold_state_manager.cpp", |
| 111 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_pocket_fold_state_manager.cpp", | 109 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_pocket_fold_state_manager.cpp", |
| 112 | - "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/single_display_sensor_super_fold_state_manager.cpp", | ||
| 113 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp", | 110 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp", |
| 114 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp", | 111 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp", |
| 115 | - "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/single_display_super_fold_policy.cpp", | ||
| 116 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_policy.cpp", | 112 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_policy.cpp", |
| 117 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp", | 113 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp", |
| 118 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp", | 114 | "${window_base_path}/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp", |
| @@ -1,351 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | -using namespace testing; | ||
| 26 | -using namespace testing::ext; | ||
| 27 | - | ||
| 28 | -namespace OHOS { | ||
| 29 | -namespace Rosen { | ||
| 30 | -namespace { | ||
| 31 | -constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms | ||
| 32 | -} | ||
| 33 | -class SingleDisplaySensorSuperFoldStateManagerTest : public testing::Test { | ||
| 34 | -public: | ||
| 35 | - static void SetUpTestCase(); | ||
| 36 | - static void TearDownTestCase(); | ||
| 37 | - void SetUp() override; | ||
| 38 | - void TearDown() override; | ||
| 39 | -}; | ||
| 40 | - | ||
| 41 | -void SingleDisplaySensorSuperFoldStateManagerTest::SetUpTestCase() | ||
| 42 | -{ | ||
| 43 | -} | ||
| 44 | - | ||
| 45 | -void SingleDisplaySensorSuperFoldStateManagerTest::TearDownTestCase() | ||
| 46 | -{ | ||
| 47 | - usleep(SLEEP_TIME_IN_US); | ||
| 48 | -} | ||
| 49 | - | ||
| 50 | -void SingleDisplaySensorSuperFoldStateManagerTest::SetUp() | ||
| 51 | -{ | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -void SingleDisplaySensorSuperFoldStateManagerTest::TearDown() | ||
| 55 | -{ | ||
| 56 | -} | ||
| 57 | - | ||
| 58 | -namespace { | ||
| 59 | -/** | ||
| 60 | - * @tc.name: HandleAngleChange | ||
| 61 | - * @tc.desc: test function : HandleAngleChange | ||
| 62 | - * @tc.type: FUNC | ||
| 63 | - */ | ||
| 64 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, HandleAngleChange, TestSize.Level1) | ||
| 65 | -{ | ||
| 66 | - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { | ||
| 67 | - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; | ||
| 68 | - } | ||
| 69 | - float angel = 0; | ||
| 70 | - int hall = 0; | ||
| 71 | - sptr<FoldScreenPolicy> foldScreenPolicy = nullptr; | ||
| 72 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 73 | - manager.HandleAngleChange(angel, hall, foldScreenPolicy); | ||
| 74 | - EXPECT_EQ(manager.mState_, FoldStatus::UNKNOWN); | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | -/** | ||
| 78 | - * @tc.name: HandleHallChange | ||
| 79 | - * @tc.desc: test function : HandleHallChange | ||
| 80 | - * @tc.type: FUNC | ||
| 81 | - */ | ||
| 82 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, HandleHallChange, TestSize.Level1) | ||
| 83 | -{ | ||
| 84 | - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { | ||
| 85 | - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; | ||
| 86 | - } | ||
| 87 | - float angel = 0; | ||
| 88 | - int hall = 0; | ||
| 89 | - sptr<FoldScreenPolicy> foldScreenPolicy = nullptr; | ||
| 90 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 91 | - manager.HandleHallChange(angel, hall, foldScreenPolicy); | ||
| 92 | - EXPECT_EQ(manager.mState_, FoldStatus::UNKNOWN); | ||
| 93 | -} | ||
| 94 | - | ||
| 95 | -/** | ||
| 96 | - * @tc.name: UpdateSwitchScreenBoundaryForLargeFoldDevice | ||
| 97 | - * @tc.desc: test function : UpdateSwitchScreenBoundaryForLargeFoldDevice | ||
| 98 | - * @tc.type: FUNC | ||
| 99 | - */ | ||
| 100 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, UpdateSwitchScreenBoundaryForLargeFoldDevice, | ||
| 101 | - TestSize.Level1) | ||
| 102 | -{ | ||
| 103 | - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { | ||
| 104 | - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; | ||
| 105 | - } | ||
| 106 | - float angel = 0; | ||
| 107 | - int hall = 0; | ||
| 108 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 109 | - manager.UpdateSwitchScreenBoundaryForLargeFoldDevice(angel, hall); | ||
| 110 | - EXPECT_EQ(manager.allowUserSensorForLargeFoldDevice, 0); | ||
| 111 | - | ||
| 112 | - angel = 91.0F; | ||
| 113 | - hall = 1; | ||
| 114 | - manager.UpdateSwitchScreenBoundaryForLargeFoldDevice(angel, hall); | ||
| 115 | - EXPECT_EQ(manager.allowUserSensorForLargeFoldDevice, 1); | ||
| 116 | -} | ||
| 117 | - | ||
| 118 | -/** | ||
| 119 | - * @tc.name: GetNextFoldState01 | ||
| 120 | - * @tc.desc: test function : GetNextFoldState | ||
| 121 | - * @tc.type: FUNC | ||
| 122 | - */ | ||
| 123 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, GetNextFoldState01, TestSize.Level1) | ||
| 124 | -{ | ||
| 125 | - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { | ||
| 126 | - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; | ||
| 127 | - } | ||
| 128 | - float angel = -0.1; | ||
| 129 | - int hall = 0; | ||
| 130 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 131 | - auto result1 = manager.GetNextFoldState(angel, hall); | ||
| 132 | - EXPECT_EQ(static_cast<int>(result1), 0); | ||
| 133 | - | ||
| 134 | - manager.allowUserSensorForLargeFoldDevice = 0; | ||
| 135 | - angel = 90.0F; | ||
| 136 | - hall = 1; | ||
| 137 | - auto result2 = manager.GetNextFoldState(angel, hall); | ||
| 138 | - EXPECT_EQ(static_cast<int>(result2), 3); | ||
| 139 | - | ||
| 140 | - angel = 130.0F - 0.1; | ||
| 141 | - hall = 1; | ||
| 142 | - auto result3 = manager.GetNextFoldState(angel, hall); | ||
| 143 | - EXPECT_EQ(static_cast<int>(result3), 3); | ||
| 144 | - | ||
| 145 | - angel = 130.0F - 0.1; | ||
| 146 | - hall = 0; | ||
| 147 | - auto result4 = manager.GetNextFoldState(angel, hall); | ||
| 148 | - EXPECT_EQ(static_cast<int>(result4), 3); | ||
| 149 | - | ||
| 150 | - angel = 130.0F + 0.1; | ||
| 151 | - hall = 0; | ||
| 152 | - auto result5 = manager.GetNextFoldState(angel, hall); | ||
| 153 | - EXPECT_EQ(static_cast<int>(result5), 3); | ||
| 154 | - | ||
| 155 | - angel = 140.0F + 0.1; | ||
| 156 | - hall = 0; | ||
| 157 | - auto result6 = manager.GetNextFoldState(angel, hall); | ||
| 158 | - EXPECT_EQ(static_cast<int>(result6), 3); | ||
| 159 | - | ||
| 160 | - angel = 140.0F + 0.1; | ||
| 161 | - hall = 1; | ||
| 162 | - auto result7 = manager.GetNextFoldState(angel, hall); | ||
| 163 | - EXPECT_EQ(static_cast<int>(result7), 1); | ||
| 164 | -} | ||
| 165 | - | ||
| 166 | -/** | ||
| 167 | - * @tc.name: GetNextFoldState02 | ||
| 168 | - * @tc.desc: test function : GetNextFoldState | ||
| 169 | - * @tc.type: FUNC | ||
| 170 | - */ | ||
| 171 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, GetNextFoldState02, TestSize.Level1) | ||
| 172 | -{ | ||
| 173 | - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { | ||
| 174 | - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; | ||
| 175 | - } | ||
| 176 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 177 | - manager.allowUserSensorForLargeFoldDevice = 1; | ||
| 178 | - int hall = 1; | ||
| 179 | - float angel; | ||
| 180 | - if (FoldScreenStateInternel::IsSingleDisplayFoldDevice()) { | ||
| 181 | - angel = 25.0F; | ||
| 182 | - auto result1 = manager.GetNextFoldState(angel, hall); | ||
| 183 | - EXPECT_EQ(static_cast<int>(result1), 0); | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - angel = 70.0F - 0.1; | ||
| 187 | - auto result2 = manager.GetNextFoldState(angel, hall); | ||
| 188 | - EXPECT_EQ(static_cast<int>(result2), 2); | ||
| 189 | - | ||
| 190 | - angel = 70.0F + 0.1; | ||
| 191 | - auto result3 = manager.GetNextFoldState(angel, hall); | ||
| 192 | - EXPECT_EQ(static_cast<int>(result3), 3); | ||
| 193 | - | ||
| 194 | - angel = 130.0F - 0.1; | ||
| 195 | - auto result4 = manager.GetNextFoldState(angel, hall); | ||
| 196 | - EXPECT_EQ(static_cast<int>(result4), 3); | ||
| 197 | - | ||
| 198 | - angel = 130.0F + 0.1; | ||
| 199 | - auto result5 = manager.GetNextFoldState(angel, hall); | ||
| 200 | - EXPECT_EQ(static_cast<int>(result5), 3); | ||
| 201 | - | ||
| 202 | - angel = 80.0F - 0.1; | ||
| 203 | - auto result6 = manager.GetNextFoldState(angel, hall); | ||
| 204 | - EXPECT_EQ(static_cast<int>(result6), 3); | ||
| 205 | - | ||
| 206 | - angel = 70.0F + 0.1; | ||
| 207 | - hall = 0; | ||
| 208 | - auto result7 = manager.GetNextFoldState(angel, hall); | ||
| 209 | - EXPECT_EQ(static_cast<int>(result7), 3); | ||
| 210 | - | ||
| 211 | - angel = 130.0F + 0.1; | ||
| 212 | - auto result8 = manager.GetNextFoldState(angel, hall); | ||
| 213 | - EXPECT_EQ(static_cast<int>(result8), 3); | ||
| 214 | -} | ||
| 215 | - | ||
| 216 | -/** | ||
| 217 | - * @tc.name: HandleAngleChange | ||
| 218 | - * @tc.desc: test function : HandleAngleChange02 | ||
| 219 | - * @tc.type: FUNC | ||
| 220 | - */ | ||
| 221 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, HandleAngleChange02, TestSize.Level1) | ||
| 222 | -{ | ||
| 223 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 224 | - float angle = 90.0f; | ||
| 225 | - int hall = 1; | ||
| 226 | - sptr<FoldScreenPolicy> foldScreenPolicy = nullptr; | ||
| 227 | - manager.SetTentMode(1); | ||
| 228 | - manager.HandleAngleChange(angle, hall, foldScreenPolicy); | ||
| 229 | - EXPECT_FLOAT_EQ(manager.currentAngle_, angle); | ||
| 230 | -} | ||
| 231 | - | ||
| 232 | -/** | ||
| 233 | - * @tc.name: HandleHallChange | ||
| 234 | - * @tc.desc: test function : HandleHallChange02 | ||
| 235 | - * @tc.type: FUNC | ||
| 236 | - */ | ||
| 237 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, HandleHallChange02, TestSize.Level1) | ||
| 238 | -{ | ||
| 239 | - SingleDisplaySensorSuperFoldStateManager manager; | ||
| 240 | - float angle = 90.0f; | ||
| 241 | - int hall = 1; | ||
| 242 | - sptr<FoldScreenPolicy> foldScreenPolicy = nullptr; | ||
| 243 | - manager.SetTentMode(1); | ||
| 244 | - manager.HandleHallChange(angle, hall, foldScreenPolicy); | ||
| 245 | - EXPECT_EQ(manager.currentHall_, hall); | ||
| 246 | -} | ||
| 247 | - | ||
| 248 | -/** | ||
| 249 | - * @tc.name: HandleTentChange | ||
| 250 | - * @tc.desc: test function : HandleTentChange | ||
| 251 | - * @tc.type: FUNC | ||
| 252 | - */ | ||
| 253 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, HandleTentChange, TestSize.Level1) | ||
| 254 | -{ | ||
| 255 | - SingleDisplaySensorSuperFoldStateManager mgr; | ||
| 256 | - mgr.SetTentMode(0); | ||
| 257 | - int32_t hall = 0; | ||
| 258 | - mgr.HandleTentChange(0, nullptr, hall); | ||
| 259 | - EXPECT_EQ(mgr.tentModeType_, 0); | ||
| 260 | - mgr.HandleTentChange(1, nullptr, hall); | ||
| 261 | - EXPECT_EQ(mgr.tentModeType_, 1); | ||
| 262 | - | ||
| 263 | - std::recursive_mutex displayInfoMutex; | ||
| 264 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 265 | - auto policy = sptr<SingleDisplaySuperFoldPolicy>::MakeSptr(displayInfoMutex, screenPowerTaskScheduler); | ||
| 266 | - mgr.SetTentMode(0); | ||
| 267 | - mgr.HandleTentChange(1, policy, hall); | ||
| 268 | - EXPECT_EQ(mgr.tentModeType_, 1); | ||
| 269 | - mgr.SetTentMode(1); | ||
| 270 | - mgr.HandleTentChange(0, policy, hall); | ||
| 271 | - EXPECT_FLOAT_EQ(mgr.currentAngle_, ANGLE_MIN_VAL); | ||
| 272 | - hall = 1; | ||
| 273 | - mgr.SetTentMode(1); | ||
| 274 | - mgr.HandleAngleChange(90.0f, hall, nullptr); | ||
| 275 | - mgr.HandleTentChange(0, policy, hall); | ||
| 276 | - EXPECT_FLOAT_EQ(mgr.currentAngle_, 90.0f); | ||
| 277 | - hall = -1; | ||
| 278 | - mgr.SetTentMode(1); | ||
| 279 | - mgr.HandleTentChange(0, policy, hall); | ||
| 280 | - EXPECT_FLOAT_EQ(mgr.currentAngle_, 90.0f); | ||
| 281 | - | ||
| 282 | - mgr.SetTentMode(1); | ||
| 283 | - mgr.HandleAngleChange(160.0f, hall, nullptr); | ||
| 284 | - mgr.HandleTentChange(0, policy, hall); | ||
| 285 | - EXPECT_FLOAT_EQ(mgr.currentAngle_, 160.0f); | ||
| 286 | -} | ||
| 287 | - | ||
| 288 | -/** | ||
| 289 | - * @tc.name: TriggerTentExit | ||
| 290 | - * @tc.desc: test function : TriggerTentExit | ||
| 291 | - * @tc.type: FUNC | ||
| 292 | - */ | ||
| 293 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, TriggerTentExit, TestSize.Level1) | ||
| 294 | -{ | ||
| 295 | - float angle = 0.0F; | ||
| 296 | - int hall; | ||
| 297 | - bool result; | ||
| 298 | - SingleDisplaySensorSuperFoldStateManager mgr; | ||
| 299 | - | ||
| 300 | - hall = 0; | ||
| 301 | - result = mgr.TriggerTentExit(angle, hall); | ||
| 302 | - EXPECT_EQ(result, true); | ||
| 303 | - | ||
| 304 | - hall = 1; | ||
| 305 | - angle = 176.0F; | ||
| 306 | - result = mgr.TriggerTentExit(angle, hall); | ||
| 307 | - EXPECT_EQ(result, true); | ||
| 308 | - | ||
| 309 | - hall = 1; | ||
| 310 | - angle = 4.0F; | ||
| 311 | - result = mgr.TriggerTentExit(angle, hall); | ||
| 312 | - EXPECT_EQ(result, true); | ||
| 313 | - | ||
| 314 | - hall = 1; | ||
| 315 | - angle = 90.0F; | ||
| 316 | - result = mgr.TriggerTentExit(angle, hall); | ||
| 317 | - EXPECT_EQ(result, false); | ||
| 318 | -} | ||
| 319 | - | ||
| 320 | -/** | ||
| 321 | - * @tc.name: TentModeHandleSensorChange | ||
| 322 | - * @tc.desc: test function : TentModeHandleSensorChange | ||
| 323 | - * @tc.type: FUNC | ||
| 324 | - */ | ||
| 325 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, TentModeHandleSensorChange, TestSize.Level1) | ||
| 326 | -{ | ||
| 327 | - SingleDisplaySensorSuperFoldStateManager stateManager; | ||
| 328 | - | ||
| 329 | - stateManager.SetTentMode(1); | ||
| 330 | - stateManager.TentModeHandleSensorChange(4.0F, 0, nullptr); | ||
| 331 | - ASSERT_EQ(stateManager.IsTentMode(), false); | ||
| 332 | - stateManager.SetTentMode(1); | ||
| 333 | - stateManager.TentModeHandleSensorChange(160.0F, 0, nullptr); | ||
| 334 | - ASSERT_EQ(stateManager.IsTentMode(), false); | ||
| 335 | -} | ||
| 336 | - | ||
| 337 | -/** | ||
| 338 | - * @tc.name: ReportTentStatusChange | ||
| 339 | - * @tc.desc: test function : ReportTentStatusChange | ||
| 340 | - * @tc.type: FUNC | ||
| 341 | - */ | ||
| 342 | -HWTEST_F(SingleDisplaySensorSuperFoldStateManagerTest, ReportTentStatusChange, TestSize.Level1) | ||
| 343 | -{ | ||
| 344 | - SingleDisplaySensorSuperFoldStateManager stateManager; | ||
| 345 | - ReportTentModeStatus tentStatus = ReportTentModeStatus::NORMAL_ENTER_TENT_MODE; | ||
| 346 | - stateManager.ReportTentStatusChange(tentStatus); | ||
| 347 | - ASSERT_EQ(tentStatus, ReportTentModeStatus::NORMAL_ENTER_TENT_MODE); | ||
| 348 | -} | ||
| 349 | -} | ||
| 350 | -} | ||
| 351 | -} | ||
| @@ -1,649 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | -using namespace testing; | ||
| 23 | -using namespace testing::ext; | ||
| 24 | - | ||
| 25 | -namespace { | ||
| 26 | - std::string g_errLog; | ||
| 27 | - void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, | ||
| 28 | - const char *msg) | ||
| 29 | - { | ||
| 30 | - g_errLog = msg; | ||
| 31 | - } | ||
| 32 | -} | ||
| 33 | -namespace OHOS { | ||
| 34 | -namespace Rosen { | ||
| 35 | -namespace { | ||
| 36 | -constexpr uint32_t SLEEP_TIME_US = 100000; | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -class SingleDisplaySuperFoldPolicyTest : public testing::Test { | ||
| 40 | -public: | ||
| 41 | - static void SetUpTestCase(); | ||
| 42 | - static void TearDownTestCase(); | ||
| 43 | - void SetUp() override; | ||
| 44 | - void TearDown() override; | ||
| 45 | -}; | ||
| 46 | - | ||
| 47 | -void SingleDisplaySuperFoldPolicyTest::SetUpTestCase() | ||
| 48 | -{ | ||
| 49 | -} | ||
| 50 | - | ||
| 51 | -void SingleDisplaySuperFoldPolicyTest::TearDownTestCase() | ||
| 52 | -{ | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | -void SingleDisplaySuperFoldPolicyTest::SetUp() | ||
| 56 | -{ | ||
| 57 | -} | ||
| 58 | - | ||
| 59 | -void SingleDisplaySuperFoldPolicyTest::TearDown() | ||
| 60 | -{ | ||
| 61 | - usleep(SLEEP_TIME_US); | ||
| 62 | -} | ||
| 63 | - | ||
| 64 | -namespace { | ||
| 65 | -/** | ||
| 66 | - * @tc.name: ChangeScreenDisplayMode | ||
| 67 | - * @tc.desc: test function : ChangeScreenDisplayMode | ||
| 68 | - * @tc.type: FUNC | ||
| 69 | - */ | ||
| 70 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayMode, TestSize.Level1) | ||
| 71 | -{ | ||
| 72 | - std::recursive_mutex displayInfoMutex; | ||
| 73 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 74 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 75 | - | ||
| 76 | - FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; | ||
| 77 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 78 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 79 | - | ||
| 80 | - displayMode = FoldDisplayMode::MAIN; | ||
| 81 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 82 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 83 | - | ||
| 84 | - displayMode = FoldDisplayMode::FULL; | ||
| 85 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 86 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 87 | - | ||
| 88 | - displayMode = FoldDisplayMode::SUB; | ||
| 89 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 90 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 91 | -} | ||
| 92 | - | ||
| 93 | -/** | ||
| 94 | - * @tc.name: SendSensorResult | ||
| 95 | - * @tc.desc: test function : SendSensorResult | ||
| 96 | - * @tc.type: FUNC | ||
| 97 | - */ | ||
| 98 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, SendSensorResult, TestSize.Level1) | ||
| 99 | -{ | ||
| 100 | - std::recursive_mutex displayInfoMutex; | ||
| 101 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 102 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 103 | - | ||
| 104 | - FoldStatus foldStatus = FoldStatus::UNKNOWN; | ||
| 105 | - policy.SendSensorResult(foldStatus); | ||
| 106 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 107 | -} | ||
| 108 | - | ||
| 109 | -/** | ||
| 110 | - * @tc.name: GetCurrentFoldCreaseRegion | ||
| 111 | - * @tc.desc: test function : GetCurrentFoldCreaseRegion | ||
| 112 | - * @tc.type: FUNC | ||
| 113 | - */ | ||
| 114 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, GetCurrentFoldCreaseRegion, TestSize.Level1) | ||
| 115 | -{ | ||
| 116 | - std::recursive_mutex displayInfoMutex; | ||
| 117 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 118 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 119 | - | ||
| 120 | - sptr<FoldCreaseRegion> foldCreaseRegion; | ||
| 121 | - foldCreaseRegion = policy.GetCurrentFoldCreaseRegion(); | ||
| 122 | - EXPECT_EQ(policy.currentFoldCreaseRegion_, foldCreaseRegion); | ||
| 123 | -} | ||
| 124 | - | ||
| 125 | -/** | ||
| 126 | - * @tc.name: GetSupportedFoldStatus | ||
| 127 | - * @tc.desc: GetSupportedFoldStatus | ||
| 128 | - * @tc.type: FUNC | ||
| 129 | - */ | ||
| 130 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, GetSupportedFoldStatus, TestSize.Level1) | ||
| 131 | -{ | ||
| 132 | - std::recursive_mutex displayInfoMutex; | ||
| 133 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 134 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 135 | - | ||
| 136 | - EXPECT_THAT(policy.GetSupportedFoldStatus(), | ||
| 137 | - UnorderedElementsAre( | ||
| 138 | - FoldStatus::EXPAND, | ||
| 139 | - FoldStatus::FOLDED, | ||
| 140 | - FoldStatus::HALF_FOLD)); | ||
| 141 | -} | ||
| 142 | - | ||
| 143 | -/** | ||
| 144 | - * @tc.name: LockDisplayStatus | ||
| 145 | - * @tc.desc: test function : LockDisplayStatus | ||
| 146 | - * @tc.type: FUNC | ||
| 147 | - */ | ||
| 148 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, LockDisplayStatus, TestSize.Level1) | ||
| 149 | -{ | ||
| 150 | - std::recursive_mutex displayInfoMutex; | ||
| 151 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 152 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 153 | - | ||
| 154 | - policy.LockDisplayStatus(false); | ||
| 155 | - EXPECT_EQ(policy.lockDisplayStatus_, false); | ||
| 156 | -} | ||
| 157 | - | ||
| 158 | -/** | ||
| 159 | - * @tc.name: SetOnBootAnimation | ||
| 160 | - * @tc.desc: test function : SetOnBootAnimation | ||
| 161 | - * @tc.type: FUNC | ||
| 162 | - */ | ||
| 163 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, SetOnBootAnimation, TestSize.Level1) | ||
| 164 | -{ | ||
| 165 | - std::recursive_mutex displayInfoMutex; | ||
| 166 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 167 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 168 | - | ||
| 169 | - policy.SetOnBootAnimation(false); | ||
| 170 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 171 | - | ||
| 172 | - policy.SetOnBootAnimation(true); | ||
| 173 | - EXPECT_TRUE(policy.onBootAnimation_); | ||
| 174 | -} | ||
| 175 | - | ||
| 176 | -/** | ||
| 177 | - * @tc.name: RecoverWhenBootAnimationExit | ||
| 178 | - * @tc.desc: test function : RecoverWhenBootAnimationExit | ||
| 179 | - * @tc.type: FUNC | ||
| 180 | - */ | ||
| 181 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, RecoverWhenBootAnimationExit, TestSize.Level1) | ||
| 182 | -{ | ||
| 183 | - std::recursive_mutex displayInfoMutex; | ||
| 184 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 185 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 186 | - | ||
| 187 | - policy.currentDisplayMode_ = FoldDisplayMode::UNKNOWN; | ||
| 188 | - policy.RecoverWhenBootAnimationExit(); | ||
| 189 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 190 | - | ||
| 191 | - policy.currentDisplayMode_ = FoldDisplayMode::SUB; | ||
| 192 | - policy.RecoverWhenBootAnimationExit(); | ||
| 193 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 194 | - | ||
| 195 | - policy.currentDisplayMode_ = FoldDisplayMode::FULL; | ||
| 196 | - policy.RecoverWhenBootAnimationExit(); | ||
| 197 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 198 | - | ||
| 199 | - policy.currentDisplayMode_ = FoldDisplayMode::MAIN; | ||
| 200 | - policy.RecoverWhenBootAnimationExit(); | ||
| 201 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 202 | - | ||
| 203 | - policy.currentDisplayMode_ = FoldDisplayMode::COORDINATION; | ||
| 204 | - policy.RecoverWhenBootAnimationExit(); | ||
| 205 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 206 | -} | ||
| 207 | - | ||
| 208 | -/** | ||
| 209 | - * @tc.name: UpdateForPhyScreenPropertyChange | ||
| 210 | - * @tc.desc: test function : UpdateForPhyScreenPropertyChange | ||
| 211 | - * @tc.type: FUNC | ||
| 212 | - */ | ||
| 213 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, UpdateForPhyScreenPropertyChange, TestSize.Level1) | ||
| 214 | -{ | ||
| 215 | - std::recursive_mutex displayInfoMutex; | ||
| 216 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 217 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 218 | - | ||
| 219 | - policy.currentDisplayMode_ = FoldDisplayMode::UNKNOWN; | ||
| 220 | - policy.UpdateForPhyScreenPropertyChange(); | ||
| 221 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 222 | - | ||
| 223 | - policy.currentDisplayMode_ = FoldDisplayMode::SUB; | ||
| 224 | - policy.UpdateForPhyScreenPropertyChange(); | ||
| 225 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 226 | - | ||
| 227 | - policy.currentDisplayMode_ = FoldDisplayMode::FULL; | ||
| 228 | - policy.UpdateForPhyScreenPropertyChange(); | ||
| 229 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 230 | - | ||
| 231 | - policy.currentDisplayMode_ = FoldDisplayMode::MAIN; | ||
| 232 | - policy.UpdateForPhyScreenPropertyChange(); | ||
| 233 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 234 | - | ||
| 235 | - policy.currentDisplayMode_ = FoldDisplayMode::COORDINATION; | ||
| 236 | - policy.UpdateForPhyScreenPropertyChange(); | ||
| 237 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 238 | -} | ||
| 239 | - | ||
| 240 | -/** | ||
| 241 | - * @tc.name: GetModeMatchStatus01 | ||
| 242 | - * @tc.desc: test function : GetModeMatchStatus | ||
| 243 | - * @tc.type: FUNC | ||
| 244 | - */ | ||
| 245 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, GetModeMatchStatus01, TestSize.Level1) | ||
| 246 | -{ | ||
| 247 | - std::recursive_mutex displayInfoMutex; | ||
| 248 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 249 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 250 | - FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; | ||
| 251 | - | ||
| 252 | - policy.currentFoldStatus_ = FoldStatus::EXPAND; | ||
| 253 | - displayMode = policy.GetModeMatchStatus(); | ||
| 254 | - EXPECT_EQ(FoldDisplayMode::FULL, displayMode); | ||
| 255 | - | ||
| 256 | - policy.currentFoldStatus_ = FoldStatus::FOLDED; | ||
| 257 | - displayMode = policy.GetModeMatchStatus(); | ||
| 258 | - EXPECT_EQ(FoldDisplayMode::MAIN, displayMode); | ||
| 259 | - | ||
| 260 | - policy.currentFoldStatus_ = FoldStatus::HALF_FOLD; | ||
| 261 | - displayMode = policy.GetModeMatchStatus(); | ||
| 262 | - EXPECT_EQ(FoldDisplayMode::FULL, displayMode); | ||
| 263 | - | ||
| 264 | - policy.currentFoldStatus_ = FoldStatus::UNKNOWN; | ||
| 265 | - displayMode = policy.GetModeMatchStatus(); | ||
| 266 | - EXPECT_EQ(FoldDisplayMode::UNKNOWN, displayMode); | ||
| 267 | -} | ||
| 268 | - | ||
| 269 | -/** | ||
| 270 | - * @tc.name: GetModeMatchStatus02 | ||
| 271 | - * @tc.desc: test function : GetModeMatchStatus | ||
| 272 | - * @tc.type: FUNC | ||
| 273 | - */ | ||
| 274 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, GetModeMatchStatus02, TestSize.Level1) | ||
| 275 | -{ | ||
| 276 | - std::recursive_mutex displayInfoMutex; | ||
| 277 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 278 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 279 | - | ||
| 280 | - FoldStatus targetFoldStatus = FoldStatus::EXPAND; | ||
| 281 | - FoldDisplayMode ret = policy.GetModeMatchStatus(targetFoldStatus); | ||
| 282 | - EXPECT_EQ(FoldDisplayMode::FULL, ret); | ||
| 283 | - | ||
| 284 | - targetFoldStatus = FoldStatus::FOLDED; | ||
| 285 | - ret = policy.GetModeMatchStatus(targetFoldStatus); | ||
| 286 | - EXPECT_EQ(FoldDisplayMode::MAIN, ret); | ||
| 287 | - | ||
| 288 | - targetFoldStatus = FoldStatus::HALF_FOLD; | ||
| 289 | - ret = policy.GetModeMatchStatus(targetFoldStatus); | ||
| 290 | - EXPECT_EQ(FoldDisplayMode::FULL, ret); | ||
| 291 | - | ||
| 292 | - targetFoldStatus = FoldStatus::UNKNOWN; | ||
| 293 | - ret = policy.GetModeMatchStatus(targetFoldStatus); | ||
| 294 | - EXPECT_EQ(FoldDisplayMode::UNKNOWN, ret); | ||
| 295 | - | ||
| 296 | - targetFoldStatus = FoldStatus::FOLD_STATE_EXPAND_WITH_SECOND_EXPAND; | ||
| 297 | - ret = policy.GetModeMatchStatus(targetFoldStatus); | ||
| 298 | - EXPECT_EQ(FoldDisplayMode::UNKNOWN, ret); | ||
| 299 | -} | ||
| 300 | - | ||
| 301 | -/** | ||
| 302 | - * @tc.name: ReportFoldDisplayModeChange | ||
| 303 | - * @tc.desc: test function : ReportFoldDisplayModeChange | ||
| 304 | - * @tc.type: FUNC | ||
| 305 | - */ | ||
| 306 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ReportFoldDisplayModeChange, TestSize.Level1) | ||
| 307 | -{ | ||
| 308 | - std::recursive_mutex displayInfoMutex; | ||
| 309 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 310 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 311 | - | ||
| 312 | - g_errLog.clear(); | ||
| 313 | - LOG_SetCallback(MyLogCallback); | ||
| 314 | - FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; | ||
| 315 | - policy.ReportFoldDisplayModeChange(displayMode); | ||
| 316 | - EXPECT_TRUE(g_errLog.find("Write HiSysEvent error") == std::string::npos); | ||
| 317 | - g_errLog.clear(); | ||
| 318 | - LOG_SetCallback(nullptr); | ||
| 319 | - | ||
| 320 | - displayMode = FoldDisplayMode::FULL; | ||
| 321 | - policy.ReportFoldDisplayModeChange(displayMode); | ||
| 322 | - EXPECT_NE(FoldDisplayMode::UNKNOWN, displayMode); | ||
| 323 | -} | ||
| 324 | - | ||
| 325 | -/** | ||
| 326 | - * @tc.name: ReportFoldStatusChangeBegin | ||
| 327 | - * @tc.desc: test function : ReportFoldStatusChangeBegin | ||
| 328 | - * @tc.type: FUNC | ||
| 329 | - */ | ||
| 330 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ReportFoldStatusChangeBegin, TestSize.Level1) | ||
| 331 | -{ | ||
| 332 | - std::recursive_mutex displayInfoMutex; | ||
| 333 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 334 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 335 | - | ||
| 336 | - int32_t offScreen = 0; | ||
| 337 | - int32_t onScreen = 1; | ||
| 338 | - policy.ReportFoldStatusChangeBegin(offScreen, onScreen); | ||
| 339 | - EXPECT_TRUE(onScreen); | ||
| 340 | - | ||
| 341 | - policy.ReportFoldStatusChangeBegin(offScreen, onScreen); | ||
| 342 | - EXPECT_TRUE(onScreen); | ||
| 343 | -} | ||
| 344 | - | ||
| 345 | -/** | ||
| 346 | - * @tc.name: ChangeScreenDisplayModeToMain | ||
| 347 | - * @tc.desc: test function : ChangeScreenDisplayModeToMain | ||
| 348 | - * @tc.type: FUNC | ||
| 349 | - */ | ||
| 350 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModeToMain, TestSize.Level1) | ||
| 351 | -{ | ||
| 352 | - std::recursive_mutex displayInfoMutex; | ||
| 353 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 354 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 355 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 356 | - | ||
| 357 | - policy.onBootAnimation_ = true; | ||
| 358 | - policy.ChangeScreenDisplayModeToMain(screenSession); | ||
| 359 | - EXPECT_TRUE(policy.onBootAnimation_); | ||
| 360 | - | ||
| 361 | - policy.ChangeScreenDisplayModeToMain(screenSession); | ||
| 362 | - EXPECT_TRUE(policy.onBootAnimation_); | ||
| 363 | -} | ||
| 364 | - | ||
| 365 | -/** | ||
| 366 | - * @tc.name: ChangeScreenDisplayModeToFull | ||
| 367 | - * @tc.desc: test function : ChangeScreenDisplayModeToFull | ||
| 368 | - * @tc.type: FUNC | ||
| 369 | - */ | ||
| 370 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModeToFull, TestSize.Level1) | ||
| 371 | -{ | ||
| 372 | - std::recursive_mutex displayInfoMutex; | ||
| 373 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 374 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 375 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 376 | - | ||
| 377 | - policy.onBootAnimation_ = true; | ||
| 378 | - policy.ChangeScreenDisplayModeToFull(screenSession); | ||
| 379 | - EXPECT_TRUE(policy.onBootAnimation_); | ||
| 380 | - | ||
| 381 | - policy.ChangeScreenDisplayModeToFull(screenSession); | ||
| 382 | - EXPECT_TRUE(policy.onBootAnimation_); | ||
| 383 | -} | ||
| 384 | - | ||
| 385 | -/** | ||
| 386 | - * @tc.name: ChangeScreenDisplayModePower | ||
| 387 | - * @tc.desc: test function : ChangeScreenDisplayModePower | ||
| 388 | - * @tc.type: FUNC | ||
| 389 | - */ | ||
| 390 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModePower, TestSize.Level1) | ||
| 391 | -{ | ||
| 392 | - std::recursive_mutex displayInfoMutex; | ||
| 393 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 394 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 395 | - EXPECT_TRUE(1); | ||
| 396 | -} | ||
| 397 | - | ||
| 398 | -/** | ||
| 399 | - * @tc.name: SendPropertyChangeResult | ||
| 400 | - * @tc.desc: test function : SendPropertyChangeResult | ||
| 401 | - * @tc.type: FUNC | ||
| 402 | - */ | ||
| 403 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, SendPropertyChangeResult, TestSize.Level1) | ||
| 404 | -{ | ||
| 405 | - std::recursive_mutex displayInfoMutex; | ||
| 406 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 407 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 408 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 409 | - ScreenId screenId = 0; | ||
| 410 | - ScreenPropertyChangeReason reason = ScreenPropertyChangeReason::UNDEFINED; | ||
| 411 | - | ||
| 412 | - policy.SendPropertyChangeResult(screenSession, screenId, reason); | ||
| 413 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 414 | -} | ||
| 415 | - | ||
| 416 | -/** | ||
| 417 | - * @tc.name: ChangeScreenDisplayModeToMainOnBootAnimation | ||
| 418 | - * @tc.desc: test function : ChangeScreenDisplayModeToMainOnBootAnimation | ||
| 419 | - * @tc.type: FUNC | ||
| 420 | - */ | ||
| 421 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModeToMainOnBootAnimation, TestSize.Level1) | ||
| 422 | -{ | ||
| 423 | - std::recursive_mutex displayInfoMutex; | ||
| 424 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 425 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 426 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 427 | - | ||
| 428 | - policy.ChangeScreenDisplayModeToMainOnBootAnimation(screenSession); | ||
| 429 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 430 | -} | ||
| 431 | - | ||
| 432 | -/** | ||
| 433 | - * @tc.name: ChangeScreenDisplayModeToFullOnBootAnimation | ||
| 434 | - * @tc.desc: test function : ChangeScreenDisplayModeToFullOnBootAnimation | ||
| 435 | - * @tc.type: FUNC | ||
| 436 | - */ | ||
| 437 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModeToFullOnBootAnimation, TestSize.Level1) | ||
| 438 | -{ | ||
| 439 | - std::recursive_mutex displayInfoMutex; | ||
| 440 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 441 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 442 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 443 | - | ||
| 444 | - policy.ChangeScreenDisplayModeToFullOnBootAnimation(screenSession); | ||
| 445 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 446 | -} | ||
| 447 | - | ||
| 448 | -/** | ||
| 449 | - * @tc.name: SetdisplayModeChangeStatus01 | ||
| 450 | - * @tc.desc: test function : SetdisplayModeChangeStatus01 | ||
| 451 | - * @tc.type: FUNC | ||
| 452 | - */ | ||
| 453 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, SetdisplayModeChangeStatus01, TestSize.Level1) | ||
| 454 | -{ | ||
| 455 | - std::recursive_mutex displayInfoMutex; | ||
| 456 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 457 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 458 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 459 | - bool status = true; | ||
| 460 | - | ||
| 461 | - policy.SetdisplayModeChangeStatus(status); | ||
| 462 | - EXPECT_EQ(policy.pengdingTask_, 4); | ||
| 463 | -} | ||
| 464 | - | ||
| 465 | -/** | ||
| 466 | - * @tc.name: SetdisplayModeChangeStatus02 | ||
| 467 | - * @tc.desc: test function : SetdisplayModeChangeStatus02 | ||
| 468 | - * @tc.type: FUNC | ||
| 469 | - */ | ||
| 470 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, SetdisplayModeChangeStatus02, TestSize.Level1) | ||
| 471 | -{ | ||
| 472 | - std::recursive_mutex displayInfoMutex; | ||
| 473 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 474 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 475 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 476 | - bool status = false; | ||
| 477 | - | ||
| 478 | - policy.SetdisplayModeChangeStatus(status); | ||
| 479 | - EXPECT_NE(policy.pengdingTask_, 4); | ||
| 480 | -} | ||
| 481 | - | ||
| 482 | -/** | ||
| 483 | - * @tc.name: ChangeScreenDisplayMode02 | ||
| 484 | - * @tc.desc: test function : ChangeScreenDisplayMode02 | ||
| 485 | - * @tc.type: FUNC | ||
| 486 | - */ | ||
| 487 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayMode02, TestSize.Level1) | ||
| 488 | -{ | ||
| 489 | - std::recursive_mutex displayInfoMutex; | ||
| 490 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 491 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 492 | - sptr<ScreenSession> screenSession = new ScreenSession; | ||
| 493 | - | ||
| 494 | - FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; | ||
| 495 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 496 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 497 | - | ||
| 498 | - displayMode = FoldDisplayMode::MAIN; | ||
| 499 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 500 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 501 | - | ||
| 502 | - displayMode = FoldDisplayMode::FULL; | ||
| 503 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 504 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 505 | - | ||
| 506 | - displayMode = FoldDisplayMode::SUB; | ||
| 507 | - policy.ChangeScreenDisplayMode(displayMode); | ||
| 508 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 509 | -} | ||
| 510 | - | ||
| 511 | -/** | ||
| 512 | - * @tc.name: ChangeScreenDisplayModeInner | ||
| 513 | - * @tc.desc: test function : ChangeScreenDisplayModeInner | ||
| 514 | - * @tc.type: FUNC | ||
| 515 | - */ | ||
| 516 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModeInner, TestSize.Level1) | ||
| 517 | -{ | ||
| 518 | - std::recursive_mutex displayInfoMutex; | ||
| 519 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 520 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 521 | - | ||
| 522 | - FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; | ||
| 523 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT; | ||
| 524 | - policy.ChangeScreenDisplayModeInner(displayMode, reason); | ||
| 525 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 526 | - | ||
| 527 | - displayMode = FoldDisplayMode::MAIN; | ||
| 528 | - policy.ChangeScreenDisplayModeInner(displayMode, reason); | ||
| 529 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 530 | - | ||
| 531 | - displayMode = FoldDisplayMode::FULL; | ||
| 532 | - policy.ChangeScreenDisplayModeInner(displayMode, reason); | ||
| 533 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 534 | - | ||
| 535 | - displayMode = FoldDisplayMode::SUB; | ||
| 536 | - policy.ChangeScreenDisplayModeInner(displayMode, reason); | ||
| 537 | - EXPECT_FALSE(policy.onBootAnimation_); | ||
| 538 | -} | ||
| 539 | - | ||
| 540 | -/** | ||
| 541 | - * @tc.name: ChangeScreenDisplayModeInner | ||
| 542 | - * @tc.desc: test fold exit coordination | ||
| 543 | - * @tc.type: FUNC | ||
| 544 | - */ | ||
| 545 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayModeInnerTest_foldExitCoordination, TestSize.Level1) | ||
| 546 | -{ | ||
| 547 | - std::recursive_mutex displayInfoMutex; | ||
| 548 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 549 | - SingleDisplaySuperFoldPolicy policy(displayInfoMutex, screenPowerTaskScheduler); | ||
| 550 | - | ||
| 551 | - policy.currentFoldStatus_ = FoldStatus::FOLDED; | ||
| 552 | - policy.currentDisplayMode_ = FoldDisplayMode::COORDINATION; | ||
| 553 | - ScreenId screenId = 0; | ||
| 554 | - sptr<ScreenSession> screenSession = sptr<ScreenSession>::MakeSptr(); | ||
| 555 | - ScreenSessionManager::GetInstance().screenSessionMap_.insert({screenid, screenSession}); | ||
| 556 | - FoldDisplayMode displayMode = FoldDisplayMode::FULL; | ||
| 557 | - DisplayModeChangeReason reason = DisplayModeChangeReason::DEFAULT; | ||
| 558 | - policy.ChangeScreenDisplayModeInner(displayMode, reason); | ||
| 559 | - EXPECT_EQ(policy.currentDisplayMode_, FoldDisplayMode::FULL); | ||
| 560 | - | ||
| 561 | - policy.currentFoldStatus_ = FoldStatus::EXPAND; | ||
| 562 | - policy.ChangeScreenDisplayModeInner(displayMode, reason); | ||
| 563 | - EXPECT_EQ(policy.currentDisplayMode_, FoldDisplayMode::FULL); | ||
| 564 | -} | ||
| 565 | - | ||
| 566 | -/** | ||
| 567 | - * @tc.name: SetIsClearingBootAnimation | ||
| 568 | - * @tc.desc: test function : SetIsClearingBootAnimation | ||
| 569 | - * @tc.type: FUNC | ||
| 570 | - */ | ||
| 571 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, SetIsClearingBootAnimation, TestSize.Level1) | ||
| 572 | -{ | ||
| 573 | - std::recursive_mutex displayInfoMutex; | ||
| 574 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 575 | - auto policy = sptr<SingleDisplaySuperFoldPolicy>::MakeSptr(displayInfoMutex, screenPowerTaskScheduler); | ||
| 576 | - | ||
| 577 | - policy->SetIsClearingBootAnimation(false); | ||
| 578 | - EXPECT_FALSE(policy->isClearingBootAnimation_); | ||
| 579 | - policy->SetIsClearingBootAnimation(true); | ||
| 580 | - EXPECT_TRUE(policy->isClearingBootAnimation_); | ||
| 581 | -} | ||
| 582 | - | ||
| 583 | -/** | ||
| 584 | - * @tc.name: ChangeScreenDisplayMode | ||
| 585 | - * @tc.desc: test function : ChangeScreenDisplayMode | ||
| 586 | - * @tc.type: FUNC | ||
| 587 | - */ | ||
| 588 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeScreenDisplayMode03, TestSize.Level1) | ||
| 589 | -{ | ||
| 590 | - std::recursive_mutex displayInfoMutex; | ||
| 591 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 592 | - auto policy = sptr<SingleDisplaySuperFoldPolicy>::MakeSptr(displayInfoMutex, screenPowerTaskScheduler); | ||
| 593 | - | ||
| 594 | - policy->SetIsClearingBootAnimation(false); | ||
| 595 | - FoldDisplayMode displayMode = FoldDisplayMode::MAIN; | ||
| 596 | - policy->ChangeScreenDisplayMode(displayMode); | ||
| 597 | - EXPECT_EQ(policy->lastCachedisplayMode_, displayMode); | ||
| 598 | - policy->SetIsClearingBootAnimation(true); | ||
| 599 | - displayMode = FoldDisplayMode::FULL; | ||
| 600 | - policy->ChangeScreenDisplayMode(displayMode); | ||
| 601 | - EXPECT_NE(policy->lastCachedisplayMode_, displayMode); | ||
| 602 | -} | ||
| 603 | - | ||
| 604 | -/** | ||
| 605 | - * @tc.name: ChangeOnTentMode | ||
| 606 | - * @tc.desc: test function : ChangeOnTentMode | ||
| 607 | - * @tc.type: FUNC | ||
| 608 | - */ | ||
| 609 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeOnTentMode, TestSize.Level1) | ||
| 610 | -{ | ||
| 611 | - std::recursive_mutex displayInfoMutex; | ||
| 612 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 613 | - auto policy = sptr<SingleDisplaySuperFoldPolicy>::MakeSptr(displayInfoMutex, screenPowerTaskScheduler); | ||
| 614 | - | ||
| 615 | - FoldStatus currentState = FoldStatus::EXPAND; | ||
| 616 | - policy->ChangeOnTentMode(currentState); | ||
| 617 | - EXPECT_EQ(policy->lastCachedisplayMode_, FoldDisplayMode::MAIN); | ||
| 618 | - | ||
| 619 | - currentState = FoldStatus::HALF_FOLD; | ||
| 620 | - policy->ChangeOnTentMode(currentState); | ||
| 621 | - EXPECT_EQ(policy->lastCachedisplayMode_, FoldDisplayMode::MAIN); | ||
| 622 | - | ||
| 623 | - currentState = FoldStatus::FOLDED; | ||
| 624 | - policy->ChangeOnTentMode(currentState); | ||
| 625 | - EXPECT_EQ(policy->lastCachedisplayMode_, FoldDisplayMode::MAIN); | ||
| 626 | - | ||
| 627 | - currentState = FoldStatus::UNKNOWN; | ||
| 628 | - policy->ChangeOnTentMode(currentState); | ||
| 629 | - EXPECT_EQ(policy->lastCachedisplayMode_, FoldDisplayMode::MAIN); | ||
| 630 | -} | ||
| 631 | - | ||
| 632 | -/** | ||
| 633 | - * @tc.name: ChangeOffTentMode | ||
| 634 | - * @tc.desc: test function : ChangeOffTentMode | ||
| 635 | - * @tc.type: FUNC | ||
| 636 | - */ | ||
| 637 | -HWTEST_F(SingleDisplaySuperFoldPolicyTest, ChangeOffTentMode, TestSize.Level1) | ||
| 638 | -{ | ||
| 639 | - std::recursive_mutex displayInfoMutex; | ||
| 640 | - std::shared_ptr<TaskScheduler> screenPowerTaskScheduler = nullptr; | ||
| 641 | - auto policy = sptr<SingleDisplaySuperFoldPolicy>::MakeSptr(displayInfoMutex, screenPowerTaskScheduler); | ||
| 642 | - | ||
| 643 | - policy->ChangeOffTentMode(); | ||
| 644 | - FoldDisplayMode displayMode = policy->GetModeMatchStatus(); | ||
| 645 | - EXPECT_EQ(policy->lastCachedisplayMode_, displayMode); | ||
| 646 | -} | ||
| 647 | -} | ||
| 648 | -} // namespace Rosen | ||
| 649 | -} // namespace OHOS | ||