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