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

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

Issue 11647017: Rename platform-independent ConstrainedWindow types to WebContentsModalDialog types (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stage changes to preserve history Created 8 years 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 | Annotate | Revision Log
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/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) { 78 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) {
79 // Show dialog in non active tab. 79 // Show dialog in non active tab.
80 NiceMock<ConstrainedWindowDelegateMock> delegate; 80 NiceMock<ConstrainedWindowDelegateMock> delegate;
81 ConstrainedWindowMac dialog(&delegate, tab0_, sheet_); 81 ConstrainedWindowMac dialog(&delegate, tab0_, sheet_);
82 EXPECT_EQ(0.0, [sheet_window_ alphaValue]); 82 EXPECT_EQ(0.0, [sheet_window_ alphaValue]);
83 83
84 // Switch to inactive tab. 84 // Switch to inactive tab.
85 browser()->tab_strip_model()->ActivateTabAt(0, true); 85 browser()->tab_strip_model()->ActivateTabAt(0, true);
86 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 86 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
87 87
88 dialog.CloseConstrainedWindow(); 88 dialog.CloseWebContentsModalDialog();
89 } 89 }
90 90
91 // If a tab has never been shown then the associated tab view for the web 91 // 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 92 // content will not be created. Verify that adding a constrained window to such
93 // a tab works correctly. 93 // a tab works correctly.
94 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) { 94 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) {
95 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( 95 scoped_ptr<content::WebContents> web_contents(content::WebContents::Create(
96 content::WebContents::CreateParams(browser()->profile()))); 96 content::WebContents::CreateParams(browser()->profile())));
97 bool was_blocked = false; 97 bool was_blocked = false;
98 chrome::AddWebContents(browser(), NULL, web_contents.release(), 98 chrome::AddWebContents(browser(), NULL, web_contents.release(),
99 NEW_BACKGROUND_TAB, gfx::Rect(), false, &was_blocked); 99 NEW_BACKGROUND_TAB, gfx::Rect(), false, &was_blocked);
100 content::WebContents* tab2 = 100 content::WebContents* tab2 =
101 browser()->tab_strip_model()->GetWebContentsAt(2); 101 browser()->tab_strip_model()->GetWebContentsAt(2);
102 ASSERT_TRUE(tab2); 102 ASSERT_TRUE(tab2);
103 EXPECT_FALSE([tab2->GetNativeView() superview]); 103 EXPECT_FALSE([tab2->GetNativeView() superview]);
104 104
105 // Show dialog and verify that it's not visible yet. 105 // Show dialog and verify that it's not visible yet.
106 NiceMock<ConstrainedWindowDelegateMock> delegate; 106 NiceMock<ConstrainedWindowDelegateMock> delegate;
107 ConstrainedWindowMac dialog(&delegate, tab2, sheet_); 107 ConstrainedWindowMac dialog(&delegate, tab2, sheet_);
108 EXPECT_FALSE([sheet_window_ isVisible]); 108 EXPECT_FALSE([sheet_window_ isVisible]);
109 109
110 // Activate the tab and verify that the constrained window is shown. 110 // Activate the tab and verify that the constrained window is shown.
111 browser()->tab_strip_model()->ActivateTabAt(2, true); 111 browser()->tab_strip_model()->ActivateTabAt(2, true);
112 EXPECT_TRUE([tab2->GetNativeView() superview]); 112 EXPECT_TRUE([tab2->GetNativeView() superview]);
113 EXPECT_TRUE([sheet_window_ isVisible]); 113 EXPECT_TRUE([sheet_window_ isVisible]);
114 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 114 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
115 115
116 dialog.CloseConstrainedWindow(); 116 dialog.CloseWebContentsModalDialog();
117 } 117 }
118 118
119 // Test that adding a sheet disables tab dragging. 119 // Test that adding a sheet disables tab dragging.
120 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) { 120 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, TabDragging) {
121 NiceMock<ConstrainedWindowDelegateMock> delegate; 121 NiceMock<ConstrainedWindowDelegateMock> delegate;
122 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_); 122 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
123 123
124 // Verify that the dialog disables dragging. 124 // Verify that the dialog disables dragging.
125 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]); 125 EXPECT_TRUE([controller_ isTabDraggable:tab_view0_]);
126 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]); 126 EXPECT_FALSE([controller_ isTabDraggable:tab_view1_]);
127 127
128 dialog.CloseConstrainedWindow(); 128 dialog.CloseWebContentsModalDialog();
129 } 129 }
130 130
131 // Test that closing a browser window with a sheet works. 131 // Test that closing a browser window with a sheet works.
132 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) { 132 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, BrowserWindowClose) {
133 NiceMock<ConstrainedWindowDelegateMock> delegate; 133 NiceMock<ConstrainedWindowDelegateMock> delegate;
134 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_); 134 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
135 EXPECT_EQ(1.0, [sheet_window_ alphaValue]); 135 EXPECT_EQ(1.0, [sheet_window_ alphaValue]);
136 136
137 // Close the browser window. 137 // Close the browser window.
138 scoped_nsobject<NSWindow> browser_window( 138 scoped_nsobject<NSWindow> browser_window(
(...skipping 19 matching lines...) Expand all
158 // Test that adding a sheet disables fullscreen. 158 // Test that adding a sheet disables fullscreen.
159 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, Fullscreen) { 159 IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, Fullscreen) {
160 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 160 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
161 161
162 // Dialog will delete it self when closed. 162 // Dialog will delete it self when closed.
163 NiceMock<ConstrainedWindowDelegateMock> delegate; 163 NiceMock<ConstrainedWindowDelegateMock> delegate;
164 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_); 164 ConstrainedWindowMac dialog(&delegate, tab1_, sheet_);
165 165
166 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 166 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
167 167
168 dialog.CloseConstrainedWindow(); 168 dialog.CloseWebContentsModalDialog();
169 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698