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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp

Issue 2696893002: [Blink>Media] Add heuristic for dominant video detection for Android (Closed)
Patch Set: Created 3 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: third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
index 69c6ee7ef4eadeca2f572ea6e042ac5738aa054c..466ff28358452fbbd212a10b64dbfe222cf378e6 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
@@ -16,6 +16,14 @@ namespace blink {
enum class TestParam { Audio, Video };
class HTMLMediaElementTest : public ::testing::TestWithParam<TestParam> {
+ public:
+ static bool computeIsMostlyFillingViewport(const IntRect& targetRect,
+ const IntRect& rootRect,
+ const IntRect& intersectionRect) {
+ return HTMLMediaElement::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect);
+ }
+
protected:
void SetUp() {
m_dummyPageHolder = DummyPageHolder::create();
@@ -138,4 +146,85 @@ TEST_P(HTMLMediaElementTest, preloadType) {
}
}
+TEST(HTMLMediaElementTest_ViewportFillComputation, xCompleteFill) {
+ IntRect targetRect(0, 0, 100, 50);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 100, 50);
+
+ ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
mlamouri (slow - plz ping) 2017/02/15 11:08:04 nit: here and below: use EXPECT_*
Zhiqiang Zhang (Slow) 2017/02/15 11:52:09 Oops. Why did I do that :/ Done.
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, yCompleteFill) {
+ IntRect targetRect(0, 0, 50, 100);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 50, 100);
+
+ ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, xyCompleteFill) {
+ IntRect targetRect(0, 0, 100, 100);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 100, 100);
+
+ ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, xIncompleteFillTooSmall) {
+ IntRect targetRect(0, 0, 84, 50);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 84, 50);
+
+ ASSERT_FALSE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, yIncompleteFillTooSmall) {
+ IntRect targetRect(0, 0, 50, 84);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 50, 84);
+
+ ASSERT_FALSE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, xIncompleteFillJustRight) {
+ IntRect targetRect(0, 0, 86, 50);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 86, 50);
+
+ ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, yIncompleteFillJustRight) {
+ IntRect targetRect(0, 0, 50, 86);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 50, 86);
+
+ ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, visibleProportionTooSmall) {
+ IntRect targetRect(0, 0, 100, 100);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 100, 74);
+
+ ASSERT_FALSE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
+TEST(HTMLMediaElementTest_ViewportFillComputation, visibleProportionJustRight) {
+ IntRect targetRect(0, 0, 100, 100);
+ IntRect rootRect(0, 0, 100, 100);
+ IntRect intersectionRect(0, 0, 100, 76);
+
+ ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport(
+ targetRect, rootRect, intersectionRect));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698