Initial commit: RHINE LAB · ANALYSIS OS:三维界面与动效实验(本仓库不含个人归档索引数据)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import {createRequire} from 'node:module';
|
||||
import {readFile,mkdir,writeFile} from 'node:fs/promises';
|
||||
import {pathToFileURL} from 'node:url';
|
||||
import {resolve} from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
const require=createRequire(import.meta.url),{chromium}=require(process.env.PLAYWRIGHT_MODULE||'playwright');
|
||||
const browser=await chromium.launch({channel:'msedge',headless:true});
|
||||
try{const page=await browser.newPage({viewport:{width:1280,height:720}});await page.goto(pathToFileURL(resolve('verification/wallpaper-image/test.html')).href);for(const file of ['src/style.css','src/theme.css','src/wallpaper-effects.css'])await page.evaluate(css=>{const style=document.createElement('style');style.textContent=css;document.head.append(style)},await readFile(file,'utf8'));await page.evaluate(()=>{document.querySelector('#stage').style.cssText='position:fixed;inset:0';document.querySelector('#stage').insertAdjacentHTML('beforeend','<div class="scene-atmosphere archive-atmosphere" style="opacity:1"></div>')});
|
||||
const results=[];for(const dark of [false,true])for(const value of [100,50,0]){await page.evaluate(({dark,value})=>{document.documentElement.dataset.darkSurface=String(dark);document.documentElement.style.setProperty('--theme-paper-rgb',dark?'40,44,48':'234,229,225');background.update({customwallpaper:{value:true},customwallpaperfile:{value:'E:/AIProject/RhineLabUI/reference/extracted-3088099655/wallpaper-2.jpg'},customwallpapermask:{value}},true,true)},{dark,value});await page.waitForFunction(()=>document.querySelector('.wallpaper-background').dataset.ready==='true');await page.waitForTimeout(100);const result=await page.locator('.scene-atmosphere').evaluate(el=>({opacity:getComputedStyle(el).opacity,size:getComputedStyle(el).backgroundSize}));assert.equal(result.opacity,value===0?'0':'1');assert.ok(result.size.includes(`${value}%`));results.push({dark,value,...result});await mkdir('verification/wallpaper-mask',{recursive:true});await page.screenshot({path:`verification/wallpaper-mask/${dark?'dark':'light'}-${value}.png`})}await writeFile('verification/wallpaper-mask/results.json',JSON.stringify(results,null,2));console.log('Light/dark mask ranges 100, 50, 0 passed.')}finally{await browser.close()}
|
||||
|
||||
Reference in New Issue
Block a user