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 "chrome/browser/website_settings_model.h" | 5 #include "chrome/browser/website_settings_model.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "content/browser/cert_store.h" | 10 #include "content/public/browser/cert_store.h" |
11 #include "content/public/common/ssl_status.h" | 11 #include "content/public/common/ssl_status.h" |
12 #include "net/base/cert_status_flags.h" | 12 #include "net/base/cert_status_flags.h" |
13 #include "net/base/ssl_connection_status_flags.h" | 13 #include "net/base/ssl_connection_status_flags.h" |
14 #include "net/base/test_certificate_data.h" | 14 #include "net/base/test_certificate_data.h" |
15 #include "net/base/x509_certificate.h" | 15 #include "net/base/x509_certificate.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using content::SSLStatus; | 19 using content::SSLStatus; |
20 using namespace testing; | 20 using namespace testing; |
(...skipping 10 matching lines...) Expand all Loading... |
31 int bitmask = version << net::SSL_CONNECTION_VERSION_SHIFT; | 31 int bitmask = version << net::SSL_CONNECTION_VERSION_SHIFT; |
32 return bitmask | connection_status; | 32 return bitmask | connection_status; |
33 } | 33 } |
34 | 34 |
35 int SetSSLCipherSuite(int connection_status, int cipher_suite) { | 35 int SetSSLCipherSuite(int connection_status, int cipher_suite) { |
36 // Clear cipher suite bits (the 16 lowest bits). | 36 // Clear cipher suite bits (the 16 lowest bits). |
37 connection_status &= ~net::SSL_CONNECTION_CIPHERSUITE_MASK; | 37 connection_status &= ~net::SSL_CONNECTION_CIPHERSUITE_MASK; |
38 return cipher_suite | connection_status; | 38 return cipher_suite | connection_status; |
39 } | 39 } |
40 | 40 |
41 class MockCertStore : public CertStore { | 41 class MockCertStore : public content::CertStore { |
42 public: | 42 public: |
43 virtual ~MockCertStore() {} | 43 virtual ~MockCertStore() {} |
44 MOCK_METHOD2(StoreCert, int(net::X509Certificate*, int)); | 44 MOCK_METHOD2(StoreCert, int(net::X509Certificate*, int)); |
45 MOCK_METHOD2(RetrieveCert, bool(int, scoped_refptr<net::X509Certificate>*)); | 45 MOCK_METHOD2(RetrieveCert, bool(int, scoped_refptr<net::X509Certificate>*)); |
46 MOCK_METHOD1(RemoveCertsForRenderProcesHost, void(int)); | |
47 }; | 46 }; |
48 | 47 |
49 class WebsiteSettingsModelTest : public testing::Test { | 48 class WebsiteSettingsModelTest : public testing::Test { |
50 public: | 49 public: |
51 WebsiteSettingsModelTest() : testing::Test(), | 50 WebsiteSettingsModelTest() : testing::Test(), |
52 profile_(new TestingProfile()), | 51 profile_(new TestingProfile()), |
53 cert_id_(0) { | 52 cert_id_(0) { |
54 } | 53 } |
55 | 54 |
56 virtual ~WebsiteSettingsModelTest() { | 55 virtual ~WebsiteSettingsModelTest() { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 ssl.connection_status = status; | 214 ssl.connection_status = status; |
216 | 215 |
217 scoped_ptr<WebsiteSettingsModel> model( | 216 scoped_ptr<WebsiteSettingsModel> model( |
218 new WebsiteSettingsModel(profile(), url, ssl, &cert_store_)); | 217 new WebsiteSettingsModel(profile(), url, ssl, &cert_store_)); |
219 EXPECT_EQ(WebsiteSettingsModel::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, | 218 EXPECT_EQ(WebsiteSettingsModel::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, |
220 model->site_connection_status()); | 219 model->site_connection_status()); |
221 EXPECT_EQ(WebsiteSettingsModel::SITE_IDENTITY_STATUS_CERT, | 220 EXPECT_EQ(WebsiteSettingsModel::SITE_IDENTITY_STATUS_CERT, |
222 model->site_identity_status()); | 221 model->site_identity_status()); |
223 EXPECT_EQ(string16(), model->organization_name()); | 222 EXPECT_EQ(string16(), model->organization_name()); |
224 } | 223 } |
OLD | NEW |