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 "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/macros.h" | 9 #include "base/macros.h" |
6 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
8 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
13 #include "components/search_engines/template_url.h" | 16 #include "components/search_engines/template_url.h" |
14 #include "components/search_engines/template_url_service.h" | 17 #include "components/search_engines/template_url_service.h" |
15 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
16 #include "net/test/embedded_test_server/http_request.h" | 19 #include "net/test/embedded_test_server/http_request.h" |
17 #include "net/test/embedded_test_server/http_response.h" | 20 #include "net/test/embedded_test_server/http_response.h" |
18 | 21 |
19 using net::test_server::BasicHttpResponse; | 22 using net::test_server::BasicHttpResponse; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 " href='%s'" | 73 " href='%s'" |
71 " title='ExampleSearch'>" | 74 " title='ExampleSearch'>" |
72 "</head>" | 75 "</head>" |
73 "</html>", | 76 "</html>", |
74 osdd_xml_url.spec().c_str()); | 77 osdd_xml_url.spec().c_str()); |
75 | 78 |
76 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 79 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
77 http_response->set_code(net::HTTP_OK); | 80 http_response->set_code(net::HTTP_OK); |
78 http_response->set_content(html); | 81 http_response->set_content(html); |
79 http_response->set_content_type("text/html"); | 82 http_response->set_content_type("text/html"); |
80 return http_response.Pass(); | 83 return std::move(http_response); |
81 } | 84 } |
82 | 85 |
83 // Starts a test server that serves a page pointing to a opensearch descriptor | 86 // Starts a test server that serves a page pointing to a opensearch descriptor |
84 // from a file:// url. | 87 // from a file:// url. |
85 bool StartTestServer() { | 88 bool StartTestServer() { |
86 GURL file_url = ui_test_utils::GetTestUrl( | 89 GURL file_url = ui_test_utils::GetTestUrl( |
87 base::FilePath(), | 90 base::FilePath(), |
88 base::FilePath().AppendASCII("simple_open_search.xml")); | 91 base::FilePath().AppendASCII("simple_open_search.xml")); |
89 embedded_test_server()->RegisterRequestHandler( | 92 embedded_test_server()->RegisterRequestHandler( |
90 base::Bind(&SearchEngineTabHelperBrowserTest::HandleRequest, | 93 base::Bind(&SearchEngineTabHelperBrowserTest::HandleRequest, |
(...skipping 14 matching lines...) Expand all Loading... |
105 VerifyTemplateURLServiceLoad(url_service); | 108 VerifyTemplateURLServiceLoad(url_service); |
106 TemplateURLService::TemplateURLVector template_urls = | 109 TemplateURLService::TemplateURLVector template_urls = |
107 url_service->GetTemplateURLs(); | 110 url_service->GetTemplateURLs(); |
108 // Navigate to a page with a search descriptor. Path doesn't matter as the | 111 // Navigate to a page with a search descriptor. Path doesn't matter as the |
109 // test server always serves the same HTML. | 112 // test server always serves the same HTML. |
110 GURL url(embedded_test_server()->GetURL("/")); | 113 GURL url(embedded_test_server()->GetURL("/")); |
111 ui_test_utils::NavigateToURL(browser(), url); | 114 ui_test_utils::NavigateToURL(browser(), url); |
112 // No new search engines should be added. | 115 // No new search engines should be added. |
113 EXPECT_EQ(template_urls, url_service->GetTemplateURLs()); | 116 EXPECT_EQ(template_urls, url_service->GetTemplateURLs()); |
114 } | 117 } |
OLD | NEW |