!6399 补齐FUZZ测试用例

Merge pull request !6399 from kangchongtao/0115
This commit is contained in:
openharmony_ci 2022-11-08 01:43:31 +00:00 committed by Gitee
commit 81302f7df1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 59 additions and 5 deletions

View File

@ -28,11 +28,50 @@ namespace OHOS {
}
bool FileImageLoaderTest(const uint8_t* data, size_t size)
{
auto info = CreatImageSourceInfo(data, size);
Ace::WeakPtr<Ace::PipelineBase> context = nullptr;
Ace::FileImageLoader fileImageLoader;
return fileImageLoader.LoadImageData(info, context) != nullptr;
}
bool DataProviderImageLoaderTest(const uint8_t* data, size_t size)
{
auto info = CreatImageSourceInfo(data, size);
Ace::WeakPtr<Ace::PipelineBase> context = nullptr;
Ace::DataProviderImageLoader dataProviderImageLoader;
return dataProviderImageLoader.LoadImageData(info, context) != nullptr;
Ace::Base64ImageLoader base64ImageLoader;
auto base64Image = base64ImageLoader.LoadImageData(info, context) != nullptr;
return dataProviderImageLoader.LoadImageData(info, context) != nullptr && base64Image;
}
bool DecodedDataProviderImageLoaderTest(const uint8_t* data, size_t size)
{
auto info = CreatImageSourceInfo(data, size);
Ace::WeakPtr<Ace::PipelineBase> context = nullptr;
Ace::DecodedDataProviderImageLoader decodedDataProviderImageLoader;
auto skData = decodedDataProviderImageLoader.LoadImageData(info, context);
auto ngData = decodedDataProviderImageLoader.LoadDecodedImageData(info, context);
return skData != nullptr && ngData != nullptr;
}
bool PixelMapImageLoaderTest(const uint8_t* data, size_t size)
{
auto info = CreatImageSourceInfo(data, size);
Ace::WeakPtr<Ace::PipelineBase> context = nullptr;
Ace::PixelMapImageLoader pixelMapImageLoader;
auto skData = pixelMapImageLoader.LoadImageData(info, context);
auto ngData = pixelMapImageLoader.LoadDecodedImageData(info, context);
return skData != nullptr && ngData != nullptr;
}
bool ResourceImageLoaderTest(const uint8_t* data, size_t size)
{
auto info = CreatImageSourceInfo(data, size);
Ace::WeakPtr<Ace::PipelineBase> context = nullptr;
Ace::ResourceImageLoader resourceImageLoader;
auto skData = resourceImageLoader.LoadImageData(info, context);
return skData != nullptr;
}
bool AssetImageLoader(const uint8_t* data, size_t size)
@ -40,7 +79,9 @@ namespace OHOS {
auto info = CreatImageSourceInfo(data, size);
Ace::WeakPtr<Ace::PipelineBase> context = nullptr;
Ace::AssetImageLoader assetImageLoader;
return assetImageLoader.LoadImageData(info, context) != nullptr;
std::string randomString = reinterpret_cast<const char*>(data);
auto jsonString = assetImageLoader.LoadJsonData(randomString);
return assetImageLoader.LoadImageData(info, context) != nullptr && jsonString.empty();
}
bool NetworkImageLoader(const uint8_t* data, size_t size)
@ -65,9 +106,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::FileImageLoaderTest(data, size);
OHOS::DataProviderImageLoaderTest(data, size);
OHOS::DecodedDataProviderImageLoaderTest(data, size);
OHOS::AssetImageLoader(data, size);
OHOS::NetworkImageLoader(data, size);
OHOS::InternalImageLoader(data, size);
OHOS::ResourceImageLoaderTest(data, size);
OHOS::PixelMapImageLoaderTest(data, size);
return 0;
}

View File

@ -19,11 +19,20 @@
#include "want.h"
namespace OHOS {
bool RegisterCallBackTest(const AAFwk::Want& want)
bool RegisterCallBackTest(const uint8_t* data, const AAFwk::Want& want)
{
OHOS::Ace::UIServiceMgrClient client;
sptr<Ace::IUIService> uiService = nullptr;
return client.RegisterCallBack(want, uiService) == ERR_OK;
std::string randomString = reinterpret_cast<const char*>(data);
int randomNumber = static_cast<int>(U32_AT(data));
DialogCallback callback;
int* id = nullptr;
client.RegisterCallBack(want, uiService);
client.ShowDialog(
randomString, randomString, OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
randomNumber, randomNumber, randomNumber, randomNumber, callback, id);
client.UpdateDialog(randomNumber, randomString);
return client.CancelDialog(randomNumber) == ERR_OK;
}
bool UnregisterCallBackTest(const uint8_t* data, const AAFwk::Want& want)
@ -61,7 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
OHOS::AAFwk::Want want;
std::string randomString = reinterpret_cast<const char*>(data);
want = want.SetUri(randomString);
OHOS::RegisterCallBackTest(want);
OHOS::RegisterCallBackTest(data, want);
OHOS::PushTest(data, want);
OHOS::RequestTest(data, want);
OHOS::ReturnRequestTest(data, want);