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 "net/test/embedded_test_server/embedded_test_server.h" | 5 #include "net/test/embedded_test_server/embedded_test_server.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
10 #include "net/test/embedded_test_server/http_request.h" | 10 #include "net/test/embedded_test_server/http_request.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(EmbeddedTestServerTest, GetURL) { | 118 TEST_F(EmbeddedTestServerTest, GetURL) { |
119 EXPECT_EQ(base::StringPrintf("http://127.0.0.1:%d/path?query=foo", | 119 EXPECT_EQ(base::StringPrintf("http://127.0.0.1:%d/path?query=foo", |
120 server_->port()), | 120 server_->port()), |
121 server_->GetURL("/path?query=foo").spec()); | 121 server_->GetURL("/path?query=foo").spec()); |
122 } | 122 } |
123 | 123 |
| 124 TEST_F(EmbeddedTestServerTest, GetURLWithHostname) { |
| 125 EXPECT_EQ(base::StringPrintf("http://foo.com:%d/path?query=foo", |
| 126 server_->port()), |
| 127 server_->GetURL("foo.com", "/path?query=foo").spec()); |
| 128 } |
| 129 |
124 TEST_F(EmbeddedTestServerTest, RegisterRequestHandler) { | 130 TEST_F(EmbeddedTestServerTest, RegisterRequestHandler) { |
125 server_->RegisterRequestHandler( | 131 server_->RegisterRequestHandler( |
126 base::Bind(&EmbeddedTestServerTest::HandleRequest, | 132 base::Bind(&EmbeddedTestServerTest::HandleRequest, |
127 base::Unretained(this), | 133 base::Unretained(this), |
128 "/test", | 134 "/test", |
129 "<b>Worked!</b>", | 135 "<b>Worked!</b>", |
130 "text/html", | 136 "text/html", |
131 HTTP_OK)); | 137 HTTP_OK)); |
132 | 138 |
133 scoped_ptr<URLFetcher> fetcher( | 139 scoped_ptr<URLFetcher> fetcher( |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); | 326 ASSERT_TRUE(base::PlatformThread::Create(0, &delegate, &thread_handle)); |
321 base::PlatformThread::Join(thread_handle); | 327 base::PlatformThread::Join(thread_handle); |
322 } | 328 } |
323 | 329 |
324 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, | 330 INSTANTIATE_TEST_CASE_P(EmbeddedTestServerThreadingTestInstantiation, |
325 EmbeddedTestServerThreadingTest, | 331 EmbeddedTestServerThreadingTest, |
326 testing::Combine(testing::Bool(), testing::Bool())); | 332 testing::Combine(testing::Bool(), testing::Bool())); |
327 | 333 |
328 } // namespace test_server | 334 } // namespace test_server |
329 } // namespace net | 335 } // namespace net |
OLD | NEW |