public async Task HdrCaptureProgress_CHECK_EVENT() { if (TestCamera.Capabilities.IsHdrCaptureSupported == false) { Assert.Pass("HDR feature is not supported."); } using (var completeWaiter = EventAwaiter.Create()) using (var eventWaiter = EventAwaiter <HdrCaptureProgressEventArgs> .Create()) { TestCamera.Settings.HdrMode = CameraHdrMode.Enable; TestCamera.HdrCaptureProgress += eventWaiter; TestCamera.CaptureCompleted += completeWaiter; TestCamera.StartPreview(); TestCamera.StartCapture(); var eventArgs = await eventWaiter.GetResultAsync(); Assert.That(eventArgs.Percent, Is.GreaterThan(0), "HDR progress should be bigger than 0."); await completeWaiter.IsRaisedAsync(); } }
public async Task StartCapture_INVALID_OP_EXCEPTION() { TestCamera.StartPreview(); using (var tokenSource = new CancellationTokenSource()) { try { TestCamera.StartCapture(3, 100, tokenSource.Token); await Task.Delay(1000); } catch (NotSupportedException) { if (TestCamera.Capabilities.IsContinuousCaptureSupported) { Assert.Fail("Continuous capture is failed."); } else { Assert.Pass("Continuous capture feature is not supported."); } } catch (Exception ex) { Assert.Fail("Continuous capture is failed. Msg : " + ex.ToString()); } /* TESTCODE */ try { tokenSource.Cancel(); } catch (AggregateException ex) { ex.Handle((x) => { if (x is InvalidOperationException) { Assert.Pass("Proper exception is occured."); return(true); } Assert.Fail("Proper exception is not occured."); return(false); }); } } }
public async Task State_GET_ENUM_ALL() { Assert.That(TestCamera.State, Is.EqualTo(CameraState.Created)); TestCamera.StartPreview(); Assert.That(TestCamera.State, Is.EqualTo(CameraState.Preview)); using (var eventWaiter = EventAwaiter <EventArgs> .Create()) { TestCamera.CaptureCompleted += eventWaiter; TestCamera.StartCapture(); Assert.That(await eventWaiter.IsRaisedAsync()); } }
public async Task StartCapture_CHANGE_STATUS() { TestCamera.StartPreview(); using (var completeWaiter = EventAwaiter <CameraCapturingEventArgs> .Create()) using (var tokenSource = new CancellationTokenSource()) { try { TestCamera.Capturing += completeWaiter; TestCamera.StartCapture(10, 100, tokenSource.Token); await completeWaiter.IsRaisedAsync(); } catch (NotSupportedException) { if (TestCamera.Capabilities.IsContinuousCaptureSupported) { Assert.Fail("Continuous capture is failed."); } else { Assert.Pass("Continuous capture feature is not supported."); } } catch (Exception ex) { Assert.Fail("Continuous capture is failed. Msg : " + ex.ToString()); } /* TESTCODE */ using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; tokenSource.Cancel(); await eventWaiter.IsRaisedAsync(); } Assert.That(TestCamera.State, Is.EqualTo(CameraState.Captured)); } }
public async Task CaptureCompleted_CHECK_EVENT() { using (var completeWaiter = EventAwaiter.Create()) using (var eventWaiter = EventAwaiter <EventArgs> .Create()) { TestCamera.Settings.ImageQuality = 100; TestCamera.Settings.CapturePixelFormat = CameraPixelFormat.Jpeg; TestCamera.CaptureCompleted += eventWaiter; TestCamera.CaptureCompleted += completeWaiter; TestCamera.StartPreview(); TestCamera.StartCapture(); Assert.That(await eventWaiter.IsRaisedAsync()); await completeWaiter.IsRaisedAsync(); } }