update test sample
This commit is contained in:
+7
-2
@@ -92,8 +92,6 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator B1_TestBundlePlaying()
|
||||
{
|
||||
@@ -115,6 +113,13 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator D_DestroyPackage()
|
||||
{
|
||||
var tester = new TestDestroyPackage();
|
||||
yield return tester.RuntimeTester(false);
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string sourceDir, string targetDir)
|
||||
{
|
||||
// 检查源目录是否存在
|
||||
|
||||
+17
-18
@@ -17,31 +17,30 @@ public class TestBundleDownloader
|
||||
Assert.IsNotNull(package);
|
||||
|
||||
var downloader = package.CreateResourceDownloader(10, 1);
|
||||
if (downloader.TotalDownloadCount == 0)
|
||||
{
|
||||
Assert.Fail($"Test downloader not found any file !");
|
||||
}
|
||||
Assert.AreNotEqual(downloader.TotalDownloadCount, 0);
|
||||
|
||||
downloader.BeginDownload();
|
||||
downloader.DownloadFinishCallback = (DownloaderFinishData data) =>
|
||||
{
|
||||
if (data.Succeed == false)
|
||||
Assert.Fail($"Test downloader failed ! {downloader.Error}");
|
||||
};
|
||||
|
||||
// 等待一秒
|
||||
yield return new WaitForSeconds(1f);
|
||||
yield return downloader;
|
||||
Assert.AreEqual(EOperationStatus.Succeed, downloader.Status);
|
||||
}
|
||||
}
|
||||
|
||||
/* 资源代码流程
|
||||
* 远端文件下载(下载器)
|
||||
* 远端文件下载(下载器触发)
|
||||
BundleInfo::CreateDownloader()
|
||||
{
|
||||
return _buildFileSystem.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);
|
||||
if (string.IsNullOrEmpty(options.ImportFilePath))
|
||||
{
|
||||
//RemoteServices返回CDN文件路径
|
||||
string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||
string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||
options.SetURL(mainURL, fallbackURL);
|
||||
var downloader = new DownloadPackageBundleOperation(bundle, options);
|
||||
return downloader;
|
||||
}
|
||||
}
|
||||
*/
|
||||
+8
-7
@@ -35,14 +35,11 @@ public class TestBundleImporter
|
||||
unpacker.BeginDownload();
|
||||
yield return unpacker;
|
||||
Assert.AreEqual(EOperationStatus.Succeed, unpacker.Status);
|
||||
|
||||
// 等待一秒
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
}
|
||||
|
||||
/* 资源代码流程
|
||||
* 本地文件导入(导入器)
|
||||
* 本地文件导入(导入器触发)
|
||||
BundleInfo::CreateDownloader()
|
||||
{
|
||||
options.ImportFilePath = _importFilePath;
|
||||
@@ -50,8 +47,12 @@ BundleInfo::CreateDownloader()
|
||||
}
|
||||
CacheFileSystem::DownloadFileAsync()
|
||||
{
|
||||
string mainURL = ConvertToWWWPath(options.ImportFilePath);
|
||||
options.SetURL(mainURL, mainURL);
|
||||
return new DownloadPackageBundleOperation(bundle, options);
|
||||
if (string.IsNullOrEmpty(options.ImportFilePath) == false)
|
||||
{
|
||||
string mainURL = ConvertToWWWPath(options.ImportFilePath);
|
||||
options.SetURL(mainURL, mainURL);
|
||||
var downloader = new DownloadPackageBundleOperation(bundle, options);
|
||||
return downloader;
|
||||
}
|
||||
}
|
||||
*/
|
||||
+24
-21
@@ -16,28 +16,27 @@ public class TestBundlePlaying
|
||||
ResourcePackage package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
|
||||
Assert.IsNotNull(package);
|
||||
|
||||
if (package.IsNeedDownloadFromRemote("panel_a") == false)
|
||||
if (package.IsNeedDownloadFromRemote("prefab_encryptA") == false)
|
||||
{
|
||||
Assert.Fail("Load bundle is already existed !");
|
||||
}
|
||||
if (package.IsNeedDownloadFromRemote("panel_b") == false)
|
||||
if (package.IsNeedDownloadFromRemote("prefab_encryptB") == false)
|
||||
{
|
||||
Assert.Fail("Load bundle is already existed !");
|
||||
}
|
||||
|
||||
// 测试异步加载
|
||||
// 测试异步加载远端资源
|
||||
{
|
||||
var assetsHandle = package.LoadAssetAsync<GameObject>("panel_a");
|
||||
var assetsHandle = package.LoadAssetAsync<GameObject>("prefab_encryptA");
|
||||
yield return assetsHandle;
|
||||
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
|
||||
}
|
||||
|
||||
// 测试同步加载
|
||||
// 测试同步加载远端资源
|
||||
{
|
||||
// 验证失败结果
|
||||
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true;
|
||||
var assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
||||
yield return assetsHandle;
|
||||
var assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
||||
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
|
||||
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false;
|
||||
|
||||
@@ -46,34 +45,38 @@ public class TestBundlePlaying
|
||||
package.UnloadUnusedAssetsAsync();
|
||||
|
||||
// 验证成功结果
|
||||
// 说明:同步加载也会触发远端下载任务!
|
||||
yield return new WaitForSeconds(1f);
|
||||
assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
||||
yield return assetsHandle;
|
||||
assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
||||
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
|
||||
}
|
||||
|
||||
// 等待一秒
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
}
|
||||
|
||||
/* 资源代码流程
|
||||
* 远端文件下载(加载器)
|
||||
* 远端文件下载(加载器触发)
|
||||
CacheFileSystem::LoadBundleFile()
|
||||
{
|
||||
_cacheFileSystem.LoadBundleFile(bundle);
|
||||
}
|
||||
CacheFileSystem::LoadAssetBundleOperation()
|
||||
DCFSLoadAssetBundleOperation::InternalUpdate()
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||
_cacheFileSystem.DownloadFileAsync(_bundle, options);
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_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);
|
||||
if (string.IsNullOrEmpty(options.ImportFilePath))
|
||||
{
|
||||
//RemoteServices返回CDN文件路径
|
||||
string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||
string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||
options.SetURL(mainURL, fallbackURL);
|
||||
var downloader = new DownloadPackageBundleOperation(bundle, options);
|
||||
return downloader;
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user