yandex-music-rs/tests/parity_extended.rs
2026-11-27 13:17:37 +03:00

1675 lines
62 KiB
Rust

//! Extended 1-to-1 Parity, Light Theme, Titlebar Restore, Search/Mixes, Temporal Smoothness,
//! Official Asset Integrity & Live Resilience Suite (pure `ash` SDF + `taffy` + `cosmic-text`).
//!
//! Supplements `tests/visual_parity.rs` (19 tests) with deep checks for:
//! - EXT 1: Temporal stability of the Vulkan My Vibe shader during playback under rapid beat transients
//! - EXT 2: Official CDN `ai_meteor_glow.png` asymmetric falling-meteor shape & lossless CDP parity
//! - EXT 3: Official `pause.svg` vs `play.svg` button states & `link_rounded_xxs.svg` wheel arrow
//! - EXT 4: All 114+ embedded official Yandex Music SVG icons + 3 official media PNGs integrity
//! - EXT 5: Absence of invented neon cartoon fallbacks when covers/wheel icons are still loading
//! - EXT 6: Exact sRGB (`css_rgba`) text colors & transparent Player Bar Play triangle cutout
//! - EXT 7: Non-deadlocking `CoverCache` failure recovery & URL normalization
//! - EXT 8: Authentic Yandex Music 5.129.0 official Pumpkin wheel station CDN catalog
//! - EXT 9: Light Theme rendering across Favorites, For You, Search, Collection & Profile Popup
//! asserting ZERO hardcoded dark surfaces (`#1E1E22`/`#252525`/`#333333`) & high contrast text on `#FFFFFF`
//! - EXT 10: Maximized Titlebar Windows 11 Restore double-square icon verification
//! - EXT 11: Search empty inactive input (zero placeholder text) & Mixes 8px 50%-opacity folder tab
mod common;
use image::{ImageBuffer, Rgb, RgbImage, RgbaImage};
use std::path::Path;
use std::time::{Duration, Instant};
use yandex_music_rs::api::demo_data;
use yandex_music_rs::api::models::{ArtistSummary, Track, UserAccount, VibeStationSummary};
use yandex_music_rs::api::YandexApiClient;
use yandex_music_rs::app::{AppState, Route};
use yandex_music_rs::config::{AppConfig, Language, PinnedItem, ThemeMode};
use yandex_music_rs::covers::CoverCache;
use yandex_music_rs::engine::{TextureRegistry, Vec2};
use yandex_music_rs::icons::{Icon, IconCache};
use yandex_music_rs::views::YandexMusicShell;
use yandex_music_rs::vulkan::headless::HeadlessVulkanRenderer;
use common::{is_vibe_gold, is_yandex_yellow, output_dir, NATIVE_H, NATIVE_W};
fn make_base_shell(
rt: tokio::runtime::Handle,
gpu_name: String,
route: Route,
theme: ThemeMode,
language: Language,
fixed_time: f32,
) -> YandexMusicShell {
let mut cfg = AppConfig::default();
cfg.theme = theme;
cfg.language = language;
cfg.sidebar_collapsed = false;
cfg.show_perf_hud = false;
cfg.pinned_items = vec![
PinnedItem {
id: "likes".into(),
kind: "likes".into(),
title: if language.is_ru() {
"Мне нравится".into()
} else {
"My Favorites".into()
},
subtitle: if language.is_ru() {
"Плейлист".into()
} else {
"Playlist".into()
},
cover_uri: None,
owner_uid: None,
},
PinnedItem {
id: "p_2025".into(),
kind: "playlist".into(),
title: "My 2025".into(),
subtitle: if language.is_ru() {
"Плейлист".into()
} else {
"Playlist".into()
},
cover_uri: None,
owner_uid: None,
},
PinnedItem {
id: "p_2024".into(),
kind: "playlist".into(),
title: "My 2024".into(),
subtitle: if language.is_ru() {
"Плейлист".into()
} else {
"Playlist".into()
},
cover_uri: None,
owner_uid: None,
},
PinnedItem {
id: "p_daily".into(),
kind: "playlist".into(),
title: "Daily Playlist".into(),
subtitle: if language.is_ru() {
"Плейлист".into()
} else {
"Playlist".into()
},
cover_uri: None,
owner_uid: None,
},
];
let account = Some(UserAccount {
uid: 1,
login: "Marwy".into(),
display_name: "Marwy".into(),
has_plus: true,
avatar_uri: None,
});
let track = Track {
id: "t_1".into(),
title: "MONTAGEM TENTA".into(),
version: Some("Hardstyle".into()),
artists: vec![ArtistSummary {
id: "a_1".into(),
name: "KYOR".into(),
cover_uri: None,
genres: vec![],
}],
album_id: Some("alb_1".into()),
album_title: Some("MONTAGEM TENTA".into()),
cover_uri: None,
duration_ms: 141_000,
is_explicit: false,
has_lossless: true,
has_lyrics: false,
chart_position: None,
chart_progress: None,
preview_url: None,
r128_i: None,
r128_tp: None,
derived_average_hex: None,
derived_accent_hex: None,
};
let track2 = Track {
id: "t_2".into(),
title: "Midnight Sun".into(),
version: None,
artists: vec![ArtistSummary {
id: "a_2".into(),
name: "SuperSolar".into(),
cover_uri: None,
genres: vec![],
}],
album_id: Some("alb_2".into()),
album_title: Some("Midnight Sun".into()),
cover_uri: None,
duration_ms: 184_000,
is_explicit: false,
has_lossless: true,
has_lyrics: true,
chart_position: None,
chart_progress: None,
preview_url: None,
r128_i: None,
r128_tp: None,
derived_average_hex: None,
derived_accent_hex: None,
};
let landing = demo_data::demo_landing();
let app = AppState::new_visual_test(
rt.clone(),
gpu_name,
route,
cfg,
landing,
account,
vec![track.clone(), track2],
vec![track],
52_000,
141_000,
fixed_time,
);
let covers = CoverCache::new(128, rt);
YandexMusicShell::new_visual_test(app, covers)
}
fn render_single_frame_ex(
vk: &mut HeadlessVulkanRenderer,
shell: &mut YandexMusicShell,
time_s: f64,
is_maximized: bool,
) -> RgbImage {
let (out, _cmd) = shell.render_frame(
Vec2::new(NATIVE_W as f32, NATIVE_H as f32),
1.0,
time_s,
is_maximized,
);
let clear_col = shell.palette.clear_color_f32();
let vibe_push = shell.vibe_push_constants();
let rgba = vk
.render_to_rgba(
&out.display_list,
&out.texture_uploads,
1.0,
clear_col,
vibe_push,
)
.expect("Headless Vulkan render failed");
let rgba_img: RgbaImage = ImageBuffer::from_raw(NATIVE_W, NATIVE_H, rgba).unwrap();
ImageBuffer::from_fn(NATIVE_W, NATIVE_H, |x, y| {
let p = rgba_img.get_pixel(x, y).0;
Rgb([p[0], p[1], p[2]])
})
}
fn render_single_frame(
vk: &mut HeadlessVulkanRenderer,
shell: &mut YandexMusicShell,
time_s: f64,
) -> RgbImage {
render_single_frame_ex(vk, shell, time_s, false)
}
fn region_mean_abs_diff(a: &RgbImage, b: &RgbImage, x0: u32, y0: u32, x1: u32, y1: u32) -> f64 {
let mut sum = 0.0_f64;
let mut n = 0_u64;
for y in y0..y1.min(a.height()) {
for x in x0..x1.min(a.width()) {
let pa = a.get_pixel(x, y).0;
let pb = b.get_pixel(x, y).0;
sum += (pa[0].abs_diff(pb[0]) as f64
+ pa[1].abs_diff(pb[1]) as f64
+ pa[2].abs_diff(pb[2]) as f64)
/ 3.0;
n += 1;
}
}
sum / n.max(1) as f64
}
// ============================================================================
// EXT 1: VIBE TEMPORAL SMOOTHNESS DURING PLAYBACK (ZERO SEIZING / TELEPORTING)
// ============================================================================
#[test]
fn test_ext_01_vibe_temporal_smoothness_during_playback() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
0.0,
);
// Warm up layout & glyph atlas
for f in 0..3 {
let _ = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
// Simulate 12 consecutive 60fps frames AFTER 45 seconds of playback with wildly swinging beat energy!
for _ in 0..120 {
shell.app.set_vibe_playback_for_test(true, 0.45, 0.40);
shell.app.tick_vibe_animation(0.05, None);
}
let beat_energies = [
0.15_f32, 0.92, 0.12, 0.88, 0.08, 0.95, 0.20, 0.85, 0.10, 0.90, 0.18, 0.82,
];
let beat_basses = [
0.10_f32, 0.95, 0.15, 0.90, 0.10, 0.96, 0.22, 0.88, 0.12, 0.92, 0.18, 0.85,
];
let mut frames = Vec::with_capacity(beat_energies.len());
let mut prev_phase = -1.0_f32;
for (i, (&e, &b)) in beat_energies.iter().zip(beat_basses.iter()).enumerate() {
shell.app.set_vibe_playback_for_test(true, e, b);
shell.app.tick_vibe_animation(1.0 / 60.0, None);
let push = shell
.vibe_push_constants()
.expect("MyVibe push constants missing");
assert!(
push.time > prev_phase,
"Vibe phase MUST advance strictly monotonically! frame={} prev={} cur={}",
i,
prev_phase,
push.time
);
prev_phase = push.time;
let img = render_single_frame(&mut vk, &mut shell, 45.0 + i as f64 * (1.0 / 60.0));
frames.push(img);
}
let mut max_delta = 0.0_f64;
let mut sum_delta = 0.0_f64;
for w in frames.windows(2) {
let d = region_mean_abs_diff(&w[0], &w[1], 620, 60, 1240, 520);
max_delta = max_delta.max(d);
sum_delta += d;
}
let mean_delta = sum_delta / (frames.len() - 1) as f64;
println!(
"Vibe playback temporal smoothness (12 frames, extreme beat swings): mean_delta={:.3} RGB, max_delta={:.3} RGB",
mean_delta, max_delta
);
assert!(
mean_delta > 0.02,
"Vibe orb appears frozen during playback (mean_delta={:.4})",
mean_delta
);
assert!(
max_delta < 5.0,
"Vibe orb seized/strobed during playback! max_delta={:.3} RGB (limit < 5.0)",
max_delta
);
// Verify warm golden-yellow core is preserved during playback (no snapping to neon blue!)
let last = frames.last().unwrap();
let mut gold_px = 0usize;
for y in 160..390 {
for x in 800..1080 {
if is_vibe_gold(last.get_pixel(x, y).0) {
gold_px += 1;
}
}
}
assert!(
gold_px > 4000,
"Expected iconic golden-yellow My Vibe core during playback, found only {} gold px",
gold_px
);
let _ = std::fs::create_dir_all(output_dir());
let _ = last.save(output_dir().join("my_vibe_playing_smooth.png"));
}
// ============================================================================
// EXT 2: OFFICIAL CDN AI METEOR GLOW SHAPE & LOSSLESS CDP PARITY
// ============================================================================
#[test]
fn test_ext_02_official_ai_meteor_glow_exact_shape_and_cdp_parity() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
0.0,
);
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..4 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
let mean_luma = |x0: u32, y0: u32, x1: u32, y1: u32| -> f64 {
let mut s = 0.0;
let mut n = 0;
for y in y0..y1 {
for x in x0..x1 {
let [r, g, b] = img.get_pixel(x, y).0;
s += (r as f64 + g as f64 + b as f64) / 3.0;
n += 1;
}
}
s / n.max(1) as f64
};
let top_right_tail = mean_luma(810, 655, 875, 710);
let top_left_void = mean_luma(725, 635, 760, 675);
let halo_near_sparkle = mean_luma(765, 738, 795, 765);
println!(
"Official AiBadge_glow meteor luma: top_right_tail={:.2}, top_left_void={:.2}, halo_near_sparkle={:.2}",
top_right_tail, top_left_void, halo_near_sparkle
);
assert!(
top_right_tail > top_left_void + 8.0,
"Meteor glow must have an asymmetric upper-right falling tail! tail={:.2}, void={:.2}",
top_right_tail,
top_left_void
);
assert!(
halo_near_sparkle > 20.0 && halo_near_sparkle < 110.0,
"Meteor halo brightness around sparkle out of authentic 0.65 opacity range: {:.2}",
halo_near_sparkle
);
let cdp_path = Path::new(r"C:\Users\marwy\.gemini\antigravity\brain\7307703a-5352-42dd-81cb-7008b16a13f3\scratch\cdp_dump\my_vibe_1280x800.png");
if cdp_path.exists() {
let cdp = image::open(cdp_path).unwrap().to_rgb8();
let mae = region_mean_abs_diff(&cdp, &img, 710, 640, 800, 795);
println!("Official meteor vs lossless CDP 1280x800 MAE = {:.2} RGB", mae);
assert!(
mae < 4.5,
"Official meteor glow diverged from lossless CDP reference! MAE={:.2} > 4.5",
mae
);
}
}
// ============================================================================
// EXT 3: OFFICIAL PAUSE.SVG VS PLAY.SVG & WHEEL LINK_ROUNDED ARROW
// ============================================================================
#[test]
fn test_ext_03_my_vibe_pause_svg_and_wheel_link_arrow_parity() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
0.0,
);
// Render PAUSED state (`play.svg`)
let mut paused = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..4 {
paused = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
// Render PLAYING state (`pause.svg`)
shell.app.set_vibe_playback_for_test(true, 0.35, 0.30);
shell.app.set_fixed_vibe_time_for_test(Some(0.0));
let playing = render_single_frame(&mut vk, &mut shell, 0.1);
// 1. Paused state MUST render the 64x64 #FFFF00 yellow Play button around (943, 632)
let mut yellow_px = 0usize;
let mut sum_x = 0u64;
let mut sum_y = 0u64;
for y in 580..680 {
for x in 890..995 {
if is_yandex_yellow(paused.get_pixel(x, y).0) {
yellow_px += 1;
sum_x += x as u64;
sum_y += y as u64;
}
}
}
assert!(
yellow_px > 2200,
"Expected 64x64 #FFFF00 My Vibe paused Play button, found {} yellow px",
yellow_px
);
let cx = (sum_x / yellow_px as u64) as u32;
let cy = (sum_y / yellow_px as u64) as u32;
// 2. Playing state MUST switch to translucent glass circle with crisp white `pause.svg`
// (two bright vertical bars separated by a darker center vertical gap!)
let center_gap_luma = {
let p = playing.get_pixel(cx, cy).0;
(p[0] as u32 + p[1] as u32 + p[2] as u32) / 3
};
let left_bar_bright = ((cx - 10)..(cx - 1)).any(|x| {
let p = playing.get_pixel(x, cy).0;
p[0] > 170 && p[1] > 170 && p[2] > 170
});
let right_bar_bright = ((cx + 2)..(cx + 11)).any(|x| {
let p = playing.get_pixel(x, cy).0;
p[0] > 170 && p[1] > 170 && p[2] > 170
});
assert!(
center_gap_luma < 150 && left_bar_bright && right_bar_bright,
"Expected official pause.svg two bright vertical bars with darker center gap on playing glass button at ({},{}): center_luma={}, left_bright={}, right_bright={}",
cx,
cy,
center_gap_luma,
left_bar_bright,
right_bar_bright
);
// 3. Verify paused (`play.svg`) and playing (`pause.svg`) differ significantly inside the 32x32 icon box
let icon_diff = region_mean_abs_diff(&paused, &playing, cx - 15, cy - 16, cx + 15, cy + 16);
assert!(
icon_diff > 20.0,
"Play and Pause icons should look distinct! diff={:.2}",
icon_diff
);
// 4. Verify official `link_rounded_xxs.svg` diagonal `↗` badge on wheel item 5
let mut arrow_bright = 0usize;
for y in 560..690 {
for x in 420..645 {
let [r, g, b] = paused.get_pixel(x, y).0;
if r > 55 && g > 55 && b > 55 {
arrow_bright += 1;
}
}
}
assert!(
arrow_bright >= 25,
"Expected official link_rounded_xxs.svg arrow / wheel item 5 visible, found only {} lit px",
arrow_bright
);
}
// ============================================================================
// EXT 4: ALL 114+ OFFICIAL YANDEX MUSIC SVGs & 3 OFFICIAL MEDIA PNGs INTEGRITY
// ============================================================================
#[test]
fn test_ext_04_all_official_svg_and_media_assets_integrity() {
assert!(
Icon::ALL.len() >= 100,
"Expected at least 100 official Icon variants in Icon::ALL, got {}",
Icon::ALL.len()
);
let opt = resvg::usvg::Options::default();
let mut registry = TextureRegistry::new();
let mut cache = IconCache::new();
for &icon in Icon::ALL {
let raw = icon.raw_svg();
let text = std::str::from_utf8(raw)
.unwrap_or_else(|e| panic!("Icon {:?} SVG is not valid UTF-8: {}", icon, e));
assert!(
!text.contains("var(--"),
"Icon {:?} still contains unresolved CSS variable `var(--...)`!",
icon
);
let tree = resvg::usvg::Tree::from_data(raw, &opt)
.unwrap_or_else(|e| panic!("Icon {:?} failed resvg parse: {}", icon, e));
let mut pixmap = resvg::tiny_skia::Pixmap::new(48, 48).unwrap();
let s = (48.0 / tree.size().width().max(1.0)).min(48.0 / tree.size().height().max(1.0));
resvg::render(
&tree,
resvg::tiny_skia::Transform::from_scale(s, s),
&mut pixmap.as_mut(),
);
let visible = pixmap.data().chunks_exact(4).filter(|p| p[3] > 16).count();
assert!(
visible >= 8,
"Icon {:?} rasterized empty ({} visible pixels)!",
icon,
visible
);
let _tex_id = cache.get(&mut registry, icon);
}
// Verify all 3 official embedded PNG media textures load cleanly
let _ = cache.get_official_heart(&mut registry);
let _ = cache.get_official_search_glow(&mut registry);
let _ = cache.get_official_meteor_glow(&mut registry);
println!(
"Verified all {} official SVGs + 3 official media PNGs!",
Icon::ALL.len()
);
}
// ============================================================================
// EXT 5: ZERO INVENTED NEON CARTOON FALLBACKS WHEN COVERS ARE UNLOADED
// ============================================================================
#[test]
fn test_ext_05_no_invented_cartoon_fallbacks_when_covers_unloaded() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
0.0,
);
let unloaded_wheel: Vec<VibeStationSummary> = (0..7)
.map(|i| VibeStationSummary {
id: format!("st_{}", i),
title: format!("Station {}", i),
subtitle: if i == 2 { Some("Artist".into()) } else { None },
seeds: vec!["user:onyourwave".into()],
cover_uri: Some(format!("test.local/unloaded_wheel_{}/%%", i)),
color_hex: None,
is_artist: i == 2,
has_link_arrow: i == 5,
item_type: if i == 5 {
"PROMO_LINK".into()
} else if i == 2 {
"ARTIST".into()
} else {
"WAVE".into()
},
promo_url: if i == 5 { Some("/collection".into()) } else { None },
is_reshuffle: false,
})
.collect();
shell.app.set_wheel_stations_for_test(unloaded_wheel);
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..4 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
let check_clean_placeholder = |label: &str, x0: u32, y0: u32, x1: u32, y1: u32| {
let mut max_sat = 0u8;
let mut mean_luma = 0.0_f64;
let mut n = 0usize;
for y in y0..y1 {
for x in x0..x1 {
let [r, g, b] = img.get_pixel(x, y).0;
let sat = r.max(g).max(b) - r.min(g).min(b);
max_sat = max_sat.max(sat);
mean_luma += (r as f64 + g as f64 + b as f64) / 3.0;
n += 1;
}
}
mean_luma /= n.max(1) as f64;
assert!(
max_sat <= 14,
"[{}] Invented colorful cartoon fallback detected! max_saturation={} (must be <= 14 neutral gray)",
label,
max_sat
);
assert!(
mean_luma >= 12.0 && mean_luma <= 76.0,
"[{}] Unloaded cover placeholder brightness out of Yandex dark shimmer range: {:.1}",
label,
mean_luma
);
};
// Sidebar unloaded pins
check_clean_placeholder("Sidebar Pin My 2025", 28, 492, 60, 524);
check_clean_placeholder("Sidebar Pin My 2024", 28, 548, 60, 580);
check_clean_placeholder("Sidebar Pin Daily Playlist", 28, 604, 60, 636);
// Center playing track unloaded cover
check_clean_placeholder("My Vibe Center Track Cover", 910, 410, 975, 470);
// Center wheel station unloaded shimmer
check_clean_placeholder("My Vibe Wheel Shimmer", 290, 380, 336, 424);
let _ = std::fs::create_dir_all(output_dir());
let _ = img.save(output_dir().join("my_vibe_clean_unloaded.png"));
}
// ============================================================================
// EXT 6: EXACT sRGB (`css_rgba`) COLORS & TRANSPARENT PLAYER BAR PLAY CUTOUT
// ============================================================================
#[test]
fn test_ext_06_exact_srgb_colors_and_transparent_play_cutout() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::LikedTracks,
ThemeMode::Dark,
Language::En,
0.0,
);
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..4 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
// 1. Sidebar `"Playlist"` subtitle under My Favorites on #000000:
// With exact linear sRGB premultiplied blending (`css_rgba(255,255,255,128)`), peak glyph brightness is ~110..155
let mut peak_playlist_rgb = 0u8;
for y in 454..472 {
for x in 72..145 {
let [r, g, b] = img.get_pixel(x, y).0;
peak_playlist_rgb = peak_playlist_rgb.max(r).max(g).max(b);
}
}
assert!(
(105..=158).contains(&peak_playlist_rgb),
"Sidebar 'Playlist' text color drifted from Yandex css_rgba(255,255,255,128): peak={}",
peak_playlist_rgb
);
// 2. Player Bar Play button (`Icon::PlayFilled` circular #FFFF00 button):
let mut yellow_disc = 0usize;
let mut sum_x = 0u64;
let mut sum_y = 0u64;
for y in 712..784 {
for x in 680..800 {
let p = img.get_pixel(x, y).0;
if is_yandex_yellow(p) {
yellow_disc += 1;
sum_x += x as u64;
sum_y += y as u64;
}
}
}
assert!(
yellow_disc > 750,
"Expected #FFFF00 circular Player Bar Play button, found {} yellow px",
yellow_disc
);
let play_cx = (sum_x / yellow_disc as u64) as u32;
let play_cy = (sum_y / yellow_disc as u64) as u32;
// Exact interior pixel of the Play triangle cutout must reveal the dark player bar surface (NOT pure #000000)
let center_cutout = img.get_pixel(play_cx, play_cy).0;
assert!(
center_cutout[0] >= 16 && center_cutout[0] <= 80
&& center_cutout[1] >= 16 && center_cutout[1] <= 80
&& center_cutout[2] >= 16 && center_cutout[2] <= 80,
"Player Bar Play triangle center cutout ({},{}) must reveal player bar surface (not pure #000000 or yellow), got {:?}",
play_cx,
play_cy,
center_cutout
);
// 3. Content card bg is exact #121212 (18, 18, 18) and outer shell is #000000
let card_px = img.get_pixel(1150, 620).0;
assert!(
card_px[0].abs_diff(18) <= 2 && card_px[1].abs_diff(18) <= 2 && card_px[2].abs_diff(18) <= 2,
"Content card background must be #121212 (18,18,18), got {:?}",
card_px
);
assert_eq!(
img.get_pixel(10, 10).0,
[0, 0, 0],
"Outer shell must be #000000"
);
}
// ============================================================================
// EXT 7: COVER CACHE FAILURE RECOVERY & NON-DEADLOCKING RESILIENCE
// ============================================================================
#[test]
fn test_ext_07_cover_cache_failure_recovery_and_non_deadlock() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut textures = TextureRegistry::new();
let mut cache = CoverCache::new(64, rt.handle().clone());
assert_eq!(
CoverCache::format_url("avatars.yandex.net/get-music-content/1/a/%%", 100),
"https://avatars.yandex.net/get-music-content/1/a/100x100"
);
assert_eq!(
CoverCache::format_url("https://avatars.mds.yandex.net/get-music-misc/2/b/%%", 200),
"https://avatars.mds.yandex.net/get-music-misc/2/b/200x200"
);
assert_eq!(
CoverCache::format_url("//avatars.mds.yandex.net/get-music-misc/3/c/%%", 400),
"https://avatars.mds.yandex.net/get-music-misc/3/c/400x400"
);
for i in 0..20 {
let _ = cache.get_or_fetch(&format!("http://127.0.0.1:1/fail_{}.png", i), 200);
}
let deadline = Instant::now() + Duration::from_secs(6);
while cache.in_flight_count() > 0 && Instant::now() < deadline {
cache.poll_uploads(&mut textures);
std::thread::sleep(Duration::from_millis(25));
}
cache.poll_uploads(&mut textures);
assert_eq!(
cache.in_flight_count(),
0,
"CoverCache leaked in_flight entries after failures (would deadlock all future cover loads)!"
);
assert!(
cache.failed_count() >= 16,
"Expected failed URLs to be recorded cleanly, got {}",
cache.failed_count()
);
let _ = cache.get_or_fetch("http://127.0.0.1:1/after_recovery.png", 200);
assert_eq!(
cache.in_flight_count(),
1,
"CoverCache remained blocked after previous failures drained!"
);
}
// ============================================================================
// EXT 8: OFFICIAL 5.129.0 PUMPKIN WHEEL CATALOG
// ============================================================================
#[test]
fn test_ext_08_official_wheel_catalog_and_visual_proof() {
let pumpkin = YandexApiClient::official_pumpkin_wheel();
assert_eq!(
pumpkin.len(),
7,
"Official Pumpkin wheel should have 7 stations"
);
for st in &pumpkin {
let uri = st
.cover_uri
.as_deref()
.expect("Every Pumpkin wheel station must carry an official Yandex CDN cover URI");
assert!(
uri.starts_with("https://avatars.mds.yandex.net/get-music-misc/") && uri.ends_with("/%%"),
"Unexpected Pumpkin station cover URI: {}",
uri
);
assert!(
!st.seeds.is_empty(),
"Station {} missing Rotor seeds",
st.title
);
}
}
// ============================================================================
// EXT 9: LIGHT THEME VERIFICATION (ZERO HARDCODED DARK SURFACES + HIGH CONTRAST)
// ============================================================================
/// Check if an RGB triple closely matches one of the forbidden hardcoded dark theme surfaces
/// (`#1E1E22`, `#252525`, `#333333`, `#121212`).
fn is_hardcoded_dark_surface(rgb: [u8; 3]) -> bool {
const FORBIDDEN: [[u8; 3]; 4] = [
[0x1E, 0x1E, 0x22], // old hardcoded Profile Popup bg
[0x25, 0x25, 0x25], // old hardcoded Search pill / quick card dark gray
[0x33, 0x33, 0x33], // old hardcoded Dark chip bg
[0x12, 0x12, 0x12], // old hardcoded Dark content card bg
];
FORBIDDEN.iter().any(|&f| {
rgb[0].abs_diff(f[0]) <= 3 && rgb[1].abs_diff(f[1]) <= 3 && rgb[2].abs_diff(f[2]) <= 3
})
}
/// Detect contiguous dark surface patches (20x12 solid blocks) inside a Light-theme region,
/// ignoring thin anti-aliased text strokes and icon pixels!
fn count_forbidden_dark_blocks(img: &RgbImage, x0: u32, y0: u32, x1: u32, y1: u32) -> usize {
let mut bad_blocks = 0usize;
let mut y = y0;
while y + 12 <= y1.min(img.height()) {
let mut x = x0;
while x + 20 <= x1.min(img.width()) {
let mut dark_hits = 0usize;
for dy in 0..12 {
for dx in 0..20 {
if is_hardcoded_dark_surface(img.get_pixel(x + dx, y + dy).0) {
dark_hits += 1;
}
}
}
// A solid >=85% block of a forbidden dark surface color is a genuine hardcoded dark surface!
if dark_hits >= (20 * 12 * 85) / 100 {
bad_blocks += 1;
}
x += 10;
}
y += 6;
}
bad_blocks
}
#[test]
fn test_ext_09_light_theme_zero_dark_surfaces_and_high_contrast() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::LikedTracks,
ThemeMode::Light,
Language::Ru,
0.0,
);
let out_dir = output_dir();
let _ = std::fs::create_dir_all(&out_dir);
let pages: &[(&str, Route)] = &[
("light_favorites", Route::LikedTracks),
("light_for_you", Route::ForYou),
("light_search", Route::Search),
("light_collection", Route::Collection),
];
for &(name, ref route) in pages {
shell.app.set_route_for_test(route.clone());
shell.shell.sidebar_profile_open = false;
shell.shell.sidebar_appearance_open = false;
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..3 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
let _ = img.save(out_dir.join(format!("{}.png", name)));
// 1. Outer shell & sidebar background MUST be #F5F5F5 (245, 245, 245), NOT #000000!
let shell_px = img.get_pixel(10, 10).0;
assert!(
shell_px[0] >= 235 && shell_px[1] >= 235 && shell_px[2] >= 235,
"[{}] Light theme outer shell should be #F5F5F5, got {:?}",
name,
shell_px
);
// 2. Content card whitespace (right margin x=1240, y=220) MUST be pure #FFFFFF (255, 255, 255), NOT #121212!
let card_px = img.get_pixel(1240, 220).0;
assert!(
card_px[0] >= 245 && card_px[1] >= 245 && card_px[2] >= 245,
"[{}] Light theme content card should be #FFFFFF, got {:?}",
name,
card_px
);
// 3. ZERO hardcoded dark surface blocks (#1E1E22 / #252525 / #333333 / #121212) inside content card!
let bad_blocks = count_forbidden_dark_blocks(&img, 240, 44, 1256, 680);
assert_eq!(
bad_blocks, 0,
"[{}] Detected {} hardcoded dark surface blocks (#1E1E22/#252525/#333333/#121212) inside Light theme content card!",
name, bad_blocks
);
// 4. High-contrast dark text pixels (luma < 90) MUST exist on the white content card!
let mut dark_text_px = 0usize;
for y in 48..660 {
for x in 250..1240 {
let [r, g, b] = img.get_pixel(x, y).0;
let luma = (r as u32 + g as u32 + b as u32) / 3;
if luma < 90 {
dark_text_px += 1;
}
}
}
assert!(
dark_text_px >= 600,
"[{}] Light theme missing high-contrast dark text on #FFFFFF (dark_text_px={} < 600)!",
name,
dark_text_px
);
}
// 5. Light Theme Yandex ID Profile Popup + Appearance Submenu!
shell.app.set_route_for_test(Route::LikedTracks);
shell.shell.sidebar_profile_open = true;
shell.shell.sidebar_appearance_open = true;
let mut prof_img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..3 {
prof_img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
let _ = prof_img.save(out_dir.join("light_profile_popup.png"));
// Profile card sits at x=20..340, y~240..690: MUST be bright white #FFFFFF with ZERO dark hardcoded #1E1E22 blocks!
let popup_bad_blocks = count_forbidden_dark_blocks(&prof_img, 24, 260, 336, 680);
assert_eq!(
popup_bad_blocks, 0,
"[light_profile_popup] Detected {} hardcoded dark surface blocks (#1E1E22/#252525/#333333) inside Light theme Profile Popup!",
popup_bad_blocks
);
// Count bright white pixels (#F0..#FF) inside Profile Popup card to confirm crisp white surface
let mut popup_white_px = 0usize;
let mut popup_dark_text_px = 0usize;
for y in 280..670 {
for x in 32..328 {
let [r, g, b] = prof_img.get_pixel(x, y).0;
if r >= 235 && g >= 235 && b >= 235 {
popup_white_px += 1;
} else if r < 90 && g < 90 && b < 90 {
popup_dark_text_px += 1;
}
}
}
assert!(
popup_white_px > 40_000,
"[light_profile_popup] Profile Popup background is not bright white #FFFFFF (white_px={})",
popup_white_px
);
assert!(
popup_dark_text_px > 1_000,
"[light_profile_popup] Profile Popup missing high-contrast dark text/icons on #FFFFFF (dark_px={})",
popup_dark_text_px
);
}
// ============================================================================
// EXT 10: MAXIMIZED TITLEBAR WINDOWS 11 RESTORE DOUBLE-SQUARE ICON
// ============================================================================
#[test]
fn test_ext_10_maximized_titlebar_restore_double_square_icon() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::LikedTracks,
ThemeMode::Dark,
Language::Ru,
0.0,
);
// Warm up
let _ = render_single_frame_ex(&mut vk, &mut shell, 0.0, false);
// Capture unmaximized (10x10 single rounded square) vs maximized (Windows 11 Restore double-square)
let normal_img = render_single_frame_ex(&mut vk, &mut shell, 0.016, false);
let maxed_img = render_single_frame_ex(&mut vk, &mut shell, 0.032, true);
let _ = std::fs::create_dir_all(output_dir());
let _ = maxed_img.save(output_dir().join("titlebar_maximized_restore.png"));
// Maximize/Restore button is at x = 1280 - 92 .. 1280 - 46 = 1188..1234, y = 0..32, center = (1211, 16)
let cx = 1211u32;
let cy = 16u32;
let is_lit = |img: &RgbImage, x: u32, y: u32| -> bool {
let p = img.get_pixel(x, y).0;
p[0] > 90 && p[1] > 90 && p[2] > 90
};
let mut norm_lit = 0usize;
let mut max_lit = 0usize;
for y in (cy - 7)..=(cy + 7) {
for x in (cx - 7)..=(cx + 7) {
if is_lit(&normal_img, x, y) {
norm_lit += 1;
}
if is_lit(&maxed_img, x, y) {
max_lit += 1;
}
}
}
assert!(
norm_lit >= 24 && max_lit >= 28,
"Titlebar Maximize/Restore icon failed to draw crisply: normal_lit={}, maxed_lit={}",
norm_lit,
max_lit
);
// Unmaximized vs Maximized MUST render distinct icons inside the 14x14 glyph box!
let icon_diff = region_mean_abs_diff(&normal_img, &maxed_img, cx - 7, cy - 7, cx + 8, cy + 8);
assert!(
icon_diff >= 12.0,
"Maximized titlebar button did NOT switch to Windows 11 Restore double-square icon! diff={:.2} RGB",
icon_diff
);
// Verify Windows 11 Restore double-square geometry on `maxed_img`:
// Front 8x8 square occupies x=[cx-5..cx+3], y=[cy-3..cy+5]
// Rear 8x8 square occupies x=[cx-3..cx+5], y=[cy-5..cy+3]
// 1) Top edge of rear square (y = cy-5..cy-4, x = cx-2..cx+4) MUST be lit
let rear_top_lit = ((cx - 2)..=(cx + 4)).any(|x| is_lit(&maxed_img, x, cy - 5) || is_lit(&maxed_img, x, cy - 4));
// 2) Front square top edge (y = cy-3..cy-2, x = cx-4..cx+2) MUST ALSO be lit (double horizontal bar!)
let front_top_lit = ((cx - 4)..=(cx + 2)).any(|x| is_lit(&maxed_img, x, cy - 3) || is_lit(&maxed_img, x, cy - 2));
// 3) Right edge of rear square (x = cx+4..cx+5, y = cy-4..cy+2) MUST be lit
let rear_right_lit = ((cy - 4)..=(cy + 2)).any(|y| is_lit(&maxed_img, cx + 4, y) || is_lit(&maxed_img, cx + 5, y));
// 4) Interior center of front square (cx-1, cy+1) MUST stay hollow (dark)!
let front_interior_dark = !is_lit(&maxed_img, cx - 1, cy + 1);
assert!(
rear_top_lit && front_top_lit && rear_right_lit && front_interior_dark,
"Maximized Restore double-square geometry invalid: rear_top={}, front_top={}, rear_right={}, front_hollow={}",
rear_top_lit,
front_top_lit,
rear_right_lit,
front_interior_dark
);
}
// ============================================================================
// EXT 11: SEARCH EMPTY INACTIVE INPUT (ZERO PLACEHOLDER) & MIXES 8px 50% TAB
// ============================================================================
#[test]
fn test_ext_11_search_empty_inactive_input_and_mixes_folder_tab() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::Search,
ThemeMode::Dark,
Language::Ru,
0.0,
);
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..3 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.016);
}
// 1. SEARCH EMPTY INACTIVE INPUT MUST HAVE ZERO PLACEHOLDER TEXT!
// Search pill is at x = 224 + 25 = 249 (exact CDP!), y = 32 + 13 + 12 = 57, h = 40 (y = 57..97).
// Magnifying glass icon ends around x = 291; text region is x = 298..720, y = 63..91.
let pill_bg = img.get_pixel(650, 77).0;
let mut text_like_px = 0usize;
for y in 63..91 {
for x in 298..720 {
let p = img.get_pixel(x, y).0;
let diff = p[0].abs_diff(pill_bg[0]) as u32
+ p[1].abs_diff(pill_bg[1]) as u32
+ p[2].abs_diff(pill_bg[2]) as u32;
if diff > 24 {
text_like_px += 1;
}
}
}
assert_eq!(
text_like_px, 0,
"Empty unfocused Search input rendered unwanted placeholder text ({} non-bg pixels vs pill_bg={:?})!",
text_like_px, pill_bg
);
// 2. MIXES 8px 50%-OPACITY FOLDER TAB VERIFICATION!
// In `search.rs` (exact CDP coordinates):
// inner_r.left = 224 + 25 = 249, avail_w = 994, content_w = 988
// side_pad = 38.2 => first Mix card left = 287.2, width = 114.5 (right = 401.7)
// card_top y = 57 + 40 + 20 + 48 + 36 + 36 + 43 + 28 + 27 = 335
// 8px folder tab: x = 295.2..393.7, y = 335..343 (50% opacity of #6E523C over #121212!)
// Main cover starts at y = 343..457.5
let card_bg = img.get_pixel(265, 338).0; // #121212 content card bg outside Mix card
// 2a. Outside the 8px horizontal inset on the left of the tab (x = 288..292, y = 337..341) MUST be pure card_bg!
for y in 337..341 {
for x in 288..292 {
let p = img.get_pixel(x, y).0;
assert!(
p[0].abs_diff(card_bg[0]) <= 6
&& p[1].abs_diff(card_bg[1]) <= 6
&& p[2].abs_diff(card_bg[2]) <= 6,
"Mixes folder tab missing 8px left inset at ({},{}): got {:?}, expected card_bg {:?}",
x,
y,
p,
card_bg
);
}
}
// 2b. Inside the 8px folder tab (x = 316..372, y = 337..341), pixels MUST be ~50% opacity blend of
// tab_col (#6E523C = 110, 82, 60) over #121212 (18, 18, 18) => expected ~ (64, 50, 39) ± 14!
let mut r_sum = 0u64;
let mut g_sum = 0u64;
let mut b_sum = 0u64;
let mut n = 0u64;
for y in 337..341 {
for x in 316..372 {
let p = img.get_pixel(x, y).0;
r_sum += p[0] as u64;
g_sum += p[1] as u64;
b_sum += p[2] as u64;
n += 1;
}
}
let avg_tab = [
(r_sum / n) as u8,
(g_sum / n) as u8,
(b_sum / n) as u8,
];
// Expected 50% alpha composite of (110, 82, 60) over (18, 18, 18) = (64, 50, 39)
// (Whereas 100% opacity would be (110, 82, 60) and missing tab would be (18, 18, 18)!)
assert!(
avg_tab[0].abs_diff(64) <= 14
&& avg_tab[1].abs_diff(50) <= 14
&& avg_tab[2].abs_diff(39) <= 14,
"Mixes 8px folder tab color/opacity mismatch! Expected ~50% blend [64, 50, 39], got {:?} (card_bg={:?})",
avg_tab,
card_bg
);
// 2c. Main cover below y=343 (e.g. y=355, x=344) MUST be bright/opaque (significantly brighter than 50% tab!)
let cover_px = img.get_pixel(344, 355).0;
assert!(
cover_px[0] > avg_tab[0] + 40,
"Mixes main cover at y=355 should start cleanly below the 8px tab (cover={:?}, tab={:?})",
cover_px,
avg_tab
);
}
// ============================================================================
// EXT 12: PLAYING MY VIBE 16-STOP GRADIENT — ZERO VERTICAL DARK HAIRLINES
// ============================================================================
#[test]
fn test_ext_12_my_vibe_playing_gradient_zero_vertical_seams() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
10.0,
);
// Give the playing track a vivid tangerine average color (#F56E00) so the 16-stop
// horizontal exponential-decay backdrop gradient is bright orange on the right edge.
if let Some(tr) = shell.app.queue.get_mut(0) {
tr.derived_average_hex = Some("#F56E00".into());
}
shell.app.set_vibe_playback_for_test(true, 0.35, 0.25);
// Render settled playing frame (play_fade_t = 1.0)
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..6 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.25);
}
let out_dir = output_dir();
let _ = std::fs::create_dir_all(&out_dir);
let _ = img.save(out_dir.join("my_vibe_playing_gradient.png"));
// 1. Confirm the 16-stop orange gradient is vividly active near the right edge (y=675, x=1265)
let right_px = img.get_pixel(1265, 675).0;
assert!(
right_px[0] > 180 && right_px[1] > 70 && right_px[2] < 40,
"Expected vivid orange 16-stop playing My Vibe gradient at right edge (1265,675), got {:?}",
right_px
);
// 2. Scan horizontal rows across the entire 15-strip boundary span (x = 520..1276)
// at y = 668..692 (below transport row, above AI sparkle & version badge).
// Because the gradient decays monotonically from right -> left, ANY 1px SDF AA dark seam
// between adjacent strips shows up as a sharp local valley where col[x] dips below BOTH
// col[x-1] and col[x+1] (or drops suddenly going rightward)!
for &row_y in &[670u32, 682u32] {
let mut r_vals = Vec::with_capacity(760);
for x in 520..=1276u32 {
r_vals.push(img.get_pixel(x, row_y).0[0] as f32);
}
for i in 1..(r_vals.len() - 1) {
let x = 520 + i as u32;
let prev = r_vals[i - 1];
let curr = r_vals[i];
let next = r_vals[i + 1];
// Check 1px dark valley (seam hairline)
let neighbor_min = prev.min(next);
assert!(
curr + 3.0 >= neighbor_min,
"Vertical dark hairline seam detected across 16-stop My Vibe gradient at ({},{}): R=[{:.0}, {:.0}, {:.0}]!",
x,
row_y,
prev,
curr,
next
);
// Check monotonic non-decreasing R going left -> right (within 2.0 quantization tolerance)
assert!(
curr + 2.0 >= prev,
"Non-monotonic dark drop in playing My Vibe gradient at ({},{}): prev_R={:.0} -> curr_R={:.0}!",
x,
row_y,
prev,
curr
);
}
}
// 3. Verify bottom-right 5.129.0 version badge is NOT clipped at the right edge (x = 1272..1278 has clean orange bg)
let badge_margin_px = img.get_pixel(1275, 775).0;
assert!(
badge_margin_px[0] > 170 && badge_margin_px[2] < 45,
"Bottom-right version badge appears clipped at right edge (1275,775)={:?}",
badge_margin_px
);
}
// ============================================================================
// EXT 13: MY VIBE PAUSE TRANSITION — SMOOTH GRADUAL DECAY (NO ABRUPT 1-FRAME SNAP)
// ============================================================================
#[test]
fn test_ext_13_my_vibe_pause_transition_smoothness() {
use std::sync::atomic::Ordering;
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
12.0,
);
if let Some(tr) = shell.app.queue.get_mut(0) {
tr.derived_average_hex = Some("#F56E00".into());
}
// Start fully settled in playing state (`smooth_playing == 1.0`, `play_fade_t == 1.0`)
shell.app.set_vibe_playback_for_test(true, 0.55, 0.45);
let mut t = 0.0_f64;
for _ in 0..4 {
t += 0.25;
let _ = render_single_frame(&mut vk, &mut shell, t);
}
let playing_before = shell
.vibe_push_constants()
.expect("MyVibe push constants missing")
.playing;
assert!(
playing_before > 0.99,
"Expected settled playing=1.0 before pause, got {}",
playing_before
);
// Live pause toggle (`true -> false`) WITHOUT snapping `smooth_playing`!
shell.app.audio.state.is_playing.store(false, Ordering::SeqCst);
let dt = 1.0_f32 / 60.0;
let mut frames = Vec::with_capacity(10);
let mut playing_curve = Vec::with_capacity(10);
for i in 0..10 {
shell.app.tick_vibe_animation(dt, None);
assert!(
shell.app.needs_continuous_repaint(),
"App must keep repainting while Vibe pause transition is settling (frame {})",
i
);
let p = shell
.vibe_push_constants()
.expect("MyVibe push constants missing")
.playing;
playing_curve.push(p);
t += dt as f64;
frames.push(render_single_frame(&mut vk, &mut shell, t));
}
// 1. `smooth_playing` MUST decay strictly monotonically without snapping to 0.0 on frame 0
assert!(
playing_curve[0] > 0.85 && playing_curve[0] < 0.99,
"smooth_playing snapped instead of gradually decaying on pause frame 0: {:?}",
playing_curve
);
for w in playing_curve.windows(2) {
assert!(
w[1] < w[0],
"smooth_playing must decay strictly monotonically on pause: {:?}",
playing_curve
);
}
assert!(
*playing_curve.last().unwrap() < playing_curve[0] - 0.25 && *playing_curve.last().unwrap() > 0.05,
"Expected smooth exponential decay curve over 10 frames (not instant 0.0 snap), got {:?}",
playing_curve
);
// 2. Rendered pixels across the hero stage + orb MUST transition smoothly (zero single-frame snap > 6.0 RGB!)
let mut max_step_delta = 0.0_f64;
for (idx, w) in frames.windows(2).enumerate() {
let d = region_mean_abs_diff(&w[0], &w[1], 560, 40, 1270, 720);
max_step_delta = max_step_delta.max(d);
assert!(
d < 6.0,
"Abrupt single-frame visual snap on My Vibe pause at frame {}->{}: mean_delta={:.2} RGB (limit < 6.0)!",
idx,
idx + 1,
d
);
}
let total_delta = region_mean_abs_diff(&frames[0], frames.last().unwrap(), 560, 40, 1270, 720);
println!(
"My Vibe pause transition (10 frames @ 60fps): smooth_playing={:.3}->{:.3}, max_step_delta={:.2} RGB, total_delta={:.2} RGB",
playing_curve[0],
playing_curve.last().unwrap(),
max_step_delta,
total_delta
);
assert!(
total_delta > 1.5,
"Pause transition appeared frozen over 10 frames (total_delta={:.2} RGB)",
total_delta
);
}
#[test]
fn test_ext_14_cover_cache_min_capacity_and_cross_res_reuse() {
use yandex_music_rs::app::AppAction;
use yandex_music_rs::covers::{CoverCache, MIN_COVER_CACHE_CAPACITY};
use yandex_music_rs::engine::textures::TextureRegistry;
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.enable_all()
.build()
.expect("tokio runtime");
// 1. Legacy small capacity (e.g. stale `max_cover_cache: 24` in config.json) MUST be floored to >= 128!
let mut cache = CoverCache::new(24, rt.handle().clone());
assert!(
cache.capacity() >= MIN_COVER_CACHE_CAPACITY && cache.capacity() >= 128,
"CoverCache::new(24) must enforce >= 128 floor, got {}",
cache.capacity()
);
cache.set_capacity(16);
assert!(
cache.capacity() >= 128,
"CoverCache::set_capacity(16) must enforce >= 128 floor, got {}",
cache.capacity()
);
// 2. Dense Artist page workload (64 unique covers across sidebar + player + tracks + carousels)
// MUST NOT evict or flicker across repeated frames!
let mut textures = TextureRegistry::new();
let sample_rgba = vec![200u8, 120, 80, 255].repeat(4 * 4);
let mut inserted_ids = Vec::with_capacity(64);
for i in 0..64 {
let uri = format!("test.local/artist_dense_{}/%%", i);
let tid = cache.insert_test_rgba_at_size(&mut textures, &uri, 200, &sample_rgba, 4, 4);
inserted_ids.push((uri, tid));
}
assert_eq!(cache.len(), 64);
for _frame in 0..5 {
cache.poll_uploads(&mut textures);
for (uri, expected_tid) in &inserted_ids {
let hit = cache.get_or_fetch(uri, 200);
assert!(
hit.is_some(),
"Cover {} was evicted/flickered under dense Artist page load!",
uri
);
assert_eq!(hit.unwrap().0, *expected_tid);
}
}
// 3. Cross-resolution mipmap reuse: a cached 400x400 cover MUST satisfy 100x100 and 200x200
// requests immediately without duplicating LRU slots or starting a redundant fetch!
let len_before = cache.len();
let hi_uri = "test.local/hires_artist_cover/%%";
let tid_400 = cache.insert_test_rgba_at_size(&mut textures, hi_uri, 400, &sample_rgba, 4, 4);
assert_eq!(cache.len(), len_before + 1);
let hit_100 = cache
.get_or_fetch(hi_uri, 100)
.expect("400x400 cached cover must satisfy 100x100 request via hardware mipmaps");
let hit_200 = cache
.get_or_fetch(hi_uri, 200)
.expect("400x400 cached cover must satisfy 200x200 request via hardware mipmaps");
assert_eq!(hit_100.0, tid_400);
assert_eq!(hit_200.0, tid_400);
assert_eq!(cache.in_flight_count(), 0);
assert_eq!(
cache.len(),
len_before + 1,
"Cross-resolution reuse must not allocate duplicate LRU entries"
);
// 4. Same-frame eviction protection: 129 unique covers in ONE frame auto-grows instead of evicting frame's own covers!
let mut cache2 = CoverCache::new(128, rt.handle().clone());
let mut textures2 = TextureRegistry::new();
let first_uri = "test.local/same_frame_0/%%";
let first_tid =
cache2.insert_test_rgba_at_size(&mut textures2, first_uri, 200, &sample_rgba, 4, 4);
for i in 1..=130 {
let uri = format!("test.local/same_frame_{}/%%", i);
cache2.insert_test_rgba_at_size(&mut textures2, &uri, 200, &sample_rgba, 4, 4);
}
assert!(
cache2.capacity() > 128,
"Same-frame eviction protection should auto-grow capacity above 128, got {}",
cache2.capacity()
);
assert_eq!(
cache2.get_or_fetch(first_uri, 200).map(|x| x.0),
Some(first_tid),
"First cover rendered in the same frame must not be evicted"
);
// 5. AppAction::SetMaxCoverCache(24) MUST clamp to >= 128
let mut shell = make_base_shell(
rt.handle().clone(),
"TestGPU".into(),
Route::LikedTracks,
ThemeMode::Dark,
Language::En,
0.0,
);
shell.app.dispatch(AppAction::SetMaxCoverCache(24));
assert!(
shell.app.config.max_cover_cache >= 128,
"AppAction::SetMaxCoverCache(24) must clamp to >= 128, got {}",
shell.app.config.max_cover_cache
);
}
#[test]
fn test_ext_15_opengl33_strict_shaders_and_renderer_backend() {
use yandex_music_rs::vulkan::VulkanContext;
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
let gl_shaders = [
"shaders/gl/ui_sdf.vert",
"shaders/gl/ui_sdf.frag",
"shaders/gl/blur.vert",
"shaders/gl/blur.frag",
"shaders/gl/vibe.vert",
"shaders/gl/vibe.frag",
];
let forbidden_gl4_tokens = [
"std430",
"layout(binding",
"layout (binding",
"gl_BaseInstance",
"image2D",
"glDrawArraysInstancedBaseInstance",
"#version 4",
];
for rel in gl_shaders {
let path = root.join(rel);
let src = std::fs::read_to_string(&path)
.unwrap_or_else(|e| panic!("Missing OpenGL 3.3 shader {}: {}", rel, e));
let first_line = src
.lines()
.find(|l| !l.trim().is_empty())
.unwrap_or("")
.trim();
assert_eq!(
first_line, "#version 330 core",
"Shader {} must begin with strict `#version 330 core`, got {:?}",
rel, first_line
);
for tok in forbidden_gl4_tokens {
assert!(
!src.contains(tok),
"Shader {} contains forbidden OpenGL 4.x token `{}` (breaks Intel HD 3000 / OpenGL 3.3 Core!)",
rel, tok
);
}
// Check no SSBO `buffer Name {` declaration
for line in src.lines() {
let trimmed = line.trim_start();
assert!(
!trimmed.starts_with("buffer ") && !trimmed.contains(") buffer "),
"Shader {} contains forbidden GL 4.3 SSBO declaration: {}",
rel, trimmed
);
}
}
// Verify Rust GL backend never uses GL 4.2 `draw_arrays_instanced_base_instance`
// and enforces `UNPACK_ALIGNMENT` for R8 glyph atlas uploads
let ui_gl_src = std::fs::read_to_string(root.join("src/gl/ui_renderer.rs"))
.expect("src/gl/ui_renderer.rs missing");
assert!(
!ui_gl_src.contains("draw_arrays_instanced_base_instance"),
"src/gl/ui_renderer.rs must NOT call GL 4.2 draw_arrays_instanced_base_instance!"
);
assert!(
ui_gl_src.contains("UNPACK_ALIGNMENT"),
"src/gl/ui_renderer.rs must set GL_UNPACK_ALIGNMENT=1 for R8/RGBA8 uploads!"
);
// Verify Debian metadata makes Vulkan optional (`recommends`, not hard `depends`)
let cargo_toml = std::fs::read_to_string(root.join("Cargo.toml")).expect("Cargo.toml");
assert!(
cargo_toml.contains("recommends") && cargo_toml.contains("libgl1"),
"Cargo.toml [package.metadata.deb] should recommend libvulkan1/libgl1 for Debian 13"
);
// Verify hardware Vulkan probe works cleanly without crashing or leaking
assert!(
VulkanContext::has_hardware_vulkan(),
"Expected hardware Vulkan to be detected on test GPU"
);
// Live OpenGL 3.3 Core GPU smoke test: creates an invisible native window + strict OpenGL 3.3 Core
// context, compiles & links all 6 `#version 330 core` shaders on the live driver, uploads textures,
// renders both MyVibe (512x512 Vibe FBO) and LikedTracks (SDF + glyph atlas + mipmapped covers)
// frames, and tears down cleanly without interfering with any running app instance!
#[cfg(windows)]
{
use winit::application::ApplicationHandler;
use winit::dpi::{LogicalSize, PhysicalSize};
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::platform::windows::EventLoopBuilderExtWindows;
use winit::window::{Window, WindowAttributes, WindowId};
use yandex_music_rs::gl::GlContext;
struct GlSmokeApp {
rt: tokio::runtime::Handle,
result: Option<Result<(String, u64), String>>,
gl: Option<GlContext>,
window: Option<std::sync::Arc<Window>>,
}
impl ApplicationHandler for GlSmokeApp {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
if self.result.is_some() {
return;
}
let attrs = WindowAttributes::default()
.with_title("GL 3.3 Core Smoke Test")
.with_inner_size(LogicalSize::new(800.0, 600.0))
.with_visible(false);
match GlContext::create_window_and_context(event_loop, attrs) {
Ok((win, mut gl)) => {
let gpu = gl.gpu_name.clone();
let mut shell = make_base_shell(
self.rt.clone(),
gpu.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::En,
12.0,
);
let sz = PhysicalSize::new(800, 600);
let mut err: Option<String> = None;
for (idx, route) in [Route::MyVibe, Route::LikedTracks, Route::Search]
.into_iter()
.enumerate()
{
shell.app.set_route_for_test(route);
let (out, _) = shell.render_frame(
Vec2::new(800.0, 600.0),
1.0,
idx as f64 * 0.016,
false,
);
if let Err(e) = gl.render_frame(
sz,
1.0,
shell.palette.clear_color_f32(),
shell.vibe_push_constants(),
&out.texture_uploads,
&out.display_list,
) {
err = Some(format!("GlContext::render_frame failed: {e}"));
break;
}
}
let vram = gl.estimated_vram_bytes();
self.gl = Some(gl);
self.window = Some(win);
self.result = Some(match err {
Some(e) => Err(e),
None => Ok((gpu, vram)),
});
}
Err(e) => {
self.result = Some(Err(format!("GlContext init failed: {e}")));
}
}
// Drop GL context BEFORE window inside event loop exit
self.gl = None;
self.window = None;
event_loop.exit();
}
fn window_event(&mut self, _: &ActiveEventLoop, _: WindowId, _: WindowEvent) {}
}
let rt = tokio::runtime::Runtime::new().unwrap();
let event_loop = EventLoop::builder()
.with_any_thread(true)
.build()
.expect("Failed to create winit event loop for GL smoke test");
let mut app = GlSmokeApp {
rt: rt.handle().clone(),
result: None,
gl: None,
window: None,
};
event_loop
.run_app(&mut app)
.expect("GL smoke event loop failed");
let (gpu_name, vram_bytes) = app
.result
.expect("GL smoke app never reached resumed()")
.expect("Live OpenGL 3.3 Core smoke test failed");
assert!(
!gpu_name.is_empty() && vram_bytes > 0,
"Expected non-empty GL gpu_name and allocated VRAM, got ({gpu_name:?}, {vram_bytes})"
);
println!(
"Live OpenGL 3.3 Core smoke test PASS: gpu='{}', vram={:.2} MB (3 routes rendered cleanly)",
gpu_name,
vram_bytes as f64 / (1024.0 * 1024.0)
);
}
}