Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        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();
                }
        }
Esempio n. 3
0
        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.");
            }
        }
Esempio n. 4
0
        public async Task Preview_CHECK_EVENT()
        {
            using (var eventWaiter = EventAwaiter <CameraStateChangedEventArgs> .Create())
            {
                TestCamera.StateChanged += eventWaiter;

                TestCamera.StartPreview();

                Assert.That(await eventWaiter.IsRaisedAsync());
            }
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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.");
        }
Esempio n. 7
0
        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);
                    });
                }
            }
        }
Esempio n. 8
0
        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());
            }
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 10
0
        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));
                }
        }
Esempio n. 11
0
        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();
                }
        }
Esempio n. 12
0
        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.");
            }
        }