OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <utility> |
6 | 7 |
7 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/search_engines/template_url_service_factory.h" | 14 #include "chrome/browser/search_engines/template_url_service_factory.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 base::FilePath test_data_dir; | 56 base::FilePath test_data_dir; |
56 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 57 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
57 base::FilePath index_file = test_data_dir.AppendASCII("template_url_scraper") | 58 base::FilePath index_file = test_data_dir.AppendASCII("template_url_scraper") |
58 .AppendASCII("submit_handler") | 59 .AppendASCII("submit_handler") |
59 .AppendASCII("index.html"); | 60 .AppendASCII("index.html"); |
60 std::string file_contents; | 61 std::string file_contents; |
61 EXPECT_TRUE(base::ReadFileToString(index_file, &file_contents)); | 62 EXPECT_TRUE(base::ReadFileToString(index_file, &file_contents)); |
62 scoped_ptr<net::test_server::BasicHttpResponse> response( | 63 scoped_ptr<net::test_server::BasicHttpResponse> response( |
63 new net::test_server::BasicHttpResponse); | 64 new net::test_server::BasicHttpResponse); |
64 response->set_content(file_contents); | 65 response->set_content(file_contents); |
65 return response.Pass(); | 66 return std::move(response); |
66 } | 67 } |
67 | 68 |
68 } // namespace | 69 } // namespace |
69 | 70 |
70 IN_PROC_BROWSER_TEST_F(TemplateURLScraperTest, ScrapeWithOnSubmit) { | 71 IN_PROC_BROWSER_TEST_F(TemplateURLScraperTest, ScrapeWithOnSubmit) { |
71 host_resolver()->AddRule("*.foo.com", "localhost"); | 72 host_resolver()->AddRule("*.foo.com", "localhost"); |
72 embedded_test_server()->RegisterRequestHandler(base::Bind(&SendResponse)); | 73 embedded_test_server()->RegisterRequestHandler(base::Bind(&SendResponse)); |
73 ASSERT_TRUE(embedded_test_server()->Start()); | 74 ASSERT_TRUE(embedded_test_server()->Start()); |
74 | 75 |
75 TemplateURLService* template_urls = | 76 TemplateURLService* template_urls = |
(...skipping 25 matching lines...) Expand all Loading... |
101 | 102 |
102 content::WebContents* web_contents = | 103 content::WebContents* web_contents = |
103 browser()->tab_strip_model()->GetActiveWebContents(); | 104 browser()->tab_strip_model()->GetActiveWebContents(); |
104 content::TestNavigationObserver observer(web_contents); | 105 content::TestNavigationObserver observer(web_contents); |
105 EXPECT_TRUE(content::ExecuteScript(web_contents, "submit_form()")); | 106 EXPECT_TRUE(content::ExecuteScript(web_contents, "submit_form()")); |
106 observer.Wait(); | 107 observer.Wait(); |
107 | 108 |
108 all_urls = template_urls->GetTemplateURLs(); | 109 all_urls = template_urls->GetTemplateURLs(); |
109 EXPECT_EQ(prepopulate_urls.size() + 1, all_urls.size()); | 110 EXPECT_EQ(prepopulate_urls.size() + 1, all_urls.size()); |
110 } | 111 } |
OLD | NEW |