fix window fuzz test issue

Signed-off-by: wangjian10 <wangjian10@huawei.com>
This commit is contained in:
wangjian10 2024-05-20 23:26:02 +08:00
parent 9607198815
commit 8e414eb404
15 changed files with 124 additions and 87 deletions

View File

@ -30,7 +30,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
@ -47,12 +47,27 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowEventChannel> eventStub = std::make_shared<WindowEventChannel>(nullptr);
sptr<WindowEventChannel> eventStub = new (std::nothrow) WindowEventChannel(nullptr);
if (eventStub == nullptr) {
return false;
}
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_POINTER_EVENT),
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_ACTIVE_EVENT),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT_ASYNC),
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_WINDOW_ID_EVENT),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_STATE_EVENT),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_MOVE_SEARCH),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FIND_FOCUSED_ELEMENT_INFO),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_CLEAR_FOCUS),
parcel, reply, option);
return true;
}

View File

@ -30,7 +30,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
@ -47,18 +47,21 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowEventChannel> eventStub = std::make_shared<WindowEventChannel>(nullptr);
sptr<WindowEventChannel> eventStub = new (std::nothrow) WindowEventChannel(nullptr);
if (eventStub == nullptr) {
return false;
}
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_ACTIVE_EVENT),
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_WINDOW_ID_EVENT),
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT_ASYNC),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_STATE_EVENT),
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_EXECUTE_ACTION),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_MOVE_SEARCH),
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT),
parcel, reply, option);
return true;
}

View File

@ -30,7 +30,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
@ -47,10 +47,22 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowEventChannel> eventStub = std::make_shared<WindowEventChannel>(nullptr);
sptr<WindowEventChannel> eventStub = new (std::nothrow) WindowEventChannel(nullptr);
if (eventStub == nullptr) {
return false;
}
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_POINTER_EVENT),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_BACKPRESSED_EVENT),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_SEARCH_ELEMENT_INFO),
parcel, reply, option);
eventStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::WindowEventInterfaceCode::TRANS_ID_TRANSFER_SEARCH_ELEMENT_INFO_BY_TEXT),
parcel, reply, option);
return true;
}
} // namespace.OHOS

View File

@ -31,7 +31,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
@ -48,8 +48,11 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
sptr<IWindowExtensionCallback> componentCallback;
std::shared_ptr<WindowExtensionClientStubImpl> extensionStubClient =
std::make_shared<WindowExtensionClientStubImpl>(componentCallback);
sptr<WindowExtensionClientStubImpl> extensionStubClient =
new (std::nothrow) WindowExtensionClientStubImpl(componentCallback);
if (extensionStubClient == nullptr) {
return false;
}
extensionStubClient->OnRemoteRequest(
static_cast<uint32_t>(IWindowExtensionClient::TRANS_ID_ON_WINDOW_READY),
parcel, reply, option);

View File

@ -31,7 +31,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
@ -48,7 +48,10 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowExtensionStubImpl> extensionStub = std::make_shared<WindowExtensionStubImpl>("windowName");
sptr<WindowExtensionStubImpl> extensionStub = new (std::nothrow) WindowExtensionStubImpl("windowName");
if (extensionStub == nullptr) {
return false;
}
extensionStub->OnRemoteRequest(
static_cast<uint32_t>(IWindowExtension::TRANS_ID_SETBOUNDS),
parcel, reply, option);

View File

@ -25,19 +25,7 @@ ohos_fuzztest("WindowManagerAgentStubBarFuzzTest") {
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
@ -67,5 +55,10 @@ ohos_fuzztest("WindowManagerAgentStubBarFuzzTest") {
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":WindowManagerAgentStubBarFuzzTest",
]
}
###############################################################################

View File

@ -29,7 +29,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
@ -55,10 +55,16 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteInterfaceToken(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
sptr<WindowManagerAgent> wmStub = new (std::nothrow) WindowManagerAgent();
if (wmStub == nullptr) {
return false;
}
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS),
parcel, reply, option);
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT),
parcel, reply, option);
return true;
}
} // namespace.OHOS

View File

@ -25,19 +25,7 @@ ohos_fuzztest("WindowManagerAgentStubFoucsFuzzTest") {
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
@ -67,5 +55,10 @@ ohos_fuzztest("WindowManagerAgentStubFoucsFuzzTest") {
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":WindowManagerAgentStubFoucsFuzzTest",
]
}
###############################################################################

View File

@ -29,7 +29,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
@ -55,10 +55,19 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteInterfaceToken(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
sptr<WindowManagerAgent> wmStub = new (std::nothrow) WindowManagerAgent();
if (wmStub == nullptr) {
return false;
}
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS),
parcel, reply, option);
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_VISIBILITY),
parcel, reply, option);
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_VISIBLE_WINDOW_NUM),
parcel, reply, option);
return true;
}
} // namespace.OHOS

View File

@ -25,19 +25,7 @@ ohos_fuzztest("WindowManagerAgentStubStateFuzzTest") {
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
@ -67,5 +55,10 @@ ohos_fuzztest("WindowManagerAgentStubStateFuzzTest") {
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":WindowManagerAgentStubStateFuzzTest",
]
}
###############################################################################

View File

@ -29,7 +29,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
@ -55,10 +55,18 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteInterfaceToken(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
sptr<WindowManagerAgent> wmStub = new (std::nothrow) WindowManagerAgent();
if (wmStub == nullptr) {
return false;
}
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_DRAWING_STATE),
parcel, reply, option);
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::
WindowManagerAgentMsg::TRANS_ID_UPDATE_GESTURE_NAVIGATION_ENABLED),
parcel, reply, option);
return true;
}
} // namespace.OHOS

View File

@ -25,19 +25,7 @@ ohos_fuzztest("WindowManagerAgentStubStatusFuzzTest") {
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
@ -67,5 +55,10 @@ ohos_fuzztest("WindowManagerAgentStubStatusFuzzTest") {
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":WindowManagerAgentStubStatusFuzzTest",
]
}
###############################################################################

View File

@ -29,7 +29,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
@ -55,10 +55,16 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteInterfaceToken(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
sptr<WindowManagerAgent> wmStub = new (std::nothrow) WindowManagerAgent();
if (wmStub == nullptr) {
return false;
}
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS),
parcel, reply, option);
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_WINDOW_STATUS),
parcel, reply, option);
return true;
}
} // namespace.OHOS

View File

@ -25,19 +25,7 @@ ohos_fuzztest("WindowManagerAgentStubTypeFuzzTest") {
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
@ -67,5 +55,10 @@ ohos_fuzztest("WindowManagerAgentStubTypeFuzzTest") {
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":WindowManagerAgentStubTypeFuzzTest",
]
}
###############################################################################

View File

@ -29,7 +29,7 @@ using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
@ -55,10 +55,17 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
parcel.WriteInterfaceToken(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
sptr<WindowManagerAgent> wmStub = new (std::nothrow) WindowManagerAgent();
if (wmStub == nullptr) {
return false;
}
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE),
parcel, reply, option);
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WATER_MARK_FLAG),
parcel, reply, option);
return true;
}
} // namespace.OHOS