OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
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 "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
11 #include "content/public/common/ssl_status.h" | 11 #include "content/public/common/ssl_status.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class NavigationEntryTest : public testing::Test { | 16 class NavigationEntryTest : public testing::Test { |
17 public: | 17 public: |
18 NavigationEntryTest() : instance_(NULL) { | 18 NavigationEntryTest() : instance_(NULL) { |
19 } | 19 } |
20 | 20 |
21 virtual void SetUp() { | 21 virtual void SetUp() { |
22 entry1_.reset(new NavigationEntryImpl); | 22 entry1_.reset(new NavigationEntryImpl); |
23 | 23 |
24 #if !defined(OS_IOS) | 24 #if !defined(OS_IOS) |
25 instance_ = static_cast<SiteInstanceImpl*>(SiteInstance::Create(NULL)); | 25 instance_ = static_cast<SiteInstanceImpl*>(SiteInstance::Create(NULL)); |
26 #endif | 26 #endif |
27 entry2_.reset(new NavigationEntryImpl( | 27 entry2_.reset(new NavigationEntryImpl( |
28 instance_, 3, | 28 instance_, 3, |
29 GURL("test:url"), | 29 GURL("test:url"), |
30 Referrer(GURL("from"), WebKit::WebReferrerPolicyDefault), | 30 Referrer(GURL("from"), blink::WebReferrerPolicyDefault), |
31 ASCIIToUTF16("title"), | 31 ASCIIToUTF16("title"), |
32 PAGE_TRANSITION_TYPED, | 32 PAGE_TRANSITION_TYPED, |
33 false)); | 33 false)); |
34 } | 34 } |
35 | 35 |
36 virtual void TearDown() { | 36 virtual void TearDown() { |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 scoped_ptr<NavigationEntryImpl> entry1_; | 40 scoped_ptr<NavigationEntryImpl> entry1_; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Page type | 125 // Page type |
126 EXPECT_EQ(PAGE_TYPE_NORMAL, entry1_->GetPageType()); | 126 EXPECT_EQ(PAGE_TYPE_NORMAL, entry1_->GetPageType()); |
127 EXPECT_EQ(PAGE_TYPE_NORMAL, entry2_->GetPageType()); | 127 EXPECT_EQ(PAGE_TYPE_NORMAL, entry2_->GetPageType()); |
128 entry2_->set_page_type(PAGE_TYPE_INTERSTITIAL); | 128 entry2_->set_page_type(PAGE_TYPE_INTERSTITIAL); |
129 EXPECT_EQ(PAGE_TYPE_INTERSTITIAL, entry2_->GetPageType()); | 129 EXPECT_EQ(PAGE_TYPE_INTERSTITIAL, entry2_->GetPageType()); |
130 | 130 |
131 // Referrer | 131 // Referrer |
132 EXPECT_EQ(GURL(), entry1_->GetReferrer().url); | 132 EXPECT_EQ(GURL(), entry1_->GetReferrer().url); |
133 EXPECT_EQ(GURL("from"), entry2_->GetReferrer().url); | 133 EXPECT_EQ(GURL("from"), entry2_->GetReferrer().url); |
134 entry2_->SetReferrer( | 134 entry2_->SetReferrer( |
135 Referrer(GURL("from2"), WebKit::WebReferrerPolicyDefault)); | 135 Referrer(GURL("from2"), blink::WebReferrerPolicyDefault)); |
136 EXPECT_EQ(GURL("from2"), entry2_->GetReferrer().url); | 136 EXPECT_EQ(GURL("from2"), entry2_->GetReferrer().url); |
137 | 137 |
138 // Title | 138 // Title |
139 EXPECT_EQ(string16(), entry1_->GetTitle()); | 139 EXPECT_EQ(string16(), entry1_->GetTitle()); |
140 EXPECT_EQ(ASCIIToUTF16("title"), entry2_->GetTitle()); | 140 EXPECT_EQ(ASCIIToUTF16("title"), entry2_->GetTitle()); |
141 entry2_->SetTitle(ASCIIToUTF16("title2")); | 141 entry2_->SetTitle(ASCIIToUTF16("title2")); |
142 EXPECT_EQ(ASCIIToUTF16("title2"), entry2_->GetTitle()); | 142 EXPECT_EQ(ASCIIToUTF16("title2"), entry2_->GetTitle()); |
143 | 143 |
144 // State | 144 // State |
145 EXPECT_FALSE(entry1_->GetPageState().IsValid()); | 145 EXPECT_FALSE(entry1_->GetPageState().IsValid()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Content in |output| is not modified if data is not present at the key. | 232 // Content in |output| is not modified if data is not present at the key. |
233 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); | 233 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); |
234 EXPECT_EQ(test_data, output); | 234 EXPECT_EQ(test_data, output); |
235 // Using an empty string shows that the data is not present in the map. | 235 // Using an empty string shows that the data is not present in the map. |
236 string16 output2; | 236 string16 output2; |
237 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); | 237 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); |
238 EXPECT_EQ(ASCIIToUTF16(""), output2); | 238 EXPECT_EQ(ASCIIToUTF16(""), output2); |
239 } | 239 } |
240 | 240 |
241 } // namespace content | 241 } // namespace content |
OLD | NEW |