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