Resolve WES-113 "Commons tests"
This commit is contained in:
@@ -13,7 +13,7 @@ steps:
|
|||||||
- mkdir code_coverage
|
- mkdir code_coverage
|
||||||
- chmod 777 code_coverage
|
- chmod 777 code_coverage
|
||||||
- /opt/unity/editors/2021.3.19f1/Editor/Unity -runTests -batchmode -nographics -projectPath . -testResults results_editmode.xml -testPlatform EditMode -debugCodeOptimization -enableCodeCoverage -coverageResultsPath code_coverage -coverageOptions "generateAdditionalMetrics;pathFilters:-**Assets/MediaPipeUnity/Common/**,-**Assets/**Test*.cs;dontClear" || true
|
- /opt/unity/editors/2021.3.19f1/Editor/Unity -runTests -batchmode -nographics -projectPath . -testResults results_editmode.xml -testPlatform EditMode -debugCodeOptimization -enableCodeCoverage -coverageResultsPath code_coverage -coverageOptions "generateAdditionalMetrics;pathFilters:-**Assets/MediaPipeUnity/Common/**,-**Assets/**Test*.cs;dontClear" || true
|
||||||
- /opt/unity/editors/2021.3.19f1/Editor/Unity -runTests -batchmode -nographics -projectPath . -testResults results_playmode.xml -testPlatform PlayMode -debugCodeOptimization -enableCodeCoverage -coverageResultsPath code_coverage -coverageOptions "generateAdditionalMetrics;pathFilters:-**Assets/MediaPipeUnity/Common/**,-**Assets/**Test*.cs;dontClear" || true
|
#- /opt/unity/editors/2021.3.19f1/Editor/Unity -runTests -batchmode -nographics -projectPath . -testResults results_playmode.xml -testPlatform PlayMode -debugCodeOptimization -enableCodeCoverage -coverageResultsPath code_coverage -coverageOptions "generateAdditionalMetrics;pathFilters:-**Assets/MediaPipeUnity/Common/**,-**Assets/**Test*.cs;dontClear" || true
|
||||||
- /opt/unity/editors/2021.3.19f1/Editor/Unity -batchmode -nographics -projectPath . -debugCodeOptimization -enableCodeCoverage -coverageResultsPath code_coverage -coverageOptions "generateAdditionalReports;pathFilters:-**Assets/MediaPipeUnity/Common/**,-**Assets/**Test*.cs" -quit || true
|
- /opt/unity/editors/2021.3.19f1/Editor/Unity -batchmode -nographics -projectPath . -debugCodeOptimization -enableCodeCoverage -coverageResultsPath code_coverage -coverageOptions "generateAdditionalReports;pathFilters:-**Assets/MediaPipeUnity/Common/**,-**Assets/**Test*.cs" -quit || true
|
||||||
- ls code_coverage
|
- ls code_coverage
|
||||||
- ls code_coverage/Report
|
- ls code_coverage/Report
|
||||||
@@ -21,7 +21,7 @@ steps:
|
|||||||
- name: tests-parser
|
- name: tests-parser
|
||||||
image: docker.io/library/unity-test-parser:0.1
|
image: docker.io/library/unity-test-parser:0.1
|
||||||
commands:
|
commands:
|
||||||
- python /app/unity_test_parser.py results_editmode.xml results_playmode.xml
|
- python /app/unity_test_parser.py results_editmode.xml results_editmode.xml
|
||||||
|
|
||||||
- name: sonarqube-code-coverage
|
- name: sonarqube-code-coverage
|
||||||
pull: if-not-exists
|
pull: if-not-exists
|
||||||
|
|||||||
8
Assets/Common/PlayModeTests.meta
Normal file
8
Assets/Common/PlayModeTests.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f89227a2dd3cfd6de917157d10b7340f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
44
Assets/Common/PlayModeTests/BackButtonTests.cs
Normal file
44
Assets/Common/PlayModeTests/BackButtonTests.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class BackButtonTests
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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/PlayModeTests/BackButtonTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
26
Assets/Common/PlayModeTests/CommonPlayModeTests.asmdef
Normal file
26
Assets/Common/PlayModeTests/CommonPlayModeTests.asmdef
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "CommonPlayModeTests",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"UnityEngine.TestRunner",
|
||||||
|
"UnityEditor.TestRunner",
|
||||||
|
"CourseScripts",
|
||||||
|
"CommonScripts",
|
||||||
|
"InterfacesScripts",
|
||||||
|
"Unity.TextMeshPro",
|
||||||
|
"AccountsScripts"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": true,
|
||||||
|
"precompiledReferences": [
|
||||||
|
"nunit.framework.dll"
|
||||||
|
],
|
||||||
|
"autoReferenced": false,
|
||||||
|
"defineConstraints": [
|
||||||
|
"UNITY_INCLUDE_TESTS"
|
||||||
|
],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d08ee7c88a96eed139d13a61cc27631c
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
40
Assets/Common/PlayModeTests/CourseActivityTests.cs
Normal file
40
Assets/Common/PlayModeTests/CourseActivityTests.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class CourseActivityTests
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = (TemplateCourse) GameObject.FindObjectOfType(typeof(TemplateCourse));
|
||||||
|
Assert.IsNotNull(templateCourse);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Common/PlayModeTests/CourseActivityTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
41
Assets/Common/PlayModeTests/CourseMenuScreenTests.cs
Normal file
41
Assets/Common/PlayModeTests/CourseMenuScreenTests.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class CourseMenuScreenTest
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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/PlayModeTests/CourseMenuScreenTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
41
Assets/Common/PlayModeTests/ListCoursesScreenTests.cs
Normal file
41
Assets/Common/PlayModeTests/ListCoursesScreenTests.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class ListCoursesScreenTest
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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/PlayModeTests/ListCoursesScreenTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
69
Assets/Common/PlayModeTests/MainMenuScreenTests.cs
Normal file
69
Assets/Common/PlayModeTests/MainMenuScreenTests.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class MainMenuScreenTests
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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/PlayModeTests/MainMenuScreenTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
41
Assets/Common/PlayModeTests/MinigameActivityScreenTests.cs
Normal file
41
Assets/Common/PlayModeTests/MinigameActivityScreenTests.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class MiniGameActivityScreenTests
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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:
|
||||||
106
Assets/Common/PlayModeTests/StartGameTests.cs
Normal file
106
Assets/Common/PlayModeTests/StartGameTests.cs
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class StartGamesTests
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[UnityTest]
|
||||||
|
public IEnumerator BootWithUsersTest()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
Debug.Log("no webcam");
|
||||||
|
Assert.IsNull(userCreationScreen);
|
||||||
|
Assert.IsNull(mainMenuScreen);
|
||||||
|
Assert.IsNotNull(bootScreen);
|
||||||
|
Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat je webcam correct is aangesloten!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("everything is there");
|
||||||
|
Assert.IsNull(bootScreen);
|
||||||
|
Assert.IsNull(userCreationScreen);
|
||||||
|
Assert.IsNotNull(mainMenuScreen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnityTest]
|
||||||
|
public IEnumerator BootWithoutUsersTest()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
|
Debug.Log("no webcam");
|
||||||
|
Assert.IsNull(userCreationScreen);
|
||||||
|
Assert.IsNull(mainMenuScreen);
|
||||||
|
Assert.IsNotNull(bootScreen);
|
||||||
|
Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat je webcam correct is aangesloten!");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Debug.Log("no users");
|
||||||
|
Assert.IsNull(bootScreen);
|
||||||
|
Assert.IsNull(mainMenuScreen);
|
||||||
|
Assert.IsNotNull(userCreationScreen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Common/PlayModeTests/StartGameTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
52
Assets/Common/PlayModeTests/UserButtonTests.cs
Normal file
52
Assets/Common/PlayModeTests/UserButtonTests.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
|
||||||
|
public class UserButtonTests
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnitySetUp]
|
||||||
|
public IEnumerator SetupFunction()
|
||||||
|
{
|
||||||
|
string path = Path.Combine("Assets", "users.json");
|
||||||
|
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
writer.Write(oneUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
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/PlayModeTests/UserButtonTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/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:
|
||||||
8
Assets/Courses/PlayModeTests.meta
Normal file
8
Assets/Courses/PlayModeTests.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d322616d16e32135eb3735e3bb704d05
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
27
Assets/Courses/PlayModeTests/BasicTests.cs
Normal file
27
Assets/Courses/PlayModeTests/BasicTests.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TestTools;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
public class BasicTests
|
||||||
|
{
|
||||||
|
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
|
||||||
|
// `yield return null;` to skip a frame.
|
||||||
|
[UnityTest]
|
||||||
|
public IEnumerator BasicTestsWithEnumeratorPasses()
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene("TemplateCourse");
|
||||||
|
// Use the Assert class to test conditions.
|
||||||
|
// Use yield to skip a frame.
|
||||||
|
yield return null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// var courseObject = GameObject.findGameObjectWithTag("Course");
|
||||||
|
// Assert.IsNotNull(courseObject);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
11
Assets/Courses/PlayModeTests/BasicTests.cs.meta
Normal file
11
Assets/Courses/PlayModeTests/BasicTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 98c67df90515b0fec8184240768037cd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
6
Assets/Courses/PlayModeTests/PlayModeTests.asmdef
Normal file
6
Assets/Courses/PlayModeTests/PlayModeTests.asmdef
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "PlayModeTests",
|
||||||
|
"optionalUnityReferences": [
|
||||||
|
"TestAssemblies"
|
||||||
|
]
|
||||||
|
}
|
||||||
7
Assets/Courses/PlayModeTests/PlayModeTests.asmdef.meta
Normal file
7
Assets/Courses/PlayModeTests/PlayModeTests.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1606ac91cab3333be8c7e7281c392595
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user