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/core/fetch/MultipartImageResourceParserTest.cpp

Issue 2120233003: [OBSOLETE] Remove WebURLResponse::initialize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix formatting issues and one last compile error Created 4 years, 5 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 "core/fetch/MultipartImageResourceParser.h" 5 #include "core/fetch/MultipartImageResourceParser.h"
6 6
7 #include "platform/network/ResourceResponse.h" 7 #include "platform/network/ResourceResponse.h"
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 #include "public/platform/WebURL.h" 9 #include "public/platform/WebURL.h"
10 #include "public/platform/WebURLResponse.h" 10 #include "public/platform/WebURLResponse.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 { "Foo: bar\nBaz:\n\nAfter:\n", true, 15 }, 82 { "Foo: bar\nBaz:\n\nAfter:\n", true, 15 },
83 { "Foo: bar\nBaz:\n", false, 0}, 83 { "Foo: bar\nBaz:\n", false, 0},
84 { "Foo: bar\r\nBaz:\r\n\r\nAfter:\r\n", true, 18 }, 84 { "Foo: bar\r\nBaz:\r\n\r\nAfter:\r\n", true, 18 },
85 { "Foo: bar\r\nBaz:\r\n", false, 0 }, 85 { "Foo: bar\r\nBaz:\r\n", false, 0 },
86 { "Foo: bar\nBaz:\r\n\r\nAfter:\n\n", true, 17 }, 86 { "Foo: bar\nBaz:\r\n\r\nAfter:\n\n", true, 17 },
87 { "Foo: bar\r\nBaz:\n", false, 0 }, 87 { "Foo: bar\r\nBaz:\n", false, 0 },
88 { "\r\n", true, 2 }, 88 { "\r\n", true, 2 },
89 }; 89 };
90 for (size_t i = 0; i < WTF_ARRAY_LENGTH(tests); ++i) { 90 for (size_t i = 0; i < WTF_ARRAY_LENGTH(tests); ++i) {
91 WebURLResponse response; 91 WebURLResponse response;
92 response.initialize();
93 size_t end = 0; 92 size_t end = 0;
94 bool result = Platform::current()->parseMultipartHeadersFromBody(tests[i ].data, strlen(tests[i].data), &response, &end); 93 bool result = Platform::current()->parseMultipartHeadersFromBody(tests[i ].data, strlen(tests[i].data), &response, &end);
95 EXPECT_EQ(tests[i].result, result); 94 EXPECT_EQ(tests[i].result, result);
96 EXPECT_EQ(tests[i].end, end); 95 EXPECT_EQ(tests[i].end, end);
97 } 96 }
98 } 97 }
99 98
100 TEST(MultipartResponseTest, ParseMultipartHeaders) 99 TEST(MultipartResponseTest, ParseMultipartHeaders)
101 { 100 {
102 WebURLResponse webResponse; 101 WebURLResponse webResponse;
103 webResponse.initialize();
104 webResponse.addHTTPHeaderField(WebString::fromLatin1("foo"), WebString::from Latin1("bar")); 102 webResponse.addHTTPHeaderField(WebString::fromLatin1("foo"), WebString::from Latin1("bar"));
105 webResponse.addHTTPHeaderField(WebString::fromLatin1("range"), WebString::fr omLatin1("piyo")); 103 webResponse.addHTTPHeaderField(WebString::fromLatin1("range"), WebString::fr omLatin1("piyo"));
106 webResponse.addHTTPHeaderField(WebString::fromLatin1("content-length"), WebS tring::fromLatin1("999")); 104 webResponse.addHTTPHeaderField(WebString::fromLatin1("content-length"), WebS tring::fromLatin1("999"));
107 105
108 const char data[] = "content-type: image/png\ncontent-length: 10\n\n"; 106 const char data[] = "content-type: image/png\ncontent-length: 10\n\n";
109 size_t end = 0; 107 size_t end = 0;
110 bool result = Platform::current()->parseMultipartHeadersFromBody(data, strle n(data), &webResponse, &end); 108 bool result = Platform::current()->parseMultipartHeadersFromBody(data, strle n(data), &webResponse, &end);
111 const ResourceResponse& response = webResponse.toResourceResponse(); 109 const ResourceResponse& response = webResponse.toResourceResponse();
112 110
113 EXPECT_TRUE(result); 111 EXPECT_TRUE(result);
114 EXPECT_EQ(strlen(data), end); 112 EXPECT_EQ(strlen(data), end);
115 EXPECT_EQ("image/png", response.httpHeaderField("content-type")); 113 EXPECT_EQ("image/png", response.httpHeaderField("content-type"));
116 EXPECT_EQ("10", response.httpHeaderField("content-length")); 114 EXPECT_EQ("10", response.httpHeaderField("content-length"));
117 EXPECT_EQ("bar", response.httpHeaderField("foo")); 115 EXPECT_EQ("bar", response.httpHeaderField("foo"));
118 EXPECT_EQ(AtomicString(), response.httpHeaderField("range")); 116 EXPECT_EQ(AtomicString(), response.httpHeaderField("range"));
119 } 117 }
120 118
121 TEST(MultipartResponseTest, ParseMultipartHeadersContentCharset) 119 TEST(MultipartResponseTest, ParseMultipartHeadersContentCharset)
122 { 120 {
123 WebURLResponse webResponse; 121 WebURLResponse webResponse;
124 webResponse.initialize();
125 122
126 const char data[] = "content-type: text/html; charset=utf-8\n\n"; 123 const char data[] = "content-type: text/html; charset=utf-8\n\n";
127 size_t end = 0; 124 size_t end = 0;
128 bool result = Platform::current()->parseMultipartHeadersFromBody(data, strle n(data), &webResponse, &end); 125 bool result = Platform::current()->parseMultipartHeadersFromBody(data, strle n(data), &webResponse, &end);
129 const ResourceResponse& response = webResponse.toResourceResponse(); 126 const ResourceResponse& response = webResponse.toResourceResponse();
130 127
131 EXPECT_TRUE(result); 128 EXPECT_TRUE(result);
132 EXPECT_EQ(strlen(data), end); 129 EXPECT_EQ(strlen(data), end);
133 EXPECT_EQ("text/html; charset=utf-8", response.httpHeaderField("content-type ")); 130 EXPECT_EQ("text/html; charset=utf-8", response.httpHeaderField("content-type "));
134 EXPECT_EQ("utf-8", response.textEncodingName()); 131 EXPECT_EQ("utf-8", response.textEncodingName());
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 EXPECT_EQ("\r\ncontent-type: 1\r\n\r\n\r\n\r\n", toString(client->m_data[1]) ); 495 EXPECT_EQ("\r\ncontent-type: 1\r\n\r\n\r\n\r\n", toString(client->m_data[1]) );
499 EXPECT_EQ(String(), client->m_responses[2].httpHeaderField("content-type")); 496 EXPECT_EQ(String(), client->m_responses[2].httpHeaderField("content-type"));
500 EXPECT_EQ("content-type: 2\r\n\r\n\r\n\r\n", toString(client->m_data[2])); 497 EXPECT_EQ("content-type: 2\r\n\r\n\r\n\r\n", toString(client->m_data[2]));
501 EXPECT_EQ("3", client->m_responses[3].httpHeaderField("content-type")); 498 EXPECT_EQ("3", client->m_responses[3].httpHeaderField("content-type"));
502 EXPECT_EQ("", toString(client->m_data[3])); 499 EXPECT_EQ("", toString(client->m_data[3]));
503 } 500 }
504 501
505 } // namespace 502 } // namespace
506 503
507 } // namespace blink 504 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698