OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/memory/ptr_util.h" | |
6 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
10 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 11 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/search_test_utils.h" | 16 #include "chrome/test/base/search_test_utils.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 52 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
52 search_test_utils::WaitForTemplateURLServiceToLoad(template_url_service); | 53 search_test_utils::WaitForTemplateURLServiceToLoad(template_url_service); |
53 UIThreadSearchTermsData::SetGoogleBaseURL("https://mock.http/"); | 54 UIThreadSearchTermsData::SetGoogleBaseURL("https://mock.http/"); |
54 std::string base_url("{google:baseURL}"); | 55 std::string base_url("{google:baseURL}"); |
55 TemplateURLData data; | 56 TemplateURLData data; |
56 data.SetShortName(base::ASCIIToUTF16("Google")); | 57 data.SetShortName(base::ASCIIToUTF16("Google")); |
57 data.SetKeyword(base::UTF8ToUTF16(base_url)); | 58 data.SetKeyword(base::UTF8ToUTF16(base_url)); |
58 data.SetURL(base_url + "url?bar={searchTerms}"); | 59 data.SetURL(base_url + "url?bar={searchTerms}"); |
59 data.new_tab_url = base_url + new_tab_path; | 60 data.new_tab_url = base_url + new_tab_path; |
60 TemplateURL* template_url = new TemplateURL(data); | 61 TemplateURL* template_url = new TemplateURL(data); |
61 // Takes ownership of |template_url|. | 62 // Takes ownership of |template_url|. |
Peter Kasting
2016/08/31 04:12:56
Nit: Comment is now redundant.
Avi (use Gerrit)
2016/09/01 00:34:26
Done.
| |
62 template_url_service->Add(template_url); | 63 template_url_service->Add(base::WrapUnique(template_url)); |
63 template_url_service->SetUserSelectedDefaultSearchProvider(template_url); | 64 template_url_service->SetUserSelectedDefaultSearchProvider(template_url); |
64 } | 65 } |
65 | 66 |
66 private: | 67 private: |
67 GURL new_tab_url_; | 68 GURL new_tab_url_; |
68 base::FilePath path_; | 69 base::FilePath path_; |
69 }; | 70 }; |
70 | 71 |
71 IN_PROC_BROWSER_TEST_F(NewTabPageInterceptorTest, NoInterception) { | 72 IN_PROC_BROWSER_TEST_F(NewTabPageInterceptorTest, NoInterception) { |
72 set_new_tab_url( | 73 set_new_tab_url( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 ChangeDefaultSearchProvider("notarealfile.html"); | 114 ChangeDefaultSearchProvider("notarealfile.html"); |
114 | 115 |
115 ui_test_utils::NavigateToURL(browser(), new_tab_url()); | 116 ui_test_utils::NavigateToURL(browser(), new_tab_url()); |
116 content::WebContents* contents = | 117 content::WebContents* contents = |
117 browser()->tab_strip_model()->GetWebContentsAt(0); | 118 browser()->tab_strip_model()->GetWebContentsAt(0); |
118 content::NavigationController* controller = &contents->GetController(); | 119 content::NavigationController* controller = &contents->GetController(); |
119 // Failed navigation makes a redirect to the local NTP. | 120 // Failed navigation makes a redirect to the local NTP. |
120 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), | 121 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), |
121 controller->GetLastCommittedEntry()->GetURL()); | 122 controller->GetLastCommittedEntry()->GetURL()); |
122 } | 123 } |
OLD | NEW |