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

Side by Side Diff: ios/web/public/test/http_server_util.mm

Issue 2193543002: [ios] Added web::test::SetUpHttpServer which takes ResponseProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « ios/web/public/test/http_server_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/web/public/test/http_server_util.h" 5 #include "ios/web/public/test/http_server_util.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #import "ios/web/public/test/http_server.h" 9 #import "ios/web/public/test/http_server.h"
10 #include "ios/web/public/test/response_providers/file_based_response_provider.h" 10 #include "ios/web/public/test/response_providers/file_based_response_provider.h"
11 #include "ios/web/public/test/response_providers/html_response_provider.h" 11 #include "ios/web/public/test/response_providers/html_response_provider.h"
12 12
13 namespace web { 13 namespace web {
14 namespace test { 14 namespace test {
15 15
16 void SetUpSimpleHttpServer(const std::map<GURL, std::string>& responses) { 16 void SetUpSimpleHttpServer(const std::map<GURL, std::string>& responses) {
17 SetUpHttpServer(base::MakeUnique<HtmlResponseProvider>(responses));
18 }
19
20 void SetUpFileBasedHttpServer() {
21 base::FilePath path;
22 PathService::Get(base::DIR_MODULE, &path);
23 SetUpHttpServer(base::MakeUnique<FileBasedResponseProvider>(path));
24 }
25
26 void SetUpHttpServer(std::unique_ptr<web::ResponseProvider> provider) {
17 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 27 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
18 DCHECK(server.IsRunning()); 28 DCHECK(server.IsRunning());
19 auto provider = base::MakeUnique<HtmlResponseProvider>(responses);
20 29
21 server.RemoveAllResponseProviders(); 30 server.RemoveAllResponseProviders();
22 server.AddResponseProvider(std::move(provider)); 31 server.AddResponseProvider(std::move(provider));
23 }
24
25 void SetUpFileBasedHttpServer() {
26 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
27 DCHECK(server.IsRunning());
28 base::FilePath path;
29 PathService::Get(base::DIR_MODULE, &path);
30 auto provider = base::MakeUnique<FileBasedResponseProvider>(path);
31
32 server.RemoveAllResponseProviders();
33 server.AddResponseProvider(std::move(provider));
34 } 32 }
35 33
36 } // namespace test 34 } // namespace test
37 } // namespace web 35 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/public/test/http_server_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698