Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ssl/ssl_error_classification.h" | 5 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | |
| 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 9 #include "net/base/test_data_directory.h" | 12 #include "net/base/test_data_directory.h" |
| 10 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
| 11 #include "net/test/cert_test_util.h" | 14 #include "net/test/cert_test_util.h" |
| 12 #include "net/test/test_certificate_data.h" | 15 #include "net/test/test_certificate_data.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 17 |
| 15 using base::Time; | 18 using base::Time; |
| 16 | 19 |
| 17 TEST(SSLErrorClassification, TestDateInvalidScore) { | 20 class SSLErrorClassificationTest : public ChromeRenderViewHostTestHarness { |
| 21 public: | |
| 22 virtual void SetUp() OVERRIDE { | |
|
dcheng
2014/07/22 21:38:20
I patched your test in locally and ran it. Your te
| |
| 23 ChromeRenderViewHostTestHarness::SetUp(); | |
| 24 TabSpecificContentSettings::CreateForWebContents(web_contents()); | |
| 25 } | |
| 26 }; | |
| 27 | |
| 28 TEST_F(SSLErrorClassificationTest, TestDateInvalidScore) { | |
| 18 base::FilePath certs_dir = net::GetTestCertsDirectory(); | 29 base::FilePath certs_dir = net::GetTestCertsDirectory(); |
| 19 scoped_refptr<net::X509Certificate> expired_cert = | 30 scoped_refptr<net::X509Certificate> expired_cert = |
| 20 net::ImportCertFromFile(certs_dir, "expired_cert.pem"); | 31 net::ImportCertFromFile(certs_dir, "expired_cert.pem"); |
| 21 base::Time time; | 32 base::Time time; |
| 22 | 33 |
| 23 { | 34 { |
| 24 EXPECT_TRUE(base::Time::FromString("Wed, 03 Jan 2007 12:00:00 GMT", &time)); | 35 EXPECT_TRUE(base::Time::FromString("Wed, 03 Jan 2007 12:00:00 GMT", &time)); |
| 25 SSLErrorClassification ssl_error(time, *expired_cert); | 36 SSLErrorClassification ssl_error(web_contents(), time, *expired_cert); |
| 26 EXPECT_FLOAT_EQ(0.2f, ssl_error.CalculateScoreTimePassedSinceExpiry()); | 37 EXPECT_FLOAT_EQ(0.2f, ssl_error.CalculateScoreTimePassedSinceExpiry()); |
| 27 } | 38 } |
| 28 | 39 |
| 29 { | 40 { |
| 30 EXPECT_TRUE(base::Time::FromString("Sat, 06 Jan 2007 12:00:00 GMT", &time)); | 41 EXPECT_TRUE(base::Time::FromString("Sat, 06 Jan 2007 12:00:00 GMT", &time)); |
| 31 SSLErrorClassification ssl_error(time, *expired_cert); | 42 SSLErrorClassification ssl_error(web_contents(), time, *expired_cert); |
| 32 EXPECT_FLOAT_EQ(0.3f, ssl_error.CalculateScoreTimePassedSinceExpiry()); | 43 EXPECT_FLOAT_EQ(0.3f, ssl_error.CalculateScoreTimePassedSinceExpiry()); |
| 33 } | 44 } |
| 34 | 45 |
| 35 { | 46 { |
| 36 EXPECT_TRUE(base::Time::FromString("Mon, 08 Jan 2007 12:00:00 GMT", &time)); | 47 EXPECT_TRUE(base::Time::FromString("Mon, 08 Jan 2007 12:00:00 GMT", &time)); |
| 37 SSLErrorClassification ssl_error(time, *expired_cert); | 48 SSLErrorClassification ssl_error(web_contents(), time, *expired_cert); |
| 38 EXPECT_FLOAT_EQ(0.4f, ssl_error.CalculateScoreTimePassedSinceExpiry()); | 49 EXPECT_FLOAT_EQ(0.4f, ssl_error.CalculateScoreTimePassedSinceExpiry()); |
| 39 } | 50 } |
| 40 | |
| 41 } | 51 } |
| OLD | NEW |