Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/skills/test-authoring/gnome/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ notification is gone, not that no banner shows: Shell holds earlier banners on
screen while the session is idle, as a headless VM always is. Calculator and
Text Editor divergences on plain GNOME OS 51:
[`references/gnome-51-app-divergences.md`](references/gnome-51-app-divergences.md).
The Files steps for rows 4-6 print `gnome-51-audit row N: <reading>` (the branch that matched) in each smoke log; keep it when editing them.

## Remote session commands from the runner container

Expand Down
27 changes: 22 additions & 5 deletions tests/smoke/features/steps/gnome_files_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,29 @@ def _skip_if_no_atspi(context) -> bool:
}


_AUDIT_READINGS: set = set()


def _audit_reading(row: int, reading: str) -> None:
"""Print a GNOME 51 audit reading once per run; it records which branch matched."""
line = f"gnome-51-audit row {row}: {reading}"
if line not in _AUDIT_READINGS:
_AUDIT_READINGS.add(line)
print(line, flush=True)


def _app_name(app) -> str:
name = getattr(app, "name", None) or (app.get_name() if hasattr(app, "get_name") else None)
return name.strip("'\" ") if isinstance(name, str) else ""


def _files_apps() -> list:
"""Take one ``applications()`` snapshot; dogtail's per-name lookup retries internally."""
matches = []
for app in tree.root.applications():
name = getattr(app, "name", None) or (app.get_name() if hasattr(app, "get_name") else None)
if isinstance(name, str):
clean = name.strip("'\" ")
if clean in FILES_APP_NAMES or "nautilus" in clean.lower():
matches.append(app)
clean = _app_name(app)
if clean in FILES_APP_NAMES or "nautilus" in clean.lower():
matches.append(app)
return matches


Expand All @@ -64,6 +78,7 @@ def _nautilus_app(timeout: int = 15):
while True:
try:
for app in _files_apps():
_audit_reading(6, f"Files AT-SPI app name={_app_name(app)!r}")
return app
last_error = f"none of {FILES_APP_NAMES} registered"
except Exception as exc: # noqa: BLE001
Expand Down Expand Up @@ -96,6 +111,7 @@ def _is_frame(n):
for _ in range(timeout * 2):
frames = app.findChildren(_is_frame)
if frames:
_audit_reading(4, f"Files toplevel role={getattr(frames[0], 'roleName', '')!r}")
return frames[0]
last_children = [(getattr(child, "roleName", getattr(child, "get_role_name", lambda: "")()), getattr(child, "name", getattr(child, "get_name", lambda: "")())) for child in getattr(app, "children", [])[:10]]
sleep(0.5)
Expand Down Expand Up @@ -174,6 +190,7 @@ def home_folder_is_in_the_sidebar(context) -> None:
)

assert home_items, "Home list item not found in Nautilus sidebar"
_audit_reading(5, f"Files sidebar Home item roles={sorted({n.roleName for n in home_items})}")


@step('Navigate to "{name}" in Files sidebar')
Expand Down
44 changes: 44 additions & 0 deletions tests/unit/test_gnome_files_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,47 @@ def find(pred):
patch("subprocess.run"):
with pytest.raises(AssertionError, match="GNOME Files is still visible"):
self.m.files_is_no_longer_running(MagicMock())


# ---------------------------------------------------------------------------
# GNOME 51 audit readings (rows 4, 5 and 6 of references/gnome-51-audit.md)
# ---------------------------------------------------------------------------

class TestGnome51AuditReadings:
def setup_method(self):
self.m = _import_files_steps()

def _window_app(self, role):
frame = MagicMock()
frame.roleName = role
frame.name = "Files"
frame.showing = True
app = MagicMock()
app.findChildren.return_value = [frame]
return app

def test_window_reports_toplevel_role(self, capsys):
with patch.object(self.m, "tree", _files_tree(self._window_app("filler"))):
self.m._nautilus_window(timeout=1)
assert "gnome-51-audit row 4: Files toplevel role='filler'" in capsys.readouterr().out

def test_reading_is_printed_once_per_run(self, capsys):
with patch.object(self.m, "tree", _files_tree(self._window_app("frame"))):
self.m._nautilus_window(timeout=1)
self.m._nautilus_window(timeout=1)
assert capsys.readouterr().out.count("gnome-51-audit row 4:") == 1

def test_app_reports_matched_name(self, capsys):
files = MagicMock()
files.name = "Files"
tree_mock = MagicMock()
tree_mock.root.applications.return_value = [files]
with patch.object(self.m, "tree", tree_mock):
self.m._nautilus_app(timeout=1)
assert "gnome-51-audit row 6: Files AT-SPI app name='Files'" in capsys.readouterr().out

def test_sidebar_reports_home_item_role(self, capsys):
window = TestHomeFolderIsInTheSidebar()._make_window_with_sidebar(item_role="button")
with patch.object(self.m, "_nautilus_window", return_value=window):
self.m.home_folder_is_in_the_sidebar(MagicMock())
assert "gnome-51-audit row 5: Files sidebar Home item roles=['button']" in capsys.readouterr().out
Loading