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 "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" | 9 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 BrowserThread::PostTask( | 66 BrowserThread::PostTask( |
67 BrowserThread::IO, FROM_HERE, | 67 BrowserThread::IO, FROM_HERE, |
68 base::Bind(&SSLClientCertificateSelectorTest::SetUpOnIOThread, this)); | 68 base::Bind(&SSLClientCertificateSelectorTest::SetUpOnIOThread, this)); |
69 | 69 |
70 io_loop_finished_event_.Wait(); | 70 io_loop_finished_event_.Wait(); |
71 | 71 |
72 content::WaitForLoadStop( | 72 content::WaitForLoadStop( |
73 browser()->tab_strip_model()->GetActiveWebContents()); | 73 browser()->tab_strip_model()->GetActiveWebContents()); |
74 selector_ = new SSLClientCertificateSelector( | 74 selector_ = new SSLClientCertificateSelector( |
75 browser()->tab_strip_model()->GetActiveWebContents(), | 75 browser()->tab_strip_model()->GetActiveWebContents(), |
76 auth_requestor_->http_network_session_, | |
77 auth_requestor_->cert_request_info_, | 76 auth_requestor_->cert_request_info_, |
78 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 77 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
79 auth_requestor_)); | 78 auth_requestor_)); |
80 selector_->Init(); | 79 selector_->Init(); |
81 | 80 |
82 EXPECT_EQ(mit_davidben_cert_.get(), selector_->GetSelectedCert()); | 81 EXPECT_EQ(mit_davidben_cert_.get(), selector_->GetSelectedCert()); |
83 } | 82 } |
84 | 83 |
85 virtual void SetUpOnIOThread() { | 84 virtual void SetUpOnIOThread() { |
86 url_request_ = MakeURLRequest(url_request_context_getter_.get()).release(); | 85 url_request_ = MakeURLRequest(url_request_context_getter_.get()).release(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 AddTabAtIndex(1, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); | 153 AddTabAtIndex(1, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); |
155 AddTabAtIndex(2, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); | 154 AddTabAtIndex(2, GURL("about:blank"), ui::PAGE_TRANSITION_LINK); |
156 ASSERT_TRUE(NULL != browser()->tab_strip_model()->GetWebContentsAt(0)); | 155 ASSERT_TRUE(NULL != browser()->tab_strip_model()->GetWebContentsAt(0)); |
157 ASSERT_TRUE(NULL != browser()->tab_strip_model()->GetWebContentsAt(1)); | 156 ASSERT_TRUE(NULL != browser()->tab_strip_model()->GetWebContentsAt(1)); |
158 ASSERT_TRUE(NULL != browser()->tab_strip_model()->GetWebContentsAt(2)); | 157 ASSERT_TRUE(NULL != browser()->tab_strip_model()->GetWebContentsAt(2)); |
159 content::WaitForLoadStop(browser()->tab_strip_model()->GetWebContentsAt(1)); | 158 content::WaitForLoadStop(browser()->tab_strip_model()->GetWebContentsAt(1)); |
160 content::WaitForLoadStop(browser()->tab_strip_model()->GetWebContentsAt(2)); | 159 content::WaitForLoadStop(browser()->tab_strip_model()->GetWebContentsAt(2)); |
161 | 160 |
162 selector_1_ = new SSLClientCertificateSelector( | 161 selector_1_ = new SSLClientCertificateSelector( |
163 browser()->tab_strip_model()->GetWebContentsAt(1), | 162 browser()->tab_strip_model()->GetWebContentsAt(1), |
164 auth_requestor_1_->http_network_session_, | |
165 auth_requestor_1_->cert_request_info_, | 163 auth_requestor_1_->cert_request_info_, |
166 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 164 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
167 auth_requestor_1_)); | 165 auth_requestor_1_)); |
168 selector_1_->Init(); | 166 selector_1_->Init(); |
169 selector_2_ = new SSLClientCertificateSelector( | 167 selector_2_ = new SSLClientCertificateSelector( |
170 browser()->tab_strip_model()->GetWebContentsAt(2), | 168 browser()->tab_strip_model()->GetWebContentsAt(2), |
171 auth_requestor_2_->http_network_session_, | |
172 auth_requestor_2_->cert_request_info_, | 169 auth_requestor_2_->cert_request_info_, |
173 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 170 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
174 auth_requestor_2_)); | 171 auth_requestor_2_)); |
175 selector_2_->Init(); | 172 selector_2_->Init(); |
176 | 173 |
177 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 174 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
178 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); | 175 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); |
179 EXPECT_EQ(mit_davidben_cert_.get(), selector_2_->GetSelectedCert()); | 176 EXPECT_EQ(mit_davidben_cert_.get(), selector_2_->GetSelectedCert()); |
180 } | 177 } |
181 | 178 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 229 |
233 virtual void SetUpOnMainThread() override { | 230 virtual void SetUpOnMainThread() override { |
234 browser_1_ = CreateIncognitoBrowser(); | 231 browser_1_ = CreateIncognitoBrowser(); |
235 url_request_context_getter_1_ = browser_1_->profile()->GetRequestContext(); | 232 url_request_context_getter_1_ = browser_1_->profile()->GetRequestContext(); |
236 | 233 |
237 // Also calls SetUpOnIOThread. | 234 // Also calls SetUpOnIOThread. |
238 SSLClientCertificateSelectorTest::SetUpOnMainThread(); | 235 SSLClientCertificateSelectorTest::SetUpOnMainThread(); |
239 | 236 |
240 selector_1_ = new SSLClientCertificateSelector( | 237 selector_1_ = new SSLClientCertificateSelector( |
241 browser_1_->tab_strip_model()->GetActiveWebContents(), | 238 browser_1_->tab_strip_model()->GetActiveWebContents(), |
242 auth_requestor_1_->http_network_session_, | |
243 auth_requestor_1_->cert_request_info_, | 239 auth_requestor_1_->cert_request_info_, |
244 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 240 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
245 auth_requestor_1_)); | 241 auth_requestor_1_)); |
246 selector_1_->Init(); | 242 selector_1_->Init(); |
247 | 243 |
248 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); | 244 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); |
249 } | 245 } |
250 | 246 |
251 virtual void SetUpOnIOThread() override { | 247 virtual void SetUpOnIOThread() override { |
252 url_request_1_ = | 248 url_request_1_ = |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 386 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
391 browser_1_, ui::VKEY_RETURN, false, false, false, false)); | 387 browser_1_, ui::VKEY_RETURN, false, false, false, false)); |
392 | 388 |
393 Mock::VerifyAndClear(auth_requestor_.get()); | 389 Mock::VerifyAndClear(auth_requestor_.get()); |
394 Mock::VerifyAndClear(auth_requestor_1_.get()); | 390 Mock::VerifyAndClear(auth_requestor_1_.get()); |
395 | 391 |
396 // Now let the default selection for auth_requestor_ mock get checked on | 392 // Now let the default selection for auth_requestor_ mock get checked on |
397 // destruction. | 393 // destruction. |
398 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); | 394 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
399 } | 395 } |
OLD | NEW |