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

Unified Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp

Issue 2415443004: [Blink, RemotePlayback]Split onstatechange to separate events (Closed)
Patch Set: Added extra state changes Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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..9f83a7e288d5a716902d9ce1426f4b8f8821e1d0 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,37 @@ 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::Connecting);
+ setState(remotePlayback, WebRemotePlaybackState::Connected);
+ setState(remotePlayback, WebRemotePlaybackState::Connected);
+ setState(remotePlayback, WebRemotePlaybackState::Disconnected);
+ setState(remotePlayback, WebRemotePlaybackState::Disconnected);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698