update test sample

增加cache file system单元测试
This commit is contained in:
何冠峰
2025-07-17 21:26:13 +08:00
parent ac7ee16017
commit db159428c6
42 changed files with 890 additions and 269 deletions

View File

@@ -0,0 +1,71 @@
using System;
using System.IO;
using System.Text;
using System.Collections;
using UnityEngine;
using NUnit.Framework;
using YooAsset;
/// <summary>
/// 测试边玩边下
/// </summary>
public class TestBundlePlaying
{
public IEnumerator RuntimeTester()
{
ResourcePackage package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
Assert.IsNotNull(package);
if (package.IsNeedDownloadFromRemote("panel_a") == false)
{
Assert.Fail("Load bundle is already existed !");
}
if (package.IsNeedDownloadFromRemote("panel_b") == false)
{
Assert.Fail("Load bundle is already existed !");
}
// 测试异步加载
{
var assetsHandle = package.LoadAssetAsync<GameObject>("panel_a");
yield return assetsHandle;
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
}
// 测试同步加载
{
var assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
yield return assetsHandle;
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
yield return new WaitForSeconds(1f);
assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
yield return assetsHandle;
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
}
// 等待一秒
yield return new WaitForSeconds(1f);
}
}
/* 资源代码流程
* 远端文件下载(加载器)
CacheFileSystem::LoadBundleFile()
{
_cacheFileSystem.LoadBundleFile(bundle);
}
CacheFileSystem::LoadAssetBundleOperation()
{
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
_cacheFileSystem.DownloadFileAsync(_bundle, options);
}
CacheFileSystem::DownloadFileAsync()
{
//RemoteServices返回CDN文件路径
string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
options.SetURL(mainURL, fallbackURL);
return new DownloadPackageBundleOperation(bundle, options);
}
*/