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

Side by Side Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp

Issue 2480003002: [RemotePlayback] Keep track of source compatibility and reject prompt() correspondingly (Closed)
Patch Set: Fixed the java enum comment 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 unified diff | Download patch
OLDNEW
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 "modules/remoteplayback/RemotePlayback.h" 5 #include "modules/remoteplayback/RemotePlayback.h"
6 6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" 9 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h"
10 #include "core/dom/DocumentUserGestureToken.h" 10 #include "core/dom/DocumentUserGestureToken.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 class RemotePlaybackTest : public ::testing::Test { 49 class RemotePlaybackTest : public ::testing::Test {
50 protected: 50 protected:
51 void cancelPrompt(RemotePlayback* remotePlayback) { 51 void cancelPrompt(RemotePlayback* remotePlayback) {
52 remotePlayback->promptCancelled(); 52 remotePlayback->promptCancelled();
53 } 53 }
54 54
55 void setState(RemotePlayback* remotePlayback, WebRemotePlaybackState state) { 55 void setState(RemotePlayback* remotePlayback, WebRemotePlaybackState state) {
56 remotePlayback->stateChanged(state); 56 remotePlayback->stateChanged(state);
57 } 57 }
58
59 void setAvailability(RemotePlayback* remotePlayback, bool available) {
60 remotePlayback->availabilityChanged(available);
61 }
62 }; 58 };
63 59
64 TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) { 60 TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) {
65 V8TestingScope scope; 61 V8TestingScope scope;
66 62
67 auto pageHolder = DummyPageHolder::create(); 63 auto pageHolder = DummyPageHolder::create();
68 64
69 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); 65 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document());
70 RemotePlayback* remotePlayback = 66 RemotePlayback* remotePlayback =
71 HTMLMediaElementRemotePlayback::remote(*element); 67 HTMLMediaElementRemotePlayback::remote(*element);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 247
252 EXPECT_CALL(*resolve, call(::testing::_)).Times(1); 248 EXPECT_CALL(*resolve, call(::testing::_)).Times(1);
253 EXPECT_CALL(*reject, call(::testing::_)).Times(0); 249 EXPECT_CALL(*reject, call(::testing::_)).Times(0);
254 250
255 remotePlayback 251 remotePlayback
256 ->watchAvailability(scope.getScriptState(), availabilityCallback) 252 ->watchAvailability(scope.getScriptState(), availabilityCallback)
257 .then(resolve->bind(), reject->bind()); 253 .then(resolve->bind(), reject->bind());
258 254
259 HTMLMediaElementRemotePlayback::setBooleanAttribute( 255 HTMLMediaElementRemotePlayback::setBooleanAttribute(
260 HTMLNames::disableremoteplaybackAttr, *element, true); 256 HTMLNames::disableremoteplaybackAttr, *element, true);
261 setAvailability(remotePlayback, true);
262 257
263 // Runs pending promises. 258 // Runs pending promises.
264 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 259 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
265 260
266 // Verify mock expectations explicitly as the mock objects are garbage 261 // Verify mock expectations explicitly as the mock objects are garbage
267 // collected. 262 // collected.
268 ::testing::Mock::VerifyAndClear(resolve); 263 ::testing::Mock::VerifyAndClear(resolve);
269 ::testing::Mock::VerifyAndClear(reject); 264 ::testing::Mock::VerifyAndClear(reject);
270 ::testing::Mock::VerifyAndClear(callbackFunction); 265 ::testing::Mock::VerifyAndClear(callbackFunction);
271 } 266 }
272 267
273 } // namespace blink 268 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698