using NUnit.Framework; using System.Collections; using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; using UnityEngine.UI; /// /// Test the ThemeItem class /// public class ThemeItemTests { /// /// Setup the environment before each test /// [UnitySetUp] public IEnumerator SetupFunction() { string path = $"{Application.persistentDataPath}/wesign_unit_test.json"; string oneUser = $"{{\"version\":1027,\"users\":[{{\"entries\":[],\"username\":\"TEST\",\"avatarIndex\":0,\"playtime\":0.0,\"minigames\":[],\"courses\":[]}}],\"currentUser\":0,\"currentMinigame\":0,\"currentCourse\":0,\"currentTheme\":0}}"; File.WriteAllText(path, oneUser); PersistentDataController.PATH = path; PersistentDataController.GetInstance().Load(); AssetDatabase.LoadAssetAtPath("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake(); SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen"); yield return new WaitForSeconds(0.2f); } /// /// Cleanup after testing /// [TearDown] public void TearDown_ThemeItemTests() { PersistentDataController.PATH = null; } /// /// Test the callback function of a ThemeItem /// [UnityTest] public IEnumerator CallBackTest() { var listMinigamesScreen = GameObject.FindObjectOfType(); listMinigamesScreen.minigameList.SetCurrentMinigame(MinigameIndex.SPELLING_BEE); listMinigamesScreen.LoadScene("Common/Scenes/MinigameActivityScreen"); yield return new WaitForSeconds(0.2f); SystemController.GetInstance().LoadNextScene("Common/Scenes/ThemeSelectionScreen"); yield return new WaitForSeconds(0.2f); GameObject buttonObject = GameObject.Find("Theme Item(Clone)"); Assert.IsNotNull(buttonObject, "Could not find button object"); Button button = buttonObject.GetComponent