public void Grabber_ReturnsGrabber()
 {
     var grabber = new ScreenGrabber(new CaptureParameters());
     var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5));
     using (var recorder = new ScreenRecorder(grabber, video))
     {
         Assert.AreSame(grabber, recorder.Grabber);
     }
 }
        public void Grabber_WhenDisposed_Throws()
        {
            var grabber = new ScreenGrabber(new CaptureParameters());
            var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5));
            var recorder = new ScreenRecorder(grabber, video);
            recorder.Dispose();

            ScreenGrabber x;
            Assert.Throws<ObjectDisposedException>(() => x = recorder.Grabber);
        }
Beispiel #3
0
        /// <summary>
        /// Starts recording a screen capture video of the entire desktop.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Recording a screen capture video can be very CPU and space intensive particularly
        /// when running tests on a single-core CPU.  We recommend calling
        /// <see cref="StartRecording(CaptureParameters, double)" /> with
        /// a <see cref="CaptureParameters.Zoom" /> factor of 0.25 or less and a frame rate
        /// of no more than 5 to 10 frames per second.
        /// </para>
        /// </remarks>
        /// <param name="parameters">The capture parameters.</param>
        /// <param name="framesPerSecond">The number of frames per second to capture.</param>
        /// <returns>The recorder.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="parameters"/> is null.</exception>
        /// <exception cref="ScreenshotNotAvailableException">Thrown if a screenshot cannot be captured at this time.</exception>
        public static ScreenRecorder StartRecording(CaptureParameters parameters, double framesPerSecond)
        {
            if (parameters == null)
                throw new ArgumentNullException("parameters");

            ScreenGrabber.ThrowIfScreenshotNotAvailable();

            ScreenGrabber grabber = new ScreenGrabber(parameters);
            try
            {
                FlashScreenVideo video = new FlashScreenVideo(new FlashScreenVideoParameters(
                    grabber.ScreenshotWidth, grabber.ScreenshotHeight, framesPerSecond));

                ScreenRecorder recorder = new ScreenRecorder(grabber, video);
                try
                {
                    recorder.OverlayManager.AddOverlay(GetOverlayManager().ToOverlay());

                    recorder.Start();
                    return recorder;
                }
                catch
                {
                    recorder.Dispose();
                    throw;
                }
            }
            catch
            {
                grabber.Dispose();
                throw;
            }
        }
        private void StopScreenRecordingAndEmbedIfNeeded()
        {
            if (screenRecorder != null)
            {
                screenRecorder.Stop();
                Video video = screenRecorder.Video;
                screenRecorder = null;

                if (ShouldEmbedScreenRecordingGivenCurrentTestContext())
                {
                    TestLog.EmbedVideo("Screen Recording", video);
                }
            }
        }
 private void StartScreenRecordingIfNeeded()
 {
     if (ShouldStartScreenRecordingGivenCurrentTestContext())
     {
         screenRecorder = Capture.StartRecording(new CaptureParameters()
         {
             Zoom = browserConfiguration.ScreenRecordingZoom
         }, browserConfiguration.ScreenRecordingFramesPerSecond);
     }
 }
        public void Start_CapturesVideoUntilStopped()
        {
            var grabber = new ScreenGrabber(new CaptureParameters() { Zoom = 0.25 });
            var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5));
            using (var recorder = new ScreenRecorder(grabber, video))
            {
                recorder.Start();
                Thread.Sleep(2000);
                recorder.Stop();

                TestLog.EmbedVideo("Video", recorder.Video);
            }
        }