Esempio n. 1
0
        protected override AssetPromise_Gif CreatePromise()
        {
            string url  = TestAssetsUtils.GetPath() + "/Images/gif1.gif";
            var    prom = new AssetPromise_Gif(url);

            return(prom);
        }
        protected AssetPromise_Gif CreatePromise()
        {
            string url  = Utils.GetTestsAssetsPath() + "/Images/gif1.gif";
            var    prom = new AssetPromise_Gif(url);

            return(prom);
        }
Esempio n. 3
0
 public void Dispose()
 {
     if (hqGifPromise != null)
     {
         AssetPromiseKeeper_Gif.i.Forget(hqGifPromise);
         hqGifPromise = null;
     }
 }
Esempio n. 4
0
        public void RestorePreviewAsset()
        {
            gifPlayer?.SetGif(previewGif);

            if (hqGifPromise != null)
            {
                AssetPromiseKeeper_Gif.i.Forget(hqGifPromise);
                hqGifPromise = null;
            }
        }
        public IEnumerator FailCorrectlyWhenGivenWrongURL()
        {
            var       prom             = new AssetPromise_Gif("123325");
            Asset_Gif asset            = null;
            bool      failEventCalled1 = false;

            prom.OnSuccessEvent += (x) => { asset = x; };
            prom.OnFailEvent    += (x) => { failEventCalled1 = true; };

            var       prom2            = new AssetPromise_Gif("43254378");
            Asset_Gif asset2           = null;
            bool      failEventCalled2 = false;

            prom2.OnSuccessEvent += (x) => { asset2 = x; };
            prom2.OnFailEvent    += (x) => { failEventCalled2 = true; };

            var       prom3            = new AssetPromise_Gif("09898765");
            Asset_Gif asset3           = null;
            bool      failEventCalled3 = false;

            prom3.OnSuccessEvent += (x) => { asset3 = x; };
            prom3.OnFailEvent    += (x) => { failEventCalled3 = true; };

            keeper.Keep(prom);
            keeper.Keep(prom2);
            keeper.Keep(prom3);

            Assert.AreEqual(3, keeper.waitingPromisesCount);

            yield return(prom);

            yield return(prom2);

            yield return(prom3);

            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom.state);
            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom2.state);
            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom3.state);

            Assert.IsTrue(failEventCalled1);
            Assert.IsTrue(failEventCalled2);
            Assert.IsTrue(failEventCalled3);

            Assert.IsFalse(asset != null);
            Assert.IsFalse(asset2 != null);
            Assert.IsFalse(asset3 != null);

            Assert.IsFalse(keeper.library.Contains(asset));
            Assert.AreNotEqual(1, keeper.library.masterAssets.Count);
        }
Esempio n. 6
0
        public void FetchAndSetHQAsset(string url, Action onSuccess, Action onFail)
        {
            hqGifPromise = new AssetPromise_Gif(url);

            hqGifPromise.OnSuccessEvent += (asset) =>
            {
                gifPlayer?.SetGif(asset);
                onSuccess?.Invoke();
            };
            hqGifPromise.OnFailEvent += (asset) =>
            {
                hqGifPromise = null;
                onFail?.Invoke();
            };

            AssetPromiseKeeper_Gif.i.Keep(hqGifPromise);
        }
        public IEnumerator ShareGifAmongPromises()
        {
            Asset_Gif[]        assets   = new Asset_Gif [] { null, null };
            AssetPromise_Gif[] promises = new AssetPromise_Gif [] { CreatePromise(), CreatePromise() };

            promises[0].OnSuccessEvent += (x) => assets[0] = x;
            promises[1].OnSuccessEvent += (x) => assets[1] = x;

            for (int i = 0; i < promises.Length; i++)
            {
                keeper.Keep(promises[i]);
                yield return(promises[i]);
            }

            for (int i = 0; i < assets.Length; i++)
            {
                Assert.IsNotNull(assets[i]);
                Assert.IsNotNull(assets[i].texture);
            }

            Assert.IsTrue(assets[0].texture == assets[1].texture);
        }
Esempio n. 8
0
 public PromiseLike_Gif(AssetPromise_Gif promiseGif)
 {
     promise = promiseGif;
 }