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

Unified Diff: content/renderer/media/canvas_capture_handler_unittest.cc

Issue 1737253002: Handle Alpha channel in Canvas capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/renderer/media/canvas_capture_handler_unittest.cc
diff --git a/content/renderer/media/canvas_capture_handler_unittest.cc b/content/renderer/media/canvas_capture_handler_unittest.cc
index 6f23ed103ef0bff2838d8144194be1c90e737f2e..5dd20cf9ff62bd9218a6b9fd53d34ab7e5d92517 100644
--- a/content/renderer/media/canvas_capture_handler_unittest.cc
+++ b/content/renderer/media/canvas_capture_handler_unittest.cc
@@ -25,6 +25,8 @@ using ::testing::Test;
namespace content {
+namespace {
+
static const int kTestCanvasCaptureWidth = 320;
static const int kTestCanvasCaptureHeight = 240;
static const double kTestCanvasCaptureFramesPerSecond = 55.5;
@@ -32,11 +34,14 @@ static const double kTestCanvasCaptureFramesPerSecond = 55.5;
static const int kTestCanvasCaptureFrameWidth = 2;
static const int kTestCanvasCaptureFrameHeight = 2;
static const int kTestCanvasCaptureFrameErrorTolerance = 2;
+static const int kTestAlphaValue = 175;
ACTION_P(RunClosure, closure) {
closure.Run();
}
+} // namespace
+
class CanvasCaptureHandlerTest : public Test {
public:
CanvasCaptureHandlerTest() {}
@@ -80,23 +85,25 @@ class CanvasCaptureHandlerTest : public Test {
SkBitmap testBitmap;
testBitmap.allocN32Pixels(kTestCanvasCaptureFrameWidth,
kTestCanvasCaptureFrameHeight);
- testBitmap.eraseColor(SK_ColorBLUE);
+ testBitmap.eraseARGB(kTestAlphaValue, 30, 60, 200);
return skia::AdoptRef(SkImage::NewFromBitmap(testBitmap));
}
void OnVerifyDeliveredFrame(
const scoped_refptr<media::VideoFrame>& video_frame,
base::TimeTicks estimated_capture_time) {
- EXPECT_EQ(media::PIXEL_FORMAT_I420, video_frame->format());
+ EXPECT_EQ(media::PIXEL_FORMAT_YV12A, video_frame->format());
const gfx::Size& size = video_frame->coded_size();
EXPECT_EQ(kTestCanvasCaptureFrameWidth, size.width());
EXPECT_EQ(kTestCanvasCaptureFrameHeight, size.height());
- const uint8_t* y_plane = video_frame->data(0);
- EXPECT_NEAR(41, y_plane[0], kTestCanvasCaptureFrameErrorTolerance);
- const uint8_t* u_plane = video_frame->data(1);
- EXPECT_NEAR(239, u_plane[0], kTestCanvasCaptureFrameErrorTolerance);
- const uint8_t* v_plane = video_frame->data(2);
- EXPECT_NEAR(110, v_plane[0], kTestCanvasCaptureFrameErrorTolerance);
+ const uint8_t* y_plane = video_frame->data(media::VideoFrame::kYPlane);
+ EXPECT_NEAR(74, y_plane[0], kTestCanvasCaptureFrameErrorTolerance);
+ const uint8_t* u_plane = video_frame->data(media::VideoFrame::kUPlane);
+ EXPECT_NEAR(193, u_plane[0], kTestCanvasCaptureFrameErrorTolerance);
+ const uint8_t* v_plane = video_frame->data(media::VideoFrame::kVPlane);
+ EXPECT_NEAR(105, v_plane[0], kTestCanvasCaptureFrameErrorTolerance);
+ const uint8_t* a_plane = video_frame->data(media::VideoFrame::kAPlane);
+ EXPECT_EQ(kTestAlphaValue, a_plane[0]);
}
blink::WebMediaStreamTrack track_;

Powered by Google App Engine
This is Rietveld 408576698