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

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

Issue 2924383003: [MD Bookmarks] Enable by default. (Closed)
Patch Set: more tests 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 // (the bookmark manager is implemented as an extension)
tsergeant 2017/06/15 07:23:44 update this comment too
calamity 2017/06/19 06:00:29 Done.
215 GURL bookmarks(chrome::kChromeUIBookmarksURL); 219 GURL extension_url("chrome-extension://" + extension->id());
216 ui_test_utils::WindowedTabAddedNotificationObserver observer4( 220 ui_test_utils::WindowedTabAddedNotificationObserver observer4(
217 content::NotificationService::AllSources()); 221 content::NotificationService::AllSources());
218 chrome::ShowSingletonTab(browser(), bookmarks); 222 chrome::ShowSingletonTab(browser(), extension_url);
223
219 observer4.Wait(); 224 observer4.Wait();
220 tab_count++; 225 tab_count++;
221 host_count++; 226 host_count++;
222 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 227 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
223 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); 228 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
224 rph3 = tab1->GetRenderProcessHost(); 229 rph3 = tab1->GetRenderProcessHost();
225 EXPECT_EQ(tab1->GetURL(), bookmarks); 230 EXPECT_EQ(tab1->GetURL(), extension_url);
226 EXPECT_EQ(host_count, RenderProcessHostCount()); 231 EXPECT_EQ(host_count, RenderProcessHostCount());
227 EXPECT_NE(rph1, rph3); 232 EXPECT_NE(rph1, rph3);
228 EXPECT_NE(rph2, rph3); 233 EXPECT_NE(rph2, rph3);
229 } 234 }
230 }; 235 };
231 236
232 class ChromeRenderProcessHostTestWithCommandLine 237 class ChromeRenderProcessHostTestWithCommandLine
233 : public ChromeRenderProcessHostTest { 238 : public ChromeRenderProcessHostTest {
234 protected: 239 protected:
235 void SetUpCommandLine(base::CommandLine* command_line) override { 240 void SetUpCommandLine(base::CommandLine* command_line) override {
241 ChromeRenderProcessHostTest::SetUpCommandLine(command_line);
236 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); 242 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1");
237 } 243 }
238 }; 244 };
239 245
240 // Disable on Windows and Mac due to ongoing flakiness. (crbug.com/442785) 246 // Disable on Windows and Mac due to ongoing flakiness. (crbug.com/442785)
241 #if defined(OS_WIN) || defined(OS_MACOSX) 247 #if defined(OS_WIN) || defined(OS_MACOSX)
242 #define MAYBE_ProcessPerTab DISABLED_ProcessPerTab 248 #define MAYBE_ProcessPerTab DISABLED_ProcessPerTab
243 #else 249 #else
244 #define MAYBE_ProcessPerTab ProcessPerTab 250 #define MAYBE_ProcessPerTab ProcessPerTab
245 #endif 251 #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 595 // 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 596 // 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 597 // associated with each tab, the urls of the two pages and the WebContents of
592 // the "audio" page. 598 // the "audio" page.
593 class ChromeRenderProcessHostBackgroundingTest 599 class ChromeRenderProcessHostBackgroundingTest
594 : public ChromeRenderProcessHostTest { 600 : public ChromeRenderProcessHostTest {
595 public: 601 public:
596 ChromeRenderProcessHostBackgroundingTest() {} 602 ChromeRenderProcessHostBackgroundingTest() {}
597 603
598 void SetUpCommandLine(base::CommandLine* command_line) override { 604 void SetUpCommandLine(base::CommandLine* command_line) override {
605 ChromeRenderProcessHostTest::SetUpCommandLine(command_line);
599 command_line->AppendSwitch(switches::kProcessPerTab); 606 command_line->AppendSwitch(switches::kProcessPerTab);
600 } 607 }
601 608
602 void SetUpOnMainThread() override { 609 void SetUpOnMainThread() override {
610 ChromeRenderProcessHostTest::SetUpOnMainThread();
603 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); 611 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
604 612
605 // Set up the server and get the test pages. 613 // Set up the server and get the test pages.
606 base::FilePath test_data_dir; 614 base::FilePath test_data_dir;
607 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); 615 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
608 embedded_test_server()->ServeFilesFromDirectory( 616 embedded_test_server()->ServeFilesFromDirectory(
609 test_data_dir.AppendASCII("chrome/test/data/")); 617 test_data_dir.AppendASCII("chrome/test/data/"));
610 audio_url_ = embedded_test_server()->GetURL("/extensions/loop_audio.html"); 618 audio_url_ = embedded_test_server()->GetURL("/extensions/loop_audio.html");
611 no_audio_url_ = embedded_test_server()->GetURL("/title1.html"); 619 no_audio_url_ = embedded_test_server()->GetURL("/title1.html");
612 620
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, true); 735 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, true);
728 736
729 // Start the audio from the backgrounded tab. 737 // Start the audio from the backgrounded tab.
730 ASSERT_TRUE( 738 ASSERT_TRUE(
731 content::ExecuteScript(audio_tab_web_contents_, 739 content::ExecuteScript(audio_tab_web_contents_,
732 "document.getElementById('audioPlayer').play();")); 740 "document.getElementById('audioPlayer').play();"));
733 741
734 // Wait until the two pages are not backgrounded. 742 // Wait until the two pages are not backgrounded.
735 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, false); 743 WaitUntilBackgrounded(no_audio_process_, false, audio_process_, false);
736 } 744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698