test(media_session,connection): logcat START parsing (cmp=, wrapped records, null/non-START ignored, u-prefixes), instant stamp + notify, duplicate START suppression, 5-in-10-min auto-disable, OFF = no stream task, stream never touches the poller socket (P5-3)

This commit is contained in:
James Mackay committed 2026-10-09 06:06:10 +01:00
1 parent 07cb73fbb7
commit f863496ce5
2 files changed
+146

No files matched your search

+43
View File
@@ -209,3 +209,46 @@ def test_parse_application_label_tolerance():
assert parse_application_label("application-label: null") is None
assert parse_application_label("") is None
assert parse_application_label("nothing here") is None
def _logcat_lines():
"""Synthetic logcat list covering START shapes + noise + wrapping."""
return [
"03-21 10:19:40.100 3104 3456 I NotificationService: noise",
"03-21 10:19:41.792 3104 3456 I ActivityTaskManager: START u0 "
"{cmp=com.netflix.ninja/com.netflix.ui.main flg=0x10000000}",
"03-21 10:19:45.100 3104 3456 I ActivityTaskManager: START u0 {cmp=null}",
"03-21 10:19:47.000 3104 3456 I ActivityTaskManager: START u10 "
"{cmp=ar.tvplayer.tv/.ui.MainActivity",
" xflg=214 abi=arm64-v8a}",
"03-21 10:19:50.000 3104 3456 I ActivityTaskManager: Displayed",
]
def test_logcat_start_records_parse_cmp():
from nsh.ha_adb_common.logcat_events import foreground_from_logcat, foreground_packages
lines = _logcat_lines()
assert foreground_packages(lines) == ["com.netflix.ninja", "ar.tvplayer.tv"]
# LAST valid START wins
assert foreground_from_logcat(lines) == "ar.tvplayer.tv"
def test_logcat_non_start_and_null_ignored():
from nsh.ha_adb_common.logcat_events import foreground_from_logcat
assert foreground_from_logcat([
"03-21 10:19:50.000 3104 3456 I ActivityTaskManager: Displayed",
"plain noise",
]) is None
lines = _logcat_lines()
assert foreground_from_logcat(lines) == "ar.tvplayer.tv" # null skipped
def test_logcat_multi_user_prefix_tolerated():
from nsh.ha_adb_common.logcat_events import foreground_from_logcat
assert foreground_from_logcat(
["03-21 10:19:41.792 3104 3456 I ActivityTaskManager: START u123 {cmp=net.whatsapp/"] + [
" flg=0x1}"]
) == "net.whatsapp"