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 "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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_EQ(GURL(), entry2_->GetOriginalRequestURL()); | 206 EXPECT_EQ(GURL(), entry2_->GetOriginalRequestURL()); |
207 entry2_->SetOriginalRequestURL(GURL("original_url")); | 207 entry2_->SetOriginalRequestURL(GURL("original_url")); |
208 EXPECT_EQ(GURL("original_url"), entry2_->GetOriginalRequestURL()); | 208 EXPECT_EQ(GURL("original_url"), entry2_->GetOriginalRequestURL()); |
209 | 209 |
210 // User agent override | 210 // User agent override |
211 EXPECT_FALSE(entry1_->GetIsOverridingUserAgent()); | 211 EXPECT_FALSE(entry1_->GetIsOverridingUserAgent()); |
212 EXPECT_FALSE(entry2_->GetIsOverridingUserAgent()); | 212 EXPECT_FALSE(entry2_->GetIsOverridingUserAgent()); |
213 entry2_->SetIsOverridingUserAgent(true); | 213 entry2_->SetIsOverridingUserAgent(true); |
214 EXPECT_TRUE(entry2_->GetIsOverridingUserAgent()); | 214 EXPECT_TRUE(entry2_->GetIsOverridingUserAgent()); |
215 | 215 |
216 // Browser initiated post data | 216 // Post data |
217 EXPECT_EQ(NULL, entry1_->GetBrowserInitiatedPostData()); | 217 EXPECT_FALSE(entry1_->GetPostData()); |
218 EXPECT_EQ(NULL, entry2_->GetBrowserInitiatedPostData()); | 218 EXPECT_FALSE(entry2_->GetPostData()); |
219 const int length = 11; | 219 const int length = 11; |
220 const unsigned char* raw_data = | 220 const char* raw_data = "post\n\n\0data"; |
221 reinterpret_cast<const unsigned char*>("post\n\n\0data"); | 221 scoped_refptr<ResourceRequestBody> post_data = |
222 std::vector<unsigned char> post_data_vector(raw_data, raw_data+length); | 222 ResourceRequestBody::CreateFromBytes(raw_data, length); |
223 scoped_refptr<base::RefCountedBytes> post_data = | 223 entry2_->SetPostData(post_data); |
224 base::RefCountedBytes::TakeVector(&post_data_vector); | 224 EXPECT_EQ(post_data, entry2_->GetPostData()); |
225 entry2_->SetBrowserInitiatedPostData(post_data.get()); | |
226 EXPECT_EQ(post_data->front(), | |
227 entry2_->GetBrowserInitiatedPostData()->front()); | |
228 } | 225 } |
229 | 226 |
230 // Test basic Clone behavior. | 227 // Test basic Clone behavior. |
231 TEST_F(NavigationEntryTest, NavigationEntryClone) { | 228 TEST_F(NavigationEntryTest, NavigationEntryClone) { |
232 // Set some additional values. | 229 // Set some additional values. |
233 entry2_->SetTransitionType(ui::PAGE_TRANSITION_RELOAD); | 230 entry2_->SetTransitionType(ui::PAGE_TRANSITION_RELOAD); |
234 entry2_->set_should_replace_entry(true); | 231 entry2_->set_should_replace_entry(true); |
235 | 232 |
236 std::unique_ptr<NavigationEntryImpl> clone(entry2_->Clone()); | 233 std::unique_ptr<NavigationEntryImpl> clone(entry2_->Clone()); |
237 | 234 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // Content in |output| is not modified if data is not present at the key. | 268 // Content in |output| is not modified if data is not present at the key. |
272 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); | 269 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); |
273 EXPECT_EQ(test_data, output); | 270 EXPECT_EQ(test_data, output); |
274 // Using an empty string shows that the data is not present in the map. | 271 // Using an empty string shows that the data is not present in the map. |
275 base::string16 output2; | 272 base::string16 output2; |
276 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); | 273 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); |
277 EXPECT_EQ(ASCIIToUTF16(""), output2); | 274 EXPECT_EQ(ASCIIToUTF16(""), output2); |
278 } | 275 } |
279 | 276 |
280 } // namespace content | 277 } // namespace content |
OLD | NEW |