• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #include "test/mock/base/mock_system_properties.h"
17 
18 #include <string>
19 
20 #include "base/utils/system_properties.h"
21 
22 namespace OHOS::Ace {
23 namespace {
24 constexpr int32_t ORIENTATION_PORTRAIT = 0;
25 constexpr int32_t ORIENTATION_LANDSCAPE = 1;
26 
Swap(int32_t & deviceWidth,int32_t & deviceHeight)27 void Swap(int32_t& deviceWidth, int32_t& deviceHeight)
28 {
29     int32_t temp = deviceWidth;
30     deviceWidth = deviceHeight;
31     deviceHeight = temp;
32 }
33 } // namespace
34 
35 DeviceType SystemProperties::deviceType_ = DeviceType::PHONE;
36 DeviceOrientation SystemProperties::orientation_ { DeviceOrientation::PORTRAIT };
37 bool SystemProperties::isHookModeEnabled_ = false;
38 bool SystemProperties::rosenBackendEnabled_ = true;
39 bool SystemProperties::windowAnimationEnabled_ = true;
40 std::atomic<bool> SystemProperties::layoutTraceEnable_(false);
41 std::atomic<bool> SystemProperties::traceInputEventEnable_(false);
42 bool SystemProperties::buildTraceEnable_ = false;
43 bool SystemProperties::syncDebugTraceEnable_ = false;
44 bool SystemProperties::measureDebugTraceEnable_ = false;
45 bool SystemProperties::safeAreaDebugTraceEnable_ = false;
46 bool SystemProperties::pixelRoundEnable_ = true;
47 bool SystemProperties::textTraceEnable_ = false;
48 bool SystemProperties::vsyncModeTraceEnable_ = false;
49 bool SystemProperties::syntaxTraceEnable_ = false;
50 double SystemProperties::resolution_ = 0.0;
51 constexpr float defaultAnimationScale = 1.0f;
52 bool SystemProperties::extSurfaceEnabled_ = false;
53 uint32_t SystemProperties::dumpFrameCount_ = 0;
54 bool SystemProperties::debugEnabled_ = false;
55 DebugFlags SystemProperties::debugFlags_ = 0;
56 bool SystemProperties::containerDeleteFlag_ = false;
57 bool SystemProperties::layoutDetectEnabled_ = false;
58 int32_t SystemProperties::deviceWidth_ = 720;
59 int32_t SystemProperties::deviceHeight_ = 1280;
60 bool SystemProperties::debugOffsetLogEnabled_ = false;
61 bool SystemProperties::downloadByNetworkEnabled_ = false;
62 bool SystemProperties::recycleImageEnabled_ = false;
63 int32_t SystemProperties::devicePhysicalWidth_ = 0;
64 int32_t SystemProperties::devicePhysicalHeight_ = 0;
65 bool SystemProperties::enableScrollableItemPool_ = false;
66 bool SystemProperties::navigationBlurEnabled_ = false;
67 bool SystemProperties::cacheNavigationNodeEnable_ = false;
68 bool SystemProperties::gridCacheEnabled_ = true;
69 bool SystemProperties::sideBarContainerBlurEnable_ = false;
70 std::atomic<bool> SystemProperties::stateManagerEnable_(false);
71 std::atomic<bool> SystemProperties::acePerformanceMonitorEnable_(false);
72 std::atomic<bool> SystemProperties::asyncInitializeEnabled_(true);
73 std::atomic<bool> SystemProperties::focusCanBeActive_(true);
74 bool SystemProperties::aceCommercialLogEnable_ = false;
75 std::atomic<bool> SystemProperties::debugBoundaryEnabled_(false);
76 bool SystemProperties::developerModeOn_ = false;
77 bool SystemProperties::faultInjectEnabled_ = false;
78 bool SystemProperties::imageFileCacheConvertAstc_ = true;
79 bool SystemProperties::imageFrameworkEnable_ = true;
80 bool SystemProperties::debugAutoUIEnabled_ = false;
81 float SystemProperties::dragStartDampingRatio_ = 0.2f;
82 float SystemProperties::dragStartPanDisThreshold_ = 10.0f;
83 float SystemProperties::pageCount_ = 0.0f;
84 std::pair<float, float> SystemProperties::brightUpPercent_ = {};
85 int32_t SystemProperties::imageFileCacheConvertAstcThreshold_ = 3;
86 bool SystemProperties::taskPriorityAdjustmentEnable_ = false;
87 int32_t SystemProperties::dragDropFrameworkStatus_ = 0;
88 
89 bool g_irregularGrid = true;
90 bool g_segmentedWaterflow = true;
91 
GetFontWeightScale()92 float SystemProperties::GetFontWeightScale()
93 {
94     // Default value of font weight scale is 1.0.
95     return 1.0f;
96 }
97 
GetDeviceType()98 DeviceType SystemProperties::GetDeviceType()
99 {
100     return deviceType_;
101 }
102 
GetDebugEnabled()103 bool SystemProperties::GetDebugEnabled()
104 {
105     return debugEnabled_;
106 }
107 
GetLayoutDetectEnabled()108 bool SystemProperties::GetLayoutDetectEnabled()
109 {
110     return layoutDetectEnabled_;
111 }
112 
GetAnimationScale()113 float SystemProperties::GetAnimationScale()
114 {
115     return defaultAnimationScale;
116 }
117 
GetIsUseMemoryMonitor()118 bool SystemProperties::GetIsUseMemoryMonitor()
119 {
120     return false;
121 }
122 
IsSyscapExist(const char * cap)123 bool SystemProperties::IsSyscapExist(const char* cap)
124 {
125     return false;
126 }
127 
IsOpIncEnable()128 bool SystemProperties::IsOpIncEnable()
129 {
130     return true;
131 }
132 
SetDeviceOrientation(int32_t orientation)133 void SystemProperties::SetDeviceOrientation(int32_t orientation)
134 {
135     if (orientation == ORIENTATION_PORTRAIT && orientation_ != DeviceOrientation::PORTRAIT) {
136         Swap(deviceWidth_, deviceHeight_);
137         orientation_ = DeviceOrientation::PORTRAIT;
138     } else if (orientation == ORIENTATION_LANDSCAPE && orientation_ != DeviceOrientation::LANDSCAPE) {
139         Swap(deviceWidth_, deviceHeight_);
140         orientation_ = DeviceOrientation::LANDSCAPE;
141     }
142 }
143 
Is24HourClock()144 bool SystemProperties::Is24HourClock()
145 {
146     return false;
147 }
148 
GetTitleStyleEnabled()149 bool SystemProperties::GetTitleStyleEnabled()
150 {
151     return false;
152 }
153 
GetCustomTitleFilePath()154 std::string SystemProperties::GetCustomTitleFilePath()
155 {
156     return {};
157 }
158 
GetDisplaySyncSkipEnabled()159 bool SystemProperties::GetDisplaySyncSkipEnabled()
160 {
161     return true;
162 }
163 
GetNavigationBlurEnabled()164 bool SystemProperties::GetNavigationBlurEnabled()
165 {
166     return navigationBlurEnabled_;
167 }
168 
GetCacheNavigationNodeEnable()169 bool SystemProperties::GetCacheNavigationNodeEnable()
170 {
171     return cacheNavigationNodeEnable_;
172 }
173 
GetGridCacheEnabled()174 bool SystemProperties::GetGridCacheEnabled()
175 {
176     return gridCacheEnabled_;
177 }
178 
GetGridIrregularLayoutEnabled()179 bool SystemProperties::GetGridIrregularLayoutEnabled()
180 {
181     return g_irregularGrid;
182 }
183 
WaterFlowUseSegmentedLayout()184 bool SystemProperties::WaterFlowUseSegmentedLayout()
185 {
186     return g_segmentedWaterflow;
187 }
188 
GetSideBarContainerBlurEnable()189 bool SystemProperties::GetSideBarContainerBlurEnable()
190 {
191     return sideBarContainerBlurEnable_;
192 }
193 
GetDefaultResolution()194 float SystemProperties::GetDefaultResolution()
195 {
196     return 1.0f;
197 }
198 
GetAtomicServiceBundleName()199 std::string SystemProperties::GetAtomicServiceBundleName()
200 {
201     return {};
202 }
203 
GetDragStartDampingRatio()204 float SystemProperties::GetDragStartDampingRatio()
205 {
206     return dragStartDampingRatio_;
207 }
208 
GetDragStartPanDistanceThreshold()209 float SystemProperties::GetDragStartPanDistanceThreshold()
210 {
211     return dragStartPanDisThreshold_;
212 }
213 
GetAllowWindowOpenMethodEnabled()214 bool SystemProperties::GetAllowWindowOpenMethodEnabled()
215 {
216     return false;
217 }
218 
IsSmallFoldProduct()219 bool SystemProperties::IsSmallFoldProduct()
220 {
221     return false;
222 }
223 
IsBigFoldProduct()224 bool SystemProperties::IsBigFoldProduct()
225 {
226     return false;
227 }
228 
GetDebugInspectorId()229 std::string SystemProperties::GetDebugInspectorId()
230 {
231     return "N/A";
232 }
233 
GetSrollableVelocityScale()234 double SystemProperties::GetSrollableVelocityScale()
235 {
236     return 0.0;
237 }
238 
GetSrollableFriction()239 double SystemProperties::GetSrollableFriction()
240 {
241     return 0.0;
242 }
243 
GetScrollableDistance()244 double SystemProperties::GetScrollableDistance()
245 {
246     return 0.0;
247 }
248 
GetWebDebugMaximizeResizeOptimize()249 bool SystemProperties::GetWebDebugMaximizeResizeOptimize()
250 {
251     return true;
252 }
253 
IsNeedResampleTouchPoints()254 bool SystemProperties::IsNeedResampleTouchPoints()
255 {
256     return true;
257 }
258 
IsNeedSymbol()259 bool SystemProperties::IsNeedSymbol()
260 {
261     return true;
262 }
263 
GetResourceDecoupling()264 bool SystemProperties::GetResourceDecoupling()
265 {
266     return true;
267 }
268 
GetDragDropFrameworkStatus()269 int32_t SystemProperties::GetDragDropFrameworkStatus()
270 {
271     return dragDropFrameworkStatus_;
272 }
273 
GetContainerDeleteFlag()274 bool SystemProperties::GetContainerDeleteFlag()
275 {
276     return false;
277 }
278 
IsSuperFoldDisplayDevice()279 bool SystemProperties::IsSuperFoldDisplayDevice()
280 {
281     return false;
282 }
283 } // namespace OHOS::Ace
284