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

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

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

Powered by Google App Engine
This is Rietveld 408576698