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

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

Issue 73633002: Add more test cases for HttpUtil::PathForRequest() and SpecForRequest() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « no previous file | no next file » | 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/http/http_util.h" 9 #include "net/http/http_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 }, 605 },
606 { // The reference may itself contain # -- strip all of it. 606 { // The reference may itself contain # -- strip all of it.
607 "http://192.168.0.1?query=1#hash#10#11#13#14", 607 "http://192.168.0.1?query=1#hash#10#11#13#14",
608 "http://192.168.0.1/?query=1", 608 "http://192.168.0.1/?query=1",
609 "/?query=1" 609 "/?query=1"
610 }, 610 },
611 { // Strip username/password. 611 { // Strip username/password.
612 "http://user:pass@google.com", 612 "http://user:pass@google.com",
613 "http://google.com/", 613 "http://google.com/",
614 "/" 614 "/"
615 },
616 { // https scheme
617 "https://www.google.com:78/foobar?query=1#hash",
618 "https://www.google.com:78/foobar?query=1",
619 "/foobar?query=1"
620 },
621 { // WebSocket's ws scheme
622 "ws://www.google.com:78/foobar?query=1#hash",
623 "ws://www.google.com:78/foobar?query=1",
624 "/foobar?query=1"
625 },
626 { // WebSocket's wss scheme
627 "wss://www.google.com:78/foobar?query=1#hash",
628 "wss://www.google.com:78/foobar?query=1",
629 "/foobar?query=1"
615 } 630 }
616 }; 631 };
617 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 632 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
618 GURL url(GURL(tests[i].url)); 633 GURL url(GURL(tests[i].url));
619 std::string expected_spec(tests[i].expected_spec); 634 std::string expected_spec(tests[i].expected_spec);
620 std::string expected_path(tests[i].expected_path); 635 std::string expected_path(tests[i].expected_path);
621 636
622 EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url)); 637 EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url));
623 EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url)); 638 EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url));
624 } 639 }
625 } 640 }
626 641
642 // Test SpecForRequest() for "ftp" scheme.
643 TEST(HttpUtilTest, SpecForRequestForUrlWithFtpScheme) {
644 GURL ftp_url("ftp://user:pass@google.com/pub/chromium/");
645 EXPECT_EQ("ftp://google.com/pub/chromium/",
646 HttpUtil::SpecForRequest(ftp_url));
647 }
648
627 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) { 649 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) {
628 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"), 650 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"),
629 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de")); 651 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de"));
630 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2," 652 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2,"
631 "ja;q=0.2"), 653 "ja;q=0.2"),
632 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja")); 654 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja"));
633 } 655 }
634 656
635 // HttpResponseHeadersTest.GetMimeType also tests ParseContentType. 657 // HttpResponseHeadersTest.GetMimeType also tests ParseContentType.
636 TEST(HttpUtilTest, ParseContentType) { 658 TEST(HttpUtilTest, ParseContentType) {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { 1064 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) {
1043 std::string data = "name='value"; 1065 std::string data = "name='value";
1044 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); 1066 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';');
1045 EXPECT_TRUE(parser.valid()); 1067 EXPECT_TRUE(parser.valid());
1046 1068
1047 ASSERT_NO_FATAL_FAILURE( 1069 ASSERT_NO_FATAL_FAILURE(
1048 CheckNextNameValuePair(&parser, true, true, "name", "value")); 1070 CheckNextNameValuePair(&parser, true, true, "name", "value"));
1049 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( 1071 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair(
1050 &parser, false, true, std::string(), std::string())); 1072 &parser, false, true, std::string(), std::string()));
1051 } 1073 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698