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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months 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 "chrome/browser/ui/search_engines/search_engine_tab_helper.h" 5 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 21 matching lines...) Expand all
32 DCHECK(loop); 32 DCHECK(loop);
33 template_url_sub_ = service->RegisterOnLoadedCallback(base::Bind( 33 template_url_sub_ = service->RegisterOnLoadedCallback(base::Bind(
34 &TemplateURLServiceObserver::StopLoop, base::Unretained(this))); 34 &TemplateURLServiceObserver::StopLoop, base::Unretained(this)));
35 service->Load(); 35 service->Load();
36 } 36 }
37 ~TemplateURLServiceObserver() {} 37 ~TemplateURLServiceObserver() {}
38 38
39 private: 39 private:
40 void StopLoop() { runner_->Quit(); } 40 void StopLoop() { runner_->Quit(); }
41 base::RunLoop* runner_; 41 base::RunLoop* runner_;
42 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; 42 std::unique_ptr<TemplateURLService::Subscription> template_url_sub_;
43 43
44 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceObserver); 44 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceObserver);
45 }; 45 };
46 46
47 testing::AssertionResult VerifyTemplateURLServiceLoad( 47 testing::AssertionResult VerifyTemplateURLServiceLoad(
48 TemplateURLService* service) { 48 TemplateURLService* service) {
49 if (service->loaded()) 49 if (service->loaded())
50 return testing::AssertionSuccess(); 50 return testing::AssertionSuccess();
51 base::RunLoop runner; 51 base::RunLoop runner;
52 TemplateURLServiceObserver observer(service, &runner); 52 TemplateURLServiceObserver observer(service, &runner);
53 runner.Run(); 53 runner.Run();
54 if (service->loaded()) 54 if (service->loaded())
55 return testing::AssertionSuccess(); 55 return testing::AssertionSuccess();
56 return testing::AssertionFailure() << "TemplateURLService isn't loaded"; 56 return testing::AssertionFailure() << "TemplateURLService isn't loaded";
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 class SearchEngineTabHelperBrowserTest : public InProcessBrowserTest { 61 class SearchEngineTabHelperBrowserTest : public InProcessBrowserTest {
62 public: 62 public:
63 SearchEngineTabHelperBrowserTest() {} 63 SearchEngineTabHelperBrowserTest() {}
64 ~SearchEngineTabHelperBrowserTest() override {} 64 ~SearchEngineTabHelperBrowserTest() override {}
65 65
66 private: 66 private:
67 scoped_ptr<HttpResponse> HandleRequest(const GURL& osdd_xml_url, 67 std::unique_ptr<HttpResponse> HandleRequest(const GURL& osdd_xml_url,
68 const HttpRequest& request) { 68 const HttpRequest& request) {
69 std::string html = base::StringPrintf( 69 std::string html = base::StringPrintf(
70 "<html>" 70 "<html>"
71 "<head>" 71 "<head>"
72 " <link rel='search' type='application/opensearchdescription+xml'" 72 " <link rel='search' type='application/opensearchdescription+xml'"
73 " href='%s'" 73 " href='%s'"
74 " title='ExampleSearch'>" 74 " title='ExampleSearch'>"
75 "</head>" 75 "</head>"
76 "</html>", 76 "</html>",
77 osdd_xml_url.spec().c_str()); 77 osdd_xml_url.spec().c_str());
78 78
79 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); 79 std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
80 http_response->set_code(net::HTTP_OK); 80 http_response->set_code(net::HTTP_OK);
81 http_response->set_content(html); 81 http_response->set_content(html);
82 http_response->set_content_type("text/html"); 82 http_response->set_content_type("text/html");
83 return std::move(http_response); 83 return std::move(http_response);
84 } 84 }
85 85
86 // 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
87 // from a file:// url. 87 // from a file:// url.
88 bool StartTestServer() { 88 bool StartTestServer() {
89 GURL file_url = ui_test_utils::GetTestUrl( 89 GURL file_url = ui_test_utils::GetTestUrl(
(...skipping 18 matching lines...) Expand all
108 VerifyTemplateURLServiceLoad(url_service); 108 VerifyTemplateURLServiceLoad(url_service);
109 TemplateURLService::TemplateURLVector template_urls = 109 TemplateURLService::TemplateURLVector template_urls =
110 url_service->GetTemplateURLs(); 110 url_service->GetTemplateURLs();
111 // 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
112 // test server always serves the same HTML. 112 // test server always serves the same HTML.
113 GURL url(embedded_test_server()->GetURL("/")); 113 GURL url(embedded_test_server()->GetURL("/"));
114 ui_test_utils::NavigateToURL(browser(), url); 114 ui_test_utils::NavigateToURL(browser(), url);
115 // No new search engines should be added. 115 // No new search engines should be added.
116 EXPECT_EQ(template_urls, url_service->GetTemplateURLs()); 116 EXPECT_EQ(template_urls, url_service->GetTemplateURLs());
117 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698