Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 83 |
| 84 // Runs pending promises. | 84 // Runs pending promises. |
| 85 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 85 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 86 | 86 |
| 87 // Verify mock expectations explicitly as the mock objects are garbage | 87 // Verify mock expectations explicitly as the mock objects are garbage |
| 88 // collected. | 88 // collected. |
| 89 ::testing::Mock::VerifyAndClear(resolve); | 89 ::testing::Mock::VerifyAndClear(resolve); |
| 90 ::testing::Mock::VerifyAndClear(reject); | 90 ::testing::Mock::VerifyAndClear(reject); |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST_F(RemotePlaybackTest, PromptConnectedRejectsWhenCancelled) { | |
| 94 V8TestingScope scope; | |
| 95 | |
| 96 auto pageHolder = DummyPageHolder::create(); | |
| 97 | |
| 98 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); | |
| 99 RemotePlayback* remotePlayback = | |
| 100 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); | |
| 101 | |
| 102 auto resolve = MockFunction::create(scope.getScriptState()); | |
| 103 auto reject = MockFunction::create(scope.getScriptState()); | |
| 104 | |
| 105 EXPECT_CALL(*resolve, call(::testing::_)).Times(0); | |
| 106 EXPECT_CALL(*reject, call(::testing::_)).Times(1); | |
| 107 | |
| 108 setState(remotePlayback, WebRemotePlaybackState::Connected); | |
| 109 | |
| 110 UserGestureIndicator indicator(DocumentUserGestureToken::create( | |
| 111 &pageHolder->document(), UserGestureToken::NewGesture)); | |
| 112 remotePlayback->prompt().then(resolve->bind(), reject->bind()); | |
| 113 cancelPrompt(remotePlayback); | |
|
mlamouri (slow - plz ping)
2016/11/02 14:59:10
This is confusing. I initially thought of a bug: w
whywhat
2016/11/02 21:05:00
Cancelling the prompt is dismissing the dialog. In
| |
| 114 | |
| 115 // Runs pending promises. | |
| 116 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | |
| 117 | |
| 118 // Verify mock expectations explicitly as the mock objects are garbage | |
| 119 // collected. | |
| 120 ::testing::Mock::VerifyAndClear(resolve); | |
| 121 ::testing::Mock::VerifyAndClear(reject); | |
| 122 } | |
| 123 | |
| 124 TEST_F(RemotePlaybackTest, PromptConnectedResolvesWhenDisconnected) { | |
| 125 V8TestingScope scope; | |
| 126 | |
| 127 auto pageHolder = DummyPageHolder::create(); | |
| 128 | |
| 129 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); | |
| 130 RemotePlayback* remotePlayback = | |
| 131 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); | |
| 132 | |
| 133 auto resolve = MockFunction::create(scope.getScriptState()); | |
| 134 auto reject = MockFunction::create(scope.getScriptState()); | |
| 135 | |
| 136 EXPECT_CALL(*resolve, call(::testing::_)).Times(1); | |
| 137 EXPECT_CALL(*reject, call(::testing::_)).Times(0); | |
| 138 | |
| 139 setState(remotePlayback, WebRemotePlaybackState::Connected); | |
| 140 | |
| 141 UserGestureIndicator indicator(DocumentUserGestureToken::create( | |
| 142 &pageHolder->document(), UserGestureToken::NewGesture)); | |
| 143 remotePlayback->prompt().then(resolve->bind(), reject->bind()); | |
| 144 | |
| 145 setState(remotePlayback, WebRemotePlaybackState::Disconnected); | |
| 146 | |
| 147 // Runs pending promises. | |
| 148 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | |
| 149 | |
| 150 // Verify mock expectations explicitly as the mock objects are garbage | |
| 151 // collected. | |
| 152 ::testing::Mock::VerifyAndClear(resolve); | |
| 153 ::testing::Mock::VerifyAndClear(reject); | |
| 154 } | |
| 155 | |
| 93 TEST_F(RemotePlaybackTest, StateChangeEvents) { | 156 TEST_F(RemotePlaybackTest, StateChangeEvents) { |
| 94 V8TestingScope scope; | 157 V8TestingScope scope; |
| 95 | 158 |
| 96 auto pageHolder = DummyPageHolder::create(); | 159 auto pageHolder = DummyPageHolder::create(); |
| 97 | 160 |
| 98 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); | 161 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); |
| 99 RemotePlayback* remotePlayback = | 162 RemotePlayback* remotePlayback = |
| 100 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); | 163 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); |
| 101 | 164 |
| 102 auto connectingHandler = new ::testing::StrictMock<MockEventListener>(); | 165 auto connectingHandler = new ::testing::StrictMock<MockEventListener>(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 259 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 197 | 260 |
| 198 // Verify mock expectations explicitly as the mock objects are garbage | 261 // Verify mock expectations explicitly as the mock objects are garbage |
| 199 // collected. | 262 // collected. |
| 200 ::testing::Mock::VerifyAndClear(resolve); | 263 ::testing::Mock::VerifyAndClear(resolve); |
| 201 ::testing::Mock::VerifyAndClear(reject); | 264 ::testing::Mock::VerifyAndClear(reject); |
| 202 ::testing::Mock::VerifyAndClear(callbackFunction); | 265 ::testing::Mock::VerifyAndClear(callbackFunction); |
| 203 } | 266 } |
| 204 | 267 |
| 205 } // namespace blink | 268 } // namespace blink |
| OLD | NEW |