public IEnumerator BundledCatalog_LoadCatalogFromBundle_InvalidBundleFileFormat_ShouldFail()
        {
            var bundleFilePath = Path.Combine(k_TempBuildFolder, "catalog.bundle");

            Directory.CreateDirectory(Path.GetDirectoryName(bundleFilePath));

            var bytes = new byte[] { 1, 2, 3, 4, 5, 6 };

            File.WriteAllBytes(bundleFilePath, bytes);

            var bundledCatalog = new ContentCatalogProvider.InternalOp.BundledCatalog(bundleFilePath);

            bundledCatalog.LoadCatalogFromBundleAsync();

            yield return(new WaitWhile(() => bundledCatalog.OpInProgress));

#if UNITY_2020_1_OR_NEWER
            LogAssert.Expect(LogType.Error, new Regex("Failed to read data for", RegexOptions.IgnoreCase));
#endif
            LogAssert.Expect(LogType.Error, new Regex("Unable to load", RegexOptions.IgnoreCase));
            Assert.IsFalse(bundledCatalog.OpIsSuccess);

            if (Directory.Exists(k_TempBuildFolder))
            {
                Directory.Delete(k_TempBuildFolder, true);
            }
        }
        public IEnumerator BundledCatalog_LoadCatalogFromBundle_WhenCalledMultipleTimes_OpNotCompleted_FirstShouldSucceedAndOthersShouldFail()
        {
            var bundleFilePath = Path.Combine(Addressables.RuntimePath, m_RuntimeCatalogFilename);

            var timesCalled    = 0;
            var bundledCatalog = new ContentCatalogProvider.InternalOp.BundledCatalog(bundleFilePath);

            bundledCatalog.OnLoaded += catalogData =>
            {
                Assert.NotNull(catalogData);
                Assert.AreEqual(ResourceManagerRuntimeData.kCatalogAddress, catalogData.ProviderId);
                timesCalled++;
            };

            bundledCatalog.LoadCatalogFromBundleAsync();
            bundledCatalog.LoadCatalogFromBundleAsync();
            LogAssert.Expect(LogType.Error, new Regex("progress", RegexOptions.IgnoreCase));

            yield return(new WaitWhile(() => bundledCatalog.OpInProgress));

            Assert.AreEqual(1, timesCalled);
        }
        public IEnumerator BundledCatalog_LoadCatalogFromBundle_WhenCalledMultipleTimes_OpCompleted_AllShouldSucceed()
        {
            var bundleFilePath = Path.Combine(Addressables.RuntimePath, m_RuntimeCatalogFilename);

            var timesCalled    = 0;
            var bundledCatalog = new ContentCatalogProvider.InternalOp.BundledCatalog(bundleFilePath);

            bundledCatalog.OnLoaded += catalogData =>
            {
                Assert.NotNull(catalogData);
                Assert.AreEqual(ResourceManagerRuntimeData.kCatalogAddress, catalogData.ProviderId);
                timesCalled++;
            };

            bundledCatalog.LoadCatalogFromBundleAsync();
            yield return(new WaitWhile(() => bundledCatalog.OpInProgress));

            bundledCatalog.LoadCatalogFromBundleAsync();
            yield return(new WaitWhile(() => bundledCatalog.OpInProgress));

            Assert.AreEqual(2, timesCalled);
            Assert.IsTrue(bundledCatalog.OpIsSuccess);
        }
Пример #4
0
        public IEnumerator BundledCatalog_WhenRemoteCatalogDoesNotExist_LoadCatalogFromBundle_LogsErrorAndOpFails()
        {
            string bundleFilePath = "file:///doesnotexist.bundle";

            var bundledCatalog = new ContentCatalogProvider.InternalOp.BundledCatalog(bundleFilePath);

            bundledCatalog.LoadCatalogFromBundleAsync();

            LogAssert.Expect(LogType.Error, $"Unable to load dependent bundle from location : {bundleFilePath}");

            yield return(new WaitWhile(() => bundledCatalog.OpInProgress));

            Assert.IsFalse(bundledCatalog.OpIsSuccess);
        }
        public IEnumerator BundledCatalog_LoadCatalogFromBundle_ShouldLoadCatalogAndUnloadResources()
        {
            var bundleFilePath = Path.Combine(Addressables.RuntimePath, m_RuntimeCatalogFilename);

            var bundledCatalog = new ContentCatalogProvider.InternalOp.BundledCatalog(bundleFilePath);

            bundledCatalog.LoadCatalogFromBundleAsync();
            bundledCatalog.OnLoaded += catalogData =>
            {
                Assert.NotNull(catalogData);
                Assert.AreEqual(ResourceManagerRuntimeData.kCatalogAddress, catalogData.ProviderId);
            };

            yield return(new WaitWhile(() => bundledCatalog.OpInProgress));

            Assert.IsTrue(bundledCatalog.OpIsSuccess);
            Assert.Null(bundledCatalog.m_CatalogAssetBundle);
        }