Initial commit: Client Doc docs Server Tools
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace XWorld.PublishTool.Tests
|
||||
{
|
||||
public class MiniGameHostUiTests
|
||||
{
|
||||
// Unity 2022.2+ 移除了内置 Arial.ttf,GetBuiltinResource("Arial.ttf") 会抛
|
||||
// ArgumentException,导致结算弹框构建中断(只剩遮罩无文字无按钮)。
|
||||
[Fact]
|
||||
public void MiniGameHost_UsesLegacyRuntimeFont_NotRemovedArial()
|
||||
{
|
||||
string source = File.ReadAllText(Path.Combine(
|
||||
RepoRoot(),
|
||||
"Client",
|
||||
"Assets",
|
||||
"Script",
|
||||
"xmain",
|
||||
"MiniGame",
|
||||
"MiniGameHost.cs"));
|
||||
|
||||
Assert.DoesNotContain("Arial.ttf", source);
|
||||
Assert.Contains("LegacyRuntime.ttf", source);
|
||||
}
|
||||
|
||||
// 结算弹框须走标准 UGUI 预设(JSON→Prefab 管线产物)+ 异步加载,代码构建仅作回退。
|
||||
[Fact]
|
||||
public void MiniGameHost_LoadsResultDialogPrefab_Async()
|
||||
{
|
||||
string source = File.ReadAllText(Path.Combine(
|
||||
RepoRoot(),
|
||||
"Client",
|
||||
"Assets",
|
||||
"Script",
|
||||
"xmain",
|
||||
"MiniGame",
|
||||
"MiniGameHost.cs"));
|
||||
|
||||
Assert.Contains("UI_MiniGameResult.prefab", source);
|
||||
Assert.Contains("coLoadRes", source); // 项目规则:资源一律异步加载
|
||||
|
||||
// 预设的 JSON 描述文件必须存在(Doc/UIPrefabCreater 管线输入)
|
||||
Assert.True(File.Exists(Path.Combine(
|
||||
RepoRoot(), "Doc", "UIPrefabCreater", "UI_MiniGameResult.json")));
|
||||
}
|
||||
|
||||
private static string RepoRoot()
|
||||
{
|
||||
var dir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
while (dir != null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(dir.FullName, "Client", "Assets", "MiniGames", "RockPaperScissors", "publish.json")))
|
||||
return dir.FullName;
|
||||
dir = dir.Parent;
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException("Could not locate repo root.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user