Echo typed characters in Wine edit fields

This commit is contained in:
deedra committed 2026-10-12 15:31:00 -07:00
1 parent d9aa40e16c
commit a002c4cc1e
7 files changed
+154 -22

No files matched your search

+15 -1
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Drive Wine's actual Notepad; the standard-control fixture covers edge cases.
#include <windows.h>
#include <stdio.h>
static DWORD notepad_pid;
static HWND notepad;
@@ -61,6 +62,18 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show)
if (notepad) {
HWND edit = FindWindowExW(notepad, NULL, L"Edit", NULL);
SetForegroundWindow(notepad);
Sleep(400);
key('Z', FALSE, FALSE);
key('Z', FALSE, FALSE);
key(VK_SPACE, FALSE, FALSE);
key(VK_RETURN, FALSE, FALSE);
WCHAR typed[16] = {0};
SendMessageW(edit, WM_GETTEXT, 16, (LPARAM)typed);
if (lstrcmpW(typed, L"zz \r\n")) {
fprintf(stderr, "Notepad typing did not reach its edit: units=%d first=%04x foreground=%p expected=%p\n",
lstrlenW(typed), (unsigned)typed[0], (void *)GetForegroundWindow(), (void *)notepad);
ExitProcess(2);
}
SendMessageW(edit, WM_SETTEXT, 0, (LPARAM)L"hello beta\r\nNotepad second line");
SendMessageW(edit, EM_SETSEL, 0, 0);
Sleep(400);
@@ -79,12 +92,13 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show)
WCHAR text[80] = {0};
SendMessageW(edit, WM_GETTEXT, 80, (LPARAM)text);
if (!lstrcmpW(text, L"hello beta\r\notepad second line")) result = 0;
else fprintf(stderr, "Notepad final document mismatch: units=%d\n", lstrlenW(text));
PostMessageW(notepad, WM_CLOSE, 0, 0);
for (int i = 0; i < 100 && !saveDialog; ++i) {
EnumWindows(find_save_dialog, 0);
Sleep(50);
}
if (!saveDialog) result = 2;
if (!saveDialog) { fprintf(stderr, "Notepad save dialog missing\n"); result = 2; }
else {
SetForegroundWindow(saveDialog);
Sleep(400);