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

Side by Side Diff: content/browser/frame_host/navigation_entry_impl_unittest.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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
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 "base/strings/string16.h" 5 #include "base/strings/string16.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/browser/frame_host/navigation_entry_impl.h" 10 #include "content/browser/frame_host/navigation_entry_impl.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 // Test URL accessors 56 // Test URL accessors
57 TEST_F(NavigationEntryTest, NavigationEntryURLs) { 57 TEST_F(NavigationEntryTest, NavigationEntryURLs) {
58 // Start with no virtual_url (even if a url is set) 58 // Start with no virtual_url (even if a url is set)
59 EXPECT_FALSE(entry1_->has_virtual_url()); 59 EXPECT_FALSE(entry1_->has_virtual_url());
60 EXPECT_FALSE(entry2_->has_virtual_url()); 60 EXPECT_FALSE(entry2_->has_virtual_url());
61 61
62 EXPECT_EQ(GURL(), entry1_->GetURL()); 62 EXPECT_EQ(GURL(), entry1_->GetURL());
63 EXPECT_EQ(GURL(), entry1_->GetVirtualURL()); 63 EXPECT_EQ(GURL(), entry1_->GetVirtualURL());
64 EXPECT_TRUE(entry1_->GetTitleForDisplay(std::string()).empty()); 64 EXPECT_TRUE(entry1_->GetTitleForDisplay().empty());
65 65
66 // Setting URL affects virtual_url and GetTitleForDisplay 66 // Setting URL affects virtual_url and GetTitleForDisplay
67 entry1_->SetURL(GURL("http://www.google.com")); 67 entry1_->SetURL(GURL("http://www.google.com"));
68 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetURL()); 68 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetURL());
69 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetVirtualURL()); 69 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetVirtualURL());
70 EXPECT_EQ(ASCIIToUTF16("www.google.com"), 70 EXPECT_EQ(ASCIIToUTF16("www.google.com"),
71 entry1_->GetTitleForDisplay(std::string())); 71 entry1_->GetTitleForDisplay());
72 72
73 // file:/// URLs should only show the filename. 73 // file:/// URLs should only show the filename.
74 entry1_->SetURL(GURL("file:///foo/bar baz.txt")); 74 entry1_->SetURL(GURL("file:///foo/bar baz.txt"));
75 EXPECT_EQ(ASCIIToUTF16("bar baz.txt"), 75 EXPECT_EQ(ASCIIToUTF16("bar baz.txt"), entry1_->GetTitleForDisplay());
76 entry1_->GetTitleForDisplay(std::string()));
77 76
78 // For file:/// URLs, make sure that slashes after the filename are ignored. 77 // For file:/// URLs, make sure that slashes after the filename are ignored.
79 // Regression test for https://crbug.com/503003. 78 // Regression test for https://crbug.com/503003.
80 entry1_->SetURL(GURL("file:///foo/bar baz.txt#foo/bar")); 79 entry1_->SetURL(GURL("file:///foo/bar baz.txt#foo/bar"));
81 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#foo/bar"), 80 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#foo/bar"), entry1_->GetTitleForDisplay());
82 entry1_->GetTitleForDisplay(std::string()));
83 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar")); 81 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar"));
84 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar"), 82 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar"),
85 entry1_->GetTitleForDisplay(std::string())); 83 entry1_->GetTitleForDisplay());
86 entry1_->SetURL(GURL("file:///foo/bar baz.txt#baz/boo?x=foo/bar")); 84 entry1_->SetURL(GURL("file:///foo/bar baz.txt#baz/boo?x=foo/bar"));
87 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#baz/boo?x=foo/bar"), 85 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#baz/boo?x=foo/bar"),
88 entry1_->GetTitleForDisplay(std::string())); 86 entry1_->GetTitleForDisplay());
89 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar#baz/boo")); 87 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar#baz/boo"));
90 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar#baz/boo"), 88 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar#baz/boo"),
91 entry1_->GetTitleForDisplay(std::string())); 89 entry1_->GetTitleForDisplay());
92 entry1_->SetURL(GURL("file:///foo/bar baz.txt#foo/bar#baz/boo")); 90 entry1_->SetURL(GURL("file:///foo/bar baz.txt#foo/bar#baz/boo"));
93 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#foo/bar#baz/boo"), 91 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#foo/bar#baz/boo"),
94 entry1_->GetTitleForDisplay(std::string())); 92 entry1_->GetTitleForDisplay());
95 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar?y=baz/boo")); 93 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar?y=baz/boo"));
96 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar?y=baz/boo"), 94 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar?y=baz/boo"),
97 entry1_->GetTitleForDisplay(std::string())); 95 entry1_->GetTitleForDisplay());
98 96
99 // Title affects GetTitleForDisplay 97 // Title affects GetTitleForDisplay
100 entry1_->SetTitle(ASCIIToUTF16("Google")); 98 entry1_->SetTitle(ASCIIToUTF16("Google"));
101 EXPECT_EQ(ASCIIToUTF16("Google"), entry1_->GetTitleForDisplay(std::string())); 99 EXPECT_EQ(ASCIIToUTF16("Google"), entry1_->GetTitleForDisplay());
102 100
103 // Setting virtual_url doesn't affect URL 101 // Setting virtual_url doesn't affect URL
104 entry2_->SetVirtualURL(GURL("display:url")); 102 entry2_->SetVirtualURL(GURL("display:url"));
105 EXPECT_TRUE(entry2_->has_virtual_url()); 103 EXPECT_TRUE(entry2_->has_virtual_url());
106 EXPECT_EQ(GURL("test:url"), entry2_->GetURL()); 104 EXPECT_EQ(GURL("test:url"), entry2_->GetURL());
107 EXPECT_EQ(GURL("display:url"), entry2_->GetVirtualURL()); 105 EXPECT_EQ(GURL("display:url"), entry2_->GetVirtualURL());
108 106
109 // Having a title set in constructor overrides virtual URL 107 // Having a title set in constructor overrides virtual URL
110 EXPECT_EQ(ASCIIToUTF16("title"), entry2_->GetTitleForDisplay(std::string())); 108 EXPECT_EQ(ASCIIToUTF16("title"), entry2_->GetTitleForDisplay());
111 109
112 // User typed URL is independent of the others 110 // User typed URL is independent of the others
113 EXPECT_EQ(GURL(), entry1_->GetUserTypedURL()); 111 EXPECT_EQ(GURL(), entry1_->GetUserTypedURL());
114 EXPECT_EQ(GURL(), entry2_->GetUserTypedURL()); 112 EXPECT_EQ(GURL(), entry2_->GetUserTypedURL());
115 entry2_->set_user_typed_url(GURL("typedurl")); 113 entry2_->set_user_typed_url(GURL("typedurl"));
116 EXPECT_EQ(GURL("typedurl"), entry2_->GetUserTypedURL()); 114 EXPECT_EQ(GURL("typedurl"), entry2_->GetUserTypedURL());
117 } 115 }
118 116
119 // Test Favicon inner class construction. 117 // Test Favicon inner class construction.
120 TEST_F(NavigationEntryTest, NavigationEntryFavicons) { 118 TEST_F(NavigationEntryTest, NavigationEntryFavicons) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Content in |output| is not modified if data is not present at the key. 271 // Content in |output| is not modified if data is not present at the key.
274 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); 272 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output));
275 EXPECT_EQ(test_data, output); 273 EXPECT_EQ(test_data, output);
276 // Using an empty string shows that the data is not present in the map. 274 // Using an empty string shows that the data is not present in the map.
277 base::string16 output2; 275 base::string16 output2;
278 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); 276 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2));
279 EXPECT_EQ(ASCIIToUTF16(""), output2); 277 EXPECT_EQ(ASCIIToUTF16(""), output2);
280 } 278 }
281 279
282 } // namespace content 280 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_entry_impl.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698