OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/google_apis/test_server/http_server.h" | 5 #include "chrome/browser/google_apis/test_server/http_server.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "chrome/browser/google_apis/test_server/http_request.h" | 9 #include "chrome/browser/google_apis/test_server/http_request.h" |
10 #include "chrome/browser/google_apis/test_server/http_response.h" | 10 #include "chrome/browser/google_apis/test_server/http_response.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 // Gets the content type from the given URLFetcher. | 33 // Gets the content type from the given URLFetcher. |
34 std::string GetContentTypeFromFetcher(const net::URLFetcher& fetcher) { | 34 std::string GetContentTypeFromFetcher(const net::URLFetcher& fetcher) { |
35 const net::HttpResponseHeaders* headers = fetcher.GetResponseHeaders(); | 35 const net::HttpResponseHeaders* headers = fetcher.GetResponseHeaders(); |
36 if (headers) { | 36 if (headers) { |
37 std::string content_type; | 37 std::string content_type; |
38 if (headers->GetMimeType(&content_type)) | 38 if (headers->GetMimeType(&content_type)) |
39 return content_type; | 39 return content_type; |
40 } | 40 } |
41 return ""; | 41 return std::string(); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 class HttpServerTest : public testing::Test, | 46 class HttpServerTest : public testing::Test, |
47 public net::URLFetcherDelegate { | 47 public net::URLFetcherDelegate { |
48 public: | 48 public: |
49 HttpServerTest() | 49 HttpServerTest() |
50 : num_responses_received_(0), | 50 : num_responses_received_(0), |
51 num_responses_expected_(0), | 51 num_responses_expected_(0), |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 EXPECT_EQ("text/html", GetContentTypeFromFetcher(*fetcher2)); | 217 EXPECT_EQ("text/html", GetContentTypeFromFetcher(*fetcher2)); |
218 | 218 |
219 EXPECT_EQ(net::URLRequestStatus::SUCCESS, fetcher3->GetStatus().status()); | 219 EXPECT_EQ(net::URLRequestStatus::SUCCESS, fetcher3->GetStatus().status()); |
220 EXPECT_EQ(NOT_FOUND, fetcher3->GetResponseCode()); | 220 EXPECT_EQ(NOT_FOUND, fetcher3->GetResponseCode()); |
221 EXPECT_EQ("No chocolates", GetContentFromFetcher(*fetcher3)); | 221 EXPECT_EQ("No chocolates", GetContentFromFetcher(*fetcher3)); |
222 EXPECT_EQ("text/plain", GetContentTypeFromFetcher(*fetcher3)); | 222 EXPECT_EQ("text/plain", GetContentTypeFromFetcher(*fetcher3)); |
223 } | 223 } |
224 | 224 |
225 } // namespace test_server | 225 } // namespace test_server |
226 } // namespace google_apis | 226 } // namespace google_apis |
OLD | NEW |