Chromium Code Reviews

Side by Side Diff: chrome/browser/ui/tests/browser_uitest.cc

Issue 6187002: Remove sleep_timeout_ms and fix all the callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
11 #include "base/test/test_file_util.h" 11 #include "base/test/test_file_util.h"
12 #include "base/test/test_timeouts.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/platform_util.h" 15 #include "chrome/browser/platform_util.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "chrome/test/automation/browser_proxy.h" 20 #include "chrome/test/automation/browser_proxy.h"
20 #include "chrome/test/automation/tab_proxy.h" 21 #include "chrome/test/automation/tab_proxy.h"
21 #include "chrome/test/automation/window_proxy.h" 22 #include "chrome/test/automation/window_proxy.h"
(...skipping 84 matching lines...)
106 107
107 // Use JavaScript URL to "fork" a new tab, just like Gmail. (Open tab to a 108 // Use JavaScript URL to "fork" a new tab, just like Gmail. (Open tab to a
108 // blank page, set its opener to null, and redirect it cross-site.) 109 // blank page, set its opener to null, and redirect it cross-site.)
109 std::wstring url_prefix(L"javascript:(function(){w=window.open();"); 110 std::wstring url_prefix(L"javascript:(function(){w=window.open();");
110 GURL fork_url(url_prefix + 111 GURL fork_url(url_prefix +
111 L"w.opener=null;w.document.location=\"http://localhost:1337\";})()"); 112 L"w.opener=null;w.document.location=\"http://localhost:1337\";})()");
112 113
113 // Make sure that a new tab has been created and that we have a new renderer 114 // Make sure that a new tab has been created and that we have a new renderer
114 // process for it. 115 // process for it.
115 ASSERT_TRUE(tab->NavigateToURLAsync(fork_url)); 116 ASSERT_TRUE(tab->NavigateToURLAsync(fork_url));
116 PlatformThread::Sleep(sleep_timeout_ms()); 117 PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
117 ASSERT_EQ(orig_process_count + 1, GetBrowserProcessCount()); 118 ASSERT_EQ(orig_process_count + 1, GetBrowserProcessCount());
118 int new_tab_count = -1; 119 int new_tab_count = -1;
119 ASSERT_TRUE(window->GetTabCount(&new_tab_count)); 120 ASSERT_TRUE(window->GetTabCount(&new_tab_count));
120 ASSERT_EQ(orig_tab_count + 1, new_tab_count); 121 ASSERT_EQ(orig_tab_count + 1, new_tab_count);
121 } 122 }
122 #endif // CHROME_V8 123 #endif // CHROME_V8
123 124
124 // This test fails on ChromeOS (it has never been known to work on it). 125 // This test fails on ChromeOS (it has never been known to work on it).
125 // Currently flaky on Windows - it has crashed a couple of times. 126 // Currently flaky on Windows - it has crashed a couple of times.
126 // http://crbug.com/32799 127 // http://crbug.com/32799
(...skipping 32 matching lines...)
159 // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the 160 // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the
160 // opener non-null.) Should not fork a process. 161 // opener non-null.) Should not fork a process.
161 std::string url_str = "javascript:(function(){w=window.open(); "; 162 std::string url_str = "javascript:(function(){w=window.open(); ";
162 url_str += "w.document.location=\""; 163 url_str += "w.document.location=\"";
163 url_str += test_server.GetURL("").spec(); 164 url_str += test_server.GetURL("").spec();
164 url_str += "\";})()"; 165 url_str += "\";})()";
165 GURL dont_fork_url(url_str); 166 GURL dont_fork_url(url_str);
166 167
167 // Make sure that a new tab but not new process has been created. 168 // Make sure that a new tab but not new process has been created.
168 ASSERT_TRUE(tab->NavigateToURLAsync(dont_fork_url)); 169 ASSERT_TRUE(tab->NavigateToURLAsync(dont_fork_url));
169 base::PlatformThread::Sleep(sleep_timeout_ms()); 170 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
170 ASSERT_EQ(orig_process_count, GetBrowserProcessCount()); 171 ASSERT_EQ(orig_process_count, GetBrowserProcessCount());
171 int new_tab_count = -1; 172 int new_tab_count = -1;
172 ASSERT_TRUE(window->GetTabCount(&new_tab_count)); 173 ASSERT_TRUE(window->GetTabCount(&new_tab_count));
173 ASSERT_EQ(orig_tab_count + 1, new_tab_count); 174 ASSERT_EQ(orig_tab_count + 1, new_tab_count);
174 175
175 // Same thing if the current tab tries to redirect itself. 176 // Same thing if the current tab tries to redirect itself.
176 url_str = "javascript:(function(){w=window.open(); "; 177 url_str = "javascript:(function(){w=window.open(); ";
177 url_str += "document.location=\""; 178 url_str += "document.location=\"";
178 url_str += test_server.GetURL("").spec(); 179 url_str += test_server.GetURL("").spec();
179 url_str += "\";})()"; 180 url_str += "\";})()";
180 GURL dont_fork_url2(url_str); 181 GURL dont_fork_url2(url_str);
181 182
182 // Make sure that no new process has been created. 183 // Make sure that no new process has been created.
183 ASSERT_TRUE(tab->NavigateToURLAsync(dont_fork_url2)); 184 ASSERT_TRUE(tab->NavigateToURLAsync(dont_fork_url2));
184 base::PlatformThread::Sleep(sleep_timeout_ms()); 185 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
185 ASSERT_EQ(orig_process_count, GetBrowserProcessCount()); 186 ASSERT_EQ(orig_process_count, GetBrowserProcessCount());
186 } 187 }
187 188
188 TEST_F(VisibleBrowserTest, WindowOpenClose) { 189 TEST_F(VisibleBrowserTest, WindowOpenClose) {
189 FilePath test_file(test_data_directory_); 190 FilePath test_file(test_data_directory_);
190 test_file = test_file.AppendASCII("window.close.html"); 191 test_file = test_file.AppendASCII("window.close.html");
191 192
192 NavigateToURLBlockUntilNavigationsComplete( 193 NavigateToURLBlockUntilNavigationsComplete(
193 net::FilePathToFileURL(test_file), 2); 194 net::FilePathToFileURL(test_file), 2);
194 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); 195 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle());
(...skipping 181 matching lines...)
376 EXPECT_EQ(0, window_count); 377 EXPECT_EQ(0, window_count);
377 378
378 // Starting a browser window should work just fine. 379 // Starting a browser window should work just fine.
379 ASSERT_TRUE(IsBrowserRunning()); 380 ASSERT_TRUE(IsBrowserRunning());
380 ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, true)); 381 ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, true));
381 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 382 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
382 EXPECT_EQ(1, window_count); 383 EXPECT_EQ(1, window_count);
383 } 384 }
384 385
385 } // namespace 386 } // namespace
OLDNEW

Powered by Google App Engine