Index: third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp |
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp |
index f4dee9b4960b9651ed939c1feb368285b8cc6506..7a537b997d1a04bf3de683d1cd6c2ec04d01dc1e 100644 |
--- a/third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp |
+++ b/third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp |
@@ -8,6 +8,7 @@ |
#include "bindings/core/v8/V8BindingForTesting.h" |
#include "core/frame/LocalFrame.h" |
#include "core/testing/DummyPageHolder.h" |
+#include "modules/presentation/PresentationConnection.h" |
#include "modules/presentation/PresentationConnectionList.h" |
#include "platform/testing/URLTestHelpers.h" |
#include "public/platform/modules/presentation/WebPresentationClient.h" |
@@ -85,6 +86,8 @@ class PresentationReceiverTest : public ::testing::Test { |
public: |
void addConnectionavailableEventListener( |
EventListener*, const PresentationReceiver*); |
+ void addOnMessageEventListener( |
+ EventListener*, const PresentationReceiver*); |
void verifyConnectionListPropertyState( |
ScriptPromisePropertyBase::State, const PresentationReceiver*); |
void verifyConnectionListSize( |
@@ -98,6 +101,14 @@ void PresentationReceiverTest::addConnectionavailableEventListener( |
receiver->m_connectionList->addEventListener(EventTypeNames::connectionavailable, eventHandler); |
} |
+void PresentationReceiverTest::addOnMessageEventListener( |
+ EventListener* eventHandler, |
+ const PresentationReceiver* receiver) |
+{ |
+ for (auto const& connection : receiver->m_connectionList->m_connections) |
+ connection->addEventListener(EventTypeNames::connect, eventHandler); |
+} |
+ |
void PresentationReceiverTest::verifyConnectionListPropertyState( |
ScriptPromisePropertyBase::State expectedState, |
const PresentationReceiver* receiver) |
@@ -200,4 +211,24 @@ TEST_F(PresentationReceiverTest, CreateReceiver) |
new PresentationReceiver(&scope.frame(), &client); |
} |
+TEST_F(PresentationReceiverTest, didReceiveSessionTextMessage) |
+{ |
+ V8TestingScope scope; |
+ auto receiver = new PresentationReceiver(&scope.frame(), nullptr); |
+ |
+ // Receive first connection. |
+ auto connectionClient1 = new TestWebPresentationConnectionClient(); |
+ receiver->onReceiverConnectionAvailable(connectionClient1); |
+ |
+ // verify onMessage event |
+ StrictMock<MockEventListener>* eventHandler = new StrictMock<MockEventListener>(); |
+ addOnMessageEventListener(eventHandler, receiver); |
+ EXPECT_CALL(*eventHandler, handleEvent(testing::_, testing::_)) |
+ .Times(1); |
+ |
+ // Receive second connection. |
+ auto connectionClient2 = new TestWebPresentationConnectionClient(); |
+ receiver->didReceiveSessionTextMessage(connectionClient2, "Hello World"); |
+} |
+ |
} // namespace blink |