Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: components/sessions/serialized_navigation_entry_test_helper.cc

Issue 1361613002: Move all core files in //components/sessions into core/ subdir (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "components/sessions/serialized_navigation_entry_test_helper.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "base/time/time.h"
9 #include "components/sessions/serialized_navigation_entry.h"
10 #include "sync/util/time.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h"
13
14 namespace sessions {
15
16 namespace test_data {
17
18 const int kIndex = 3;
19 const int kUniqueID = 50;
20 const GURL kReferrerURL = GURL("http://www.referrer.com");
21 const int kReferrerPolicy = 0;
22 const GURL kVirtualURL= GURL("http://www.virtual-url.com");
23 const base::string16 kTitle = base::ASCIIToUTF16("title");
24 const std::string kEncodedPageState = "page state";
25 const ui::PageTransition kTransitionType =
26 ui::PageTransitionFromInt(
27 ui::PAGE_TRANSITION_AUTO_SUBFRAME |
28 ui::PAGE_TRANSITION_HOME_PAGE |
29 ui::PAGE_TRANSITION_CLIENT_REDIRECT);
30 const bool kHasPostData = true;
31 const int64 kPostID = 100;
32 const GURL kOriginalRequestURL = GURL("http://www.original-request.com");
33 const bool kIsOverridingUserAgent = true;
34 const base::Time kTimestamp = syncer::ProtoTimeToTime(100);
35 const base::string16 kSearchTerms = base::ASCIIToUTF16("my search terms");
36 const GURL kFaviconURL = GURL("http://virtual-url.com/favicon.ico");
37 const int kHttpStatusCode = 404;
38 const GURL kRedirectURL0 = GURL("http://go/redirect0");
39 const GURL kRedirectURL1 = GURL("http://go/redirect1");
40 const GURL kOtherURL = GURL("http://other.com");
41 const int kPageID = 10;
42
43 } // namespace test_data
44
45 // static
46 void SerializedNavigationEntryTestHelper::ExpectNavigationEquals(
47 const SerializedNavigationEntry& expected,
48 const SerializedNavigationEntry& actual) {
49 EXPECT_EQ(expected.referrer_url_, actual.referrer_url_);
50 EXPECT_EQ(expected.referrer_policy_, actual.referrer_policy_);
51 EXPECT_EQ(expected.virtual_url_, actual.virtual_url_);
52 EXPECT_EQ(expected.title_, actual.title_);
53 EXPECT_EQ(expected.encoded_page_state_, actual.encoded_page_state_);
54 EXPECT_EQ(expected.transition_type_, actual.transition_type_);
55 EXPECT_EQ(expected.has_post_data_, actual.has_post_data_);
56 EXPECT_EQ(expected.original_request_url_, actual.original_request_url_);
57 EXPECT_EQ(expected.is_overriding_user_agent_,
58 actual.is_overriding_user_agent_);
59 }
60
61 // static
62 SerializedNavigationEntry SerializedNavigationEntryTestHelper::CreateNavigation(
63 const std::string& virtual_url,
64 const std::string& title) {
65 SerializedNavigationEntry navigation;
66 navigation.index_ = 0;
67 navigation.referrer_url_ = GURL("http://www.referrer.com");
68 navigation.virtual_url_ = GURL(virtual_url);
69 navigation.title_ = base::UTF8ToUTF16(title);
70 navigation.encoded_page_state_ = "fake state";
71 navigation.timestamp_ = base::Time::Now();
72 navigation.http_status_code_ = 200;
73 return navigation;
74 }
75
76 // static
77 SerializedNavigationEntry
78 SerializedNavigationEntryTestHelper::CreateNavigationForTest() {
79 SerializedNavigationEntry navigation;
80 navigation.index_ = test_data::kIndex;
81 navigation.unique_id_ = test_data::kUniqueID;
82 navigation.referrer_url_ = test_data::kReferrerURL;
83 navigation.referrer_policy_ = test_data::kReferrerPolicy;
84 navigation.virtual_url_ = test_data::kVirtualURL;
85 navigation.title_ = test_data::kTitle;
86 navigation.encoded_page_state_ = test_data::kEncodedPageState;
87 navigation.transition_type_ = test_data::kTransitionType;
88 navigation.has_post_data_ = test_data::kHasPostData;
89 navigation.post_id_ = test_data::kPostID;
90 navigation.original_request_url_ = test_data::kOriginalRequestURL;
91 navigation.is_overriding_user_agent_ = test_data::kIsOverridingUserAgent;
92 navigation.timestamp_ = test_data::kTimestamp;
93 navigation.search_terms_ = test_data::kSearchTerms;
94 navigation.favicon_url_ = test_data::kFaviconURL;
95 navigation.http_status_code_ = test_data::kHttpStatusCode;
96
97 navigation.redirect_chain_.push_back(test_data::kRedirectURL0);
98 navigation.redirect_chain_.push_back(test_data::kRedirectURL1);
99 navigation.redirect_chain_.push_back(test_data::kVirtualURL);
100 return navigation;
101 }
102
103 // static
104 void SerializedNavigationEntryTestHelper::SetReferrerPolicy(
105 int policy,
106 SerializedNavigationEntry* navigation) {
107 navigation->referrer_policy_ = policy;
108 }
109
110 // static
111 void SerializedNavigationEntryTestHelper::SetVirtualURL(
112 const GURL& virtual_url,
113 SerializedNavigationEntry* navigation) {
114 navigation->virtual_url_ = virtual_url;
115 }
116
117 // static
118 void SerializedNavigationEntryTestHelper::SetEncodedPageState(
119 const std::string& encoded_page_state,
120 SerializedNavigationEntry* navigation) {
121 navigation->encoded_page_state_ = encoded_page_state;
122 }
123
124 // static
125 void SerializedNavigationEntryTestHelper::SetTransitionType(
126 ui::PageTransition transition_type,
127 SerializedNavigationEntry* navigation) {
128 navigation->transition_type_ = transition_type;
129 }
130
131 // static
132 void SerializedNavigationEntryTestHelper::SetHasPostData(
133 bool has_post_data,
134 SerializedNavigationEntry* navigation) {
135 navigation->has_post_data_ = has_post_data;
136 }
137
138 // static
139 void SerializedNavigationEntryTestHelper::SetOriginalRequestURL(
140 const GURL& original_request_url,
141 SerializedNavigationEntry* navigation) {
142 navigation->original_request_url_ = original_request_url;
143 }
144
145 // static
146 void SerializedNavigationEntryTestHelper::SetIsOverridingUserAgent(
147 bool is_overriding_user_agent,
148 SerializedNavigationEntry* navigation) {
149 navigation->is_overriding_user_agent_ = is_overriding_user_agent;
150 }
151
152 // static
153 void SerializedNavigationEntryTestHelper::SetTimestamp(
154 base::Time timestamp,
155 SerializedNavigationEntry* navigation) {
156 navigation->timestamp_ = timestamp;
157 }
158
159 } // namespace sessions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698