Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/browser/ui/search_engines/search_engine_tab_helper_browsertest.cc

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "chrome/browser/search_engines/template_url_service_factory.h" 6 #include "chrome/browser/search_engines/template_url_service_factory.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" 8 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "components/search_engines/template_url.h" 12 #include "components/search_engines/template_url.h"
13 #include "components/search_engines/template_url_service.h" 13 #include "components/search_engines/template_url_service.h"
14 #include "net/test/embedded_test_server/embedded_test_server.h" 14 #include "net/test/embedded_test_server/embedded_test_server.h"
15 #include "net/test/embedded_test_server/http_request.h" 15 #include "net/test/embedded_test_server/http_request.h"
16 #include "net/test/embedded_test_server/http_response.h" 16 #include "net/test/embedded_test_server/http_response.h"
17 17
18 using net::test_server::BasicHttpResponse; 18 using net::test_server::BasicHttpResponse;
19 using net::test_server::EmbeddedTestServer;
20 using net::test_server::HttpRequest; 19 using net::test_server::HttpRequest;
21 using net::test_server::HttpResponse; 20 using net::test_server::HttpResponse;
22 21
23 namespace { 22 namespace {
24 23
25 class TemplateURLServiceObserver { 24 class TemplateURLServiceObserver {
26 public: 25 public:
27 TemplateURLServiceObserver(TemplateURLService* service, base::RunLoop* loop) 26 TemplateURLServiceObserver(TemplateURLService* service, base::RunLoop* loop)
28 : runner_(loop) { 27 : runner_(loop) {
29 DCHECK(loop); 28 DCHECK(loop);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 81
83 // Starts a test server that serves a page pointing to a opensearch descriptor 82 // Starts a test server that serves a page pointing to a opensearch descriptor
84 // from a file:// url. 83 // from a file:// url.
85 bool StartTestServer() { 84 bool StartTestServer() {
86 GURL file_url = ui_test_utils::GetTestUrl( 85 GURL file_url = ui_test_utils::GetTestUrl(
87 base::FilePath(), 86 base::FilePath(),
88 base::FilePath().AppendASCII("simple_open_search.xml")); 87 base::FilePath().AppendASCII("simple_open_search.xml"));
89 embedded_test_server()->RegisterRequestHandler( 88 embedded_test_server()->RegisterRequestHandler(
90 base::Bind(&SearchEngineTabHelperBrowserTest::HandleRequest, 89 base::Bind(&SearchEngineTabHelperBrowserTest::HandleRequest,
91 base::Unretained(this), file_url)); 90 base::Unretained(this), file_url));
92 return embedded_test_server()->InitializeAndWaitUntilReady(); 91 return embedded_test_server()->Start();
93 } 92 }
94 93
95 void SetUpOnMainThread() override { ASSERT_TRUE(StartTestServer()); } 94 void SetUpOnMainThread() override { ASSERT_TRUE(StartTestServer()); }
96 95
97 DISALLOW_COPY_AND_ASSIGN(SearchEngineTabHelperBrowserTest); 96 DISALLOW_COPY_AND_ASSIGN(SearchEngineTabHelperBrowserTest);
98 }; 97 };
99 98
100 IN_PROC_BROWSER_TEST_F(SearchEngineTabHelperBrowserTest, 99 IN_PROC_BROWSER_TEST_F(SearchEngineTabHelperBrowserTest,
101 IgnoreSearchDescriptionsFromFileURLs) { 100 IgnoreSearchDescriptionsFromFileURLs) {
102 TemplateURLService* url_service = 101 TemplateURLService* url_service =
103 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 102 TemplateURLServiceFactory::GetForProfile(browser()->profile());
104 ASSERT_TRUE(url_service); 103 ASSERT_TRUE(url_service);
105 VerifyTemplateURLServiceLoad(url_service); 104 VerifyTemplateURLServiceLoad(url_service);
106 TemplateURLService::TemplateURLVector template_urls = 105 TemplateURLService::TemplateURLVector template_urls =
107 url_service->GetTemplateURLs(); 106 url_service->GetTemplateURLs();
108 // Navigate to a page with a search descriptor. Path doesn't matter as the 107 // Navigate to a page with a search descriptor. Path doesn't matter as the
109 // test server always serves the same HTML. 108 // test server always serves the same HTML.
110 GURL url(embedded_test_server()->GetURL("/")); 109 GURL url(embedded_test_server()->GetURL("/"));
111 ui_test_utils::NavigateToURL(browser(), url); 110 ui_test_utils::NavigateToURL(browser(), url);
112 // No new search engines should be added. 111 // No new search engines should be added.
113 EXPECT_EQ(template_urls, url_service->GetTemplateURLs()); 112 EXPECT_EQ(template_urls, url_service->GetTemplateURLs());
114 } 113 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/local_ntp_browsertest.cc ('k') | chrome/browser/ui/startup/startup_browser_creator_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698