|
|
|
|
|
|
Assert.AreEqual(sensor.framesBetweenCaptures, framesBetween); |
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator ReportCapture_ReportsProperJson() |
|
|
|
RgbSensor CreateMocRgbCapture() |
|
|
|
{ |
|
|
|
var position = new float3(.2f, 1.1f, .3f); |
|
|
|
var rotation = new Quaternion(.3f, .2f, .1f, .5f); |
|
|
|
|
|
|
var sensor = new RgbSensor |
|
|
|
return new RgbSensor |
|
|
|
{ |
|
|
|
position = position, |
|
|
|
rotation = rotation.eulerAngles, |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator ReportCaptureAsync_TimesOut() |
|
|
|
{ |
|
|
|
var collector = new CollectEndpoint(); |
|
|
|
DatasetCapture.SetEndpoint(collector); |
|
|
|
DatasetCapture.Instance.automaticShutdown = false; |
|
|
|
SimulationState.TimeOutFrameCount = 5; |
|
|
|
var sensorHandle = RegisterSensor("camera", "", "", 0, CaptureTriggerMode.Scheduled, 1, 0); |
|
|
|
var f = sensorHandle.ReportSensorAsync(); |
|
|
|
|
|
|
|
for (var i = 0; i <= SimulationState.TimeOutFrameCount; i++) yield return null; |
|
|
|
|
|
|
|
DatasetCapture.Instance.ResetSimulation(); |
|
|
|
var dcWatcher = new DatasetCapture.WaitUntilComplete(); |
|
|
|
yield return dcWatcher; |
|
|
|
|
|
|
|
LogAssert.Expect(LogType.Error, new Regex("A frame has timed out and is being removed.*")); |
|
|
|
SimulationState.TimeOutFrameCount = 6000; |
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator ReportCaptureAsync_DoesNotTimeOut() |
|
|
|
{ |
|
|
|
var collector = new CollectEndpoint(); |
|
|
|
DatasetCapture.SetEndpoint(collector); |
|
|
|
DatasetCapture.Instance.automaticShutdown = false; |
|
|
|
SimulationState.TimeOutFrameCount = 5; |
|
|
|
|
|
|
|
var sensorHandle = RegisterSensor("camera", "", "", 0, CaptureTriggerMode.Scheduled, 1, 0); |
|
|
|
var f = sensorHandle.ReportSensorAsync(); |
|
|
|
|
|
|
|
yield return null; |
|
|
|
yield return null; |
|
|
|
|
|
|
|
f.Report(CreateMocRgbCapture()); |
|
|
|
|
|
|
|
DatasetCapture.Instance.ResetSimulation(); |
|
|
|
var dcWatcher = new DatasetCapture.WaitUntilComplete(); |
|
|
|
yield return dcWatcher; |
|
|
|
|
|
|
|
Assert.AreEqual(1, collector.currentRun.frames.Count); |
|
|
|
SimulationState.TimeOutFrameCount = 6000; |
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator ReportCapture_ReportsProperJson() |
|
|
|
{ |
|
|
|
var sensor = CreateMocRgbCapture(); |
|
|
|
sensorHandle.ReportSensor(sensor); |
|
|
|
|
|
|
|
var collector = new CollectEndpoint(); |
|
|
|
|
|
|
Assert.AreEqual(20, tAnn.entries[1].b); |
|
|
|
} |
|
|
|
|
|
|
|
[Test] |
|
|
|
public void ReportAnnotationFile_WhenCaptureNotExpected_Throws() |
|
|
|
[UnityTest] |
|
|
|
public IEnumerator ReportAnnotationFile_WhenCaptureNotExpected_Throws() |
|
|
|
DatasetCapture.Instance.automaticShutdown = false; |
|
|
|
|
|
|
|
|
|
|
|
DatasetCapture.Instance.ResetSimulation(); |
|
|
|
var dcWatcher = new DatasetCapture.WaitUntilComplete(); |
|
|
|
yield return dcWatcher; |
|
|
|
DatasetCapture.Instance.automaticShutdown = false; |
|
|
|
|
|
|
|
var def = new TestDef(); |
|
|
|
DatasetCapture.Instance.RegisterAnnotationDefinition(def); |
|
|
|
var ann = new TestAnnotation() |
|
|
|
|
|
|
}; |
|
|
|
var sensorHandle = RegisterSensor("camera", "", "", 100, CaptureTriggerMode.Scheduled, 1, 0); |
|
|
|
Assert.Throws<InvalidOperationException>(() => sensorHandle.ReportAnnotation(def, ann)); |
|
|
|
DatasetCapture.Instance.ResetSimulation(); |
|
|
|
} |
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator AnnotationAsyncIsValid_ReturnsProperValue() |
|
|
|
public IEnumerator AnnotationAsyncInvalid_TimesOut() |
|
|
|
DatasetCapture.Instance.automaticShutdown = false; |
|
|
|
SimulationState.TimeOutFrameCount = 100; |
|
|
|
|
|
|
|
var def = new TestDef(); |
|
|
|
DatasetCapture.Instance.RegisterAnnotationDefinition(def); |
|
|
|
var sensorHandle = RegisterSensor("camera", "", "", 0, CaptureTriggerMode.Scheduled, 1, 0); |
|
|
|
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(def); |
|
|
|
Assert.IsTrue(asyncAnnotation.IsValid()); |
|
|
|
|
|
|
|
DatasetCapture.Instance.ResetSimulation(); |
|
|
|
var dcWatcher = new DatasetCapture.WaitUntilComplete(); |
|
|
|
yield return dcWatcher; |
|
|
|
|
|
|
|
LogAssert.Expect(LogType.Error, new Regex("A frame has timed out and is being removed.*")); |
|
|
|
Assert.IsFalse(asyncAnnotation.IsValid()); |
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|
public IEnumerator AnnotationAsyncIsValid_ReturnsProperValue() |
|
|
|
{ |
|
|
|
var collector = new CollectEndpoint(); |
|
|
|
DatasetCapture.SetEndpoint(collector); |
|
|
|
LogAssert.ignoreFailingMessages = true; //we aren't worried about "Simulation ended with pending..."
|
|
|
|
SimulationState.TimeOutFrameCount = 10; |
|
|
|
|
|
|
|
LogAssert.ignoreFailingMessages = true; //we are not worried about timing out
|
|
|
|
|
|
|
|
var def = new TestDef(); |
|
|
|
DatasetCapture.Instance.RegisterAnnotationDefinition(def); |
|
|
|
|
|
|
yield return dcWatcher; |
|
|
|
|
|
|
|
Assert.IsFalse(asyncAnnotation.IsValid()); |
|
|
|
SimulationState.TimeOutFrameCount = 6000; |
|
|
|
} |
|
|
|
|
|
|
|
[UnityTest] |
|
|
|