OLD | NEW |
1 // Copyright (c) 2006-2008 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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "chrome/browser/view_ids.h" | 8 #include "chrome/browser/view_ids.h" |
9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
10 #include "chrome/common/l10n_util.h" | 10 #include "chrome/common/l10n_util.h" |
11 #include "chrome/test/automation/automation_constants.h" | 11 #include "chrome/test/automation/automation_constants.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( | 79 ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( |
80 VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); | 80 VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); |
81 ASSERT_FALSE(is_timeout); | 81 ASSERT_FALSE(is_timeout); |
82 ASSERT_EQ(300, rect.width()); | 82 ASSERT_EQ(300, rect.width()); |
83 ASSERT_EQ(320, rect.height()); | 83 ASSERT_EQ(320, rect.height()); |
84 | 84 |
85 SimulateClickInCenterOf(popup_window); | 85 SimulateClickInCenterOf(popup_window); |
86 | 86 |
87 // No idea how to wait here other then sleeping. This timeout used to be | 87 // No idea how to wait here other then sleeping. This timeout used to be |
88 // lower, then we started hitting it before it was done. :( | 88 // lower, then we started hitting it before it was done. :( |
89 Sleep(5000); | 89 PlatformThread::Sleep(5000); |
90 | 90 |
91 // The actual content will be LESS than (200, 200) because resizeTo | 91 // The actual content will be LESS than (200, 200) because resizeTo |
92 // deals with a window's outer{Width,Height} instead of its | 92 // deals with a window's outer{Width,Height} instead of its |
93 // inner{Width,Height}. | 93 // inner{Width,Height}. |
94 is_timeout = false; | 94 is_timeout = false; |
95 ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( | 95 ASSERT_TRUE(popup_window->GetViewBoundsWithTimeout( |
96 VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); | 96 VIEW_ID_TAB_CONTAINER, &rect, false, 1000, &is_timeout)); |
97 ASSERT_FALSE(is_timeout); | 97 ASSERT_FALSE(is_timeout); |
98 ASSERT_LT(rect.width(), 200); | 98 ASSERT_LT(rect.width(), 200); |
99 ASSERT_LT(rect.height(), 200); | 99 ASSERT_LT(rect.height(), 200); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 bool continuing = true; | 152 bool continuing = true; |
153 while (continuing && popup_window_count < kMaxPopupWindows) { | 153 while (continuing && popup_window_count < kMaxPopupWindows) { |
154 std::wstring title; | 154 std::wstring title; |
155 ASSERT_TRUE(constrained_window->GetTitle(&title)); | 155 ASSERT_TRUE(constrained_window->GetTitle(&title)); |
156 ASSERT_TRUE(ParseCountOutOfTitle(title, &new_popup_window_count)); | 156 ASSERT_TRUE(ParseCountOutOfTitle(title, &new_popup_window_count)); |
157 if (new_popup_window_count == popup_window_count) { | 157 if (new_popup_window_count == popup_window_count) { |
158 if (times_slept == 10) { | 158 if (times_slept == 10) { |
159 continuing = false; | 159 continuing = false; |
160 } else { | 160 } else { |
161 // Nothing intereseting is going on wait it out. | 161 // Nothing intereseting is going on wait it out. |
162 Sleep(automation::kSleepTime); | 162 PlatformThread::Sleep(automation::kSleepTime); |
163 times_slept++; | 163 times_slept++; |
164 } | 164 } |
165 } else { | 165 } else { |
166 times_slept = 0; | 166 times_slept = 0; |
167 } | 167 } |
168 | 168 |
169 EXPECT_GE(new_popup_window_count, popup_window_count); | 169 EXPECT_GE(new_popup_window_count, popup_window_count); |
170 EXPECT_LE(new_popup_window_count, kMaxPopupWindows); | 170 EXPECT_LE(new_popup_window_count, kMaxPopupWindows); |
171 popup_window_count = new_popup_window_count; | 171 popup_window_count = new_popup_window_count; |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 // Make sure that we refuse to close windows when a constrained popup is | 175 // Make sure that we refuse to close windows when a constrained popup is |
176 // displayed. | 176 // displayed. |
177 TEST_F(InteractiveConstrainedWindowTest, WindowOpenWindowClosePopup) { | 177 TEST_F(InteractiveConstrainedWindowTest, WindowOpenWindowClosePopup) { |
178 NavigateMainTabTo(L"openclose_main.html"); | 178 NavigateMainTabTo(L"openclose_main.html"); |
179 SimulateClickInCenterOf(window_); | 179 SimulateClickInCenterOf(window_); |
180 | 180 |
181 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); | 181 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, 5000)); |
182 | 182 |
183 Sleep(1000); | 183 PlatformThread::Sleep(1000); |
184 | 184 |
185 // Make sure we have a blocked popup notification | 185 // Make sure we have a blocked popup notification |
186 scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); | 186 scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); |
187 ASSERT_TRUE(popup_browser.get()); | 187 ASSERT_TRUE(popup_browser.get()); |
188 scoped_ptr<WindowProxy> popup_window(popup_browser->GetWindow()); | 188 scoped_ptr<WindowProxy> popup_window(popup_browser->GetWindow()); |
189 ASSERT_TRUE(popup_window.get()); | 189 ASSERT_TRUE(popup_window.get()); |
190 scoped_ptr<TabProxy> popup_tab(popup_browser->GetTab(0)); | 190 scoped_ptr<TabProxy> popup_tab(popup_browser->GetTab(0)); |
191 ASSERT_TRUE(popup_tab.get()); | 191 ASSERT_TRUE(popup_tab.get()); |
192 scoped_ptr<ConstrainedWindowProxy> popup_notification( | 192 scoped_ptr<ConstrainedWindowProxy> popup_notification( |
193 popup_tab->GetConstrainedWindow(0)); | 193 popup_tab->GetConstrainedWindow(0)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 TEST_F(InteractiveConstrainedWindowTest, DontBreakOnBlur) { | 248 TEST_F(InteractiveConstrainedWindowTest, DontBreakOnBlur) { |
249 NavigateMainTabTo(L"window_blur_test.html"); | 249 NavigateMainTabTo(L"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 } |
OLD | NEW |