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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" | 10 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); | 76 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); |
77 cert_request_info_->client_certs.push_back(client_cert_1_); | 77 cert_request_info_->client_certs.push_back(client_cert_1_); |
78 cert_request_info_->client_certs.push_back(client_cert_2_); | 78 cert_request_info_->client_certs.push_back(client_cert_2_); |
79 } | 79 } |
80 | 80 |
81 void SetUpOnMainThread() override { | 81 void SetUpOnMainThread() override { |
82 url_request_context_getter_ = browser()->profile()->GetRequestContext(); | 82 url_request_context_getter_ = browser()->profile()->GetRequestContext(); |
83 | 83 |
84 BrowserThread::PostTask( | 84 BrowserThread::PostTask( |
85 BrowserThread::IO, FROM_HERE, | 85 BrowserThread::IO, FROM_HERE, |
86 base::Bind(&SSLClientCertificateSelectorTest::SetUpOnIOThread, | 86 base::BindOnce(&SSLClientCertificateSelectorTest::SetUpOnIOThread, |
87 base::Unretained(this))); | 87 base::Unretained(this))); |
88 | 88 |
89 io_loop_finished_event_.Wait(); | 89 io_loop_finished_event_.Wait(); |
90 | 90 |
91 content::WaitForLoadStop( | 91 content::WaitForLoadStop( |
92 browser()->tab_strip_model()->GetActiveWebContents()); | 92 browser()->tab_strip_model()->GetActiveWebContents()); |
93 selector_ = new SSLClientCertificateSelector( | 93 selector_ = new SSLClientCertificateSelector( |
94 browser()->tab_strip_model()->GetActiveWebContents(), | 94 browser()->tab_strip_model()->GetActiveWebContents(), |
95 auth_requestor_->cert_request_info_, auth_requestor_->CreateDelegate()); | 95 auth_requestor_->cert_request_info_, auth_requestor_->CreateDelegate()); |
96 selector_->Init(); | 96 selector_->Init(); |
97 selector_->Show(); | 97 selector_->Show(); |
98 | 98 |
99 EXPECT_EQ(client_cert_1_.get(), selector_->GetSelectedCert()); | 99 EXPECT_EQ(client_cert_1_.get(), selector_->GetSelectedCert()); |
100 } | 100 } |
101 | 101 |
102 virtual void SetUpOnIOThread() { | 102 virtual void SetUpOnIOThread() { |
103 url_request_ = MakeURLRequest(url_request_context_getter_.get()).release(); | 103 url_request_ = MakeURLRequest(url_request_context_getter_.get()).release(); |
104 | 104 |
105 auth_requestor_ = new StrictMock<SSLClientAuthRequestorMock>( | 105 auth_requestor_ = new StrictMock<SSLClientAuthRequestorMock>( |
106 url_request_, | 106 url_request_, |
107 cert_request_info_); | 107 cert_request_info_); |
108 | 108 |
109 io_loop_finished_event_.Signal(); | 109 io_loop_finished_event_.Signal(); |
110 } | 110 } |
111 | 111 |
112 // Have to release our reference to the auth handler during the test to allow | 112 // Have to release our reference to the auth handler during the test to allow |
113 // it to be destroyed while the Browser and its IO thread still exist. | 113 // it to be destroyed while the Browser and its IO thread still exist. |
114 void TearDownOnMainThread() override { | 114 void TearDownOnMainThread() override { |
115 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
116 BrowserThread::IO, FROM_HERE, | 116 BrowserThread::IO, FROM_HERE, |
117 base::Bind(&SSLClientCertificateSelectorTest::CleanUpOnIOThread, | 117 base::BindOnce(&SSLClientCertificateSelectorTest::CleanUpOnIOThread, |
118 base::Unretained(this))); | 118 base::Unretained(this))); |
119 | 119 |
120 io_loop_finished_event_.Wait(); | 120 io_loop_finished_event_.Wait(); |
121 | 121 |
122 auth_requestor_ = NULL; | 122 auth_requestor_ = NULL; |
123 } | 123 } |
124 | 124 |
125 virtual void CleanUpOnIOThread() { | 125 virtual void CleanUpOnIOThread() { |
126 delete url_request_; | 126 delete url_request_; |
127 | 127 |
128 io_loop_finished_event_.Signal(); | 128 io_loop_finished_event_.Signal(); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 396 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
397 browser_1_, ui::VKEY_RETURN, false, false, false, false)); | 397 browser_1_, ui::VKEY_RETURN, false, false, false, false)); |
398 | 398 |
399 Mock::VerifyAndClear(auth_requestor_.get()); | 399 Mock::VerifyAndClear(auth_requestor_.get()); |
400 Mock::VerifyAndClear(auth_requestor_1_.get()); | 400 Mock::VerifyAndClear(auth_requestor_1_.get()); |
401 | 401 |
402 // Now let the default selection for auth_requestor_ mock get checked on | 402 // Now let the default selection for auth_requestor_ mock get checked on |
403 // destruction. | 403 // destruction. |
404 EXPECT_CALL(*auth_requestor_.get(), CancelCertificateSelection()); | 404 EXPECT_CALL(*auth_requestor_.get(), CancelCertificateSelection()); |
405 } | 405 } |
OLD | NEW |