| 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/presentation/PresentationReceiver.h" | 5 #include "modules/presentation/PresentationReceiver.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 11 #include "modules/presentation/PresentationConnection.h" |
| 11 #include "modules/presentation/PresentationConnectionList.h" | 12 #include "modules/presentation/PresentationConnectionList.h" |
| 12 #include "platform/testing/URLTestHelpers.h" | 13 #include "platform/testing/URLTestHelpers.h" |
| 13 #include "public/platform/modules/presentation/WebPresentationClient.h" | 14 #include "public/platform/modules/presentation/WebPresentationClient.h" |
| 15 #include "public/platform/modules/presentation/WebPresentationConnectionProxy.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include <memory> | 18 #include <memory> |
| 17 #include <v8.h> | 19 #include <v8.h> |
| 18 | 20 |
| 19 namespace blink { | 21 namespace blink { |
| 20 | 22 |
| 21 class MockEventListener : public EventListener { | 23 class MockEventListener : public EventListener { |
| 22 public: | 24 public: |
| 23 MockEventListener() : EventListener(CPPEventListenerType) {} | 25 MockEventListener() : EventListener(CPPEventListenerType) {} |
| 24 | 26 |
| 25 bool operator==(const EventListener& other) const final { | 27 bool operator==(const EventListener& other) const final { |
| 26 return this == &other; | 28 return this == &other; |
| 27 } | 29 } |
| 28 | 30 |
| 29 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*)); | 31 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*)); |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 class MockWebPresentationClient : public WebPresentationClient { | 34 class MockWebPresentationClient : public WebPresentationClient { |
| 33 void startSession( | 35 void startSession( |
| 34 const WebVector<WebURL>& presentationUrls, | 36 const WebVector<WebURL>& presentationUrls, |
| 35 std::unique_ptr<WebPresentationConnectionCallback> callbacks) override { | 37 std::unique_ptr<WebPresentationConnectionCallbacks> callbacks) override { |
| 36 return startSession_(presentationUrls, callbacks); | 38 return startSession_(presentationUrls, callbacks); |
| 37 } | 39 } |
| 38 void joinSession( | 40 void joinSession( |
| 39 const WebVector<WebURL>& presentationUrls, | 41 const WebVector<WebURL>& presentationUrls, |
| 40 const WebString& presentationId, | 42 const WebString& presentationId, |
| 41 std::unique_ptr<WebPresentationConnectionCallback> callbacks) override { | 43 std::unique_ptr<WebPresentationConnectionCallbacks> callbacks) override { |
| 42 return joinSession_(presentationUrls, presentationId, callbacks); | 44 return joinSession_(presentationUrls, presentationId, callbacks); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void getAvailability(const WebVector<WebURL>& availabilityURLs, | 47 void getAvailability(const WebVector<WebURL>& availabilityURLs, |
| 46 std::unique_ptr<WebPresentationAvailabilityCallbacks> | 48 std::unique_ptr<WebPresentationAvailabilityCallbacks> |
| 47 callbacks) override { | 49 callbacks) override { |
| 48 return getAvailability_(availabilityURLs, callbacks); | 50 return getAvailability_(availabilityURLs, callbacks); |
| 49 } | 51 } |
| 50 | 52 |
| 51 public: | 53 public: |
| 52 MOCK_METHOD1(setController, void(WebPresentationController*)); | 54 MOCK_METHOD1(setController, void(WebPresentationController*)); |
| 53 | 55 |
| 54 MOCK_METHOD1(setReceiver, void(WebPresentationReceiver*)); | 56 MOCK_METHOD1(setReceiver, void(WebPresentationReceiver*)); |
| 55 | 57 |
| 56 MOCK_METHOD2(startSession_, | 58 MOCK_METHOD2(startSession_, |
| 57 void(const WebVector<WebURL>& presentationUrls, | 59 void(const WebVector<WebURL>& presentationUrls, |
| 58 std::unique_ptr<WebPresentationConnectionCallback>&)); | 60 std::unique_ptr<WebPresentationConnectionCallbacks>&)); |
| 59 | 61 |
| 60 MOCK_METHOD3(joinSession_, | 62 MOCK_METHOD3(joinSession_, |
| 61 void(const WebVector<WebURL>& presentationUrls, | 63 void(const WebVector<WebURL>& presentationUrls, |
| 62 const WebString& presentationId, | 64 const WebString& presentationId, |
| 63 std::unique_ptr<WebPresentationConnectionCallback>&)); | 65 std::unique_ptr<WebPresentationConnectionCallbacks>&)); |
| 64 | 66 |
| 65 MOCK_METHOD3(sendString, | 67 MOCK_METHOD4(sendString, |
| 66 void(const WebURL& presentationUrl, | 68 void(const WebURL& presentationUrl, |
| 67 const WebString& presentationId, | 69 const WebString& presentationId, |
| 68 const WebString& message)); | 70 const WebString& message, |
| 71 const WebPresentationConnectionProxy* proxy)); |
| 69 | 72 |
| 70 MOCK_METHOD4(sendArrayBuffer, | 73 MOCK_METHOD5(sendArrayBuffer, |
| 71 void(const WebURL& presentationUrl, | 74 void(const WebURL& presentationUrl, |
| 72 const WebString& presentationId, | 75 const WebString& presentationId, |
| 73 const uint8_t* data, | 76 const uint8_t* data, |
| 74 size_t length)); | 77 size_t length, |
| 78 const WebPresentationConnectionProxy* proxy)); |
| 75 | 79 |
| 76 MOCK_METHOD4(sendBlobData, | 80 MOCK_METHOD5(sendBlobData, |
| 77 void(const WebURL& presentationUrl, | 81 void(const WebURL& presentationUrl, |
| 78 const WebString& presentationId, | 82 const WebString& presentationId, |
| 79 const uint8_t* data, | 83 const uint8_t* data, |
| 80 size_t length)); | 84 size_t length, |
| 85 const WebPresentationConnectionProxy* proxy)); |
| 81 | 86 |
| 82 MOCK_METHOD2(closeSession, | 87 MOCK_METHOD2(closeSession, |
| 83 void(const WebURL& presentationUrl, | 88 void(const WebURL& presentationUrl, |
| 84 const WebString& presentationId)); | 89 const WebString& presentationId)); |
| 85 | 90 |
| 86 MOCK_METHOD2(terminateSession, | 91 MOCK_METHOD2(terminateSession, |
| 87 void(const WebURL& presentationUrl, | 92 void(const WebURL& presentationUrl, |
| 88 const WebString& presentationId)); | 93 const WebString& presentationId)); |
| 89 | 94 |
| 90 MOCK_METHOD2(getAvailability_, | 95 MOCK_METHOD2(getAvailability_, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 213 |
| 209 TEST_F(PresentationReceiverTest, CreateReceiver) { | 214 TEST_F(PresentationReceiverTest, CreateReceiver) { |
| 210 MockWebPresentationClient client; | 215 MockWebPresentationClient client; |
| 211 EXPECT_CALL(client, setReceiver(testing::_)); | 216 EXPECT_CALL(client, setReceiver(testing::_)); |
| 212 | 217 |
| 213 V8TestingScope scope; | 218 V8TestingScope scope; |
| 214 new PresentationReceiver(&scope.frame(), &client); | 219 new PresentationReceiver(&scope.frame(), &client); |
| 215 } | 220 } |
| 216 | 221 |
| 217 } // namespace blink | 222 } // namespace blink |
| OLD | NEW |