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 #import "chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa.h" |
6 | 6 |
7 #import <SecurityInterface/SFChooseIdentityPanel.h> | 7 #import <SecurityInterface/SFChooseIdentityPanel.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #import "base/mac/mac_util.h" | 10 #import "base/mac/mac_util.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 return; | 41 return; |
42 | 42 |
43 content::WebContents* web_contents = | 43 content::WebContents* web_contents = |
44 browser()->tab_strip_model()->GetActiveWebContents(); | 44 browser()->tab_strip_model()->GetActiveWebContents(); |
45 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 45 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
46 WebContentsModalDialogManager::FromWebContents(web_contents); | 46 WebContentsModalDialogManager::FromWebContents(web_contents); |
47 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); | 47 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); |
48 | 48 |
49 net::X509Certificate* cert = NULL; | 49 net::X509Certificate* cert = NULL; |
50 int count = 0; | 50 int count = 0; |
51 SSLClientCertificateSelectorCocoa* selector = | 51 SSLClientCertificateSelectorCocoa* selector = [ |
Lei Zhang
2014/09/19 18:38:59
nit: is this the preferred objc style?
dcheng
2014/09/19 19:23:47
I'm not sure. It looks like the formatter is aware
Robert Sesek
2014/09/19 20:26:01
clang-format technically has support for ObjC, but
| |
52 [[SSLClientCertificateSelectorCocoa alloc] | 52 [SSLClientCertificateSelectorCocoa alloc] |
53 initWithNetworkSession:auth_requestor_->http_network_session_ | 53 initWithNetworkSession:auth_requestor_->http_network_session_ |
54 certRequestInfo:auth_requestor_->cert_request_info_ | 54 certRequestInfo:auth_requestor_->cert_request_info_.get() |
55 callback:base::Bind(&OnCertificateSelected, | 55 callback:base::Bind(&OnCertificateSelected, &cert, &count)]; |
56 &cert, | |
57 &count)]; | |
58 [selector displayForWebContents:web_contents]; | 56 [selector displayForWebContents:web_contents]; |
59 content::RunAllPendingInMessageLoop(); | 57 content::RunAllPendingInMessageLoop(); |
60 EXPECT_TRUE([selector panel]); | 58 EXPECT_TRUE([selector panel]); |
61 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); | 59 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); |
62 | 60 |
63 WebContentsModalDialogManager::TestApi test_api( | 61 WebContentsModalDialogManager::TestApi test_api( |
64 web_contents_modal_dialog_manager); | 62 web_contents_modal_dialog_manager); |
65 test_api.CloseAllDialogs(); | 63 test_api.CloseAllDialogs(); |
66 content::RunAllPendingInMessageLoop(); | 64 content::RunAllPendingInMessageLoop(); |
67 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); | 65 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); |
68 | 66 |
69 EXPECT_EQ(NULL, cert); | 67 EXPECT_EQ(NULL, cert); |
70 EXPECT_EQ(1, count); | 68 EXPECT_EQ(1, count); |
71 } | 69 } |
72 | 70 |
73 // Test that switching to another tab correctly hides the sheet. | 71 // Test that switching to another tab correctly hides the sheet. |
74 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) { | 72 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) { |
75 SSLClientCertificateSelectorCocoa* selector = | 73 SSLClientCertificateSelectorCocoa* selector = |
76 [[SSLClientCertificateSelectorCocoa alloc] | 74 [[SSLClientCertificateSelectorCocoa alloc] |
77 initWithNetworkSession:auth_requestor_->http_network_session_ | 75 initWithNetworkSession:auth_requestor_->http_network_session_ |
78 certRequestInfo:auth_requestor_->cert_request_info_ | 76 certRequestInfo:auth_requestor_->cert_request_info_.get() |
79 callback:chrome::SelectCertificateCallback()]; | 77 callback:chrome::SelectCertificateCallback()]; |
80 content::WebContents* web_contents = | 78 content::WebContents* web_contents = |
81 browser()->tab_strip_model()->GetActiveWebContents(); | 79 browser()->tab_strip_model()->GetActiveWebContents(); |
82 [selector displayForWebContents:web_contents]; | 80 [selector displayForWebContents:web_contents]; |
83 content::RunAllPendingInMessageLoop(); | 81 content::RunAllPendingInMessageLoop(); |
84 | 82 |
85 NSWindow* sheetWindow = [[selector overlayWindow] attachedSheet]; | 83 NSWindow* sheetWindow = [[selector overlayWindow] attachedSheet]; |
86 NSRect sheetFrame = [sheetWindow frame]; | 84 NSRect sheetFrame = [sheetWindow frame]; |
87 EXPECT_EQ(1.0, [sheetWindow alphaValue]); | 85 EXPECT_EQ(1.0, [sheetWindow alphaValue]); |
88 | 86 |
89 // Switch to another tab and verify that the sheet is hidden. | 87 // Switch to another tab and verify that the sheet is hidden. |
90 AddBlankTabAndShow(browser()); | 88 AddBlankTabAndShow(browser()); |
91 EXPECT_EQ(0.0, [sheetWindow alphaValue]); | 89 EXPECT_EQ(0.0, [sheetWindow alphaValue]); |
92 EXPECT_TRUE(NSEqualRects(ui::kWindowSizeDeterminedLater, | 90 EXPECT_TRUE(NSEqualRects(ui::kWindowSizeDeterminedLater, |
93 [sheetWindow frame])); | 91 [sheetWindow frame])); |
94 | 92 |
95 // Switch back and verify that the sheet is shown. | 93 // Switch back and verify that the sheet is shown. |
96 chrome::SelectNumberedTab(browser(), 0); | 94 chrome::SelectNumberedTab(browser(), 0); |
97 EXPECT_EQ(1.0, [sheetWindow alphaValue]); | 95 EXPECT_EQ(1.0, [sheetWindow alphaValue]); |
98 EXPECT_TRUE(NSEqualRects(sheetFrame, [sheetWindow frame])); | 96 EXPECT_TRUE(NSEqualRects(sheetFrame, [sheetWindow frame])); |
99 } | 97 } |
OLD | NEW |