test : 新增测试用例
This commit is contained in:
@@ -187,6 +187,31 @@ public class T0_InitYooAssets : IPrebuildSetup, IPostBuildCleanup
|
||||
collector3.PackRuleName = nameof(YooAsset.Editor.PackSeparately);
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(encryptGroup, collector3);
|
||||
}
|
||||
|
||||
// 卸载测试文件
|
||||
var unloadGroup = YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(testPackage, "UnloadGroup");
|
||||
{
|
||||
var collector1 = new YooAsset.Editor.AssetBundleCollector();
|
||||
collector1.CollectPath = "";
|
||||
collector1.CollectorGUID = "c8cebdb7cd80a4044b15a1522363bb86"; //TestRes4/Enemy目录
|
||||
collector1.CollectorType = YooAsset.Editor.ECollectorType.MainAssetCollector;
|
||||
collector1.PackRuleName = nameof(YooAsset.Editor.PackDirectory);
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(unloadGroup, collector1);
|
||||
|
||||
var collector2 = new YooAsset.Editor.AssetBundleCollector();
|
||||
collector2.CollectPath = "";
|
||||
collector2.CollectorGUID = "3ba9252bc0a278145a7bde0cf876cbcb"; //TestRes4/EnemyImage目录
|
||||
collector2.CollectorType = YooAsset.Editor.ECollectorType.DependAssetCollector;
|
||||
collector2.PackRuleName = nameof(YooAsset.Editor.PackDirectory);
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(unloadGroup, collector2);
|
||||
|
||||
var collector3 = new YooAsset.Editor.AssetBundleCollector();
|
||||
collector3.CollectPath = "";
|
||||
collector3.CollectorGUID = "65cc88e038c61ec488be24b82c4e2937"; //TestRes4/EnemyMat目录
|
||||
collector3.CollectorType = YooAsset.Editor.ECollectorType.DependAssetCollector;
|
||||
collector3.PackRuleName = nameof(YooAsset.Editor.PackDirectory);
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(unloadGroup, collector3);
|
||||
}
|
||||
}
|
||||
private static void CreateRawBundlePackageCollector()
|
||||
{
|
||||
|
||||
+16
-2
@@ -188,9 +188,9 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator C1_TestBundleReference()
|
||||
public IEnumerator C1_TestGetAssetInfos()
|
||||
{
|
||||
var tester = new TestBundleReference();
|
||||
var tester = new TestGetAssetInfos();
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
@@ -208,6 +208,20 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator C4_TestBundleReference()
|
||||
{
|
||||
var tester = new TestBundleReference();
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator C4_TestBundleUnload()
|
||||
{
|
||||
var tester = new TestBundleUnload();
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator D_DestroyPackage()
|
||||
{
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.U2D;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using YooAsset;
|
||||
using System.Linq;
|
||||
|
||||
public class TestBundleUnload
|
||||
{
|
||||
public IEnumerator RuntimeTester()
|
||||
{
|
||||
ResourcePackage package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
|
||||
Assert.IsNotNull(package);
|
||||
|
||||
string targetBundleName = "assets_samples_test_sample_testres4_enemy.bundle";
|
||||
|
||||
// 加载Enemy
|
||||
AssetHandle assetHandle;
|
||||
{
|
||||
assetHandle = package.LoadAssetAsync<GameObject>("enemy");
|
||||
yield return assetHandle;
|
||||
Assert.AreEqual(EOperationStatus.Succeed, assetHandle.Status);
|
||||
|
||||
DebugPackageData debugData = package.GetDebugPackageData();
|
||||
var findItem = debugData.BundleInfos.Where(x => x.BundleName == targetBundleName);
|
||||
Assert.AreEqual(findItem.Count(), 1);
|
||||
}
|
||||
|
||||
// 卸载Enemy
|
||||
{
|
||||
assetHandle.Release();
|
||||
package.TryUnloadUnusedAsset("enemy");
|
||||
|
||||
DebugPackageData debugData = package.GetDebugPackageData();
|
||||
var findItem = debugData.BundleInfos.Where(x => x.BundleName == targetBundleName);
|
||||
Assert.AreEqual(findItem.Count(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9cf81becc940b94b98926a171bca520
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.U2D;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using YooAsset;
|
||||
|
||||
public class TestGetAssetInfos
|
||||
{
|
||||
public IEnumerator RuntimeTester()
|
||||
{
|
||||
ResourcePackage package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
|
||||
Assert.IsNotNull(package);
|
||||
|
||||
// 获取所有资源对象信息
|
||||
var allAssetInfos = package.GetAllAssetInfos();
|
||||
Assert.AreEqual(allAssetInfos.Length, 28);
|
||||
|
||||
// 获取指定资源对象信息
|
||||
var assetInfos = package.GetAssetInfos("import");
|
||||
Assert.AreEqual(assetInfos.Length, 2);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed2ce0f1d01df854da3622e757694128
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+3
-3
@@ -93,21 +93,21 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator B1_TestBundlePlaying()
|
||||
public IEnumerator C1_TestBundlePlaying()
|
||||
{
|
||||
var tester = new TestBundlePlaying();
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator B2_TestBundleImporter()
|
||||
public IEnumerator C2_TestBundleImporter()
|
||||
{
|
||||
var tester = new TestBundleImporter();
|
||||
yield return tester.RuntimeTester();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator B3_TestBundleDownloader()
|
||||
public IEnumerator C3_TestBundleDownloader()
|
||||
{
|
||||
var tester = new TestBundleDownloader();
|
||||
yield return tester.RuntimeTester();
|
||||
|
||||
Reference in New Issue
Block a user