From 9c1200bab4b0b22f3c701dd94163cf091f98e316 Mon Sep 17 00:00:00 2001 From: alexiscatnip Date: Wed, 19 Jan 2022 21:33:12 +0800 Subject: [PATCH] Closes #10. modified the test to login twice --- Assets/Raindrop/UI/screens/LoginPresenter.cs | 27 +- Assets/Scenes/MainScene.unity | 98 ++++---- Assets/Tests/RaindropIntegrationTests.cs | 244 +++++++++++-------- 3 files changed, 200 insertions(+), 169 deletions(-) diff --git a/Assets/Raindrop/UI/screens/LoginPresenter.cs b/Assets/Raindrop/UI/screens/LoginPresenter.cs index ed81644..5aa3403 100644 --- a/Assets/Raindrop/UI/screens/LoginPresenter.cs +++ b/Assets/Raindrop/UI/screens/LoginPresenter.cs @@ -63,7 +63,7 @@ namespace Raindrop.Presenters } public ReactiveProperty loginMsg = new ReactiveProperty(""); //"" is a magic value that is required to prevent showing the modal immediately on load. - private ReactiveProperty btnLoginEnabled = new ReactiveProperty(true); + private ReactiveProperty LoginButton_IsClickable = new ReactiveProperty(true); //is empty string if there is no error. public ReactiveProperty credParserErrorString = new ReactiveProperty(); @@ -97,7 +97,11 @@ namespace Raindrop.Presenters //3 hookup reactive UIs. LoginButton.onClick.AsObservable().Subscribe(_ => OnLoginBtnClick()); //when clicked, runs this method. - btnLoginEnabled.AsObservable().Subscribe(_ => LoginButton.gameObject.SetActive(_)); //update the login button availabilty according to this boolean. + LoginButton_IsClickable.AsObservable().Subscribe(_ => + { + LoginButton.gameObject.SetActive(_); + LoginButton.interactable = _; + }); //update the login button availabilty according to this boolean. usernameField.onValueChanged.AsObservable().Subscribe(_ => { @@ -204,7 +208,7 @@ namespace Raindrop.Presenters case LoginStatus.Success: loginMsg.Value += "Logged in as " + netcom.LoginOptions.FullName; - btnLoginEnabled.Value = false; + LoginButton_IsClickable.Value = false; // instance.Client.Groups.RequestCurrentGroups(); Close_LoginModal_Slow(); @@ -218,18 +222,16 @@ namespace Raindrop.Presenters if (e.FailReason == "tos") { loginMsg.Value = "Must agree to Terms of Service before logging in"; - uimanager.modalManager.showModalNotification("Logging in failed",loginMsg.Value); + //uimanager.modalManager.showModalNotification("Logging in failed",loginMsg.Value); //pnlTos.Visible = true; //txtTOS.Text = e.Message.Replace("\n", "\r\n"); - btnLoginEnabled.Value = true; - LoginButton.interactable = true; + LoginButton_IsClickable.Value = true; } else { loginMsg.Value = e.Message; - uimanager.modalManager.showModalNotification("Logging in failed", loginMsg.Value); - btnLoginEnabled.Value = true; - LoginButton.interactable = true; + //uimanager.modalManager.showModalNotification("Logging in failed", loginMsg.Value); + LoginButton_IsClickable.Value = true; } break; } @@ -238,7 +240,8 @@ namespace Raindrop.Presenters public void netcom_ClientLoggedOut(object sender, EventArgs e) { loginMsg.Value = "logged out."; - uimanager.modalManager.showModalNotification("Login status", loginMsg.Value); + // uimanager.modalManager.showModalNotification("Login status", loginMsg.Value); + LoginButton_IsClickable.Value = true; //pnlLoginPrompt.Visible = true; //pnlLoggingIn.Visible = false; @@ -248,7 +251,7 @@ namespace Raindrop.Presenters public void netcom_ClientLoggingOut(object sender, OverrideEventArgs e) { - btnLoginEnabled.Value = false; + LoginButton_IsClickable.Value = false; loginMsg.Value = "Logging out..."; // uimanager.modalManager.showModalNotification("Login status", Login_msg.Value); @@ -259,7 +262,7 @@ namespace Raindrop.Presenters loginMsg.Value = "Start to Logging in..."; // uimanager.modalManager.showModalNotification("Login status", Login_msg.Value); - btnLoginEnabled.Value = false; + LoginButton_IsClickable.Value = false; } diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index a5ad9f6..56ad9a9 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -1851,7 +1851,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 505369346} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fa61eabca29ec274e822d94f50702a99, type: 3} m_Name: @@ -2727,9 +2727,9 @@ RectTransform: m_Father: {fileID: 4864090719644605630} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 578.0375, y: -78.67935} m_SizeDelta: {x: 212.5211, y: 122.8239} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &665582346 @@ -4262,9 +4262,9 @@ RectTransform: m_Father: {fileID: 7342915068255667008} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 150, y: -150} m_SizeDelta: {x: 300, y: 300} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &866740886 @@ -5136,9 +5136,9 @@ RectTransform: m_Father: {fileID: 4864090719644605630} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 342.14902, y: -78.67935} m_SizeDelta: {x: 212.5211, y: 122.8239} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1117884413 @@ -6395,9 +6395,9 @@ RectTransform: m_Father: {fileID: 665582345} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 100.597595, y: -68.77045} m_SizeDelta: {x: 201.19519, y: 137.5409} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1362173643 @@ -8075,7 +8075,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7869931064214119123, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3} propertyPath: m_AnchorMin.y - value: 0.00094008446 + value: 0 objectReference: {fileID: 0} - target: {fileID: 7869931064243508739, guid: 6d2618c0195b58c43b26e914c74c68ea, type: 3} propertyPath: m_AnchorMax.y @@ -9552,7 +9552,7 @@ RectTransform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0.48691124} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 20, y: 20} m_Pivot: {x: 0.5, y: 0.5} @@ -10978,9 +10978,9 @@ RectTransform: m_Father: {fileID: 1117884412} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 100.597595, y: -68.77045} m_SizeDelta: {x: 201.19519, y: 137.5409} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2130253299 @@ -11697,9 +11697,9 @@ RectTransform: m_Father: {fileID: 7342915068255667008} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 226.915, y: -322.345} m_SizeDelta: {x: 453.83, y: 44.69} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &2034435792207592601 @@ -12966,7 +12966,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &7342915067822221018 MonoBehaviour: m_ObjectHideFlags: 0 @@ -13170,10 +13170,10 @@ RectTransform: m_Father: {fileID: 7342915068755596249} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 217.42072, y: -76.8} + m_SizeDelta: {x: 140, y: 140} m_Pivot: {x: 0.5, y: 0.5} --- !u!224 &7342915068212254128 RectTransform: @@ -13189,10 +13189,10 @@ RectTransform: m_Father: {fileID: 7342915068755596249} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 1672.5793, y: -76.8} + m_SizeDelta: {x: 200, y: 143.6} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &7342915068212254129 MonoBehaviour: @@ -13587,9 +13587,9 @@ RectTransform: m_Father: {fileID: 7342915068255667008} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 288.97, y: -633.52875} m_SizeDelta: {x: 577.94, y: 407.3851} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &7342915068506302733 @@ -13825,9 +13825,9 @@ RectTransform: m_Father: {fileID: 4864090719644605630} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 106.26055, y: -78.67935} m_SizeDelta: {x: 212.5211, y: 122.8239} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &7342915068667080760 @@ -14071,10 +14071,10 @@ RectTransform: m_Father: {fileID: 7342915068755596249} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 930, y: -76.8} + m_SizeDelta: {x: 642.5793, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &7342915068738205369 MonoBehaviour: @@ -14370,9 +14370,9 @@ RectTransform: m_Father: {fileID: 7342915068255667008} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 226.915, y: -364.9181} m_SizeDelta: {x: 453.83, y: 40.4562} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &7342915069145180224 @@ -14407,9 +14407,9 @@ RectTransform: m_Father: {fileID: 7342915068667080759} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 100.597595, y: -68.77045} m_SizeDelta: {x: 201.19519, y: 137.5409} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &7342915069145180236 @@ -14638,9 +14638,9 @@ RectTransform: m_Father: {fileID: 7342915068255667008} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 226.915, y: -407.4912} m_SizeDelta: {x: 453.83, y: 44.69} m_Pivot: {x: 0.5, y: 0.5} --- !u!224 &7380121242292692513 diff --git a/Assets/Tests/RaindropIntegrationTests.cs b/Assets/Tests/RaindropIntegrationTests.cs index 08609a8..b08f8b1 100644 --- a/Assets/Tests/RaindropIntegrationTests.cs +++ b/Assets/Tests/RaindropIntegrationTests.cs @@ -16,7 +16,6 @@ using OpenMetaverse.Imaging; using OpenMetaverse.ImportExport.Collada14; using Raindrop.Services; using TMPro; -using UnityEditor.PackageManager; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; @@ -34,103 +33,107 @@ namespace Raindrop.Tests private RaindropNetcom netcom { get { return instance.Netcom; } } private RaindropInstance instance { get { return ServiceLocator.ServiceLocator.Instance.Get(); } } - - [SetUp] - public void Setup() + [OneTimeSetUp] + public void OneTimeSetUp() { //load the main scene. SceneManager.LoadScene("Scenes/MainScene"); } - - [TearDown] - public void TearDown() - { - // if (netcom.IsLoggedIn) - // { - // netcom.Logout(); - // } - Application.Quit(); - } + // + // [TearDown] + // public void TearDown() + // { + // SceneManager.CreateScene("some scene"); + // + // } + // // decode a j2p into a managed image. convert it to t2d. save it to disk. // the goal is to make sure the image is not upside down. - [UnityTest] - public IEnumerator decode_j2p_variant1() - { - //decode - var relax_b = File.ReadAllBytes("C:\\Users\\Alexis\\Pictures\\menhara.jp2"); - ManagedImage im; - OpenJPEG.DecodeToImage(relax_b, out im); - - //convert to unityland - Texture2D t2d; - t2d = im.ExportTex2D(); - - //print. - var bytes = t2d.EncodeToJPG(100); - System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "relax.jpg"), bytes); + // [UnityTest] + // public IEnumerator decode_j2p_variant1() + // { + // //decode + // var relax_b = File.ReadAllBytes("C:\\Users\\Alexis\\Pictures\\menhara.jp2"); + // ManagedImage im; + // OpenJPEG.DecodeToImage(relax_b, out im); + // + // //convert to unityland + // Texture2D t2d; + // t2d = im.ExportTex2D(); + // + // //print. + // var bytes = t2d.EncodeToJPG(100); + // System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "relax.jpg"), bytes); + // + // + // yield break; + // } - - yield break; - } + // [UnityTest] + // // managedimage -> texture2d -> managed image test + // /* 1. create managedimage 2x2 red-blue-green- black image by code. + // * 2. call convert to texture2d. + // * 3. print to screen. + // * 4. convert back to managed image. + // * 5. print to disk. + // */ //weird ass test + // public IEnumerator ManagedImage_Texture2D_conversions() + // { + // //1 load the image using unity's texture 2d (known to be correct.). + // var tex = new Texture2D(1024,1024); + // var b = File.ReadAllBytes("C:\\Users\\Alexis\\Pictures\\menhara.jpg"); + // tex.LoadImage(b); + // // OpenMetaverse.Imaging.LoadTGAClass.LoadTGA( + // // "C:\\Users\\Alexis\\Pictures\\menhara.tga"); + // + // + // + // //1b. check image loading integrity. + // // var bytesa = tex.EncodeToJPG(100); + // // System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "menhara_from_t2d.jpg"), bytesa); + // // mi.Blue[2] = 0xFF; + // // mi.Red[0] = 0xFF; + // // mi.Green[1] = 0xFF; + // // // mi.Blue = new byte[]{0x00,0x00,0xFF,0x00}; + // // mi.Red = new byte[]{0xFF,0x00,0x00,0x00}; + // // mi.Green = new byte[]{0x00,0xFF,0x00,0x00}; + // + // //2 print mi to disk in some easy to read format. + // // error! this image is written to disk upside down!. + // ManagedImage mi = new ManagedImage(tex); + // var tgaBytes = mi.ExportTGA(); + // Debug.Log("writing to "+ Path.Combine(Application.persistentDataPath, "exportTGA_managed_image1.tga").ToString()); + // System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "exportTGA_managed_image1.tga"), tgaBytes); + // + // //3. convert to t2d and show on screen. + // Texture2D t2d = mi.ExportTex2D(); + // // plane.make + // // plane.show(t2d) + // + // var bytes = t2d.EncodeToJPG(100); + // System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "EncodeToJPG_Texture2d.jpg"), bytes); + // + // yield return new WaitForSeconds(1); + // + // //4. convert back to tga, save it as a 2nd file. + // ManagedImage mi2 = new ManagedImage(t2d); + // // error:this method writes a up-side down image. + // var tgaBytes2 = mi2.ExportTGA(); + // System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "exportTGA_managedimage2.tga"), tgaBytes2); + // + // Assert.Pass(); + // yield break; + // } [UnityTest] - // managedimage -> texture2d -> managed image test - /* 1. create managedimage 2x2 red-blue-green- black image by code. - * 2. call convert to texture2d. - * 3. print to screen. - * 4. convert back to managed image. - * 5. print to disk. - */ //weird ass test - public IEnumerator ManagedImage_Texture2D_conversions() + //assert pass is working (teardown is ok) + public IEnumerator AbleToAssertPass() { - //1 load the image using unity's texture 2d (known to be correct.). - var tex = new Texture2D(1024,1024); - var b = File.ReadAllBytes("C:\\Users\\Alexis\\Pictures\\menhara.jpg"); - tex.LoadImage(b); - // OpenMetaverse.Imaging.LoadTGAClass.LoadTGA( - // "C:\\Users\\Alexis\\Pictures\\menhara.tga"); - - - - //1b. check image loading integrity. - // var bytesa = tex.EncodeToJPG(100); - // System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "menhara_from_t2d.jpg"), bytesa); - // mi.Blue[2] = 0xFF; - // mi.Red[0] = 0xFF; - // mi.Green[1] = 0xFF; - // // mi.Blue = new byte[]{0x00,0x00,0xFF,0x00}; - // mi.Red = new byte[]{0xFF,0x00,0x00,0x00}; - // mi.Green = new byte[]{0x00,0xFF,0x00,0x00}; - - //2 print mi to disk in some easy to read format. - // error! this image is written to disk upside down!. - ManagedImage mi = new ManagedImage(tex); - var tgaBytes = mi.ExportTGA(); - Debug.Log("writing to "+ Path.Combine(Application.persistentDataPath, "managed_image_export.tga").ToString()); - System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "managed_image_export.tga"), tgaBytes); - - //3. convert to t2d and show on screen. - Texture2D t2d = mi.ExportTex2D(); - // plane.make - // plane.show(t2d) - - var bytes = t2d.EncodeToJPG(100); - System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "managed_image_to_texture2d.jpg"), bytes); - - yield return new WaitForSeconds(1); - - //4. convert back to tga, save it as a 2nd file. - ManagedImage mi2 = new ManagedImage(t2d); - // error:this method writes a up-side down image. - var tgaBytes2 = mi2.ExportTGA(); - System.IO.File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "smallPic2.tga"), tgaBytes2); - Assert.Pass(); yield break; } - [UnityTest] //login UI-backend-UI test /* 1. [UI] enter creds, press login button @@ -141,7 +144,6 @@ namespace Raindrop.Tests */ public IEnumerator LoginLogoutTest() { - //0. is the scene ready? var gm = GameObject.Find("GameManager"); var vm = GameObject.Find("ViewsManager"); @@ -157,18 +159,18 @@ namespace Raindrop.Tests if (UISrv.canvasManager.topCanvas.canvasType == CanvasType.Eula) { // well, we need to agree to eula first. - Utils.UI.accepttheeula(); + Utils.UIHelpers.accepttheeula(); } //1b. we are on the welcome screen. now navigate to the login screen. if (UISrv.canvasManager.topCanvas.canvasType == CanvasType.Welcome) { yield return new WaitForSeconds(2); - Utils.UI.Click_Button_Welcome2LoginScreen(); + Utils.UIHelpers.Click_Button_Welcome2LoginScreen(); } else { - Assert.Fail("expected to be on the login screen!"); + Assert.Fail("expected to be on the welcome screen!"); } //Extra: set reducedsettings so that we do not use too many dependencies @@ -186,49 +188,75 @@ namespace Raindrop.Tests var loginPresenter = vm.GetComponent().getForegroundCanvas().GetComponent(); string _username = "***REMOVED*** Resident"; - Utils.UI.Set_TMPInputField_ofGameObjectName("UserTextField", _username); + Utils.UIHelpers.Set_TMPInputField_ofGameObjectName("UserTextField", _username); string _password = "***REMOVED***"; - Utils.UI.Set_TMPInputField_ofGameObjectName("PassTextField", _password); + Utils.UIHelpers.Set_TMPInputField_ofGameObjectName("PassTextField", _password); yield return new WaitForSeconds(2); - Utils.UI.ClickButtonByUnityName("LoginBtn"); + Utils.UIHelpers.ClickButtonByUnityName("LoginBtn"); //assert the backend API; that we are logged in. yield return new WaitForSeconds(20); Assert.True(instance.Client.Network.Connected == true, "check API that we are logged in"); //finally, disconnect. assert disconnected. - Utils.UI.Click_DisconnectButton(); + Utils.UIHelpers.Click_DisconnectButton(); yield return new WaitForSeconds(5); Assert.True(instance.Client.Network.Connected == false, "check API that we are logged out"); + yield return new WaitForSeconds(30); + + + + + //try to login again! + + //1b. we are on the welcome screen. now navigate to the login screen. + if (UISrv.canvasManager.topCanvas.canvasType == CanvasType.Welcome) + { + yield return new WaitForSeconds(2); + Utils.UIHelpers.Click_Button_Welcome2LoginScreen(); + } + else + { + Assert.Fail("expected to be on the welcome screen!"); + } + Assert.True(UISrv.canvasManager.topCanvas.canvasType == CanvasType.Login); + yield return new WaitForSeconds(2); + Assert.True(instance.Client.Network.Connected == false, "check API that we are logged out"); + + loginPresenter + = vm.GetComponent().getForegroundCanvas().GetComponent(); + Utils.UIHelpers.Set_TMPInputField_ofGameObjectName("UserTextField", _username); + Utils.UIHelpers.Set_TMPInputField_ofGameObjectName("PassTextField", _password); + yield return new WaitForSeconds(2); + Utils.UIHelpers.ClickButtonByUnityName("LoginBtn"); + //assert the backend API; that we are logged in. + yield return new WaitForSeconds(20); + Assert.True(instance.Client.Network.Connected == true, "check API that we are logged in"); + + //finally, disconnect. assert disconnected. + Utils.UIHelpers.Click_DisconnectButton(); + yield return new WaitForSeconds(5); + Assert.True(instance.Client.Network.Connected == false, "check API that we are logged out"); + + Assert.Pass(); - // yield break; - + Debug.Log("test is ok!"); + yield return new WaitForSeconds(30); } - public async Task GetTestTaskAsync(int delay) - { - Debug.Log("1"); - await Task.Delay(TimeSpan.FromMilliseconds(delay)); - Debug.Log("2"); - //await Task.Run(async () => await Task.Delay(TimeSpan.FromSeconds(delay))); - //Debug.Log("3"); - //await Task.Delay(TimeSpan.FromMilliseconds(200)); - //Debug.Log("4"); - } - public class Utils { /* * A whole bunch of methods to click buttons and type into inputfields. */ - public class UI + public class UIHelpers { public static bool ClickButtonByUnityName(string gameObjectName) { var btn = GameObject.Find(gameObjectName); - Assert.IsNotNull(btn, "Missing button " + btn.ToString()); + Assert.IsNotNull(btn, "Missing button supposed to have name: " + gameObjectName); if (btn.GetComponent