| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/dom/Document.h" | 5 #include "core/dom/Document.h" |
| 6 #include "core/html/AutoplayExperimentHelper.h" | 6 #include "core/html/AutoplayExperimentHelper.h" |
| 7 #include "platform/UserGestureIndicator.h" | 7 #include "platform/UserGestureIndicator.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 public: | 97 public: |
| 98 AutoplayExperimentTest() {} | 98 AutoplayExperimentTest() {} |
| 99 | 99 |
| 100 ~AutoplayExperimentTest() {} | 100 ~AutoplayExperimentTest() {} |
| 101 | 101 |
| 102 bool isEligible() | 102 bool isEligible() |
| 103 { | 103 { |
| 104 return m_helper->isEligible(); | 104 return m_helper->isEligible(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void setInterface(PassOwnPtrWillBeRawPtr<MockAutoplayClient> client) | 107 void setInterface(RawPtr<MockAutoplayClient> client) |
| 108 { | 108 { |
| 109 m_client = client; | 109 m_client = client; |
| 110 | 110 |
| 111 // Set some defaults. | 111 // Set some defaults. |
| 112 setUserGestureRequiredForPlay(true); | 112 setUserGestureRequiredForPlay(true); |
| 113 setShouldAutoplay(true); | 113 setShouldAutoplay(true); |
| 114 setIsMuted(false); | 114 setIsMuted(false); |
| 115 | 115 |
| 116 m_helper = AutoplayExperimentHelper::create(m_client.get()); | 116 m_helper = AutoplayExperimentHelper::create(m_client.get()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 #if ENABLE(OILPAN) | 119 #if ENABLE(OILPAN) |
| 120 void TearDown() | 120 void TearDown() |
| 121 { | 121 { |
| 122 // Be sure that the mock is destructed before the test, so that any | 122 // Be sure that the mock is destructed before the test, so that any |
| 123 // missing expectations are noticed. Otherwise, the test will pass | 123 // missing expectations are noticed. Otherwise, the test will pass |
| 124 // and then missing expectations will show up in the log, without | 124 // and then missing expectations will show up in the log, without |
| 125 // causing a test failure. | 125 // causing a test failure. |
| 126 m_helper.clear(); | 126 m_helper.clear(); |
| 127 m_client.clear(); | 127 m_client.clear(); |
| 128 Heap::collectAllGarbage(); | 128 Heap::collectAllGarbage(); |
| 129 } | 129 } |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 OwnPtrWillBePersistent<MockAutoplayClient> m_client; | 132 Persistent<MockAutoplayClient> m_client; |
| 133 OwnPtrWillBePersistent<AutoplayExperimentHelper> m_helper; | 133 Persistent<AutoplayExperimentHelper> m_helper; |
| 134 | 134 |
| 135 // Mirror updatePlayState to transition to play. | 135 // Mirror updatePlayState to transition to play. |
| 136 void startPlayback() | 136 void startPlayback() |
| 137 { | 137 { |
| 138 EXPECT_CALL(*m_client, recordAutoplayMetric(AnyPlaybackStarted)) | 138 EXPECT_CALL(*m_client, recordAutoplayMetric(AnyPlaybackStarted)) |
| 139 .Times(1); | 139 .Times(1); |
| 140 m_helper->playbackStarted(); | 140 m_helper->playbackStarted(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void startPlaybackWithoutUserGesture() | 143 void startPlaybackWithoutUserGesture() |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 void moveIntoViewport() | 221 void moveIntoViewport() |
| 222 { | 222 { |
| 223 m_helper->positionChanged(IntRect(0, 0, 200, 200)); | 223 m_helper->positionChanged(IntRect(0, 0, 200, 200)); |
| 224 m_helper->triggerAutoplayViewportCheckForTesting(); | 224 m_helper->triggerAutoplayViewportCheckForTesting(); |
| 225 } | 225 } |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 TEST_F(AutoplayExperimentTest, IsNotEligibleWithEmptyMode) | 228 TEST_F(AutoplayExperimentTest, IsNotEligibleWithEmptyMode) |
| 229 { | 229 { |
| 230 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("", MockAut
oplayClient::Video))); | 230 setInterface(new NiceMock<MockAutoplayClient>("", MockAutoplayClient::Video)
); |
| 231 EXPECT_FALSE(isEligible()); | 231 EXPECT_FALSE(isEligible()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 TEST_F(AutoplayExperimentTest, IsVideoEligibleForVideoMode) | 234 TEST_F(AutoplayExperimentTest, IsVideoEligibleForVideoMode) |
| 235 { | 235 { |
| 236 // Video should be eligible in "forvideo" mode. | 236 // Video should be eligible in "forvideo" mode. |
| 237 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 237 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 238 EXPECT_TRUE(isEligible()); | 238 EXPECT_TRUE(isEligible()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 TEST_F(AutoplayExperimentTest, IsAudioNotEligibleForVideoMode) | 241 TEST_F(AutoplayExperimentTest, IsAudioNotEligibleForVideoMode) |
| 242 { | 242 { |
| 243 // Audio should not be eligible for video mode. | 243 // Audio should not be eligible for video mode. |
| 244 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Audio))); | 244 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Audio)); |
| 245 EXPECT_FALSE(isEligible()); | 245 EXPECT_FALSE(isEligible()); |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST_F(AutoplayExperimentTest, IsEligibleRequiresUserGesture) | 248 TEST_F(AutoplayExperimentTest, IsEligibleRequiresUserGesture) |
| 249 { | 249 { |
| 250 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 250 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 251 // If a user gesture is not required, then we're not eligible. | 251 // If a user gesture is not required, then we're not eligible. |
| 252 ON_CALL(*m_client, isUserGestureRequiredForPlay()) | 252 ON_CALL(*m_client, isUserGestureRequiredForPlay()) |
| 253 .WillByDefault(Return(false)); | 253 .WillByDefault(Return(false)); |
| 254 EXPECT_FALSE(isEligible()); | 254 EXPECT_FALSE(isEligible()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 TEST_F(AutoplayExperimentTest, IsEligibleRequiresShouldAutoplay) | 257 TEST_F(AutoplayExperimentTest, IsEligibleRequiresShouldAutoplay) |
| 258 { | 258 { |
| 259 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 259 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 260 // If we shouldn't autoplay, then we're not eligible. | 260 // If we shouldn't autoplay, then we're not eligible. |
| 261 ON_CALL(*m_client, shouldAutoplay()) | 261 ON_CALL(*m_client, shouldAutoplay()) |
| 262 .WillByDefault(Return(false)); | 262 .WillByDefault(Return(false)); |
| 263 EXPECT_FALSE(isEligible()); | 263 EXPECT_FALSE(isEligible()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TEST_F(AutoplayExperimentTest, IsAudioEligibleForAudioMode) | 266 TEST_F(AutoplayExperimentTest, IsAudioEligibleForAudioMode) |
| 267 { | 267 { |
| 268 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
raudio", MockAutoplayClient::Audio))); | 268 setInterface(new NiceMock<MockAutoplayClient>("enabled-foraudio", MockAutopl
ayClient::Audio)); |
| 269 EXPECT_TRUE(isEligible()); | 269 EXPECT_TRUE(isEligible()); |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST_F(AutoplayExperimentTest, EligibleIfOptimizedForMobile) | 272 TEST_F(AutoplayExperimentTest, EligibleIfOptimizedForMobile) |
| 273 { | 273 { |
| 274 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo-ifmobile", MockAutoplayClient::Video))); | 274 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo-ifmobile", M
ockAutoplayClient::Video)); |
| 275 // Should not be eligible with our default of "not mobile". | 275 // Should not be eligible with our default of "not mobile". |
| 276 EXPECT_FALSE(isEligible()); | 276 EXPECT_FALSE(isEligible()); |
| 277 | 277 |
| 278 ON_CALL(*m_client, isLegacyViewportType()) | 278 ON_CALL(*m_client, isLegacyViewportType()) |
| 279 .WillByDefault(Return(true)); | 279 .WillByDefault(Return(true)); |
| 280 EXPECT_TRUE(isEligible()); | 280 EXPECT_TRUE(isEligible()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 TEST_F(AutoplayExperimentTest, EligibleIfMuted) | 283 TEST_F(AutoplayExperimentTest, EligibleIfMuted) |
| 284 { | 284 { |
| 285 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo-ifmuted", MockAutoplayClient::Video))); | 285 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo-ifmuted", Mo
ckAutoplayClient::Video)); |
| 286 // Should not be eligible with our default of "not muted". | 286 // Should not be eligible with our default of "not muted". |
| 287 EXPECT_FALSE(isEligible()); | 287 EXPECT_FALSE(isEligible()); |
| 288 | 288 |
| 289 ON_CALL(*m_client, muted()) | 289 ON_CALL(*m_client, muted()) |
| 290 .WillByDefault(Return(true)); | 290 .WillByDefault(Return(true)); |
| 291 EXPECT_TRUE(isEligible()); | 291 EXPECT_TRUE(isEligible()); |
| 292 } | 292 } |
| 293 | 293 |
| 294 TEST_F(AutoplayExperimentTest, BecameReadyAutoplayThenBailout) | 294 TEST_F(AutoplayExperimentTest, BecameReadyAutoplayThenBailout) |
| 295 { | 295 { |
| 296 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 296 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 297 | 297 |
| 298 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 298 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 299 .Times(1); | 299 .Times(1); |
| 300 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 300 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 301 .Times(1); | 301 .Times(1); |
| 302 m_helper->becameReadyToPlay(); | 302 m_helper->becameReadyToPlay(); |
| 303 | 303 |
| 304 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagImmediately)) | 304 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagImmediately)) |
| 305 .Times(1); | 305 .Times(1); |
| 306 startPlaybackWithoutUserGesture(); | 306 startPlaybackWithoutUserGesture(); |
| 307 | 307 |
| 308 pausePlaybackExpectingBailout(true); | 308 pausePlaybackExpectingBailout(true); |
| 309 } | 309 } |
| 310 | 310 |
| 311 TEST_F(AutoplayExperimentTest, BecameReadyAutoplayThenPause) | 311 TEST_F(AutoplayExperimentTest, BecameReadyAutoplayThenPause) |
| 312 { | 312 { |
| 313 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 313 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 314 | 314 |
| 315 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 315 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 316 .Times(1); | 316 .Times(1); |
| 317 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 317 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 318 .Times(1); | 318 .Times(1); |
| 319 m_helper->becameReadyToPlay(); | 319 m_helper->becameReadyToPlay(); |
| 320 | 320 |
| 321 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagImmediately)) | 321 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagImmediately)) |
| 322 .Times(1); | 322 .Times(1); |
| 323 startPlaybackWithoutUserGesture(); | 323 startPlaybackWithoutUserGesture(); |
| 324 | 324 |
| 325 pausePlaybackNotExpectingBailout(true); | 325 pausePlaybackNotExpectingBailout(true); |
| 326 } | 326 } |
| 327 | 327 |
| 328 TEST_F(AutoplayExperimentTest, BecameReadyAutoplayThenComplete) | 328 TEST_F(AutoplayExperimentTest, BecameReadyAutoplayThenComplete) |
| 329 { | 329 { |
| 330 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 330 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 331 | 331 |
| 332 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 332 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 333 .Times(1); | 333 .Times(1); |
| 334 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 334 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 335 .Times(1); | 335 .Times(1); |
| 336 m_helper->becameReadyToPlay(); | 336 m_helper->becameReadyToPlay(); |
| 337 | 337 |
| 338 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagImmediately)) | 338 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagImmediately)) |
| 339 .Times(1); | 339 .Times(1); |
| 340 startPlaybackWithoutUserGesture(); | 340 startPlaybackWithoutUserGesture(); |
| 341 | 341 |
| 342 // Now stop at the end. | 342 // Now stop at the end. |
| 343 endPlayback(true); | 343 endPlayback(true); |
| 344 } | 344 } |
| 345 | 345 |
| 346 TEST_F(AutoplayExperimentTest, NoUserGestureNeededShouldNotOverride) | 346 TEST_F(AutoplayExperimentTest, NoUserGestureNeededShouldNotOverride) |
| 347 { | 347 { |
| 348 // Make sure that we don't override the user gesture if it isn't needed. | 348 // Make sure that we don't override the user gesture if it isn't needed. |
| 349 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 349 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 350 setUserGestureRequiredForPlay(false); | 350 setUserGestureRequiredForPlay(false); |
| 351 | 351 |
| 352 // It is still autoplay media, though. | 352 // It is still autoplay media, though. |
| 353 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 353 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 354 .Times(1); | 354 .Times(1); |
| 355 m_helper->becameReadyToPlay(); | 355 m_helper->becameReadyToPlay(); |
| 356 | 356 |
| 357 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackNotOverridden
)) | 357 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackNotOverridden
)) |
| 358 .Times(1); | 358 .Times(1); |
| 359 startPlaybackWithoutUserGesture(); | 359 startPlaybackWithoutUserGesture(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 TEST_F(AutoplayExperimentTest, NoAutoplayMetricsIfNoAutoplay) | 362 TEST_F(AutoplayExperimentTest, NoAutoplayMetricsIfNoAutoplay) |
| 363 { | 363 { |
| 364 // If playback is started while processing a user gesture, then nothing | 364 // If playback is started while processing a user gesture, then nothing |
| 365 // should be overridden or logged about autoplay. | 365 // should be overridden or logged about autoplay. |
| 366 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 366 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 367 setUserGestureRequiredForPlay(false); | 367 setUserGestureRequiredForPlay(false); |
| 368 setShouldAutoplay(false); | 368 setShouldAutoplay(false); |
| 369 startPlaybackWithUserGesture(); | 369 startPlaybackWithUserGesture(); |
| 370 | 370 |
| 371 // Expect bailout, but not from autoplay. | 371 // Expect bailout, but not from autoplay. |
| 372 pausePlaybackExpectingBailout(false); | 372 pausePlaybackExpectingBailout(false); |
| 373 } | 373 } |
| 374 | 374 |
| 375 TEST_F(AutoplayExperimentTest, PlayMethodThenBailout) | 375 TEST_F(AutoplayExperimentTest, PlayMethodThenBailout) |
| 376 { | 376 { |
| 377 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo", MockAutoplayClient::Video))); | 377 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo", MockAutopl
ayClient::Video)); |
| 378 setShouldAutoplay(false); // No autoplay attribute. | 378 setShouldAutoplay(false); // No autoplay attribute. |
| 379 | 379 |
| 380 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 380 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 381 .Times(1); | 381 .Times(1); |
| 382 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 382 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 383 .Times(1); | 383 .Times(1); |
| 384 m_helper->playMethodCalled(); | 384 m_helper->playMethodCalled(); |
| 385 | 385 |
| 386 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByPlay
MethodImmediately)) | 386 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByPlay
MethodImmediately)) |
| 387 .Times(1); | 387 .Times(1); |
| 388 startPlaybackWithoutUserGesture(); | 388 startPlaybackWithoutUserGesture(); |
| 389 | 389 |
| 390 pausePlaybackExpectingBailout(true); | 390 pausePlaybackExpectingBailout(true); |
| 391 } | 391 } |
| 392 | 392 |
| 393 TEST_F(AutoplayExperimentTest, DeferAutoplayUntilMuted) | 393 TEST_F(AutoplayExperimentTest, DeferAutoplayUntilMuted) |
| 394 { | 394 { |
| 395 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo-ifmuted", MockAutoplayClient::Video))); | 395 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo-ifmuted", Mo
ckAutoplayClient::Video)); |
| 396 | 396 |
| 397 // Should not override the gesture requirement yet. | 397 // Should not override the gesture requirement yet. |
| 398 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 398 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 399 .Times(1); | 399 .Times(1); |
| 400 m_helper->becameReadyToPlay(); | 400 m_helper->becameReadyToPlay(); |
| 401 | 401 |
| 402 // When we toggle the muted attribute, it should start. | 402 // When we toggle the muted attribute, it should start. |
| 403 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 403 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 404 .Times(1); | 404 .Times(1); |
| 405 EXPECT_CALL(*m_client, playInternal()) | 405 EXPECT_CALL(*m_client, playInternal()) |
| 406 .Times(1); | 406 .Times(1); |
| 407 setIsMuted(true); | 407 setIsMuted(true); |
| 408 m_helper->mutedChanged(); | 408 m_helper->mutedChanged(); |
| 409 | 409 |
| 410 // When playback starts (in response to playInternal()), it should also | 410 // When playback starts (in response to playInternal()), it should also |
| 411 // record why. 'After scroll' isn't the best name, but this isn't a common
case. | 411 // record why. 'After scroll' isn't the best name, but this isn't a common
case. |
| 412 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagAfterScroll)) | 412 EXPECT_CALL(*m_client, recordAutoplayMetric(GesturelessPlaybackStartedByAuto
playFlagAfterScroll)) |
| 413 .Times(1); | 413 .Times(1); |
| 414 startPlaybackWithoutUserGesture(); | 414 startPlaybackWithoutUserGesture(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 TEST_F(AutoplayExperimentTest, DeferPlaybackUntilInViewport) | 417 TEST_F(AutoplayExperimentTest, DeferPlaybackUntilInViewport) |
| 418 { | 418 { |
| 419 setInterface(adoptPtrWillBeNoop(new NiceMock<MockAutoplayClient>("enabled-fo
rvideo-ifviewport", MockAutoplayClient::Video))); | 419 setInterface(new NiceMock<MockAutoplayClient>("enabled-forvideo-ifviewport",
MockAutoplayClient::Video)); |
| 420 | 420 |
| 421 // Should not override the gesture requirement yet. | 421 // Should not override the gesture requirement yet. |
| 422 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) | 422 EXPECT_CALL(*m_client, recordAutoplayMetric(AutoplayMediaFound)) |
| 423 .Times(1); | 423 .Times(1); |
| 424 EXPECT_CALL(*m_client, setRequestPositionUpdates(true)) | 424 EXPECT_CALL(*m_client, setRequestPositionUpdates(true)) |
| 425 .Times(1); | 425 .Times(1); |
| 426 m_helper->becameReadyToPlay(); | 426 m_helper->becameReadyToPlay(); |
| 427 | 427 |
| 428 EXPECT_CALL(*m_client, removeUserGestureRequirement()) | 428 EXPECT_CALL(*m_client, removeUserGestureRequirement()) |
| 429 .Times(1); | 429 .Times(1); |
| 430 EXPECT_CALL(*m_client, playInternal()) | 430 EXPECT_CALL(*m_client, playInternal()) |
| 431 .Times(1); | 431 .Times(1); |
| 432 EXPECT_CALL(*m_client, setRequestPositionUpdates(false)) | 432 EXPECT_CALL(*m_client, setRequestPositionUpdates(false)) |
| 433 .Times(1); | 433 .Times(1); |
| 434 moveIntoViewport(); | 434 moveIntoViewport(); |
| 435 } | 435 } |
| 436 } | 436 } |
| OLD | NEW |