OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "components/sessions/serialized_navigation_entry.h" | 5 #include "components/sessions/serialized_navigation_entry.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace sessions { | 27 namespace sessions { |
28 namespace { | 28 namespace { |
29 | 29 |
30 const int kIndex = 3; | 30 const int kIndex = 3; |
31 const int kUniqueID = 50; | 31 const int kUniqueID = 50; |
32 const content::Referrer kReferrer = | 32 const content::Referrer kReferrer = |
33 content::Referrer(GURL("http://www.referrer.com"), | 33 content::Referrer(GURL("http://www.referrer.com"), |
34 blink::WebReferrerPolicyAlways); | 34 blink::WebReferrerPolicyAlways); |
35 const GURL kVirtualURL("http://www.virtual-url.com"); | 35 const GURL kVirtualURL("http://www.virtual-url.com"); |
36 const string16 kTitle = ASCIIToUTF16("title"); | 36 const base::string16 kTitle = ASCIIToUTF16("title"); |
37 const content::PageState kPageState = | 37 const content::PageState kPageState = |
38 content::PageState::CreateFromEncodedData("page state"); | 38 content::PageState::CreateFromEncodedData("page state"); |
39 const content::PageTransition kTransitionType = | 39 const content::PageTransition kTransitionType = |
40 static_cast<content::PageTransition>( | 40 static_cast<content::PageTransition>( |
41 content::PAGE_TRANSITION_AUTO_SUBFRAME | | 41 content::PAGE_TRANSITION_AUTO_SUBFRAME | |
42 content::PAGE_TRANSITION_HOME_PAGE | | 42 content::PAGE_TRANSITION_HOME_PAGE | |
43 content::PAGE_TRANSITION_CLIENT_REDIRECT); | 43 content::PAGE_TRANSITION_CLIENT_REDIRECT); |
44 const bool kHasPostData = true; | 44 const bool kHasPostData = true; |
45 const int64 kPostID = 100; | 45 const int64 kPostID = 100; |
46 const GURL kOriginalRequestURL("http://www.original-request.com"); | 46 const GURL kOriginalRequestURL("http://www.original-request.com"); |
47 const bool kIsOverridingUserAgent = true; | 47 const bool kIsOverridingUserAgent = true; |
48 const base::Time kTimestamp = syncer::ProtoTimeToTime(100); | 48 const base::Time kTimestamp = syncer::ProtoTimeToTime(100); |
49 const string16 kSearchTerms = ASCIIToUTF16("my search terms"); | 49 const base::string16 kSearchTerms = ASCIIToUTF16("my search terms"); |
50 const GURL kFaviconURL("http://virtual-url.com/favicon.ico"); | 50 const GURL kFaviconURL("http://virtual-url.com/favicon.ico"); |
51 const int kHttpStatusCode = 404; | 51 const int kHttpStatusCode = 404; |
52 | 52 |
53 const int kPageID = 10; | 53 const int kPageID = 10; |
54 | 54 |
55 // Create a NavigationEntry from the constants above. | 55 // Create a NavigationEntry from the constants above. |
56 scoped_ptr<content::NavigationEntry> MakeNavigationEntryForTest() { | 56 scoped_ptr<content::NavigationEntry> MakeNavigationEntryForTest() { |
57 scoped_ptr<content::NavigationEntry> navigation_entry( | 57 scoped_ptr<content::NavigationEntry> navigation_entry( |
58 content::NavigationEntry::Create()); | 58 content::NavigationEntry::Create()); |
59 navigation_entry->SetReferrer(kReferrer); | 59 navigation_entry->SetReferrer(kReferrer); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 EXPECT_EQ(kPageState, new_navigation_entry->GetPageState()); | 223 EXPECT_EQ(kPageState, new_navigation_entry->GetPageState()); |
224 EXPECT_EQ(kPageID, new_navigation_entry->GetPageID()); | 224 EXPECT_EQ(kPageID, new_navigation_entry->GetPageID()); |
225 EXPECT_EQ(content::PAGE_TRANSITION_RELOAD, | 225 EXPECT_EQ(content::PAGE_TRANSITION_RELOAD, |
226 new_navigation_entry->GetTransitionType()); | 226 new_navigation_entry->GetTransitionType()); |
227 EXPECT_EQ(kHasPostData, new_navigation_entry->GetHasPostData()); | 227 EXPECT_EQ(kHasPostData, new_navigation_entry->GetHasPostData()); |
228 EXPECT_EQ(kPostID, new_navigation_entry->GetPostID()); | 228 EXPECT_EQ(kPostID, new_navigation_entry->GetPostID()); |
229 EXPECT_EQ(kOriginalRequestURL, | 229 EXPECT_EQ(kOriginalRequestURL, |
230 new_navigation_entry->GetOriginalRequestURL()); | 230 new_navigation_entry->GetOriginalRequestURL()); |
231 EXPECT_EQ(kIsOverridingUserAgent, | 231 EXPECT_EQ(kIsOverridingUserAgent, |
232 new_navigation_entry->GetIsOverridingUserAgent()); | 232 new_navigation_entry->GetIsOverridingUserAgent()); |
233 string16 search_terms; | 233 base::string16 search_terms; |
234 new_navigation_entry->GetExtraData(kSearchTermsKey, &search_terms); | 234 new_navigation_entry->GetExtraData(kSearchTermsKey, &search_terms); |
235 EXPECT_EQ(kSearchTerms, search_terms); | 235 EXPECT_EQ(kSearchTerms, search_terms); |
236 EXPECT_EQ(kHttpStatusCode, new_navigation_entry->GetHttpStatusCode()); | 236 EXPECT_EQ(kHttpStatusCode, new_navigation_entry->GetHttpStatusCode()); |
237 } | 237 } |
238 | 238 |
239 // Create a NavigationEntry, convert it to a SerializedNavigationEntry, then | 239 // Create a NavigationEntry, convert it to a SerializedNavigationEntry, then |
240 // create a sync protocol buffer from it. The protocol buffer should | 240 // create a sync protocol buffer from it. The protocol buffer should |
241 // have matching fields to the NavigationEntry (when applicable). | 241 // have matching fields to the NavigationEntry (when applicable). |
242 TEST(SerializedNavigationEntryTest, ToSyncData) { | 242 TEST(SerializedNavigationEntryTest, ToSyncData) { |
243 const scoped_ptr<content::NavigationEntry> navigation_entry( | 243 const scoped_ptr<content::NavigationEntry> navigation_entry( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 const content::PageTransition constructed_transition = | 290 const content::PageTransition constructed_transition = |
291 constructed_nav.transition_type(); | 291 constructed_nav.transition_type(); |
292 | 292 |
293 EXPECT_EQ(transition, constructed_transition); | 293 EXPECT_EQ(transition, constructed_transition); |
294 } | 294 } |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 } // namespace | 298 } // namespace |
299 } // namespace sessions | 299 } // namespace sessions |
OLD | NEW |