Resolve WES-187 "Unit tests common and course"

This commit is contained in:
Jelle De Geest
2023-05-12 11:53:17 +00:00
committed by Jerome Coudron
parent 672ff367e2
commit 48b915acba
25 changed files with 1248 additions and 101 deletions

View File

@@ -161,6 +161,16 @@ public class CoursesController : AbstractFeedback
/// </summary>
private GameObject previousPanel = null;
/// <summary>
/// Boolean used to make a test possible
/// </summary>
private bool corruptPanelId = false;
/// <summary>
/// Corrupted PanelID Value
/// </summary>
private int CorruptedPanelIDValue = 999;
/// <summary>
/// This function is called when the script is initialised.
/// It inactivatis the popup, finds a webcam to use and links it via the WebcamTexture to the display RawImage.
@@ -319,7 +329,13 @@ public class CoursesController : AbstractFeedback
/// <returns>Reference to the GameObject of the panel</returns>
private GameObject SetupPanel()
{
(currentWordIndex, panelId) = FetchSign().ToValueTuple();
if (corruptPanelId == true)
{
(currentWordIndex, panelId) = (1, CorruptedPanelIDValue);
} else
{
(currentWordIndex, panelId) = FetchSign().ToValueTuple();
}
switch (panelId)
{
case 0:
@@ -413,9 +429,11 @@ public class CoursesController : AbstractFeedback
if (currentWordIndex < course.theme.learnables.Count && panelId != 1 && !hasAnswered)
{
// Get current sign
Learnable sign = course.theme.learnables[currentWordIndex];
string currentSign = sign.name.ToUpper().Replace(" ", "-");
// Get the predicted sign
if (signPredictor != null && signPredictor.learnableProbabilities != null &&
currentSign != null && signPredictor.learnableProbabilities.ContainsKey(currentSign))
@@ -567,4 +585,60 @@ public class CoursesController : AbstractFeedback
UserList.Save();
SystemController.GetInstance().BackToPreviousScene();
}
/// <summary>
/// Returns panelId for testing
/// </summary>
/// <returns></returns>
public int GetPanelId()
{
return panelId;
}
/// <summary>
/// Returns currentSign for testing
/// </summary>
/// <returns></returns>
public string GetCurrentSign()
{
Learnable sign = course.theme.learnables[currentWordIndex];
return sign.name.ToUpper().Replace(" ", "-");
}
/// <summary>
/// Used for testing an out of bounds PanelId
/// </summary>
/// <returns></returns>
public void CorruptPanelID()
{
corruptPanelId = true;
}
/// <summary>
/// Needed to be able to test an out of bounds PanelId
/// </summary>
/// <returns></returns>
public IEnumerator CallSetupPanel()
{
yield return SetupPanel();
}
/// <summary>
/// Needed to be able to test an out of bounds PanelId
/// </summary>
/// <returns></returns>
public void SetFeedbackProgress()
{
feedbackProgress.value = 0.0f;
}
/// <summary>
/// Open multiple choice panel for testing
/// </summary>
public IEnumerator SummonMultipleChoice()
{
CorruptPanelID();
CorruptedPanelIDValue = 1;
yield return CRNextSign();
}
}