OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "google_apis/drive/base_requests.h" | 5 #include "google_apis/drive/base_requests.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 request_context_getter_ = new net::TestURLRequestContextGetter( | 39 request_context_getter_ = new net::TestURLRequestContextGetter( |
40 message_loop_.task_runner()); | 40 message_loop_.task_runner()); |
41 | 41 |
42 request_sender_.reset(new RequestSender( | 42 request_sender_.reset(new RequestSender( |
43 new DummyAuthService, | 43 new DummyAuthService, |
44 request_context_getter_.get(), | 44 request_context_getter_.get(), |
45 message_loop_.task_runner(), | 45 message_loop_.task_runner(), |
46 kTestUserAgent)); | 46 kTestUserAgent)); |
47 | 47 |
48 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 48 ASSERT_TRUE(test_server_.Start()); |
49 test_server_.RegisterRequestHandler( | 49 test_server_.RegisterRequestHandler( |
50 base::Bind(&test_util::HandleDownloadFileRequest, | 50 base::Bind(&test_util::HandleDownloadFileRequest, |
51 test_server_.base_url(), | 51 test_server_.base_url(), |
52 base::Unretained(&http_request_))); | 52 base::Unretained(&http_request_))); |
53 } | 53 } |
54 | 54 |
55 // Returns a temporary file path suitable for storing the cache file. | 55 // Returns a temporary file path suitable for storing the cache file. |
56 base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) { | 56 base::FilePath GetTestCachedFilePath(const base::FilePath& file_name) { |
57 return temp_dir_.path().Append(file_name); | 57 return temp_dir_.path().Append(file_name); |
58 } | 58 } |
59 | 59 |
60 base::MessageLoopForIO message_loop_; // Test server needs IO thread. | 60 base::MessageLoopForIO message_loop_; // Test server needs IO thread. |
61 net::test_server::EmbeddedTestServer test_server_; | 61 net::EmbeddedTestServer test_server_; |
62 scoped_ptr<RequestSender> request_sender_; | 62 scoped_ptr<RequestSender> request_sender_; |
63 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 63 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
64 base::ScopedTempDir temp_dir_; | 64 base::ScopedTempDir temp_dir_; |
65 | 65 |
66 // The incoming HTTP request is saved so tests can verify the request | 66 // The incoming HTTP request is saved so tests can verify the request |
67 // parameters like HTTP method (ex. some requests should use DELETE | 67 // parameters like HTTP method (ex. some requests should use DELETE |
68 // instead of GET). | 68 // instead of GET). |
69 net::test_server::HttpRequest http_request_; | 69 net::test_server::HttpRequest http_request_; |
70 }; | 70 }; |
71 | 71 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 run_loop.Run(); | 122 run_loop.Run(); |
123 } | 123 } |
124 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 124 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
125 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 125 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
126 EXPECT_EQ("/files/gdata/no-such-file.txt", | 126 EXPECT_EQ("/files/gdata/no-such-file.txt", |
127 http_request_.relative_url); | 127 http_request_.relative_url); |
128 // Do not verify the not found message. | 128 // Do not verify the not found message. |
129 } | 129 } |
130 | 130 |
131 } // namespace google_apis | 131 } // namespace google_apis |
OLD | NEW |