| 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 13 matching lines...) Expand all Loading... |
| 24 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 24 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 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 WebKit::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 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; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return sync_data; | 92 return sync_data; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Create a default SerializedNavigationEntry. All its fields should be | 95 // Create a default SerializedNavigationEntry. All its fields should be |
| 96 // initialized to their respective default values. | 96 // initialized to their respective default values. |
| 97 TEST(SerializedNavigationEntryTest, DefaultInitializer) { | 97 TEST(SerializedNavigationEntryTest, DefaultInitializer) { |
| 98 const SerializedNavigationEntry navigation; | 98 const SerializedNavigationEntry navigation; |
| 99 EXPECT_EQ(-1, navigation.index()); | 99 EXPECT_EQ(-1, navigation.index()); |
| 100 EXPECT_EQ(0, navigation.unique_id()); | 100 EXPECT_EQ(0, navigation.unique_id()); |
| 101 EXPECT_EQ(GURL(), navigation.referrer().url); | 101 EXPECT_EQ(GURL(), navigation.referrer().url); |
| 102 EXPECT_EQ(WebKit::WebReferrerPolicyDefault, navigation.referrer().policy); | 102 EXPECT_EQ(blink::WebReferrerPolicyDefault, navigation.referrer().policy); |
| 103 EXPECT_EQ(GURL(), navigation.virtual_url()); | 103 EXPECT_EQ(GURL(), navigation.virtual_url()); |
| 104 EXPECT_TRUE(navigation.title().empty()); | 104 EXPECT_TRUE(navigation.title().empty()); |
| 105 EXPECT_FALSE(navigation.page_state().IsValid()); | 105 EXPECT_FALSE(navigation.page_state().IsValid()); |
| 106 EXPECT_EQ(content::PAGE_TRANSITION_TYPED, navigation.transition_type()); | 106 EXPECT_EQ(content::PAGE_TRANSITION_TYPED, navigation.transition_type()); |
| 107 EXPECT_FALSE(navigation.has_post_data()); | 107 EXPECT_FALSE(navigation.has_post_data()); |
| 108 EXPECT_EQ(-1, navigation.post_id()); | 108 EXPECT_EQ(-1, navigation.post_id()); |
| 109 EXPECT_EQ(GURL(), navigation.original_request_url()); | 109 EXPECT_EQ(GURL(), navigation.original_request_url()); |
| 110 EXPECT_FALSE(navigation.is_overriding_user_agent()); | 110 EXPECT_FALSE(navigation.is_overriding_user_agent()); |
| 111 EXPECT_TRUE(navigation.timestamp().is_null()); | 111 EXPECT_TRUE(navigation.timestamp().is_null()); |
| 112 EXPECT_TRUE(navigation.search_terms().empty()); | 112 EXPECT_TRUE(navigation.search_terms().empty()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // sbould be set to the default value otherwise. | 146 // sbould be set to the default value otherwise. |
| 147 TEST(SerializedNavigationEntryTest, FromSyncData) { | 147 TEST(SerializedNavigationEntryTest, FromSyncData) { |
| 148 const sync_pb::TabNavigation sync_data = MakeSyncDataForTest(); | 148 const sync_pb::TabNavigation sync_data = MakeSyncDataForTest(); |
| 149 | 149 |
| 150 const SerializedNavigationEntry& navigation = | 150 const SerializedNavigationEntry& navigation = |
| 151 SerializedNavigationEntry::FromSyncData(kIndex, sync_data); | 151 SerializedNavigationEntry::FromSyncData(kIndex, sync_data); |
| 152 | 152 |
| 153 EXPECT_EQ(kIndex, navigation.index()); | 153 EXPECT_EQ(kIndex, navigation.index()); |
| 154 EXPECT_EQ(kUniqueID, navigation.unique_id()); | 154 EXPECT_EQ(kUniqueID, navigation.unique_id()); |
| 155 EXPECT_EQ(kReferrer.url, navigation.referrer().url); | 155 EXPECT_EQ(kReferrer.url, navigation.referrer().url); |
| 156 EXPECT_EQ(WebKit::WebReferrerPolicyDefault, navigation.referrer().policy); | 156 EXPECT_EQ(blink::WebReferrerPolicyDefault, navigation.referrer().policy); |
| 157 EXPECT_EQ(kVirtualURL, navigation.virtual_url()); | 157 EXPECT_EQ(kVirtualURL, navigation.virtual_url()); |
| 158 EXPECT_EQ(kTitle, navigation.title()); | 158 EXPECT_EQ(kTitle, navigation.title()); |
| 159 EXPECT_EQ(kPageState, navigation.page_state()); | 159 EXPECT_EQ(kPageState, navigation.page_state()); |
| 160 EXPECT_EQ(kTransitionType, navigation.transition_type()); | 160 EXPECT_EQ(kTransitionType, navigation.transition_type()); |
| 161 EXPECT_FALSE(navigation.has_post_data()); | 161 EXPECT_FALSE(navigation.has_post_data()); |
| 162 EXPECT_EQ(-1, navigation.post_id()); | 162 EXPECT_EQ(-1, navigation.post_id()); |
| 163 EXPECT_EQ(GURL(), navigation.original_request_url()); | 163 EXPECT_EQ(GURL(), navigation.original_request_url()); |
| 164 EXPECT_FALSE(navigation.is_overriding_user_agent()); | 164 EXPECT_FALSE(navigation.is_overriding_user_agent()); |
| 165 EXPECT_TRUE(navigation.timestamp().is_null()); | 165 EXPECT_TRUE(navigation.timestamp().is_null()); |
| 166 EXPECT_EQ(kSearchTerms, navigation.search_terms()); | 166 EXPECT_EQ(kSearchTerms, navigation.search_terms()); |
| (...skipping 123 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 |