public async Task GetDeviceState_ENUM_ALL() { // Check NotOpened State for secondary camera. if (IsSupportedSecondaryCamera()) { Assert.That(Camera.GetDeviceState(CameraDevice.Front), Is.EqualTo(CameraDeviceState.NotOpened)); } // Check NotOpened State. Assert.That(Camera.GetDeviceState(CameraDevice.Rear), Is.EqualTo(CameraDeviceState.NotOpened)); /* Opened state cannot be tested. * DeviceState is internally translated from NotOpened state to Working state after calling StartPreview method. */ using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); await eventWaiter.IsRaisedAsync(); // Check Working State. Assert.That(Camera.GetDeviceState(CameraDevice.Rear), Is.EqualTo(CameraDeviceState.Working)); } }
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 void StopFaceDetection_NO_EXCEPTION() { TestCamera.StartPreview(); try { TestCamera.StartFaceDetection(); } catch (NotSupportedException) { if (TestCamera.Capabilities.IsFaceDetectionSupported) { Assert.Fail("Face Detection feature is supported. But StartFaceDetection returns NotSupportedException."); } else { Assert.Pass("Face Detection feature is not supported."); } } /* TESTCODE */ try { TestCamera.StopFaceDetection(); } catch { Assert.Fail("Exception should not be occurred."); } }
public async Task Preview_CHECK_EVENT() { using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); Assert.That(await eventWaiter.IsRaisedAsync()); } }
public async Task StopPreview_CHECK_STATE() { using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); await eventWaiter.IsRaisedAsync(); } TestCamera.StopPreview(); Assert.That(TestCamera.State, Is.EqualTo(CameraState.Created)); }
public async Task DisplayReuseHint_PROPERTY_READ_WRITE() { using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create()) { TestCamera.StateChanged += eventWaiter; TestCamera.StartPreview(); await eventWaiter.IsRaisedAsync(); } TestCamera.DisplayReuseHint = true; Assert.IsNotNull(TestCamera.DisplayReuseHint, "display reuse hint should not be null."); Assert.IsTrue(TestCamera.DisplayReuseHint, "display reuse hint is not same as set value."); }
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 MediaPacketPreview_CHECK_EVENT() { if (TestCamera.Capabilities.IsMediaPacketPreviewCallbackSupported == false) { Assert.Pass("MediaPacketPreviewCallback feature is not supported."); } using (var eventWaiter = EventAwaiter <MediaPacketPreviewEventArgs> .Create()) { TestCamera.MediaPacketPreview += eventWaiter; TestCamera.StartPreview(); var eventArgs = await eventWaiter.GetResultAsync(); Assert.IsNotNull(eventArgs.Packet); } }
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(); } }
public void StopFocusing_NO_EXCEPTION() { bool isAfModeSupported = false; IList afModes = TestCamera.Capabilities.SupportedAutoFocusModes.ToList(); foreach (CameraAutoFocusMode afMode in afModes) { if (afMode != CameraAutoFocusMode.None) { TestCamera.Settings.AutoFocusMode = afMode; isAfModeSupported = true; break; } } TestCamera.StartPreview(); try { TestCamera.StartFocusing(true); } catch (NotSupportedException) { if (isAfModeSupported) { Assert.Fail("StartFocusing is failed."); } else { Assert.Pass("Auto focus feature is not supported."); } } /* TESTCODE */ try { TestCamera.StopFocusing(); } catch { Assert.Fail("No exception should be occurred."); } }