5#include "flutter/shell/platform/windows/testing/test_keyboard.h"
7#include <rapidjson/document.h>
9#include "flutter/fml/logging.h"
10#include "flutter/shell/platform/common/json_message_codec.h"
11#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
17 if (
string ==
nullptr) {
20 size_t len = strlen(
string);
27std::string _print_character(
const char*
s) {
31 return std::string(
"\"") +
s +
"\"";
34std::unique_ptr<std::vector<uint8_t>> _keyHandlingResponse(
bool handled) {
35 rapidjson::Document document;
36 auto& allocator = document.GetAllocator();
38 document.AddMember(
"handled", handled, allocator);
42static std::string ordinal(
int num) {
56#define _RETURN_IF_NOT_EQUALS(val1, val2) \
57 if ((val1) != (val2)) { \
58 return ::testing::AssertionFailure() \
59 << "Expected equality of these values:\n " #val1 "\n " << val2 \
60 << "\n Actual: \n " << val1; \
64 const char* expr_expected,
71 if ((
event.character ==
nullptr) != (expected.
character ==
nullptr) ||
73 return ::testing::AssertionFailure()
74 <<
"Expected equality of these values:\n expected.character\n "
75 << _print_character(expected.
character) <<
"\n Actual: \n "
76 << _print_character(
event.character);
79 return ::testing::AssertionSuccess();
87 bool transition_state) {
103 std::shared_ptr<MockKeyResponseController> response_controller) {
109 if (std::string(
message->channel) == std::string(
"flutter/settings")) {
112 if (std::string(
message->channel) == std::string(
"flutter/keyevent")) {
114 auto response = _keyHandlingResponse(handled);
115 auto response_handle =
message->response_handle;
116 if (response_handle->callback !=
nullptr) {
117 response_handle->callback(response->data(), response->size(),
118 response_handle->user_data);
123 if (std::string(
message->channel) == std::string(
"flutter/textinput")) {
124 std::unique_ptr<rapidjson::Document> document =
127 if (document ==
nullptr) {
151 [](
auto engine,
auto data_callback,
auto user_data,
auto response_out) {
154 response_handle->callback = data_callback;
155 *response_out = response_handle;
171 const uint8_t*
data,
size_t data_length) {
return kSuccess; };
202 size_t display_count) {
return kSuccess; };
211 <<
"Called DispatchFront while pending message queue is empty";
220 << ordinal(
_sent_messages.size()) <<
" event, with\n " << std::hex
221 <<
"Message 0x" <<
message.message <<
" LParam 0x" <<
message.lParam
222 <<
" WParam 0x" <<
message.wParam;
233 if (iter->message >= wMsgFilterMin && iter->message <= wMsgFilterMax) {
235 .message = iter->message,
236 .wParam = iter->wParam,
237 .lParam = iter->lParam,
239 if ((wRemoveMsg & PM_REMOVE) == PM_REMOVE) {
FlutterEngineProcTable & embedder_api()
static const JsonMessageCodec & GetInstance()
std::unique_ptr< T > DecodeMessage(const uint8_t *binary_message, const size_t message_size) const
std::unique_ptr< std::vector< uint8_t > > EncodeMessage(const T &message) const
std::list< Win32Message > _pending_messages
std::list< Win32Message > _sent_messages
void PushBack(const Win32Message *message)
virtual LRESULT Win32SendMessage(UINT const message, WPARAM const wparam, LPARAM const lparam)=0
BOOL Win32PeekMessage(LPMSG lpMsg, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
struct _FlutterPlatformMessageResponseHandle FlutterPlatformMessageResponseHandle
struct _FlutterEngine * FLUTTER_API_SYMBOL(FlutterEngine)
FlutterAccessibilityFeature
FlutterEngineDisplaysUpdateType
void(* FlutterKeyEventCallback)(bool, void *)
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_DCHECK(condition)
::testing::AssertionResult _EventEquals(const char *expr_event, const char *expr_expected, const FlutterKeyEvent &event, const FlutterKeyEvent &expected)
void MockEmbedderApiForKeyboard(EngineModifier &modifier, std::shared_ptr< MockKeyResponseController > response_controller)
constexpr LRESULT kWmResultDontCheck
static std::shared_ptr< MockKeyResponseController > stored_response_controller
LPARAM CreateKeyEventLparam(USHORT scancode, bool extended, bool was_down, USHORT repeat_count, bool context_code, bool transition_state)
char * clone_string(const char *string)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
FlutterEnginePlatformMessageReleaseResponseHandleFnPtr PlatformMessageReleaseResponseHandle
FlutterEngineUpdateLocalesFnPtr UpdateLocales
FlutterEngineSendKeyEventFnPtr SendKeyEvent
FlutterEngineSendWindowMetricsEventFnPtr SendWindowMetricsEvent
FlutterEngineShutdownFnPtr Shutdown
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate
FlutterEngineSendPlatformMessageFnPtr SendPlatformMessage
FlutterEnginePlatformMessageCreateResponseHandleFnPtr PlatformMessageCreateResponseHandle
FlutterEngineSendPlatformMessageResponseFnPtr SendPlatformMessageResponse
FlutterEngineRunFnPtr Run
FlutterEngineUpdateAccessibilityFeaturesFnPtr UpdateAccessibilityFeatures
FlutterKeyEventType type
The event kind.
#define _RETURN_IF_NOT_EQUALS(val1, val2)