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

Side by Side Diff: chrome/browser/blocked_popup_container_interactive_uitest.cc

Issue 193047: Fix to use FilePath version of PathService::Get.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « base/file_version_info_unittest.cc ('k') | chrome/browser/dom_ui/chrome_url_data_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 <string> 5 #include <string>
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/gfx/rect.h" 9 #include "base/gfx/rect.h"
10 #include "chrome/browser/view_ids.h" 10 #include "chrome/browser/view_ids.h"
(...skipping 19 matching lines...) Expand all
30 browser_ = automation()->GetBrowserWindow(0); 30 browser_ = automation()->GetBrowserWindow(0);
31 ASSERT_TRUE(browser_.get()); 31 ASSERT_TRUE(browser_.get());
32 32
33 window_ = browser_->GetWindow(); 33 window_ = browser_->GetWindow();
34 ASSERT_TRUE(window_.get()); 34 ASSERT_TRUE(window_.get());
35 35
36 tab_ = browser_->GetTab(0); 36 tab_ = browser_->GetTab(0);
37 ASSERT_TRUE(tab_.get()); 37 ASSERT_TRUE(tab_.get());
38 } 38 }
39 39
40 void NavigateMainTabTo(const std::wstring& file_name) { 40 void NavigateMainTabTo(const std::string& file_name) {
41 FilePath filename(test_data_directory_); 41 FilePath filename(test_data_directory_);
42 filename = filename.AppendASCII("constrained_files"); 42 filename = filename.AppendASCII("constrained_files");
43 filename = filename.Append(FilePath::FromWStringHack(file_name)); 43 filename = filename.AppendASCII(file_name);
44 ASSERT_TRUE(tab_->NavigateToURL(net::FilePathToFileURL(filename))); 44 ASSERT_TRUE(tab_->NavigateToURL(net::FilePathToFileURL(filename)));
45 } 45 }
46 46
47 void SimulateClickInCenterOf(const scoped_refptr<WindowProxy>& window) { 47 void SimulateClickInCenterOf(const scoped_refptr<WindowProxy>& window) {
48 gfx::Rect tab_view_bounds; 48 gfx::Rect tab_view_bounds;
49 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, 49 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER,
50 &tab_view_bounds, true)); 50 &tab_view_bounds, true));
51 51
52 // Simulate a click of the actual link to force user_gesture to be 52 // Simulate a click of the actual link to force user_gesture to be
53 // true; if we don't, the resulting popup will be constrained, which 53 // true; if we don't, the resulting popup will be constrained, which
54 // isn't what we want to test. 54 // isn't what we want to test.
55 ASSERT_TRUE(window->SimulateOSClick(tab_view_bounds.CenterPoint(), 55 ASSERT_TRUE(window->SimulateOSClick(tab_view_bounds.CenterPoint(),
56 views::Event::EF_LEFT_BUTTON_DOWN)); 56 views::Event::EF_LEFT_BUTTON_DOWN));
57 } 57 }
58 58
59 scoped_refptr<BrowserProxy> browser_; 59 scoped_refptr<BrowserProxy> browser_;
60 scoped_refptr<WindowProxy> window_; 60 scoped_refptr<WindowProxy> window_;
61 scoped_refptr<TabProxy> tab_; 61 scoped_refptr<TabProxy> tab_;
62 }; 62 };
63 63
64 TEST_F(BlockedPopupContainerInteractiveTest, TestOpenAndResizeTo) { 64 TEST_F(BlockedPopupContainerInteractiveTest, TestOpenAndResizeTo) {
65 NavigateMainTabTo(L"constrained_window_onload_resizeto.html"); 65 NavigateMainTabTo("constrained_window_onload_resizeto.html");
66 SimulateClickInCenterOf(window_); 66 SimulateClickInCenterOf(window_);
67 67
68 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); 68 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));
69 69
70 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 70 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
71 ASSERT_TRUE(popup_browser != NULL); 71 ASSERT_TRUE(popup_browser != NULL);
72 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); 72 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow());
73 ASSERT_TRUE(popup_window != NULL); 73 ASSERT_TRUE(popup_window != NULL);
74 74
75 // Make sure we were created with the correct width and height. 75 // Make sure we were created with the correct width and height.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 number += title[offset]; 133 number += title[offset];
134 offset++; 134 offset++;
135 } 135 }
136 136
137 return StringToInt(WideToUTF16(number), output); 137 return StringToInt(WideToUTF16(number), output);
138 } 138 }
139 139
140 // Tests that in the window.open() equivalent of a fork bomb, we stop building 140 // Tests that in the window.open() equivalent of a fork bomb, we stop building
141 // windows. 141 // windows.
142 TEST_F(BlockedPopupContainerInteractiveTest, DontSpawnEndlessPopups) { 142 TEST_F(BlockedPopupContainerInteractiveTest, DontSpawnEndlessPopups) {
143 NavigateMainTabTo(L"infinite_popups.html"); 143 NavigateMainTabTo("infinite_popups.html");
144 SimulateClickInCenterOf(window_); 144 SimulateClickInCenterOf(window_);
145 145
146 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); 146 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));
147 147
148 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 148 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
149 ASSERT_TRUE(popup_browser.get()); 149 ASSERT_TRUE(popup_browser.get());
150 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); 150 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0));
151 ASSERT_TRUE(popup_tab.get()); 151 ASSERT_TRUE(popup_tab.get());
152 152
153 // And now we spin, waiting to make sure that we don't spawn popup 153 // And now we spin, waiting to make sure that we don't spawn popup
(...skipping 22 matching lines...) Expand all
176 176
177 EXPECT_GE(new_popup_window_count, popup_window_count); 177 EXPECT_GE(new_popup_window_count, popup_window_count);
178 EXPECT_LE(new_popup_window_count, kMaxPopupWindows); 178 EXPECT_LE(new_popup_window_count, kMaxPopupWindows);
179 popup_window_count = new_popup_window_count; 179 popup_window_count = new_popup_window_count;
180 } 180 }
181 } 181 }
182 182
183 // Make sure that we refuse to close windows when a constrained popup is 183 // Make sure that we refuse to close windows when a constrained popup is
184 // displayed. 184 // displayed.
185 TEST_F(BlockedPopupContainerInteractiveTest, WindowOpenWindowClosePopup) { 185 TEST_F(BlockedPopupContainerInteractiveTest, WindowOpenWindowClosePopup) {
186 NavigateMainTabTo(L"openclose_main.html"); 186 NavigateMainTabTo("openclose_main.html");
187 SimulateClickInCenterOf(window_); 187 SimulateClickInCenterOf(window_);
188 188
189 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); 189 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000));
190 190
191 // Make sure we have a blocked popup notification 191 // Make sure we have a blocked popup notification
192 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 192 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
193 ASSERT_TRUE(popup_browser.get()); 193 ASSERT_TRUE(popup_browser.get());
194 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); 194 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow());
195 ASSERT_TRUE(popup_window.get()); 195 ASSERT_TRUE(popup_window.get());
196 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); 196 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0));
197 ASSERT_TRUE(popup_tab.get()); 197 ASSERT_TRUE(popup_tab.get());
198 ASSERT_TRUE(popup_tab->WaitForBlockedPopupCountToChangeTo(1, 1000)); 198 ASSERT_TRUE(popup_tab->WaitForBlockedPopupCountToChangeTo(1, 1000));
199 199
200 // Ensure we didn't close the first popup window. 200 // Ensure we didn't close the first popup window.
201 ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 3000)); 201 ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 3000));
202 } 202 }
203 203
204 TEST_F(BlockedPopupContainerInteractiveTest, BlockAlertFromBlockedPopup) { 204 TEST_F(BlockedPopupContainerInteractiveTest, BlockAlertFromBlockedPopup) {
205 NavigateMainTabTo(L"block_alert.html"); 205 NavigateMainTabTo("block_alert.html");
206 206
207 // Wait for there to be an app modal dialog (and fail if it's shown). 207 // Wait for there to be an app modal dialog (and fail if it's shown).
208 ASSERT_FALSE(automation()->WaitForAppModalDialog(4000)); 208 ASSERT_FALSE(automation()->WaitForAppModalDialog(4000));
209 209
210 // Ensure one browser window. 210 // Ensure one browser window.
211 int browser_window_count; 211 int browser_window_count;
212 ASSERT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count)); 212 ASSERT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count));
213 ASSERT_EQ(1, browser_window_count); 213 ASSERT_EQ(1, browser_window_count);
214 214
215 // Ensure one blocked popup window: the popup didn't escape. 215 // Ensure one blocked popup window: the popup didn't escape.
216 int popup_count = 0; 216 int popup_count = 0;
217 ASSERT_TRUE(tab_->GetBlockedPopupCount(&popup_count)); 217 ASSERT_TRUE(tab_->GetBlockedPopupCount(&popup_count));
218 ASSERT_EQ(1, popup_count); 218 ASSERT_EQ(1, popup_count);
219 } 219 }
220 220
221 TEST_F(BlockedPopupContainerInteractiveTest, ShowAlertFromNormalPopup) { 221 TEST_F(BlockedPopupContainerInteractiveTest, ShowAlertFromNormalPopup) {
222 NavigateMainTabTo(L"show_alert.html"); 222 NavigateMainTabTo("show_alert.html");
223 SimulateClickInCenterOf(window_); 223 SimulateClickInCenterOf(window_);
224 224
225 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); 225 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000));
226 226
227 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 227 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
228 ASSERT_TRUE(popup_browser.get()); 228 ASSERT_TRUE(popup_browser.get());
229 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); 229 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow());
230 ASSERT_TRUE(popup_window.get()); 230 ASSERT_TRUE(popup_window.get());
231 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); 231 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0));
232 ASSERT_TRUE(popup_tab.get()); 232 ASSERT_TRUE(popup_tab.get());
233 233
234 #if defined(OS_LINUX) 234 #if defined(OS_LINUX)
235 // It seems we have to wait a little bit for the widgets to spin up before 235 // It seems we have to wait a little bit for the widgets to spin up before
236 // we can start clicking on them. 236 // we can start clicking on them.
237 PlatformThread::Sleep(500); 237 PlatformThread::Sleep(500);
238 #endif 238 #endif
239 239
240 SimulateClickInCenterOf(popup_window); 240 SimulateClickInCenterOf(popup_window);
241 241
242 // Wait for there to be an app modal dialog. 242 // Wait for there to be an app modal dialog.
243 ASSERT_TRUE(automation()->WaitForAppModalDialog(5000)); 243 ASSERT_TRUE(automation()->WaitForAppModalDialog(5000));
244 } 244 }
245 245
246 // Make sure that window focus works while creating a popup window so that we 246 // Make sure that window focus works while creating a popup window so that we
247 // don't 247 // don't
248 TEST_F(BlockedPopupContainerInteractiveTest, DontBreakOnBlur) { 248 TEST_F(BlockedPopupContainerInteractiveTest, DontBreakOnBlur) {
249 NavigateMainTabTo(L"window_blur_test.html"); 249 NavigateMainTabTo("window_blur_test.html");
250 SimulateClickInCenterOf(window_); 250 SimulateClickInCenterOf(window_);
251 251
252 // Wait for the popup window to open. 252 // Wait for the popup window to open.
253 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); 253 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));
254 254
255 // We popup shouldn't be closed by the onblur handler. 255 // We popup shouldn't be closed by the onblur handler.
256 ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 1500)); 256 ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 1500));
257 } 257 }
OLDNEW
« no previous file with comments | « base/file_version_info_unittest.cc ('k') | chrome/browser/dom_ui/chrome_url_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698