Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/html/HTMLMediaElement.h" | 5 #include "core/html/HTMLMediaElement.h" |
| 6 | 6 |
| 7 #include "core/frame/Settings.h" | 7 #include "core/frame/Settings.h" |
| 8 #include "core/html/HTMLAudioElement.h" | 8 #include "core/html/HTMLAudioElement.h" |
| 9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
| 10 #include "core/page/NetworkStateNotifier.h" | 10 #include "core/page/NetworkStateNotifier.h" |
| 11 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 enum class TestParam { Audio, Video }; | 16 enum class TestParam { Audio, Video }; |
| 17 | 17 |
| 18 class HTMLMediaElementTest : public ::testing::TestWithParam<TestParam> { | 18 class HTMLMediaElementTest : public ::testing::TestWithParam<TestParam> { |
| 19 public: | |
| 20 static bool computeIsMostlyFillingViewport(const IntRect& targetRect, | |
| 21 const IntRect& rootRect, | |
| 22 const IntRect& intersectionRect) { | |
| 23 return HTMLMediaElement::computeIsMostlyFillingViewport( | |
| 24 targetRect, rootRect, intersectionRect); | |
| 25 } | |
| 26 | |
| 19 protected: | 27 protected: |
| 20 void SetUp() { | 28 void SetUp() { |
| 21 m_dummyPageHolder = DummyPageHolder::create(); | 29 m_dummyPageHolder = DummyPageHolder::create(); |
| 22 | 30 |
| 23 if (GetParam() == TestParam::Audio) | 31 if (GetParam() == TestParam::Audio) |
| 24 m_media = HTMLAudioElement::create(m_dummyPageHolder->document()); | 32 m_media = HTMLAudioElement::create(m_dummyPageHolder->document()); |
| 25 else | 33 else |
| 26 m_media = HTMLVideoElement::create(m_dummyPageHolder->document()); | 34 m_media = HTMLVideoElement::create(m_dummyPageHolder->document()); |
| 27 } | 35 } |
| 28 | 36 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 } | 139 } |
| 132 setCurrentSrc(srcSchemeToURL(data.srcScheme)); | 140 setCurrentSrc(srcSchemeToURL(data.srcScheme)); |
| 133 media()->setPreload(data.preloadToSet); | 141 media()->setPreload(data.preloadToSet); |
| 134 | 142 |
| 135 EXPECT_EQ(data.preloadExpected, media()->preload()) | 143 EXPECT_EQ(data.preloadExpected, media()->preload()) |
| 136 << "preload type differs at index" << index; | 144 << "preload type differs at index" << index; |
| 137 ++index; | 145 ++index; |
| 138 } | 146 } |
| 139 } | 147 } |
| 140 | 148 |
| 149 TEST(HTMLMediaElementTest_ViewportFillComputation, xCompleteFill) { | |
| 150 IntRect targetRect(0, 0, 100, 50); | |
| 151 IntRect rootRect(0, 0, 100, 100); | |
| 152 IntRect intersectionRect(0, 0, 100, 50); | |
| 153 | |
| 154 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.
| |
| 155 targetRect, rootRect, intersectionRect)); | |
| 156 } | |
| 157 | |
| 158 TEST(HTMLMediaElementTest_ViewportFillComputation, yCompleteFill) { | |
| 159 IntRect targetRect(0, 0, 50, 100); | |
| 160 IntRect rootRect(0, 0, 100, 100); | |
| 161 IntRect intersectionRect(0, 0, 50, 100); | |
| 162 | |
| 163 ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 164 targetRect, rootRect, intersectionRect)); | |
| 165 } | |
| 166 | |
| 167 TEST(HTMLMediaElementTest_ViewportFillComputation, xyCompleteFill) { | |
| 168 IntRect targetRect(0, 0, 100, 100); | |
| 169 IntRect rootRect(0, 0, 100, 100); | |
| 170 IntRect intersectionRect(0, 0, 100, 100); | |
| 171 | |
| 172 ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 173 targetRect, rootRect, intersectionRect)); | |
| 174 } | |
| 175 | |
| 176 TEST(HTMLMediaElementTest_ViewportFillComputation, xIncompleteFillTooSmall) { | |
| 177 IntRect targetRect(0, 0, 84, 50); | |
| 178 IntRect rootRect(0, 0, 100, 100); | |
| 179 IntRect intersectionRect(0, 0, 84, 50); | |
| 180 | |
| 181 ASSERT_FALSE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 182 targetRect, rootRect, intersectionRect)); | |
| 183 } | |
| 184 | |
| 185 TEST(HTMLMediaElementTest_ViewportFillComputation, yIncompleteFillTooSmall) { | |
| 186 IntRect targetRect(0, 0, 50, 84); | |
| 187 IntRect rootRect(0, 0, 100, 100); | |
| 188 IntRect intersectionRect(0, 0, 50, 84); | |
| 189 | |
| 190 ASSERT_FALSE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 191 targetRect, rootRect, intersectionRect)); | |
| 192 } | |
| 193 | |
| 194 TEST(HTMLMediaElementTest_ViewportFillComputation, xIncompleteFillJustRight) { | |
| 195 IntRect targetRect(0, 0, 86, 50); | |
| 196 IntRect rootRect(0, 0, 100, 100); | |
| 197 IntRect intersectionRect(0, 0, 86, 50); | |
| 198 | |
| 199 ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 200 targetRect, rootRect, intersectionRect)); | |
| 201 } | |
| 202 | |
| 203 TEST(HTMLMediaElementTest_ViewportFillComputation, yIncompleteFillJustRight) { | |
| 204 IntRect targetRect(0, 0, 50, 86); | |
| 205 IntRect rootRect(0, 0, 100, 100); | |
| 206 IntRect intersectionRect(0, 0, 50, 86); | |
| 207 | |
| 208 ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 209 targetRect, rootRect, intersectionRect)); | |
| 210 } | |
| 211 | |
| 212 TEST(HTMLMediaElementTest_ViewportFillComputation, visibleProportionTooSmall) { | |
| 213 IntRect targetRect(0, 0, 100, 100); | |
| 214 IntRect rootRect(0, 0, 100, 100); | |
| 215 IntRect intersectionRect(0, 0, 100, 74); | |
| 216 | |
| 217 ASSERT_FALSE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 218 targetRect, rootRect, intersectionRect)); | |
| 219 } | |
| 220 | |
| 221 TEST(HTMLMediaElementTest_ViewportFillComputation, visibleProportionJustRight) { | |
| 222 IntRect targetRect(0, 0, 100, 100); | |
| 223 IntRect rootRect(0, 0, 100, 100); | |
| 224 IntRect intersectionRect(0, 0, 100, 76); | |
| 225 | |
| 226 ASSERT_TRUE(HTMLMediaElementTest::computeIsMostlyFillingViewport( | |
| 227 targetRect, rootRect, intersectionRect)); | |
| 228 } | |
| 229 | |
| 141 } // namespace blink | 230 } // namespace blink |
| OLD | NEW |