* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "accessibleabilityclientgetchildren_fuzzer.h"
#include "accessible_ability_client_fuzz.h"
namespace OHOS {
bool DoSomethingInterestingWithGetChildElementInfo(const uint8_t* data, size_t size)
{
if (data == nullptr || size < DATA_MIN_SIZE) {
return false;
}
size_t startPos = 0;
int32_t index = 0;
OHOS::Accessibility::AccessibilityElementInfo sourceElementInfo;
OHOS::Accessibility::AccessibilityElementInfo resultElementInfo;
startPos += GetObject<int32_t>(index, &data[startPos], size - startPos);
GenerateAccessibilityElementInfo(sourceElementInfo, &data[startPos], size - startPos);
OHOS::Accessibility::AccessibilityUITestAbility::GetInstance()->GetChildElementInfo(
index, sourceElementInfo, resultElementInfo);
return true;
}
bool DoSomethingInterestingWithGetChildren(const uint8_t* data, size_t size)
{
if (data == nullptr || size < DATA_MIN_SIZE) {
return false;
}
size_t startPos = 0;
OHOS::Accessibility::AccessibilityElementInfo sourceElementInfo;
std::vector<OHOS::Accessibility::AccessibilityElementInfo> resultElementInfos;
GenerateAccessibilityElementInfo(sourceElementInfo, &data[startPos], size - startPos);
OHOS::Accessibility::AccessibilityUITestAbility::GetInstance()->GetChildren(sourceElementInfo, resultElementInfos);
return true;
}
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
OHOS::DoSomethingInterestingWithGetChildElementInfo(data, size);
OHOS::DoSomethingInterestingWithGetChildren(data, size);
return 0;
}