| Index: chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
|
| diff --git a/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc b/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
|
| index 8804ad39f3c4942780ef9bd1049fe934d8a8bdff..dba9d0be5006a82a862711e409aa3b942807e041 100644
|
| --- a/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
|
| +++ b/chrome/browser/ui/search/new_tab_page_interceptor_browsertest.cc
|
| @@ -40,14 +40,12 @@ class NewTabPageInterceptorTest : public InProcessBrowserTest {
|
| NewTabPageInterceptorTest() {}
|
|
|
| void SetUpOnMainThread() override {
|
| - path_ = ui_test_utils::GetTestFilePath(base::FilePath(), base::FilePath());
|
| + base::FilePath path =
|
| + ui_test_utils::GetTestFilePath(base::FilePath(), base::FilePath());
|
| BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
| - base::BindOnce(&SetUrlRequestMock, path_));
|
| + base::BindOnce(&SetUrlRequestMock, path));
|
| }
|
|
|
| - const GURL& new_tab_url() const { return new_tab_url_; }
|
| - void set_new_tab_url(const GURL& url) { new_tab_url_ = url; }
|
| -
|
| void ChangeDefaultSearchProvider(const char* new_tab_path) {
|
| TemplateURLService* template_url_service =
|
| TemplateURLServiceFactory::GetForProfile(browser()->profile());
|
| @@ -63,61 +61,56 @@ class NewTabPageInterceptorTest : public InProcessBrowserTest {
|
| template_url_service->Add(base::MakeUnique<TemplateURL>(data));
|
| template_url_service->SetUserSelectedDefaultSearchProvider(template_url);
|
| }
|
| -
|
| - private:
|
| - GURL new_tab_url_;
|
| - base::FilePath path_;
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(NewTabPageInterceptorTest, NoInterception) {
|
| - set_new_tab_url(
|
| - net::URLRequestMockHTTPJob::GetMockHttpsUrl("instant_extended.html"));
|
| + GURL new_tab_url =
|
| + net::URLRequestMockHTTPJob::GetMockHttpsUrl("instant_extended.html");
|
| ChangeDefaultSearchProvider("instant_extended.html");
|
|
|
| - ui_test_utils::NavigateToURL(browser(), new_tab_url());
|
| + ui_test_utils::NavigateToURL(browser(), new_tab_url);
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetWebContentsAt(0);
|
| - content::NavigationController* controller = &contents->GetController();
|
| // A correct, 200-OK file works correctly.
|
| - EXPECT_EQ(new_tab_url(), controller->GetLastCommittedEntry()->GetURL());
|
| + EXPECT_EQ(new_tab_url,
|
| + contents->GetController().GetLastCommittedEntry()->GetURL());
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(NewTabPageInterceptorTest, 404Interception) {
|
| - set_new_tab_url(net::URLRequestMockHTTPJob::GetMockHttpsUrl("page404.html"));
|
| + GURL new_tab_url =
|
| + net::URLRequestMockHTTPJob::GetMockHttpsUrl("page404.html");
|
| ChangeDefaultSearchProvider("page404.html");
|
|
|
| - ui_test_utils::NavigateToURL(browser(), new_tab_url());
|
| + ui_test_utils::NavigateToURL(browser(), new_tab_url);
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetWebContentsAt(0);
|
| - content::NavigationController* controller = &contents->GetController();
|
| // 404 makes a redirect to the local NTP.
|
| EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
|
| - controller->GetLastCommittedEntry()->GetURL());
|
| + contents->GetController().GetLastCommittedEntry()->GetURL());
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(NewTabPageInterceptorTest, 204Interception) {
|
| - set_new_tab_url(net::URLRequestMockHTTPJob::GetMockHttpsUrl("page204.html"));
|
| + GURL new_tab_url =
|
| + net::URLRequestMockHTTPJob::GetMockHttpsUrl("page204.html");
|
| ChangeDefaultSearchProvider("page204.html");
|
|
|
| - ui_test_utils::NavigateToURL(browser(), new_tab_url());
|
| + ui_test_utils::NavigateToURL(browser(), new_tab_url);
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetWebContentsAt(0);
|
| - content::NavigationController* controller = &contents->GetController();
|
| // 204 makes a redirect to the local NTP.
|
| EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
|
| - controller->GetLastCommittedEntry()->GetURL());
|
| + contents->GetController().GetLastCommittedEntry()->GetURL());
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(NewTabPageInterceptorTest, FailedRequestInterception) {
|
| - set_new_tab_url(
|
| - net::URLRequestMockHTTPJob::GetMockHttpsUrl("notarealfile.html"));
|
| + GURL new_tab_url =
|
| + net::URLRequestMockHTTPJob::GetMockHttpsUrl("notarealfile.html");
|
| ChangeDefaultSearchProvider("notarealfile.html");
|
|
|
| - ui_test_utils::NavigateToURL(browser(), new_tab_url());
|
| + ui_test_utils::NavigateToURL(browser(), new_tab_url);
|
| content::WebContents* contents =
|
| browser()->tab_strip_model()->GetWebContentsAt(0);
|
| - content::NavigationController* controller = &contents->GetController();
|
| // Failed navigation makes a redirect to the local NTP.
|
| EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
|
| - controller->GetLastCommittedEntry()->GetURL());
|
| + contents->GetController().GetLastCommittedEntry()->GetURL());
|
| }
|
|
|