public void HandleBundleDelete_Deletes_VariantFolderAndChildren() { // Account for existing asset bundles int numChildren = ABModelUtil.Root.GetChildList().Count; BundleVariantFolderInfo bundleVariantFolderRoot = new BundleVariantFolderInfo("variantFolder", ABModelUtil.Root); ABModelUtil.Root.AddChild(bundleVariantFolderRoot); BundleVariantDataInfo bundleVariantDataInfo1 = new BundleVariantDataInfo("variant.a", bundleVariantFolderRoot); BundleVariantDataInfo bundleVariantDataInfo2 = new BundleVariantDataInfo("variant.b", bundleVariantFolderRoot); BundleVariantDataInfo bundleVariantDataInfo3 = new BundleVariantDataInfo("variant.c", bundleVariantFolderRoot); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo1); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo2); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo3); FieldInfo numberOfChildrenFieldInfo = typeof(BundleFolderConcreteInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance); Dictionary <string, BundleInfo> numberOfConcreteFolderChildren = numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>; Assert.AreEqual(numChildren + 1, numberOfConcreteFolderChildren.Keys.Count); Model.HandleBundleDelete(new BundleInfo[] { bundleVariantFolderRoot }); numberOfConcreteFolderChildren = numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>; Assert.AreEqual(numChildren, numberOfConcreteFolderChildren.Keys.Count); }
public void ModelRebuild_KeepsCorrect_BundlesToUpdate() { List <string> listOfPrefabs = new List <string>(); string bundleName = "bundletest"; listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v1")); listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v2")); TestUtil.ExecuteCodeAndCleanupAssets(() => { Model.Rebuild(); var rootChildList = ABModelUtil.Root.GetChildList(); //Checks that the root has 1 bundle variant folder object as a child Assert.AreEqual(1, rootChildList.Count); Assert.AreEqual(typeof(BundleVariantFolderInfo), rootChildList.FirstOrDefault().GetType()); BundleVariantFolderInfo folderInfo = rootChildList.FirstOrDefault() as BundleVariantFolderInfo; //Checks that the bundle variant folder object (mentioned above) has two children Assert.AreEqual(2, folderInfo.GetChildList().Count); }, listOfPrefabs); }
public void HandleBundleReparent_MovesBundle_IntoCorrectVariantFolder() { string variantFolderName = "variantfolder"; string bundleName = "bundle1"; BundleVariantFolderInfo bundleVariantFolderRoot = new BundleVariantFolderInfo(variantFolderName, ABModelUtil.Root); BundleDataInfo bundleDataInfo = new BundleDataInfo(bundleName, ABModelUtil.Root); ABModelUtil.Root.AddChild(bundleVariantFolderRoot); ABModelUtil.Root.AddChild(bundleDataInfo); Model.HandleBundleReparent(new BundleInfo[] { bundleDataInfo }, bundleVariantFolderRoot); Assert.AreEqual(variantFolderName + "/" + bundleName, bundleDataInfo.m_Name.bundleName); }
public static void HandleBundleDelete_Deletes_SingleVariantFromVariantFolder() { // Account for existing asset bundles var numChildren = ABModelUtil.Root.GetChildList().Count; var numBundles = AssetDatabase.GetAllAssetBundleNames().Length; var bundleVariantFolderRoot = new BundleVariantFolderInfo("variantFolder", ABModelUtil.Root); ABModelUtil.Root.AddChild(bundleVariantFolderRoot); var bundleVariantDataInfo1 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot); bundleVariantDataInfo1.m_Name.variant = "a"; var bundleVariantDataInfo2 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot); bundleVariantDataInfo2.m_Name.variant = "b"; var bundleVariantDataInfo3 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot); bundleVariantDataInfo3.m_Name.variant = "c"; bundleVariantFolderRoot.AddChild(bundleVariantDataInfo1); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo2); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo3); var numberOfChildrenFieldInfo = typeof(BundleFolderConcreteInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance); var numberOfConcreteFolderChildren = numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>; Assert.AreEqual(numChildren + 1, numberOfConcreteFolderChildren.Keys.Count); Model.HandleBundleDelete(new BundleInfo[] { bundleVariantDataInfo1 }); numberOfConcreteFolderChildren = numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>; Assert.AreEqual(numChildren + 1, numberOfConcreteFolderChildren.Keys.Count); var numberOfVariantFolderChildrenFieldInfo = typeof(BundleVariantFolderInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance); var numberOfVariantFolderChildren = numberOfVariantFolderChildrenFieldInfo.GetValue(bundleVariantFolderRoot) as Dictionary <string, BundleInfo>; Assert.AreEqual(2, numberOfVariantFolderChildren.Keys.Count); }
public void HandleBundleDelete_Deletes_SingleVariantFromVariantFolder() { BundleVariantFolderInfo bundleVariantFolderRoot = new BundleVariantFolderInfo("variantFolder", ABModelUtil.Root); ABModelUtil.Root.AddChild(bundleVariantFolderRoot); BundleVariantDataInfo bundleVariantDataInfo1 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot); bundleVariantDataInfo1.m_Name.variant = "a"; BundleVariantDataInfo bundleVariantDataInfo2 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot); bundleVariantDataInfo2.m_Name.variant = "b"; BundleVariantDataInfo bundleVariantDataInfo3 = new BundleVariantDataInfo("variant1", bundleVariantFolderRoot); bundleVariantDataInfo3.m_Name.variant = "c"; bundleVariantFolderRoot.AddChild(bundleVariantDataInfo1); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo2); bundleVariantFolderRoot.AddChild(bundleVariantDataInfo3); FieldInfo numberOfChildrenFieldInfo = typeof(BundleFolderConcreteInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance); Dictionary <string, BundleInfo> numberOfConcreteFolderChildren = numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>; Assert.AreEqual(1, numberOfConcreteFolderChildren.Keys.Count); Model.HandleBundleDelete(new BundleInfo[] { bundleVariantDataInfo1 }); numberOfConcreteFolderChildren = numberOfChildrenFieldInfo.GetValue(ABModelUtil.Root) as Dictionary <string, BundleInfo>; Assert.AreEqual(1, numberOfConcreteFolderChildren.Keys.Count); FieldInfo numberOfVariantFolderChildrenFieldInfo = typeof(BundleVariantFolderInfo).GetField("m_Children", BindingFlags.NonPublic | BindingFlags.Instance); Dictionary <string, BundleInfo> numberOfVariantFolderChildren = numberOfVariantFolderChildrenFieldInfo.GetValue(bundleVariantFolderRoot) as Dictionary <string, BundleInfo>; Assert.AreEqual(2, numberOfVariantFolderChildren.Keys.Count); }
public void VerifyBasicTreeStructure_ContainsCorrect_ClassTypes() { // Account for existing bundles int numChildren = ABModelUtil.Root.GetChildList().Count; List <string> listOfPrefabs = new List <string>(); string bundleName = "bundletest"; listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v1")); listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v2")); TestUtil.ExecuteCodeAndCleanupAssets(() => { Model.Refresh(); var rootChildList = ABModelUtil.Root.GetChildList(); Assert.AreEqual(numChildren + 1, rootChildList.Count); Type bundleVariantFolderInfoType = typeof(BundleVariantFolderInfo); BundleVariantFolderInfo foundItem = null; foreach (BundleInfo item in rootChildList) { if (item.GetType() == bundleVariantFolderInfoType) { foundItem = item as BundleVariantFolderInfo; break; } } Assert.IsNotNull(foundItem); BundleInfo[] folderChildArray = foundItem.GetChildList().ToArray(); Assert.AreEqual(2, folderChildArray.Length); Assert.AreEqual(typeof(BundleVariantDataInfo), folderChildArray[0].GetType()); Assert.AreEqual(typeof(BundleVariantDataInfo), folderChildArray[1].GetType()); }, listOfPrefabs); }
public void ModelRebuild_KeepsCorrect_BundlesToUpdate() { // Account for existing bundles int numChildren = ABModelUtil.Root.GetChildList().Count; List <string> listOfPrefabs = new List <string>(); string bundleName = "bundletest"; listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v1")); listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v2")); TestUtil.ExecuteCodeAndCleanupAssets(() => { Model.Rebuild(); var rootChildList = ABModelUtil.Root.GetChildList(); //Checks that the root has 1 bundle variant folder object as a child Assert.AreEqual(numChildren + 1, rootChildList.Count); Type variantFolderType = typeof(BundleVariantFolderInfo); BundleVariantFolderInfo foundItem = null; foreach (BundleInfo item in rootChildList) { if (item.GetType() == variantFolderType) { foundItem = item as BundleVariantFolderInfo; break; } } //Checks that the bundle variant folder object (mentioned above) has two children Assert.IsNotNull(foundItem); Assert.AreEqual(2, foundItem.GetChildList().Count); }, listOfPrefabs); }
public void VerifyBasicTreeStructure_ContainsCorrect_ClassTypes() { List <string> listOfPrefabs = new List <string>(); string bundleName = "bundletest"; listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v1")); listOfPrefabs.Add(TestUtil.CreatePrefabWithBundleAndVariantName(bundleName, "v2")); TestUtil.ExecuteCodeAndCleanupAssets(() => { Model.Refresh(); var rootChildList = ABModelUtil.Root.GetChildList(); Assert.AreEqual(1, rootChildList.Count); Assert.AreEqual(typeof(BundleVariantFolderInfo), rootChildList.FirstOrDefault().GetType()); BundleVariantFolderInfo folderInfo = rootChildList.FirstOrDefault() as BundleVariantFolderInfo; BundleInfo[] folderChildArray = folderInfo.GetChildList().ToArray(); Assert.AreEqual(2, folderChildArray.Length); Assert.AreEqual(typeof(BundleVariantDataInfo), folderChildArray[0].GetType()); Assert.AreEqual(typeof(BundleVariantDataInfo), folderChildArray[1].GetType()); }, listOfPrefabs); }