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

Unified Diff: media/base/video_util_unittest.cc

Issue 1135823004: Implement all resolution change policies for desktop and tab capture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resolution_change_policy_constraints_ITEM1_CR1
Patch Set: REBASE Created 5 years, 7 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
« no previous file with comments | « media/base/video_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_util_unittest.cc
diff --git a/media/base/video_util_unittest.cc b/media/base/video_util_unittest.cc
index 9ac13c1f6109811785a8fab0ce7978a92af5c3f9..79c53159ab8b6866c14470e97da938082148cd1e 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;
« no previous file with comments | « media/base/video_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698