public void DetermineRequiredAssetEntryUpdates_AssetWithoutDependenciesAndChangedHashInStaticGroup_ReturnsOnlyRevertToCachedState() { File.WriteAllText(k_ContentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); File.WriteAllText(k_ContentUpdateTestNewBundleName, "TestNewBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = group.Guid; group.GetSchema <ContentUpdateGroupSchema>().StaticContent = true; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var ops = RevertUnchangedAssetsToPreviousAssetState.DetermineRequiredAssetEntryUpdates(group, context); Assert.AreEqual(assetEntry, ops[0].AssetEntry); Assert.AreEqual(k_ContentUpdateTestNewBundleName, ops[0].CurrentBuildPath); Assert.AreEqual(k_ContentUpdateTestCachedBundlePath, ops[0].PreviousBuildPath); File.Delete(k_ContentUpdateTestCachedBundlePath); File.Delete(k_ContentUpdateTestNewBundleName); Settings.RemoveGroup(group); }
private static void ProcessCatalogEntriesForBuild(AddressableAssetsBuildContext aaContext, IBuildLogger log, IEnumerable <AddressableAssetGroup> validGroups, AddressablesDataBuilderInput builderInput, IBundleWriteData writeData, List <CachedAssetState> carryOverCachedState, Dictionary <string, string> bundleToInternalId) { using (log.ScopedStep(LogLevel.Info, "Catalog Entries.")) using (var progressTracker = new UnityEditor.Build.Pipeline.Utilities.ProgressTracker()) { progressTracker.UpdateTask("Post Processing Catalog Entries"); Dictionary <string, ContentCatalogDataEntry> locationIdToCatalogEntryMap = BuildLocationIdToCatalogEntryMap(aaContext.locations); if (builderInput.PreviousContentState != null) { ContentUpdateContext contentUpdateContext = new ContentUpdateContext() { BundleToInternalBundleIdMap = bundleToInternalId, GuidToPreviousAssetStateMap = BuildGuidToCachedAssetStateMap(builderInput.PreviousContentState, aaContext.settings), IdToCatalogDataEntryMap = locationIdToCatalogEntryMap, WriteData = writeData, ContentState = builderInput.PreviousContentState, Registry = builderInput.Registry, PreviousAssetStateCarryOver = carryOverCachedState }; RevertUnchangedAssetsToPreviousAssetState.Run(aaContext, contentUpdateContext); } else { foreach (var assetGroup in validGroups) { SetAssetEntriesBundleFileIdToCatalogEntryBundleFileId(assetGroup.entries, bundleToInternalId, writeData, locationIdToCatalogEntryMap); } } } bundleToInternalId.Clear(); }
public void DetermineRequiredAssetEntryUpdates_AssetWithMatchingCachedInternalBundleId_TakesNoAction() { string contentUpdateTestAssetGUID = GUID.Generate().ToString(); string contentUpdateTestCachedAssetHash = "8888"; string contentUpdateTestNewInternalBundleName = "bundle"; string contentUpdateTestNewBundleName = "fullbundlepath"; string contentUpdateTestCachedBundlePath = contentUpdateTestNewBundleName; string contentUpdateTestFileName = "testfile"; File.WriteAllText(contentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = group.Guid; group.GetSchema <ContentUpdateGroupSchema>().StaticContent = true; var assetEntry = CreateAssetEntry(contentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(contentUpdateTestAssetGUID, contentUpdateTestCachedAssetHash, contentUpdateTestNewInternalBundleName, contentUpdateTestNewBundleName, contentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, contentUpdateTestFileName); var ops = RevertUnchangedAssetsToPreviousAssetState.DetermineRequiredAssetEntryUpdates(group, context); Assert.IsTrue(ops.Count == 0); File.Delete(contentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void DetermineRequiredAssetEntryUpdates_WithMissingPreviousBundle_LogsWarningAndTakesNoAction() { string contentUpdateTestAssetGUID = GUID.Generate().ToString(); string contentUpdateTestCachedAssetHash = "8888"; string contentUpdateTestNewInternalBundleName = "bundle"; string contentUpdateTestNewBundleName = "fullbundlepath"; string contentUpdateTestCachedBundlePath = "cachedBundle"; string contentUpdateTestFileName = "testfile"; var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = group.Guid; group.GetSchema <ContentUpdateGroupSchema>().StaticContent = true; var assetEntry = CreateAssetEntry(contentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(contentUpdateTestAssetGUID, contentUpdateTestCachedAssetHash, contentUpdateTestNewInternalBundleName, contentUpdateTestNewBundleName, contentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, contentUpdateTestFileName); var ops = RevertUnchangedAssetsToPreviousAssetState.DetermineRequiredAssetEntryUpdates(group, context); LogAssert.Expect(LogType.Warning, $"CachedAssetState found for {assetEntry.AssetPath} but the previous bundle at {contentUpdateTestCachedBundlePath} cannot be found. " + $"The modified assets will not be able to use the previously built bundle which will result in new bundles being created " + $"for these static content groups. This will point the Content Catalog to local bundles that do not exist on currently " + $"deployed versions of an application."); Assert.IsTrue(ops.Count == 0); Settings.RemoveGroup(group); }
public void DetermineRequiredAssetEntryUpdates_WithMissingBundleFileId_LogsErrorAndTakesNoAction() { string contentUpdateTestAssetGUID = GUID.Generate().ToString(); string contentUpdateTestCachedAssetHash = "8888"; string contentUpdateTestNewInternalBundleName = "bundle"; string contentUpdateTestNewBundleName = "fullbundlepath"; string contentUpdateTestCachedBundlePath = "cachedBundle"; string contentUpdateTestFileName = "testfile"; File.WriteAllText(contentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = group.Guid; group.GetSchema <ContentUpdateGroupSchema>().StaticContent = true; var assetEntry = CreateAssetEntry(contentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(contentUpdateTestAssetGUID, contentUpdateTestCachedAssetHash, contentUpdateTestNewInternalBundleName, contentUpdateTestNewBundleName, "", contentUpdateTestGroupGuid, contentUpdateTestFileName); var ops = RevertUnchangedAssetsToPreviousAssetState.DetermineRequiredAssetEntryUpdates(group, context); LogAssert.Expect(LogType.Error, $"CachedAssetState found for {assetEntry.AssetPath} but the bundleFileId was never set on the previous build."); Assert.IsTrue(ops.Count == 0); File.Delete(contentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_DeletesCorrectBundle() { File.WriteAllText(k_ContentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); File.WriteAllText(k_ContentUpdateTestNewBundleName, "TestAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] }, new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", new List <ContentCatalogDataEntry>(), context); Assert.IsTrue(File.Exists(k_ContentUpdateTestCachedBundlePath)); Assert.IsFalse(File.Exists(k_ContentUpdateTestNewBundleName)); File.Delete(k_ContentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_InvalidKeyForGuidToPreviousAssetStateMap_DoesNotThrow() { File.WriteAllText(k_ContentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID].dependencies = new AssetState[] { new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("9823749283742") } }; var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; Assert.DoesNotThrow(() => RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", new List <ContentCatalogDataEntry>(), context)); File.Delete(k_ContentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_RegistryOnlyContainsCachedBundleEntry() { var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] }, new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", new List <ContentCatalogDataEntry>(), context); var registryPaths = context.Registry.GetFilePaths(); Assert.AreEqual(1, registryPaths.Count()); Assert.AreEqual(k_ContentUpdateTestCachedBundlePath, registryPaths.ElementAt(0)); Settings.RemoveGroup(group); }
public void DetermineRequiredAssetEntryUpdates_AssetWithDependenciesAndChangedHashInStaticGroup_ReturnsRevertToCachedStateAndDependencies() { string contentUpdateTestAssetGUID = GUID.Generate().ToString(); string contentUpdateTestCachedAssetHash = "8888"; string contentUpdateTestNewInternalBundleName = "bundle"; string contentUpdateTestNewBundleName = "fullbundlepath"; string contentUpdateTestCachedBundlePath = "cachedBundle"; string contentUpdateTestFileName = "testfile"; File.WriteAllText(contentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); File.WriteAllText(contentUpdateTestNewBundleName, "TestNewBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = group.Guid; group.GetSchema <ContentUpdateGroupSchema>().StaticContent = true; var assetEntry = CreateAssetEntry(contentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(contentUpdateTestAssetGUID, contentUpdateTestCachedAssetHash, contentUpdateTestNewInternalBundleName, contentUpdateTestNewBundleName, contentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, contentUpdateTestFileName); context.GuidToPreviousAssetStateMap[contentUpdateTestAssetGUID].dependencies = new AssetState[] { new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("00000000000000") } }; var ops = RevertUnchangedAssetsToPreviousAssetState.DetermineRequiredAssetEntryUpdates(group, context); Assert.AreEqual(assetEntry, ops[0].AssetEntry); Assert.AreEqual(contentUpdateTestNewBundleName, ops[0].CurrentBuildPath); Assert.AreEqual(contentUpdateTestCachedBundlePath, ops[0].PreviousBuildPath); File.Delete(contentUpdateTestCachedBundlePath); File.Delete(contentUpdateTestNewBundleName); Settings.RemoveGroup(group); }
public void DetermineRequiredAssetEntryUpdates_AssetWithChangedHashInNonStaticGroup_TakesNoAction() { File.WriteAllText(k_ContentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var ops = RevertUnchangedAssetsToPreviousAssetState.DetermineRequiredAssetEntryUpdates(group, context); Assert.IsTrue(ops.Count == 0); File.Delete(k_ContentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_PreviousStateDependencies_SetInCatalogEntry() { var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var previousDep = new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("9823749283742") }; var currentDep = new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("128747239872") }; context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID].dependencies = new AssetState[] { previousDep }; context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID].Dependencies.Add(currentDep); var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; string depBundleFileId = "depBundleFileId"; context.GuidToPreviousAssetStateMap.Add(previousDep.guid.ToString(), new CachedAssetState() { asset = previousDep, bundleFileId = depBundleFileId, data = previousDep, dependencies = new AssetState[0], groupGuid = contentUpdateTestGroupGuid }); var locations = new List <ContentCatalogDataEntry>(); RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", locations, context); Assert.AreEqual(1, locations.Count); Assert.AreEqual(1, ops[0].BundleCatalogEntry.Dependencies.Count); Assert.AreEqual(depBundleFileId + ops[0].AssetEntry.GetHashCode(), ops[0].BundleCatalogEntry.Dependencies[0]); Settings.RemoveGroup(group); }