Resolve WES-187 "Unit tests common and course"
This commit is contained in:
committed by
Jerome Coudron
parent
672ff367e2
commit
48b915acba
@@ -9,11 +9,15 @@ using UnityEngine.TestTools;
|
||||
|
||||
public class StartGamesTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Setup the environment before each test
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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}}";
|
||||
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;
|
||||
@@ -23,20 +27,10 @@ public class StartGamesTests
|
||||
|
||||
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));
|
||||
var userCreationScreen = GameObject.FindObjectOfType<UserCreationScreen>();
|
||||
var bootScreen = GameObject.FindObjectOfType<BootScreen>();
|
||||
var mainMenuScreen = GameObject.FindObjectOfType<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);
|
||||
@@ -50,7 +44,19 @@ public class StartGamesTests
|
||||
}
|
||||
Assert.IsNull(userCreationScreen);
|
||||
}
|
||||
/// <summary>
|
||||
/// Cleanup after testing
|
||||
/// </summary>
|
||||
[TearDown]
|
||||
public void TearDown_StartGamesTests()
|
||||
{
|
||||
PersistentDataController.PATH = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test booting without user
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[UnityTest]
|
||||
public IEnumerator BootWithoutUsersTest()
|
||||
{
|
||||
@@ -65,20 +71,10 @@ public class StartGamesTests
|
||||
|
||||
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));
|
||||
var userCreationScreen = GameObject.FindObjectOfType<UserCreationScreen>();
|
||||
var bootScreen = GameObject.FindObjectOfType<BootScreen>();
|
||||
var mainMenuScreen = GameObject.FindObjectOfType<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);
|
||||
|
||||
Reference in New Issue
Block a user