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

Side by Side Diff: net/base/url_util_unittest.cc

Issue 24261010: Allow explicitly whitelisted apps/extensions in public sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix handing of guest user ID. Created 7 years, 2 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/base/url_util.cc ('k') | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/url_util.h" 5 #include "net/base/url_util.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 TEST(UrlUtilTest, GetValueForKeyInQueryInvalidURL) { 103 TEST(UrlUtilTest, GetValueForKeyInQueryInvalidURL) {
104 GURL url("http://%01/?test"); 104 GURL url("http://%01/?test");
105 std::string value; 105 std::string value;
106 106
107 // Always false when parsing an invalid URL. 107 // Always false when parsing an invalid URL.
108 EXPECT_FALSE(GetValueForKeyInQuery(url, "test", &value)); 108 EXPECT_FALSE(GetValueForKeyInQuery(url, "test", &value));
109 } 109 }
110 110
111 TEST(UrlUtilTest, ParseQuery) {
112 const GURL url("http://example.com/path?name=value&boolParam&"
113 "url=http://test.com/q?n1%3Dv1%26n2&"
114 "multikey=value1&multikey=value2&multikey");
115 QueryIterator it(url);
116
117 ASSERT_FALSE(it.IsAtEnd());
118 EXPECT_EQ("name", it.GetKey());
119 EXPECT_EQ("value", it.GetValue());
120 EXPECT_EQ("value", it.GetUnescapedValue());
121 it.Advance();
122
123 ASSERT_FALSE(it.IsAtEnd());
124 EXPECT_EQ("boolParam", it.GetKey());
125 EXPECT_EQ("", it.GetValue());
126 EXPECT_EQ("", it.GetUnescapedValue());
127 it.Advance();
128
129 ASSERT_FALSE(it.IsAtEnd());
130 EXPECT_EQ("url", it.GetKey());
131 EXPECT_EQ("http://test.com/q?n1%3Dv1%26n2", it.GetValue());
132 EXPECT_EQ("http://test.com/q?n1=v1&n2", it.GetUnescapedValue());
133 it.Advance();
134
135 ASSERT_FALSE(it.IsAtEnd());
136 EXPECT_EQ("multikey", it.GetKey());
137 EXPECT_EQ("value1", it.GetValue());
138 EXPECT_EQ("value1", it.GetUnescapedValue());
139 it.Advance();
140
141 ASSERT_FALSE(it.IsAtEnd());
142 EXPECT_EQ("multikey", it.GetKey());
143 EXPECT_EQ("value2", it.GetValue());
144 EXPECT_EQ("value2", it.GetUnescapedValue());
145 it.Advance();
146
147 ASSERT_FALSE(it.IsAtEnd());
148 EXPECT_EQ("multikey", it.GetKey());
149 EXPECT_EQ("", it.GetValue());
150 EXPECT_EQ("", it.GetUnescapedValue());
151 it.Advance();
152
153 EXPECT_TRUE(it.IsAtEnd());
154 }
155
156 TEST(UrlUtilTest, ParseQueryInvalidURL) {
157 const GURL url("http://%01/?test");
158 QueryIterator it(url);
159 EXPECT_TRUE(it.IsAtEnd());
160 }
161
111 } // namespace 162 } // namespace
112 } // namespace net 163 } // namespace net
OLDNEW
« no previous file with comments | « net/base/url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698