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

Unified Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp

Issue 2469863002: [RemotePlayback API] Resolve/reject prompt() properly when the element is 'connected'. (Closed)
Patch Set: Fixed comments Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698