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 "chrome/browser/google_apis/base_requests.h" | 5 #include "chrome/browser/google_apis/base_requests.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 net::test_server::HttpRequest http_request_; | 81 net::test_server::HttpRequest http_request_; |
82 }; | 82 }; |
83 | 83 |
84 TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) { | 84 TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) { |
85 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 85 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
86 base::FilePath temp_file; | 86 base::FilePath temp_file; |
87 { | 87 { |
88 base::RunLoop run_loop; | 88 base::RunLoop run_loop; |
89 DownloadFileRequest* request = new DownloadFileRequest( | 89 DownloadFileRequest* request = new DownloadFileRequest( |
90 request_sender_.get(), | 90 request_sender_.get(), |
91 request_context_getter_.get(), | |
92 test_util::CreateQuitCallback( | 91 test_util::CreateQuitCallback( |
93 &run_loop, | 92 &run_loop, |
94 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 93 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
95 GetContentCallback(), | 94 GetContentCallback(), |
96 ProgressCallback(), | 95 ProgressCallback(), |
97 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 96 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
98 GetTestCachedFilePath( | 97 GetTestCachedFilePath( |
99 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); | 98 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); |
100 request_sender_->StartRequestWithRetry(request); | 99 request_sender_->StartRequestWithRetry(request); |
101 run_loop.Run(); | 100 run_loop.Run(); |
(...skipping 14 matching lines...) Expand all Loading... |
116 EXPECT_EQ(expected_contents, contents); | 115 EXPECT_EQ(expected_contents, contents); |
117 } | 116 } |
118 | 117 |
119 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) { | 118 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) { |
120 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 119 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
121 base::FilePath temp_file; | 120 base::FilePath temp_file; |
122 { | 121 { |
123 base::RunLoop run_loop; | 122 base::RunLoop run_loop; |
124 DownloadFileRequest* request = new DownloadFileRequest( | 123 DownloadFileRequest* request = new DownloadFileRequest( |
125 request_sender_.get(), | 124 request_sender_.get(), |
126 request_context_getter_.get(), | |
127 test_util::CreateQuitCallback( | 125 test_util::CreateQuitCallback( |
128 &run_loop, | 126 &run_loop, |
129 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 127 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
130 GetContentCallback(), | 128 GetContentCallback(), |
131 ProgressCallback(), | 129 ProgressCallback(), |
132 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), | 130 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), |
133 GetTestCachedFilePath( | 131 GetTestCachedFilePath( |
134 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); | 132 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); |
135 request_sender_->StartRequestWithRetry(request); | 133 request_sender_->StartRequestWithRetry(request); |
136 run_loop.Run(); | 134 run_loop.Run(); |
137 } | 135 } |
138 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 136 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
139 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 137 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
140 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", | 138 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", |
141 http_request_.relative_url); | 139 http_request_.relative_url); |
142 // Do not verify the not found message. | 140 // Do not verify the not found message. |
143 } | 141 } |
144 | 142 |
145 } // namespace google_apis | 143 } // namespace google_apis |
OLD | NEW |