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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationReceiverTest.cpp

Issue 2471263003: [Presentation API] (4th)(1-UA blink side) Add WebPresentationConnection and WebPresentationConnecti… (Closed)
Patch Set: PresentationConnectionProxy::Send() will be invoked from PresentationDispatcher Created 4 years 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 unified diff | Download patch
OLDNEW
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"
14 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h " 15 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h "
16 #include "public/platform/modules/presentation/WebPresentationConnectionProxy.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
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
(...skipping 12 matching lines...) Expand all
37 39
38 MOCK_METHOD2(startSession, 40 MOCK_METHOD2(startSession,
39 void(const WebVector<WebURL>& presentationUrls, 41 void(const WebVector<WebURL>& presentationUrls,
40 WebPresentationConnectionClientCallbacks*)); 42 WebPresentationConnectionClientCallbacks*));
41 43
42 MOCK_METHOD3(joinSession, 44 MOCK_METHOD3(joinSession,
43 void(const WebVector<WebURL>& presentationUrls, 45 void(const WebVector<WebURL>& presentationUrls,
44 const WebString& presentationId, 46 const WebString& presentationId,
45 WebPresentationConnectionClientCallbacks*)); 47 WebPresentationConnectionClientCallbacks*));
46 48
47 MOCK_METHOD3(sendString, 49 MOCK_METHOD4(sendString,
48 void(const WebURL& presentationUrl, 50 void(const WebURL& presentationUrl,
49 const WebString& presentationId, 51 const WebString& presentationId,
50 const WebString& message)); 52 const WebString& message,
53 const WebPresentationConnectionProxy* proxy));
51 54
52 MOCK_METHOD4(sendArrayBuffer, 55 MOCK_METHOD5(sendArrayBuffer,
53 void(const WebURL& presentationUrl, 56 void(const WebURL& presentationUrl,
54 const WebString& presentationId, 57 const WebString& presentationId,
55 const uint8_t* data, 58 const uint8_t* data,
56 size_t length)); 59 size_t length,
60 const WebPresentationConnectionProxy* proxy));
57 61
58 MOCK_METHOD4(sendBlobData, 62 MOCK_METHOD5(sendBlobData,
59 void(const WebURL& presentationUrl, 63 void(const WebURL& presentationUrl,
60 const WebString& presentationId, 64 const WebString& presentationId,
61 const uint8_t* data, 65 const uint8_t* data,
62 size_t length)); 66 size_t length,
67 const WebPresentationConnectionProxy* proxy));
63 68
64 MOCK_METHOD2(closeSession, 69 MOCK_METHOD2(closeSession,
65 void(const WebURL& presentationUrl, 70 void(const WebURL& presentationUrl,
66 const WebString& presentationId)); 71 const WebString& presentationId));
67 72
68 MOCK_METHOD2(terminateSession, 73 MOCK_METHOD2(terminateSession,
69 void(const WebURL& presentationUrl, 74 void(const WebURL& presentationUrl,
70 const WebString& presentationId)); 75 const WebString& presentationId));
71 76
72 MOCK_METHOD2(getAvailability, 77 MOCK_METHOD2(getAvailability,
73 void(const WebURL& availabilityUrl, 78 void(const WebURL& availabilityUrl,
74 WebPresentationAvailabilityCallbacks*)); 79 WebPresentationAvailabilityCallbacks*));
75 80
76 MOCK_METHOD1(startListening, void(WebPresentationAvailabilityObserver*)); 81 MOCK_METHOD1(startListening, void(WebPresentationAvailabilityObserver*));
77 82
78 MOCK_METHOD1(stopListening, void(WebPresentationAvailabilityObserver*)); 83 MOCK_METHOD1(stopListening, void(WebPresentationAvailabilityObserver*));
79 84
80 MOCK_METHOD1(setDefaultPresentationUrls, void(const WebVector<WebURL>&)); 85 MOCK_METHOD1(setDefaultPresentationUrls, void(const WebVector<WebURL>&));
81 }; 86 };
82 87
88 class MockWebPresentationConnectionProxy
89 : public WebPresentationConnectionProxy {
90 public:
91 MOCK_METHOD1(SetSourceConnection, void(blink::WebPresentationConnection*));
92 MOCK_METHOD1(SendString, void(const blink::WebString& message));
93 MOCK_METHOD2(SendArrayBuffer, void(const uint8_t* data, size_t length));
94 };
95
83 class TestWebPresentationConnectionClient 96 class TestWebPresentationConnectionClient
84 : public WebPresentationConnectionClient { 97 : public WebPresentationConnectionClient {
85 public: 98 public:
86 WebString getId() override { return WebString::fromUTF8("id"); } 99 WebString getId() override { return WebString::fromUTF8("id"); }
87 WebURL getUrl() override { 100 WebURL getUrl() override {
88 return URLTestHelpers::toKURL("http://www.example.com"); 101 return URLTestHelpers::toKURL("http://www.example.com");
89 } 102 }
103 std::unique_ptr<WebPresentationConnectionProxy> takeProxy() override {
104 return std::unique_ptr<WebPresentationConnectionProxy>(
105 new MockWebPresentationConnectionProxy());
haraken 2016/11/24 04:49:55 Use wrapUnique.
zhaobin 2016/12/05 20:28:16 Done.
106 }
90 }; 107 };
91 108
92 class PresentationReceiverTest : public ::testing::Test { 109 class PresentationReceiverTest : public ::testing::Test {
93 public: 110 public:
94 void addConnectionavailableEventListener(EventListener*, 111 void addConnectionavailableEventListener(EventListener*,
95 const PresentationReceiver*); 112 const PresentationReceiver*);
96 void verifyConnectionListPropertyState(ScriptPromisePropertyBase::State, 113 void verifyConnectionListPropertyState(ScriptPromisePropertyBase::State,
97 const PresentationReceiver*); 114 const PresentationReceiver*);
98 void verifyConnectionListSize(size_t expectedSize, 115 void verifyConnectionListSize(size_t expectedSize,
99 const PresentationReceiver*); 116 const PresentationReceiver*);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 217
201 TEST_F(PresentationReceiverTest, CreateReceiver) { 218 TEST_F(PresentationReceiverTest, CreateReceiver) {
202 MockWebPresentationClient client; 219 MockWebPresentationClient client;
203 EXPECT_CALL(client, setReceiver(testing::_)); 220 EXPECT_CALL(client, setReceiver(testing::_));
204 221
205 V8TestingScope scope; 222 V8TestingScope scope;
206 new PresentationReceiver(&scope.frame(), &client); 223 new PresentationReceiver(&scope.frame(), &client);
207 } 224 }
208 225
209 } // namespace blink 226 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698