using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; #if pHUMANOID4 using NUnit.Framework; namespace Passer.Humanoid { public class Sites_Test { public void Setup() { UnityEngine.SceneManagement.SceneManager.LoadScene("HumanoidControl/Runtime/Visitors/HumanoidVisitor Desktop"); } [UnityTest] [Category("Sites")] public IEnumerator VisitShootingRange() { Setup(); yield return new WaitForSeconds(1); HumanoidControl humanoid = Object.FindObjectOfType(); Assert.IsFalse(humanoid == null); SiteNavigator navigator = humanoid.GetComponentInChildren(); Assert.IsFalse(navigator == null); navigator.LoadSiteFromURL("serrarens.nl/sites/shootingrange"); yield return new WaitForSeconds(2); int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); bool found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "ShootingRange") found = true; } Assert.IsTrue(found); yield return new WaitForSeconds(1); // Destroy explicitly, because DontDestroyOnLoad is enabled Object.Destroy(humanoid.gameObject); yield return new WaitForSeconds(0.1F); } [UnityTest] [Category("Sites")] public IEnumerator VisitSocialSpace() { Setup(); yield return new WaitForSeconds(1); HumanoidControl humanoid = Object.FindObjectOfType(); Assert.IsFalse(humanoid == null); SiteNavigator navigator = humanoid.GetComponentInChildren(); Assert.IsFalse(navigator == null); navigator.LoadSiteFromURL("serrarens.nl/sites/socialspace"); yield return new WaitForSeconds(2); int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); bool found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "SocialSpace") found = true; } Assert.IsTrue(found); yield return new WaitForSeconds(1); // Destroy explicitly, because DontDestroyOnLoad is enabled Object.Destroy(humanoid.gameObject); yield return new WaitForSeconds(0.1F); } [UnityTest] [Category("Sites")] public IEnumerator VisitAvatarShop() { Setup(); yield return new WaitForSeconds(1); HumanoidControl humanoid = Object.FindObjectOfType(); Assert.IsFalse(humanoid == null); SiteNavigator navigator = humanoid.GetComponentInChildren(); Assert.IsFalse(navigator == null); navigator.LoadSiteFromURL("serrarens.nl/sites/avatarshop"); yield return new WaitForSeconds(2); int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); bool found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "AvatarShop") found = true; } Assert.IsTrue(found); yield return new WaitForSeconds(1); // Destroy explicitly, because DontDestroyOnLoad is enabled Debug.Log("Destroying humanoid gameObject"); Object.Destroy(humanoid.gameObject); yield return new WaitForSeconds(0.1F); } [UnityTest] [Category("Sites")] public IEnumerator VisitGroceryStore() { Setup(); yield return new WaitForSeconds(1); HumanoidControl humanoid = Object.FindObjectOfType(); Assert.IsFalse(humanoid == null); SiteNavigator navigator = humanoid.GetComponentInChildren(); Assert.IsFalse(navigator == null); navigator.LoadSiteFromURL("serrarens.nl/sites/grocerystore"); yield return new WaitForSeconds(2); int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); bool found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "GroceryStore") found = true; } Assert.IsTrue(found); yield return new WaitForSeconds(1); // Destroy explicitly, because DontDestroyOnLoad is enabled Object.Destroy(humanoid.gameObject); yield return new WaitForSeconds(0.1F); } [UnityTest] [Category("Sites")] public IEnumerator VisitTour() { Setup(); yield return new WaitForSeconds(1); HumanoidControl humanoid = Object.FindObjectOfType(); Assert.IsFalse(humanoid == null); SiteNavigator navigator = humanoid.GetComponentInChildren(); Assert.IsFalse(navigator == null); navigator.LoadSiteFromURL("serrarens.nl/sites/shootingrange"); yield return new WaitForSeconds(2); int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); bool found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "ShootingRange") found = true; } Assert.IsTrue(found); navigator.LoadSiteFromURL("serrarens.nl/sites/socialspace"); yield return new WaitForSeconds(2); sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "SocialSpace") found = true; } Assert.IsTrue(found); navigator.LoadSiteFromURL("serrarens.nl/sites/avatarshop"); yield return new WaitForSeconds(2); sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "AvatarShop") found = true; } Assert.IsTrue(found); navigator.LoadSiteFromURL("serrarens.nl/sites/grocerystore"); yield return new WaitForSeconds(2); sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; Assert.AreEqual(1, sceneCount); found = false; for (int i = 0; i < sceneCount; i++) { Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); if (scene.name == "GroceryStore") found = true; } Assert.IsTrue(found); yield return new WaitForSeconds(1); // Destroy explicitly, because DontDestroyOnLoad is enabled Object.Destroy(humanoid.gameObject); yield return new WaitForSeconds(0.1F); } } } #endif