| 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 "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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |