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

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

Issue 3834002: Make all browser code use browser::Navigate to open tabs.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | « chrome/browser/browser.cc ('k') | chrome/browser/browser_focus_uitest.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/app/chrome_dll_resource.h" 12 #include "chrome/app/chrome_dll_resource.h"
13 #include "chrome/browser/app_modal_dialog.h" 13 #include "chrome/browser/app_modal_dialog.h"
14 #include "chrome/browser/browser.h" 14 #include "chrome/browser/browser.h"
15 #include "chrome/browser/browser_init.h" 15 #include "chrome/browser/browser_init.h"
16 #include "chrome/browser/browser_list.h" 16 #include "chrome/browser/browser_list.h"
17 #include "chrome/browser/browser_navigator.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/browser_window.h" 19 #include "chrome/browser/browser_window.h"
19 #include "chrome/browser/defaults.h" 20 #include "chrome/browser/defaults.h"
20 #include "chrome/browser/extensions/extension_browsertest.h" 21 #include "chrome/browser/extensions/extension_browsertest.h"
21 #include "chrome/browser/extensions/extensions_service.h" 22 #include "chrome/browser/extensions/extensions_service.h"
22 #include "chrome/browser/js_modal_dialog.h" 23 #include "chrome/browser/js_modal_dialog.h"
23 #include "chrome/browser/native_app_modal_dialog.h" 24 #include "chrome/browser/native_app_modal_dialog.h"
24 #include "chrome/browser/profile.h" 25 #include "chrome/browser/profile.h"
25 #include "chrome/browser/renderer_host/render_process_host.h" 26 #include "chrome/browser/renderer_host/render_process_host.h"
26 #include "chrome/browser/renderer_host/render_view_host.h" 27 #include "chrome/browser/renderer_host/render_view_host.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Test is crashing on Mac, see http://crbug.com/29424. 200 // Test is crashing on Mac, see http://crbug.com/29424.
200 #define MAYBE_JavascriptAlertActivatesTab DISABLED_JavascriptAlertActivatesTab 201 #define MAYBE_JavascriptAlertActivatesTab DISABLED_JavascriptAlertActivatesTab
201 #else 202 #else
202 #define MAYBE_JavascriptAlertActivatesTab JavascriptAlertActivatesTab 203 #define MAYBE_JavascriptAlertActivatesTab JavascriptAlertActivatesTab
203 #endif 204 #endif
204 205
205 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_JavascriptAlertActivatesTab) { 206 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_JavascriptAlertActivatesTab) {
206 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 207 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
207 FilePath(kTitle1File))); 208 FilePath(kTitle1File)));
208 ui_test_utils::NavigateToURL(browser(), url); 209 ui_test_utils::NavigateToURL(browser(), url);
209 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); 210 AddTabAtIndex(0, url, PageTransition::TYPED);
210 params.index = 0;
211 browser()->AddTabWithURL(&params);
212 EXPECT_EQ(browser(), params.target);
213 EXPECT_EQ(2, browser()->tab_count()); 211 EXPECT_EQ(2, browser()->tab_count());
214 EXPECT_EQ(0, browser()->selected_index()); 212 EXPECT_EQ(0, browser()->selected_index());
215 TabContents* second_tab = browser()->GetTabContentsAt(1); 213 TabContents* second_tab = browser()->GetTabContentsAt(1);
216 ASSERT_TRUE(second_tab); 214 ASSERT_TRUE(second_tab);
217 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"", 215 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"",
218 L"alert('Activate!');"); 216 L"alert('Activate!');");
219 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 217 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
220 alert->CloseModalDialog(); 218 alert->CloseModalDialog();
221 EXPECT_EQ(2, browser()->tab_count()); 219 EXPECT_EQ(2, browser()->tab_count());
222 EXPECT_EQ(1, browser()->selected_index()); 220 EXPECT_EQ(1, browser()->selected_index());
223 } 221 }
224 222
225 // Create 34 tabs and verify that a lot of processes have been created. The 223 // Create 34 tabs and verify that a lot of processes have been created. The
226 // exact number of processes depends on the amount of memory. Previously we 224 // exact number of processes depends on the amount of memory. Previously we
227 // had a hard limit of 31 processes and this test is mainly directed at 225 // had a hard limit of 31 processes and this test is mainly directed at
228 // verifying that we don't crash when we pass this limit. 226 // verifying that we don't crash when we pass this limit.
229 // Warning: this test can take >30 seconds when running on a slow (low 227 // Warning: this test can take >30 seconds when running on a slow (low
230 // memory?) Mac builder. 228 // memory?) Mac builder.
231 IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) { 229 IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) {
232 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 230 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
233 FilePath(kTitle2File))); 231 FilePath(kTitle2File)));
234 232
235 // There is one initial tab. 233 // There is one initial tab.
236 for (int ix = 0; ix != 33; ++ix) { 234 for (int ix = 0; ix != 33; ++ix)
237 Browser::AddTabWithURLParams params(url, PageTransition::TYPED); 235 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
238 params.index = 0;
239 browser()->AddTabWithURL(&params);
240 EXPECT_EQ(browser(), params.target);
241 }
242 EXPECT_EQ(34, browser()->tab_count()); 236 EXPECT_EQ(34, browser()->tab_count());
243 237
244 // See browser\renderer_host\render_process_host.cc for the algorithm to 238 // See browser\renderer_host\render_process_host.cc for the algorithm to
245 // decide how many processes to create. 239 // decide how many processes to create.
246 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { 240 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) {
247 EXPECT_GE(CountRenderProcessHosts(), 24); 241 EXPECT_GE(CountRenderProcessHosts(), 24);
248 } else { 242 } else {
249 EXPECT_LE(CountRenderProcessHosts(), 23); 243 EXPECT_LE(CountRenderProcessHosts(), 23);
250 } 244 }
251 } 245 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 646
653 // The normal browser should now have four. 647 // The normal browser should now have four.
654 EXPECT_EQ(4, browser()->tab_count()); 648 EXPECT_EQ(4, browser()->tab_count());
655 649
656 // Close the additional browsers. 650 // Close the additional browsers.
657 popup_browser->CloseAllTabs(); 651 popup_browser->CloseAllTabs();
658 app_browser->CloseAllTabs(); 652 app_browser->CloseAllTabs();
659 app_popup_browser->CloseAllTabs(); 653 app_popup_browser->CloseAllTabs();
660 } 654 }
661 #endif 655 #endif
OLDNEW
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/browser_focus_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698