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

Side by Side Diff: net/http/http_content_disposition_unittest.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_content_disposition.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/http/http_content_disposition.h" 5 #include "net/http/http_content_disposition.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // attfnboth2 191 // attfnboth2
192 {"attachment; filename*=UTF-8''foo-%c3%a4.html; " 192 {"attachment; filename*=UTF-8''foo-%c3%a4.html; "
193 "filename=\"foo-ae.html\"", "", L"foo-\xe4.html"}, 193 "filename=\"foo-ae.html\"", "", L"foo-\xe4.html"},
194 // attnewandfn 194 // attnewandfn
195 {"attachment; foobar=x; filename=\"foo.html\"", "", 195 {"attachment; foobar=x; filename=\"foo.html\"", "",
196 L"foo.html"}, 196 L"foo.html"},
197 }; 197 };
198 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 198 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
199 HttpContentDisposition header(tests[i].header, tests[i].referrer_charset); 199 HttpContentDisposition header(tests[i].header, tests[i].referrer_charset);
200 EXPECT_EQ(tests[i].expected, 200 EXPECT_EQ(tests[i].expected,
201 UTF8ToWide(header.filename())) 201 base::UTF8ToWide(header.filename()))
202 << "Failed on input: " << tests[i].header; 202 << "Failed on input: " << tests[i].header;
203 } 203 }
204 } 204 }
205 205
206 // Test cases from http://greenbytes.de/tech/tc2231/ 206 // Test cases from http://greenbytes.de/tech/tc2231/
207 TEST(HttpContentDispositionTest, tc2231) { 207 TEST(HttpContentDispositionTest, tc2231) {
208 const struct FileNameCDCase { 208 const struct FileNameCDCase {
209 const char* header; 209 const char* header;
210 net::HttpContentDisposition::Type expected_type; 210 net::HttpContentDisposition::Type expected_type;
211 const wchar_t* expected_filename; 211 const wchar_t* expected_filename;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 }, 500 },
501 // TODO(abarth): Add the filename* tests, but check 501 // TODO(abarth): Add the filename* tests, but check
502 // HttpContentDispositionTest.Filename for overlap. 502 // HttpContentDispositionTest.Filename for overlap.
503 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047token 503 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047token
504 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047quoted 504 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047quoted
505 }; 505 };
506 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 506 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
507 HttpContentDisposition header(tests[i].header, std::string()); 507 HttpContentDisposition header(tests[i].header, std::string());
508 EXPECT_EQ(tests[i].expected_type, header.type()) 508 EXPECT_EQ(tests[i].expected_type, header.type())
509 << "Failed on input: " << tests[i].header; 509 << "Failed on input: " << tests[i].header;
510 EXPECT_EQ(tests[i].expected_filename, UTF8ToWide(header.filename())) 510 EXPECT_EQ(tests[i].expected_filename, base::UTF8ToWide(header.filename()))
511 << "Failed on input: " << tests[i].header; 511 << "Failed on input: " << tests[i].header;
512 } 512 }
513 } 513 }
514 514
515 TEST(HttpContentDispositionTest, ParseResult) { 515 TEST(HttpContentDispositionTest, ParseResult) {
516 const struct ParseResultTestCase { 516 const struct ParseResultTestCase {
517 const char* header; 517 const char* header;
518 int expected_flags; 518 int expected_flags;
519 } kTestCases[] = { 519 } kTestCases[] = {
520 // Basic feature tests 520 // Basic feature tests
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 HttpContentDisposition content_disposition(test_case.header, "utf-8"); 581 HttpContentDisposition content_disposition(test_case.header, "utf-8");
582 int result = content_disposition.parse_result_flags(); 582 int result = content_disposition.parse_result_flags();
583 583
584 SCOPED_TRACE(testing::Message() << "Test case " << i 584 SCOPED_TRACE(testing::Message() << "Test case " << i
585 << " with header " << test_case.header); 585 << " with header " << test_case.header);
586 EXPECT_EQ(test_case.expected_flags, result); 586 EXPECT_EQ(test_case.expected_flags, result);
587 } 587 }
588 } 588 }
589 589
590 } // namespace net 590 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_content_disposition.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698