inputflinger fuzzers: add function for creating RawEvents
The exact same logic was being repeated in five different places, so
let's make a helper function for it.
Bug: 264582512
Test: build and run inputflinger_multitouch_input_fuzzer
Change-Id: I870c762fd849dcde338be00918da766911e56c04
diff --git a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
index 616e870..d11e8ae 100644
--- a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
@@ -16,6 +16,7 @@
#include <FuzzContainer.h>
#include <KeyboardInputMapper.h>
+#include <MapperHelpers.h>
namespace android {
@@ -72,17 +73,7 @@
std::list<NotifyArgs> unused = mapper.reset(fdp->ConsumeIntegral<nsecs_t>());
},
[&]() -> void {
- int32_t type, code;
- type = fdp->ConsumeBool() ? fdp->PickValueInArray(kValidTypes)
- : fdp->ConsumeIntegral<int32_t>();
- code = fdp->ConsumeBool() ? fdp->PickValueInArray(kValidCodes)
- : fdp->ConsumeIntegral<int32_t>();
- RawEvent rawEvent{fdp->ConsumeIntegral<nsecs_t>(),
- fdp->ConsumeIntegral<nsecs_t>(),
- fdp->ConsumeIntegral<int32_t>(),
- type,
- code,
- fdp->ConsumeIntegral<int32_t>()};
+ RawEvent rawEvent = getFuzzedRawEvent(*fdp);
std::list<NotifyArgs> unused = mapper.process(&rawEvent);
},
[&]() -> void {