JA
apps/winzik / tests / ScreensTest.php · commit 6576d6f
<?phpnamespace Tests;use App\Native\NativeShell;use PHPUnit\Framework\TestCase;final class ScreensTest extends TestCase{    public function testXrandrGivesWhatEachScreenShowsTheMainOneFirst(): void    {        // the user's laptop docked: three screens, the HDMI one is the main one (*)        $out = "Monitors: 3\n 0: +*HDMI-A-0 2560/798x1080/334+0+768  HDMI-A-0\n 1: +eDP 1707/288x1067/180+2560+768  eDP\n 2: +DisplayPort-9 1366/300x768/170+2560+0  DisplayPort-9\n";        self::assertSame([[0, 768, 2560, 1080], [2560, 768, 1707, 1067], [2560, 0, 1366, 768]], NativeShell::parseXrandr($out));        // the laptop alone, its 2560x1600 panel showing 1707x1067 of the desktop (SDL says 2560x1600: wrong)        self::assertSame([[0, 0, 1707, 1067]], NativeShell::parseXrandr("Monitors: 1\n 0: +eDP 1707/288x1067/180+0+0  eDP\n"));        self::assertSame([], NativeShell::parseXrandr(''));    }    public function testTheSplashIsAboutFortyPercentOfItsScreenWhateverItsResolution(): void    {        foreach ([[1707, 1067], [2560, 1080], [1366, 768], [3840, 2160], [1280, 720]] as [$w, $h]) {            [$sw, $sh] = NativeShell::splashSize($w, $h);            self::assertEqualsWithDelta(0.4, $sw / $w, 0.08, "{$w}x{$h}: $sw");            self::assertLessThanOrEqual($h / 2, $sh);            self::assertEqualsWithDelta(489 / 153, $sw / $sh, 0.02, 'its proportions');        }    }}