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

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

Issue 174201: More interactive test porting for Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fixes Created 11 years, 4 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, DISABLED_TestOpenAndResizeTo) { 64 TEST_F(BlockedPopupContainerInteractiveTest, TestOpenAndResizeTo) {
65 NavigateMainTabTo(L"constrained_window_onload_resizeto.html"); 65 NavigateMainTabTo(L"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
(...skipping 18 matching lines...) Expand all
93 // lower, then we started hitting it before it was done. :( 93 // lower, then we started hitting it before it was done. :(
94 PlatformThread::Sleep(5000); 94 PlatformThread::Sleep(5000);
95 95
96 // The actual content will be LESS than (200, 200) because resizeTo 96 // The actual content will be LESS than (200, 200) because resizeTo
97 // deals with a window's outer{Width,Height} instead of its 97 // deals with a window's outer{Width,Height} instead of its
98 // inner{Width,Height}. 98 // inner{Width,Height}.
99 is_timeout = false; 99 is_timeout = false;
100 ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( 100 ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout(
101 VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); 101 VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout));
102 ASSERT_FALSE(is_timeout); 102 ASSERT_FALSE(is_timeout);
103 EXPECT_LT(rect.height(), 200);
104 #if defined(OS_LINUX)
105 // On Linux we may run in an environment where there is no window frame. In
106 // this case our width might be exactly 200. The height will still be less
107 // because we have to show the location bar.
108 EXPECT_LE(rect.width(), 200);
109 #else
103 EXPECT_LT(rect.width(), 200); 110 EXPECT_LT(rect.width(), 200);
104 EXPECT_LT(rect.height(), 200); 111 #endif
105 } 112 }
106 113
107 // TODO(estade): port.
108 #if !defined(OS_LINUX)
109 // Helper function used to get the number of blocked popups out of the window 114 // Helper function used to get the number of blocked popups out of the window
110 // title. 115 // title.
111 bool ParseCountOutOfTitle(const std::wstring& title, int* output) { 116 bool ParseCountOutOfTitle(const std::wstring& title, int* output) {
112 // Since we will be reading the number of popup windows open by grabbing the 117 // Since we will be reading the number of popup windows open by grabbing the
113 // number out of the window title, and that format string is localized, we 118 // number out of the window title, and that format string is localized, we
114 // need to find out the offset into that string. 119 // need to find out the offset into that string.
115 const wchar_t* placeholder = L"XXXX"; 120 const wchar_t* placeholder = L"XXXX";
116 size_t offset = 121 size_t offset =
117 l10n_util::GetStringF(IDS_POPUPS_BLOCKED_COUNT, placeholder). 122 l10n_util::GetStringF(IDS_POPUPS_BLOCKED_COUNT, placeholder).
118 find(placeholder); 123 find(placeholder);
119 124
120 std::wstring number; 125 std::wstring number;
121 while (offset < title.size() && iswdigit(title[offset])) { 126 while (offset < title.size() && iswdigit(title[offset])) {
122 number += title[offset]; 127 number += title[offset];
123 offset++; 128 offset++;
124 } 129 }
125 130
126 return StringToInt(WideToUTF16(number), output); 131 return StringToInt(WideToUTF16(number), output);
127 } 132 }
128 133
129 // Tests that in the window.open() equivalent of a fork bomb, we stop building 134 // Tests that in the window.open() equivalent of a fork bomb, we stop building
130 // windows. 135 // windows.
131 TEST_F(BlockedPopupContainerInteractiveTest, DISABLED_DontSpawnEndlessPopups) { 136 TEST_F(BlockedPopupContainerInteractiveTest, DontSpawnEndlessPopups) {
132 NavigateMainTabTo(L"infinite_popups.html"); 137 NavigateMainTabTo(L"infinite_popups.html");
133 SimulateClickInCenterOf(window_); 138 SimulateClickInCenterOf(window_);
134 139
135 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); 140 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));
136 141
137 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 142 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
138 ASSERT_TRUE(popup_browser.get()); 143 ASSERT_TRUE(popup_browser.get());
139 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); 144 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0));
140 ASSERT_TRUE(popup_tab.get()); 145 ASSERT_TRUE(popup_tab.get());
141 146
(...skipping 22 matching lines...) Expand all
164 } 169 }
165 170
166 EXPECT_GE(new_popup_window_count, popup_window_count); 171 EXPECT_GE(new_popup_window_count, popup_window_count);
167 EXPECT_LE(new_popup_window_count, kMaxPopupWindows); 172 EXPECT_LE(new_popup_window_count, kMaxPopupWindows);
168 popup_window_count = new_popup_window_count; 173 popup_window_count = new_popup_window_count;
169 } 174 }
170 } 175 }
171 176
172 // Make sure that we refuse to close windows when a constrained popup is 177 // Make sure that we refuse to close windows when a constrained popup is
173 // displayed. 178 // displayed.
174 TEST_F(BlockedPopupContainerInteractiveTest, DISABLED_WindowOpenWindowClosePopup ) { 179 TEST_F(BlockedPopupContainerInteractiveTest, WindowOpenWindowClosePopup) {
175 NavigateMainTabTo(L"openclose_main.html"); 180 NavigateMainTabTo(L"openclose_main.html");
176 SimulateClickInCenterOf(window_); 181 SimulateClickInCenterOf(window_);
177 182
178 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); 183 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000));
179 184
180 // Make sure we have a blocked popup notification 185 // Make sure we have a blocked popup notification
181 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 186 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
182 ASSERT_TRUE(popup_browser.get()); 187 ASSERT_TRUE(popup_browser.get());
183 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); 188 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow());
184 ASSERT_TRUE(popup_window.get()); 189 ASSERT_TRUE(popup_window.get());
(...skipping 15 matching lines...) Expand all
200 int browser_window_count; 205 int browser_window_count;
201 ASSERT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count)); 206 ASSERT_TRUE(automation()->GetBrowserWindowCount(&browser_window_count));
202 ASSERT_EQ(1, browser_window_count); 207 ASSERT_EQ(1, browser_window_count);
203 208
204 // Ensure one blocked popup window: the popup didn't escape. 209 // Ensure one blocked popup window: the popup didn't escape.
205 int popup_count = 0; 210 int popup_count = 0;
206 ASSERT_TRUE(tab_->GetBlockedPopupCount(&popup_count)); 211 ASSERT_TRUE(tab_->GetBlockedPopupCount(&popup_count));
207 ASSERT_EQ(1, popup_count); 212 ASSERT_EQ(1, popup_count);
208 } 213 }
209 214
210 TEST_F(BlockedPopupContainerInteractiveTest, DISABLED_ShowAlertFromNormalPopup) { 215 TEST_F(BlockedPopupContainerInteractiveTest, ShowAlertFromNormalPopup) {
211 NavigateMainTabTo(L"show_alert.html"); 216 NavigateMainTabTo(L"show_alert.html");
212 SimulateClickInCenterOf(window_); 217 SimulateClickInCenterOf(window_);
213 218
214 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); 219 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000));
215 220
216 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); 221 scoped_refptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1));
217 ASSERT_TRUE(popup_browser.get()); 222 ASSERT_TRUE(popup_browser.get());
218 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow()); 223 scoped_refptr<WindowProxy> popup_window(popup_browser->GetWindow());
219 ASSERT_TRUE(popup_window.get()); 224 ASSERT_TRUE(popup_window.get());
220 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0)); 225 scoped_refptr<TabProxy> popup_tab(popup_browser->GetTab(0));
221 ASSERT_TRUE(popup_tab.get()); 226 ASSERT_TRUE(popup_tab.get());
222 227
223 SimulateClickInCenterOf(popup_window); 228 SimulateClickInCenterOf(popup_window);
224 229
225 // Wait for there to be an app modal dialog. 230 // Wait for there to be an app modal dialog.
226 ASSERT_TRUE(automation()->WaitForAppModalDialog(5000)); 231 ASSERT_TRUE(automation()->WaitForAppModalDialog(5000));
227 } 232 }
228 233
229 // Make sure that window focus works while creating a popup window so that we 234 // Make sure that window focus works while creating a popup window so that we
230 // don't 235 // don't
231 TEST_F(BlockedPopupContainerInteractiveTest, DISABLED_DontBreakOnBlur) { 236 TEST_F(BlockedPopupContainerInteractiveTest, DontBreakOnBlur) {
232 NavigateMainTabTo(L"window_blur_test.html"); 237 NavigateMainTabTo(L"window_blur_test.html");
233 SimulateClickInCenterOf(window_); 238 SimulateClickInCenterOf(window_);
234 239
235 // Wait for the popup window to open. 240 // Wait for the popup window to open.
236 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000)); 241 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 1000));
237 242
238 // We popup shouldn't be closed by the onblur handler. 243 // We popup shouldn't be closed by the onblur handler.
239 ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 1500)); 244 ASSERT_FALSE(automation()->WaitForWindowCountToBecome(1, 1500));
240 } 245 }
241 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698