| 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_test_helper.h" | 5 #include "components/sessions/serialized_navigation_entry_test_helper.h" |
| 6 | 6 |
| 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 "components/sessions/serialized_navigation_entry.h" | 9 #include "components/sessions/serialized_navigation_entry.h" |
| 10 #include "content/public/common/page_state.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 12 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace sessions { | 15 namespace sessions { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 void SerializedNavigationEntryTestHelper::ExpectNavigationEquals( | 18 void SerializedNavigationEntryTestHelper::ExpectNavigationEquals( |
| 18 const SerializedNavigationEntry& expected, | 19 const SerializedNavigationEntry& expected, |
| 19 const SerializedNavigationEntry& actual) { | 20 const SerializedNavigationEntry& actual) { |
| 20 EXPECT_EQ(expected.referrer_.url, actual.referrer_.url); | 21 EXPECT_EQ(expected.referrer_url_, actual.referrer_url_); |
| 21 EXPECT_EQ(expected.referrer_.policy, actual.referrer_.policy); | 22 EXPECT_EQ(expected.referrer_policy_, actual.referrer_policy_); |
| 22 EXPECT_EQ(expected.virtual_url_, actual.virtual_url_); | 23 EXPECT_EQ(expected.virtual_url_, actual.virtual_url_); |
| 23 EXPECT_EQ(expected.title_, actual.title_); | 24 EXPECT_EQ(expected.title_, actual.title_); |
| 24 EXPECT_EQ(expected.page_state_, actual.page_state_); | 25 EXPECT_EQ(expected.encoded_page_state_, actual.encoded_page_state_); |
| 25 EXPECT_EQ(expected.transition_type_, actual.transition_type_); | 26 EXPECT_EQ(expected.transition_type_, actual.transition_type_); |
| 26 EXPECT_EQ(expected.has_post_data_, actual.has_post_data_); | 27 EXPECT_EQ(expected.has_post_data_, actual.has_post_data_); |
| 27 EXPECT_EQ(expected.original_request_url_, actual.original_request_url_); | 28 EXPECT_EQ(expected.original_request_url_, actual.original_request_url_); |
| 28 EXPECT_EQ(expected.is_overriding_user_agent_, | 29 EXPECT_EQ(expected.is_overriding_user_agent_, |
| 29 actual.is_overriding_user_agent_); | 30 actual.is_overriding_user_agent_); |
| 30 } | 31 } |
| 31 | 32 |
| 32 // static | 33 // static |
| 33 SerializedNavigationEntry SerializedNavigationEntryTestHelper::CreateNavigation( | 34 SerializedNavigationEntry SerializedNavigationEntryTestHelper::CreateNavigation( |
| 34 const std::string& virtual_url, | 35 const std::string& virtual_url, |
| 35 const std::string& title) { | 36 const std::string& title) { |
| 36 SerializedNavigationEntry navigation; | 37 SerializedNavigationEntry navigation; |
| 37 navigation.index_ = 0; | 38 navigation.index_ = 0; |
| 38 navigation.referrer_ = | 39 navigation.referrer_url_ = GURL("http://www.referrer.com"); |
| 39 content::Referrer(GURL("http://www.referrer.com"), | 40 navigation.referrer_policy_ = blink::WebReferrerPolicyDefault; |
| 40 blink::WebReferrerPolicyDefault); | |
| 41 navigation.virtual_url_ = GURL(virtual_url); | 41 navigation.virtual_url_ = GURL(virtual_url); |
| 42 navigation.title_ = base::UTF8ToUTF16(title); | 42 navigation.title_ = base::UTF8ToUTF16(title); |
| 43 navigation.page_state_ = | 43 navigation.encoded_page_state_ = "fake state"; |
| 44 content::PageState::CreateFromEncodedData("fake_state"); | |
| 45 navigation.timestamp_ = base::Time::Now(); | 44 navigation.timestamp_ = base::Time::Now(); |
| 46 navigation.http_status_code_ = 200; | 45 navigation.http_status_code_ = 200; |
| 47 return navigation; | 46 return navigation; |
| 48 } | 47 } |
| 49 | 48 |
| 50 // static | 49 // static |
| 51 void SerializedNavigationEntryTestHelper::SetPageState( | 50 void SerializedNavigationEntryTestHelper::SetPageState( |
| 52 const content::PageState& page_state, | 51 const content::PageState& page_state, |
| 53 SerializedNavigationEntry* navigation) { | 52 SerializedNavigationEntry* navigation) { |
| 54 navigation->page_state_ = page_state; | 53 navigation->encoded_page_state_ = page_state.ToEncodedData(); |
| 55 } | 54 } |
| 56 | 55 |
| 57 // static | 56 // static |
| 58 void SerializedNavigationEntryTestHelper::SetHasPostData( | 57 void SerializedNavigationEntryTestHelper::SetHasPostData( |
| 59 bool has_post_data, | 58 bool has_post_data, |
| 60 SerializedNavigationEntry* navigation) { | 59 SerializedNavigationEntry* navigation) { |
| 61 navigation->has_post_data_ = has_post_data; | 60 navigation->has_post_data_ = has_post_data; |
| 62 } | 61 } |
| 63 | 62 |
| 64 // static | 63 // static |
| (...skipping 11 matching lines...) Expand all Loading... |
| 76 } | 75 } |
| 77 | 76 |
| 78 // static | 77 // static |
| 79 void SerializedNavigationEntryTestHelper::SetTimestamp( | 78 void SerializedNavigationEntryTestHelper::SetTimestamp( |
| 80 base::Time timestamp, | 79 base::Time timestamp, |
| 81 SerializedNavigationEntry* navigation) { | 80 SerializedNavigationEntry* navigation) { |
| 82 navigation->timestamp_ = timestamp; | 81 navigation->timestamp_ = timestamp; |
| 83 } | 82 } |
| 84 | 83 |
| 85 } // namespace sessions | 84 } // namespace sessions |
| OLD | NEW |