Resolve WES-187 "Unit tests account and system"
This commit is contained in:
committed by
Jerome Coudron
parent
c4b6c60288
commit
b9bbef8dcf
8
Assets/Common/Tests/EditMode.meta
Normal file
8
Assets/Common/Tests/EditMode.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7efafb99e31fdd243b9470c45ec5da7d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "CommonTests",
|
||||
"name": "CommonEditMode",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"UnityEngine.TestRunner",
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
/// Test the CourseList class
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class CourseListTest
|
||||
public class CourseListTests
|
||||
{
|
||||
private CourseList courseList;
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
/// Test the MinigameList class
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class MinigameListTest
|
||||
public class MinigameListTests
|
||||
{
|
||||
private MinigameList minigameList;
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
/// Test the ModelList class
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class ModelListTest
|
||||
public class ModelListTests
|
||||
{
|
||||
private ModelList modelList;
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
/// Test the ThemeList class
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class ThemeListTest
|
||||
public class ThemeListTests
|
||||
{
|
||||
private ThemeList themeList;
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
/// Test the Theme class
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class ThemeTest
|
||||
public class ThemeTests
|
||||
{
|
||||
private Theme theme;
|
||||
private List<string> names = new List<string>() { "appel", "peer", "banaan" };
|
||||
8
Assets/Common/Tests/PlayMode.meta
Normal file
8
Assets/Common/Tests/PlayMode.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f89227a2dd3cfd6de917157d10b7340f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Common/Tests/PlayMode/BackButtonTests.cs
Normal file
39
Assets/Common/Tests/PlayMode/BackButtonTests.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
public class BackButtonTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/MainMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BackTest()
|
||||
{
|
||||
|
||||
var backButton = (BackButton)GameObject.FindObjectOfType(typeof(BackButton));
|
||||
backButton.Back();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
Assert.IsNotNull(mainMenuScreen);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/Tests/PlayMode/BackButtonTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/BackButtonTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ad16a6ce457c004ea62362a0cf79bfc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/Common/Tests/PlayMode/CommonPlayMode.asmdef
Normal file
28
Assets/Common/Tests/PlayMode/CommonPlayMode.asmdef
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "CommonPlayMode",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner",
|
||||
"CourseScripts",
|
||||
"CommonScripts",
|
||||
"InterfacesScripts",
|
||||
"Unity.TextMeshPro",
|
||||
"AccountsScripts",
|
||||
"SignPredictor",
|
||||
"ArchitectureScripts"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"nunit.framework.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Common/Tests/PlayMode/CommonPlayMode.asmdef.meta
Normal file
7
Assets/Common/Tests/PlayMode/CommonPlayMode.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d08ee7c88a96eed139d13a61cc27631c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Common/Tests/PlayMode/CourseActivityTests.cs
Normal file
35
Assets/Common/Tests/PlayMode/CourseActivityTests.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
public class CourseActivityTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/CourseActivityScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator StartCoursesTests()
|
||||
{
|
||||
var courseActivityScreen = (CourseActivityScreen)GameObject.FindObjectOfType(typeof(CourseActivityScreen));
|
||||
courseActivityScreen.StartCourse();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var templateCourse = (CoursesController)GameObject.FindObjectOfType(typeof(CoursesController));
|
||||
Assert.IsNotNull(templateCourse);
|
||||
}
|
||||
}
|
||||
11
Assets/Common/Tests/PlayMode/CourseActivityTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/CourseActivityTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 949e9bdeb8c6a13fa9191084efa1bbeb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Common/Tests/PlayMode/CourseMenuScreenTests.cs
Normal file
36
Assets/Common/Tests/PlayMode/CourseMenuScreenTests.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
public class CourseMenuScreenTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/CoursesMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoListOfCoursesTest()
|
||||
{
|
||||
var courseMenuScreen = (CourseMenuScreen)GameObject.FindObjectOfType(typeof(CourseMenuScreen));
|
||||
courseMenuScreen.GotoListOfCourses();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
Assert.IsNotNull(listCoursesScreen);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/Tests/PlayMode/CourseMenuScreenTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/CourseMenuScreenTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5619dced821bf9645b502b748b0383bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Common/Tests/PlayMode/ListCoursesScreenTests.cs
Normal file
36
Assets/Common/Tests/PlayMode/ListCoursesScreenTests.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
public class ListCoursesScreenTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListCoursesScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoCourseInfoTest()
|
||||
{
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
listCoursesScreen.GotoCourseInfo();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var courseInfo = (CourseActivityScreen)GameObject.FindObjectOfType(typeof(CourseActivityScreen));
|
||||
Assert.IsNotNull(courseInfo);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/Tests/PlayMode/ListCoursesScreenTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/ListCoursesScreenTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56f4974974083304c814d0598c09fbcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
66
Assets/Common/Tests/PlayMode/MainMenuScreenTests.cs
Normal file
66
Assets/Common/Tests/PlayMode/MainMenuScreenTests.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
|
||||
public class MainMenuScreenTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SceneManager.LoadScene("Common/Scenes/MainMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoCoursesTest()
|
||||
{
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
mainMenuScreen.GotoCourses();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var courseMenuScreen = (CourseMenuScreen)GameObject.FindObjectOfType(typeof(CourseMenuScreen));
|
||||
|
||||
Assert.IsNotNull(courseMenuScreen);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoMiniGamesTest()
|
||||
{
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
mainMenuScreen.GotoMinigames();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listMinigamesScreen = (ListMinigamesScreen)GameObject.FindObjectOfType(typeof(ListMinigamesScreen));
|
||||
Assert.IsNotNull(listMinigamesScreen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* [UnityTest]
|
||||
public IEnumerator GotoSettingsTest()
|
||||
{
|
||||
Arrange
|
||||
SceneManager.LoadScene("Common/Scenes/MainMenuScreen");
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
mainMenuScreen.GotoSettings();
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
var minigameActivityScreen = (MinigameActivityScreen)GameObject.FindObjectOfType(typeof(MinigameActivityScreen));
|
||||
Assert.IsNotNull(minigameActivityScreen);
|
||||
}*/
|
||||
}
|
||||
11
Assets/Common/Tests/PlayMode/MainMenuScreenTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/MainMenuScreenTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 531b780eb4e25f58b8a03f66aa0c070a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Assets/Common/Tests/PlayMode/MinigameActivityScreenTests.cs
Normal file
37
Assets/Common/Tests/PlayMode/MinigameActivityScreenTests.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
|
||||
public class MiniGameActivityScreenTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/CoursesMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoListOfCoursesTest()
|
||||
{
|
||||
var courseMenuScreen = (CourseMenuScreen)GameObject.FindObjectOfType(typeof(CourseMenuScreen));
|
||||
courseMenuScreen.GotoListOfCourses();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
Assert.IsNotNull(listCoursesScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d578cc288b904dd49bec039987a248a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
96
Assets/Common/Tests/PlayMode/StartGameTests.cs
Normal file
96
Assets/Common/Tests/PlayMode/StartGameTests.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
|
||||
public class StartGamesTests
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator BootWithUsersTest()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SceneManager.LoadScene("Common/Scenes/Boot");
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var userCreationScreen = (UserCreationScreen)GameObject.FindObjectOfType(typeof(UserCreationScreen));
|
||||
var bootScreen = (BootScreen)GameObject.FindObjectOfType(typeof(BootScreen));
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
|
||||
// yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
// if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||||
// {
|
||||
// Debug.Log("no access");
|
||||
// Assert.IsNull(userCreationScreen);
|
||||
// Assert.IsNull(mainMenuScreen);
|
||||
// Assert.IsNotNull(bootScreen);
|
||||
// Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!");
|
||||
// }
|
||||
// else
|
||||
if (0 >= WebCamTexture.devices.Length)
|
||||
{
|
||||
Assert.IsNull(mainMenuScreen);
|
||||
Assert.IsNotNull(bootScreen);
|
||||
Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat je webcam correct is aangesloten!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNull(bootScreen);
|
||||
Assert.IsNotNull(mainMenuScreen);
|
||||
}
|
||||
Assert.IsNull(userCreationScreen);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BootWithoutUsersTest()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string noUsers = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
|
||||
|
||||
File.WriteAllText(path, noUsers);
|
||||
PersistentDataController.PATH = path;
|
||||
PersistentDataController.GetInstance().Load();
|
||||
AssetDatabase.LoadAssetAtPath<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SceneManager.LoadScene("Common/Scenes/Boot");
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var userCreationScreen = (UserCreationScreen)GameObject.FindObjectOfType(typeof(UserCreationScreen));
|
||||
var bootScreen = (BootScreen)GameObject.FindObjectOfType(typeof(BootScreen));
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
|
||||
// yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
// if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||||
// {
|
||||
// Debug.Log("no access");
|
||||
// Assert.IsNull(userCreationScreen);
|
||||
// Assert.IsNull(mainMenuScreen);
|
||||
// Assert.IsNotNull(bootScreen);
|
||||
// Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!");
|
||||
// }
|
||||
// else
|
||||
if (0 >= WebCamTexture.devices.Length)
|
||||
{
|
||||
Assert.IsNull(userCreationScreen);
|
||||
Assert.IsNotNull(bootScreen);
|
||||
Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat je webcam correct is aangesloten!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNull(bootScreen);
|
||||
Assert.IsNotNull(userCreationScreen);
|
||||
}
|
||||
Assert.IsNull(mainMenuScreen);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Common/Tests/PlayMode/StartGameTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/StartGameTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b23b9d56e564350dbed07a7c3439763
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Common/Tests/PlayMode/UserButtonTests.cs
Normal file
48
Assets/Common/Tests/PlayMode/UserButtonTests.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
|
||||
public class UserButtonTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
|
||||
string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"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<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/CoursesMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
/* [UnityTest]
|
||||
public IEnumerator OpenProgressCallbackTest()
|
||||
{
|
||||
var userButton = (UserButton)GameObject.FindObjectOfType(typeof(UserButton));
|
||||
userButton.OpenProgressCallback();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
Assert.IsNotNull(listCoursesScreen);
|
||||
}*/
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator ChangeUserCallbackTest()
|
||||
{
|
||||
var userButton = (UserButton)GameObject.FindObjectOfType(typeof(UserButton));
|
||||
userButton.ChangeUserCallback();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var changeUserScreen = (ChangeUserScreen)GameObject.FindObjectOfType(typeof(ChangeUserScreen));
|
||||
Assert.IsNotNull(changeUserScreen);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/Tests/PlayMode/UserButtonTests.cs.meta
Normal file
11
Assets/Common/Tests/PlayMode/UserButtonTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa48a935164b1d4488c66de005349cdd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user