• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "sequenceable_fuzzer.h"
17 
18 #include "singleton.h"
19 
20 #define private public
21 #include "sequenceable_cooperate_options.h"
22 #include "sequenceable_drag_data.h"
23 #include "sequenceable_drag_result.h"
24 #include "sequenceable_drag_visible.h"
25 #include "sequenceable_posture_data.h"
26 #include "sequenceable_preview_animation.h"
27 #include "sequenceable_preview_style.h"
28 #include "sequenceable_rotate_window.h"
29 #include "fi_log.h"
30 #include "message_parcel.h"
31 
32 #undef LOG_TAG
33 #define LOG_TAG "SequenceableFuzzTest"
34 
35 namespace OHOS {
36 namespace Msdp {
37 namespace DeviceStatus {
38 namespace OHOS {
39 const std::u16string FORMMGR_DEVICE_TOKEN { u"ohos.msdp.Idevicestatus" };
40 
SequenceableFuzzTest(const uint8_t * data,size_t size)41 bool SequenceableFuzzTest(const uint8_t* data, size_t size)
42 {
43     MessageParcel datas;
44     if (!datas.WriteInterfaceToken(FORMMGR_DEVICE_TOKEN) ||
45         !datas.WriteBuffer(data, size) || !datas.RewindRead(0)) {
46         FI_HILOGE("Write failed");
47         return false;
48     }
49     PreviewStyle previewStyle;
50     PreviewAnimation previewAnimation;
51     Parcel parcel;
52     SequenceablePreviewAnimation sequenceablePreviewAnimation(previewStyle, previewAnimation);
53     sequenceablePreviewAnimation.Marshalling(parcel);
54     sequenceablePreviewAnimation.Unmarshalling(parcel);
55     SequenceablePreviewStyle sequenceablePreviewStyle(previewStyle);
56     sequenceablePreviewStyle.Marshalling(parcel);
57     sequenceablePreviewStyle.Unmarshalling(parcel);
58     DragDropResult dropResult;
59     SequenceableDragResult sequenceableDragResult(dropResult);
60     sequenceableDragResult.Marshalling(parcel);
61     sequenceableDragResult.Unmarshalling(parcel);
62     bool visible = true;
63     bool isForce = true;
64     std::shared_ptr<Rosen::RSTransaction> rsTransaction = nullptr;
65     DragVisibleParam dragVisibleParam;
66     dragVisibleParam.visible = visible;
67     dragVisibleParam.isForce = isForce;
68     dragVisibleParam.rsTransaction = rsTransaction;
69     SequenceableDragVisible sequenceableDragVisible(dragVisibleParam);
70     sequenceableDragVisible.Marshalling(parcel);
71     sequenceableDragVisible.Unmarshalling(parcel);
72     SequenceableRotateWindow sequenceableRotateWindow(rsTransaction);
73     sequenceableRotateWindow.Marshalling(parcel);
74     sequenceableRotateWindow.Unmarshalling(parcel);
75     PreviewAnimation animation;
76     SequenceablePreviewAnimation sequenceablePreviewAnimation1(previewStyle, animation);
77     sequenceablePreviewAnimation1.Marshalling(parcel);
78     sequenceablePreviewAnimation1.Unmarshalling(parcel);
79     SequenceablePostureData postureData;
80     postureData.Marshalling(parcel);
81     postureData.Unmarshalling(parcel);
82     return true;
83 }
84 } // namespace OHOS
85 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)86 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
87 {
88     /* Run your code on data */
89     if (data == nullptr) {
90         return 0;
91     }
92     OHOS::SequenceableFuzzTest(data, size);
93     return 0;
94 }
95 } // namespace DeviceStatus
96 } // namespace Msdp
97 } // namespace OHOS