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

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

Issue 2327993002: [PresentationAPI] Use KURL and WebURL in place of string types. (Closed)
Patch Set: Address imcheng@ comments Created 4 years, 3 months 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/PresentationConnectionList.h" 11 #include "modules/presentation/PresentationConnectionList.h"
12 #include "platform/testing/URLTestHelpers.h"
12 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h " 13 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h "
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include <v8.h> 16 #include <v8.h>
16 17
17 namespace blink { 18 namespace blink {
18 19
19 class MockEventListener : public EventListener { 20 class MockEventListener : public EventListener {
20 public: 21 public:
21 MockEventListener() 22 MockEventListener()
22 : EventListener(CPPEventListenerType) 23 : EventListener(CPPEventListenerType)
23 { 24 {
24 } 25 }
25 26
26 bool operator==(const EventListener& other) const final 27 bool operator==(const EventListener& other) const final
27 { 28 {
28 return this == &other; 29 return this == &other;
29 } 30 }
30 31
31 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*)); 32 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event*));
32 }; 33 };
33 34
34 class TestWebPresentationConnectionClient : public WebPresentationConnectionClie nt { 35 class TestWebPresentationConnectionClient : public WebPresentationConnectionClie nt {
35 public: 36 public:
36 WebString getId() override { return WebString::fromUTF8("id"); } 37 WebString getId() override { return WebString::fromUTF8("id"); }
37 WebString getUrl() override { return WebString::fromUTF8("url"); } 38 WebURL getUrl() override { return URLTestHelpers::toKURL("http://www.example .com"); }
38 }; 39 };
39 40
40 class PresentationReceiverTest : public ::testing::Test { 41 class PresentationReceiverTest : public ::testing::Test {
41 public: 42 public:
42 void addConnectionavailableEventListener( 43 void addConnectionavailableEventListener(
43 EventListener*, const PresentationReceiver*); 44 EventListener*, const PresentationReceiver*);
44 void verifyConnectionListPropertyState( 45 void verifyConnectionListPropertyState(
45 ScriptPromisePropertyBase::State, const PresentationReceiver*); 46 ScriptPromisePropertyBase::State, const PresentationReceiver*);
46 void verifyConnectionListSize( 47 void verifyConnectionListSize(
47 size_t expectedSize, const PresentationReceiver*); 48 size_t expectedSize, const PresentationReceiver*);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Receive second connection. 142 // Receive second connection.
142 auto connectionClient2 = new TestWebPresentationConnectionClient(); 143 auto connectionClient2 = new TestWebPresentationConnectionClient();
143 receiver->onConnectionReceived(connectionClient2); 144 receiver->onConnectionReceived(connectionClient2);
144 145
145 receiver->connectionList(scope.getScriptState()); 146 receiver->connectionList(scope.getScriptState());
146 verifyConnectionListPropertyState(ScriptPromisePropertyBase::Resolved, recei ver); 147 verifyConnectionListPropertyState(ScriptPromisePropertyBase::Resolved, recei ver);
147 verifyConnectionListSize(2, receiver); 148 verifyConnectionListSize(2, receiver);
148 } 149 }
149 150
150 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698