use smix_sdk::parse_resolved_activity;
const HIT: &str = include_str!("fixtures/resolve-activity-settings-2026-07-22.txt");
const MISS: &str = include_str!("fixtures/resolve-activity-absent-2026-07-22.txt");
#[test]
fn the_component_line_yields_a_relative_activity() {
assert_eq!(
parse_resolved_activity(HIT, "com.android.settings").as_deref(),
Some(".Settings"),
"the captured output is:\n{HIT}"
);
}
#[test]
fn the_captured_output_still_has_its_header() {
assert!(
HIT.lines().count() >= 2,
"the fixture lost its header line and no longer stands for real output"
);
assert!(
HIT.lines().next().unwrap().starts_with("priority="),
"the fixture's first line is no longer the header a device printed"
);
}
#[test]
fn no_activity_found_yields_nothing() {
assert_eq!(parse_resolved_activity(MISS, "com.example.nosuchapp"), None);
}
#[test]
fn a_fully_qualified_component_is_relativised() {
assert_eq!(
parse_resolved_activity(
"com.example.app/com.example.app.SplashActivity",
"com.example.app"
)
.as_deref(),
Some(".SplashActivity")
);
}
#[test]
fn an_unrecognised_shape_yields_nothing() {
for text in ["", "Exception: something went wrong", "com.other.app/.Main"] {
assert_eq!(
parse_resolved_activity(text, "com.android.settings"),
None,
"{text:?} was read as an activity"
);
}
}