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

Side by Side Diff: chrome/browser/ui/app_list/search/webstore/webstore_provider_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list/search/webstore/webstore_provider.h" 5 #include "chrome/browser/ui/app_list/search/webstore/webstore_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
9 #include <memory>
8 #include <string> 10 #include <string>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/command_line.h" 14 #include "base/command_line.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/app_list/search/webstore/webstore_result.h" 19 #include "chrome/browser/ui/app_list/search/webstore/webstore_result.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
23 #include "net/test/embedded_test_server/embedded_test_server.h" 24 #include "net/test/embedded_test_server/embedded_test_server.h"
24 #include "net/test/embedded_test_server/http_request.h" 25 #include "net/test/embedded_test_server/http_request.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 const std::string& mock_server_response, 215 const std::string& mock_server_response,
215 const ParsedSearchResult* expected_results, 216 const ParsedSearchResult* expected_results,
216 size_t expected_result_size) { 217 size_t expected_result_size) {
217 RunQuery(query, mock_server_response); 218 RunQuery(query, mock_server_response);
218 VerifyResults(expected_results, expected_result_size); 219 VerifyResults(expected_results, expected_result_size);
219 } 220 }
220 221
221 WebstoreProvider* webstore_provider() { return webstore_provider_.get(); } 222 WebstoreProvider* webstore_provider() { return webstore_provider_.get(); }
222 223
223 private: 224 private:
224 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { 225 std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) {
225 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); 226 std::unique_ptr<BasicHttpResponse> response(new BasicHttpResponse);
226 227
227 if (request.relative_url.find("/jsonsearch?") != std::string::npos) { 228 if (request.relative_url.find("/jsonsearch?") != std::string::npos) {
228 if (mock_server_response_ == "ERROR_NOT_FOUND") { 229 if (mock_server_response_ == "ERROR_NOT_FOUND") {
229 response->set_code(net::HTTP_NOT_FOUND); 230 response->set_code(net::HTTP_NOT_FOUND);
230 } else if (mock_server_response_ == "ERROR_INTERNAL_SERVER_ERROR") { 231 } else if (mock_server_response_ == "ERROR_INTERNAL_SERVER_ERROR") {
231 response->set_code(net::HTTP_INTERNAL_SERVER_ERROR); 232 response->set_code(net::HTTP_INTERNAL_SERVER_ERROR);
232 } else { 233 } else {
233 response->set_code(net::HTTP_OK); 234 response->set_code(net::HTTP_OK);
234 response->set_content(mock_server_response_); 235 response->set_content(mock_server_response_);
235 } 236 }
236 } 237 }
237 238
238 return std::move(response); 239 return std::move(response);
239 } 240 }
240 241
241 void OnSearchResultsFetched() { 242 void OnSearchResultsFetched() {
242 if (run_loop_) 243 if (run_loop_)
243 run_loop_->Quit(); 244 run_loop_->Quit();
244 } 245 }
245 246
246 scoped_ptr<base::RunLoop> run_loop_; 247 std::unique_ptr<base::RunLoop> run_loop_;
247 248
248 std::string mock_server_response_; 249 std::string mock_server_response_;
249 250
250 scoped_ptr<WebstoreProvider> webstore_provider_; 251 std::unique_ptr<WebstoreProvider> webstore_provider_;
251 252
252 DISALLOW_COPY_AND_ASSIGN(WebstoreProviderTest); 253 DISALLOW_COPY_AND_ASSIGN(WebstoreProviderTest);
253 }; 254 };
254 255
255 IN_PROC_BROWSER_TEST_F(WebstoreProviderTest, Basic) { 256 IN_PROC_BROWSER_TEST_F(WebstoreProviderTest, Basic) {
256 struct { 257 struct {
257 const char* query; 258 const char* query;
258 const char* mock_server_response; 259 const char* mock_server_response;
259 const char* expected_result_titles; 260 const char* expected_result_titles;
260 const ParsedSearchResult* expected_results; 261 const ParsedSearchResult* expected_results;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 336
336 IN_PROC_BROWSER_TEST_F(WebstoreProviderTest, SearchCache) { 337 IN_PROC_BROWSER_TEST_F(WebstoreProviderTest, SearchCache) {
337 RunQueryAndVerify("fun", kOneResult, kParsedOneResult, 1); 338 RunQueryAndVerify("fun", kOneResult, kParsedOneResult, 1);
338 339
339 // No result is provided but the provider gets the result from the cache. 340 // No result is provided but the provider gets the result from the cache.
340 RunQueryAndVerify("fun", "", kParsedOneResult, 1); 341 RunQueryAndVerify("fun", "", kParsedOneResult, 1);
341 } 342 }
342 343
343 } // namespace test 344 } // namespace test
344 } // namespace app_list 345 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698