|
|
|
|
|
|
Object.DestroyImmediate(m_TestObject); |
|
|
|
} |
|
|
|
|
|
|
|
IEnumerator CreateNewScenario() |
|
|
|
void CreateNewScenario() |
|
|
|
yield return null; |
|
|
|
yield return CreateNewScenario(); |
|
|
|
CreateNewScenario(); |
|
|
|
m_Scenario.serializedConstantsFileName = "perception_serialization_test"; |
|
|
|
|
|
|
|
var constants = new FixedLengthScenario.Constants |
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator IterationsCanLastMultipleFrames() |
|
|
|
{ |
|
|
|
yield return CreateNewScenario(); |
|
|
|
CreateNewScenario(); |
|
|
|
|
|
|
|
// Scenario update loop starts next frame
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
for (var i = 0; i < testIterationFrameCount; i++) |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator CompletesWhenIsScenarioCompleteIsTrue() |
|
|
|
public IEnumerator FinishesWhenIsScenarioCompleteIsTrue() |
|
|
|
yield return CreateNewScenario(); |
|
|
|
CreateNewScenario(); |
|
|
|
|
|
|
|
// Scenario update loop starts next frame
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
for (var i = 0; i < testIterationTotal; i++) |
|
|
|
{ |
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator AppliesParametersEveryFrame() |
|
|
|
{ |
|
|
|
yield return CreateNewScenario(); |
|
|
|
CreateNewScenario(); |
|
|
|
m_Scenario.constants.framesPerIteration = 5; |
|
|
|
m_Scenario.constants.totalIterations = 1; |
|
|
|
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator AppliesParametersEveryIteration() |
|
|
|
{ |
|
|
|
yield return CreateNewScenario(); |
|
|
|
m_Scenario.constants.framesPerIteration = 5; |
|
|
|
m_Scenario.constants.totalIterations = 1; |
|
|
|
|
|
|
|
var config = m_TestObject.AddComponent<ParameterConfiguration>(); |
|
|
|
var parameter = config.AddParameter<Vector3Parameter>(); |
|
|
|
parameter.x = new UniformSampler(1, 2); |
|
|
|
|
|
|
var transform = m_Scenario.transform; |
|
|
|
var transform = m_TestObject.transform; |
|
|
|
transform.position = new Vector3(); |
|
|
|
var initialPosition = new Vector3(); |
|
|
|
transform.position = initialPosition; |
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
CreateNewScenario(); |
|
|
|
m_Scenario.constants.framesPerIteration = 2; |
|
|
|
m_Scenario.constants.totalIterations = 2; |
|
|
|
|
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
var initialPosition = transform.position; |
|
|
|
Assert.AreNotEqual(new Vector3(), initialPosition); |
|
|
|
// The position should change when the first iteration starts
|
|
|
|
yield return null; |
|
|
|
Assert.AreNotEqual(initialPosition, transform.position); |
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
initialPosition = transform.position; |
|
|
|
var nextPosition = transform.position; |
|
|
|
Assert.AreEqual(initialPosition, nextPosition); |
|
|
|
// The position should stay the same since the iteration doesn't change for another 4 frames
|
|
|
|
yield return null; |
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
Assert.AreEqual(initialPosition, transform.position); |
|
|
|
Assert.AreNotEqual(nextPosition, transform.position); |
|
|
|
yield return CreateNewScenario(); |
|
|
|
CreateNewScenario(); |
|
|
|
m_Scenario.constants.framesPerIteration = 2; |
|
|
|
m_Scenario.constants.totalIterations = 2; |
|
|
|
|
|
|
|