public void AssetBundleRequestOptionsTest() { var options = new AssetBundleRequestOptions { ChunkedTransfer = true, Crc = 123, Hash = new Hash128(1, 2, 3, 4).ToString(), RedirectLimit = 4, RetryCount = 7, Timeout = 12 }; var dataEntry = new ContentCatalogDataEntry(typeof(ContentCatalogData), "internalId", "provider", new object[] { 1 }, null, options); var entries = new List <ContentCatalogDataEntry>(); entries.Add(dataEntry); var ccData = new ContentCatalogData(entries); var locator = ccData.CreateLocator(); IList <IResourceLocation> locations; if (!locator.Locate(1, typeof(object), out locations)) { Assert.Fail("Unable to locate resource location"); } var loc = locations[0]; var locOptions = loc.Data as AssetBundleRequestOptions; Assert.IsNotNull(locOptions); Assert.AreEqual(locOptions.ChunkedTransfer, options.ChunkedTransfer); Assert.AreEqual(locOptions.Crc, options.Crc); Assert.AreEqual(locOptions.Hash, options.Hash); Assert.AreEqual(locOptions.RedirectLimit, options.RedirectLimit); Assert.AreEqual(locOptions.RetryCount, options.RetryCount); Assert.AreEqual(locOptions.Timeout, options.Timeout); }
public void VerifySerialization() { var sw = Stopwatch.StartNew(); sw.Start(); var catalog = new ContentCatalogData(); var entries = new List <ContentCatalogDataEntry>(); var availableKeys = new List <object>(); for (int i = 0; i < 1000; i++) { var internalId = "Assets/TestPath/" + GUID.Generate() + ".asset"; var eKeys = GetRandomSubset(m_Keys, Random.Range(1, 5)); object data; if (i % 2 == 0) { data = new EvenData { index = i, path = internalId } } ; else { data = new OddData { index = i, path = internalId } }; var e = new ContentCatalogDataEntry(typeof(ContentCatalogData), internalId, m_Providers[Random.Range(0, m_Providers.Count)].FullName, eKeys, GetRandomSubset(availableKeys, Random.Range(0, 1)), data); availableKeys.Add(eKeys[0]); entries.Add(e); } catalog.SetData(entries); sw.Stop(); var t = sw.Elapsed.TotalMilliseconds; sw.Reset(); sw.Start(); var locMap = catalog.CreateLocator(); sw.Stop(); Debug.LogFormat("Create: {0}ms, Load: {1}ms", t, sw.Elapsed.TotalMilliseconds); foreach (var k in locMap.Locations) { foreach (var loc in k.Value) { var entry = entries.Find(e => e.InternalId == loc.InternalId); Assert.AreEqual(entry.Provider, loc.ProviderId); var deps = loc.Dependencies; if (deps != null) { foreach (var ed in entry.Dependencies) { IList <IResourceLocation> depList; Assert.IsTrue(locMap.Locate(ed, typeof(object), out depList)); for (int i = 0; i < depList.Count; i++) { Assert.AreEqual(depList[i].InternalId, deps[i].InternalId); } } } } } }