diff options
author | miu <miu@chromium.org> | 2015-05-15 16:40:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-15 23:40:06 +0000 |
commit | 39254e67228717bbddf222614abd6cb9ba38608c (patch) | |
tree | a008547d23378be8d35f969ede860fde323288a5 /media/base/video_util_unittest.cc | |
parent | f54b8097a9c45ed4ad308133d49f05325d6c5070 (diff) | |
download | chromium_src-39254e67228717bbddf222614abd6cb9ba38608c.zip chromium_src-39254e67228717bbddf222614abd6cb9ba38608c.tar.gz chromium_src-39254e67228717bbddf222614abd6cb9ba38608c.tar.bz2 |
Implement all resolution change policies for desktop and tab capture.
Prior to this change, desktop/window capture would emit frames of any
size, regardless of the resolution change policy; and tab capture would
always emit frames of a fixed resolution. Both cause a problem where
some receivers of the captured video need to do scaling/letterboxing
themselves for proper UX, and other receivers require this be done on
by the capture pipeline.
This change builds upon https://codereview.chromium.org/1124263004,
which allows the client to specify capture constraints that configure
the capture pipeline to do (or not do) the scaling/letterboxing. All
frame resolution calculation logic has been factored into one place in a
new CaptureResolutionChooser class, which also depends on new utility
functions added to media/base/video_util.*.
BUG=473336
Review URL: https://codereview.chromium.org/1135823004
Cr-Commit-Position: refs/heads/master@{#330232}
Diffstat (limited to 'media/base/video_util_unittest.cc')
-rw-r--r-- | media/base/video_util_unittest.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/media/base/video_util_unittest.cc b/media/base/video_util_unittest.cc index 9ac13c1..79c5315 100644 --- a/media/base/video_util_unittest.cc +++ b/media/base/video_util_unittest.cc @@ -328,6 +328,8 @@ TEST_P(VideoUtilRotationTest, Rotate) { INSTANTIATE_TEST_CASE_P(, VideoUtilRotationTest, testing::ValuesIn(kVideoRotationTestData)); +// Tests the ComputeLetterboxRegion function. Also, because of shared code +// internally, this also tests ScaleSizeToFitWithinTarget(). TEST_F(VideoUtilTest, ComputeLetterboxRegion) { EXPECT_EQ(gfx::Rect(167, 0, 666, 500), ComputeLetterboxRegion(gfx::Rect(0, 0, 1000, 500), @@ -348,6 +350,48 @@ TEST_F(VideoUtilTest, ComputeLetterboxRegion) { gfx::Size(0, 0)).IsEmpty()); } +TEST_F(VideoUtilTest, ScaleSizeToEncompassTarget) { + EXPECT_EQ(gfx::Size(1000, 750), + ScaleSizeToEncompassTarget(gfx::Size(640, 480), + gfx::Size(1000, 500))); + EXPECT_EQ(gfx::Size(1333, 1000), + ScaleSizeToEncompassTarget(gfx::Size(640, 480), + gfx::Size(500, 1000))); + EXPECT_EQ(gfx::Size(1000, 562), + ScaleSizeToEncompassTarget(gfx::Size(1920, 1080), + gfx::Size(1000, 500))); + EXPECT_EQ(gfx::Size(133, 100), + ScaleSizeToEncompassTarget(gfx::Size(400, 300), + gfx::Size(100, 100))); + EXPECT_EQ(gfx::Size(2666666666, 2000000000), + ScaleSizeToEncompassTarget(gfx::Size(40000, 30000), + gfx::Size(2000000000, 2000000000))); + EXPECT_TRUE(ScaleSizeToEncompassTarget( + gfx::Size(0, 0), gfx::Size(2000000000, 2000000000)).IsEmpty()); +} + +TEST_F(VideoUtilTest, PadToMatchAspectRatio) { + EXPECT_EQ(gfx::Size(640, 480), + PadToMatchAspectRatio(gfx::Size(640, 480), gfx::Size(640, 480))); + EXPECT_EQ(gfx::Size(640, 480), + PadToMatchAspectRatio(gfx::Size(640, 480), gfx::Size(4, 3))); + EXPECT_EQ(gfx::Size(960, 480), + PadToMatchAspectRatio(gfx::Size(640, 480), gfx::Size(1000, 500))); + EXPECT_EQ(gfx::Size(640, 1280), + PadToMatchAspectRatio(gfx::Size(640, 480), gfx::Size(500, 1000))); + EXPECT_EQ(gfx::Size(2160, 1080), + PadToMatchAspectRatio(gfx::Size(1920, 1080), gfx::Size(1000, 500))); + EXPECT_EQ(gfx::Size(400, 400), + PadToMatchAspectRatio(gfx::Size(400, 300), gfx::Size(100, 100))); + EXPECT_EQ(gfx::Size(400, 400), + PadToMatchAspectRatio(gfx::Size(300, 400), gfx::Size(100, 100))); + EXPECT_EQ(gfx::Size(40000, 40000), + PadToMatchAspectRatio(gfx::Size(40000, 30000), + gfx::Size(2000000000, 2000000000))); + EXPECT_TRUE(PadToMatchAspectRatio( + gfx::Size(40000, 30000), gfx::Size(0, 0)).IsEmpty()); +} + TEST_F(VideoUtilTest, LetterboxYUV) { int width = 40; int height = 30; |