OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/certificate_viewer.h" | 5 #import "chrome/browser/certificate_viewer.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/cocoa/certificate_viewer_mac.h" | 9 #include "chrome/browser/ui/cocoa/certificate_viewer_mac.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 IN_PROC_BROWSER_TEST_F(SSLCertificateViewerCocoaTest, Basic) { | 32 IN_PROC_BROWSER_TEST_F(SSLCertificateViewerCocoaTest, Basic) { |
33 scoped_refptr<net::X509Certificate> cert = GetSampleCertificate(); | 33 scoped_refptr<net::X509Certificate> cert = GetSampleCertificate(); |
34 ASSERT_TRUE(cert.get()); | 34 ASSERT_TRUE(cert.get()); |
35 content::WebContents* web_contents = | 35 content::WebContents* web_contents = |
36 browser()->tab_strip_model()->GetActiveWebContents(); | 36 browser()->tab_strip_model()->GetActiveWebContents(); |
37 gfx::NativeWindow window = web_contents->GetView()->GetTopLevelNativeWindow(); | 37 gfx::NativeWindow window = web_contents->GetView()->GetTopLevelNativeWindow(); |
38 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 38 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
39 WebContentsModalDialogManager::FromWebContents(web_contents); | 39 WebContentsModalDialogManager::FromWebContents(web_contents); |
40 EXPECT_FALSE(web_contents_modal_dialog_manager->IsShowingDialog()); | 40 EXPECT_FALSE(web_contents_modal_dialog_manager->IsShowingDialog()); |
41 | 41 |
42 ShowCertificateViewer(web_contents, window, cert); | 42 ShowCertificateViewer(web_contents, window, cert.get()); |
43 | 43 |
44 content::RunAllPendingInMessageLoop(); | 44 content::RunAllPendingInMessageLoop(); |
45 EXPECT_TRUE(web_contents_modal_dialog_manager->IsShowingDialog()); | 45 EXPECT_TRUE(web_contents_modal_dialog_manager->IsShowingDialog()); |
46 | 46 |
47 WebContentsModalDialogManager::TestApi test_api( | 47 WebContentsModalDialogManager::TestApi test_api( |
48 web_contents_modal_dialog_manager); | 48 web_contents_modal_dialog_manager); |
49 test_api.CloseAllDialogs(); | 49 test_api.CloseAllDialogs(); |
50 content::RunAllPendingInMessageLoop(); | 50 content::RunAllPendingInMessageLoop(); |
51 EXPECT_FALSE(web_contents_modal_dialog_manager->IsShowingDialog()); | 51 EXPECT_FALSE(web_contents_modal_dialog_manager->IsShowingDialog()); |
52 } | 52 } |
53 | 53 |
54 // Test that switching to another tab correctly hides the sheet. | 54 // Test that switching to another tab correctly hides the sheet. |
55 IN_PROC_BROWSER_TEST_F(SSLCertificateViewerCocoaTest, HideShow) { | 55 IN_PROC_BROWSER_TEST_F(SSLCertificateViewerCocoaTest, HideShow) { |
56 scoped_refptr<net::X509Certificate> cert = GetSampleCertificate(); | 56 scoped_refptr<net::X509Certificate> cert = GetSampleCertificate(); |
57 ASSERT_TRUE(cert.get()); | 57 ASSERT_TRUE(cert.get()); |
58 content::WebContents* web_contents = | 58 content::WebContents* web_contents = |
59 browser()->tab_strip_model()->GetActiveWebContents(); | 59 browser()->tab_strip_model()->GetActiveWebContents(); |
60 | 60 |
61 SSLCertificateViewerCocoa* viewer = | 61 SSLCertificateViewerCocoa* viewer = |
62 [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert]; | 62 [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert.get()]; |
63 [viewer displayForWebContents:web_contents]; | 63 [viewer displayForWebContents:web_contents]; |
64 | 64 |
65 content::RunAllPendingInMessageLoop(); | 65 content::RunAllPendingInMessageLoop(); |
66 | 66 |
67 NSWindow* sheetWindow = [[viewer overlayWindow] attachedSheet]; | 67 NSWindow* sheetWindow = [[viewer overlayWindow] attachedSheet]; |
68 NSRect sheetFrame = [sheetWindow frame]; | 68 NSRect sheetFrame = [sheetWindow frame]; |
69 EXPECT_EQ(1.0, [sheetWindow alphaValue]); | 69 EXPECT_EQ(1.0, [sheetWindow alphaValue]); |
70 | 70 |
71 // Switch to another tab and verify that the sheet is hidden. | 71 // Switch to another tab and verify that the sheet is hidden. |
72 AddBlankTabAndShow(browser()); | 72 AddBlankTabAndShow(browser()); |
73 EXPECT_EQ(0.0, [sheetWindow alphaValue]); | 73 EXPECT_EQ(0.0, [sheetWindow alphaValue]); |
74 EXPECT_TRUE( | 74 EXPECT_TRUE( |
75 NSEqualRects(ui::kWindowSizeDeterminedLater, [sheetWindow frame])); | 75 NSEqualRects(ui::kWindowSizeDeterminedLater, [sheetWindow frame])); |
76 | 76 |
77 // Switch back and verify that the sheet is shown. | 77 // Switch back and verify that the sheet is shown. |
78 chrome::SelectNumberedTab(browser(), 0); | 78 chrome::SelectNumberedTab(browser(), 0); |
79 EXPECT_EQ(1.0, [sheetWindow alphaValue]); | 79 EXPECT_EQ(1.0, [sheetWindow alphaValue]); |
80 EXPECT_TRUE(NSEqualRects(sheetFrame, [sheetWindow frame])); | 80 EXPECT_TRUE(NSEqualRects(sheetFrame, [sheetWindow frame])); |
81 } | 81 } |
OLD | NEW |