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

Side by Side Diff: chrome/common/net/url_util_unittest.cc

Issue 10384086: Moved url_utils from chrome/browser/net to chrome/common/net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « chrome/common/net/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 (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 "chrome/browser/net/browser_url_util.h" 5 #include "chrome/common/net/url_util.h"
6 6
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace chrome_browser_net { 10 namespace chrome_common_net {
11 11
12 TEST(BrowserUrlUtilTest, AppendQueryParameter) { 12 TEST(UrlUtilTest, AppendQueryParameter) {
13 // Appending a name-value pair to a URL without a query component. 13 // Appending a name-value pair to a URL without a query component.
14 EXPECT_EQ("http://example.com/path?name=value", 14 EXPECT_EQ("http://example.com/path?name=value",
15 AppendQueryParameter(GURL("http://example.com/path"), 15 AppendQueryParameter(GURL("http://example.com/path"),
16 "name", "value").spec()); 16 "name", "value").spec());
17 17
18 // Appending a name-value pair to a URL with a query component. 18 // Appending a name-value pair to a URL with a query component.
19 // The original component should be preserved, and the new pair should be 19 // The original component should be preserved, and the new pair should be
20 // appended with '&'. 20 // appended with '&'.
21 EXPECT_EQ("http://example.com/path?existing=one&name=value", 21 EXPECT_EQ("http://example.com/path?existing=one&name=value",
22 AppendQueryParameter(GURL("http://example.com/path?existing=one"), 22 AppendQueryParameter(GURL("http://example.com/path?existing=one"),
23 "name", "value").spec()); 23 "name", "value").spec());
24 24
25 // Appending a name-value pair with unsafe characters included. The 25 // Appending a name-value pair with unsafe characters included. The
26 // unsafe characters should be escaped. 26 // unsafe characters should be escaped.
27 EXPECT_EQ("http://example.com/path?existing=one&na+me=v.alue%3D", 27 EXPECT_EQ("http://example.com/path?existing=one&na+me=v.alue%3D",
28 AppendQueryParameter(GURL("http://example.com/path?existing=one"), 28 AppendQueryParameter(GURL("http://example.com/path?existing=one"),
29 "na me", "v.alue=").spec()); 29 "na me", "v.alue=").spec());
30 30
31 } 31 }
32 32
33 TEST(BrowserUrlUtilTest, AppendOrReplaceQueryParameter) { 33 TEST(UrlUtilTest, AppendOrReplaceQueryParameter) {
34 // Appending a name-value pair to a URL without a query component. 34 // Appending a name-value pair to a URL without a query component.
35 EXPECT_EQ("http://example.com/path?name=value", 35 EXPECT_EQ("http://example.com/path?name=value",
36 AppendOrReplaceQueryParameter(GURL("http://example.com/path"), 36 AppendOrReplaceQueryParameter(GURL("http://example.com/path"),
37 "name", "value").spec()); 37 "name", "value").spec());
38 38
39 // Appending a name-value pair to a URL with a query component. 39 // Appending a name-value pair to a URL with a query component.
40 // The original component should be preserved, and the new pair should be 40 // The original component should be preserved, and the new pair should be
41 // appended with '&'. 41 // appended with '&'.
42 EXPECT_EQ("http://example.com/path?existing=one&name=value", 42 EXPECT_EQ("http://example.com/path?existing=one&name=value",
43 AppendOrReplaceQueryParameter( 43 AppendOrReplaceQueryParameter(
(...skipping 29 matching lines...) Expand all
73 // Preserve the content of the original params regarless of our failure to 73 // Preserve the content of the original params regarless of our failure to
74 // interpret them correctly. 74 // interpret them correctly.
75 EXPECT_EQ("http://example.com/path?bar&name=new&left=&" 75 EXPECT_EQ("http://example.com/path?bar&name=new&left=&"
76 "=right&=&&name=again", 76 "=right&=&&name=again",
77 AppendOrReplaceQueryParameter( 77 AppendOrReplaceQueryParameter(
78 GURL("http://example.com/path?bar&name=old&left=&" 78 GURL("http://example.com/path?bar&name=old&left=&"
79 "=right&=&&name=again"), 79 "=right&=&&name=again"),
80 "name", "new").spec()); 80 "name", "new").spec());
81 } 81 }
82 82
83 } // namespace chrome_browser_net. 83 } // namespace chrome_common_net.
OLDNEW
« no previous file with comments | « chrome/common/net/url_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698