yandex-music-rs/tests/parity_extended.rs

2595 lines
98 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! 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(),
default_email: Some("marwy@yandex.ru".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,
fade: 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,
fade: 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)
);
}
}
#[test]
fn test_ext_16_yandex_id_popup_and_words_card_visual_parity() {
use yandex_music_rs::api::models::{WordsCard, WordsCardSource};
use yandex_music_rs::engine::types::Pos2;
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let out_dir = output_dir();
let _ = std::fs::create_dir_all(&out_dir);
// 1. Dark Theme Yandex ID v2.79.0 Account Popup + Appearance Popover (`dark_profile_popup.png`)
{
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::LikedTracks,
ThemeMode::Dark,
Language::Ru,
0.0,
);
shell.shell.sidebar_profile_open = true;
shell.shell.sidebar_appearance_open = true;
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("dark_profile_popup.png"));
// Verify `#1F1F24` dark Yandex ID card surface inside x=32..320, y=240..660
let mut card_bg_px = 0usize;
let mut bright_text_px = 0usize;
for y in 240..660 {
for x in 32..320 {
let [r, g, b] = img.get_pixel(x, y).0;
if (r as i32 - 0x1F).abs() <= 6
&& (g as i32 - 0x1F).abs() <= 6
&& (b as i32 - 0x24).abs() <= 6
{
card_bg_px += 1;
} else if r >= 220 && g >= 220 && b >= 225 {
bright_text_px += 1;
}
}
}
assert!(
card_bg_px > 40_000,
"[dark_profile_popup] Expected Yandex ID #1F1F24 dark surface (got {} px)",
card_bg_px
);
assert!(
bright_text_px > 1_200,
"[dark_profile_popup] Expected high-contrast #FAFAFF text/icons (got {} px)",
bright_text_px
);
// Verify Appearance submenu popover rendered to the right of the card (x=345..555)
let mut sub_bg_px = 0usize;
for y in 420..660 {
for x in 348..555 {
let [r, g, b] = img.get_pixel(x, y).0;
if (r as i32 - 0x2D).abs() <= 8
&& (g as i32 - 0x2D).abs() <= 8
&& (b as i32 - 0x34).abs() <= 8
{
sub_bg_px += 1;
}
}
}
assert!(
sub_bg_px > 10_000,
"[dark_profile_popup] Expected Yandex ID #2D2D34 Appearance popover (got {} px)",
sub_bg_px
);
}
// 2. My Vibe official 5.129.0 `WordsCard` + `WordsCardPopoverDesktop` (`my_vibe_words_popover.png`)
{
// Static guard: fake AI Vibe-settings string MUST be completely gone from `src/views/my_vibe.rs`
let mv_src = std::fs::read_to_string(
Path::new(env!("CARGO_MANIFEST_DIR")).join("src/views/my_vibe.rs"),
)
.expect("read src/views/my_vibe.rs");
assert!(
!mv_src.contains("Мою волну по настроению и характеру"),
"Fake AI Vibe-settings phrase must be removed from WordsCard in src/views/my_vibe.rs!"
);
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::Ru,
108.0,
);
shell.app.words_cards.insert(
"t_1".into(),
WordsCard {
id: "wc_test_1".into(),
track_id: "t_1".into(),
text: "Трек вдохновлён бразильским фонком и энергичными рейвами 2000-х".into(),
tags: vec!["FACT".into()],
action: None,
actions: vec![WordsCardSource {
title: "Подробнее об артисте".into(),
url: "https://music.yandex.ru".into(),
favicon_url: None,
}],
big_card_ids: Vec::new(),
feedback_state: None,
},
);
// Warm up WordsCard layout (renders State B around cx~943, ai_y~732)
let before = render_single_frame(&mut vk, &mut shell, 0.0);
let click_pos = Pos2::new(943.0, 732.0);
// Simulate genuine left-click press + release on WordsCard to toggle WordsCardPopoverDesktop
shell.ui.input.pointer_pos = Some(click_pos);
shell.ui.input.left_down = true;
shell.ui.input.left_pressed = true;
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
shell.ui.input.left_down = false;
shell.ui.input.left_released = true;
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
let after = render_single_frame(&mut vk, &mut shell, 0.048);
let _ = after.save(out_dir.join("my_vibe_words_popover.png"));
// Verify WordsCardPopoverDesktop actually appeared above WordsCard (y=500..700, x=810..1075)
let popover_delta = region_mean_abs_diff(&before, &after, 810, 500, 1075, 700);
assert!(
popover_delta > 4.0,
"[my_vibe_words_popover] Clicking WordsCard did not open WordsCardPopoverDesktop (delta={:.2} RGB)",
popover_delta
);
assert!(
!shell.app.vibe_modal_open,
"[my_vibe_words_popover] Clicking WordsCard MUST NOT open fake Vibe settings modal!"
);
}
// 3. Official 1-to-1 `VibeResetButton` unified pill + `0.1.0` version badge (`my_vibe_context_pill.png`)
{
use yandex_music_rs::app::APP_VERSION;
assert_eq!(
APP_VERSION,
env!("CARGO_PKG_VERSION"),
"APP_VERSION must match Cargo.toml"
);
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());
}
shell.app.is_vibe_active = false;
shell.app.context_name = "My Favorites".into();
shell.app.context_key = "likes".into();
shell.app.set_vibe_playback_for_test(true, 0.45, 0.35);
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.2);
}
let _ = img.save(out_dir.join("my_vibe_context_pill.png"));
// Verify bright electric yellow pixels (#FFFF00) inside top-center VibeResetButton pill (y=32..80, x=830..1060)
let mut pill_yellow_px = 0usize;
for y in 32..80 {
for x in 830..1060 {
if is_yandex_yellow(img.get_pixel(x, y).0) {
pill_yellow_px += 1;
}
}
}
assert!(
pill_yellow_px >= 400,
"[my_vibe_context_pill] Expected electric yellow text + filled yellow close circle inside unified VibeResetButton pill, found {} yellow px",
pill_yellow_px
);
}
}
#[test]
fn test_ext_17_for_you_collection_concerts_words_fullscreen() {
use yandex_music_rs::api::models::{
AlbumSummary, ConcertItem, NewReleaseItem, VibePickItem, VibePickTab, WordsBigCard,
WordsCard, WordsCardSource,
};
use yandex_music_rs::engine::WidgetId;
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let out_dir = output_dir();
let _ = std::fs::create_dir_all(&out_dir);
// 1. Official `For You` scrolled down: sticky frosted header + circular NewReleases + More Picks (`for_you_new_releases_picks.png`)
{
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::ForYou,
ThemeMode::Dark,
Language::En,
0.0,
);
let mk_album = |id: &str, title: &str, artist: &str| AlbumSummary {
id: id.into(),
title: title.into(),
version: None,
year: Some(2026),
cover_uri: None,
artists: vec![ArtistSummary {
id: format!("art_{id}"),
name: artist.into(),
cover_uri: None,
genres: vec![],
}],
track_count: 12,
genre: Some("electronic".into()),
is_explicit: false,
content_type: Some("album".into()),
};
shell.app.landing.rich_new_releases = vec![
NewReleaseItem {
album: mk_album("nr1", "Neon Horizon", "SALUKI"),
artist_cover_uri: None,
cover_color: Some("#3B4CA8".into()),
release_date: Some("2026-11-20".into()),
},
NewReleaseItem {
album: mk_album("nr2", "Velvet Pulse", "Mirele"),
artist_cover_uri: None,
cover_color: Some("#7B2D5F".into()),
release_date: Some("2026-11-18".into()),
},
NewReleaseItem {
album: mk_album("nr3", "Night Drive", "SLAVA MARLOW"),
artist_cover_uri: None,
cover_color: Some("#1E6B52".into()),
release_date: Some("2026-11-15".into()),
},
NewReleaseItem {
album: mk_album("nr4", "Solar Flare", "OG BLESS"),
artist_cover_uri: None,
cover_color: Some("#8F4A1E".into()),
release_date: Some("2026-11-12".into()),
},
];
shell.app.landing.vibe_pick_tabs = vec![
VibePickTab {
title: "Mood".into(),
items: vec![
VibePickItem {
title: "Energetic".into(),
header: "Vibe".into(),
seeds: vec!["mood:energetic".into()],
color_hex: Some("#D94E2A".into()),
background_image_url: None,
image_url: None,
},
VibePickItem {
title: "Night Focus".into(),
header: "Vibe".into(),
seeds: vec!["mood:calm".into()],
color_hex: Some("#2F55A4".into()),
background_image_url: None,
image_url: None,
},
VibePickItem {
title: "Dreamy Synth".into(),
header: "Vibe".into(),
seeds: vec!["genre:electronic".into()],
color_hex: Some("#7C3AED".into()),
background_image_url: None,
image_url: None,
},
],
},
VibePickTab {
title: "Activity".into(),
items: vec![VibePickItem {
title: "Workout".into(),
header: "Vibe".into(),
seeds: vec!["activity:workout".into()],
color_hex: Some("#0F766E".into()),
background_image_url: None,
image_url: None,
}],
},
VibePickTab {
title: "Genres".into(),
items: vec![],
},
];
// Warm up layout so scroll content height is computed, then scroll to show New Releases + More Picks + sticky switcher
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
shell
.ui
.scrolls
.jump_to_y(WidgetId::new("foryou_page_scroll"), 860.0);
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
let img = render_single_frame(&mut vk, &mut shell, 0.048);
let _ = img.save(out_dir.join("for_you_new_releases_picks.png"));
// Verify colored NewRelease cards / More Picks cards rendered non-flat rich pixels in content card
let mut colored_px = 0usize;
for y in 110..680 {
for x in 250..1240 {
let [r, g, b] = img.get_pixel(x, y).0;
let max_c = r.max(g).max(b);
let min_c = r.min(g).min(b);
if max_c.saturating_sub(min_c) >= 24 {
colored_px += 1;
}
}
}
assert!(
colored_px > 5_000,
"[for_you_new_releases_picks] Expected colored New Releases / More Picks cards, found only {} chromatic px",
colored_px
);
}
// 2. Official `My Collection` vertical feed (`my_collection_official.png`)
{
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::Collection,
ThemeMode::Dark,
Language::En,
0.0,
);
let extra_tracks = [
("c_1", "MONTAGEM TENTA", "KYOR", 141_000),
("c_2", "Midnight Sun", "SuperSolar", 184_000),
("c_3", "BANG A RANG", "GSTRNM", 100_000),
("c_4", "BOSS BITCH TEKK", "wharoxmane", 107_000),
("c_5", "Neon Rain", "Mirele", 192_000),
("c_6", "Skyline Pulse", "SALUKI", 168_000),
("c_7", "Electric Horizon", "SLAVA MARLOW", 155_000),
("c_8", "Deep Focus", "OG BLESS", 210_000),
];
shell.app.liked_tracks = extra_tracks
.iter()
.map(|(id, title, art, dur)| Track {
id: (*id).into(),
title: (*title).into(),
version: None,
artists: vec![ArtistSummary {
id: format!("ca_{id}"),
name: (*art).into(),
cover_uri: None,
genres: vec![],
}],
album_id: Some(format!("calb_{id}")),
album_title: Some((*title).into()),
duration_ms: *dur,
cover_uri: None,
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,
fade: None,
})
.collect();
shell.app.liked_artists = ["SALUKI", "Mirele", "KYOR", "SuperSolar", "GSTRNM", "OG BLESS"]
.iter()
.enumerate()
.map(|(i, name)| ArtistSummary {
id: format!("la_{i}"),
name: (*name).into(),
cover_uri: None,
genres: vec![],
})
.collect();
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
let img = render_single_frame(&mut vk, &mut shell, 0.032);
let _ = img.save(out_dir.join("my_collection_official.png"));
// Verify pink-magenta colored "color" word in subtitle + crimson 3D heart icon present,
// and ZERO old yellow-bordered My Favorites hero card!
let mut pink_subtitle_px = 0usize;
for y in 75..125 {
for x in 250..520 {
let [r, g, b] = img.get_pixel(x, y).0;
if r > 170 && b > 100 && (r as u16) > (g as u16) + 50 {
pink_subtitle_px += 1;
}
}
}
assert!(
pink_subtitle_px >= 15,
"[my_collection_official] Expected magenta-colored subtitle word 'color', found {} px",
pink_subtitle_px
);
}
// 3. Official `ConcertsPage` (`concerts_official.png`)
{
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::Concerts,
ThemeMode::Dark,
Language::Ru,
0.0,
);
shell.app.concerts = vec![
ConcertItem {
id: "con_1".into(),
title: "SALUKI — Большой сольный концерт".into(),
artist_name: "SALUKI".into(),
city: "Москва".into(),
place: "VK Stadium".into(),
date: "14 дек, 20:00".into(),
cover_uri: None,
afisha_url: Some("https://afisha.yandex.ru".into()),
min_price: Some(2500),
currency: Some("RUB".into()),
cashback_percent: Some(15),
cashback_title: Some("Кешбэк 15%".into()),
cover_color: Some("#4C2A85".into()),
event_kind: Some("concert".into()),
},
ConcertItem {
id: "con_2".into(),
title: "Mirele — Акустический вечер".into(),
artist_name: "Mirele".into(),
city: "Санкт-Петербург".into(),
place: "A2 Green Concert".into(),
date: "21 дек, 19:30".into(),
cover_uri: None,
afisha_url: Some("https://afisha.yandex.ru".into()),
min_price: Some(1900),
currency: Some("RUB".into()),
cashback_percent: Some(10),
cashback_title: None,
cover_color: Some("#1D5B79".into()),
event_kind: Some("concert".into()),
},
ConcertItem {
id: "con_3".into(),
title: "SLAVA MARLOW — Live Tour".into(),
artist_name: "SLAVA MARLOW".into(),
city: "Казань".into(),
place: "Korston Club Hotel".into(),
date: "28 дек, 20:00".into(),
cover_uri: None,
afisha_url: Some("https://afisha.yandex.ru".into()),
min_price: Some(2200),
currency: Some("RUB".into()),
cashback_percent: Some(20),
cashback_title: None,
cover_color: Some("#8C2F39".into()),
event_kind: Some("concert".into()),
},
ConcertItem {
id: "con_4".into(),
title: "Электрофорез — Зимний сет".into(),
artist_name: "Электрофорез".into(),
city: "Москва".into(),
place: "Урбан".into(),
date: "5 янв, 20:00".into(),
cover_uri: None,
afisha_url: Some("https://afisha.yandex.ru".into()),
min_price: Some(1700),
currency: Some("RUB".into()),
cashback_percent: Some(10),
cashback_title: None,
cover_color: Some("#2D4F1E".into()),
event_kind: Some("concert".into()),
},
];
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
let img = render_single_frame(&mut vk, &mut shell, 0.032);
let _ = img.save(out_dir.join("concerts_official.png"));
// Verify Top 3 poster cards (aspect 0.963, h~320px) + cashback pills + yellow price CTAs rendered cleanly
let mut poster_chromatic_px = 0usize;
for y in 160..540 {
for x in 250..1240 {
let [r, g, b] = img.get_pixel(x, y).0;
if r.max(g).max(b).saturating_sub(r.min(g).min(b)) >= 20 {
poster_chromatic_px += 1;
}
}
}
assert!(
poster_chromatic_px > 10_000,
"[concerts_official] Expected Top 3 concert poster cards + cashback pills, found {} chromatic px",
poster_chromatic_px
);
}
// 4. Official `WordsCardFullscreen` (`words_fullscreen_official.png`)
{
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::MyVibe,
ThemeMode::Dark,
Language::Ru,
108.0,
);
shell.app.words_cards.insert(
"t_1".into(),
WordsCard {
id: "wc_fs_1".into(),
track_id: "t_1".into(),
text: "MONTAGEM TENTA сочетает бразильский фонк и жёсткие хардстайл-кики.".into(),
tags: vec!["FACT".into()],
action: None,
actions: vec![],
big_card_ids: vec!["bc_1".into()],
feedback_state: None,
},
);
shell.app.words_big_card_open = true;
shell.app.words_big_card_loading = false;
shell.app.words_big_card = Some(WordsBigCard {
id: "bc_1".into(),
text: "MONTAGEM TENTA (Hardstyle) — взрывной кроссовер бразильского фонка и европейского хардстайла с плотным саб-басом и стремительным ритмом.".into(),
actions: vec![WordsCardSource {
title: "Обсудить с Алисой AI".into(),
url: "https://alice.yandex.ru".into(),
favicon_url: None,
}],
});
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
let img = render_single_frame(&mut vk, &mut shell, 0.032);
let _ = img.save(out_dir.join("words_fullscreen_official.png"));
// Verify purple Alice ring (#8B5CF6) rendered inside the centered source pill
let mut alice_purple_px = 0usize;
for y in 360..600 {
for x in 560..960 {
let [r, g, b] = img.get_pixel(x, y).0;
if b > 160 && r > 90 && (b as u16) > (g as u16) + 50 {
alice_purple_px += 1;
}
}
}
assert!(
alice_purple_px >= 15,
"[words_fullscreen_official] Expected purple Alice AI icon inside source pill, found {} px",
alice_purple_px
);
}
}
#[test]
fn test_ext_18_qa_sync_lyrics_scroll_concerts_duplicate_albums() {
use std::sync::atomic::Ordering;
use yandex_music_rs::api::models::{AlbumSummary, LyricLine, TrackLyrics};
use yandex_music_rs::app::CollectionTab;
use yandex_music_rs::engine::input::{InputState, ZLayer};
use yandex_music_rs::engine::scroll::ScrollState;
use yandex_music_rs::engine::types::{Pos2, Rect};
use yandex_music_rs::engine::widgets::cover_fit_uv;
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
let out_dir = output_dir();
let _ = std::fs::create_dir_all(&out_dir);
// 1. 1-to-1 Official FullscreenPlayerDesktop 50/50 SyncLyrics (`fullscreen_sync_lyrics_official.png`)
{
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::LikedTracks,
ThemeMode::Dark,
Language::Ru,
0.0,
);
if let Some(tr) = shell.app.queue.get_mut(0) {
tr.derived_average_hex = Some("#1A2238".into());
}
shell.app.current_lyrics = Some(TrackLyrics {
track_id: "t_1".into(),
is_synced: true,
lines: vec![
LyricLine { time_ms: 4_000, text: "Первая строчка уходит вверх".into() },
LyricLine { time_ms: 10_000, text: "Вторая строчка уже прозвучала".into() },
LyricLine { time_ms: 16_000, text: "Третья строчка перед текущей".into() },
LyricLine { time_ms: 21_000, text: "Активная яркая строка прямо по центру".into() },
LyricLine { time_ms: 28_000, text: "Следующая строчка ждёт своей очереди".into() },
LyricLine { time_ms: 35_000, text: "Пятая строчка чуть дальше вниз".into() },
LyricLine { time_ms: 42_000, text: "Шестая строчка в приглушённом цвете".into() },
LyricLine { time_ms: 49_000, text: "Финальная строчка композиции".into() },
],
writers: Some("Test Writer".into()),
major: Some("Genius".into()),
});
shell.app.fullscreen_open = true;
shell.app.fullscreen_lyrics_open = true;
shell.app.audio.state.position_ms.store(22_000, Ordering::SeqCst);
shell.app.audio.state.is_playing.store(true, Ordering::SeqCst);
shell.shell.fs_lyrics_upper_until = 0.0;
shell.shell.fs_lyrics_manual_until = 0.0;
// Settle 0.45s split + opacity animations cleanly with mouse idle
let mut img = render_single_frame(&mut vk, &mut shell, 0.0);
for f in 1..25 {
img = render_single_frame(&mut vk, &mut shell, f as f64 * 0.05);
}
let _ = img.save(out_dir.join("fullscreen_sync_lyrics_official.png"));
// Verify bright white active line near 40vh (y=250..410, x=600..1220)
let mut active_bright_px = 0usize;
for y in 250..410 {
for x in 600..1220 {
let [r, g, b] = img.get_pixel(x, y).0;
if r >= 200 && g >= 200 && b >= 200 {
active_bright_px += 1;
}
}
}
assert!(
active_bright_px >= 600,
"[fullscreen_sync_lyrics] Expected bright white active line near 40vh, found {} px",
active_bright_px
);
// Verify past lines above active (y=60..210, x=640..1180) are hidden (0 bright white px) when mouse is idle
let mut past_bright_px = 0usize;
for y in 60..210 {
for x in 640..1180 {
let [r, g, b] = img.get_pixel(x, y).0;
if r >= 170 && g >= 170 && b >= 170 {
past_bright_px += 1;
}
}
}
assert_eq!(
past_bright_px, 0,
"[fullscreen_sync_lyrics] Past upper lines must be hidden (opacity 0.0) when mouse is idle, found {} bright px",
past_bright_px
);
// Verify Volume button is anchored in the bottom-right corner (center ~(1236, 760)), NOT bottom-center
let mut vol_corner_bright_px = 0usize;
for y in 740..780 {
for x in 1216..1256 {
let [r, g, b] = img.get_pixel(x, y).0;
if r >= 160 && g >= 160 && b >= 160 {
vol_corner_bright_px += 1;
}
}
}
assert!(
vol_corner_bright_px >= 25,
"[fullscreen_sync_lyrics] Expected Volume icon anchored in bottom-right corner (1236,760), found {} bright px",
vol_corner_bright_px
);
}
// 2. Horizontal Scroll Isolation: plain vertical wheel MUST NOT scroll horizontal-only carousels!
{
let vp = Rect::from_xywh(0.0, 0.0, 600.0, 200.0);
let mut st = ScrollState::new();
st.content_size = Vec2::new(2000.0, 200.0);
let mut inp = InputState::new();
inp.pointer_pos = Some(Pos2::new(200.0, 100.0));
inp.wheel_delta = Vec2::new(0.0, -120.0);
st.update(&inp, ZLayer::Base, vp, false, true);
assert!(
st.target.x.abs() < 0.001,
"Horizontal-only ScrollState must ignore plain vertical wheel_delta.y, got target.x={}",
st.target.x
);
// Shift + vertical wheel scrolls horizontally
inp.modifiers.shift = true;
st.update(&inp, ZLayer::Base, vp, false, true);
assert!(
st.target.x > 50.0,
"Shift + wheel_delta.y must scroll horizontally, got target.x={}",
st.target.x
);
// Trackpad horizontal wheel_delta.x scrolls horizontally without Shift
st.reset();
inp.modifiers.shift = false;
inp.wheel_delta = Vec2::new(-120.0, 0.0);
st.update(&inp, ZLayer::Base, vp, false, true);
assert!(
st.target.x > 50.0,
"Horizontal wheel_delta.x must scroll horizontally, got target.x={}",
st.target.x
);
}
// 3. `object-fit: cover` (`cover_fit_uv`) preserves aspect ratio with zero stretching
{
let uv_wide = cover_fit_uv(400, 400, Rect::from_xywh(0.0, 0.0, 300.0, 150.0), 0.35);
assert!(
(uv_wide.w - 1.0).abs() < 1e-4 && (uv_wide.h - 0.5).abs() < 1e-4,
"400x400 in 300x150 expected uv (w=1.0, h=0.5), got {:?}",
uv_wide
);
let uv_portrait = cover_fit_uv(200, 400, Rect::from_xywh(0.0, 0.0, 200.0, 200.0), 0.35);
assert!(
(uv_portrait.w - 1.0).abs() < 1e-4 && (uv_portrait.h - 0.5).abs() < 1e-4,
"200x400 in 200x200 expected uv (w=1.0, h=0.5), got {:?}",
uv_portrait
);
}
// 4. Concerts Active Icon (`Icon::ConcertsSelected`) rasterizes with symmetric filled ticket silhouette
{
let opt = resvg::usvg::Options::default();
let tree = resvg::usvg::Tree::from_data(Icon::ConcertsSelected.raw_svg(), &opt)
.expect("ConcertsSelected SVG parse failed");
let sz = 48u32;
let mut pixmap = resvg::tiny_skia::Pixmap::new(sz, sz).unwrap();
let sx = sz as f32 / tree.size().width();
let sy = sz as f32 / tree.size().height();
resvg::render(
&tree,
resvg::tiny_skia::Transform::from_scale(sx, sy),
&mut pixmap.as_mut(),
);
let data = pixmap.data();
let mut left_cov = 0u64;
let mut right_cov = 0u64;
for y in 0..sz {
for x in 0..sz {
let a = data[((y * sz + x) * 4 + 3) as usize] as u64;
if x < sz / 2 {
left_cov += a;
} else {
right_cov += a;
}
}
}
let total = left_cov + right_cov;
assert!(
total > 40_000,
"ConcertsSelected SVG coverage too small ({})",
total
);
let asym = (left_cov as i64 - right_cov as i64).unsigned_abs() as f64 / total as f64;
assert!(
asym < 0.05,
"ConcertsSelected SVG is asymmetric (left={}, right={}, asym={:.3})",
left_cov,
right_cov,
asym
);
}
// 5. Duplicate-Title Albums render distinctly in Collection overview + Albums sub-view with zero panics
{
let mk_dup = |id: &str, version: Option<&str>| AlbumSummary {
id: id.into(),
title: "Same Title Album".into(),
version: version.map(String::from),
year: Some(2025),
cover_uri: None,
artists: vec![ArtistSummary {
id: "art_dup".into(),
name: "Test Artist".into(),
cover_uri: None,
genres: vec![],
}],
track_count: 10,
genre: Some("pop".into()),
is_explicit: false,
content_type: Some("album".into()),
};
let std_alb = mk_dup("alb_std", None);
let dlx_alb = mk_dup("alb_dlx", Some("Deluxe"));
assert_eq!(std_alb.full_title(), "Same Title Album");
assert_eq!(dlx_alb.full_title(), "Same Title Album (Deluxe)");
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::Collection,
ThemeMode::Dark,
Language::Ru,
0.0,
);
shell.app.liked_albums = vec![std_alb, dlx_alb];
shell.app.collection_tab = CollectionTab::Tracks;
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let _ = render_single_frame(&mut vk, &mut shell, 0.016);
shell.app.collection_tab = CollectionTab::Albums;
let _ = render_single_frame(&mut vk, &mut shell, 0.032);
let img_albums = render_single_frame(&mut vk, &mut shell, 0.048);
// Confirm both album cards rendered distinct non-empty content in the Albums grid (x=250..650, y=130..360)
let mut card1_lit = 0usize;
let mut card2_lit = 0usize;
for y in 130..360 {
for x in 250..430 {
let [r, g, b] = img_albums.get_pixel(x, y).0;
if r > 30 || g > 30 || b > 30 {
card1_lit += 1;
}
}
for x in 450..630 {
let [r, g, b] = img_albums.get_pixel(x, y).0;
if r > 30 || g > 30 || b > 30 {
card2_lit += 1;
}
}
}
assert!(
card1_lit > 2_000 && card2_lit > 2_000,
"Expected both duplicate-title album cards to render distinctly (card1={}, card2={})",
card1_lit,
card2_lit
);
}
}
#[test]
fn test_ext_15_release_notes_modal_update_notification_and_download_ring() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
for theme in [ThemeMode::Dark, ThemeMode::Light] {
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::LikedTracks,
theme,
Language::Ru,
0.0,
);
if let Some(first_id) = shell.app.liked_tracks.first().map(|t| t.id.clone()) {
shell.app.downloading_track_ids.insert(first_id.clone());
shell.app.downloading_track_progress.insert(first_id, 0.45);
shell.app.download_batch_total = 2;
shell.app.download_batch_done = 0;
}
shell.app.available_update = Some(yandex_music_rs::api::models::UpdateInfo {
version: "9.9.9".into(),
html_url: "https://git.tatar/marwy/yandex-music-rs/releases/tag/v9.9.9".into(),
date: "2026-11-28".into(),
body: "## Новое\n- Тестовое обновление".into(),
});
shell.app.release_notes_modal_open = true;
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let img = render_single_frame(&mut vk, &mut shell, 0.016);
assert!(img.width() == NATIVE_W && img.height() == NATIVE_H);
}
}
#[test]
fn test_ext_19_official_settings_sound_quality_equalizer_and_shortcuts_modals() {
let rt = tokio::runtime::Runtime::new().unwrap();
let mut vk = HeadlessVulkanRenderer::new(NATIVE_W, NATIVE_H).expect("Vulkan init failed");
for theme in [ThemeMode::Dark, ThemeMode::Light] {
let mut shell = make_base_shell(
rt.handle().clone(),
vk.gpu_name.clone(),
Route::Settings,
theme,
Language::Ru,
0.0,
);
shell.app.config.eq_enabled = true;
shell.app.config.eq_preamp = 1.15;
shell.app.eq_popover_open = true;
let _ = render_single_frame(&mut vk, &mut shell, 0.0);
let img_qs = render_single_frame(&mut vk, &mut shell, 0.016);
assert!(img_qs.width() == NATIVE_W && img_qs.height() == NATIVE_H);
shell.app.config.eq_enabled = false;
shell.app.eq_popover_open = false;
shell.app.equalizer_modal_open = true;
let img_eq = render_single_frame(&mut vk, &mut shell, 0.032);
assert!(img_eq.width() == NATIVE_W && img_eq.height() == NATIVE_H);
shell.app.equalizer_modal_open = false;
shell.app.shortcuts_modal_open = true;
let img_sc = render_single_frame(&mut vk, &mut shell, 0.048);
assert!(img_sc.width() == NATIVE_W && img_sc.height() == NATIVE_H);
shell.app.shortcuts_modal_open = false;
for &style in yandex_music_rs::config::PlayerThumbStyle::ALL {
shell.app.config.player_thumb = style;
let img_th = render_single_frame(&mut vk, &mut shell, 0.064);
assert!(img_th.width() == NATIVE_W && img_th.height() == NATIVE_H);
}
}
}