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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/html/MediaCustomControlsFullscreenDetector.h"
6
7 #include "core/testing/DummyPageHolder.h"
8 #include "platform/geometry/IntRect.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace blink {
12
13 struct TestParam {
14 String description;
15 bool isVideoOrParentFullscreen;
16 IntRect targetRect;
17 bool expectedResult;
18 };
19
20 class MediaCustomControlsFullscreenDetectorTest : public ::testing::Test {
21 protected:
22 static bool computeIsDominantVideo(bool isVideoOrParentFullscreen,
23 const IntRect& targetRect,
24 const IntRect& rootRect,
25 const IntRect& intersectionRect) {
26 return MediaCustomControlsFullscreenDetector::computeIsDominantVideo(
27 isVideoOrParentFullscreen, targetRect, rootRect, intersectionRect);
28 }
29 };
30
31 TEST_F(MediaCustomControlsFullscreenDetectorTest, computeIsDominantVideo) {
32 // TestWithParam cannot be applied here as IntRect needs the memory allocator
33 // to be initialized, but the array of parameters is statically initialized,
34 // which is before the memory allocation initialization.
35 TestParam testParams[] = {
36 {"nonFullscreen", false, {0, 0, 100, 100}, false},
37 {"xCompleteFill", true, {0, 0, 100, 50}, true},
38 {"yCompleteFill", true, {0, 0, 50, 100}, true},
39 {"xyCompleteFill", true, {0, 0, 100, 100}, true},
40 {"xIncompleteFillTooSmall", true, {0, 0, 84, 50}, false},
41 {"yIncompleteFillTooSmall", true, {0, 0, 50, 84}, false},
42 {"xIncompleteFillJustRight", true, {0, 0, 86, 50}, true},
43 {"yIncompleteFillJustRight", true, {0, 0, 50, 86}, true},
44 {"xVisibleProportionTooSmall", true, {-26, 0, 100, 100}, false},
45 {"yVisibleProportionTooSmall", true, {0, -26, 100, 100}, false},
46 {"xVisibleProportionJustRight", true, {-24, 0, 100, 100}, true},
47 {"yVisibleProportionJustRight", true, {0, -24, 100, 100}, true},
48 };
49
50 IntRect rootRect(0, 0, 100, 100);
51
52 for (const TestParam& testParam : testParams) {
53 bool isVideoOrParentFullscreen = testParam.isVideoOrParentFullscreen;
54 const IntRect& targetRect = testParam.targetRect;
55 IntRect intersectionRect = intersection(targetRect, rootRect);
56 ASSERT_EQ(testParam.expectedResult,
57 computeIsDominantVideo(isVideoOrParentFullscreen, targetRect,
58 rootRect, intersectionRect))
59 << testParam.description << " failed";
60 }
61 }
62
63 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698