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 "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 11 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.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.page_state_, actual.page_state_); | 24 EXPECT_EQ(expected.encoded_page_state_, actual.encoded_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_url_ = GURL("http://www.referrer.com"); |
39 content::Referrer(GURL("http://www.referrer.com"), | 39 navigation.referrer_policy_ = blink::WebReferrerPolicyDefault; |
40 blink::WebReferrerPolicyDefault); | |
41 navigation.virtual_url_ = GURL(virtual_url); | 40 navigation.virtual_url_ = GURL(virtual_url); |
42 navigation.title_ = base::UTF8ToUTF16(title); | 41 navigation.title_ = base::UTF8ToUTF16(title); |
43 navigation.page_state_ = | 42 navigation.encoded_page_state_ = "fake state"; |
44 content::PageState::CreateFromEncodedData("fake_state"); | |
45 navigation.timestamp_ = base::Time::Now(); | 43 navigation.timestamp_ = base::Time::Now(); |
46 navigation.http_status_code_ = 200; | 44 navigation.http_status_code_ = 200; |
47 return navigation; | 45 return navigation; |
48 } | 46 } |
49 | 47 |
50 // static | 48 // static |
51 void SerializedNavigationEntryTestHelper::SetPageState( | 49 void SerializedNavigationEntryTestHelper::SetPageState( |
52 const content::PageState& page_state, | 50 const content::PageState& page_state, |
53 SerializedNavigationEntry* navigation) { | 51 SerializedNavigationEntry* navigation) { |
54 navigation->page_state_ = page_state; | 52 navigation->encoded_page_state_ = page_state.ToEncodedData(); |
55 } | 53 } |
56 | 54 |
57 // static | 55 // static |
58 void SerializedNavigationEntryTestHelper::SetHasPostData( | 56 void SerializedNavigationEntryTestHelper::SetHasPostData( |
59 bool has_post_data, | 57 bool has_post_data, |
60 SerializedNavigationEntry* navigation) { | 58 SerializedNavigationEntry* navigation) { |
61 navigation->has_post_data_ = has_post_data; | 59 navigation->has_post_data_ = has_post_data; |
62 } | 60 } |
63 | 61 |
64 // static | 62 // static |
(...skipping 11 matching lines...) Expand all Loading... |
76 } | 74 } |
77 | 75 |
78 // static | 76 // static |
79 void SerializedNavigationEntryTestHelper::SetTimestamp( | 77 void SerializedNavigationEntryTestHelper::SetTimestamp( |
80 base::Time timestamp, | 78 base::Time timestamp, |
81 SerializedNavigationEntry* navigation) { | 79 SerializedNavigationEntry* navigation) { |
82 navigation->timestamp_ = timestamp; | 80 navigation->timestamp_ = timestamp; |
83 } | 81 } |
84 | 82 |
85 } // namespace sessions | 83 } // namespace sessions |
OLD | NEW |