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

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

Issue 1858533002: Introduce WebCachePolicy to merge cache policy enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hiroshige review Created 4 years, 8 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/WebURLRequest.h" 11 #include "public/platform/WebURLRequest.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "wtf/text/AtomicString.h" 13 #include "wtf/text/AtomicString.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 TEST(ResourceRequestTest, RequestorOriginNonNull) 17 TEST(ResourceRequestTest, RequestorOriginNonNull)
17 { 18 {
18 ResourceRequest req; 19 ResourceRequest req;
19 EXPECT_NE(nullptr, req.requestorOrigin().get()); 20 EXPECT_NE(nullptr, req.requestorOrigin().get());
20 EXPECT_TRUE(req.requestorOrigin()->isUnique()); 21 EXPECT_TRUE(req.requestorOrigin()->isUnique());
21 } 22 }
22 23
23 TEST(ResourceRequestTest, CrossThreadResourceRequestData) 24 TEST(ResourceRequestTest, CrossThreadResourceRequestData)
24 { 25 {
25 ResourceRequest original; 26 ResourceRequest original;
26 original.setURL(KURL(ParsedURLString, "http://www.example.com/test.htm")); 27 original.setURL(KURL(ParsedURLString, "http://www.example.com/test.htm"));
27 original.setCachePolicy(UseProtocolCachePolicy); 28 original.setCachePolicy(WebCachePolicy::UseProtocolCachePolicy);
28 original.setTimeoutInterval(10); 29 original.setTimeoutInterval(10);
29 original.setFirstPartyForCookies(KURL(ParsedURLString, "http://www.example.c om/first_party.htm")); 30 original.setFirstPartyForCookies(KURL(ParsedURLString, "http://www.example.c om/first_party.htm"));
30 original.setRequestorOrigin(SecurityOrigin::create(KURL(ParsedURLString, "ht tp://www.example.com/first_party.htm"))); 31 original.setRequestorOrigin(SecurityOrigin::create(KURL(ParsedURLString, "ht tp://www.example.com/first_party.htm")));
31 original.setHTTPMethod(HTTPNames::GET); 32 original.setHTTPMethod(HTTPNames::GET);
32 original.setHTTPHeaderField(AtomicString("Foo"), AtomicString("Bar")); 33 original.setHTTPHeaderField(AtomicString("Foo"), AtomicString("Bar"));
33 original.setHTTPHeaderField(AtomicString("Piyo"), AtomicString("Fuga")); 34 original.setHTTPHeaderField(AtomicString("Piyo"), AtomicString("Fuga"));
34 original.setPriority(ResourceLoadPriorityLow, 20); 35 original.setPriority(ResourceLoadPriorityLow, 20);
35 36
36 RefPtr<EncodedFormData> originalBody(EncodedFormData::create("Test Body")); 37 RefPtr<EncodedFormData> originalBody(EncodedFormData::create("Test Body"));
37 original.setHTTPBody(originalBody); 38 original.setHTTPBody(originalBody);
38 original.setAllowStoredCredentials(false); 39 original.setAllowStoredCredentials(false);
39 original.setReportUploadProgress(false); 40 original.setReportUploadProgress(false);
40 original.setHasUserGesture(false); 41 original.setHasUserGesture(false);
41 original.setDownloadToFile(false); 42 original.setDownloadToFile(false);
42 original.setSkipServiceWorker(false); 43 original.setSkipServiceWorker(false);
43 original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); 44 original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
44 original.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeSameOrig in); 45 original.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeSameOrig in);
45 original.setRequestorID(30); 46 original.setRequestorID(30);
46 original.setRequestorProcessID(40); 47 original.setRequestorProcessID(40);
47 original.setAppCacheHostID(50); 48 original.setAppCacheHostID(50);
48 original.setRequestContext(WebURLRequest::RequestContextAudio); 49 original.setRequestContext(WebURLRequest::RequestContextAudio);
49 original.setFrameType(WebURLRequest::FrameTypeNested); 50 original.setFrameType(WebURLRequest::FrameTypeNested);
50 original.setHTTPReferrer(Referrer("http://www.example.com/referrer.htm", Ref errerPolicyDefault)); 51 original.setHTTPReferrer(Referrer("http://www.example.com/referrer.htm", Ref errerPolicyDefault));
51 52
52 EXPECT_STREQ("http://www.example.com/test.htm", original.url().getString().u tf8().data()); 53 EXPECT_STREQ("http://www.example.com/test.htm", original.url().getString().u tf8().data());
53 EXPECT_EQ(UseProtocolCachePolicy, original.getCachePolicy()); 54 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, original.getCachePolicy()) ;
54 EXPECT_EQ(10, original.timeoutInterval()); 55 EXPECT_EQ(10, original.timeoutInterval());
55 EXPECT_STREQ("http://www.example.com/first_party.htm", original.firstPartyFo rCookies().getString().utf8().data()); 56 EXPECT_STREQ("http://www.example.com/first_party.htm", original.firstPartyFo rCookies().getString().utf8().data());
56 EXPECT_STREQ("www.example.com", original.requestorOrigin()->host().utf8().da ta()); 57 EXPECT_STREQ("www.example.com", original.requestorOrigin()->host().utf8().da ta());
57 EXPECT_STREQ("GET", original.httpMethod().utf8().data()); 58 EXPECT_STREQ("GET", original.httpMethod().utf8().data());
58 EXPECT_STREQ("Bar", original.httpHeaderFields().get("Foo").utf8().data()); 59 EXPECT_STREQ("Bar", original.httpHeaderFields().get("Foo").utf8().data());
59 EXPECT_STREQ("Fuga", original.httpHeaderFields().get("Piyo").utf8().data()); 60 EXPECT_STREQ("Fuga", original.httpHeaderFields().get("Piyo").utf8().data());
60 EXPECT_EQ(ResourceLoadPriorityLow, original.priority()); 61 EXPECT_EQ(ResourceLoadPriorityLow, original.priority());
61 EXPECT_STREQ("Test Body", original.httpBody()->flattenToString().utf8().data ()); 62 EXPECT_STREQ("Test Body", original.httpBody()->flattenToString().utf8().data ());
62 EXPECT_FALSE(original.allowStoredCredentials()); 63 EXPECT_FALSE(original.allowStoredCredentials());
63 EXPECT_FALSE(original.reportUploadProgress()); 64 EXPECT_FALSE(original.reportUploadProgress());
64 EXPECT_FALSE(original.hasUserGesture()); 65 EXPECT_FALSE(original.hasUserGesture());
65 EXPECT_FALSE(original.downloadToFile()); 66 EXPECT_FALSE(original.downloadToFile());
66 EXPECT_FALSE(original.skipServiceWorker()); 67 EXPECT_FALSE(original.skipServiceWorker());
67 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode()); 68 EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode());
68 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCrede ntialsMode()); 69 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCrede ntialsMode());
69 EXPECT_EQ(30, original.requestorID()); 70 EXPECT_EQ(30, original.requestorID());
70 EXPECT_EQ(40, original.requestorProcessID()); 71 EXPECT_EQ(40, original.requestorProcessID());
71 EXPECT_EQ(50, original.appCacheHostID()); 72 EXPECT_EQ(50, original.appCacheHostID());
72 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext()); 73 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext());
73 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType()); 74 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType());
74 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());
75 EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy()); 76 EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy());
76 77
77 OwnPtr<CrossThreadResourceRequestData> data1(original.copyData()); 78 OwnPtr<CrossThreadResourceRequestData> data1(original.copyData());
78 ResourceRequest copy1(data1.get()); 79 ResourceRequest copy1(data1.get());
79 80
80 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());
81 EXPECT_EQ(UseProtocolCachePolicy, copy1.getCachePolicy()); 82 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, copy1.getCachePolicy());
82 EXPECT_EQ(10, copy1.timeoutInterval()); 83 EXPECT_EQ(10, copy1.timeoutInterval());
83 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());
84 EXPECT_STREQ("www.example.com", copy1.requestorOrigin()->host().utf8().data( )); 85 EXPECT_STREQ("www.example.com", copy1.requestorOrigin()->host().utf8().data( ));
85 EXPECT_STREQ("GET", copy1.httpMethod().utf8().data()); 86 EXPECT_STREQ("GET", copy1.httpMethod().utf8().data());
86 EXPECT_STREQ("Bar", copy1.httpHeaderFields().get("Foo").utf8().data()); 87 EXPECT_STREQ("Bar", copy1.httpHeaderFields().get("Foo").utf8().data());
87 EXPECT_EQ(ResourceLoadPriorityLow, copy1.priority()); 88 EXPECT_EQ(ResourceLoadPriorityLow, copy1.priority());
88 EXPECT_STREQ("Test Body", copy1.httpBody()->flattenToString().utf8().data()) ; 89 EXPECT_STREQ("Test Body", copy1.httpBody()->flattenToString().utf8().data()) ;
89 EXPECT_FALSE(copy1.allowStoredCredentials()); 90 EXPECT_FALSE(copy1.allowStoredCredentials());
90 EXPECT_FALSE(copy1.reportUploadProgress()); 91 EXPECT_FALSE(copy1.reportUploadProgress());
91 EXPECT_FALSE(copy1.hasUserGesture()); 92 EXPECT_FALSE(copy1.hasUserGesture());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 { 125 {
125 ResourceRequest original; 126 ResourceRequest original;
126 EXPECT_FALSE(original.hasUserGesture()); 127 EXPECT_FALSE(original.hasUserGesture());
127 original.setHasUserGesture(true); 128 original.setHasUserGesture(true);
128 EXPECT_TRUE(original.hasUserGesture()); 129 EXPECT_TRUE(original.hasUserGesture());
129 original.setHasUserGesture(false); 130 original.setHasUserGesture(false);
130 EXPECT_TRUE(original.hasUserGesture()); 131 EXPECT_TRUE(original.hasUserGesture());
131 } 132 }
132 133
133 } // namespace blink 134 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/ResourceRequest.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698