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

Side by Side Diff: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc

Issue 2924383003: [MD Bookmarks] Enable by default. (Closed)
Patch Set: address comments Created 3 years, 6 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
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 "base/macros.h" 6 #include "base/macros.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/process/process.h" 9 #include "base/process/process.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/devtools/devtools_window.h" 14 #include "chrome/browser/devtools/devtools_window.h"
15 #include "chrome/browser/extensions/extension_browsertest.h"
15 #include "chrome/browser/search/search.h" 16 #include "chrome/browser/search/search.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_commands.h" 18 #include "chrome/browser/ui/browser_commands.h"
18 #include "chrome/browser/ui/singleton_tabs.h" 19 #include "chrome/browser/ui/singleton_tabs.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 &out_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { 84 &out_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) {
84 return base::Process(); 85 return base::Process();
85 } 86 }
86 handle = out_handle; 87 handle = out_handle;
87 #endif // defined(OS_WIN) 88 #endif // defined(OS_WIN)
88 return base::Process(handle); 89 return base::Process(handle);
89 } 90 }
90 91
91 } // namespace 92 } // namespace
92 93
93 class ChromeRenderProcessHostTest : public InProcessBrowserTest { 94 class ChromeRenderProcessHostTest : public ExtensionBrowserTest {
94 public: 95 public:
95 ChromeRenderProcessHostTest() {} 96 ChromeRenderProcessHostTest() {}
96 97
97 // Show a tab, activating the current one if there is one, and wait for 98 // Show a tab, activating the current one if there is one, and wait for
98 // the renderer process to be created or foregrounded, returning the process 99 // the renderer process to be created or foregrounded, returning the process
99 // handle. 100 // handle.
100 base::Process ShowSingletonTab(const GURL& page) { 101 base::Process ShowSingletonTab(const GURL& page) {
101 chrome::ShowSingletonTab(browser(), page); 102 chrome::ShowSingletonTab(browser(), page);
102 WebContents* wc = browser()->tab_strip_model()->GetActiveWebContents(); 103 WebContents* wc = browser()->tab_strip_model()->GetActiveWebContents();
103 CHECK(wc->GetURL() == page); 104 CHECK(wc->GetURL() == page);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // in a process of that type, even if that means creating a new process. 149 // in a process of that type, even if that means creating a new process.
149 void TestProcessOverflow() { 150 void TestProcessOverflow() {
150 int tab_count = 1; 151 int tab_count = 1;
151 int host_count = 1; 152 int host_count = 1;
152 WebContents* tab1 = NULL; 153 WebContents* tab1 = NULL;
153 WebContents* tab2 = NULL; 154 WebContents* tab2 = NULL;
154 content::RenderProcessHost* rph1 = NULL; 155 content::RenderProcessHost* rph1 = NULL;
155 content::RenderProcessHost* rph2 = NULL; 156 content::RenderProcessHost* rph2 = NULL;
156 content::RenderProcessHost* rph3 = NULL; 157 content::RenderProcessHost* rph3 = NULL;
157 158
159 const extensions::Extension* extension =
160 LoadExtension(test_data_dir_.AppendASCII("options_page"));
161
158 // Change the first tab to be the omnibox page (TYPE_WEBUI). 162 // Change the first tab to be the omnibox page (TYPE_WEBUI).
159 GURL omnibox(chrome::kChromeUIOmniboxURL); 163 GURL omnibox(chrome::kChromeUIOmniboxURL);
160 ui_test_utils::NavigateToURL(browser(), omnibox); 164 ui_test_utils::NavigateToURL(browser(), omnibox);
161 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 165 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
162 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); 166 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
163 rph1 = tab1->GetRenderProcessHost(); 167 rph1 = tab1->GetRenderProcessHost();
164 EXPECT_EQ(omnibox, tab1->GetURL()); 168 EXPECT_EQ(omnibox, tab1->GetURL());
165 EXPECT_EQ(host_count, RenderProcessHostCount()); 169 EXPECT_EQ(host_count, RenderProcessHostCount());
166 170
167 // Create a new TYPE_TABBED tab. It should be in its own process. 171 // Create a new TYPE_TABBED tab. It should be in its own process.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 chrome::ShowSingletonTab(browser(), history); 208 chrome::ShowSingletonTab(browser(), history);
205 observer3.Wait(); 209 observer3.Wait();
206 tab_count++; 210 tab_count++;
207 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 211 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
208 tab2 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); 212 tab2 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
209 EXPECT_EQ(tab2->GetURL(), GURL(history)); 213 EXPECT_EQ(tab2->GetURL(), GURL(history));
210 EXPECT_EQ(host_count, RenderProcessHostCount()); 214 EXPECT_EQ(host_count, RenderProcessHostCount());
211 EXPECT_EQ(tab2->GetRenderProcessHost(), rph1); 215 EXPECT_EQ(tab2->GetRenderProcessHost(), rph1);
212 216
213 // Create a TYPE_EXTENSION tab. It should be in its own process. 217 // Create a TYPE_EXTENSION tab. It should be in its own process.
214 // (the bookmark manager is implemented as an extension) 218 GURL extension_url("chrome-extension://" + extension->id());
215 GURL bookmarks(chrome::kChromeUIBookmarksURL);
216 ui_test_utils::WindowedTabAddedNotificationObserver observer4( 219 ui_test_utils::WindowedTabAddedNotificationObserver observer4(
217 content::NotificationService::AllSources()); 220 content::NotificationService::AllSources());
218 chrome::ShowSingletonTab(browser(), bookmarks); 221 chrome::ShowSingletonTab(browser(), extension_url);
222
219 observer4.Wait(); 223 observer4.Wait();
220 tab_count++; 224 tab_count++;
221 host_count++; 225 host_count++;
222 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 226 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
223 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); 227 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
224 rph3 = tab1->GetRenderProcessHost(); 228 rph3 = tab1->GetRenderProcessHost();
225 EXPECT_EQ(tab1->GetURL(), bookmarks); 229 EXPECT_EQ(tab1->GetURL(), extension_url);
226 EXPECT_EQ(host_count, RenderProcessHostCount()); 230 EXPECT_EQ(host_count, RenderProcessHostCount());
227 EXPECT_NE(rph1, rph3); 231 EXPECT_NE(rph1, rph3);
228 EXPECT_NE(rph2, rph3); 232 EXPECT_NE(rph2, rph3);
229 } 233 }
230 }; 234 };
231 235
232 class ChromeRenderProcessHostTestWithCommandLine 236 class ChromeRenderProcessHostTestWithCommandLine
233 : public ChromeRenderProcessHostTest { 237 : public ChromeRenderProcessHostTest {
234 protected: 238 protected:
235 void SetUpCommandLine(base::CommandLine* command_line) override { 239 void SetUpCommandLine(base::CommandLine* command_line) override {
240 ChromeRenderProcessHostTest::SetUpCommandLine(command_line);
236 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); 241 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1");
237 } 242 }
238 }; 243 };
239 244
240 // Disable on Windows and Mac due to ongoing flakiness. (crbug.com/442785) 245 // Disable on Windows and Mac due to ongoing flakiness. (crbug.com/442785)
241 #if defined(OS_WIN) || defined(OS_MACOSX) 246 #if defined(OS_WIN) || defined(OS_MACOSX)
242 #define MAYBE_ProcessPerTab DISABLED_ProcessPerTab 247 #define MAYBE_ProcessPerTab DISABLED_ProcessPerTab
243 #else 248 #else
244 #define MAYBE_ProcessPerTab ProcessPerTab 249 #define MAYBE_ProcessPerTab ProcessPerTab
245 #endif 250 #endif
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // called "no audio" in foreground and another called "audio" in background with 594 // called "no audio" in foreground and another called "audio" in background with
590 // audio in playing state. Also sets up the variables containing the process 595 // audio in playing state. Also sets up the variables containing the process
591 // associated with each tab, the urls of the two pages and the WebContents of 596 // associated with each tab, the urls of the two pages and the WebContents of
592 // the "audio" page. 597 // the "audio" page.
593 class ChromeRenderProcessHostBackgroundingTest 598 class ChromeRenderProcessHostBackgroundingTest
594 : public ChromeRenderProcessHostTest { 599 : public ChromeRenderProcessHostTest {
595 public: 600 public:
596 ChromeRenderProcessHostBackgroundingTest() {} 601 ChromeRenderProcessHostBackgroundingTest() {}
597 602
598 void SetUpCommandLine(base::CommandLine* command_line) override { 603 void SetUpCommandLine(base::CommandLine* command_line) override {
604 ChromeRenderProcessHostTest::SetUpCommandLine(command_line);
599 command_line->AppendSwitch(switches::kProcessPerTab); 605 command_line->AppendSwitch(switches::kProcessPerTab);
600 } 606 }
601 607
602 void SetUpOnMainThread() override { 608 void SetUpOnMainThread() override {
609 ChromeRenderProcessHostTest::SetUpOnMainThread();
603 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); 610 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
604 611
605 // Set up the server and get the test pages. 612 // Set up the server and get the test pages.
606 base::FilePath test_data_dir; 613 base::FilePath test_data_dir;
607 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); 614 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
608 embedded_test_server()->ServeFilesFromDirectory( 615 embedded_test_server()->ServeFilesFromDirectory(
609 test_data_dir.AppendASCII("chrome/test/data/")); 616 test_data_dir.AppendASCII("chrome/test/data/"));
610 audio_url_ = embedded_test_server()->GetURL("/extensions/loop_audio.html"); 617 audio_url_ = embedded_test_server()->GetURL("/extensions/loop_audio.html");
611 no_audio_url_ = embedded_test_server()->GetURL("/title1.html"); 618 no_audio_url_ = embedded_test_server()->GetURL("/title1.html");
612 619
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, true); 734 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, true);
728 735
729 // Start the audio from the backgrounded tab. 736 // Start the audio from the backgrounded tab.
730 ASSERT_TRUE( 737 ASSERT_TRUE(
731 content::ExecuteScript(audio_tab_web_contents_, 738 content::ExecuteScript(audio_tab_web_contents_,
732 "document.getElementById('audioPlayer').play();")); 739 "document.getElementById('audioPlayer').play();"));
733 740
734 // Wait until the two pages are not backgrounded. 741 // Wait until the two pages are not backgrounded.
735 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, false); 742 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, false);
736 } 743 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698