QT regression fixes.
This commit is contained in:
1 parent
440400985b
commit
8cc293113e
9 files changed
+782
-5
No files matched your search
@@ -29,6 +29,75 @@ actions, including ones with the same label, do not inherit the evidence.
|
|||||||
|
|
||||||
## Automated checks
|
## Automated checks
|
||||||
|
|
||||||
|
Qt wizard pages can expose an unnamed frame inside a top-level dialog. Window
|
||||||
|
ownership must resolve to the dialog, as it does for embedded frames in ordinary
|
||||||
|
windows. Otherwise page controls are rejected as background events while buttons
|
||||||
|
outside the page remain readable. Check Qt 5 and Qt 6 Tab and Shift+Tab traversal:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 tests/native_qt_dialogs.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This uses a private Xvfb/AT-SPI session and verifies that both combos and the
|
||||||
|
outside button retain the same foreground owner. For live acceptance in Mumble's
|
||||||
|
Audio Tuning Wizard, check the input and output System/Device combos, positional
|
||||||
|
audio checkbox, and Back/Next/Cancel buttons in both directions. Confirm speech
|
||||||
|
and configured control sounds, combo selection changes, and return after
|
||||||
|
switching workspaces. Also check an ordinary window containing nested frames and
|
||||||
|
browser Find; the ancestry change must preserve their top-level owners.
|
||||||
|
|
||||||
|
The same fixture checks populated port and user-name fields with Home, End,
|
||||||
|
Control+Left and Control+Right. Word capture bounds a nonnegative offset to the
|
||||||
|
last existing character and returns an empty range for empty text, matching
|
||||||
|
[Orca's word lookup](https://github.com/GNOME/orca/blob/main/src/orca/ax_text.py).
|
||||||
|
Querying a Qt 5 line edit's word at the caret after its last character was
|
||||||
|
reproduced freezing the entire provider, including subsequent Tab navigation.
|
||||||
|
The original Mumble log's first 800 ms timeout was a caret event at offset 5 in
|
||||||
|
the populated port field; later controls became invalid and the application
|
||||||
|
stopped answering fresh AT-SPI clients. Recovering an already frozen application
|
||||||
|
requires restarting it after loading the fixed reader. Private tests prevent
|
||||||
|
the freeze; they do not establish live speech, sounds or physical Braille.
|
||||||
|
|
||||||
|
Qt's default word lookup also loops when it moves before offset zero on a
|
||||||
|
leading separator or symbol. The regression matrix covers spaces, `/`, paths,
|
||||||
|
leading whitespace, underscores, punctuation and negative numbers with Home,
|
||||||
|
End and subsequent Tab navigation. At the start of a Qt field, a non-letter/
|
||||||
|
non-number uses the provider's character boundary instead, preserving its native
|
||||||
|
grapheme. Letters and numbers retain native word segmentation. Toolkit identity
|
||||||
|
is queried on the application object; the control itself can return no name.
|
||||||
|
|
||||||
|
Exercise the installed Mumble's Settings pages with a silent native adapter:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 tests/native_mumble_settings.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This uses its own display, bus, home, certificate and database, disables update
|
||||||
|
checks and public-server loading, and uses test audio configuration. It selects
|
||||||
|
every settings category and sends Tab and Shift+Tab while checking that the
|
||||||
|
provider continues to answer synchronous geometry requests. It does not connect
|
||||||
|
to a server or change the desktop Mumble instance. The adapter records native
|
||||||
|
focus/caret captures without starting speech or Braille output.
|
||||||
|
It requires Mumble, i3, OpenSSL, PyGObject, Xvfb, xdotool and the native build
|
||||||
|
dependencies. Its i3 instance runs only on the private display. Window searches
|
||||||
|
require both the fixture PID and title with xdotool's `--all` option.
|
||||||
|
|
||||||
|
The installed Mumble 1.5.939 also reproduces a button tab trap with only the
|
||||||
|
silent adapter: Apply goes to Reset, Restore Defaults, Defaults (All), then
|
||||||
|
Apply again, skipping Cancel and OK. Arrow keys follow the same cycle. This
|
||||||
|
is distinct from provider freezing or lost speech. The harness now traces
|
||||||
|
those buttons explicitly, verifies SetFocus on Cancel/OK/Apply through AT-SPI,
|
||||||
|
requires Cthulhu to capture their focus events, and activates the focused OK
|
||||||
|
button with Enter, checking that Settings closes.
|
||||||
|
|
||||||
|
An accessible route around that trap uses object navigation: from Apply,
|
||||||
|
Cthulhu+Alt+Left twice reaches Cancel then OK in the accessibility tree.
|
||||||
|
Cthulhu+Shift+A opens that object's actions; Press activates it, or SetFocus
|
||||||
|
moves keyboard focus before ordinary Enter. The tab trap reproduced without
|
||||||
|
Cthulhu's input handling, so these reader changes do not repair Mumble's
|
||||||
|
native tab order. Test actual button reachability and activation separately
|
||||||
|
from general responsive traversal.
|
||||||
|
|
||||||
Run the generic Qt 5 (PyQt5) and Qt 6 (PySide6) fixture with:
|
Run the generic Qt 5 (PyQt5) and Qt 6 (PySide6) fixture with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@@ -737,6 +737,7 @@ gboolean cthulhu_may_be_background_notification(AtspiAccessible *source) {
|
|||||||
// retaining the source object's provider identity. Nested frames (such as
|
// retaining the source object's provider identity. Nested frames (such as
|
||||||
// Chromium's Find bar) belong to their outer frame too: they have no independent
|
// Chromium's Find bar) belong to their outer frame too: they have no independent
|
||||||
// X11 foreground window or ACTIVE state.
|
// X11 foreground window or ACTIVE state.
|
||||||
|
// A top-level dialog must likewise replace any frame inside its page layout.
|
||||||
AtspiAccessible *cthulhu_window_ancestor(AtspiAccessible *source) {
|
AtspiAccessible *cthulhu_window_ancestor(AtspiAccessible *source) {
|
||||||
if (source == NULL) return NULL;
|
if (source == NULL) return NULL;
|
||||||
AtspiAccessible *current = g_object_ref(source);
|
AtspiAccessible *current = g_object_ref(source);
|
||||||
@@ -754,7 +755,7 @@ AtspiAccessible *cthulhu_window_ancestor(AtspiAccessible *source) {
|
|||||||
g_object_unref(current);
|
g_object_unref(current);
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
if (role == ATSPI_ROLE_FRAME || role == ATSPI_ROLE_WINDOW) {
|
if (role == ATSPI_ROLE_FRAME || role == ATSPI_ROLE_WINDOW || role == ATSPI_ROLE_DIALOG) {
|
||||||
if (window != NULL) g_object_unref(window);
|
if (window != NULL) g_object_unref(window);
|
||||||
window = g_object_ref(current);
|
window = g_object_ref(current);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,46 @@
|
|||||||
|
|
||||||
AtspiTextRange *cthulhu_text_get_string_at_offset(AtspiText *text, gint offset,
|
AtspiTextRange *cthulhu_text_get_string_at_offset(AtspiText *text, gint offset,
|
||||||
AtspiTextGranularity unit, GError **error) {
|
AtspiTextGranularity unit, GError **error) {
|
||||||
|
if (unit == ATSPI_TEXT_GRANULARITY_WORD && offset >= 0) {
|
||||||
|
// Word queries need a character, not the caret position after the
|
||||||
|
// last one. Qt's default textAtOffset can loop forever at that end
|
||||||
|
// position. Match Orca's bounded word lookup before calling a provider.
|
||||||
|
GError *countError = NULL;
|
||||||
|
gint count = atspi_text_get_character_count(text, &countError);
|
||||||
|
if (countError != NULL) {
|
||||||
|
g_propagate_error(error, countError);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (count <= 0) {
|
||||||
|
AtspiTextRange *empty = g_new0(AtspiTextRange, 1);
|
||||||
|
empty->content = g_strdup("");
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
offset = MIN(offset, count - 1);
|
||||||
|
if (offset == 0) {
|
||||||
|
AtspiAccessible *application = atspi_accessible_get_application((AtspiAccessible *)text, NULL);
|
||||||
|
gchar *toolkit = application != NULL ? atspi_accessible_get_toolkit_name(application, NULL) : NULL;
|
||||||
|
if (application != NULL) g_object_unref(application);
|
||||||
|
gboolean qt = toolkit != NULL && g_ascii_strcasecmp(toolkit, "Qt") == 0;
|
||||||
|
g_free(toolkit);
|
||||||
|
if (qt) {
|
||||||
|
GError *probeError = NULL;
|
||||||
|
guint character = atspi_text_get_character_at_offset(text, 0, &probeError);
|
||||||
|
if (probeError != NULL) {
|
||||||
|
g_propagate_error(error, probeError);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
// Qt's default word lookup can also move its boundary finder
|
||||||
|
// before zero for a leading separator/symbol, then loop forever.
|
||||||
|
// Its character lookup is safe and preserves the native grapheme.
|
||||||
|
// Keep native word segmentation for letters/numbers and other
|
||||||
|
// providers; this is independent of the application/control name.
|
||||||
|
if (!g_unichar_isalnum(character)) {
|
||||||
|
return atspi_text_get_string_at_offset(text, offset, ATSPI_TEXT_GRANULARITY_CHAR, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (unit != ATSPI_TEXT_GRANULARITY_LINE || offset < 0) {
|
if (unit != ATSPI_TEXT_GRANULARITY_LINE || offset < 0) {
|
||||||
return atspi_text_get_string_at_offset(text, offset, unit, error);
|
return atspi_text_get_string_at_offset(text, offset, unit, error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Copyright (c) 2026 Storm Dragon
|
||||||
|
// Authors: Storm Dragon, Angus Kola
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package atspi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNativeMumbleSettings(t *testing.T) {
|
||||||
|
if os.Getenv("CTHULHU_NATIVE_MUMBLE_SETTINGS") != "1" {
|
||||||
|
t.Skip("requires disposable Mumble and private X11/AT-SPI session")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 150*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
adapter := New()
|
||||||
|
if err := adapter.Start(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer adapter.Stop(context.Background())
|
||||||
|
finished := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
|
for scanner.Scan() {
|
||||||
|
if scanner.Text() == "finish" {
|
||||||
|
close(finished)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
fmt.Println("MUMBLE_OBSERVER_READY")
|
||||||
|
focusCount, caretCount := 0, 0
|
||||||
|
buttons := map[string]bool{}
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case event := <-adapter.Events():
|
||||||
|
if event.Source.ApplicationProcess != "mumble" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if event.Type == CaretEvent {
|
||||||
|
caretCount++
|
||||||
|
}
|
||||||
|
if event.Type == FocusedStateEvent && event.Detail1 == 1 && !event.ForegroundMismatch {
|
||||||
|
focusCount++
|
||||||
|
if event.Source.Role == "button" {
|
||||||
|
buttons[event.Source.Name] = true
|
||||||
|
}
|
||||||
|
fmt.Printf("MUMBLE_FOCUS %s %q\n", event.Source.Role, event.Source.Name)
|
||||||
|
}
|
||||||
|
case <-finished:
|
||||||
|
if focusCount < 20 || caretCount == 0 {
|
||||||
|
t.Fatalf("insufficient Mumble capture: focus=%d caret=%d", focusCount, caretCount)
|
||||||
|
}
|
||||||
|
if !buttons["OK"] || !buttons["Cancel"] || !buttons["Apply"] {
|
||||||
|
t.Fatalf("dialog button focus missing: OK=%v Cancel=%v Apply=%v", buttons["OK"], buttons["Cancel"], buttons["Apply"])
|
||||||
|
}
|
||||||
|
t.Logf("Mumble focus captures=%d caret captures=%d", focusCount, caretCount)
|
||||||
|
return
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal("Mumble settings traversal did not complete")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
// Copyright (c) 2026 Storm Dragon
|
||||||
|
// Authors: Storm Dragon, Angus Kola
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package atspi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNativeQtNestedFrames(t *testing.T) {
|
||||||
|
if os.Getenv("CTHULHU_NATIVE_QT_FRAMES") == "" {
|
||||||
|
t.Skip("requires private Qt nested-frame fixture")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
adapter := New()
|
||||||
|
if err := adapter.Start(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer adapter.Stop(context.Background())
|
||||||
|
if _, err := adapter.CaptureDesktop(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var window ObjectID
|
||||||
|
for _, step := range []struct{ key, name string }{
|
||||||
|
{"shift+Tab", "User name"}, {"shift+Tab", "Port"},
|
||||||
|
{"shift+Tab", "Device Mono"}, {"shift+Tab", "System Alpha"},
|
||||||
|
{"Tab", "Device Mono"}, {"Tab", "Port"}, {"Tab", "User name"}, {"Tab", "Next"},
|
||||||
|
{"Tab", "System Alpha"}, {"Tab", "Device Mono"},
|
||||||
|
{"Tab", "Port"}, {"Tab", "User name"}, {"Tab", "Next"},
|
||||||
|
} {
|
||||||
|
if output, err := exec.CommandContext(ctx, "xdotool", "key", step.key).CombinedOutput(); err != nil {
|
||||||
|
t.Fatalf("key %s: %v %s", step.key, err, output)
|
||||||
|
}
|
||||||
|
deadline := time.NewTimer(3 * time.Second)
|
||||||
|
var focus Event
|
||||||
|
waiting := true
|
||||||
|
for waiting {
|
||||||
|
select {
|
||||||
|
case event := <-adapter.Events():
|
||||||
|
if event.Type == FocusedStateEvent && event.Detail1 == 1 && event.Source.Name == step.name {
|
||||||
|
focus, waiting = event, false
|
||||||
|
}
|
||||||
|
case <-deadline.C:
|
||||||
|
t.Fatalf("focus on %q missing; filtered=%d", step.name, adapter.backgroundEventsFiltered.Load())
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal(ctx.Err())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deadline.Stop()
|
||||||
|
if focus.ForegroundMismatch || !focus.Window.Valid() {
|
||||||
|
t.Fatalf("focus on %q rejected: window=%+v mismatch=%v", step.name, focus.Window, focus.ForegroundMismatch)
|
||||||
|
}
|
||||||
|
if window.Valid() && focus.Window != window {
|
||||||
|
t.Fatalf("controls have different window owners: %+v and %+v", window, focus.Window)
|
||||||
|
}
|
||||||
|
window = focus.Window
|
||||||
|
}
|
||||||
|
// Ending a populated Qt line edit used to freeze the provider during the
|
||||||
|
// word-at-caret query, making every later Tab stop silent.
|
||||||
|
for _, field := range []struct{ name, word string }{{"User name", "Username"}, {"Port", "64738"}} {
|
||||||
|
if err := exec.CommandContext(ctx, "xdotool", "key", "shift+Tab").Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, key := range []string{"Home", "End", "ctrl+Left", "ctrl+Right"} {
|
||||||
|
if err := exec.CommandContext(ctx, "xdotool", "key", key).Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
wantOffset := 0
|
||||||
|
if key == "End" || key == "ctrl+Right" {
|
||||||
|
wantOffset = len(field.word)
|
||||||
|
}
|
||||||
|
deadline := time.NewTimer(3 * time.Second)
|
||||||
|
waiting := true
|
||||||
|
for waiting {
|
||||||
|
select {
|
||||||
|
case event := <-adapter.Events():
|
||||||
|
if event.Type == CaretEvent && event.Source.Name == field.name && event.Detail1 == wantOffset {
|
||||||
|
if event.Source.CaretWord != field.word || event.ForegroundMismatch || event.Window != window {
|
||||||
|
t.Fatalf("%s in %s: word=%q window=%+v mismatch=%v", key, field.name, event.Source.CaretWord, event.Window, event.ForegroundMismatch)
|
||||||
|
}
|
||||||
|
waiting = false
|
||||||
|
}
|
||||||
|
case <-deadline.C:
|
||||||
|
t.Fatalf("%s caret event missing for %s", key, field.name)
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal(ctx.Err())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deadline.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNativeQtWordPrefixes(t *testing.T) {
|
||||||
|
if os.Getenv("CTHULHU_NATIVE_QT_FRAMES") == "" {
|
||||||
|
t.Skip("requires private Qt nested-frame fixture")
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
adapter := New()
|
||||||
|
if err := adapter.Start(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer adapter.Stop(context.Background())
|
||||||
|
if _, err := adapter.CaptureDesktop(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
wait := func(description string, match func(Event) bool) Event {
|
||||||
|
t.Helper()
|
||||||
|
deadline := time.NewTimer(3 * time.Second)
|
||||||
|
defer deadline.Stop()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case event := <-adapter.Events():
|
||||||
|
if match(event) {
|
||||||
|
return event
|
||||||
|
}
|
||||||
|
case <-deadline.C:
|
||||||
|
t.Fatalf("missing %s", description)
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal(ctx.Err())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The preceding traversal leaves Port focused. Exercise leading symbols,
|
||||||
|
// whitespace-only content, and negative settings without changing windows.
|
||||||
|
for _, value := range []string{"/", " ", " ", " / ", "/path", " Username", "_name", ".", "...", ":", "-1"} {
|
||||||
|
if err := exec.CommandContext(ctx, "xdotool", "key", "ctrl+a", "BackSpace").Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if output, err := exec.CommandContext(ctx, "xdotool", "type", "--clearmodifiers", "--delay", "0", "--", value).CombinedOutput(); err != nil {
|
||||||
|
t.Fatalf("type %q: %v %s", value, err, output)
|
||||||
|
}
|
||||||
|
for _, key := range []string{"Home", "End"} {
|
||||||
|
if err := exec.CommandContext(ctx, "xdotool", "key", key).Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
offset := 0
|
||||||
|
if key == "End" {
|
||||||
|
offset = len(value)
|
||||||
|
}
|
||||||
|
event := wait(key+" in "+value, func(event Event) bool {
|
||||||
|
return event.Type == CaretEvent && event.Source.Name == "Port" &&
|
||||||
|
event.Detail1 == offset && event.Source.TextCaretKnown &&
|
||||||
|
event.Source.BrailleCaret == offset && event.Source.Text == strings.TrimSpace(value)
|
||||||
|
})
|
||||||
|
if event.ForegroundMismatch {
|
||||||
|
t.Fatalf("%s in %q lost foreground ownership", key, value)
|
||||||
|
}
|
||||||
|
if key == "Home" {
|
||||||
|
first, _ := utf8.DecodeRuneInString(value)
|
||||||
|
if want := strings.TrimSpace(string(first)); event.Source.CaretWord != want {
|
||||||
|
t.Fatalf("leading character for %q = %q; want %q", value, event.Source.CaretWord, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := exec.CommandContext(ctx, "xdotool", "key", "Tab").Run(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
wait("Tab after prefix queries", func(event Event) bool {
|
||||||
|
return event.Type == FocusedStateEvent && event.Detail1 == 1 &&
|
||||||
|
event.Source.Name == "User name" && !event.ForegroundMismatch
|
||||||
|
})
|
||||||
|
}
|
||||||
+59
-3
@@ -7,7 +7,17 @@
|
|||||||
|
|
||||||
static const gchar *content;
|
static const gchar *content;
|
||||||
static guint boundaryCalls, characterCalls, textCalls;
|
static guint boundaryCalls, characterCalls, textCalls;
|
||||||
static gboolean failProbe, changedText;
|
static gint boundaryOffset;
|
||||||
|
static AtspiTextGranularity boundaryUnit;
|
||||||
|
static gboolean failProbe, changedText, failCount, qtToolkit;
|
||||||
|
|
||||||
|
AtspiAccessible *atspi_accessible_get_application(AtspiAccessible *source, GError **error) {
|
||||||
|
return (AtspiAccessible *)g_object_new(G_TYPE_OBJECT, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *atspi_accessible_get_toolkit_name(AtspiAccessible *source, GError **error) {
|
||||||
|
return g_strdup(qtToolkit ? "Qt" : "GTK");
|
||||||
|
}
|
||||||
|
|
||||||
guint atspi_text_get_character_at_offset(AtspiText *text, gint offset, GError **error) {
|
guint atspi_text_get_character_at_offset(AtspiText *text, gint offset, GError **error) {
|
||||||
characterCalls++;
|
characterCalls++;
|
||||||
@@ -20,6 +30,10 @@ guint atspi_text_get_character_at_offset(AtspiText *text, gint offset, GError **
|
|||||||
}
|
}
|
||||||
|
|
||||||
gint atspi_text_get_character_count(AtspiText *text, GError **error) {
|
gint atspi_text_get_character_count(AtspiText *text, GError **error) {
|
||||||
|
if (failCount) {
|
||||||
|
g_set_error_literal(error, g_quark_from_static_string("count"), 1, "removed text");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return g_utf8_strlen(content, -1);
|
return g_utf8_strlen(content, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +50,14 @@ gchar *atspi_text_get_text(AtspiText *text, gint start, gint end, GError **error
|
|||||||
AtspiTextRange *atspi_text_get_string_at_offset(AtspiText *text, gint offset,
|
AtspiTextRange *atspi_text_get_string_at_offset(AtspiText *text, gint offset,
|
||||||
AtspiTextGranularity unit, GError **error) {
|
AtspiTextGranularity unit, GError **error) {
|
||||||
boundaryCalls++;
|
boundaryCalls++;
|
||||||
|
boundaryOffset = offset;
|
||||||
|
boundaryUnit = unit;
|
||||||
|
// A word lookup after the last character freezes the verified Qt 5
|
||||||
|
// provider before it can return a range. Empty text has no word to query.
|
||||||
|
if (unit == ATSPI_TEXT_GRANULARITY_WORD && offset >= 0) {
|
||||||
|
g_assert_cmpint(offset, <, g_utf8_strlen(content, -1));
|
||||||
|
if (qtToolkit && offset == 0) g_assert_true(g_unichar_isalnum(g_utf8_get_char(content)));
|
||||||
|
}
|
||||||
// Model the verified browser failure: asking for LINE at the final
|
// Model the verified browser failure: asking for LINE at the final
|
||||||
// ellipsis aborts inside the provider, before it can return a bad range.
|
// ellipsis aborts inside the provider, before it can return a bad range.
|
||||||
if (unit == ATSPI_TEXT_GRANULARITY_LINE && offset >= 0 &&
|
if (unit == ATSPI_TEXT_GRANULARITY_LINE && offset >= 0 &&
|
||||||
@@ -60,8 +82,12 @@ static void assert_range(const gchar *value, gint offset, AtspiTextGranularity u
|
|||||||
g_assert_cmpint(range->end_offset, ==, end);
|
g_assert_cmpint(range->end_offset, ==, end);
|
||||||
g_assert_cmpstr(range->content, ==, expected);
|
g_assert_cmpstr(range->content, ==, expected);
|
||||||
g_assert_cmpuint(boundaryCalls, ==, calls);
|
g_assert_cmpuint(boundaryCalls, ==, calls);
|
||||||
if (unit != ATSPI_TEXT_GRANULARITY_LINE || offset < 0) g_assert_cmpuint(characterCalls, ==, 0);
|
if (unit != ATSPI_TEXT_GRANULARITY_LINE || offset < 0) {
|
||||||
g_assert_cmpuint(textCalls, ==, calls == 0 ? 1 : 0);
|
gboolean wordProbe = qtToolkit && unit == ATSPI_TEXT_GRANULARITY_WORD && offset >= 0 &&
|
||||||
|
*content != '\0' && MIN(offset, g_utf8_strlen(content, -1) - 1) == 0;
|
||||||
|
g_assert_cmpuint(characterCalls, ==, wordProbe ? 1 : 0);
|
||||||
|
}
|
||||||
|
g_assert_cmpuint(textCalls, ==, unit == ATSPI_TEXT_GRANULARITY_LINE && calls == 0 ? 1 : 0);
|
||||||
g_free(range->content);
|
g_free(range->content);
|
||||||
g_free(range);
|
g_free(range);
|
||||||
}
|
}
|
||||||
@@ -74,6 +100,29 @@ int main(void) {
|
|||||||
assert_range("An… inside", 2, ATSPI_TEXT_GRANULARITY_LINE, 0, 10, "An… inside", 1);
|
assert_range("An… inside", 2, ATSPI_TEXT_GRANULARITY_LINE, 0, 10, "An… inside", 1);
|
||||||
assert_range("Text…", 4, ATSPI_TEXT_GRANULARITY_CHAR, 0, 5, "Text…", 1);
|
assert_range("Text…", 4, ATSPI_TEXT_GRANULARITY_CHAR, 0, 5, "Text…", 1);
|
||||||
assert_range("Text…", 4, ATSPI_TEXT_GRANULARITY_WORD, 0, 5, "Text…", 1);
|
assert_range("Text…", 4, ATSPI_TEXT_GRANULARITY_WORD, 0, 5, "Text…", 1);
|
||||||
|
g_assert_cmpint(boundaryOffset, ==, 4);
|
||||||
|
assert_range("64738", 5, ATSPI_TEXT_GRANULARITY_WORD, 0, 5, "64738", 1);
|
||||||
|
g_assert_cmpint(boundaryOffset, ==, 4);
|
||||||
|
assert_range("Username", 100, ATSPI_TEXT_GRANULARITY_WORD, 0, 8, "Username", 1);
|
||||||
|
g_assert_cmpint(boundaryOffset, ==, 7);
|
||||||
|
assert_range("猫🐈", 2, ATSPI_TEXT_GRANULARITY_WORD, 0, 2, "猫🐈", 1);
|
||||||
|
g_assert_cmpint(boundaryOffset, ==, 1);
|
||||||
|
assert_range("", 0, ATSPI_TEXT_GRANULARITY_WORD, 0, 0, "", 0);
|
||||||
|
// Other providers keep their own punctuation/whitespace segmentation.
|
||||||
|
assert_range("/", 0, ATSPI_TEXT_GRANULARITY_WORD, 0, 1, "/", 1);
|
||||||
|
g_assert_cmpint(boundaryUnit, ==, ATSPI_TEXT_GRANULARITY_WORD);
|
||||||
|
qtToolkit = TRUE;
|
||||||
|
const gchar *prefixes[] = {"/", " ", " ", " / ", " Username", "/path", "_name", "-1", "🐈"};
|
||||||
|
for (guint index = 0; index < G_N_ELEMENTS(prefixes); index++) {
|
||||||
|
const gchar *value = prefixes[index];
|
||||||
|
assert_range(value, 0, ATSPI_TEXT_GRANULARITY_WORD, 0, g_utf8_strlen(value, -1), value, 1);
|
||||||
|
g_assert_cmpint(boundaryUnit, ==, ATSPI_TEXT_GRANULARITY_CHAR);
|
||||||
|
}
|
||||||
|
assert_range("/", 1, ATSPI_TEXT_GRANULARITY_WORD, 0, 1, "/", 1);
|
||||||
|
g_assert_cmpint(boundaryUnit, ==, ATSPI_TEXT_GRANULARITY_CHAR);
|
||||||
|
assert_range("Username", 0, ATSPI_TEXT_GRANULARITY_WORD, 0, 8, "Username", 1);
|
||||||
|
g_assert_cmpint(boundaryUnit, ==, ATSPI_TEXT_GRANULARITY_WORD);
|
||||||
|
qtToolkit = FALSE;
|
||||||
assert_range("Text…", -1, ATSPI_TEXT_GRANULARITY_LINE, 0, 5, "Text…", 1);
|
assert_range("Text…", -1, ATSPI_TEXT_GRANULARITY_LINE, 0, 5, "Text…", 1);
|
||||||
gchar *prefix = g_strnfill(5000, 'x');
|
gchar *prefix = g_strnfill(5000, 'x');
|
||||||
gchar *longText = g_strconcat(prefix, "…", NULL);
|
gchar *longText = g_strconcat(prefix, "…", NULL);
|
||||||
@@ -94,5 +143,12 @@ int main(void) {
|
|||||||
g_assert_nonnull(error);
|
g_assert_nonnull(error);
|
||||||
g_assert_cmpuint(boundaryCalls, ==, 0);
|
g_assert_cmpuint(boundaryCalls, ==, 0);
|
||||||
g_clear_error(&error);
|
g_clear_error(&error);
|
||||||
|
failProbe = FALSE;
|
||||||
|
failCount = TRUE;
|
||||||
|
boundaryCalls = 0;
|
||||||
|
g_assert_null(cthulhu_text_get_string_at_offset(NULL, 8, ATSPI_TEXT_GRANULARITY_WORD, &error));
|
||||||
|
g_assert_nonnull(error);
|
||||||
|
g_assert_cmpuint(boundaryCalls, ==, 0);
|
||||||
|
g_clear_error(&error);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTextBoundaryAvoidsProviderEllipsisAbort(t *testing.T) {
|
func TestTextBoundaryAvoidsProviderEllipsisAbort(t *testing.T) {
|
||||||
flags, err := exec.Command("pkg-config", "--cflags", "--libs", "atspi-2").CombinedOutput()
|
flags, err := exec.Command("pkg-config", "--cflags", "--libs", "atspi-2", "gobject-2.0").CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("native text dependencies: %v: %s", err, flags)
|
t.Fatalf("native text dependencies: %v: %s", err, flags)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,264 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright (c) 2026 Storm Dragon
|
||||||
|
# Authors: Storm Dragon, Angus Kola
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
"""Traverse the installed Mumble's settings with a silent native reader adapter."""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
sys.dont_write_bytecode = True
|
||||||
|
from native_test_session import run_private_session
|
||||||
|
from native_x11 import set_active_window, wait_for
|
||||||
|
|
||||||
|
|
||||||
|
def run_inside():
|
||||||
|
import gi
|
||||||
|
gi.require_version('Atspi', '2.0')
|
||||||
|
from gi.repository import Atspi
|
||||||
|
|
||||||
|
Atspi.set_timeout(1200, 1200)
|
||||||
|
root = Path(__file__).resolve().parents[1]
|
||||||
|
observer = subprocess.Popen(
|
||||||
|
[os.environ['CTHULHU_MUMBLE_TEST_BINARY'], '-test.run=^TestNativeMumbleSettings$',
|
||||||
|
'-test.v', '-test.timeout=160s'], cwd=root, stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
|
||||||
|
env=dict(os.environ, CTHULHU_NATIVE_MUMBLE_SETTINGS='1'))
|
||||||
|
mumble = None
|
||||||
|
windowManager = None
|
||||||
|
logPath = None
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
line = observer.stdout.readline()
|
||||||
|
print(line, end='', flush=True)
|
||||||
|
if line.startswith('MUMBLE_OBSERVER_READY'):
|
||||||
|
break
|
||||||
|
if not line:
|
||||||
|
raise RuntimeError('native observer exited before readiness')
|
||||||
|
|
||||||
|
def drain():
|
||||||
|
for line in observer.stdout:
|
||||||
|
if not line.startswith('MUMBLE_FOCUS'):
|
||||||
|
print(line, end='', flush=True)
|
||||||
|
|
||||||
|
outputThread = threading.Thread(target=drain, daemon=True)
|
||||||
|
outputThread.start()
|
||||||
|
home = Path(os.environ['HOME'])
|
||||||
|
wmConfig = home / 'i3.conf'
|
||||||
|
wmConfig.write_text('font pango:monospace 10\nfocus_follows_mouse no\nipc-socket '
|
||||||
|
+ str(home / 'i3.sock') + '\n')
|
||||||
|
windowManager = subprocess.Popen(['i3', '-c', str(wmConfig), '-a'],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
keyPath = home / 'test-key.pem'
|
||||||
|
certPath = home / 'test-cert.pem'
|
||||||
|
certificatePath = home / 'MumbleAutomaticCertificateBackup.p12'
|
||||||
|
subprocess.run(
|
||||||
|
['openssl', 'req', '-x509', '-newkey', 'rsa:2048', '-nodes',
|
||||||
|
'-keyout', str(keyPath), '-out', str(certPath), '-days', '365',
|
||||||
|
'-subj', '/CN=Username'], check=True,
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
subprocess.run(
|
||||||
|
['openssl', 'pkcs12', '-export', '-out', str(certificatePath),
|
||||||
|
'-inkey', str(keyPath), '-in', str(certPath), '-passout', 'pass:'],
|
||||||
|
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
config = home / 'mumble-test.json'
|
||||||
|
config.write_text(json.dumps({
|
||||||
|
'settings_version': 1, 'mumble_has_quit_normally': True,
|
||||||
|
'misc': {'audio_wizard_has_been_shown': True,
|
||||||
|
'viewed_server_ping_consent_message': True,
|
||||||
|
'database_location': str(home)},
|
||||||
|
'audio': {'input_system': 'Disabled test backend',
|
||||||
|
'output_system': 'Disabled test backend', 'mute': True, 'deaf': True},
|
||||||
|
'ui': {'disable_public_server_list': True, 'send_usage_statistics': False},
|
||||||
|
'tts': {'enable': False},
|
||||||
|
'update': {'check_for_updates': False, 'check_for_plugin_updates': False},
|
||||||
|
}))
|
||||||
|
alsa = home / 'alsa.conf'
|
||||||
|
alsa.write_text('pcm.!default { type null }\n')
|
||||||
|
with tempfile.NamedTemporaryFile(prefix='cthulhu-mumble-fixture-', suffix='.log', delete=False) as log:
|
||||||
|
logPath = Path(log.name)
|
||||||
|
print('Mumble fixture diagnostics:', log.name, flush=True)
|
||||||
|
mumble = subprocess.Popen(
|
||||||
|
['mumble', '--multiple', '--noidentity', '--config', str(config),
|
||||||
|
'--default-certificate-dir', str(home)],
|
||||||
|
stdout=log, stderr=log,
|
||||||
|
env=dict(os.environ, ALSA_CONFIG_PATH=str(alsa), JACK_NO_START_SERVER='1',
|
||||||
|
PULSE_SERVER='unix:/nonexistent', PIPEWIRE_REMOTE='nonexistent'))
|
||||||
|
|
||||||
|
def application():
|
||||||
|
desktop = Atspi.get_desktop(0)
|
||||||
|
for index in range(desktop.get_child_count()):
|
||||||
|
app = desktop.get_child_at_index(index)
|
||||||
|
if app.get_process_id() == mumble.pid:
|
||||||
|
return app
|
||||||
|
|
||||||
|
app = wait_for(application, 'Mumble did not register accessibility')
|
||||||
|
|
||||||
|
def activate(title):
|
||||||
|
result = subprocess.check_output(
|
||||||
|
['xdotool', 'search', '--all', '--onlyvisible', '--pid', str(mumble.pid),
|
||||||
|
'--name', '^' + re.escape(title) + '$'], text=True)
|
||||||
|
windowId = result.strip().splitlines()[0]
|
||||||
|
subprocess.run(['xdotool', 'windowactivate', '--sync', windowId], check=True)
|
||||||
|
set_active_window(int(windowId))
|
||||||
|
|
||||||
|
def visible(title):
|
||||||
|
return subprocess.run(
|
||||||
|
['xdotool', 'search', '--all', '--onlyvisible', '--pid', str(mumble.pid),
|
||||||
|
'--name', '^' + re.escape(title) + '$'],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
|
||||||
|
|
||||||
|
def windows():
|
||||||
|
if mumble.poll() is not None:
|
||||||
|
raise RuntimeError('Mumble exited: ' + logPath.read_text()[-3000:])
|
||||||
|
app.clear_cache()
|
||||||
|
return [app.get_child_at_index(index) for index in range(app.get_child_count())]
|
||||||
|
|
||||||
|
def descendants(node, depth=0):
|
||||||
|
if depth > 12:
|
||||||
|
return
|
||||||
|
yield node
|
||||||
|
for index in range(min(node.get_child_count(), 300)):
|
||||||
|
yield from descendants(node.get_child_at_index(index), depth + 1)
|
||||||
|
|
||||||
|
# The generated test identity skips the certificate wizard. Dismiss the
|
||||||
|
# initial Connect dialog without touching any real profiles or servers.
|
||||||
|
main = None
|
||||||
|
stableMainSince = None
|
||||||
|
deadline = time.monotonic() + 15
|
||||||
|
while time.monotonic() < deadline:
|
||||||
|
if visible('Mumble Server Connect'):
|
||||||
|
stableMainSince = None
|
||||||
|
activate('Mumble Server Connect')
|
||||||
|
subprocess.run(['xdotool', 'key', 'Escape'], check=True)
|
||||||
|
elif visible('Mumble'):
|
||||||
|
if stableMainSince is None:
|
||||||
|
stableMainSince = time.monotonic()
|
||||||
|
elif time.monotonic() - stableMainSince > .4:
|
||||||
|
main = next((node for node in windows() if node.get_name() == 'Mumble'), None)
|
||||||
|
break
|
||||||
|
time.sleep(.1)
|
||||||
|
if main is None:
|
||||||
|
raise RuntimeError('Mumble startup dialogs did not close: ' + repr(
|
||||||
|
[(node.get_name(), node.get_role_name()) for node in windows()]))
|
||||||
|
|
||||||
|
activate('Mumble')
|
||||||
|
settings = next(node for node in descendants(main)
|
||||||
|
if node.get_name() == 'Settings' and node.get_role_name() == 'button')
|
||||||
|
# Qt's synchronous DoAction reply can wait for its modal dialog to close.
|
||||||
|
# Click the identified toolbar button on this private display instead.
|
||||||
|
bounds = settings.get_component_iface().get_extents(Atspi.CoordType.SCREEN)
|
||||||
|
subprocess.run(['xdotool', 'mousemove', '--sync', str(bounds.x + bounds.width // 2),
|
||||||
|
str(bounds.y + bounds.height // 2), 'click', '1'], check=True)
|
||||||
|
|
||||||
|
def configuration():
|
||||||
|
if not visible('Mumble Configuration'):
|
||||||
|
return None
|
||||||
|
return next((node for node in windows()
|
||||||
|
if node.get_name() == 'Mumble Configuration'), None)
|
||||||
|
|
||||||
|
dialog = wait_for(configuration, 'Mumble Configuration missing')
|
||||||
|
activate('Mumble Configuration')
|
||||||
|
buttons = [node for node in descendants(dialog)
|
||||||
|
if node.get_role_name() == 'button'
|
||||||
|
and node.get_name() in ('Apply', 'Cancel', 'OK', 'Reset', 'Restore Defaults', 'Defaults (All)')]
|
||||||
|
applyButton = next(node for node in buttons if node.get_name() == 'Apply')
|
||||||
|
|
||||||
|
def focused_button():
|
||||||
|
for button in buttons:
|
||||||
|
button.clear_cache()
|
||||||
|
if button.get_state_set().contains(Atspi.StateType.FOCUSED):
|
||||||
|
return button.get_name()
|
||||||
|
return 'other control'
|
||||||
|
|
||||||
|
for key in ('Tab', 'shift+Tab', 'Left', 'Right'):
|
||||||
|
bounds = applyButton.get_component_iface().get_extents(Atspi.CoordType.SCREEN)
|
||||||
|
subprocess.run(['xdotool', 'mousemove', '--sync', str(bounds.x + bounds.width // 2),
|
||||||
|
str(bounds.y + bounds.height // 2), 'click', '1'], check=True)
|
||||||
|
sequence = [focused_button()]
|
||||||
|
for _ in range(4):
|
||||||
|
subprocess.run(['xdotool', 'key', key], check=True)
|
||||||
|
sequence.append(focused_button())
|
||||||
|
print('Dialog button traversal', key, sequence, flush=True)
|
||||||
|
|
||||||
|
def focus_button(name):
|
||||||
|
button = next(node for node in buttons if node.get_name() == name)
|
||||||
|
action = button.get_action_iface()
|
||||||
|
index = next(index for index in range(Atspi.Action.get_n_actions(action))
|
||||||
|
if Atspi.Action.get_action_name(action, index) == 'SetFocus')
|
||||||
|
if not Atspi.Action.do_action(action, index):
|
||||||
|
raise RuntimeError('Cannot focus ' + name + ' through its accessible action')
|
||||||
|
wait_for(lambda: focused_button() == name, 'Accessible focus missing for ' + name)
|
||||||
|
print('Accessible SetFocus passed:', name, flush=True)
|
||||||
|
|
||||||
|
focus_button('Cancel')
|
||||||
|
focus_button('OK')
|
||||||
|
focus_button('Apply')
|
||||||
|
categoryList = next(node for node in descendants(dialog)
|
||||||
|
if node.get_role_name() == 'list' and node.get_child_count() >= 8)
|
||||||
|
categories = [categoryList.get_child_at_index(index).get_name()
|
||||||
|
for index in range(categoryList.get_child_count())]
|
||||||
|
print('Mumble settings categories:', categories, flush=True)
|
||||||
|
for index, name in enumerate(categories):
|
||||||
|
first = categoryList.get_child_at_index(0)
|
||||||
|
bounds = first.get_component_iface().get_extents(Atspi.CoordType.SCREEN)
|
||||||
|
subprocess.run(['xdotool', 'mousemove', '--sync', str(bounds.x + bounds.width // 2),
|
||||||
|
str(bounds.y + bounds.height // 2), 'click', '1'], check=True)
|
||||||
|
subprocess.run(['xdotool', 'key', 'Home', *(['Down'] * index)], check=True)
|
||||||
|
|
||||||
|
def selected_category():
|
||||||
|
item = categoryList.get_child_at_index(index)
|
||||||
|
item.clear_cache()
|
||||||
|
return item.get_state_set().contains(Atspi.StateType.SELECTED)
|
||||||
|
|
||||||
|
wait_for(selected_category, 'Cannot select settings category ' + name)
|
||||||
|
for key in ('Tab', 'shift+Tab'):
|
||||||
|
for _ in range(16):
|
||||||
|
subprocess.run(['xdotool', 'key', key], check=True)
|
||||||
|
# Component geometry is an uncached synchronous provider call.
|
||||||
|
# It must keep answering while Cthulhu captures the same events.
|
||||||
|
dialog.get_component_iface().get_extents(Atspi.CoordType.SCREEN)
|
||||||
|
time.sleep(.03)
|
||||||
|
print('Settings traversal passed:', name, flush=True)
|
||||||
|
focus_button('OK')
|
||||||
|
subprocess.run(['xdotool', 'key', 'Return'], check=True)
|
||||||
|
wait_for(lambda: not visible('Mumble Configuration'), 'OK did not close settings')
|
||||||
|
print('OK keyboard activation closed Settings', flush=True)
|
||||||
|
main.get_component_iface().get_extents(Atspi.CoordType.SCREEN)
|
||||||
|
observer.stdin.write('finish\n')
|
||||||
|
observer.stdin.flush()
|
||||||
|
if observer.wait(timeout=10):
|
||||||
|
raise RuntimeError('native Mumble capture checks failed')
|
||||||
|
outputThread.join(timeout=2)
|
||||||
|
finally:
|
||||||
|
if sys.exc_info()[0] is not None and logPath:
|
||||||
|
print(logPath.read_text()[-3000:], flush=True)
|
||||||
|
for process in (mumble, observer, windowManager):
|
||||||
|
if process and process.poll() is None:
|
||||||
|
process.kill()
|
||||||
|
process.wait(timeout=5)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if '--inside' in sys.argv:
|
||||||
|
run_inside()
|
||||||
|
else:
|
||||||
|
root = Path(__file__).resolve().parents[1]
|
||||||
|
with tempfile.TemporaryDirectory(prefix='cthulhu-mumble-settings-') as temporary:
|
||||||
|
testBinary = str(Path(temporary) / 'atspi.test')
|
||||||
|
subprocess.run(['go', 'test', '-c', '-o', testBinary, './internal/atspi'],
|
||||||
|
cwd=root, check=True, env=dict(os.environ, GOCACHE='/tmp/cthulhu-cache'))
|
||||||
|
environment = dict(
|
||||||
|
os.environ, HOME=temporary, XDG_CONFIG_HOME=temporary,
|
||||||
|
XDG_CACHE_HOME=temporary, XDG_DATA_HOME=temporary,
|
||||||
|
CTHULHU_MUMBLE_TEST_BINARY=testBinary, QT_QPA_PLATFORM='xcb',
|
||||||
|
QT_LINUX_ACCESSIBILITY_ALWAYS_ON='1', NO_AT_BRIDGE='0')
|
||||||
|
run_private_session(
|
||||||
|
['xvfb-run', '-a', '-s', '-screen 0 1280x1024x24', 'dbus-run-session', '--',
|
||||||
|
sys.executable, __file__, '--inside'], env=environment, check=True)
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright (c) 2026 Storm Dragon
|
||||||
|
# Authors: Storm Dragon, Angus Kola
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
"""Check nested Qt frames inside top-level windows and wizard dialogs."""
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import site
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
sys.dont_write_bytecode = True
|
||||||
|
from native_test_session import run_private_session
|
||||||
|
from native_x11 import set_active_window, wait_for
|
||||||
|
|
||||||
|
|
||||||
|
def fixture(version, windowType):
|
||||||
|
if version == '5':
|
||||||
|
from PyQt5 import QtWidgets
|
||||||
|
else:
|
||||||
|
from PySide6 import QtWidgets
|
||||||
|
|
||||||
|
application = QtWidgets.QApplication([])
|
||||||
|
window = QtWidgets.QDialog() if windowType == 'dialog' else QtWidgets.QMainWindow()
|
||||||
|
window.setWindowTitle('Qt nested frames probe')
|
||||||
|
content = window
|
||||||
|
if windowType != 'dialog':
|
||||||
|
content = QtWidgets.QWidget()
|
||||||
|
window.setCentralWidget(content)
|
||||||
|
layout = QtWidgets.QVBoxLayout(content)
|
||||||
|
# QWizard's page container exposes FRAME below the top-level DIALOG.
|
||||||
|
page = QtWidgets.QFrame()
|
||||||
|
pageLayout = QtWidgets.QVBoxLayout(page)
|
||||||
|
system = QtWidgets.QComboBox()
|
||||||
|
system.addItems(['System Alpha', 'System Beta'])
|
||||||
|
pageLayout.addWidget(system)
|
||||||
|
device = QtWidgets.QComboBox()
|
||||||
|
device.addItems(['Device Mono', 'Device Stereo'])
|
||||||
|
pageLayout.addWidget(device)
|
||||||
|
port = QtWidgets.QLineEdit('64738')
|
||||||
|
port.setAccessibleName('Port')
|
||||||
|
pageLayout.addWidget(port)
|
||||||
|
username = QtWidgets.QLineEdit('Username')
|
||||||
|
username.setAccessibleName('User name')
|
||||||
|
pageLayout.addWidget(username)
|
||||||
|
layout.addWidget(page)
|
||||||
|
button = QtWidgets.QPushButton('Next')
|
||||||
|
button.setAutoDefault(False)
|
||||||
|
layout.addWidget(button)
|
||||||
|
window.resize(400, 250)
|
||||||
|
window.show()
|
||||||
|
button.setFocus()
|
||||||
|
application.exec()
|
||||||
|
|
||||||
|
|
||||||
|
def run_inside():
|
||||||
|
root = Path(__file__).resolve().parents[1]
|
||||||
|
for version in ('5', '6'):
|
||||||
|
for windowType in ('dialog', 'window'):
|
||||||
|
print(f'Qt {version}: nested frame in {windowType}', flush=True)
|
||||||
|
process = subprocess.Popen(
|
||||||
|
[sys.executable, __file__, '--fixture', version, windowType])
|
||||||
|
try:
|
||||||
|
def find_window():
|
||||||
|
result = subprocess.run(
|
||||||
|
['xdotool', 'search', '--onlyvisible', '--name',
|
||||||
|
'^Qt nested frames probe$'], capture_output=True, text=True)
|
||||||
|
return result.stdout.strip().splitlines()[0] if result.stdout.strip() else None
|
||||||
|
|
||||||
|
windowId = wait_for(find_window, 'Qt nested-frame fixture missing')
|
||||||
|
subprocess.run(['xdotool', 'windowfocus', '--sync', windowId], check=True)
|
||||||
|
set_active_window(int(windowId))
|
||||||
|
subprocess.run(
|
||||||
|
[os.environ['CTHULHU_QT_FRAMES_TEST_BINARY'],
|
||||||
|
'-test.run=^TestNativeQt(NestedFrames|WordPrefixes)$', '-test.count=1',
|
||||||
|
'-test.v', '-test.timeout=30s'], cwd=root, check=True, timeout=45,
|
||||||
|
env=dict(os.environ, CTHULHU_NATIVE_QT_FRAMES=windowType))
|
||||||
|
finally:
|
||||||
|
process.terminate()
|
||||||
|
process.wait(timeout=5)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if '--fixture' in sys.argv:
|
||||||
|
fixture(*sys.argv[-2:])
|
||||||
|
elif '--inside' in sys.argv:
|
||||||
|
run_inside()
|
||||||
|
else:
|
||||||
|
with tempfile.TemporaryDirectory(prefix='cthulhu-qt-frames-') as temporary:
|
||||||
|
root = Path(__file__).resolve().parents[1]
|
||||||
|
testBinary = str(Path(temporary) / 'atspi.test')
|
||||||
|
subprocess.run(
|
||||||
|
['go', 'test', '-c', '-o', testBinary, './internal/atspi'],
|
||||||
|
cwd=root, check=True, env=dict(os.environ, GOCACHE='/tmp/cthulhu-cache'))
|
||||||
|
environment = dict(
|
||||||
|
os.environ, HOME=temporary, XDG_CONFIG_HOME=temporary,
|
||||||
|
XDG_CACHE_HOME=temporary, XDG_DATA_HOME=temporary,
|
||||||
|
PYTHONPATH=site.getusersitepackages(), QT_QPA_PLATFORM='xcb',
|
||||||
|
CTHULHU_QT_FRAMES_TEST_BINARY=testBinary,
|
||||||
|
QT_LINUX_ACCESSIBILITY_ALWAYS_ON='1', NO_AT_BRIDGE='0',
|
||||||
|
GOMODCACHE=subprocess.check_output(['go', 'env', 'GOMODCACHE'], text=True).strip())
|
||||||
|
run_private_session(
|
||||||
|
['xvfb-run', '-a', '-s', '-screen 0 1024x768x24', 'dbus-run-session',
|
||||||
|
'--', sys.executable, __file__, '--inside'], env=environment, check=True)
|
||||||
Reference in new issue
Block a user