|
|
|
|
|
|
using System.Collections; |
|
|
|
using NUnit.Framework; |
|
|
|
using RandomizationTests.ScenarioTests; |
|
|
|
using UnityEngine.Perception.GroundTruth; |
|
|
|
using UnityEngine.Perception.Randomization.Randomizers; |
|
|
|
using UnityEngine.Perception.Randomization.Scenarios; |
|
|
|
using UnityEngine.TestTools; |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// TODO: update this function once the perception camera doesn't skip the first frame
|
|
|
|
void CreateNewScenario(int totalIterations, int framesPerIteration) |
|
|
|
IEnumerator CreateNewScenario(int totalIterations, int framesPerIteration, Randomizer[] randomizers = null) |
|
|
|
|
|
|
|
if (randomizers != null) |
|
|
|
{ |
|
|
|
foreach (var rnd in randomizers) |
|
|
|
{ |
|
|
|
m_Scenario.AddRandomizer(rnd); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (PerceptionCamera.captureFrameCount < 0) |
|
|
|
{ |
|
|
|
yield return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator OnUpdateExecutesEveryFrame() |
|
|
|
{ |
|
|
|
CreateNewScenario(10, 1); |
|
|
|
m_Scenario.AddRandomizer(new ExampleTransformRandomizer()); |
|
|
|
yield return CreateNewScenario(10, 1, new Randomizer[] { new ExampleTransformRandomizer() }); |
|
|
|
var transform = m_TestObject.transform; |
|
|
|
var initialPosition = Vector3.zero; |
|
|
|
transform.position = initialPosition; |
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator OnIterationStartExecutesEveryIteration() |
|
|
|
{ |
|
|
|
CreateNewScenario(10, 2); |
|
|
|
m_Scenario.AddRandomizer(new ExampleTransformRandomizer()); |
|
|
|
yield return CreateNewScenario(10, 2, new Randomizer[] { new ExampleTransformRandomizer() }); |
|
|
|
|
|
|
|
// Wait one frame so the next iteration can begin
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
yield return null; |
|
|
|
Assert.AreNotEqual(initialRotation, transform.rotation); |
|
|
|