|
|
|
|
|
|
using System.IO; |
|
|
|
using NUnit.Framework; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Perception.GroundTruth; |
|
|
|
using UnityEngine.Perception.Randomization.Configuration; |
|
|
|
using UnityEngine.Perception.Randomization.Parameters; |
|
|
|
using UnityEngine.Perception.Randomization.Samplers; |
|
|
|
|
|
|
Object.DestroyImmediate(m_TestObject); |
|
|
|
} |
|
|
|
|
|
|
|
void CreateNewScenario() |
|
|
|
IEnumerator CreateNewScenario() |
|
|
|
yield return null; |
|
|
|
CreateNewScenario(); |
|
|
|
yield return CreateNewScenario(); |
|
|
|
m_Scenario.serializedConstantsFileName = "perception_serialization_test"; |
|
|
|
|
|
|
|
var constants = new FixedFrameLengthScenario.Constants |
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator MultipleFrameIterationTest() |
|
|
|
{ |
|
|
|
CreateNewScenario(); |
|
|
|
yield return CreateNewScenario(); |
|
|
|
const int testIterationFrameCount = 5; |
|
|
|
m_Scenario.constants.framesPerIteration = testIterationFrameCount; |
|
|
|
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator ScenarioCompletionTest() |
|
|
|
{ |
|
|
|
CreateNewScenario(); |
|
|
|
yield return CreateNewScenario(); |
|
|
|
const int testIterationTotal = 5; |
|
|
|
m_Scenario.constants.framesPerIteration = 1; |
|
|
|
m_Scenario.constants.totalIterations = testIterationTotal; |
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator AppliesParametersEveryFrame() |
|
|
|
{ |
|
|
|
CreateNewScenario(); |
|
|
|
yield return CreateNewScenario(); |
|
|
|
m_Scenario.constants.framesPerIteration = 5; |
|
|
|
m_Scenario.constants.totalIterations = 1; |
|
|
|
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator AppliesParametersEveryIteration() |
|
|
|
{ |
|
|
|
CreateNewScenario(); |
|
|
|
yield return CreateNewScenario(); |
|
|
|
m_Scenario.constants.framesPerIteration = 5; |
|
|
|
m_Scenario.constants.totalIterations = 1; |
|
|
|
|
|
|
|
|
|
|
// ReSharper disable once Unity.InefficientPropertyAccess
|
|
|
|
Assert.AreEqual(initialPosition, transform.position); |
|
|
|
} |
|
|
|
//
|
|
|
|
// [UnityTest]
|
|
|
|
// public IEnumerator StartNewDatasetSequenceEveryIteration()
|
|
|
|
// {
|
|
|
|
// yield return CreateNewScenario();
|
|
|
|
// m_Scenario.constants.framesPerIteration = 2;
|
|
|
|
// m_Scenario.constants.totalIterations = 2;
|
|
|
|
//
|
|
|
|
// var perceptionCamera = m_TestObject.AddComponent<PerceptionCamera>();
|
|
|
|
// perceptionCamera.startTime = 0;
|
|
|
|
//
|
|
|
|
// // Skip first frame
|
|
|
|
// yield return new WaitForEndOfFrame();
|
|
|
|
// Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, 0);
|
|
|
|
//
|
|
|
|
// // Second frame, first iteration
|
|
|
|
// yield return new WaitForEndOfFrame();
|
|
|
|
// Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, perceptionCamera.period);
|
|
|
|
//
|
|
|
|
// // Third frame, second iteration, SequenceTime has been reset
|
|
|
|
// yield return new WaitForEndOfFrame();
|
|
|
|
// Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, 0);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |