| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/native/state_serializer.h" | 5 #include "android_webview/native/state_serializer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 referrer.policy = blink::WebReferrerPolicyOrigin; | 48 referrer.policy = blink::WebReferrerPolicyOrigin; |
| 49 const base::string16 title(base::UTF8ToUTF16("title")); | 49 const base::string16 title(base::UTF8ToUTF16("title")); |
| 50 const content::PageState page_state = | 50 const content::PageState page_state = |
| 51 content::PageState::CreateFromEncodedData("completely bogus state"); | 51 content::PageState::CreateFromEncodedData("completely bogus state"); |
| 52 const bool has_post_data = true; | 52 const bool has_post_data = true; |
| 53 const GURL original_request_url("http://original_request_url"); | 53 const GURL original_request_url("http://original_request_url"); |
| 54 const GURL base_url_for_data_url("http://base_url"); | 54 const GURL base_url_for_data_url("http://base_url"); |
| 55 const bool is_overriding_user_agent = true; | 55 const bool is_overriding_user_agent = true; |
| 56 const base::Time timestamp = base::Time::FromInternalValue(12345); | 56 const base::Time timestamp = base::Time::FromInternalValue(12345); |
| 57 const int http_status_code = 404; | 57 const int http_status_code = 404; |
| 58 const GURL redirect_0("http://redirect_0"); |
| 59 const GURL redirect_1("http://redirect_1"); |
| 58 | 60 |
| 59 entry->SetURL(url); | 61 entry->SetURL(url); |
| 60 entry->SetVirtualURL(virtual_url); | 62 entry->SetVirtualURL(virtual_url); |
| 61 entry->SetReferrer(referrer); | 63 entry->SetReferrer(referrer); |
| 62 entry->SetTitle(title); | 64 entry->SetTitle(title); |
| 63 entry->SetPageState(page_state); | 65 entry->SetPageState(page_state); |
| 64 entry->SetHasPostData(has_post_data); | 66 entry->SetHasPostData(has_post_data); |
| 65 entry->SetOriginalRequestURL(original_request_url); | 67 entry->SetOriginalRequestURL(original_request_url); |
| 66 entry->SetBaseURLForDataURL(base_url_for_data_url); | 68 entry->SetBaseURLForDataURL(base_url_for_data_url); |
| 67 entry->SetIsOverridingUserAgent(is_overriding_user_agent); | 69 entry->SetIsOverridingUserAgent(is_overriding_user_agent); |
| 68 entry->SetTimestamp(timestamp); | 70 entry->SetTimestamp(timestamp); |
| 69 entry->SetHttpStatusCode(http_status_code); | 71 entry->SetHttpStatusCode(http_status_code); |
| 72 std::vector<GURL> redirects; |
| 73 redirects.push_back(redirect_0); |
| 74 redirects.push_back(redirect_1); |
| 75 redirects.push_back(virtual_url); |
| 76 entry->SetRedirectChain(redirects); |
| 70 | 77 |
| 71 Pickle pickle; | 78 Pickle pickle; |
| 72 bool result = internal::WriteNavigationEntryToPickle(*entry, &pickle); | 79 bool result = internal::WriteNavigationEntryToPickle(*entry, &pickle); |
| 73 EXPECT_TRUE(result); | 80 EXPECT_TRUE(result); |
| 74 | 81 |
| 75 scoped_ptr<content::NavigationEntry> copy(content::NavigationEntry::Create()); | 82 scoped_ptr<content::NavigationEntry> copy(content::NavigationEntry::Create()); |
| 76 PickleIterator iterator(pickle); | 83 PickleIterator iterator(pickle); |
| 77 result = internal::RestoreNavigationEntryFromPickle(&iterator, copy.get()); | 84 result = internal::RestoreNavigationEntryFromPickle(&iterator, copy.get()); |
| 78 EXPECT_TRUE(result); | 85 EXPECT_TRUE(result); |
| 79 | 86 |
| 80 EXPECT_EQ(url, copy->GetURL()); | 87 EXPECT_EQ(url, copy->GetURL()); |
| 81 EXPECT_EQ(virtual_url, copy->GetVirtualURL()); | 88 EXPECT_EQ(virtual_url, copy->GetVirtualURL()); |
| 82 EXPECT_EQ(referrer.url, copy->GetReferrer().url); | 89 EXPECT_EQ(referrer.url, copy->GetReferrer().url); |
| 83 EXPECT_EQ(referrer.policy, copy->GetReferrer().policy); | 90 EXPECT_EQ(referrer.policy, copy->GetReferrer().policy); |
| 84 EXPECT_EQ(title, copy->GetTitle()); | 91 EXPECT_EQ(title, copy->GetTitle()); |
| 85 EXPECT_EQ(page_state, copy->GetPageState()); | 92 EXPECT_EQ(page_state, copy->GetPageState()); |
| 86 EXPECT_EQ(has_post_data, copy->GetHasPostData()); | 93 EXPECT_EQ(has_post_data, copy->GetHasPostData()); |
| 87 EXPECT_EQ(original_request_url, copy->GetOriginalRequestURL()); | 94 EXPECT_EQ(original_request_url, copy->GetOriginalRequestURL()); |
| 88 EXPECT_EQ(base_url_for_data_url, copy->GetBaseURLForDataURL()); | 95 EXPECT_EQ(base_url_for_data_url, copy->GetBaseURLForDataURL()); |
| 89 EXPECT_EQ(is_overriding_user_agent, copy->GetIsOverridingUserAgent()); | 96 EXPECT_EQ(is_overriding_user_agent, copy->GetIsOverridingUserAgent()); |
| 90 EXPECT_EQ(timestamp, copy->GetTimestamp()); | 97 EXPECT_EQ(timestamp, copy->GetTimestamp()); |
| 91 EXPECT_EQ(http_status_code, copy->GetHttpStatusCode()); | 98 EXPECT_EQ(http_status_code, copy->GetHttpStatusCode()); |
| 99 EXPECT_EQ(3U, copy->GetRedirectChain().size()); |
| 100 EXPECT_EQ(redirect_0, copy->GetRedirectChain().at(0)); |
| 101 EXPECT_EQ(redirect_1, copy->GetRedirectChain().at(1)); |
| 102 EXPECT_EQ(virtual_url, copy->GetRedirectChain().at(2)); |
| 92 } | 103 } |
| 93 | 104 |
| 94 } // namespace android_webview | 105 } // namespace android_webview |
| OLD | NEW |