first commit

This commit is contained in:
marwy 2026-11-27 13:16:36 +03:00
commit a408df2a76
218 changed files with 52376 additions and 0 deletions

1238
tests/common/mod.rs Normal file

File diff suppressed because it is too large Load diff

BIN
tests/fixtures/reference/favorites.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
tests/fixtures/reference/for_you.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
tests/fixtures/reference/my_vibe.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
tests/fixtures/reference/search.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

1675
tests/parity_extended.rs Normal file

File diff suppressed because it is too large Load diff

807
tests/visual_parity.rs Normal file
View file

@ -0,0 +1,807 @@
//! Strict 1-to-1 Visual Parity Test Suite for Yandex Music Rust vs Official Desktop 5.129.0.
//!
//! Renders real frames through the pure-Rust production `ash` Vulkan SDF renderer
//! (`UiVulkanRenderer` + `VibeVulkanRenderer` + `taffy` + `cosmic-text` + compiled WGSL shaders +
//! authentic Yandex TTF fonts + SVG icons) at native 1280x800, downscales cleanly to the 1024x640
//! reference resolution, saves visual side-by-side + heatmap diff reports to `target/visual_tests/`,
//! and enforces strict pixel-measured geometry, color palette, gradient, shader, edge-alignment,
//! CIELAB ΔE, and SSIM parity against the 4 official Yandex Music reference screenshots.
mod common;
use common::{
capture_all_pages, compute_edge_ncc, compute_lab_delta_e, compute_ssim, find_matching_bbox,
is_vibe_gold, is_vibe_magenta, is_yandex_yellow, mean_rgb, measure_shell_geometry, median_rgb,
output_dir, rgb_dist, Region, REF_W,
};
fn diff_hint(page: &str) -> String {
format!(
"Inspect visual diff report: {}",
output_dir()
.join(format!("{}_diff_report.png", page))
.display()
)
}
fn assert_near_u32(label: &str, actual: u32, expected: u32, tol: u32, page: &str) {
let diff = actual.abs_diff(expected);
assert!(
diff <= tol,
"[{}] {} mismatch: actual={} px, reference={} px (diff={} px > allowed ±{} px). {}",
page,
label,
actual,
expected,
diff,
tol,
diff_hint(page)
);
}
fn assert_near_f32(label: &str, actual: f32, expected: f32, tol: f32, page: &str) {
let diff = (actual - expected).abs();
assert!(
diff <= tol,
"[{}] {} mismatch: actual={:.1} px, reference={:.1} px (diff={:.1} px > allowed ±{:.1} px). {}",
page,
label,
actual,
expected,
diff,
tol,
diff_hint(page)
);
}
fn assert_zone_metrics(
page: &str,
zone_name: &str,
ref_img: &image::RgbImage,
act_img: &image::RgbImage,
region: Region,
min_ssim: f64,
min_edge_ncc: f64,
max_mean_de: f64,
) {
let ssim = compute_ssim(ref_img, act_img, region);
let edge_ncc = compute_edge_ncc(ref_img, act_img, region);
let (mean_de, p95_de) = compute_lab_delta_e(ref_img, act_img, region);
let mut failures = Vec::new();
if ssim < min_ssim {
failures.push(format!("SSIM {:.4} < {:.4}", ssim, min_ssim));
}
if edge_ncc < min_edge_ncc {
failures.push(format!("Edge-NCC {:.4} < {:.4}", edge_ncc, min_edge_ncc));
}
if mean_de > max_mean_de {
failures.push(format!(
"Mean CIELAB ΔE {:.2} > {:.2} (P95 ΔE = {:.2})",
mean_de, max_mean_de, p95_de
));
}
assert!(
failures.is_empty(),
"[{}] Zone '{}' ({}x{} at {},{}) failed 1-to-1 visual parity:\n - {}\n Metrics: SSIM={:.4}, EdgeNCC={:.4}, MeanΔE={:.2}, P95ΔE={:.2}\n {}",
page,
zone_name,
region.w,
region.h,
region.x,
region.y,
failures.join("\n - "),
ssim,
edge_ncc,
mean_de,
p95_de,
diff_hint(page)
);
}
// ============================================================================
// 0. VISUAL PARITY SCORECARD (Always writes target/visual_tests/scorecard.txt)
// ============================================================================
#[test]
fn test_00_generate_visual_scorecard() {
let suite = capture_all_pages();
let mut report = String::new();
report.push_str(&format!(
"=== YANDEX MUSIC RUST 1-TO-1 VISUAL PARITY SCORECARD (GPU: {}) ===\n",
suite.gpu_name
));
report.push_str(&format!(
"{:<12} | {:>8} | {:>9} | {:>8} | {:>8} | {}\n",
"Page", "SSIM", "Edge-NCC", "Mean ΔE", "P95 ΔE", "Diff Report"
));
report.push_str(&"-".repeat(92));
report.push('\n');
for cap in [&suite.favorites, &suite.for_you, &suite.search, &suite.my_vibe] {
let ssim = compute_ssim(&cap.reference, &cap.actual, Region::full());
let edge = compute_edge_ncc(&cap.reference, &cap.actual, Region::full());
let (m_de, p95_de) = compute_lab_delta_e(&cap.reference, &cap.actual, Region::full());
report.push_str(&format!(
"{:<12} | {:>8.4} | {:>9.4} | {:>8.2} | {:>8.2} | {}_diff_report.png\n",
cap.name, ssim, edge, m_de, p95_de, cap.name
));
}
let ref_g = measure_shell_geometry(&suite.favorites.reference);
let act_g = measure_shell_geometry(&suite.favorites.actual);
report.push_str("\nMeasured Shell Geometry (1024x640 reference scale):\n");
report.push_str(&format!(
" card_left (sidebar_w): actual={:>3} px vs ref={:>3} px\n",
act_g.card_left, ref_g.card_left
));
report.push_str(&format!(
" card_top (titlebar): actual={:>3} px vs ref={:>3} px\n",
act_g.card_top, ref_g.card_top
));
report.push_str(&format!(
" card_right: actual={:>3} px vs ref={:>3} px (right_margin: {} vs {})\n",
act_g.card_right, ref_g.card_right, act_g.right_margin, ref_g.right_margin
));
report.push_str(&format!(
" card_bottom: actual={:>3} px vs ref={:>3} px (gap_y: {:?} vs {:?})\n",
act_g.card_bottom, ref_g.card_bottom, act_g.gap_y, ref_g.gap_y
));
report.push_str(&format!(
" player_bar: actual={:?}..{:?} vs ref={:?}..{:?}\n",
act_g.player_bar_top, act_g.player_bar_bottom, ref_g.player_bar_top, ref_g.player_bar_bottom
));
let out = output_dir().join("scorecard.txt");
let _ = std::fs::write(&out, &report);
println!("\n{}", report);
}
// ============================================================================
// A. GLOBAL SHELL & CHROME PARITY (Titlebar, Sidebar, Content Card, Player Bar)
// ============================================================================
#[test]
fn test_01_titlebar_geometry_and_cleanliness() {
let suite = capture_all_pages();
let cap = &suite.favorites;
let ref_geom = measure_shell_geometry(&cap.reference);
let act_geom = measure_shell_geometry(&cap.actual);
// 1. Exact titlebar height (~26px at 1024x640, i.e., 32px native at 1280x800)
assert_near_u32("titlebar height (card_top)", act_geom.card_top, ref_geom.card_top, 3, "favorites");
// 2. Center/left titlebar drag area must be pure #000000 (zero HUD / stray text / tint)
let drag_zone = Region::new(20, 4, 860, ref_geom.card_top.saturating_sub(6));
let mean = mean_rgb(&cap.actual, drag_zone);
assert!(
mean[0] < 3.0 && mean[1] < 3.0 && mean[2] < 3.0,
"[favorites] Titlebar drag strip is not pure black #000000 (mean RGB={:?}) — remove stray HUD/borders! {}",
mean,
diff_hint("favorites")
);
// 3. Top-right window controls (─ □ ×) must be present and visibly bright on black
let controls_zone = Region::new(910, 2, 112, 22);
let bright_ctrl_px = find_matching_bbox(&cap.actual, controls_zone, |rgb| {
rgb[0] > 90 && rgb[1] > 90 && rgb[2] > 90
})
.map_or(0, |b| b.pixel_count);
assert!(
bright_ctrl_px >= 18,
"[favorites] Titlebar window controls (─ □ ×) missing or too dim (bright px={}). {}",
bright_ctrl_px,
diff_hint("favorites")
);
// 4. Overall titlebar visual parity
let tb_region = Region::new(0, 2, REF_W, 22);
let ssim = compute_ssim(&cap.reference, &cap.actual, tb_region);
assert!(
ssim >= 0.90,
"[favorites] Titlebar SSIM {:.4} < 0.90. {}",
ssim,
diff_hint("favorites")
);
}
#[test]
fn test_02_sidebar_geometry_and_visual_parity() {
let suite = capture_all_pages();
let cap = &suite.favorites;
let ref_geom = measure_shell_geometry(&cap.reference);
let act_geom = measure_shell_geometry(&cap.actual);
// 1. Exact sidebar width (reference = 179px at 1024x640, i.e., ~224px at 1280x800!)
assert_near_u32("sidebar width (card_left)", act_geom.card_left, ref_geom.card_left, 4, "favorites");
// 2. Pure #000000 sidebar background gutter
let sb_bg = median_rgb(&cap.actual, Region::new(2, 200, 10, 120));
assert!(
rgb_dist(sb_bg, [0, 0, 0]) <= 3.0,
"[favorites] Sidebar background is {:?}, expected pure black [0,0,0]. {}",
sb_bg,
diff_hint("favorites")
);
// 3. Yandex Music yellow logo bbox in top-left must align with reference
let logo_zone = Region::new(0, 14, 175, 58);
let ref_logo = find_matching_bbox(&cap.reference, logo_zone, is_yandex_yellow)
.expect("Reference must contain yellow Yandex Music logo");
let act_logo = find_matching_bbox(&cap.actual, logo_zone, is_yandex_yellow)
.expect("Rust render missing yellow Yandex Music logo in top-left sidebar!");
assert_near_f32("sidebar logo center X", act_logo.cx(), ref_logo.cx(), 10.0, "favorites");
assert_near_f32("sidebar logo center Y", act_logo.cy(), ref_logo.cy(), 8.0, "favorites");
assert_near_u32("sidebar logo width", act_logo.width(), ref_logo.width(), 16, "favorites");
// 4. Per-section sidebar SSIM + Edge alignment + Color ΔE
// Logo header: pure #FFFF00 on #000000 has B=0 identically while JPEG 4:2:0 ref bleeds B~46,
// so validate standard Wang-Bovik Luma SSIM (>= 0.80) + Edge-NCC (>= 0.85) + Mean ΔE (<= 9.0)!
let logo_region = Region::new(8, 18, 160, 50);
let logo_luma_ssim = common::compute_luma_ssim(&cap.reference, &cap.actual, logo_region);
let logo_edge = compute_edge_ncc(&cap.reference, &cap.actual, logo_region);
let (logo_de, _) = compute_lab_delta_e(&cap.reference, &cap.actual, logo_region);
assert!(
logo_luma_ssim >= 0.80 && logo_edge >= 0.85 && logo_de <= 9.0,
"[favorites] Zone 'sidebar_logo' failed visual parity: LumaSSIM={:.4} (>=0.80), EdgeNCC={:.4} (>=0.85), MeanΔE={:.2} (<=9.0). {}",
logo_luma_ssim,
logo_edge,
logo_de,
diff_hint("favorites")
);
// Navigation items (Search .. My Collection)
assert_zone_metrics("favorites", "sidebar_nav", &cap.reference, &cap.actual, Region::new(8, 72, 165, 255), 0.84, 0.72, 6.5);
// Pinned playlists strip
assert_zone_metrics("favorites", "sidebar_pins", &cap.reference, &cap.actual, Region::new(8, 336, 165, 230), 0.78, 0.65, 9.5);
// User profile footer (Avatar + Marwy + "+ Plus" badge)
assert_zone_metrics("favorites", "sidebar_footer", &cap.reference, &cap.actual, Region::new(8, 574, 165, 58), 0.78, 0.65, 9.5);
}
#[test]
fn test_03_content_card_container_and_gutters() {
let suite = capture_all_pages();
let cap = &suite.favorites;
let ref_geom = measure_shell_geometry(&cap.reference);
let act_geom = measure_shell_geometry(&cap.actual);
assert_near_u32("card_left", act_geom.card_left, ref_geom.card_left, 4, "favorites");
assert_near_u32("card_right", act_geom.card_right, ref_geom.card_right, 4, "favorites");
assert_near_u32("card_top", act_geom.card_top, ref_geom.card_top, 3, "favorites");
assert_near_u32("card_bottom", act_geom.card_bottom, ref_geom.card_bottom, 4, "favorites");
assert_near_u32("right_margin", act_geom.right_margin, ref_geom.right_margin, 3, "favorites");
let ref_gap = ref_geom.gap_y.expect("Reference favorites must have gap between card and player bar");
let act_gap = act_geom.gap_y.expect("Actual favorites missing black gap between card and player bar");
assert_near_u32("gap between card and player bar", act_gap, ref_gap, 3, "favorites");
// Verify rounded corners on content card: exact outer corner pixel of the card bbox must be black!
let tl_corner = cap.actual.get_pixel(act_geom.card_left, act_geom.card_top).0;
let tr_corner = cap.actual.get_pixel(act_geom.card_right, act_geom.card_top).0;
assert!(
rgb_dist(tl_corner, [0, 0, 0]) < 8.0 && rgb_dist(tr_corner, [0, 0, 0]) < 8.0,
"[favorites] Content card corners are NOT properly rounded (TL={:?}, TR={:?}; expected black outside corner radius). {}",
tl_corner,
tr_corner,
diff_hint("favorites")
);
// Verify pure black gutter between content card and player bar (no bleeding strokes or shadows)
let gap_mid_y = act_geom.card_bottom + (act_gap / 2).max(1);
let gutter_mean = mean_rgb(&cap.actual, Region::new(220, gap_mid_y, 700, 2));
assert!(
gutter_mean[0] < 3.0 && gutter_mean[1] < 3.0 && gutter_mean[2] < 3.0,
"[favorites] Gutter between content card and player bar is not clean #000000 (mean RGB={:?}). {}",
gutter_mean,
diff_hint("favorites")
);
// Verify base content card background matches reference (#121212 = RGB(18,18,18) ± 5)
let bg_sample_zone = Region::new(820, 400, 80, 100);
let ref_bg = median_rgb(&cap.reference, bg_sample_zone);
let act_bg = median_rgb(&cap.actual, bg_sample_zone);
assert!(
rgb_dist(act_bg, ref_bg) <= 6.0,
"[favorites] Content card base background RGB mismatch: actual={:?}, reference={:?} (Δ={:.1} > 6.0). {}",
act_bg,
ref_bg,
rgb_dist(act_bg, ref_bg),
diff_hint("favorites")
);
}
#[test]
fn test_04_player_bar_1to1_visual_parity() {
let suite = capture_all_pages();
let cap = &suite.favorites;
let ref_geom = measure_shell_geometry(&cap.reference);
let act_geom = measure_shell_geometry(&cap.actual);
let ref_pt = ref_geom.player_bar_top.expect("Reference has player bar");
let ref_pb = ref_geom.player_bar_bottom.expect("Reference has player bar bottom");
let act_pt = act_geom.player_bar_top.expect("Rust render missing bottom player bar!");
let act_pb = act_geom.player_bar_bottom.expect("Rust render missing bottom player bar bottom!");
assert_near_u32("player_bar top", act_pt, ref_pt, 4, "favorites");
assert_near_u32("player_bar height", act_pb - act_pt, ref_pb - ref_pt, 4, "favorites");
// 1. CRITICAL: Check that there is NO bright yellow progress stripe across the top of the player bar!
// In original 5.128.0, progress is a subtle full-height split fill (#3D3D3D left / #333333 right),
// NOT a bright #FFFF00 line along the top edge!
let pb_top_strip = Region::new(200, act_pt, 340, 6);
let ref_top_yellow = find_matching_bbox(&cap.reference, pb_top_strip, is_yandex_yellow)
.map_or(0, |b| b.pixel_count);
let act_top_yellow = find_matching_bbox(&cap.actual, pb_top_strip, is_yandex_yellow)
.map_or(0, |b| b.pixel_count);
assert!(
act_top_yellow <= ref_top_yellow + 15,
"[favorites] Player bar has unwanted yellow stripe along top edge! actual_yellow_px={}, reference_yellow_px={}. Original 5.128.0 uses a full-height tonal split background (#3D3D3D / #333333), NOT a yellow top bar! {}",
act_top_yellow,
ref_top_yellow,
diff_hint("favorites")
);
// 2. Check player bar surface tone (played left half & unplayed right half) matches reference!
let left_mid_zone = Region::new(430, ref_pt + 8, 45, 16);
let right_mid_zone = Region::new(735, ref_pt + 8, 70, 16);
let ref_left_col = median_rgb(&cap.reference, left_mid_zone);
let act_left_col = median_rgb(&cap.actual, left_mid_zone);
let ref_right_col = median_rgb(&cap.reference, right_mid_zone);
let act_right_col = median_rgb(&cap.actual, right_mid_zone);
assert!(
rgb_dist(act_left_col, ref_left_col) <= 14.0,
"[favorites] Player bar played-side surface RGB mismatch: actual={:?}, reference={:?} (Δ={:.1} > 14.0). {}",
act_left_col,
ref_left_col,
rgb_dist(act_left_col, ref_left_col),
diff_hint("favorites")
);
assert!(
rgb_dist(act_right_col, ref_right_col) <= 14.0,
"[favorites] Player bar unplayed-side surface RGB mismatch: actual={:?}, reference={:?} (Δ={:.1} > 14.0). {}",
act_right_col,
ref_right_col,
rgb_dist(act_right_col, ref_right_col),
diff_hint("favorites")
);
// 3. Exact yellow Play button circle position & diameter
let play_search = Region::new(500, 566, 180, 66);
let ref_play = find_matching_bbox(&cap.reference, play_search, is_yandex_yellow)
.expect("Reference player bar missing yellow play button");
let act_play = find_matching_bbox(&cap.actual, play_search, is_yandex_yellow)
.expect("Actual player bar missing yellow play button!");
assert_near_f32("player bar play button center X", act_play.cx(), ref_play.cx(), 10.0, "favorites");
assert_near_f32("player bar play button center Y", act_play.cy(), ref_play.cy(), 5.0, "favorites");
assert_near_u32("player bar play button diameter", act_play.width(), ref_play.width(), 5, "favorites");
// 4. Overall Player Bar SSIM + Edge alignment + Color ΔE
let pb_region = Region::new(178, 565, 838, 68);
assert_zone_metrics("favorites", "player_bar", &cap.reference, &cap.actual, pb_region, 0.82, 0.72, 10.0);
}
#[test]
fn test_05_cross_page_shell_consistency() {
let suite = capture_all_pages();
// 1. Player bar MUST be visually identical across Favorites, For You, and Search
let pb_region = Region::new(178, 565, 838, 68);
let ssim_fav_fy = compute_ssim(&suite.favorites.actual, &suite.for_you.actual, pb_region);
let ssim_fav_sr = compute_ssim(&suite.favorites.actual, &suite.search.actual, pb_region);
assert!(
ssim_fav_fy >= 0.98 && ssim_fav_sr >= 0.98,
"Player bar drifted across pages! SSIM(fav, for_you)={:.4}, SSIM(fav, search)={:.4} (expected >= 0.98)",
ssim_fav_fy,
ssim_fav_sr
);
// 2. Sidebar logo & footer MUST be pixel-consistent across all 4 pages
let logo_r = Region::new(8, 18, 148, 50);
let footer_r = Region::new(8, 574, 148, 58);
for other in [&suite.for_you, &suite.search, &suite.my_vibe] {
let logo_ssim = compute_ssim(&suite.favorites.actual, &other.actual, logo_r);
let foot_ssim = compute_ssim(&suite.favorites.actual, &other.actual, footer_r);
assert!(
logo_ssim >= 0.98 && foot_ssim >= 0.98,
"Sidebar logo/footer inconsistent on '{}': logo_ssim={:.4}, footer_ssim={:.4}",
other.name,
logo_ssim,
foot_ssim
);
}
// 3. On My Vibe, bottom player bar MUST be completely absent (pure #000000 in bottom-left of stage)
let mv_bottom = mean_rgb(&suite.my_vibe.actual, Region::new(200, 580, 120, 45));
assert!(
mv_bottom[0] < 12.0 && mv_bottom[1] < 12.0 && mv_bottom[2] < 12.0,
"[my_vibe] Bottom player bar or stray chrome visible on full-bleed My Vibe page (mean RGB={:?})! {}",
mv_bottom,
diff_hint("my_vibe")
);
}
// ============================================================================
// B. PAGE 1: "MY FAVORITES" (PLAYLIST DETAIL) 1-TO-1 PARITY
// ============================================================================
#[test]
fn test_06_favorites_header_gradient_and_layout() {
let suite = capture_all_pages();
let cap = &suite.favorites;
// 1. Top atmospheric gradient wash MUST reach the outer edge of the card (no dark unshaded border frame!)
let top_edge_wash = Region::new(600, 34, 300, 16);
let ref_wash = median_rgb(&cap.reference, top_edge_wash);
let act_wash = median_rgb(&cap.actual, top_edge_wash);
assert!(
rgb_dist(act_wash, ref_wash) <= 14.0,
"[favorites] Top atmospheric header gradient mismatch at card top edge: actual={:?}, reference={:?} (Δ={:.1} > 14.0). Gradient must bleed edge-to-edge of the rounded content card! {}",
act_wash,
ref_wash,
rgb_dist(act_wash, ref_wash),
diff_hint("favorites")
);
// Also verify there is no dark strip directly at x=186..196 inside card top (y=40..120)
let left_edge_wash = Region::new(184, 50, 10, 60);
let ref_lwash = median_rgb(&cap.reference, left_edge_wash);
let act_lwash = median_rgb(&cap.actual, left_edge_wash);
assert!(
rgb_dist(act_lwash, ref_lwash) <= 15.0,
"[favorites] Header gradient does not bleed to card left edge! actual={:?}, reference={:?} (Δ={:.1} > 15.0). {}",
act_lwash,
ref_lwash,
rgb_dist(act_lwash, ref_lwash),
diff_hint("favorites")
);
// 2. "My Favorites" crimson heart cover bbox
let cov_search = Region::new(185, 70, 200, 200);
let is_crimson = |rgb: [u8; 3]| rgb[0] > 90 && rgb[1] < 60 && rgb[2] < 60;
let ref_cov = find_matching_bbox(&cap.reference, cov_search, is_crimson)
.expect("Reference favorites missing crimson heart cover");
let act_cov = find_matching_bbox(&cap.actual, cov_search, is_crimson)
.expect("Actual favorites missing crimson heart cover!");
assert_near_u32("favorites cover X", act_cov.x1, ref_cov.x1, 10, "favorites");
assert_near_u32("favorites cover Y", act_cov.y1, ref_cov.y1, 10, "favorites");
assert_near_u32("favorites cover width", act_cov.width(), ref_cov.width(), 12, "favorites");
assert_near_u32("favorites cover height", act_cov.height(), ref_cov.height(), 12, "favorites");
// 3. Bright yellow [ ▶ Listen ] pill button bbox
let btn_search = Region::new(360, 160, 160, 100);
let ref_btn = find_matching_bbox(&cap.reference, btn_search, is_yandex_yellow)
.expect("Reference favorites missing yellow Listen pill");
let act_btn = find_matching_bbox(&cap.actual, btn_search, is_yandex_yellow)
.expect("Actual favorites missing yellow Listen pill!");
assert_near_u32("Listen button X", act_btn.x1, ref_btn.x1, 12, "favorites");
assert_near_u32("Listen button Y", act_btn.y1, ref_btn.y1, 10, "favorites");
assert_near_u32("Listen button width", act_btn.width(), ref_btn.width(), 14, "favorites");
assert_near_u32("Listen button height", act_btn.height(), ref_btn.height(), 6, "favorites");
// 4. Full header zone SSIM + Edge + ΔE
assert_zone_metrics("favorites", "playlist_header", &cap.reference, &cap.actual, Region::new(180, 28, 830, 232), 0.80, 0.70, 9.5);
}
#[test]
fn test_07_favorites_search_tags_and_tracklist() {
let suite = capture_all_pages();
let cap = &suite.favorites;
// 1. Active "All" mood filter pill MUST have bright yellow outline at y=305..355, x=190..260
let tag_zone = Region::new(190, 305, 80, 50);
let ref_all = find_matching_bbox(&cap.reference, tag_zone, is_yandex_yellow)
.expect("Reference favorites missing yellow outline on active 'All' tag");
let act_all = find_matching_bbox(&cap.actual, tag_zone, is_yandex_yellow)
.expect("Actual favorites missing yellow outline on active 'All' tag!");
assert_near_f32("active 'All' tag center X", act_all.cx(), ref_all.cx(), 12.0, "favorites");
assert_near_f32("active 'All' tag center Y", act_all.cy(), ref_all.cy(), 10.0, "favorites");
// 2. Track search pill + tag pills bar visual parity
assert_zone_metrics("favorites", "track_search_and_tags", &cap.reference, &cap.actual, Region::new(185, 260, 820, 96), 0.80, 0.68, 8.0);
// 3. Track list rows alignment & visual parity
assert_zone_metrics("favorites", "tracklist_rows", &cap.reference, &cap.actual, Region::new(185, 365, 820, 190), 0.80, 0.70, 7.5);
}
#[test]
fn test_08_favorites_full_page_1to1_parity() {
let suite = capture_all_pages();
let cap = &suite.favorites;
assert_zone_metrics("favorites", "full_frame", &cap.reference, &cap.actual, Region::full(), 0.85, 0.74, 8.5);
}
// ============================================================================
// C. PAGE 2: "FOR YOU AND TRENDS" 1-TO-1 PARITY
// ============================================================================
#[test]
fn test_09_for_you_header_pills_and_quick_cards() {
let suite = capture_all_pages();
let cap = &suite.for_you;
// 1. Quick cards ("My Favorites >" and "History >") surface color must match #252525 (RGB(37,37,37) ± 8)
let quick_bg_zone = Region::new(390, 178, 80, 50);
let ref_qbg = median_rgb(&cap.reference, quick_bg_zone);
let act_qbg = median_rgb(&cap.actual, quick_bg_zone);
assert!(
rgb_dist(act_qbg, ref_qbg) <= 10.0,
"[for_you] Quick card fill RGB mismatch: actual={:?}, reference={:?} (Δ={:.1} > 10.0). {}",
act_qbg,
ref_qbg,
rgb_dist(act_qbg, ref_qbg),
diff_hint("for_you")
);
// 2. Header + For You / Trends switcher pills parity
assert_zone_metrics("for_you", "header_and_switcher", &cap.reference, &cap.actual, Region::new(185, 34, 820, 125), 0.80, 0.70, 8.5);
// 3. Quick cards row parity ("My Favorites >" & "History >")
assert_zone_metrics("for_you", "quick_cards", &cap.reference, &cap.actual, Region::new(185, 165, 820, 82), 0.80, 0.68, 9.0);
}
#[test]
fn test_10_for_you_artist_promo_cards() {
let suite = capture_all_pages();
let cap = &suite.for_you;
// Each of the 3 "Recommended by the Artist" cards MUST have a crisp bright-white [ ▶ Listen ] pill
// in the bottom-right corner of the card!
let is_white_pill = |rgb: [u8; 3]| rgb[0] > 210 && rgb[1] > 210 && rgb[2] > 210;
let card_pill_zones = [
("card_1_listen_pill", Region::new(350, 415, 110, 56)),
("card_2_listen_pill", Region::new(620, 415, 110, 56)),
("card_3_listen_pill", Region::new(885, 415, 110, 56)),
];
for (label, zone) in card_pill_zones {
let ref_px = find_matching_bbox(&cap.reference, zone, is_white_pill)
.map_or(0, |b| b.pixel_count);
let act_px = find_matching_bbox(&cap.actual, zone, is_white_pill)
.map_or(0, |b| b.pixel_count);
assert!(
act_px >= (ref_px / 3).max(400),
"[for_you] Missing or wrong white '▶ Listen' pill on {}: actual_white_px={}, reference_white_px={}. {}",
label,
act_px,
ref_px,
diff_hint("for_you")
);
}
assert_zone_metrics("for_you", "artist_promo_section", &cap.reference, &cap.actual, Region::new(185, 255, 820, 265), 0.78, 0.68, 11.0);
}
#[test]
fn test_11_for_you_full_page_1to1_parity() {
let suite = capture_all_pages();
let cap = &suite.for_you;
assert_zone_metrics("for_you", "full_frame", &cap.reference, &cap.actual, Region::full(), 0.82, 0.72, 10.0);
}
// ============================================================================
// D. PAGE 3: "SEARCH" 1-TO-1 PARITY
// ============================================================================
#[test]
fn test_12_search_bar_ai_prompts_and_tabs() {
let suite = capture_all_pages();
let cap = &suite.search;
// 1. Search pill fill color must match reference (#252525 = RGB(37,37,37) ± 8)
let bar_fill_zone = Region::new(400, 50, 300, 22);
let ref_bar = median_rgb(&cap.reference, bar_fill_zone);
let act_bar = median_rgb(&cap.actual, bar_fill_zone);
assert!(
rgb_dist(act_bar, ref_bar) <= 10.0,
"[search] Search bar pill fill RGB mismatch: actual={:?}, reference={:?} (Δ={:.1} > 10.0). {}",
act_bar,
ref_bar,
rgb_dist(act_bar, ref_bar),
diff_hint("search")
);
// 1b. Search bar interior MUST NOT have a bright magenta/purple smear (original bar is clean neutral dark gray #252525!)
let bar_left_zone = Region::new(205, 48, 220, 28);
let is_garish_magenta = |rgb: [u8; 3]| rgb[0] > 70 && rgb[2] > 90 && (rgb[2] as i32 - rgb[1] as i32) > 30;
let ref_bar_mag = find_matching_bbox(&cap.reference, bar_left_zone, is_garish_magenta)
.map_or(0, |b| b.pixel_count);
let act_bar_mag = find_matching_bbox(&cap.actual, bar_left_zone, is_garish_magenta)
.map_or(0, |b| b.pixel_count);
assert!(
act_bar_mag <= ref_bar_mag + 20,
"[search] Search bar has unwanted magenta/purple smear inside input box! actual_magenta_px={}, reference_magenta_px={}. {}",
act_bar_mag,
ref_bar_mag,
diff_hint("search")
);
// 2. Purple-accented AI prompts row (y=90..145) must contain purple/violet pixels!
let ai_row = Region::new(190, 90, 800, 52);
let is_purple = |rgb: [u8; 3]| rgb[2] > 120 && rgb[0] > 70 && (rgb[2] as u16) > (rgb[1] as u16) + 25;
let act_purple = find_matching_bbox(&cap.actual, ai_row, is_purple).map_or(0, |b| b.pixel_count);
assert!(
act_purple >= 120,
"[search] AI prompts row missing purple/violet accent glow/highlights (purple_px={}). {}",
act_purple,
diff_hint("search")
);
// 3. Top half (Search bar + AI prompts + Popular/History tabs) parity
assert_zone_metrics("search", "search_header_and_tabs", &cap.reference, &cap.actual, Region::new(185, 36, 820, 165), 0.80, 0.68, 9.0);
}
#[test]
fn test_13_search_mixes_and_discover_grid() {
let suite = capture_all_pages();
let cap = &suite.search;
// "Mixes >" stacked-folder 5-card row + centered labels
assert_zone_metrics("search", "mixes_row", &cap.reference, &cap.actual, Region::new(185, 210, 820, 200), 0.74, 0.65, 13.0);
// "Discover these playlists >" heading & card strip
assert_zone_metrics("search", "discover_playlists", &cap.reference, &cap.actual, Region::new(185, 435, 820, 120), 0.72, 0.62, 15.0);
}
#[test]
fn test_14_search_full_page_1to1_parity() {
let suite = capture_all_pages();
let cap = &suite.search;
assert_zone_metrics("search", "full_frame", &cap.reference, &cap.actual, Region::full(), 0.80, 0.70, 11.0);
}
// ============================================================================
// E. PAGE 4: "MY VIBE" (VULKAN SHADER ORB CANVAS) 1-TO-1 PARITY
// ============================================================================
#[test]
fn test_15_my_vibe_vulkan_orb_and_shader_quality() {
let suite = capture_all_pages();
let cap = &suite.my_vibe;
let stage = Region::new(500, 60, 500, 380);
// 1. Luminous golden-yellow core must be rendered by Vulkan `vibe.wgsl`
let ref_gold = find_matching_bbox(&cap.reference, stage, is_vibe_gold)
.expect("Reference My Vibe missing golden orb core");
let act_gold = find_matching_bbox(&cap.actual, stage, is_vibe_gold)
.expect("Actual My Vibe missing golden orb core — check Vulkan vibe.wgsl!");
assert!(
act_gold.pixel_count >= 10_000,
"[my_vibe] Vulkan Vibe orb golden core too small/dim: actual_gold_px={}, reference_gold_px={}. {}",
act_gold.pixel_count,
ref_gold.pixel_count,
diff_hint("my_vibe")
);
let ref_aspect = ref_gold.width() as f32 / ref_gold.height().max(1) as f32;
let act_aspect = act_gold.width() as f32 / act_gold.height().max(1) as f32;
assert!(
(act_aspect - ref_aspect).abs() <= 0.25,
"[my_vibe] Vulkan Vibe orb aspect ratio squished/stretched! actual={:.2} ({}x{}), reference={:.2} ({}x{}). Check vibe.wgsl aspect scaling! {}",
act_aspect,
act_gold.width(),
act_gold.height(),
ref_aspect,
ref_gold.width(),
ref_gold.height(),
diff_hint("my_vibe")
);
assert_near_f32("My Vibe orb gold center X", act_gold.cx(), ref_gold.cx(), 35.0, "my_vibe");
assert_near_f32("My Vibe orb gold center Y", act_gold.cy(), ref_gold.cy(), 35.0, "my_vibe");
// 2. Surrounding hot-magenta aura must be visible around the golden core
let act_mag = find_matching_bbox(&cap.actual, stage, is_vibe_magenta)
.map_or(0, |b| b.pixel_count);
assert!(
act_mag >= 1_500,
"[my_vibe] Vulkan Vibe orb missing hot-magenta aura (actual_magenta_px={} < 1500). {}",
act_mag,
diff_hint("my_vibe")
);
// 3. Smooth fade to pure #000000 at stage perimeter (zero hard rectangular quad seam!)
let right_perimeter = mean_rgb(&cap.actual, Region::new(985, 80, 30, 320));
assert!(
right_perimeter[0] < 8.0 && right_perimeter[1] < 8.0 && right_perimeter[2] < 8.0,
"[my_vibe] Vibe orb does not fade cleanly to #000000 at right edge (mean RGB={:?}). {}",
right_perimeter,
diff_hint("my_vibe")
);
// 4. Orb + crisp white "My Vibe" headline zone SSIM
assert_zone_metrics("my_vibe", "orb_and_headline", &cap.reference, &cap.actual, Region::new(500, 60, 480, 340), 0.74, 0.62, 15.0);
}
#[test]
fn test_16_my_vibe_inline_controls_and_left_feed() {
let suite = capture_all_pages();
let cap = &suite.my_vibe;
// 1. Yellow Play button centered below the track pill (~51px diameter at cx=754, cy=505)
let play_zone = Region::new(660, 455, 190, 100);
let ref_play = find_matching_bbox(&cap.reference, play_zone, is_yandex_yellow)
.expect("Reference My Vibe missing yellow play button");
let act_play = find_matching_bbox(&cap.actual, play_zone, is_yandex_yellow)
.expect("Actual My Vibe missing yellow play button!");
assert_near_f32("My Vibe play button center X", act_play.cx(), ref_play.cx(), 16.0, "my_vibe");
assert_near_f32("My Vibe play button center Y", act_play.cy(), ref_play.cy(), 16.0, "my_vibe");
assert_near_u32("My Vibe play button diameter", act_play.width(), ref_play.width(), 8, "my_vibe");
// 2. Inline controls row (volume, dislike, progress track capsule, like, more + transport)
assert_zone_metrics("my_vibe", "inline_controls", &cap.reference, &cap.actual, Region::new(520, 395, 470, 155), 0.76, 0.65, 11.0);
// 3. Left vertical vibe station bubbles feed
assert_zone_metrics("my_vibe", "left_vibe_bubbles", &cap.reference, &cap.actual, Region::new(200, 30, 300, 595), 0.72, 0.60, 12.0);
}
#[test]
fn test_17_my_vibe_full_page_1to1_parity() {
let suite = capture_all_pages();
let cap = &suite.my_vibe;
assert_zone_metrics("my_vibe", "full_frame", &cap.reference, &cap.actual, Region::full(), 0.78, 0.66, 11.5);
}
// ============================================================================
// F. ANTI-ARTIFACT, FONT & ICON RENDERING GUARDS
// ============================================================================
#[test]
fn test_18_no_egui_default_artifacts_or_broken_fonts() {
let suite = capture_all_pages();
// 1. Zero default egui bright-cyan selection/focus rings leaking anywhere in UI chrome
let is_egui_cyan = |rgb: [u8; 3]| rgb[0] < 40 && rgb[1] > 180 && rgb[2] > 220;
for cap in [&suite.favorites, &suite.for_you, &suite.search] {
let cyan_count = find_matching_bbox(&cap.actual, Region::new(0, 0, REF_W, 80), is_egui_cyan)
.map_or(0, |b| b.pixel_count);
assert!(
cyan_count < 10,
"[{}] Unexpected default egui cyan artifact in top chrome (cyan_px={}). {}",
cap.name,
cyan_count,
diff_hint(cap.name)
);
}
// 2. Verify Yandex headline font actually rendered bright crisp glyphs in "My Favorites" & "For you and Trends"
let is_bright_text = |rgb: [u8; 3]| rgb[0] > 190 && rgb[1] > 190 && rgb[2] > 190;
let fav_title_px = find_matching_bbox(&suite.favorites.actual, Region::new(370, 95, 320, 75), is_bright_text)
.map_or(0, |b| b.pixel_count);
assert!(
fav_title_px >= 600,
"[favorites] 'My Favorites' headline text missing/clipped/too small (bright_px={} < 600). {}",
fav_title_px,
diff_hint("favorites")
);
let fy_title_px = find_matching_bbox(&suite.for_you.actual, Region::new(190, 35, 340, 55), is_bright_text)
.map_or(0, |b| b.pixel_count);
assert!(
fy_title_px >= 450,
"[for_you] 'For you and Trends' headline text missing/clipped/too small (bright_px={} < 450). {}",
fy_title_px,
diff_hint("for_you")
);
// 3. Verify sidebar icons actually rasterized (non-blank luminance in icon column x=22..44)
let nav_icon_px = find_matching_bbox(&suite.favorites.actual, Region::new(18, 76, 30, 240), |rgb| {
rgb[0] > 60 || rgb[1] > 60 || rgb[2] > 60
})
.map_or(0, |b| b.pixel_count);
assert!(
nav_icon_px >= 250,
"[favorites] Sidebar SVG icons failed to rasterize (non-black px={} < 250). {}",
nav_icon_px,
diff_hint("favorites")
);
}