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

Side by Side Diff: third_party/WebKit/Source/platform/network/ResourceRequestTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/network/ResourceRequest.h" 5 #include "platform/network/ResourceRequest.h"
6 6
7 #include "platform/network/EncodedFormData.h" 7 #include "platform/network/EncodedFormData.h"
8 #include "platform/weborigin/KURL.h" 8 #include "platform/weborigin/KURL.h"
9 #include "platform/weborigin/Referrer.h" 9 #include "platform/weborigin/Referrer.h"
10 #include "public/platform/WebCachePolicy.h" 10 #include "public/platform/WebCachePolicy.h"
11 #include "public/platform/WebURLRequest.h" 11 #include "public/platform/WebURLRequest.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "wtf/text/AtomicString.h" 13 #include "wtf/text/AtomicString.h"
14 #include <memory>
14 15
15 namespace blink { 16 namespace blink {
16 17
17 TEST(ResourceRequestTest, RequestorOriginNonNull) 18 TEST(ResourceRequestTest, RequestorOriginNonNull)
18 { 19 {
19 ResourceRequest req; 20 ResourceRequest req;
20 EXPECT_NE(nullptr, req.requestorOrigin().get()); 21 EXPECT_NE(nullptr, req.requestorOrigin().get());
21 EXPECT_TRUE(req.requestorOrigin()->isUnique()); 22 EXPECT_TRUE(req.requestorOrigin()->isUnique());
22 } 23 }
23 24
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode()); 69 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode());
69 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCrede ntialsMode()); 70 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCrede ntialsMode());
70 EXPECT_EQ(30, original.requestorID()); 71 EXPECT_EQ(30, original.requestorID());
71 EXPECT_EQ(40, original.requestorProcessID()); 72 EXPECT_EQ(40, original.requestorProcessID());
72 EXPECT_EQ(50, original.appCacheHostID()); 73 EXPECT_EQ(50, original.appCacheHostID());
73 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext()); 74 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext());
74 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType()); 75 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType());
75 EXPECT_STREQ("http://www.example.com/referrer.htm", original.httpReferrer(). utf8().data()); 76 EXPECT_STREQ("http://www.example.com/referrer.htm", original.httpReferrer(). utf8().data());
76 EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy()); 77 EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy());
77 78
78 OwnPtr<CrossThreadResourceRequestData> data1(original.copyData()); 79 std::unique_ptr<CrossThreadResourceRequestData> data1(original.copyData());
79 ResourceRequest copy1(data1.get()); 80 ResourceRequest copy1(data1.get());
80 81
81 EXPECT_STREQ("http://www.example.com/test.htm", copy1.url().getString().utf8 ().data()); 82 EXPECT_STREQ("http://www.example.com/test.htm", copy1.url().getString().utf8 ().data());
82 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, copy1.getCachePolicy()); 83 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, copy1.getCachePolicy());
83 EXPECT_EQ(10, copy1.timeoutInterval()); 84 EXPECT_EQ(10, copy1.timeoutInterval());
84 EXPECT_STREQ("http://www.example.com/first_party.htm", copy1.firstPartyForCo okies().getString().utf8().data()); 85 EXPECT_STREQ("http://www.example.com/first_party.htm", copy1.firstPartyForCo okies().getString().utf8().data());
85 EXPECT_STREQ("www.example.com", copy1.requestorOrigin()->host().utf8().data( )); 86 EXPECT_STREQ("www.example.com", copy1.requestorOrigin()->host().utf8().data( ));
86 EXPECT_STREQ("GET", copy1.httpMethod().utf8().data()); 87 EXPECT_STREQ("GET", copy1.httpMethod().utf8().data());
87 EXPECT_STREQ("Bar", copy1.httpHeaderFields().get("Foo").utf8().data()); 88 EXPECT_STREQ("Bar", copy1.httpHeaderFields().get("Foo").utf8().data());
88 EXPECT_EQ(ResourceLoadPriorityLow, copy1.priority()); 89 EXPECT_EQ(ResourceLoadPriorityLow, copy1.priority());
(...skipping 14 matching lines...) Expand all
103 EXPECT_EQ(ReferrerPolicyDefault, copy1.getReferrerPolicy()); 104 EXPECT_EQ(ReferrerPolicyDefault, copy1.getReferrerPolicy());
104 105
105 copy1.setAllowStoredCredentials(true); 106 copy1.setAllowStoredCredentials(true);
106 copy1.setReportUploadProgress(true); 107 copy1.setReportUploadProgress(true);
107 copy1.setHasUserGesture(true); 108 copy1.setHasUserGesture(true);
108 copy1.setDownloadToFile(true); 109 copy1.setDownloadToFile(true);
109 copy1.setSkipServiceWorker(true); 110 copy1.setSkipServiceWorker(true);
110 copy1.setFetchRequestMode(WebURLRequest::FetchRequestModeNoCORS); 111 copy1.setFetchRequestMode(WebURLRequest::FetchRequestModeNoCORS);
111 copy1.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude); 112 copy1.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude);
112 113
113 OwnPtr<CrossThreadResourceRequestData> data2(copy1.copyData()); 114 std::unique_ptr<CrossThreadResourceRequestData> data2(copy1.copyData());
114 ResourceRequest copy2(data2.get()); 115 ResourceRequest copy2(data2.get());
115 EXPECT_TRUE(copy2.allowStoredCredentials()); 116 EXPECT_TRUE(copy2.allowStoredCredentials());
116 EXPECT_TRUE(copy2.reportUploadProgress()); 117 EXPECT_TRUE(copy2.reportUploadProgress());
117 EXPECT_TRUE(copy2.hasUserGesture()); 118 EXPECT_TRUE(copy2.hasUserGesture());
118 EXPECT_TRUE(copy2.downloadToFile()); 119 EXPECT_TRUE(copy2.downloadToFile());
119 EXPECT_TRUE(copy2.skipServiceWorker()); 120 EXPECT_TRUE(copy2.skipServiceWorker());
120 EXPECT_EQ(WebURLRequest::FetchRequestModeNoCORS, copy1.fetchRequestMode()); 121 EXPECT_EQ(WebURLRequest::FetchRequestModeNoCORS, copy1.fetchRequestMode());
121 EXPECT_EQ(WebURLRequest::FetchCredentialsModeInclude, copy1.fetchCredentials Mode()); 122 EXPECT_EQ(WebURLRequest::FetchCredentialsModeInclude, copy1.fetchCredentials Mode());
122 } 123 }
123 124
124 TEST(ResourceRequestTest, SetHasUserGesture) 125 TEST(ResourceRequestTest, SetHasUserGesture)
125 { 126 {
126 ResourceRequest original; 127 ResourceRequest original;
127 EXPECT_FALSE(original.hasUserGesture()); 128 EXPECT_FALSE(original.hasUserGesture());
128 original.setHasUserGesture(true); 129 original.setHasUserGesture(true);
129 EXPECT_TRUE(original.hasUserGesture()); 130 EXPECT_TRUE(original.hasUserGesture());
130 original.setHasUserGesture(false); 131 original.setHasUserGesture(false);
131 EXPECT_TRUE(original.hasUserGesture()); 132 EXPECT_TRUE(original.hasUserGesture());
132 } 133 }
133 134
134 } // namespace blink 135 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698