| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 72 TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) { | 72 TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) { |
| 73 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 73 DriveApiErrorCode result_code = DRIVE_OTHER_ERROR; |
| 74 base::FilePath temp_file; | 74 base::FilePath temp_file; |
| 75 { | 75 { |
| 76 base::RunLoop run_loop; | 76 base::RunLoop run_loop; |
| 77 DownloadFileRequestBase* request = new DownloadFileRequestBase( | 77 DownloadFileRequestBase* request = new DownloadFileRequestBase( |
| 78 request_sender_.get(), | 78 request_sender_.get(), |
| 79 test_util::CreateQuitCallback( | 79 test_util::CreateQuitCallback( |
| 80 &run_loop, | 80 &run_loop, |
| 81 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 81 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
| 82 GetContentCallback(), | 82 GetContentCallback(), |
| 83 ProgressCallback(), | 83 ProgressCallback(), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 EXPECT_EQ("/files/drive/testfile.txt", http_request_.relative_url); | 97 EXPECT_EQ("/files/drive/testfile.txt", http_request_.relative_url); |
| 98 | 98 |
| 99 const base::FilePath expected_path = | 99 const base::FilePath expected_path = |
| 100 test_util::GetTestFilePath("drive/testfile.txt"); | 100 test_util::GetTestFilePath("drive/testfile.txt"); |
| 101 std::string expected_contents; | 101 std::string expected_contents; |
| 102 base::ReadFileToString(expected_path, &expected_contents); | 102 base::ReadFileToString(expected_path, &expected_contents); |
| 103 EXPECT_EQ(expected_contents, contents); | 103 EXPECT_EQ(expected_contents, contents); |
| 104 } | 104 } |
| 105 | 105 |
| 106 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) { | 106 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) { |
| 107 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 107 DriveApiErrorCode result_code = DRIVE_OTHER_ERROR; |
| 108 base::FilePath temp_file; | 108 base::FilePath temp_file; |
| 109 { | 109 { |
| 110 base::RunLoop run_loop; | 110 base::RunLoop run_loop; |
| 111 DownloadFileRequestBase* request = new DownloadFileRequestBase( | 111 DownloadFileRequestBase* request = new DownloadFileRequestBase( |
| 112 request_sender_.get(), | 112 request_sender_.get(), |
| 113 test_util::CreateQuitCallback( | 113 test_util::CreateQuitCallback( |
| 114 &run_loop, | 114 &run_loop, |
| 115 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 115 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
| 116 GetContentCallback(), | 116 GetContentCallback(), |
| 117 ProgressCallback(), | 117 ProgressCallback(), |
| 118 test_server_.GetURL("/files/gdata/no-such-file.txt"), | 118 test_server_.GetURL("/files/gdata/no-such-file.txt"), |
| 119 GetTestCachedFilePath( | 119 GetTestCachedFilePath( |
| 120 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); | 120 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); |
| 121 request_sender_->StartRequestWithRetry(request); | 121 request_sender_->StartRequestWithRetry(request); |
| 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 |