cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / sessions / ios / ios_serialized_navigation_driver_unittest.cc
blobc9bde7f3989e755a5a2b8ed4708c626316c6af77
1 // Copyright 2014 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/ios/ios_serialized_navigation_driver.h"
7 #include "components/sessions/serialized_navigation_entry.h"
8 #include "components/sessions/serialized_navigation_entry_test_helper.h"
9 #include "ios/web/public/referrer.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace sessions {
14 // Tests that PageState data is properly sanitized when post data is present.
15 TEST(IOSSerializedNavigationDriverTest, PickleSanitization) {
16 IOSSerializedNavigationDriver* driver =
17 IOSSerializedNavigationDriver::GetInstance();
18 SerializedNavigationEntry navigation =
19 SerializedNavigationEntryTestHelper::CreateNavigationForTest();
20 EXPECT_EQ(test_data::kEncodedPageState, navigation.encoded_page_state());
22 // Sanitization always clears the page state.
23 std::string sanitized_page_state =
24 driver->GetSanitizedPageStateForPickle(&navigation);
25 EXPECT_EQ(std::string(), sanitized_page_state);
28 // Tests that the input data is left unsanitized when the referrer policy is
29 // Always.
30 TEST(IOSSerializedNavigationDriverTest, SanitizeWithReferrerPolicyAlways) {
31 IOSSerializedNavigationDriver* driver =
32 IOSSerializedNavigationDriver::GetInstance();
33 SerializedNavigationEntry navigation =
34 SerializedNavigationEntryTestHelper::CreateNavigationForTest();
35 SerializedNavigationEntryTestHelper::SetReferrerPolicy(
36 web::ReferrerPolicyAlways, &navigation);
38 driver->Sanitize(&navigation);
39 EXPECT_EQ(test_data::kIndex, navigation.index());
40 EXPECT_EQ(test_data::kUniqueID, navigation.unique_id());
41 EXPECT_EQ(test_data::kReferrerURL, navigation.referrer_url());
42 EXPECT_EQ(web::ReferrerPolicyAlways, navigation.referrer_policy());
43 EXPECT_EQ(test_data::kVirtualURL, navigation.virtual_url());
44 EXPECT_EQ(test_data::kTitle, navigation.title());
45 EXPECT_EQ(test_data::kEncodedPageState, navigation.encoded_page_state());
46 EXPECT_EQ(test_data::kTransitionType, navigation.transition_type());
47 EXPECT_EQ(test_data::kHasPostData, navigation.has_post_data());
48 EXPECT_EQ(test_data::kPostID, navigation.post_id());
49 EXPECT_EQ(test_data::kOriginalRequestURL, navigation.original_request_url());
50 EXPECT_EQ(test_data::kIsOverridingUserAgent,
51 navigation.is_overriding_user_agent());
52 EXPECT_EQ(test_data::kTimestamp, navigation.timestamp());
53 EXPECT_EQ(test_data::kSearchTerms, navigation.search_terms());
54 EXPECT_EQ(test_data::kFaviconURL, navigation.favicon_url());
55 EXPECT_EQ(test_data::kHttpStatusCode, navigation.http_status_code());
58 // Tests that the input data is properly sanitized when the referrer policy is
59 // Never.
60 TEST(IOSSerializedNavigationDriverTest, SanitizeWithReferrerPolicyNever) {
61 IOSSerializedNavigationDriver* driver =
62 IOSSerializedNavigationDriver::GetInstance();
63 SerializedNavigationEntry navigation =
64 SerializedNavigationEntryTestHelper::CreateNavigationForTest();
65 SerializedNavigationEntryTestHelper::SetReferrerPolicy(
66 web::ReferrerPolicyNever, &navigation);
68 driver->Sanitize(&navigation);
70 // Fields that should remain untouched.
71 EXPECT_EQ(test_data::kIndex, navigation.index());
72 EXPECT_EQ(test_data::kUniqueID, navigation.unique_id());
73 EXPECT_EQ(test_data::kVirtualURL, navigation.virtual_url());
74 EXPECT_EQ(test_data::kTitle, navigation.title());
75 EXPECT_EQ(test_data::kEncodedPageState, navigation.encoded_page_state());
76 EXPECT_EQ(test_data::kTransitionType, navigation.transition_type());
77 EXPECT_EQ(test_data::kHasPostData, navigation.has_post_data());
78 EXPECT_EQ(test_data::kPostID, navigation.post_id());
79 EXPECT_EQ(test_data::kOriginalRequestURL, navigation.original_request_url());
80 EXPECT_EQ(test_data::kIsOverridingUserAgent,
81 navigation.is_overriding_user_agent());
82 EXPECT_EQ(test_data::kTimestamp, navigation.timestamp());
83 EXPECT_EQ(test_data::kSearchTerms, navigation.search_terms());
84 EXPECT_EQ(test_data::kFaviconURL, navigation.favicon_url());
85 EXPECT_EQ(test_data::kHttpStatusCode, navigation.http_status_code());
87 // Fields that were sanitized.
88 EXPECT_EQ(GURL(), navigation.referrer_url());
89 EXPECT_EQ(web::ReferrerPolicyDefault, navigation.referrer_policy());
92 } // namespace sessions