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 "remoting/host/url_fetcher.h" | 5 #include "remoting/host/url_fetcher.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "net/test/test_server.h" | 9 #include "net/test/test_server.h" |
10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 protected: | 28 protected: |
29 void SetUp() OVERRIDE { | 29 void SetUp() OVERRIDE { |
30 ASSERT_TRUE(io_thread_.StartWithOptions( | 30 ASSERT_TRUE(io_thread_.StartWithOptions( |
31 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 31 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
32 ASSERT_TRUE(file_thread_.StartWithOptions( | 32 ASSERT_TRUE(file_thread_.StartWithOptions( |
33 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 33 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
34 context_getter_ = new URLRequestContextGetter( | 34 context_getter_ = new URLRequestContextGetter( |
35 message_loop_.message_loop_proxy(), | 35 message_loop_.message_loop_proxy(), |
36 io_thread_.message_loop(), | 36 io_thread_.message_loop_proxy(), |
37 static_cast<MessageLoopForIO*>(file_thread_.message_loop())); | 37 static_cast<MessageLoopForIO*>(file_thread_.message_loop())); |
38 ASSERT_TRUE(test_server_.Start()); | 38 ASSERT_TRUE(test_server_.Start()); |
39 } | 39 } |
40 | 40 |
41 protected: | 41 protected: |
42 void OnDone(const net::URLRequestStatus& status, | 42 void OnDone(const net::URLRequestStatus& status, |
43 int response_code, | 43 int response_code, |
44 const std::string& response) { | 44 const std::string& response) { |
45 ASSERT_EQ(MessageLoop::current(), &message_loop_); | 45 ASSERT_EQ(MessageLoop::current(), &message_loop_); |
46 status_ = status; | 46 status_ = status; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 UrlFetcher fetcher(test_server_.GetURL("auth-basic"), UrlFetcher::GET); | 87 UrlFetcher fetcher(test_server_.GetURL("auth-basic"), UrlFetcher::GET); |
88 fetcher.SetRequestContext(context_getter_); | 88 fetcher.SetRequestContext(context_getter_); |
89 fetcher.Start(base::Bind(&UrlFetcherTest_TestFailed_Test::OnDone, | 89 fetcher.Start(base::Bind(&UrlFetcherTest_TestFailed_Test::OnDone, |
90 base::Unretained(this))); | 90 base::Unretained(this))); |
91 message_loop_.Run(); | 91 message_loop_.Run(); |
92 EXPECT_EQ(net::URLRequestStatus::SUCCESS, status_.status()); | 92 EXPECT_EQ(net::URLRequestStatus::SUCCESS, status_.status()); |
93 EXPECT_EQ(401, response_code_); | 93 EXPECT_EQ(401, response_code_); |
94 } | 94 } |
95 | 95 |
96 } // namespace remoting | 96 } // namespace remoting |
OLD | NEW |