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

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm

Issue 1440173003: Revert of Enable AutoResize for Constrained Web Dialogs for Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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) 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 "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" 5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_tabstrip.h" 9 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 BrowserWindowController* controller_; 70 BrowserWindowController* controller_;
71 NSView* tab_view0_; 71 NSView* tab_view0_;
72 NSView* tab_view1_; 72 NSView* tab_view1_;
73 }; 73 };
74 74
75 // Test that a sheet added to a inactive tab is not shown until the 75 // Test that a sheet added to a inactive tab is not shown until the
76 // tab is activated. 76 // tab is activated.
77 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) { 77 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) {
78 // Show dialog in non active tab. 78 // Show dialog in non active tab.
79 NiceMock<ConstrainedWindowDelegateMock> delegate; 79 NiceMock<ConstrainedWindowDelegateMock> delegate;
80 ConstrainedWindowMac* dialog = 80 ConstrainedWindowMac dialog(&delegate, tab0_, sheet_);
81 CreateAndShowWebModalDialogMac(&delegate, tab0_, sheet_);
82 EXPECT_EQ(0.0, [sheet_window_ alphaValue]); 81 EXPECT_EQ(0.0, [sheet_window_ alphaValue]);
83 82
84 // Switch to inactive tab. 83 // Switch to inactive tab.
85 browser()->tab_strip_model()->ActivateTabAt(0, true); 84 browser()->tab_strip_model()->ActivateTabAt(0, true);
86 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 85 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
87 86
88 dialog->CloseWebContentsModalDialog(); 87 dialog.CloseWebContentsModalDialog();
89 } 88 }
90 89
91 // If a tab has never been shown then the associated tab view for the web 90 // If a tab has never been shown then the associated tab view for the web
92 // content will not be created. Verify that adding a constrained window to such 91 // content will not be created. Verify that adding a constrained window to such
93 // a tab works correctly. 92 // a tab works correctly.
94 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) { 93 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) {
95 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( 94 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create(
96 content::WebContents::CreateParams(browser()->profile()))); 95 content::WebContents::CreateParams(browser()->profile())));
97 bool was_blocked = false; 96 bool was_blocked = false;
98 chrome::AddWebContents(browser(), NULL, web_contents.release(), 97 chrome::AddWebContents(browser(), NULL, web_contents.release(),
99 NEW_BACKGROUND_TAB, gfx::Rect(), false, &was_blocked); 98 NEW_BACKGROUND_TAB, gfx::Rect(), false, &was_blocked);
100 content::WebContents* tab2 = 99 content::WebContents* tab2 =
101 browser()->tab_strip_model()->GetWebContentsAt(2); 100 browser()->tab_strip_model()->GetWebContentsAt(2);
102 ASSERT_TRUE(tab2); 101 ASSERT_TRUE(tab2);
103 EXPECT_FALSE([tab2->GetNativeView() superview]); 102 EXPECT_FALSE([tab2->GetNativeView() superview]);
104 103
105 // Show dialog and verify that it's not visible yet. 104 // Show dialog and verify that it's not visible yet.
106 NiceMock<ConstrainedWindowDelegateMock> delegate; 105 NiceMock<ConstrainedWindowDelegateMock> delegate;
107 ConstrainedWindowMac* dialog = 106 ConstrainedWindowMac dialog(&delegate, tab2, sheet_);
108 CreateAndShowWebModalDialogMac(&delegate, tab2, sheet_);
109 EXPECT_FALSE([sheet_window_ isVisible]); 107 EXPECT_FALSE([sheet_window_ isVisible]);
110 108
111 // Activate the tab and verify that the constrained window is shown. 109 // Activate the tab and verify that the constrained window is shown.
112 browser()->tab_strip_model()->ActivateTabAt(2, true); 110 browser()->tab_strip_model()->ActivateTabAt(2, true);
113 EXPECT_TRUE([tab2->GetNativeView() superview]); 111 EXPECT_TRUE([tab2->GetNativeView() superview]);
114 EXPECT_TRUE([sheet_window_ isVisible]); 112 EXPECT_TRUE([sheet_window_ isVisible]);
115 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 113 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
116 114
117 dialog->CloseWebContentsModalDialog(); 115 dialog.CloseWebContentsModalDialog();
118 } 116 }
119 117
120 // Test that adding a sheet disables tab dragging. 118 // Test that adding a sheet disables tab dragging.
121 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) { 119 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) {
122 NiceMock<ConstrainedWindowDelegateMock> delegate; 120 NiceMock<ConstrainedWindowDelegateMock> delegate;
123 ConstrainedWindowMac* dialog = 121 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
124 CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_);
125 122
126 // Verify that the dialog disables dragging. 123 // Verify that the dialog disables dragging.
127 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]); 124 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]);
128 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]); 125 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]);
129 126
130 dialog->CloseWebContentsModalDialog(); 127 dialog.CloseWebContentsModalDialog();
131 } 128 }
132 129
133 // Test that closing a browser window with a sheet works. 130 // Test that closing a browser window with a sheet works.
134 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) { 131 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) {
135 NiceMock<ConstrainedWindowDelegateMock> delegate; 132 NiceMock<ConstrainedWindowDelegateMock> delegate;
136 CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_); 133 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
137 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 134 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
138 135
139 // Close the browser window. 136 // Close the browser window.
140 base::scoped_nsobject<NSWindow> browser_window( 137 base::scoped_nsobject<NSWindow> browser_window(
141 [browser()->window()->GetNativeWindow() retain]); 138 [browser()->window()->GetNativeWindow() retain]);
142 EXPECT_TRUE([browser_window isVisible]); 139 EXPECT_TRUE([browser_window isVisible]);
143 [browser()->window()->GetNativeWindow() performClose:nil]; 140 [browser()->window()->GetNativeWindow() performClose:nil];
144 EXPECT_FALSE([browser_window isVisible]); 141 EXPECT_FALSE([browser_window isVisible]);
145 } 142 }
146 143
147 // Test that closing a tab with a sheet works. 144 // Test that closing a tab with a sheet works.
148 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabClose) { 145 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabClose) {
149 NiceMock<ConstrainedWindowDelegateMock> delegate; 146 NiceMock<ConstrainedWindowDelegateMock> delegate;
150 CreateAndShowWebModalDialogMac(&delegate, tab1_, sheet_); 147 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
151 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 148 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
152 149
153 // Close the tab. 150 // Close the tab.
154 TabStripModel* tab_strip = browser()->tab_strip_model(); 151 TabStripModel* tab_strip = browser()->tab_strip_model();
155 EXPECT_EQ(2, tab_strip->count()); 152 EXPECT_EQ(2, tab_strip->count());
156 EXPECT_TRUE(tab_strip->CloseWebContentsAt(1, 153 EXPECT_TRUE(tab_strip->CloseWebContentsAt(1,
157 TabStripModel::CLOSE_USER_GESTURE)); 154 TabStripModel::CLOSE_USER_GESTURE));
158 EXPECT_EQ(1, tab_strip->count()); 155 EXPECT_EQ(1, tab_strip->count());
159 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698