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
3 // found in the LICENSE file.
5 #include "components/sessions/serialized_navigation_entry_test_helper.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "base/time/time.h"
9 #include "components/sessions/serialized_navigation_entry.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
17 void SerializedNavigationEntryTestHelper::ExpectNavigationEquals(
18 const SerializedNavigationEntry
& expected
,
19 const SerializedNavigationEntry
& actual
) {
20 EXPECT_EQ(expected
.referrer_
.url
, actual
.referrer_
.url
);
21 EXPECT_EQ(expected
.referrer_
.policy
, actual
.referrer_
.policy
);
22 EXPECT_EQ(expected
.virtual_url_
, actual
.virtual_url_
);
23 EXPECT_EQ(expected
.title_
, actual
.title_
);
24 EXPECT_EQ(expected
.page_state_
, actual
.page_state_
);
25 EXPECT_EQ(expected
.transition_type_
, actual
.transition_type_
);
26 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
.is_overriding_user_agent_
,
29 actual
.is_overriding_user_agent_
);
33 SerializedNavigationEntry
SerializedNavigationEntryTestHelper::CreateNavigation(
34 const std::string
& virtual_url
,
35 const std::string
& title
) {
36 SerializedNavigationEntry navigation
;
37 navigation
.index_
= 0;
38 navigation
.referrer_
=
39 content::Referrer(GURL("http://www.referrer.com"),
40 blink::WebReferrerPolicyDefault
);
41 navigation
.virtual_url_
= GURL(virtual_url
);
42 navigation
.title_
= base::UTF8ToUTF16(title
);
43 navigation
.page_state_
=
44 content::PageState::CreateFromEncodedData("fake_state");
45 navigation
.timestamp_
= base::Time::Now();
46 navigation
.http_status_code_
= 200;
51 void SerializedNavigationEntryTestHelper::SetPageState(
52 const content::PageState
& page_state
,
53 SerializedNavigationEntry
* navigation
) {
54 navigation
->page_state_
= page_state
;
58 void SerializedNavigationEntryTestHelper::SetHasPostData(
60 SerializedNavigationEntry
* navigation
) {
61 navigation
->has_post_data_
= has_post_data
;
65 void SerializedNavigationEntryTestHelper::SetOriginalRequestURL(
66 const GURL
& original_request_url
,
67 SerializedNavigationEntry
* navigation
) {
68 navigation
->original_request_url_
= original_request_url
;
72 void SerializedNavigationEntryTestHelper::SetIsOverridingUserAgent(
73 bool is_overriding_user_agent
,
74 SerializedNavigationEntry
* navigation
) {
75 navigation
->is_overriding_user_agent_
= is_overriding_user_agent
;
79 void SerializedNavigationEntryTestHelper::SetTimestamp(
81 SerializedNavigationEntry
* navigation
) {
82 navigation
->timestamp_
= timestamp
;
85 } // namespace sessions