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

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

Issue 994803004: Add Clone and disallow copy construction for NavigationEntryImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 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 "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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 base::RefCountedBytes::TakeVector(&post_data_vector); 206 base::RefCountedBytes::TakeVector(&post_data_vector);
207 entry2_->SetBrowserInitiatedPostData(post_data.get()); 207 entry2_->SetBrowserInitiatedPostData(post_data.get());
208 EXPECT_EQ(post_data->front(), 208 EXPECT_EQ(post_data->front(),
209 entry2_->GetBrowserInitiatedPostData()->front()); 209 entry2_->GetBrowserInitiatedPostData()->front());
210 210
211 // Frame to navigate. 211 // Frame to navigate.
212 EXPECT_TRUE(entry1_->GetFrameToNavigate().empty()); 212 EXPECT_TRUE(entry1_->GetFrameToNavigate().empty());
213 EXPECT_TRUE(entry2_->GetFrameToNavigate().empty()); 213 EXPECT_TRUE(entry2_->GetFrameToNavigate().empty());
214 } 214 }
215 215
216 // Test basic Clone behavior.
217 TEST_F(NavigationEntryTest, NavigationEntryClone) {
218 // Set some additional values.
219 entry2_->SetTransitionType(ui::PAGE_TRANSITION_RELOAD);
220 entry2_->set_should_replace_entry(true);
221
222 NavigationEntryImpl* clone = entry2_->Clone();
223
224 // Value from FrameNavigationEntry.
225 EXPECT_EQ(entry2_->site_instance(), clone->site_instance());
226
227 // Value from constructor.
228 EXPECT_EQ(entry2_->GetTitle(), clone->GetTitle());
229
230 // Value set after constructor.
231 EXPECT_EQ(entry2_->GetTransitionType(), clone->GetTransitionType());
232
233 // Value not copied due to ResetForCommit.
234 EXPECT_NE(entry2_->should_replace_entry(), clone->should_replace_entry());
235 }
236
216 // Test timestamps. 237 // Test timestamps.
217 TEST_F(NavigationEntryTest, NavigationEntryTimestamps) { 238 TEST_F(NavigationEntryTest, NavigationEntryTimestamps) {
218 EXPECT_EQ(base::Time(), entry1_->GetTimestamp()); 239 EXPECT_EQ(base::Time(), entry1_->GetTimestamp());
219 const base::Time now = base::Time::Now(); 240 const base::Time now = base::Time::Now();
220 entry1_->SetTimestamp(now); 241 entry1_->SetTimestamp(now);
221 EXPECT_EQ(now, entry1_->GetTimestamp()); 242 EXPECT_EQ(now, entry1_->GetTimestamp());
222 } 243 }
223 244
224 // Test extra data stored in the navigation entry. 245 // Test extra data stored in the navigation entry.
225 TEST_F(NavigationEntryTest, NavigationEntryExtraData) { 246 TEST_F(NavigationEntryTest, NavigationEntryExtraData) {
(...skipping 10 matching lines...) Expand all
236 // Content in |output| is not modified if data is not present at the key. 257 // Content in |output| is not modified if data is not present at the key.
237 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); 258 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output));
238 EXPECT_EQ(test_data, output); 259 EXPECT_EQ(test_data, output);
239 // Using an empty string shows that the data is not present in the map. 260 // Using an empty string shows that the data is not present in the map.
240 base::string16 output2; 261 base::string16 output2;
241 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); 262 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2));
242 EXPECT_EQ(ASCIIToUTF16(""), output2); 263 EXPECT_EQ(ASCIIToUTF16(""), output2);
243 } 264 }
244 265
245 } // namespace content 266 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698