feat: integrate platform room entry, UI migration and erqiwang documentation
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/** Cocos Game View verification: mocked wire, no real ranking/card requests. */
|
||||
export async function verifyLoadingPreview(){
|
||||
const e=await System.import('cc'),modules=Array.from(System.entries()).map(([,m])=>m);
|
||||
const exported=name=>{const m=modules.find(m=>m[name]);if(!m)throw Error(`Missing ${name}`);return m[name];};
|
||||
const source=e.director.getScene().getChildByName('PlatformServices').getComponent('PlatformStartup');
|
||||
const config=source.config,assets=source.getComponent('LobbyAssets');
|
||||
source.unsubscribe?.();source.runtime?.stop();source.panel?.dispose();source.panel=null;
|
||||
await new Promise((resolve,reject)=>e.director.loadScene('PlatformLobby',err=>err?reject(err):resolve()));
|
||||
const sent=[],tips=[],checks=[];let receive,panel;
|
||||
const assert=(ok,msg)=>{if(!ok)throw Error(msg);checks.push(msg);};
|
||||
const runtime=new (exported('PlatformRuntime'))({
|
||||
gameEntry:exported('createLoginStageGameEntry')(config.identity.gameid,()=>{}),resolveRuntimeConfig:async()=>config,
|
||||
createWireClient:()=>({subscribe:cb=>{receive=cb;return ()=>{};},start:()=>{},stop:()=>{},send:p=>sent.push(p),switchServer:()=>{},reconnectCurrent:()=>{}}),
|
||||
scene:{showLoading:()=>{},showLogin:()=>{},showLobby:()=>{},showRoom:()=>{},showReconnect:()=>{},showKicked:()=>{},showServerDenial:()=>{},showFatal:err=>{throw err;},
|
||||
showTips:(msg,time,kind)=>{if(kind==='show_message')panel?.cancelRankRequest();tips.push(msg);}},
|
||||
loadResources:async()=>{},waitForMinimumDisplay:async()=>{},getLoginDeviceSnapshot:()=>{throw Error('Fixture only');},
|
||||
});
|
||||
await runtime.start();receive({type:'open',server:config.servers[0]});
|
||||
const packet=(rpc,data)=>{const message={route:'agent',rpc,data};panel?.requestReceived(message);receive({type:'message',message});};
|
||||
packet('player_login',{state:0,playerid:7,nickname:'接线验证',avatar:'',sex:0,bean:0,roomcard:3,taskstate:0,score:0,sign:null,ip:'127.0.0.1',openid:'test',unionid:'test',invitecode:null});
|
||||
const canvas=e.director.getScene().getChildByName('Canvas'),popup=new e.Node('OwnedVipTestPopup');popup.parent=canvas;popup.layer=canvas.layer;popup.addComponent(e.UITransform).setContentSize(1600,720);
|
||||
const remote=exported('createRemoteConfig')({gameNoticeShow:-1,rankList:2,cdKey:2,vipRankLimit:3},config.identity);
|
||||
const feedback=new (exported('FeedbackPanels'))(canvas,{tips:source.tipsPrefab,loading:source.waitPrefab,reconnect:source.reconnectPrefab,kick:source.kickPrefab});
|
||||
panel=new (exported('LobbyPanel'))(canvas,popup,assets,config,exported('resolveLobbyPolicy')(remote),runtime.state,msg=>tips.push(msg),()=>{},()=>null,()=>{},
|
||||
exported('resolveLobbyMenuConfig')(remote),{versionState:0,launchMode:0},action=>{if(action==='tasks')runtime.getPlayerTasks();},id=>runtime.claimTask(id),()=>{},undefined,undefined,
|
||||
{rank:()=>runtime.getTreasureList(),redeem:card=>runtime.redeemCard(card),paste:async()=>'00Ab-12',loading:show=>feedback.loading(show),vipRank:limit=>runtime.getVipRankList(limit),joinOwned:code=>runtime.joinOwnedRoom(code,{city:'test'})});
|
||||
popup.setSiblingIndex(canvas.children.length-1);
|
||||
const off=runtime.subscribeState(state=>panel.render(state),err=>{throw err;});
|
||||
const click=id=>panel.menuNodes.get(id).emit(e.Button.EventType.CLICK);
|
||||
|
||||
|
||||
const overlay=feedback.loadingNode,animation=overlay.getChildByPath('group-40/载入动画').getComponent(e.Animation);
|
||||
assert(animation&&animation.defaultClip?.name==='RequestLoading','Layer614 owns serialized RequestLoading clip');
|
||||
click(17);assert(overlay.activeInHierarchy&&sent.at(-1).rpc==='get_player_task','task send shows Layer614');
|
||||
assert(animation.getState('RequestLoading').isPlaying,'loading starts native Animation');
|
||||
const angle=animation.node.angle;await new Promise(r=>setTimeout(r,200));assert(animation.node.angle!==angle,'animation advances rotation');
|
||||
packet('get_player_task',{tasks:[{taskid:1,title:'test',award:1,finish:1,total:1,state:1}]});
|
||||
assert(!overlay.active&&!animation.getState('RequestLoading').isPlaying,'task response hides overlay and stops clip');
|
||||
panel.requestTask('award',()=>runtime.claimTask(1));assert(overlay.active&&sent.at(-1).rpc==='get_task_award','award send shows Layer614');
|
||||
packet('get_task_award',{taskid:1,taskstate:0});assert(!overlay.active,'award response hides Layer614');
|
||||
panel.close();click(3232);assert(overlay.active&&sent.at(-1).rpc==='getVipRankList','VIP rank send shows Layer614');
|
||||
packet('getVipRankList',{state:1,error:'失败'});assert(!overlay.active,'VIP failure response hides Layer614');
|
||||
panel.cancelRankRequest();click(3232);packet('getVipRankList',{list:[]});assert(!overlay.active,'empty VIP success hides Layer614');
|
||||
click(3232);packet('show_message',{msg:'服务拒绝',time:0});assert(!overlay.active,'generic failure closes request loading');
|
||||
click(17);panel.cancelTaskRequest();assert(!overlay.active,'timeout cancellation hides Layer614');
|
||||
let caught=false;try{panel.requestTask('list',()=>{throw Error('send failed');});}catch{caught=true;}
|
||||
assert(caught&&!overlay.active,'synchronous send failure hides Layer614');
|
||||
click(17);panel.requestReceived({route:'agent',rpc:'get_player_task',data:null});assert(!overlay.active,'malformed task reply closes before parsing');panel.cancelTaskRequest();
|
||||
click(3232);assert(overlay.active,'loading can restart');
|
||||
globalThis.__loadingVerification={panel,runtime,feedback,checks,close:()=>{off();panel.dispose();runtime.stop();feedback.dispose();popup.destroy();}};
|
||||
return {checks};
|
||||
}
|
||||
Reference in New Issue
Block a user