Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/browser/ssl/ssl_error_handler_unittest.cc

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set callback to DoNothing close to where it's used Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_handler.h" 5 #include "chrome/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/captive_portal/captive_portal_service.h" 12 #include "chrome/browser/captive_portal/captive_portal_service.h"
13 #include "chrome/browser/net/certificate_error_reporter.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "components/captive_portal/captive_portal_testing_utils.h" 17 #include "components/captive_portal/captive_portal_testing_utils.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
19 #include "net/ssl/ssl_info.h" 20 #include "net/ssl/ssl_info.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 class TestSSLErrorHandler : public SSLErrorHandler { 23 class TestSSLErrorHandler : public SSLErrorHandler {
23 public: 24 public:
24 TestSSLErrorHandler(Profile* profile, 25 TestSSLErrorHandler(Profile* profile,
25 content::WebContents* web_contents, 26 content::WebContents* web_contents,
26 const net::SSLInfo& ssl_info) 27 const net::SSLInfo& ssl_info)
27 : SSLErrorHandler(web_contents, 28 : SSLErrorHandler(web_contents,
28 net::ERR_CERT_COMMON_NAME_INVALID, 29 net::ERR_CERT_COMMON_NAME_INVALID,
29 ssl_info, 30 ssl_info,
30 GURL(), 31 GURL(),
31 0, 32 0,
33 nullptr,
32 base::Callback<void(bool)>()), 34 base::Callback<void(bool)>()),
33 profile_(profile), 35 profile_(profile),
34 captive_portal_checked_(false), 36 captive_portal_checked_(false),
35 ssl_interstitial_shown_(false), 37 ssl_interstitial_shown_(false),
36 captive_portal_interstitial_shown_(false) { 38 captive_portal_interstitial_shown_(false) {}
37 }
38 39
39 ~TestSSLErrorHandler() override { 40 ~TestSSLErrorHandler() override {
40 } 41 }
41 42
42 using SSLErrorHandler::StartHandlingError; 43 using SSLErrorHandler::StartHandlingError;
43 44
44 void SendCaptivePortalNotification( 45 void SendCaptivePortalNotification(
45 captive_portal::CaptivePortalResult result) { 46 captive_portal::CaptivePortalResult result) {
46 CaptivePortalService::Results results; 47 CaptivePortalService::Results results;
47 results.previous_result = captive_portal::RESULT_INTERNET_CONNECTED; 48 results.previous_result = captive_portal::RESULT_INTERNET_CONNECTED;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 ShouldShowSSLInterstitialOnCaptivePortalDetectionDisabled) { 198 ShouldShowSSLInterstitialOnCaptivePortalDetectionDisabled) {
198 EXPECT_FALSE(error_handler()->IsTimerRunning()); 199 EXPECT_FALSE(error_handler()->IsTimerRunning());
199 error_handler()->StartHandlingError(); 200 error_handler()->StartHandlingError();
200 EXPECT_FALSE(error_handler()->IsTimerRunning()); 201 EXPECT_FALSE(error_handler()->IsTimerRunning());
201 EXPECT_FALSE(error_handler()->captive_portal_checked()); 202 EXPECT_FALSE(error_handler()->captive_portal_checked());
202 EXPECT_TRUE(error_handler()->ssl_interstitial_shown()); 203 EXPECT_TRUE(error_handler()->ssl_interstitial_shown());
203 EXPECT_FALSE(error_handler()->captive_portal_interstitial_shown()); 204 EXPECT_FALSE(error_handler()->captive_portal_interstitial_shown());
204 } 205 }
205 206
206 #endif // defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 207 #endif // defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698