Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/ui/cocoa/certificate_viewer_mac_browsertest.mm

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move out ConstrainedWindowSheet to Cocoa-only, other review comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_cocoa.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "components/web_modal/web_contents_modal_dialog_manager.h" 12 #include "components/web_modal/web_contents_modal_dialog_manager.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/test_utils.h" 14 #include "content/public/test/test_utils.h"
15 #include "net/base/test_data_directory.h" 15 #include "net/base/test_data_directory.h"
16 #include "net/cert/x509_certificate.h" 16 #include "net/cert/x509_certificate.h"
17 #include "net/test/cert_test_util.h" 17 #include "net/test/cert_test_util.h"
18 #import "testing/gtest_mac.h" 18 #import "testing/gtest_mac.h"
19 #include "ui/base/cocoa/window_size_constants.h" 19 #include "ui/base/cocoa/window_size_constants.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); 51 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
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 // TODO(patricialor): Display the certificate viewer in a cross-toolkit manner
62 // and retrieve |sheetWindow| via the WebContentsModalDialogManager::TestApi.
63 // See https://crbug.com/613880.
61 SSLCertificateViewerCocoa* viewer = 64 SSLCertificateViewerCocoa* viewer =
62 [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert.get()]; 65 [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert.get()];
63 [viewer displayForWebContents:web_contents]; 66 [viewer displayForWebContents:web_contents];
64 67
65 content::RunAllPendingInMessageLoop(); 68 content::RunAllPendingInMessageLoop();
66 69
70 // TODO(patricialor): Remove the overlayWindow accessor from
71 // SSLCertificateViewerMac when the overlay is obtained via
72 // WebContentsModalDialogManager::TestApi instead - https://crbug.com/613880.
67 NSWindow* sheetWindow = [[viewer overlayWindow] attachedSheet]; 73 NSWindow* sheetWindow = [[viewer overlayWindow] attachedSheet];
68 NSRect sheetFrame = [sheetWindow frame]; 74 NSRect sheetFrame = [sheetWindow frame];
69 EXPECT_EQ(1.0, [sheetWindow alphaValue]); 75 EXPECT_EQ(1.0, [sheetWindow alphaValue]);
70 76
71 // Switch to another tab and verify that the sheet is hidden. 77 // Switch to another tab and verify that the sheet is hidden.
72 AddBlankTabAndShow(browser()); 78 AddBlankTabAndShow(browser());
73 EXPECT_EQ(0.0, [sheetWindow alphaValue]); 79 EXPECT_EQ(0.0, [sheetWindow alphaValue]);
74 EXPECT_NSEQ(sheetFrame, [sheetWindow frame]); 80 EXPECT_NSEQ(sheetFrame, [sheetWindow frame]);
75 81
76 // Switch back and verify that the sheet is shown. 82 // Switch back and verify that the sheet is shown.
77 chrome::SelectNumberedTab(browser(), 0); 83 chrome::SelectNumberedTab(browser(), 0);
84 content::RunAllPendingInMessageLoop();
78 EXPECT_EQ(1.0, [sheetWindow alphaValue]); 85 EXPECT_EQ(1.0, [sheetWindow alphaValue]);
79 EXPECT_NSEQ(sheetFrame, [sheetWindow frame]); 86 EXPECT_NSEQ(sheetFrame, [sheetWindow frame]);
80 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698