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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 public net::URLFetcherDelegate { | 44 public net::URLFetcherDelegate { |
45 public: | 45 public: |
46 HttpServerTest() | 46 HttpServerTest() |
47 : num_responses_received_(0), | 47 : num_responses_received_(0), |
48 num_responses_expected_(0), | 48 num_responses_expected_(0), |
49 io_thread_("io_thread") { | 49 io_thread_("io_thread") { |
50 } | 50 } |
51 | 51 |
52 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() OVERRIDE { |
53 base::Thread::Options thread_options; | 53 base::Thread::Options thread_options; |
54 thread_options.message_loop_type = MessageLoop::TYPE_IO; | 54 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
55 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options)); | 55 ASSERT_TRUE(io_thread_.StartWithOptions(thread_options)); |
56 | 56 |
57 request_context_getter_ = new net::TestURLRequestContextGetter( | 57 request_context_getter_ = new net::TestURLRequestContextGetter( |
58 io_thread_.message_loop_proxy()); | 58 io_thread_.message_loop_proxy()); |
59 | 59 |
60 server_.reset(new HttpServer(io_thread_.message_loop_proxy())); | 60 server_.reset(new HttpServer(io_thread_.message_loop_proxy())); |
61 ASSERT_TRUE(server_->InitializeAndWaitUntilReady()); | 61 ASSERT_TRUE(server_->InitializeAndWaitUntilReady()); |
62 } | 62 } |
63 | 63 |
64 virtual void TearDown() OVERRIDE { | 64 virtual void TearDown() OVERRIDE { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 return scoped_ptr<HttpResponse>(); | 100 return scoped_ptr<HttpResponse>(); |
101 } | 101 } |
102 | 102 |
103 protected: | 103 protected: |
104 int num_responses_received_; | 104 int num_responses_received_; |
105 int num_responses_expected_; | 105 int num_responses_expected_; |
106 std::string request_relative_url_; | 106 std::string request_relative_url_; |
107 base::Thread io_thread_; | 107 base::Thread io_thread_; |
108 MessageLoop message_loop_; | 108 base::MessageLoop message_loop_; |
109 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 109 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
110 scoped_ptr<HttpServer> server_; | 110 scoped_ptr<HttpServer> server_; |
111 }; | 111 }; |
112 | 112 |
113 TEST_F(HttpServerTest, GetBaseURL) { | 113 TEST_F(HttpServerTest, GetBaseURL) { |
114 EXPECT_EQ(base::StringPrintf("http://127.0.0.1:%d/", server_->port()), | 114 EXPECT_EQ(base::StringPrintf("http://127.0.0.1:%d/", server_->port()), |
115 server_->base_url().spec()); | 115 server_->base_url().spec()); |
116 } | 116 } |
117 | 117 |
118 TEST_F(HttpServerTest, GetURL) { | 118 TEST_F(HttpServerTest, GetURL) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 EXPECT_EQ("text/html", GetContentTypeFromFetcher(*fetcher2)); | 214 EXPECT_EQ("text/html", GetContentTypeFromFetcher(*fetcher2)); |
215 | 215 |
216 EXPECT_EQ(net::URLRequestStatus::SUCCESS, fetcher3->GetStatus().status()); | 216 EXPECT_EQ(net::URLRequestStatus::SUCCESS, fetcher3->GetStatus().status()); |
217 EXPECT_EQ(NOT_FOUND, fetcher3->GetResponseCode()); | 217 EXPECT_EQ(NOT_FOUND, fetcher3->GetResponseCode()); |
218 EXPECT_EQ("No chocolates", GetContentFromFetcher(*fetcher3)); | 218 EXPECT_EQ("No chocolates", GetContentFromFetcher(*fetcher3)); |
219 EXPECT_EQ("text/plain", GetContentTypeFromFetcher(*fetcher3)); | 219 EXPECT_EQ("text/plain", GetContentTypeFromFetcher(*fetcher3)); |
220 } | 220 } |
221 | 221 |
222 } // namespace test_server | 222 } // namespace test_server |
223 } // namespace google_apis | 223 } // namespace google_apis |
OLD | NEW |