| Index: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp
|
| diff --git a/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp b/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp
|
| index fe4d36e525690620fb72fa4761b47db2eb228ab5..165fd753ea3e4fc6c2396dab315798220aabfa23 100644
|
| --- a/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp
|
| +++ b/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp
|
| @@ -90,6 +90,69 @@ TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) {
|
| ::testing::Mock::VerifyAndClear(reject);
|
| }
|
|
|
| +TEST_F(RemotePlaybackTest, PromptConnectedRejectsWhenCancelled) {
|
| + V8TestingScope scope;
|
| +
|
| + auto pageHolder = DummyPageHolder::create();
|
| +
|
| + HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document());
|
| + RemotePlayback* remotePlayback =
|
| + HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element);
|
| +
|
| + auto resolve = MockFunction::create(scope.getScriptState());
|
| + auto reject = MockFunction::create(scope.getScriptState());
|
| +
|
| + EXPECT_CALL(*resolve, call(::testing::_)).Times(0);
|
| + EXPECT_CALL(*reject, call(::testing::_)).Times(1);
|
| +
|
| + setState(remotePlayback, WebRemotePlaybackState::Connected);
|
| +
|
| + UserGestureIndicator indicator(DocumentUserGestureToken::create(
|
| + &pageHolder->document(), UserGestureToken::NewGesture));
|
| + remotePlayback->prompt().then(resolve->bind(), reject->bind());
|
| + cancelPrompt(remotePlayback);
|
| +
|
| + // Runs pending promises.
|
| + v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
|
| +
|
| + // Verify mock expectations explicitly as the mock objects are garbage
|
| + // collected.
|
| + ::testing::Mock::VerifyAndClear(resolve);
|
| + ::testing::Mock::VerifyAndClear(reject);
|
| +}
|
| +
|
| +TEST_F(RemotePlaybackTest, PromptConnectedResolvesWhenDisconnected) {
|
| + V8TestingScope scope;
|
| +
|
| + auto pageHolder = DummyPageHolder::create();
|
| +
|
| + HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document());
|
| + RemotePlayback* remotePlayback =
|
| + HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element);
|
| +
|
| + auto resolve = MockFunction::create(scope.getScriptState());
|
| + auto reject = MockFunction::create(scope.getScriptState());
|
| +
|
| + EXPECT_CALL(*resolve, call(::testing::_)).Times(1);
|
| + EXPECT_CALL(*reject, call(::testing::_)).Times(0);
|
| +
|
| + setState(remotePlayback, WebRemotePlaybackState::Connected);
|
| +
|
| + UserGestureIndicator indicator(DocumentUserGestureToken::create(
|
| + &pageHolder->document(), UserGestureToken::NewGesture));
|
| + remotePlayback->prompt().then(resolve->bind(), reject->bind());
|
| +
|
| + setState(remotePlayback, WebRemotePlaybackState::Disconnected);
|
| +
|
| + // Runs pending promises.
|
| + v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
|
| +
|
| + // Verify mock expectations explicitly as the mock objects are garbage
|
| + // collected.
|
| + ::testing::Mock::VerifyAndClear(resolve);
|
| + ::testing::Mock::VerifyAndClear(reject);
|
| +}
|
| +
|
| TEST_F(RemotePlaybackTest, StateChangeEvents) {
|
| V8TestingScope scope;
|
|
|
|
|