Пример #1
0
        public override IEnumerator RunTest()
        {
            LogConsole.RegisterForAllLogEvents(this);

            DataStore <MyDataModel> store = new DataStore <MyDataModel>(Reducers.MainReducer, initialModel);

            var map = gameObject.GetLinkMap();

            Task showForm1 = map.Get <Button>("ShowForm1").SetOnClickAction(async delegate {
                MyFormPresenter presenter   = new MyFormPresenter();
                presenter.targetView        = gameObject.GetViewStack().ShowView("Ui16_MyForm1");
                presenter.simulateUserInput = simulateUserInput;
                await presenter.LoadModelIntoView(store);
            });

            Task showForm2 = map.Get <Button>("ShowForm2").SetOnClickAction(async delegate {
                MyFormPresenter presenter   = new MyFormPresenter();
                presenter.targetView        = gameObject.GetViewStack().ShowView("Ui16_MyForm1");
                presenter.simulateUserInput = simulateUserInput;
                var fork = store.NewFork();
                await presenter.LoadModelIntoView(fork);
                fork.ApplyMutationsBackToOriginalStore();
                ShowFormCompletedDebugInfos(fork);
            });

            if (simulateUserInput)
            {
                SimulateButtonClickOn("ShowForm1");
                yield return(showForm1.AsCoroutine());

                SimulateButtonClickOn("ShowForm2");
                yield return(showForm2.AsCoroutine());
            }
        }
Пример #2
0
        void Start()
        {
            LogConsole.RegisterForAllLogEvents(this);

            links = gameObject.GetLinkMap();
            links.Get <Button>("ButtonTestJsonLib").SetOnClickAction(delegate { TestJsonSerialization(); });
            links.Get <Button>("ButtonTestPing").SetOnClickAction(delegate {
                StartCoroutine(TestCurrentPing(links.Get <InputField>("IpInput").text));
            });
            var img = links.Get <Image>("Image1");

            img.type           = Image.Type.Simple;
            img.preserveAspect = true;
            links.Get <Button>("ButtonLoadImage1").SetOnClickAction(delegate {
                var t = Log.MethodEntered("ButtonLoadImage1");
                StartCoroutine(DownloadTexture2D(new Uri(url), new Response <Texture2D>().WithResultCallback(texture2d => {
                    img.sprite = texture2d.ToSprite();
                    Log.MethodDone(t);
                })));
            });
            links.Get <Button>("ButtonLoadImage2").SetOnClickAction(delegate {
                var t = Log.MethodEntered("ButtonLoadImage2");
                StartCoroutine(DownloadBytes(new Uri(url), new Response <byte[]>().WithResultCallback(async downloadedBytes => {
                    var texture2d = await ImageHelper.ToTexture2D(downloadedBytes);
                    img.sprite    = texture2d.ToSprite();
                    Log.MethodDone(t);
                })));
            });
        }
Пример #3
0
        public override IEnumerator RunTest()
        {
            IoC.inject.SetSingleton <IPreferences>(PlayerPrefsStore.NewPreferencesUsingPlayerPrefs());
            LogConsole.RegisterForAllLogEvents(this);

            links = gameObject.GetLinkMap();
            links.Get <Button>("ButtonTestJsonLib").SetOnClickAction(delegate {
                TestJsonSerialization().LogOnError();
            });
            links.Get <Button>("ButtonTestPing").SetOnClickAction(delegate {
                StartCoroutine(TestCurrentPing(links.Get <InputField>("IpInput").text));
            });
            links.Get <Button>("ButtonShowToast").SetOnClickAction(delegate {
                Toast.Show("Hello World");
            });
            // Clicking multiple times on a button with an async action will only execute the first click:
            links.Get <Button>("ButtonRunAsyncMethod").SetOnClickAction(async delegate {
                await Task.Delay(2000);
                Toast.Show("Button waited 2 seconds");
            });

            yield return(new WaitForSeconds(0.5f));

            SimulateButtonClickOn("ButtonTestJsonLib");

            yield return(new WaitForSeconds(0.5f));

            SimulateButtonClickOn("ButtonTestPing");
        }
Пример #4
0
        public override IEnumerator RunTest()
        {
            LogConsole.RegisterForAllLogEvents(this);

            links = gameObject.GetLinkMap();
            var img = links.Get <Image>("Image1");

            img.type           = Image.Type.Simple;
            img.preserveAspect = true;
            links.Get <Button>("ButtonLoadImage1").SetOnClickAction(delegate {
                var t = Log.MethodEntered("ButtonLoadImage1");
                StartCoroutine(DownloadTexture2D(new Uri(GetUrl()), new Response <Texture2D>().WithResultCallback(texture2d => {
                    img.sprite = texture2d.ToSprite();
                    Log.MethodDone(t);
                })));
            });
            links.Get <Button>("ButtonLoadImage2").SetOnClickAction(delegate {
                var t = Log.MethodEntered("ButtonLoadImage2");
                StartCoroutine(DownloadBytes(new Uri(GetUrl()), new Response <byte[]>().WithResultCallback(async downloadedBytes => {
                    var texture2d = await ImageLoaderUnity.ToTexture2D(downloadedBytes);
                    img.sprite    = texture2d.ToSprite();
                    Log.MethodDone(t);
                })));
            });
            links.Get <Button>("ButtonLoadImage3").SetOnClickAction(async delegate {
                var t = Log.MethodEntered("ButtonLoadImage3");
                Texture2D loadedImage = await links.Get <Image>("Image2").LoadFromUrl(GetUrl());
                Log.MethodDone(t);
                Toast.Show($"The loaded texture has the size: {loadedImage.width}x{loadedImage.height} pixels");
            });

            yield return(null);
        }
Пример #5
0
 public override IEnumerator RunTest()
 {
     LogConsole.RegisterForAllLogEvents(this);
     for (int i = 0; i < 20; i++)
     {
         LogConsole.GetLogConsole(this).AddToLog(LogEntry.d("Log event " + i));
         yield return(new WaitForSeconds(0.5f));
     }
 }
Пример #6
0
        public override IEnumerator RunTest()
        {
            LogConsole.RegisterForAllLogEvents(this);

            links = gameObject.GetLinkMap();
            links.Get <Button>("ButtonTestJsonLib").SetOnClickAction(delegate { TestJsonSerialization(); });
            links.Get <Button>("ButtonTestPing").SetOnClickAction(delegate {
                StartCoroutine(TestCurrentPing(links.Get <InputField>("IpInput").text));
            });

            yield return(new WaitForSeconds(0.5f));

            SimulateButtonClickOn("ButtonTestJsonLib");

            yield return(new WaitForSeconds(0.5f));

            SimulateButtonClickOn("ButtonTestPing");
        }
Пример #7
0
        public override IEnumerator RunTest()
        {
            IoC.inject.SetSingleton <IPreferences>(PlayerPrefsStore.NewPreferencesUsingPlayerPrefs());
            LogConsole.RegisterForAllLogEvents(this);

            links = gameObject.GetLinkMap();
            links.Get <Button>("ButtonTestJsonLib").SetOnClickAction(delegate { TestJsonSerialization().LogOnError(); });
            links.Get <Button>("ButtonTestPing").SetOnClickAction(delegate {
                StartCoroutine(TestCurrentPing(links.Get <InputField>("IpInput").text));
            });

            yield return(new WaitForSeconds(0.5f));

            SimulateButtonClickOn("ButtonTestJsonLib");

            yield return(new WaitForSeconds(0.5f));

            SimulateButtonClickOn("ButtonTestPing");
        }
Пример #8
0
        public override IEnumerator RunTest() {

            // Enable the log console and register to show all logging events in it:
            LogConsole.RegisterForAllLogEvents(this);

            // Configure a button to log errors when clicked:
            var map = gameObject.GetLinkMap();
            map.Get<Button>("Save").SetOnClickAction(delegate { Log.e("Save button clicked"); });

            // Print out a few example log entries manually:
            for (int i = 0; i < 10; i++) {
                LogConsole.GetLogConsole(this).AddToLog(LogEntry.d("Log event " + i));
                yield return new WaitForSeconds(0.5f);
            }

            // Entries can have custom colors, icons, ..:
            LogEntry entry = LogEntry.d("All logged");
            entry.color = Color.green.GetDarkerVariant();
            LogConsole.GetLogConsole(this).AddToLog(entry);

        }
Пример #9
0
        public override IEnumerator RunTest()
        {
            LogConsole.RegisterForAllLogEvents(this);

            links = gameObject.GetLinkMap();

            TestTexture2dVsRawByteLoadingSpeeds();

            links.Get <Button>("ButtonLoadImage3").SetOnClickAction(async delegate {
                var t = Log.MethodEntered("ButtonLoadImage3");
                Texture2D texture2d = await links.Get <Image>("Image2").LoadFromUrl(GetUrl());
                Log.MethodDone(t);
                Toast.Show($"The loaded texture has the size: {texture2d.width}x{texture2d.height} pixels");
            });

            links.Get <Button>("ButtonLoadImage4").SetOnClickAction(async delegate {
                DirectoryEntry targetDir = EnvironmentV2.instance.GetOrAddTempFolder("Ui14_ImageLoading");

                var imgRefFile = targetDir.GetChild("imgRef.txt");
                FileRef imgRef = imgRefFile.Exists ? imgRefFile.LoadAs <FileRef>() : null;
                if (imgRef == null)
                {
                    imgRef = new FileRef()
                    {
                        url = testUrl
                    };
                }

                var t = Log.MethodEntered("LoadAndPersistTo");
                await links.Get <Image>("Image2").LoadAndPersistTo(imgRef, targetDir, 64);
                Log.MethodDone(t);

                imgRefFile.SaveAsJson(imgRef, true); // Save so that it will be reused next time
            });

            yield return(null);
        }