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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc

Issue 11419276: Remove tabstrip wrappers in browser_tabstrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 8 years 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/ui/webui/feedback_ui.cc ('k') | chrome/test/ppapi/ppapi_browsertest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_commands.h" 7 #include "chrome/browser/ui/browser_commands.h"
8 #include "chrome/browser/ui/browser_tabstrip.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_types.h" 14 #include "content/public/browser/notification_types.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/test/browser_test_utils.h" 17 #include "content/public/test/browser_test_utils.h"
18 #include "content/public/test/test_navigation_observer.h" 18 #include "content/public/test/test_navigation_observer.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 20
21 using content::OpenURLParams; 21 using content::OpenURLParams;
22 using content::Referrer; 22 using content::Referrer;
23 23
24 class NewTabUIBrowserTest : public InProcessBrowserTest { 24 class NewTabUIBrowserTest : public InProcessBrowserTest {
25 public: 25 public:
26 NewTabUIBrowserTest() {} 26 NewTabUIBrowserTest() {}
27 }; 27 };
28 28
29 // Ensure that chrome-internal: still loads the NTP. 29 // Ensure that chrome-internal: still loads the NTP.
30 // See http://crbug.com/6564. 30 // See http://crbug.com/6564.
31 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeInternalLoadsNTP) { 31 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeInternalLoadsNTP) {
32 // Go to the "new tab page" using its old url, rather than chrome://newtab. 32 // Go to the "new tab page" using its old url, rather than chrome://newtab.
33 // Ensure that we get there by checking for non-empty page content. 33 // Ensure that we get there by checking for non-empty page content.
34 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal:")); 34 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal:"));
35 bool empty_inner_html = false; 35 bool empty_inner_html = false;
36 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 36 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
37 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), L"", 37 browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderViewHost(),
38 L"",
38 L"window.domAutomationController.send(document.body.innerHTML == '')", 39 L"window.domAutomationController.send(document.body.innerHTML == '')",
39 &empty_inner_html)); 40 &empty_inner_html));
40 ASSERT_FALSE(empty_inner_html); 41 ASSERT_FALSE(empty_inner_html);
41 } 42 }
42 43
43 // Ensure loading a NTP with an existing SiteInstance in a reused process 44 // Ensure loading a NTP with an existing SiteInstance in a reused process
44 // doesn't cause us to kill the process. See http://crbug.com/104258. 45 // doesn't cause us to kill the process. See http://crbug.com/104258.
45 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, LoadNTPInExistingProcess) { 46 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, LoadNTPInExistingProcess) {
46 // Set max renderers to 1 to force running out of processes. 47 // Set max renderers to 1 to force running out of processes.
47 content::RenderProcessHost::SetMaxRendererProcessCount(1); 48 content::RenderProcessHost::SetMaxRendererProcessCount(1);
48 49
49 // Start server for simple page. 50 // Start server for simple page.
50 ASSERT_TRUE(test_server()->Start()); 51 ASSERT_TRUE(test_server()->Start());
51 52
52 // Load a NTP in a new tab. 53 // Load a NTP in a new tab.
53 ui_test_utils::NavigateToURLWithDisposition( 54 ui_test_utils::NavigateToURLWithDisposition(
54 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, 55 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
55 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 56 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
56 EXPECT_EQ(1, chrome::GetWebContentsAt(browser(), 1)->GetMaxPageID()); 57 EXPECT_EQ(1,
58 browser()->tab_strip_model()->GetWebContentsAt(1)->GetMaxPageID());
57 59
58 // Navigate that tab to another site. This allows the NTP process to exit, 60 // Navigate that tab to another site. This allows the NTP process to exit,
59 // but it keeps the NTP SiteInstance (and its max_page_id) alive in history. 61 // but it keeps the NTP SiteInstance (and its max_page_id) alive in history.
60 { 62 {
61 // Wait not just for the navigation to finish, but for the NTP process to 63 // Wait not just for the navigation to finish, but for the NTP process to
62 // exit as well. 64 // exit as well.
63 content::WindowedNotificationObserver process_exited_observer( 65 content::WindowedNotificationObserver process_exited_observer(
64 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 66 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
65 content::NotificationService::AllSources()); 67 content::NotificationService::AllSources());
66 browser()->OpenURL(OpenURLParams( 68 browser()->OpenURL(OpenURLParams(
67 test_server()->GetURL("files/title1.html"), Referrer(), CURRENT_TAB, 69 test_server()->GetURL("files/title1.html"), Referrer(), CURRENT_TAB,
68 content::PAGE_TRANSITION_TYPED, false)); 70 content::PAGE_TRANSITION_TYPED, false));
69 process_exited_observer.Wait(); 71 process_exited_observer.Wait();
70 } 72 }
71 73
72 // Creating a NTP in another tab should not be affected, since page IDs 74 // Creating a NTP in another tab should not be affected, since page IDs
73 // are now specific to a tab. 75 // are now specific to a tab.
74 ui_test_utils::NavigateToURLWithDisposition( 76 ui_test_utils::NavigateToURLWithDisposition(
75 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, 77 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
76 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 78 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
77 EXPECT_EQ(1, chrome::GetWebContentsAt(browser(), 2)->GetMaxPageID()); 79 EXPECT_EQ(1,
80 browser()->tab_strip_model()->GetWebContentsAt(2)->GetMaxPageID());
78 chrome::CloseTab(browser()); 81 chrome::CloseTab(browser());
79 82
80 // Open another Web UI page in a new tab. 83 // Open another Web UI page in a new tab.
81 ui_test_utils::NavigateToURLWithDisposition( 84 ui_test_utils::NavigateToURLWithDisposition(
82 browser(), GURL(chrome::kChromeUISettingsURL), NEW_FOREGROUND_TAB, 85 browser(), GURL(chrome::kChromeUISettingsURL), NEW_FOREGROUND_TAB,
83 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 86 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
84 EXPECT_EQ(1, chrome::GetWebContentsAt(browser(), 2)->GetMaxPageID()); 87 EXPECT_EQ(1,
88 browser()->tab_strip_model()->GetWebContentsAt(2)->GetMaxPageID());
85 89
86 // At this point, opening another NTP will use the existing WebUI process 90 // At this point, opening another NTP will use the existing WebUI process
87 // but its own SiteInstance, so the page IDs shouldn't affect each other. 91 // but its own SiteInstance, so the page IDs shouldn't affect each other.
88 ui_test_utils::NavigateToURLWithDisposition( 92 ui_test_utils::NavigateToURLWithDisposition(
89 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, 93 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
90 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 94 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
91 EXPECT_EQ(1, chrome::GetWebContentsAt(browser(), 3)->GetMaxPageID()); 95 EXPECT_EQ(1,
96 browser()->tab_strip_model()->GetWebContentsAt(3)->GetMaxPageID());
92 97
93 // Navigating to the NTP in the original tab causes a BrowsingInstance 98 // Navigating to the NTP in the original tab causes a BrowsingInstance
94 // swap, so it gets a new SiteInstance starting with page ID 1 again. 99 // swap, so it gets a new SiteInstance starting with page ID 1 again.
95 chrome::ActivateTabAt(browser(), 1, true); 100 browser()->tab_strip_model()->ActivateTabAt(1, true);
96 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 101 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
97 EXPECT_EQ(1, chrome::GetWebContentsAt(browser(), 1)->GetMaxPageID()); 102 EXPECT_EQ(1,
103 browser()->tab_strip_model()->GetWebContentsAt(1)->GetMaxPageID());
98 } 104 }
99 105
100 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. 106 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash.
101 // See http://crbug.com/59859. 107 // See http://crbug.com/59859.
102 // If this flakes, use http://crbug.com/87200. 108 // If this flakes, use http://crbug.com/87200.
103 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) { 109 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) {
104 // Bring up a new tab page. 110 // Bring up a new tab page.
105 ui_test_utils::NavigateToURLWithDisposition( 111 ui_test_utils::NavigateToURLWithDisposition(
106 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, 112 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
107 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 113 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 151
146 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits 152 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits
147 // for current loading to stop. 153 // for current loading to stop.
148 content::TestNavigationObserver observer( 154 content::TestNavigationObserver observer(
149 content::NotificationService::AllSources()); 155 content::NotificationService::AllSources());
150 browser()->OpenURL(OpenURLParams( 156 browser()->OpenURL(OpenURLParams(
151 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, 157 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB,
152 content::PAGE_TRANSITION_TYPED, false)); 158 content::PAGE_TRANSITION_TYPED, false));
153 observer.Wait(); 159 observer.Wait();
154 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/feedback_ui.cc ('k') | chrome/test/ppapi/ppapi_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698