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

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

Issue 2696893002: [Blink>Media] Add heuristic for dominant video detection for Android (Closed)
Patch Set: s/CustomControlsFullscreenDetector/MediaCustomControlsFullscreenDetector 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/MediaCustomControlsFullscreenDetectorTest.cpp
diff --git a/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9cfcbaa6c59564899b44c04b8d194b15e7ebe11a
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/MediaCustomControlsFullscreenDetectorTest.cpp
@@ -0,0 +1,63 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/MediaCustomControlsFullscreenDetector.h"
+
+#include "core/testing/DummyPageHolder.h"
+#include "platform/geometry/IntRect.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+struct TestParam {
+ String description;
+ bool isVideoOrParentFullscreen;
+ IntRect targetRect;
+ bool expectedResult;
+};
+
+class MediaCustomControlsFullscreenDetectorTest : public ::testing::Test {
+ protected:
+ static bool computeIsDominantVideo(bool isVideoOrParentFullscreen,
+ const IntRect& targetRect,
+ const IntRect& rootRect,
+ const IntRect& intersectionRect) {
+ return MediaCustomControlsFullscreenDetector::computeIsDominantVideo(
+ isVideoOrParentFullscreen, targetRect, rootRect, intersectionRect);
+ }
+};
+
+TEST_F(MediaCustomControlsFullscreenDetectorTest, computeIsDominantVideo) {
+ // TestWithParam cannot be applied here as IntRect needs the memory allocator
+ // to be initialized, but the array of parameters is statically initialized,
+ // which is before the memory allocation initialization.
+ TestParam testParams[] = {
+ {"nonFullscreen", false, {0, 0, 100, 100}, false},
+ {"xCompleteFill", true, {0, 0, 100, 50}, true},
+ {"yCompleteFill", true, {0, 0, 50, 100}, true},
+ {"xyCompleteFill", true, {0, 0, 100, 100}, true},
+ {"xIncompleteFillTooSmall", true, {0, 0, 84, 50}, false},
+ {"yIncompleteFillTooSmall", true, {0, 0, 50, 84}, false},
+ {"xIncompleteFillJustRight", true, {0, 0, 86, 50}, true},
+ {"yIncompleteFillJustRight", true, {0, 0, 50, 86}, true},
+ {"xVisibleProportionTooSmall", true, {-26, 0, 100, 100}, false},
+ {"yVisibleProportionTooSmall", true, {0, -26, 100, 100}, false},
+ {"xVisibleProportionJustRight", true, {-24, 0, 100, 100}, true},
+ {"yVisibleProportionJustRight", true, {0, -24, 100, 100}, true},
+ };
+
+ IntRect rootRect(0, 0, 100, 100);
+
+ for (const TestParam& testParam : testParams) {
+ bool isVideoOrParentFullscreen = testParam.isVideoOrParentFullscreen;
+ const IntRect& targetRect = testParam.targetRect;
+ IntRect intersectionRect = intersection(targetRect, rootRect);
+ ASSERT_EQ(testParam.expectedResult,
+ computeIsDominantVideo(isVideoOrParentFullscreen, targetRect,
+ rootRect, intersectionRect))
+ << testParam.description << " failed";
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698