Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: content/browser/media/capture/web_contents_video_capture_device_unittest.cc

Issue 2364413002: Screen Video Capture: Implement suspend optimization. (Closed)
Patch Set: Unwind ScreenCaptureMachineAndroid changes. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/media/capture/web_contents_video_capture_device_unittest.cc
diff --git a/content/browser/media/capture/web_contents_video_capture_device_unittest.cc b/content/browser/media/capture/web_contents_video_capture_device_unittest.cc
index 60d20ff27b334f55c5d47a08859f9d47237d867d..f3730daeeff413a6c02365cc2782d5aa05391a84 100644
--- a/content/browser/media/capture/web_contents_video_capture_device_unittest.cc
+++ b/content/browser/media/capture/web_contents_video_capture_device_unittest.cc
@@ -465,7 +465,8 @@ class StubClientObserver {
public:
StubClientObserver()
: error_encountered_(false),
- wait_color_yuv_(0xcafe1950) {
+ wait_color_yuv_(0xcafe1950),
+ expecting_frames_(true) {
client_.reset(new StubClient(
base::Bind(&StubClientObserver::DidDeliverFrame,
base::Unretained(this)),
@@ -478,8 +479,14 @@ class StubClientObserver {
return std::move(client_);
}
+ void SetIsExpectingFrames(bool expecting_frames) {
+ base::AutoLock guard(lock_);
+ expecting_frames_ = expecting_frames;
+ }
+
void QuitIfConditionsMet(SkColor color, const gfx::Size& size) {
base::AutoLock guard(lock_);
+ EXPECT_TRUE(expecting_frames_);
if (error_encountered_ || wait_color_yuv_ == kNotInterested ||
wait_color_yuv_ == color) {
last_frame_color_yuv_ = color;
@@ -563,6 +570,7 @@ class StubClientObserver {
SkColor last_frame_color_yuv_;
gfx::Size last_frame_size_;
std::unique_ptr<StubClient> client_;
+ bool expecting_frames_;
DISALLOW_COPY_AND_ASSIGN(StubClientObserver);
};
@@ -1183,6 +1191,41 @@ TEST_F(MAYBE_WebContentsVideoCaptureDeviceTest,
}
}
+// Tests the Suspend/Resume() functionality.
+TEST_F(MAYBE_WebContentsVideoCaptureDeviceTest, SuspendsAndResumes) {
+ media::VideoCaptureParams capture_params;
+ capture_params.requested_format.frame_size.SetSize(kTestWidth, kTestHeight);
+ capture_params.requested_format.frame_rate = kTestFramesPerSecond;
+ capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
+ device()->AllocateAndStart(capture_params, client_observer()->PassClient());
+
+ for (int i = 0; i < 3; ++i) {
+ // Draw a RED frame and wait for a normal frame capture to occur.
+ source()->SetSolidColor(SK_ColorRED);
+ SimulateDrawEvent();
+ ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
+
+ // Suspend capture and then draw a GREEN frame. No frame capture should
+ // occur.
+ device()->MaybeSuspend();
+ base::RunLoop().RunUntilIdle();
+ client_observer()->SetIsExpectingFrames(false);
+ source()->SetSolidColor(SK_ColorGREEN);
+ SimulateDrawEvent();
+ base::RunLoop().RunUntilIdle();
+
+ // Resume capture and then draw a BLUE frame and wait for it to be captured.
+ device()->Resume();
+ base::RunLoop().RunUntilIdle();
+ client_observer()->SetIsExpectingFrames(true);
+ source()->SetSolidColor(SK_ColorBLUE);
+ SimulateDrawEvent();
+ ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorBLUE));
+ }
+
+ device()->StopAndDeAllocate();
+}
+
// Tests the RequestRefreshFrame() functionality.
TEST_F(MAYBE_WebContentsVideoCaptureDeviceTest, ProvidesRefreshFrames) {
media::VideoCaptureParams capture_params;
« no previous file with comments | « content/browser/media/capture/web_contents_video_capture_device.cc ('k') | media/capture/content/screen_capture_device_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698