Chromium Code Reviews| 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 87bfdf0012bc2ccf42e4b311fe4e272f5ee87286..0c28dd7a9eb24199dce2e056e3bc72e244a83cbd 100644 |
| --- a/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp |
| +++ b/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp |
| @@ -10,6 +10,7 @@ |
| #include "core/html/HTMLVideoElement.h" |
| #include "core/testing/DummyPageHolder.h" |
| #include "platform/testing/UnitTestHelpers.h" |
| +#include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -30,11 +31,26 @@ class MockFunction : public ScriptFunction { |
| : ScriptFunction(scriptState) {} |
| }; |
| +class MockEventListener : public EventListener { |
| + public: |
| + MockEventListener() : EventListener(CPPEventListenerType) {} |
| + |
| + bool operator==(const EventListener& other) const final { |
| + return this == &other; |
| + } |
| + |
| + MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*)); |
| +}; |
| + |
| class RemotePlaybackTest : public ::testing::Test { |
| protected: |
| void cancelPrompt(RemotePlayback* remotePlayback) { |
| remotePlayback->promptCancelled(); |
| } |
| + |
| + void setState(RemotePlayback* remotePlayback, WebRemotePlaybackState state) { |
| + remotePlayback->stateChanged(state); |
| + } |
| }; |
| TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) { |
| @@ -56,4 +72,34 @@ TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) { |
| cancelPrompt(remotePlayback); |
| } |
| +TEST_F(RemotePlaybackTest, StateChangeEvents) { |
| + V8TestingScope scope; |
| + |
| + auto pageHolder = DummyPageHolder::create(); |
| + |
| + HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); |
| + RemotePlayback* remotePlayback = RemotePlayback::create(*element); |
| + |
| + auto connectingHandler = new ::testing::StrictMock<MockEventListener>(); |
| + auto connectHandler = new ::testing::StrictMock<MockEventListener>(); |
| + auto disconnectHandler = new ::testing::StrictMock<MockEventListener>(); |
| + |
| + remotePlayback->addEventListener(EventTypeNames::connecting, |
| + connectingHandler); |
| + remotePlayback->addEventListener(EventTypeNames::connect, connectHandler); |
| + remotePlayback->addEventListener(EventTypeNames::disconnect, |
| + disconnectHandler); |
| + |
| + EXPECT_CALL(*connectingHandler, handleEvent(::testing::_, ::testing::_)) |
| + .Times(1); |
| + EXPECT_CALL(*connectHandler, handleEvent(::testing::_, ::testing::_)) |
| + .Times(1); |
| + EXPECT_CALL(*disconnectHandler, handleEvent(::testing::_, ::testing::_)) |
| + .Times(1); |
| + |
| + setState(remotePlayback, WebRemotePlaybackState::Connecting); |
| + setState(remotePlayback, WebRemotePlaybackState::Connected); |
| + setState(remotePlayback, WebRemotePlaybackState::Disconnected); |
|
mlamouri (slow - plz ping)
2016/10/13 14:37:45
Can you add double-calls? Like:
setState(remote
|
| +} |
| + |
| } // namespace blink |