test: poll_running_apps parsing against SYNTHETIC activity-recents fixture (A= and I= patterns; real R6 capture still outstanding)
This commit is contained in:
1 parent
a1e671ac6a
commit
a72cf57494
2 files changed
+75
No files matched your search
@@ -143,3 +143,66 @@ class TestPollMediaSessionsTruncation:
|
||||
client = _client_response(CMD_MEDIA_DEFAULT, Exception("dead"))
|
||||
assert await client.poll_media_sessions() is None
|
||||
assert client.last_info is None
|
||||
|
||||
|
||||
class TestPollRunningApps:
|
||||
"""Recent-task parsing against the SYNTHETIC recents fixture.
|
||||
|
||||
The real Shield `dumpsys activity recents` capture (R6) is still
|
||||
outstanding; tests/fixtures/activity_recents_synthetic.txt pins the
|
||||
parsing contract in the meantime.
|
||||
"""
|
||||
|
||||
async def test_parses_visible_user_apps_in_recency_order(self):
|
||||
recents = (FIXTURES / "activity_recents_synthetic.txt").read_text()
|
||||
client = _client_response(
|
||||
"dumpsys activity recents 2>/dev/null "
|
||||
"| grep -E 'Recent #|realActivity|visible='",
|
||||
recents,
|
||||
)
|
||||
apps = await client.poll_running_apps()
|
||||
assert [a["package"] for a in apps] == [
|
||||
"ar.tvplayer.tv",
|
||||
"com.example.launcherapp",
|
||||
]
|
||||
|
||||
async def test_i_pattern_fallback_used_without_a_uid_assignment(self):
|
||||
"""`I=com.example.launcherapp/.ui.HomeActivity` is the only package
|
||||
fragment on its line and must be picked up by the fallback regex."""
|
||||
recents = (FIXTURES / "activity_recents_synthetic.txt").read_text()
|
||||
client = _client_response(
|
||||
"dumpsys activity recents 2>/dev/null "
|
||||
"| grep -E 'Recent #|realActivity|visible='",
|
||||
recents,
|
||||
)
|
||||
apps = await client.poll_running_apps()
|
||||
assert "com.example.launcherapp" in {a["package"] for a in apps}
|
||||
|
||||
async def test_skips_invisible_tasks_system_packages_and_dot_names(self):
|
||||
recents = (FIXTURES / "activity_recents_synthetic.txt").read_text()
|
||||
client = _client_response(
|
||||
"dumpsys activity recents 2>/dev/null "
|
||||
"| grep -E 'Recent #|realActivity|visible='",
|
||||
recents,
|
||||
)
|
||||
apps = await client.poll_running_apps()
|
||||
packages = {a["package"] for a in apps}
|
||||
assert "com.github.damontecres.wholphin" not in packages # visible=false
|
||||
assert "com.android.systemui" not in packages # excluded system UI
|
||||
assert ".HiddenInternalTask" not in packages # dot-named internals
|
||||
|
||||
async def test_empty_result_returns_empty_list(self):
|
||||
client = _client_response(
|
||||
"dumpsys activity recents 2>/dev/null "
|
||||
"| grep -E 'Recent #|realActivity|visible='",
|
||||
None,
|
||||
)
|
||||
assert await client.poll_running_apps() == []
|
||||
|
||||
async def test_failed_shell_returns_empty_list(self):
|
||||
client = _client_response(
|
||||
"dumpsys activity recents 2>/dev/null "
|
||||
"| grep -E 'Recent #|realActivity|visible='",
|
||||
Exception("offline"),
|
||||
)
|
||||
assert await client.poll_running_apps() == []
|
||||
Reference in new issue
Block a user