Prove nel browser sulla scheda video: tests/chromium.mjs usa la GPU se c'è (schermata 41 ms invece di 633; tutte e venti in ~4 min invece di ~16, sei alla volta), altrimenti swiftshader; la pipeline dà la GPU ai job, runner a 6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
This commit is contained in:
@@ -5,6 +5,7 @@ import { chromium } from 'playwright';
|
||||
import { mkdirSync } from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { staticServer } from './helpers.mjs';
|
||||
import { ARGS } from './chromium.mjs';
|
||||
|
||||
const out = process.env.OUT ?? '/tmp/regolo-flipper';
|
||||
mkdirSync(out, { recursive: true });
|
||||
@@ -12,7 +13,7 @@ const server = await staticServer();
|
||||
let browser;
|
||||
const errors = [];
|
||||
try {
|
||||
browser = await chromium.launch({ args: ['--autoplay-policy=no-user-gesture-required', '--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader'] });
|
||||
browser = await chromium.launch({ args: ARGS });
|
||||
for (const [name, mobile, viewport] of [['desktop', false, { width: 1280, height: 860 }], ['touch', true, { width: 844, height: 390 }]]) {
|
||||
const page = await browser.newPage({ viewport, hasTouch: mobile, isMobile: mobile });
|
||||
page.on('pageerror', e => errors.push(e.message));
|
||||
@@ -45,9 +46,10 @@ try {
|
||||
await page.waitForFunction(() => game.closeup.holding && game.closeup.power > 0.3, null, { polling: 'raf' });
|
||||
await touch('touchEnd', []);
|
||||
} else {
|
||||
await page.mouse.move(...P(440, 320)); await page.mouse.down();
|
||||
// Da tastiera con la freccia giù (il mouse tiene la molla come il dito, provato sul telefono).
|
||||
await page.keyboard.down('ArrowDown');
|
||||
await page.waitForFunction(() => game.closeup.holding && game.closeup.power > 0.3, null, { polling: 'raf' });
|
||||
await page.mouse.up();
|
||||
await page.keyboard.up('ArrowDown');
|
||||
}
|
||||
await page.waitForFunction(() => game.closeup && !game.closeup.ball?.waiting, null, { timeout: 5000 });
|
||||
// Due dita sulla scena: sinistra, poi anche destra, poi si alza la sinistra e la destra resta su.
|
||||
@@ -83,6 +85,13 @@ try {
|
||||
await page.keyboard.up('ArrowLeft');
|
||||
await page.click('#resume');
|
||||
await page.waitForFunction(() => document.querySelector('#pause').hidden);
|
||||
// I due Shift: il sinistro alza la paletta sinistra, il destro la destra.
|
||||
await page.keyboard.down('ShiftRight');
|
||||
await page.waitForFunction(() => game.closeup.flippers.right.held.includes('key-ShiftRight') && !game.closeup.flippers.left.held.length);
|
||||
await page.keyboard.down('ShiftLeft');
|
||||
await page.waitForFunction(() => game.closeup.flippers.left.held.includes('key-ShiftLeft'));
|
||||
await page.keyboard.up('ShiftRight'); await page.keyboard.up('ShiftLeft');
|
||||
await page.waitForFunction(() => !game.closeup.flippers.left.held.length && !game.closeup.flippers.right.held.length);
|
||||
}
|
||||
// Il traguardo aggiunge una pallina e lascia continuare la partita.
|
||||
const reward = await page.evaluate(async () => {
|
||||
|
||||
Reference in New Issue
Block a user