mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
fix window manager fuzz test
Signed-off-by: wangjian10 <wangjian10@huawei.com>
This commit is contained in:
parent
f5f2e208c6
commit
43a225bca7
@ -117,21 +117,31 @@ bool DoSomethingForWindowManagerImpl(WindowManager& windowManager, const uint8_t
|
||||
void CheckAccessibilityWindowInfo(WindowManager& windowManager, const uint8_t* data, size_t size)
|
||||
{
|
||||
Parcel accessibilityWindowInfosParcel;
|
||||
if (accessibilityWindowInfosParcel.WriteBuffer(data, size)) {
|
||||
std::vector<sptr<AccessibilityWindowInfo>> windowInfos;
|
||||
MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(accessibilityWindowInfosParcel,
|
||||
windowInfos);
|
||||
windowManager.GetAccessibilityWindowInfo(windowInfos);
|
||||
WindowUpdateType type;
|
||||
GetObject<WindowUpdateType>(type, data, size);
|
||||
windowManager.NotifyAccessibilityWindowInfo(windowInfos, type);
|
||||
if (!accessibilityWindowInfosParcel.WriteBuffer(data, size)) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<sptr<AccessibilityWindowInfo>> windowInfos;
|
||||
if (!MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(
|
||||
accessibilityWindowInfosParcel, windowInfos)) {
|
||||
return;
|
||||
}
|
||||
windowManager.GetAccessibilityWindowInfo(windowInfos);
|
||||
WindowUpdateType type;
|
||||
GetObject<WindowUpdateType>(type, data, size);
|
||||
windowManager.NotifyAccessibilityWindowInfo(windowInfos, type);
|
||||
}
|
||||
|
||||
void CheckVisibilityInfo(WindowManager& windowManager, const uint8_t* data, size_t size)
|
||||
{
|
||||
Parcel windowVisibilityInfosParcel;
|
||||
windowVisibilityInfosParcel.WriteBuffer(data, size);
|
||||
if (!windowVisibilityInfosParcel.WriteBuffer(data, size)) {
|
||||
return;
|
||||
}
|
||||
std::vector<sptr<WindowVisibilityInfo>> visibilitynfos;
|
||||
MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(windowVisibilityInfosParcel,
|
||||
visibilitynfos);
|
||||
if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(windowVisibilityInfosParcel,
|
||||
visibilitynfos)) {
|
||||
return;
|
||||
}
|
||||
windowManager.GetVisibilityWindowInfo(visibilitynfos);
|
||||
windowManager.UpdateWindowVisibilityInfo(visibilitynfos);
|
||||
bool enable = false;
|
||||
@ -140,11 +150,9 @@ void CheckAccessibilityWindowInfo(WindowManager& windowManager, const uint8_t* d
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data == nullptr || size < DATA_MIN_SIZE) {
|
||||
return false;
|
||||
}
|
||||
WindowManager& windowManager = WindowManager::GetInstance();
|
||||
CheckAccessibilityWindowInfo(windowManager, data, size);
|
||||
CheckVisibilityInfo(windowManager, data, size);
|
||||
Parcel focusChangeInfoParcel;
|
||||
if (focusChangeInfoParcel.WriteBuffer(data, size)) {
|
||||
FocusChangeInfo::Unmarshalling(focusChangeInfoParcel);
|
||||
@ -195,6 +203,9 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
if (data == nullptr || size < OHOS::DATA_MIN_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
OHOS::DoSomethingInterestingWithMyAPI(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user