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

Side by Side Diff: webkit/tools/webcore_unit_tests/GKURL_unittest.cpp

Issue 165278: Roll WebKit to 47010 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « webkit/glue/devtools/js/devtools.html ('k') | webkit/webkit.gyp » ('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) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // UTF-8 94 // UTF-8
95 WebCore::KURL gurl(cases[i].url); 95 WebCore::KURL gurl(cases[i].url);
96 96
97 EXPECT_EQ(cases[i].protocol, gurl.protocol()); 97 EXPECT_EQ(cases[i].protocol, gurl.protocol());
98 EXPECT_EQ(cases[i].host, gurl.host()); 98 EXPECT_EQ(cases[i].host, gurl.host());
99 EXPECT_EQ(cases[i].port, gurl.port()); 99 EXPECT_EQ(cases[i].port, gurl.port());
100 EXPECT_EQ(cases[i].user, gurl.user()); 100 EXPECT_EQ(cases[i].user, gurl.user());
101 EXPECT_EQ(cases[i].pass, gurl.pass()); 101 EXPECT_EQ(cases[i].pass, gurl.pass());
102 EXPECT_EQ(cases[i].last_path_component, gurl.lastPathComponent()); 102 EXPECT_EQ(cases[i].last_path_component, gurl.lastPathComponent());
103 EXPECT_EQ(cases[i].query, gurl.query()); 103 EXPECT_EQ(cases[i].query, gurl.query());
104 EXPECT_EQ(cases[i].ref, gurl.ref()); 104 EXPECT_EQ(cases[i].ref, gurl.fragmentIdentifier());
105 EXPECT_EQ(cases[i].has_ref, gurl.hasRef()); 105 EXPECT_EQ(cases[i].has_ref, gurl.hasFragmentIdentifier());
106 106
107 // UTF-16 107 // UTF-16
108 string16 wstr(UTF8ToUTF16(cases[i].url)); 108 string16 wstr(UTF8ToUTF16(cases[i].url));
109 WebCore::String utf16( 109 WebCore::String utf16(
110 reinterpret_cast<const ::UChar*>(wstr.c_str()), 110 reinterpret_cast<const ::UChar*>(wstr.c_str()),
111 static_cast<int>(wstr.length())); 111 static_cast<int>(wstr.length()));
112 gurl = WebCore::KURL(utf16); 112 gurl = WebCore::KURL(utf16);
113 113
114 EXPECT_EQ(cases[i].protocol, gurl.protocol()); 114 EXPECT_EQ(cases[i].protocol, gurl.protocol());
115 EXPECT_EQ(cases[i].host, gurl.host()); 115 EXPECT_EQ(cases[i].host, gurl.host());
116 EXPECT_EQ(cases[i].port, gurl.port()); 116 EXPECT_EQ(cases[i].port, gurl.port());
117 EXPECT_EQ(cases[i].user, gurl.user()); 117 EXPECT_EQ(cases[i].user, gurl.user());
118 EXPECT_EQ(cases[i].pass, gurl.pass()); 118 EXPECT_EQ(cases[i].pass, gurl.pass());
119 EXPECT_EQ(cases[i].last_path_component, gurl.lastPathComponent()); 119 EXPECT_EQ(cases[i].last_path_component, gurl.lastPathComponent());
120 EXPECT_EQ(cases[i].query, gurl.query()); 120 EXPECT_EQ(cases[i].query, gurl.query());
121 EXPECT_EQ(cases[i].ref, gurl.ref()); 121 EXPECT_EQ(cases[i].ref, gurl.fragmentIdentifier());
122 EXPECT_EQ(cases[i].has_ref, gurl.hasRef()); 122 EXPECT_EQ(cases[i].has_ref, gurl.hasFragmentIdentifier());
123 } 123 }
124 } 124 }
125 125
126 // Test a few cases where we're different just to make sure we give reasonable 126 // Test a few cases where we're different just to make sure we give reasonable
127 // output. 127 // output.
128 TEST(GKURL, DifferentGetters) { 128 TEST(GKURL, DifferentGetters) {
129 ComponentCase cases[] = { 129 ComponentCase cases[] = {
130 // url protocol host port us er pass path last_path query ref 130 // url protocol host port us er pass path last_path query ref
131 131
132 // Old WebKit allows references and queries in what we call "path" URLs 132 // Old WebKit allows references and queries in what we call "path" URLs
(...skipping 17 matching lines...) Expand all
150 EXPECT_EQ(cases[i].protocol, gurl.protocol()); 150 EXPECT_EQ(cases[i].protocol, gurl.protocol());
151 EXPECT_EQ(cases[i].host, gurl.host()); 151 EXPECT_EQ(cases[i].host, gurl.host());
152 EXPECT_EQ(cases[i].port, gurl.port()); 152 EXPECT_EQ(cases[i].port, gurl.port());
153 EXPECT_EQ(cases[i].user, gurl.user()); 153 EXPECT_EQ(cases[i].user, gurl.user());
154 EXPECT_EQ(cases[i].pass, gurl.pass()); 154 EXPECT_EQ(cases[i].pass, gurl.pass());
155 EXPECT_EQ(cases[i].last_path, gurl.lastPathComponent()); 155 EXPECT_EQ(cases[i].last_path, gurl.lastPathComponent());
156 EXPECT_EQ(cases[i].query, gurl.query()); 156 EXPECT_EQ(cases[i].query, gurl.query());
157 // Want to compare UCS-16 refs (or to NULL). 157 // Want to compare UCS-16 refs (or to NULL).
158 if (cases[i].ref) { 158 if (cases[i].ref) {
159 EXPECT_EQ(webkit_glue::StdWStringToString(UTF8ToWide(cases[i].ref)), 159 EXPECT_EQ(webkit_glue::StdWStringToString(UTF8ToWide(cases[i].ref)),
160 gurl.ref()); 160 gurl.fragmentIdentifier());
161 } else { 161 } else {
162 EXPECT_TRUE(gurl.ref().isNull()); 162 EXPECT_TRUE(gurl.fragmentIdentifier().isNull());
163 } 163 }
164 } 164 }
165 } 165 }
166 166
167 // Ensures that both ASCII and UTF-8 canonical URLs are handled properly and we 167 // Ensures that both ASCII and UTF-8 canonical URLs are handled properly and we
168 // get the correct string object out. 168 // get the correct string object out.
169 TEST(GKURL, UTF8) { 169 TEST(GKURL, UTF8) {
170 const char ascii_url[] = "http://foo/bar#baz"; 170 const char ascii_url[] = "http://foo/bar#baz";
171 WebCore::KURL ascii_gurl(ascii_url); 171 WebCore::KURL ascii_gurl(ascii_url);
172 EXPECT_TRUE(ascii_gurl.string() == WebCore::String(ascii_url)); 172 EXPECT_TRUE(ascii_gurl.string() == WebCore::String(ascii_url));
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 gurl.setQuery(query); 439 gurl.setQuery(query);
440 EXPECT_STREQ("http://www.google.com/search?foo=bar", 440 EXPECT_STREQ("http://www.google.com/search?foo=bar",
441 gurl.string().utf8().data()); 441 gurl.string().utf8().data());
442 } 442 }
443 443
444 TEST(GKURL, Ref) { 444 TEST(GKURL, Ref) {
445 WebCore::KURL gurl("http://foo/bar#baz"); 445 WebCore::KURL gurl("http://foo/bar#baz");
446 446
447 // Basic ref setting. 447 // Basic ref setting.
448 WebCore::KURL cur("http://foo/bar"); 448 WebCore::KURL cur("http://foo/bar");
449 cur.setRef("asdf"); 449 cur.setFragmentIdentifier("asdf");
450 EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data()); 450 EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data());
451 cur = gurl; 451 cur = gurl;
452 cur.setRef("asdf"); 452 cur.setFragmentIdentifier("asdf");
453 EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data()); 453 EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data());
454 454
455 // Setting a ref to the empty string will set it to "#". 455 // Setting a ref to the empty string will set it to "#".
456 cur = WebCore::KURL("http://foo/bar"); 456 cur = WebCore::KURL("http://foo/bar");
457 cur.setRef(""); 457 cur.setFragmentIdentifier("");
458 EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data()); 458 EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data());
459 cur = gurl; 459 cur = gurl;
460 cur.setRef(""); 460 cur.setFragmentIdentifier("");
461 EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data()); 461 EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data());
462 462
463 // Setting the ref to the null string will clear it altogether. 463 // Setting the ref to the null string will clear it altogether.
464 cur = WebCore::KURL("http://foo/bar"); 464 cur = WebCore::KURL("http://foo/bar");
465 cur.setRef(WebCore::String()); 465 cur.setFragmentIdentifier(WebCore::String());
466 EXPECT_STREQ("http://foo/bar", cur.string().utf8().data()); 466 EXPECT_STREQ("http://foo/bar", cur.string().utf8().data());
467 cur = gurl; 467 cur = gurl;
468 cur.setRef(WebCore::String()); 468 cur.setFragmentIdentifier(WebCore::String());
469 EXPECT_STREQ("http://foo/bar", cur.string().utf8().data()); 469 EXPECT_STREQ("http://foo/bar", cur.string().utf8().data());
470 } 470 }
471 471
472 TEST(GKURL, Empty) { 472 TEST(GKURL, Empty) {
473 WebCore::KURL gurl; 473 WebCore::KURL gurl;
474 474
475 // First test that regular empty URLs are the same. 475 // First test that regular empty URLs are the same.
476 EXPECT_TRUE(gurl.isEmpty()); 476 EXPECT_TRUE(gurl.isEmpty());
477 EXPECT_FALSE(gurl.isValid()); 477 EXPECT_FALSE(gurl.isValid());
478 EXPECT_TRUE(gurl.isNull()); 478 EXPECT_TRUE(gurl.isNull());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 const char url[] = "http://www.google.com/"; 591 const char url[] = "http://www.google.com/";
592 WebCore::KURL src(url); 592 WebCore::KURL src(url);
593 EXPECT_TRUE(src.string() == url); // This really just initializes the cache. 593 EXPECT_TRUE(src.string() == url); // This really just initializes the cache.
594 WebCore::KURL dest = src.copy(); 594 WebCore::KURL dest = src.copy();
595 EXPECT_TRUE(dest.string() == url); // This really just initializes the cache. 595 EXPECT_TRUE(dest.string() == url); // This really just initializes the cache.
596 596
597 // The pointers should be different for both UTF-8 and UTF-16. 597 // The pointers should be different for both UTF-8 and UTF-16.
598 EXPECT_NE(dest.string().characters(), src.string().characters()); 598 EXPECT_NE(dest.string().characters(), src.string().characters());
599 EXPECT_NE(dest.utf8String().data(), src.utf8String().data()); 599 EXPECT_NE(dest.utf8String().data(), src.utf8String().data());
600 } 600 }
OLDNEW
« no previous file with comments | « webkit/glue/devtools/js/devtools.html ('k') | webkit/webkit.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698