| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using TMPro;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Olympus.Editor
- {
- public static class SuiteAudit
- {
- const BindingFlags Flags=BindingFlags.Instance|BindingFlags.NonPublic;
- static T Field<T>(OlympusGame app,string key)=>(T)typeof(OlympusGame).GetField(key,Flags).GetValue(app);
- static void Call(OlympusGame app,string method,params object[] args)=>typeof(OlympusGame).GetMethod(method,Flags).Invoke(app,args);
- static StringBuilder report;
- static void Check(bool result,string text){if(!result)throw new Exception("FAIL "+text);report.AppendLine("PASS "+text);}
- static Button Find(OlympusGame app,string key)=>app.GetComponentsInChildren<Button>().First(b=>b.name==key);
- static void Press(OlympusGame app,string key){var b=Find(app,key);Check(b.interactable,"enabled "+key);b.onClick.Invoke();}
- public static string Run()
- {
- if(!Application.isPlaying||!SessionState.GetBool("OlympusCapture",false))throw new Exception("Use isolated art review save.");
- var app=UnityEngine.Object.FindFirstObjectByType<OlympusGame>();if(!app.IsEditorPreviewSave)throw new Exception("The running game uses the normal save. Restart through Art Review.");var store=Field<PlayerStore>(app,"store");report=new StringBuilder();store.Reset();app.ShowDesignPage("Start");Press(app,"GAME START");Check(store.Data.profileSet,"start saves identity");
- Press(app,"Nav Shop");Check(Field<RectTransform>(app,"modal").GetComponent<Image>().raycastTarget,"modal blocks clicks to lobby");int coins=store.Data.coins,items=store.Data.items[0];Press(app,"Buy 0");Check(store.Data.coins==coins-400&&store.Data.items[0]==items+1,"shop purchase updates saved balance and inventory");Press(app,"Close");
- Press(app,"Check-in");coins=store.Data.coins;Press(app,"Claim");Check(store.Data.coins==coins+200,"daily claim gives configured coins");Check(!Find(app,"Claim").interactable,"same-day claim disabled");Find(app,"Claim").onClick.Invoke();Check(store.Data.coins==coins+200,"duplicate claim protected");Press(app,"Close");
- Press(app,"Settings");bool music=store.Data.music;Press(app,"Toggle 1");Check(store.Data.music!=music,"music switch saves value");Press(app,"Toggle 1");Press(app,"Done");
- Press(app,"Leaderboard");var scroll=app.GetComponentsInChildren<ScrollRect>().First();Check(scroll.content.GetComponentsInChildren<TextMeshProUGUI>().Count(t=>t.name.StartsWith("Name row"))==11,"all eleven standings are scrollable");Press(app,"Week");Check(Field<string>(app,"currentPanel")=="Weekly","weekly tab selects weekly data");Press(app,"Today");Press(app,"Done");
- Press(app,"PLAY · 200");var game=Field<MatchEngine>(app,"game");Check(Field<string>(app,"currentScreen")=="Matching","matching uses new loading page");game.Tick(4);game.Tick(2);Check(Field<string>(app,"currentScreen")=="Trial","matching enters native trial");Press(app,"Menu");double time=game.TimeLeft;game.Tick(30);Check(game.TimeLeft==time,"themed menu pauses timer");Press(app,"Resume");Check(!game.Paused,"resume restores timer");
- for(int n=0;n<5;n++){TileAnswerAudit.SelectAnswer(app,game.Current.answer);Press(app,"OK");game.Tick(1.6);if(n<4){Check(Field<SuiteView>(app,"suiteView")!=null,"native round standings "+n);game.Continue();game.Tick(1.3);}}
- Check(game.Phase==MatchPhase.Result,"new result page binds completed match");Check(Field<SuiteView>(app,"suiteView").Text("Total score").text==game.Score.ToString("N0"),"result score is live data");Press(app,"Play again");Check(game.Phase==MatchPhase.Lobby,"result returns to lobby");
- foreach(string panel in new[]{"Profile","How to","Coin records"}){Call(app,"OpenPanel",panel);Check(app.GetComponentsInChildren<SuiteView>().Any(v=>v.screen=="General"),"shared temple frame: "+panel);Press(app,"Close");}
- app.ShowDesignPage("Lobby");Directory.CreateDirectory("docs/验证");File.WriteAllText("docs/验证/全界面交互验收.txt",report.ToString());return report.ToString();
- }
- public static string Prefabs()
- {
- var result=new StringBuilder();foreach(string name in SuiteBuilder.Screens){var prefab=Resources.Load<GameObject>("Olympus/Suite/"+name);if(!prefab||!prefab.GetComponent<SuiteView>())throw new Exception("Missing prefab "+name);if(GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(prefab)>0)throw new Exception("Missing script "+name);result.AppendLine(name+": "+prefab.GetComponentsInChildren<Button>(true).Length+" native buttons, "+prefab.GetComponentsInChildren<TextMeshProUGUI>(true).Length+" text fields");}return result.ToString();
- }
- }
- }
|