using XFESystem.Branding; using Xunit; namespace XFESystem.Boot.Tests; public unsafe class BootVisualTests { [Theory] [InlineData(0, true, false, false)] [InlineData(2399, true, false, false)] [InlineData(2400, true, true, false)] [InlineData(2400, false, false, true)] [InlineData(60000, false, false, true)] [InlineData(60000, true, true, false)] public void ReadinessRequiresBothCompletedIntroAndCompletedApplicationFrame(ulong elapsed, bool ready, bool release, bool waiting) { Assert.Equal(release, BootVisual.ShouldRelease(elapsed, ready)); Assert.Equal(waiting, BootVisual.IsWaiting(elapsed, ready)); } [Theory] [InlineData(320, 240)] [InlineData(1280, 800)] [InlineData(3840, 2160)] public void AnimationStaysInItsCentralRegionAndPreservesScanoutGuards(int width, int height) { int stride = width + 16; uint sentinel = 0xA55A5AA5; uint[] memory = new uint[stride * height + 32]; Array.Fill(memory, sentinel); fixed (uint* pointer = memory) { for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) pointer[16 + y*stride+x] = 0; BootVisual.Draw(pointer + 16, width, height, stride, 2600, true); } Assert.All(memory[..16], pixel => Assert.Equal(sentinel, pixel)); Assert.All(memory[^16..], pixel => Assert.Equal(sentinel, pixel)); for (int y = 0; y < height; y++) for (int x = width; x < stride; x++) Assert.Equal(sentinel, memory[16+y*stride+x]); int size = BootVisual.LogoSize(width, height), cx = width/2, cy = BootVisual.CenterY(height); int ink = 0; for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) { uint pixel = memory[16+y*stride+x]; if (x < cx-size-12 || x > cx+size+12 || y < cy-size-12 || y >= BootVisual.LoaderY(width,height)+32) Assert.Equal(0u, pixel); if (pixel != 0) ink++; } Assert.True(ink > 200); } [Fact] public void InitialBlackLogoRevealAndWaitingHaveDifferentRealPixels() { const int width=640,height=480; uint[] black=Frame(0,false), reveal=Frame(500,false), logo=Frame(2300,false), waiting=Frame(2600,true), next=Frame(2760,true); Assert.All(black,pixel=>Assert.Equal(0u,pixel)); Assert.True(reveal.Count(pixel=>pixel!=0) < logo.Count(pixel=>pixel!=0)); Assert.NotEqual(logo,waiting); Assert.NotEqual(waiting,next); int loader=BootVisual.LoaderY(width,height); Assert.All(logo[((loader-24)*width)..((loader+24)*width)],pixel=>Assert.Equal(0u,pixel)); Assert.Contains(waiting[((loader-24)*width)..((loader+24)*width)],pixel=>pixel!=0); } [Fact] public void RequestedWordmarkAppearsAfterRevealWithoutAnyOtherTextRegion() { const int width=640,height=480; uint[] frame=Frame(2300,false); int top=BootVisual.CenterY(height)+BootVisual.LogoSize(width,height)/2+20; Assert.Contains(frame[(top*width)..((top+20)*width)],p=>(p>>16)>40 && (p&255)>80); Assert.All(frame[..(50*width)],p=>Assert.Equal(0u,p)); Assert.All(frame[^30000..],p=>Assert.Equal(0u,p)); } [Fact] public void ChannelMasksAreHonoredByTheSameNativeRenderer() { uint[] rgb=Frame(2300,false), bgr=new uint[rgb.Length]; fixed(uint* pixels=bgr) BootVisual.Draw(pixels,640,480,640,2300,false,0,8,16); for(int i=0;i>16),bgr[i]); } private static uint[] Frame(ulong ms,bool waiting) { uint[] data=new uint[640*480];fixed(uint* p=data)BootVisual.Draw(p,640,480,640,ms,waiting);return data; } }