| 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/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.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/UserGestureIndicator.h" | 10 #include "core/dom/UserGestureIndicator.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 v8::Local<v8::Function> Bind() { return BindToV8Function(); } | 33 v8::Local<v8::Function> Bind() { return BindToV8Function(); } |
| 34 | 34 |
| 35 MOCK_METHOD1(Call, ScriptValue(ScriptValue)); | 35 MOCK_METHOD1(Call, ScriptValue(ScriptValue)); |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 explicit MockFunction(ScriptState* script_state) | 38 explicit MockFunction(ScriptState* script_state) |
| 39 : ScriptFunction(script_state) {} | 39 : ScriptFunction(script_state) {} |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 class MockEventListener : public EventListener { | 42 class MockEventListenerForRemotePlayback : public EventListener { |
| 43 public: | 43 public: |
| 44 MockEventListener() : EventListener(kCPPEventListenerType) {} | 44 MockEventListenerForRemotePlayback() : EventListener(kCPPEventListenerType) {} |
| 45 | 45 |
| 46 bool operator==(const EventListener& other) const final { | 46 bool operator==(const EventListener& other) const final { |
| 47 return this == &other; | 47 return this == &other; |
| 48 } | 48 } |
| 49 | 49 |
| 50 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*)); | 50 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*)); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class RemotePlaybackTest : public ::testing::Test { | 53 class RemotePlaybackTest : public ::testing::Test { |
| 54 protected: | 54 protected: |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 TEST_F(RemotePlaybackTest, StateChangeEvents) { | 192 TEST_F(RemotePlaybackTest, StateChangeEvents) { |
| 193 V8TestingScope scope; | 193 V8TestingScope scope; |
| 194 | 194 |
| 195 auto page_holder = DummyPageHolder::Create(); | 195 auto page_holder = DummyPageHolder::Create(); |
| 196 | 196 |
| 197 HTMLMediaElement* element = | 197 HTMLMediaElement* element = |
| 198 HTMLVideoElement::Create(page_holder->GetDocument()); | 198 HTMLVideoElement::Create(page_holder->GetDocument()); |
| 199 RemotePlayback* remote_playback = | 199 RemotePlayback* remote_playback = |
| 200 HTMLMediaElementRemotePlayback::remote(*element); | 200 HTMLMediaElementRemotePlayback::remote(*element); |
| 201 | 201 |
| 202 auto connecting_handler = new ::testing::StrictMock<MockEventListener>(); | 202 auto connecting_handler = |
| 203 auto connect_handler = new ::testing::StrictMock<MockEventListener>(); | 203 new ::testing::StrictMock<MockEventListenerForRemotePlayback>(); |
| 204 auto disconnect_handler = new ::testing::StrictMock<MockEventListener>(); | 204 auto connect_handler = |
| 205 new ::testing::StrictMock<MockEventListenerForRemotePlayback>(); |
| 206 auto disconnect_handler = |
| 207 new ::testing::StrictMock<MockEventListenerForRemotePlayback>(); |
| 205 | 208 |
| 206 remote_playback->addEventListener(EventTypeNames::connecting, | 209 remote_playback->addEventListener(EventTypeNames::connecting, |
| 207 connecting_handler); | 210 connecting_handler); |
| 208 remote_playback->addEventListener(EventTypeNames::connect, connect_handler); | 211 remote_playback->addEventListener(EventTypeNames::connect, connect_handler); |
| 209 remote_playback->addEventListener(EventTypeNames::disconnect, | 212 remote_playback->addEventListener(EventTypeNames::disconnect, |
| 210 disconnect_handler); | 213 disconnect_handler); |
| 211 | 214 |
| 212 EXPECT_CALL(*connecting_handler, handleEvent(::testing::_, ::testing::_)) | 215 EXPECT_CALL(*connecting_handler, handleEvent(::testing::_, ::testing::_)) |
| 213 .Times(1); | 216 .Times(1); |
| 214 EXPECT_CALL(*connect_handler, handleEvent(::testing::_, ::testing::_)) | 217 EXPECT_CALL(*connect_handler, handleEvent(::testing::_, ::testing::_)) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // Runs pending promises. | 445 // Runs pending promises. |
| 443 v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate()); | 446 v8::MicrotasksScope::PerformCheckpoint(scope.GetIsolate()); |
| 444 | 447 |
| 445 // Verify mock expectations explicitly as the mock objects are garbage | 448 // Verify mock expectations explicitly as the mock objects are garbage |
| 446 // collected. | 449 // collected. |
| 447 ::testing::Mock::VerifyAndClear(callback_function); | 450 ::testing::Mock::VerifyAndClear(callback_function); |
| 448 ::testing::Mock::VerifyAndClear(&presentation_client_); | 451 ::testing::Mock::VerifyAndClear(&presentation_client_); |
| 449 } | 452 } |
| 450 | 453 |
| 451 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |