OLD | NEW |
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 "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_EQ(PAGE_TYPE_INTERSTITIAL, entry2_->GetPageType()); | 129 EXPECT_EQ(PAGE_TYPE_INTERSTITIAL, entry2_->GetPageType()); |
130 | 130 |
131 // Referrer | 131 // Referrer |
132 EXPECT_EQ(GURL(), entry1_->GetReferrer().url); | 132 EXPECT_EQ(GURL(), entry1_->GetReferrer().url); |
133 EXPECT_EQ(GURL("from"), entry2_->GetReferrer().url); | 133 EXPECT_EQ(GURL("from"), entry2_->GetReferrer().url); |
134 entry2_->SetReferrer( | 134 entry2_->SetReferrer( |
135 Referrer(GURL("from2"), blink::WebReferrerPolicyDefault)); | 135 Referrer(GURL("from2"), blink::WebReferrerPolicyDefault)); |
136 EXPECT_EQ(GURL("from2"), entry2_->GetReferrer().url); | 136 EXPECT_EQ(GURL("from2"), entry2_->GetReferrer().url); |
137 | 137 |
138 // Title | 138 // Title |
139 EXPECT_EQ(string16(), entry1_->GetTitle()); | 139 EXPECT_EQ(base::string16(), entry1_->GetTitle()); |
140 EXPECT_EQ(ASCIIToUTF16("title"), entry2_->GetTitle()); | 140 EXPECT_EQ(ASCIIToUTF16("title"), entry2_->GetTitle()); |
141 entry2_->SetTitle(ASCIIToUTF16("title2")); | 141 entry2_->SetTitle(ASCIIToUTF16("title2")); |
142 EXPECT_EQ(ASCIIToUTF16("title2"), entry2_->GetTitle()); | 142 EXPECT_EQ(ASCIIToUTF16("title2"), entry2_->GetTitle()); |
143 | 143 |
144 // State | 144 // State |
145 EXPECT_FALSE(entry1_->GetPageState().IsValid()); | 145 EXPECT_FALSE(entry1_->GetPageState().IsValid()); |
146 EXPECT_FALSE(entry2_->GetPageState().IsValid()); | 146 EXPECT_FALSE(entry2_->GetPageState().IsValid()); |
147 entry2_->SetPageState(PageState::CreateFromEncodedData("state")); | 147 entry2_->SetPageState(PageState::CreateFromEncodedData("state")); |
148 EXPECT_EQ("state", entry2_->GetPageState().ToEncodedData()); | 148 EXPECT_EQ("state", entry2_->GetPageState().ToEncodedData()); |
149 | 149 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // Test timestamps. | 212 // Test timestamps. |
213 TEST_F(NavigationEntryTest, NavigationEntryTimestamps) { | 213 TEST_F(NavigationEntryTest, NavigationEntryTimestamps) { |
214 EXPECT_EQ(base::Time(), entry1_->GetTimestamp()); | 214 EXPECT_EQ(base::Time(), entry1_->GetTimestamp()); |
215 const base::Time now = base::Time::Now(); | 215 const base::Time now = base::Time::Now(); |
216 entry1_->SetTimestamp(now); | 216 entry1_->SetTimestamp(now); |
217 EXPECT_EQ(now, entry1_->GetTimestamp()); | 217 EXPECT_EQ(now, entry1_->GetTimestamp()); |
218 } | 218 } |
219 | 219 |
220 // Test extra data stored in the navigation entry. | 220 // Test extra data stored in the navigation entry. |
221 TEST_F(NavigationEntryTest, NavigationEntryExtraData) { | 221 TEST_F(NavigationEntryTest, NavigationEntryExtraData) { |
222 string16 test_data = ASCIIToUTF16("my search terms"); | 222 base::string16 test_data = ASCIIToUTF16("my search terms"); |
223 string16 output; | 223 base::string16 output; |
224 entry1_->SetExtraData("search_terms", test_data); | 224 entry1_->SetExtraData("search_terms", test_data); |
225 | 225 |
226 EXPECT_FALSE(entry1_->GetExtraData("non_existent_key", &output)); | 226 EXPECT_FALSE(entry1_->GetExtraData("non_existent_key", &output)); |
227 EXPECT_EQ(ASCIIToUTF16(""), output); | 227 EXPECT_EQ(ASCIIToUTF16(""), output); |
228 EXPECT_TRUE(entry1_->GetExtraData("search_terms", &output)); | 228 EXPECT_TRUE(entry1_->GetExtraData("search_terms", &output)); |
229 EXPECT_EQ(test_data, output); | 229 EXPECT_EQ(test_data, output); |
230 // Data is cleared. | 230 // Data is cleared. |
231 entry1_->ClearExtraData("search_terms"); | 231 entry1_->ClearExtraData("search_terms"); |
232 // Content in |output| is not modified if data is not present at the key. | 232 // Content in |output| is not modified if data is not present at the key. |
233 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); | 233 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); |
234 EXPECT_EQ(test_data, output); | 234 EXPECT_EQ(test_data, output); |
235 // Using an empty string shows that the data is not present in the map. | 235 // Using an empty string shows that the data is not present in the map. |
236 string16 output2; | 236 base::string16 output2; |
237 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); | 237 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); |
238 EXPECT_EQ(ASCIIToUTF16(""), output2); | 238 EXPECT_EQ(ASCIIToUTF16(""), output2); |
239 } | 239 } |
240 | 240 |
241 } // namespace content | 241 } // namespace content |
OLD | NEW |