This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- SetUpCommandLine
- IN_PROC_BROWSER_TEST_F
#include "base/command_line.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "url/gurl.h"
using content::OpenURLParams;
using content::Referrer;
class NewTabUIBrowserTest : public InProcessBrowserTest {
public:
NewTabUIBrowserTest() {}
};
IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_LoadNTPInExistingProcess) {
content::RenderProcessHost::SetMaxRendererProcessCount(1);
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(1,
browser()->tab_strip_model()->GetWebContentsAt(1)->GetMaxPageID());
{
content::RenderProcessHostWatcher process_exited_observer(
browser()->tab_strip_model()->GetActiveWebContents(),
content::RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION);
browser()->OpenURL(OpenURLParams(
test_server()->GetURL("files/title1.html"), Referrer(), CURRENT_TAB,
content::PAGE_TRANSITION_TYPED, false));
process_exited_observer.Wait();
}
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(1,
browser()->tab_strip_model()->GetWebContentsAt(2)->GetMaxPageID());
chrome::CloseTab(browser());
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(chrome::kChromeUISettingsURL), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(1,
browser()->tab_strip_model()->GetWebContentsAt(2)->GetMaxPageID());
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(1,
browser()->tab_strip_model()->GetWebContentsAt(3)->GetMaxPageID());
browser()->tab_strip_model()->ActivateTabAt(1, true);
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
EXPECT_EQ(1,
browser()->tab_strip_model()->GetWebContentsAt(1)->GetMaxPageID());
}
IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_ChromeHangInNTP) {
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(content::kChromeUIHangURL), CURRENT_TAB, 0);
chrome::NewTab(browser());
browser()->OpenURL(OpenURLParams(
GURL(content::kChromeUIHangURL), Referrer(), CURRENT_TAB,
content::PAGE_TRANSITION_TYPED, false));
}
class NewTabUIProcessPerTabTest : public NewTabUIBrowserTest {
public:
NewTabUIProcessPerTabTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(switches::kProcessPerTab);
}
};
IN_PROC_BROWSER_TEST_F(NewTabUIProcessPerTabTest, NavBeforeNTPCommits) {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(content::kChromeUIHangURL), CURRENT_TAB, 0);
ui_test_utils::NavigateToURLWithDisposition(
browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, 0);
content::TestNavigationObserver observer(
browser()->tab_strip_model()->GetActiveWebContents());
browser()->OpenURL(OpenURLParams(
GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB,
content::PAGE_TRANSITION_TYPED, false));
observer.Wait();
}