Notepad++ should work now.
This commit is contained in:
1 parent
cbce83581a
commit
df7879acb5
12 files changed
+523
-18
No files matched your search
@@ -108,6 +108,33 @@ reader's `docs/testing/wine-accessibility.md` for current evidence and live
|
||||
acceptance gates. Run Xvfb fixtures sequentially; concurrent automatic display
|
||||
allocation can collide.
|
||||
|
||||
## Notepad++ / Scintilla checks
|
||||
|
||||
Use a locally available 64-bit Notepad++ executable:
|
||||
|
||||
```sh
|
||||
xvfb-run -a python3 tests/menu_integration.py --build-dir build --fixture scintilla --notepadpp-exe /path/to/notepad++.exe
|
||||
```
|
||||
|
||||
The runner copies the executable and model XML files into a temporary directory,
|
||||
uses local configuration, disables plugins/session restoration, and opens a
|
||||
disposable UTF-8 document in its private Wine prefix. The user's running
|
||||
Notepad++ and documents are untouched. The fixture uses actual `SendInput`
|
||||
arrows, Ctrl+Right, Shift selection, Delete, Backspace, undo and menu return;
|
||||
checks Ctrl+X, multibyte accented characters, emoji, a document over one million
|
||||
bytes and truncation at a surrogate pair; and verifies document length
|
||||
after a read-only deletion attempt. Add `--late-helper` or `--restart-helper`
|
||||
to check attachment and reader restart while the editor stays open.
|
||||
|
||||
After installing, restart Cthulhu and close/reopen Notepad++ so its process
|
||||
loads the new DLL. In a disposable document with several lines, accented
|
||||
characters and emoji, check Up/Down line reading and Left/Right character
|
||||
reading in both directions. Check Ctrl+Left/Right words, Shift selection and
|
||||
unselection, Backspace/Delete, undo, Alt/Escape return and switching document
|
||||
tabs. Repeat ordinary Wine Notepad editing, menu navigation, and password
|
||||
fields in other applications for regressions. Check speech and physical
|
||||
braille separately. These recorder tests do not establish either live output.
|
||||
|
||||
## List-view checks
|
||||
|
||||
```sh
|
||||
|
||||
@@ -7,6 +7,7 @@ import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
@@ -16,20 +17,24 @@ from gi.repository import Gio, GLib
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--build-dir", default="build")
|
||||
parser.add_argument("--session", action="store_true")
|
||||
parser.add_argument("--fixture", choices=("menu", "edit", "notepad", "list", "winforms", "controls"), default="menu")
|
||||
parser.add_argument("--fixture", choices=("menu", "edit", "notepad", "list", "winforms", "controls", "scintilla"), default="menu")
|
||||
parser.add_argument("--notepadpp-exe", type=Path)
|
||||
parser.add_argument("--32-bit", dest="is32Bit", action="store_true")
|
||||
parser.add_argument("--late-helper", action="store_true")
|
||||
parser.add_argument("--restart-helper", action="store_true")
|
||||
args = parser.parse_args()
|
||||
if args.is32Bit and args.fixture not in ("list", "controls"):
|
||||
parser.error("32-bit checks currently require --fixture list or controls")
|
||||
if (args.late_helper or args.restart_helper) and args.fixture not in ("edit", "winforms"):
|
||||
parser.error("helper lifecycle checks require --fixture edit or --fixture winforms")
|
||||
if (args.late_helper or args.restart_helper) and args.fixture not in ("edit", "winforms", "scintilla"):
|
||||
parser.error("helper lifecycle checks require --fixture edit, winforms or scintilla")
|
||||
if args.fixture == "scintilla" and (not args.notepadpp_exe or not args.notepadpp_exe.is_file()):
|
||||
parser.error("--fixture scintilla requires --notepadpp-exe pointing to a 64-bit Notepad++ executable")
|
||||
build = Path(args.build_dir).resolve()
|
||||
if not args.session:
|
||||
sys.exit(subprocess.call(["dbus-run-session", "--", sys.executable,
|
||||
__file__, "--session", "--build-dir", str(build),
|
||||
"--fixture", args.fixture,
|
||||
*(["--notepadpp-exe", str(args.notepadpp_exe.resolve())] if args.notepadpp_exe else []),
|
||||
*(["--32-bit"] if args.is32Bit else []),
|
||||
*(["--late-helper"] if args.late_helper else []),
|
||||
*(["--restart-helper"] if args.restart_helper else [])]))
|
||||
@@ -59,6 +64,21 @@ with tempfile.TemporaryDirectory(prefix="wine-access-menus-") as temporary:
|
||||
WINEDLLOVERRIDES="mscoree,mshtml=", CTHULHU_WINE_ACCESS_MANAGED="1")
|
||||
ready = Path(temporary) / "ready"
|
||||
env["WINE_ACCESS_FIXTURE_READY"] = "Z:" + str(ready).replace("/", "\\")
|
||||
if args.fixture == "scintilla":
|
||||
# Copy the application to isolate its configuration as well as its
|
||||
# document. Never open or edit files in the user's running instance.
|
||||
appDir = Path(temporary) / "notepadpp"
|
||||
appDir.mkdir()
|
||||
for name in (args.notepadpp_exe.name, "langs.model.xml", "stylers.model.xml"):
|
||||
source = args.notepadpp_exe.parent / name
|
||||
if source.is_file():
|
||||
shutil.copy2(source, appDir / name)
|
||||
(appDir / "doLocalConf.xml").touch()
|
||||
document = Path(temporary) / "editor.txt"
|
||||
document.write_bytes(("hello beta\r\nScintilla second line\r\ncafé 😀 tail\r\n" +
|
||||
"x" * 1100000 + "\r\n" + "x" * 1022 + "😀tail").encode("utf-8"))
|
||||
env["WINE_ACCESS_NOTEPADPP_EXE"] = "Z:" + str(appDir / args.notepadpp_exe.name).replace("/", "\\")
|
||||
env["WINE_ACCESS_SCINTILLA_DOCUMENT"] = "Z:" + str(document).replace("/", "\\")
|
||||
fixture = Path(temporary) / "menu-fixture.exe"
|
||||
compiler = "i686-w64-mingw32-gcc" if args.is32Bit else "x86_64-w64-mingw32-gcc"
|
||||
sourceName = "edit" if args.fixture == "winforms" else args.fixture
|
||||
@@ -72,7 +92,7 @@ with tempfile.TemporaryDirectory(prefix="wine-access-menus-") as temporary:
|
||||
subprocess.run(["wineboot", "-u"], env=env, check=True, timeout=45)
|
||||
if args.late_helper:
|
||||
app = subprocess.Popen(["wine", str(fixture)], env=env)
|
||||
deadline = time.monotonic() + 5
|
||||
deadline = time.monotonic() + 10
|
||||
while not ready.exists() and app.poll() is None and time.monotonic() < deadline:
|
||||
time.sleep(0.01)
|
||||
assert ready.exists(), "editor did not become ready before helper attachment"
|
||||
@@ -173,6 +193,28 @@ with tempfile.TemporaryDirectory(prefix="wine-access-menus-") as temporary:
|
||||
assert any(e[3] == "edit" and e[4] == "otepad second line" for e in text_events), "Notepad menu return missing"
|
||||
print("PASS: actual Wine Notepad keyboard characters, words, lines, selection, deletion, and menu return")
|
||||
sys.exit(0)
|
||||
if args.fixture == "scintilla":
|
||||
textEvents = [e for e in events if e[0].endswith(":text")]
|
||||
for event in textEvents:
|
||||
print(event[1:7])
|
||||
spoken = [e[2] for e in textEvents if e[1] == "text"]
|
||||
for expected in ("e", "l", "beta", "hello ", "Scintilla second line", "hello beta", "S selected",
|
||||
"c selected", "c unselected", "S unselected", "S deleted", "c",
|
||||
"Scintilla selected", "Scintilla deleted", "café 😀 tail", "é", "😀",
|
||||
"😀 selected", "😀 unselected", "😀 deleted"):
|
||||
assert expected in spoken, f"missing Scintilla feedback: {expected!r}; {textEvents!r}"
|
||||
assert spoken.count("l") == 2, "Scintilla lost repeated characters"
|
||||
assert any(e[1] == "focus" and e[4] == "intilla second line" for e in textEvents), "menu return lost Scintilla caret line"
|
||||
assert any(e[3] == "read only edit" for e in textEvents), "Scintilla read-only role missing"
|
||||
assert any(e[2] == "c" and "kind=7" in e[5] for e in textEvents), "Scintilla Backspace suffix wrong"
|
||||
assert any(e[2] == "😀" and "kind=7" in e[5] for e in textEvents), "multibyte Backspace missing"
|
||||
assert any(e[2] == "x" * 1022 for e in textEvents), "Scintilla truncation split a surrogate pair"
|
||||
assert any(e[2] == "x" * 1023 for e in textEvents), "large Scintilla document line missing"
|
||||
focusEvents = [e for e in textEvents if e[1] == "focus"]
|
||||
assert [e[4] for e in focusEvents[-2:]] == ["hello beta", "hello beta"], "single-byte Scintilla charset reading failed"
|
||||
assert all("offset_unit=byte" in e[5] for e in textEvents if e[1] == "text"), "Scintilla offsets mislabeled"
|
||||
print("PASS: actual Notepad++ arrows, words, Unicode, selection, deletion, undo, menu return and read-only document")
|
||||
sys.exit(0)
|
||||
if args.fixture in ("edit", "winforms"):
|
||||
text_events = [e for e in events if e[0].endswith(":text")]
|
||||
for event in text_events:
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
// Drive an actual Notepad++ instance in the runner's disposable Wine prefix.
|
||||
#include <windows.h>
|
||||
#include "../scintilla_messages.h"
|
||||
|
||||
static DWORD editorPid;
|
||||
static HWND editor, owner;
|
||||
|
||||
static BOOL CALLBACK find_editor(HWND window, LPARAM unused) {
|
||||
(void)unused;
|
||||
WCHAR name[64];
|
||||
if (IsWindowVisible(window) && GetClassNameW(window, name, 64) &&
|
||||
!lstrcmpW(name, L"Scintilla")) {
|
||||
editor = window;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK find_owner(HWND window, LPARAM unused) {
|
||||
(void)unused;
|
||||
DWORD pid;
|
||||
GetWindowThreadProcessId(window, &pid);
|
||||
if (pid == editorPid && IsWindowVisible(window)) {
|
||||
EnumChildWindows(window, find_editor, 0);
|
||||
if (editor) { owner = window; return FALSE; }
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void key(WORD vk, BOOL control, BOOL shift) {
|
||||
INPUT input[6] = {0};
|
||||
UINT count = 0;
|
||||
if (control) { input[count].ki.wVk = VK_CONTROL; ++count; }
|
||||
if (shift) { input[count].ki.wVk = VK_SHIFT; ++count; }
|
||||
input[count].ki.wVk = vk; ++count;
|
||||
input[count].ki.wVk = vk; input[count].ki.dwFlags = KEYEVENTF_KEYUP; ++count;
|
||||
if (shift) { input[count].ki.wVk = VK_SHIFT; input[count].ki.dwFlags = KEYEVENTF_KEYUP; ++count; }
|
||||
if (control) { input[count].ki.wVk = VK_CONTROL; input[count].ki.dwFlags = KEYEVENTF_KEYUP; ++count; }
|
||||
for (UINT i = 0; i < count; ++i) input[i].type = INPUT_KEYBOARD;
|
||||
if (SendInput(count, input, sizeof(INPUT)) != count) ExitProcess(3);
|
||||
Sleep(200);
|
||||
}
|
||||
|
||||
static void move_to(ptrdiff_t position) {
|
||||
SendMessageW(editor, SCI_SETSEL, position, position);
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR args, int show) {
|
||||
(void)instance; (void)previous; (void)args; (void)show;
|
||||
WCHAR executable[2048], document[2048], command[4600];
|
||||
if (!GetEnvironmentVariableW(L"WINE_ACCESS_NOTEPADPP_EXE", executable, 2048) ||
|
||||
!GetEnvironmentVariableW(L"WINE_ACCESS_SCINTILLA_DOCUMENT", document, 2048)) return 2;
|
||||
wsprintfW(command, L"\"%s\" -multiInst -nosession -noPlugin \"%s\"", executable, document);
|
||||
STARTUPINFOW startup = {0};
|
||||
PROCESS_INFORMATION process = {0};
|
||||
startup.cb = sizeof(startup);
|
||||
if (!CreateProcessW(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &process)) return 2;
|
||||
editorPid = process.dwProcessId;
|
||||
for (int i = 0; i < 100 && !editor; ++i) { EnumWindows(find_owner, 0); Sleep(50); }
|
||||
if (!editor || SendMessageW(editor, SCI_GETLENGTH, 0, 0) < 40) return 2;
|
||||
ptrdiff_t originalLength = SendMessageW(editor, SCI_GETLENGTH, 0, 0);
|
||||
SetForegroundWindow(owner);
|
||||
key(VK_HOME, TRUE, FALSE);
|
||||
WCHAR ready[1024];
|
||||
if (GetEnvironmentVariableW(L"WINE_ACCESS_FIXTURE_READY", ready, 1024)) {
|
||||
HANDLE file = CreateFileW(ready, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE) return 2;
|
||||
CloseHandle(file);
|
||||
}
|
||||
Sleep(1500);
|
||||
key(VK_RIGHT, FALSE, FALSE); // e
|
||||
key(VK_RIGHT, FALSE, FALSE); // l
|
||||
key(VK_RIGHT, FALSE, FALSE); // l
|
||||
key(VK_RIGHT, TRUE, FALSE); // beta
|
||||
key(VK_LEFT, TRUE, FALSE); // hello plus trailing space
|
||||
key(VK_RIGHT, TRUE, FALSE);
|
||||
key(VK_DOWN, FALSE, FALSE); // Scintilla second line
|
||||
key(VK_UP, FALSE, FALSE); // hello beta
|
||||
key(VK_DOWN, FALSE, FALSE);
|
||||
key(VK_HOME, FALSE, FALSE);
|
||||
key(VK_RIGHT, FALSE, TRUE); // S selected
|
||||
key(VK_RIGHT, FALSE, TRUE); // c selected
|
||||
key(VK_LEFT, FALSE, TRUE); // c unselected
|
||||
key(VK_LEFT, FALSE, FALSE); // S unselected
|
||||
key(VK_DELETE, FALSE, FALSE);// S deleted
|
||||
key(VK_RIGHT, FALSE, FALSE);
|
||||
key(VK_BACK, FALSE, FALSE); // c (without deleted suffix)
|
||||
key(VK_MENU, FALSE, FALSE);
|
||||
key(VK_ESCAPE, FALSE, FALSE);
|
||||
key(VK_ESCAPE, FALSE, FALSE);// return at "intilla second line"
|
||||
key('Z', TRUE, FALSE); // undo c
|
||||
key('Z', TRUE, FALSE); // undo S
|
||||
key(VK_HOME, FALSE, FALSE);
|
||||
key(VK_RIGHT, FALSE, FALSE);// c from restored document
|
||||
SendMessageW(editor, SCI_SETSEL, 12, 21); // Scintilla selected
|
||||
Sleep(100);
|
||||
key('X', TRUE, FALSE); // Scintilla deleted
|
||||
key('Z', TRUE, FALSE);
|
||||
key(VK_HOME, FALSE, FALSE);
|
||||
key(VK_DOWN, FALSE, FALSE); // café 😀 tail
|
||||
ptrdiff_t lineStart = SendMessageW(editor, SCI_POSITIONFROMLINE, 2, 0);
|
||||
move_to(lineStart + 2);
|
||||
key(VK_RIGHT, FALSE, FALSE);// é (two UTF-8 bytes)
|
||||
move_to(lineStart + 6);
|
||||
key(VK_LEFT, FALSE, FALSE); // space
|
||||
key(VK_RIGHT, FALSE, FALSE);// 😀 (four UTF-8 bytes)
|
||||
key(VK_RIGHT, FALSE, TRUE); // 😀 selected
|
||||
key(VK_LEFT, FALSE, TRUE); // 😀 unselected
|
||||
key(VK_DELETE, FALSE, FALSE);// 😀 deleted
|
||||
key('Z', TRUE, FALSE);
|
||||
move_to(lineStart + 10);
|
||||
key(VK_BACK, FALSE, FALSE); // 😀
|
||||
key('Z', TRUE, FALSE);
|
||||
SendMessageW(editor, 2171 /* SCI_SETREADONLY */, TRUE, 0);
|
||||
SendMessageW(editor, RegisterWindowMessageW(L"CthulhuWineEditFocus"), 0, 0);
|
||||
key(VK_DELETE, FALSE, FALSE);// read-only: must leave document unchanged
|
||||
if (SendMessageW(editor, SCI_GETLENGTH, 0, 0) != originalLength) return 4;
|
||||
SendMessageW(editor, 2171 /* SCI_SETREADONLY */, FALSE, 0);
|
||||
move_to(SendMessageW(editor, SCI_POSITIONFROMLINE, 3, 0));
|
||||
key(VK_END, TRUE, FALSE); // truncate before a surrogate pair in the last line
|
||||
key(VK_UP, FALSE, FALSE);// very large document line, bounded range read
|
||||
move_to(0);
|
||||
LRESULT codePage = SendMessageW(editor, SCI_GETCODEPAGE, 0, 0);
|
||||
SendMessageW(editor, 2037 /* SCI_SETCODEPAGE */, 0, 0);
|
||||
SendMessageW(editor, 2066 /* SCI_STYLESETCHARACTERSET */, 32, DEFAULT_CHARSET);
|
||||
SendMessageW(editor, RegisterWindowMessageW(L"CthulhuWineEditFocus"), 0, 0);
|
||||
Sleep(100);
|
||||
SendMessageW(editor, 2066 /* SCI_STYLESETCHARACTERSET */, 32, ANSI_CHARSET);
|
||||
SendMessageW(editor, RegisterWindowMessageW(L"CthulhuWineEditFocus"), 0, 0);
|
||||
Sleep(100);
|
||||
SendMessageW(editor, 2037 /* SCI_SETCODEPAGE */, codePage, 0);
|
||||
// Mark this disposable document clean to close without a save prompt.
|
||||
SendMessageW(editor, 2014 /* SCI_SETSAVEPOINT */, 0, 0);
|
||||
PostMessageW(owner, WM_CLOSE, 0, 0);
|
||||
int result = WaitForSingleObject(process.hProcess, 3000) == WAIT_OBJECT_0 ? 0 : 2;
|
||||
CloseHandle(process.hThread); CloseHandle(process.hProcess);
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user