OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/string16.h" | 5 #include "base/string16.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/browser/renderer_host/site_instance.h" | 7 #include "chrome/browser/renderer_host/site_instance.h" |
8 #include "chrome/browser/tab_contents/navigation_entry.h" | 8 #include "chrome/browser/tab_contents/navigation_entry.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 // Test SSLStatus inner class | 96 // Test SSLStatus inner class |
97 TEST_F(NavigationEntryTest, NavigationEntrySSLStatus) { | 97 TEST_F(NavigationEntryTest, NavigationEntrySSLStatus) { |
98 // Default (not secure) | 98 // Default (not secure) |
99 EXPECT_EQ(SECURITY_STYLE_UNKNOWN, entry1_.get()->ssl().security_style()); | 99 EXPECT_EQ(SECURITY_STYLE_UNKNOWN, entry1_.get()->ssl().security_style()); |
100 EXPECT_EQ(SECURITY_STYLE_UNKNOWN, entry2_.get()->ssl().security_style()); | 100 EXPECT_EQ(SECURITY_STYLE_UNKNOWN, entry2_.get()->ssl().security_style()); |
101 EXPECT_EQ(0, entry1_.get()->ssl().cert_id()); | 101 EXPECT_EQ(0, entry1_.get()->ssl().cert_id()); |
102 EXPECT_EQ(0, entry1_.get()->ssl().cert_status()); | 102 EXPECT_EQ(0, entry1_.get()->ssl().cert_status()); |
103 EXPECT_EQ(-1, entry1_.get()->ssl().security_bits()); | 103 EXPECT_EQ(-1, entry1_.get()->ssl().security_bits()); |
104 EXPECT_FALSE(entry1_.get()->ssl().displayed_mixed_content()); | 104 EXPECT_FALSE(entry1_.get()->ssl().has_mixed_content()); |
105 EXPECT_FALSE(entry1_.get()->ssl().ran_mixed_content()); | |
106 | 105 |
107 // Change from the defaults | 106 // Change from the defaults |
108 entry2_.get()->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATED); | 107 entry2_.get()->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATED); |
109 entry2_.get()->ssl().set_cert_id(4); | 108 entry2_.get()->ssl().set_cert_id(4); |
110 entry2_.get()->ssl().set_cert_status(1); | 109 entry2_.get()->ssl().set_cert_status(1); |
111 entry2_.get()->ssl().set_security_bits(0); | 110 entry2_.get()->ssl().set_security_bits(0); |
112 entry2_.get()->ssl().set_displayed_mixed_content(); | |
113 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, | 111 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATED, |
114 entry2_.get()->ssl().security_style()); | 112 entry2_.get()->ssl().security_style()); |
115 EXPECT_EQ(4, entry2_.get()->ssl().cert_id()); | 113 EXPECT_EQ(4, entry2_.get()->ssl().cert_id()); |
116 EXPECT_EQ(1, entry2_.get()->ssl().cert_status()); | 114 EXPECT_EQ(1, entry2_.get()->ssl().cert_status()); |
117 EXPECT_EQ(0, entry2_.get()->ssl().security_bits()); | 115 EXPECT_EQ(0, entry2_.get()->ssl().security_bits()); |
118 EXPECT_TRUE(entry2_.get()->ssl().displayed_mixed_content()); | |
119 | 116 |
120 entry2_.get()->ssl().set_security_style(SECURITY_STYLE_AUTHENTICATION_BROKEN); | 117 // Mixed content unaffected by unsafe content |
121 entry2_.get()->ssl().set_ran_mixed_content(); | 118 EXPECT_FALSE(entry2_.get()->ssl().has_mixed_content()); |
122 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, | 119 entry2_.get()->ssl().set_has_mixed_content(); |
123 entry2_.get()->ssl().security_style()); | 120 EXPECT_TRUE(entry2_.get()->ssl().has_mixed_content()); |
124 EXPECT_TRUE(entry2_.get()->ssl().ran_mixed_content()); | |
125 } | 121 } |
126 | 122 |
127 // Test other basic accessors | 123 // Test other basic accessors |
128 TEST_F(NavigationEntryTest, NavigationEntryAccessors) { | 124 TEST_F(NavigationEntryTest, NavigationEntryAccessors) { |
129 // SiteInstance | 125 // SiteInstance |
130 EXPECT_TRUE(entry1_.get()->site_instance() == NULL); | 126 EXPECT_TRUE(entry1_.get()->site_instance() == NULL); |
131 EXPECT_EQ(instance_, entry2_.get()->site_instance()); | 127 EXPECT_EQ(instance_, entry2_.get()->site_instance()); |
132 entry1_.get()->set_site_instance(instance_); | 128 entry1_.get()->set_site_instance(instance_); |
133 EXPECT_EQ(instance_, entry1_.get()->site_instance()); | 129 EXPECT_EQ(instance_, entry1_.get()->site_instance()); |
134 | 130 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 EXPECT_FALSE(entry2_.get()->has_post_data()); | 169 EXPECT_FALSE(entry2_.get()->has_post_data()); |
174 entry2_.get()->set_has_post_data(true); | 170 entry2_.get()->set_has_post_data(true); |
175 EXPECT_TRUE(entry2_.get()->has_post_data()); | 171 EXPECT_TRUE(entry2_.get()->has_post_data()); |
176 | 172 |
177 // Restored | 173 // Restored |
178 EXPECT_EQ(NavigationEntry::RESTORE_NONE, entry1_->restore_type()); | 174 EXPECT_EQ(NavigationEntry::RESTORE_NONE, entry1_->restore_type()); |
179 EXPECT_EQ(NavigationEntry::RESTORE_NONE, entry2_->restore_type()); | 175 EXPECT_EQ(NavigationEntry::RESTORE_NONE, entry2_->restore_type()); |
180 entry2_->set_restore_type(NavigationEntry::RESTORE_LAST_SESSION); | 176 entry2_->set_restore_type(NavigationEntry::RESTORE_LAST_SESSION); |
181 EXPECT_EQ(NavigationEntry::RESTORE_LAST_SESSION, entry2_->restore_type()); | 177 EXPECT_EQ(NavigationEntry::RESTORE_LAST_SESSION, entry2_->restore_type()); |
182 } | 178 } |
OLD | NEW |