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

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

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: merge with master Created 4 years, 1 month 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void(const WebURL& availabilityUrl, 75 void(const WebURL& availabilityUrl,
74 WebPresentationAvailabilityCallbacks*)); 76 WebPresentationAvailabilityCallbacks*));
75 77
76 MOCK_METHOD1(startListening, void(WebPresentationAvailabilityObserver*)); 78 MOCK_METHOD1(startListening, void(WebPresentationAvailabilityObserver*));
77 79
78 MOCK_METHOD1(stopListening, void(WebPresentationAvailabilityObserver*)); 80 MOCK_METHOD1(stopListening, void(WebPresentationAvailabilityObserver*));
79 81
80 MOCK_METHOD1(setDefaultPresentationUrls, void(const WebVector<WebURL>&)); 82 MOCK_METHOD1(setDefaultPresentationUrls, void(const WebVector<WebURL>&));
81 }; 83 };
82 84
85 class MockWebPresentationConnectionProxy
86 : public WebPresentationConnectionProxy {
87 public:
88 MOCK_METHOD1(SetSourceConnection, void(blink::WebPresentationConnection*));
89
90 MOCK_METHOD1(SendString, void(const blink::WebString& message));
91
92 MOCK_METHOD2(SendArrayBuffer, void(const uint8_t* data, size_t length));
93 };
94
83 class TestWebPresentationConnectionClient 95 class TestWebPresentationConnectionClient
84 : public WebPresentationConnectionClient { 96 : public WebPresentationConnectionClient {
85 public: 97 public:
86 WebString getId() override { return WebString::fromUTF8("id"); } 98 WebString getId() override { return WebString::fromUTF8("id"); }
87 WebURL getUrl() override { 99 WebURL getUrl() override {
88 return URLTestHelpers::toKURL("http://www.example.com"); 100 return URLTestHelpers::toKURL("http://www.example.com");
89 } 101 }
102 std::unique_ptr<WebPresentationConnectionProxy> takeProxy() override {
103 return std::unique_ptr<WebPresentationConnectionProxy>(
104 new MockWebPresentationConnectionProxy());
105 }
90 }; 106 };
91 107
92 class PresentationReceiverTest : public ::testing::Test { 108 class PresentationReceiverTest : public ::testing::Test {
93 public: 109 public:
94 void addConnectionavailableEventListener(EventListener*, 110 void addConnectionavailableEventListener(EventListener*,
95 const PresentationReceiver*); 111 const PresentationReceiver*);
96 void verifyConnectionListPropertyState(ScriptPromisePropertyBase::State, 112 void verifyConnectionListPropertyState(ScriptPromisePropertyBase::State,
97 const PresentationReceiver*); 113 const PresentationReceiver*);
98 void verifyConnectionListSize(size_t expectedSize, 114 void verifyConnectionListSize(size_t expectedSize,
99 const PresentationReceiver*); 115 const PresentationReceiver*);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 216
201 TEST_F(PresentationReceiverTest, CreateReceiver) { 217 TEST_F(PresentationReceiverTest, CreateReceiver) {
202 MockWebPresentationClient client; 218 MockWebPresentationClient client;
203 EXPECT_CALL(client, setReceiver(testing::_)); 219 EXPECT_CALL(client, setReceiver(testing::_));
204 220
205 V8TestingScope scope; 221 V8TestingScope scope;
206 new PresentationReceiver(&scope.frame(), &client); 222 new PresentationReceiver(&scope.frame(), &client);
207 } 223 }
208 224
209 } // namespace blink 225 } // 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