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

Unified Diff: trunk/src/net/cookies/cookie_util_unittest.cc

Issue 385113003: Revert 282546 "Enforce SafetyMode for YouTube if prefs::kForceSa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/net/cookies/cookie_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/net/cookies/cookie_util_unittest.cc
===================================================================
--- trunk/src/net/cookies/cookie_util_unittest.cc (revision 282600)
+++ trunk/src/net/cookies/cookie_util_unittest.cc (working copy)
@@ -2,49 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <string>
-#include <utility>
-#include <vector>
-
#include "base/basictypes.h"
#include "net/cookies/cookie_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
-
-struct RequestCookieParsingTest {
- std::string str;
- std::vector<std::pair<std::string, std::string> > parsed;
-};
-
-net::cookie_util::ParsedRequestCookies MakeParsedRequestCookies(
- const std::vector<std::pair<std::string, std::string> >& data) {
- net::cookie_util::ParsedRequestCookies parsed;
- for (size_t i = 0; i < data.size(); i++) {
- parsed.push_back(std::make_pair(base::StringPiece(data[i].first),
- base::StringPiece(data[i].second)));
- }
- return parsed;
-}
-
-void CheckParse(
- const std::string& str,
- const std::vector<std::pair<std::string, std::string> >& parsed_expected) {
- net::cookie_util::ParsedRequestCookies parsed;
- net::cookie_util::ParseRequestCookieLine(str, &parsed);
- EXPECT_EQ(MakeParsedRequestCookies(parsed_expected), parsed);
-}
-
-void CheckSerialize(
- const std::vector<std::pair<std::string, std::string> >& parsed,
- const std::string& str_expected) {
- net::cookie_util::ParsedRequestCookies prc =
- MakeParsedRequestCookies(parsed);
- EXPECT_EQ(str_expected, net::cookie_util::SerializeRequestCookieLine(prc));
-}
-
-} // namespace
-
TEST(CookieUtilTest, TestDomainIsHostOnly) {
const struct {
const char* str;
@@ -148,49 +109,3 @@
EXPECT_EQ(tests[i].epoch, parsed_time.ToTimeT()) << tests[i].str;
}
}
-
-TEST(CookieUtilTest, TestRequestCookieParsing) {
- std::vector<RequestCookieParsingTest> tests;
-
- // Simple case.
- tests.push_back(RequestCookieParsingTest());
- tests.back().str = "key=value";
- tests.back().parsed.push_back(std::make_pair(std::string("key"),
- std::string("value")));
- // Multiple key/value pairs.
- tests.push_back(RequestCookieParsingTest());
- tests.back().str = "key1=value1; key2=value2";
- tests.back().parsed.push_back(std::make_pair(std::string("key1"),
- std::string("value1")));
- tests.back().parsed.push_back(std::make_pair(std::string("key2"),
- std::string("value2")));
- // Empty value.
- tests.push_back(RequestCookieParsingTest());
- tests.back().str = "key=; otherkey=1234";
- tests.back().parsed.push_back(std::make_pair(std::string("key"),
- std::string()));
- tests.back().parsed.push_back(std::make_pair(std::string("otherkey"),
- std::string("1234")));
- // Special characters (including equals signs) in value.
- tests.push_back(RequestCookieParsingTest());
- tests.back().str = "key=; a2=s=(./&t=:&u=a#$; a3=+~";
- tests.back().parsed.push_back(std::make_pair(std::string("key"),
- std::string()));
- tests.back().parsed.push_back(std::make_pair(std::string("a2"),
- std::string("s=(./&t=:&u=a#$")));
- tests.back().parsed.push_back(std::make_pair(std::string("a3"),
- std::string("+~")));
- // Quoted value.
- tests.push_back(RequestCookieParsingTest());
- tests.back().str = "key=\"abcdef\"; otherkey=1234";
- tests.back().parsed.push_back(std::make_pair(std::string("key"),
- std::string("\"abcdef\"")));
- tests.back().parsed.push_back(std::make_pair(std::string("otherkey"),
- std::string("1234")));
-
- for (size_t i = 0; i < tests.size(); i++) {
- SCOPED_TRACE(testing::Message() << "Test " << i);
- CheckParse(tests[i].str, tests[i].parsed);
- CheckSerialize(tests[i].parsed, tests[i].str);
- }
-}
« no previous file with comments | « trunk/src/net/cookies/cookie_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698