Chromium Code Reviews| Index: chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
| diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
| index a0c71106e6692e7941e9f90ba3cd50fc2e7e4115..30e8c487b57020f61d143644813eb28b02202146 100644 |
| --- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
| +++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm |
| @@ -8,12 +8,14 @@ |
| #include "base/bind.h" |
| #import "base/mac/mac_util.h" |
| +#include "base/macros.h" |
| #include "chrome/browser/ssl/ssl_client_certificate_selector.h" |
| #include "chrome/browser/ssl/ssl_client_certificate_selector_test.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_commands.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| +#include "content/public/browser/client_certificate_delegate.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/test/test_utils.h" |
| #include "ui/base/cocoa/window_size_constants.h" |
| @@ -22,12 +24,32 @@ using web_modal::WebContentsModalDialogManager; |
| namespace { |
| -void OnCertificateSelected(net::X509Certificate** out_cert, |
| - int* out_count, |
| - net::X509Certificate* cert) { |
| - *out_cert = cert; |
| - ++(*out_count); |
| -} |
| +class TestClientCertificateDelegate |
| + : public content::ClientCertificateDelegate { |
| + public: |
| + // Creates a ClientCertificateDelegate that sets |*destroyed| to true on |
| + // destruction. |
| + explicit TestClientCertificateDelegate(bool* destroyed) |
| + : destroyed_(destroyed) { } |
| + ~TestClientCertificateDelegate() { |
|
Ryan Sleevi
2015/02/25 06:31:36
override?
Ryan Sleevi
2015/02/25 06:31:36
newline
davidben
2015/02/26 18:09:41
Done.
davidben
2015/02/26 18:09:41
Done.
|
| + if (destroyed_ != nullptr) |
| + *destroyed_ = true; |
| + } |
| + |
| + // content::ClientCertificateDelegate. |
| + void ContinueWithCertificate(net::X509Certificate* cert) override { |
| + // TODO(davidben): Add a test which explicitly tests selecting a |
| + // certificate, or selecting no certificate, since closing the dialog |
| + // (normally by closing the tab) is not the same as explicitly selecting no |
| + // certificate. |
| + ADD_FAILURE() << "Certificate selected"; |
| + } |
| + |
| + private: |
| + bool* destroyed_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TestClientCertificateDelegate); |
| +}; |
| } // namespace |
| @@ -46,15 +68,13 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, DISABLED_Basic) { |
| WebContentsModalDialogManager::FromWebContents(web_contents); |
| EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); |
| - net::X509Certificate* cert = NULL; |
| - int count = 0; |
| - SSLClientCertificateSelectorCocoa* selector = |
| - [[SSLClientCertificateSelectorCocoa alloc] |
| - initWithBrowserContext:web_contents->GetBrowserContext() |
| - certRequestInfo:auth_requestor_->cert_request_info_.get() |
| - callback:base::Bind(&OnCertificateSelected, |
| - &cert, |
| - &count)]; |
| + bool destroyed = false; |
| + SSLClientCertificateSelectorCocoa* selector = [ |
| + [SSLClientCertificateSelectorCocoa alloc] |
| + initWithBrowserContext:web_contents->GetBrowserContext() |
| + certRequestInfo:auth_requestor_->cert_request_info_.get() |
| + delegate:make_scoped_ptr(new TestClientCertificateDelegate( |
| + &destroyed))]; |
| [selector displayForWebContents:web_contents]; |
| content::RunAllPendingInMessageLoop(); |
| EXPECT_TRUE([selector panel]); |
| @@ -66,19 +86,19 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, DISABLED_Basic) { |
| content::RunAllPendingInMessageLoop(); |
| EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); |
| - EXPECT_EQ(NULL, cert); |
| - EXPECT_EQ(1, count); |
| + EXPECT_TRUE(destroyed); |
| } |
| // Test that switching to another tab correctly hides the sheet. |
| IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) { |
| content::WebContents* web_contents = |
| browser()->tab_strip_model()->GetActiveWebContents(); |
| - SSLClientCertificateSelectorCocoa* selector = |
| - [[SSLClientCertificateSelectorCocoa alloc] |
| - initWithBrowserContext:web_contents->GetBrowserContext() |
| - certRequestInfo:auth_requestor_->cert_request_info_.get() |
| - callback:chrome::SelectCertificateCallback()]; |
| + SSLClientCertificateSelectorCocoa* selector = [ |
| + [SSLClientCertificateSelectorCocoa alloc] |
| + initWithBrowserContext:web_contents->GetBrowserContext() |
| + certRequestInfo:auth_requestor_->cert_request_info_.get() |
| + delegate:make_scoped_ptr(new TestClientCertificateDelegate( |
| + nullptr))]; |
| [selector displayForWebContents:web_contents]; |
| content::RunAllPendingInMessageLoop(); |