| 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/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 base::FilePath temp_file; | 87 base::FilePath temp_file; |
| 88 DownloadFileRequest* request = new DownloadFileRequest( | 88 DownloadFileRequest* request = new DownloadFileRequest( |
| 89 request_sender_.get(), | 89 request_sender_.get(), |
| 90 request_context_getter_.get(), | 90 request_context_getter_.get(), |
| 91 CreateComposedCallback( | 91 CreateComposedCallback( |
| 92 base::Bind(&test_util::RunAndQuit), | 92 base::Bind(&test_util::RunAndQuit), |
| 93 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 93 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
| 94 GetContentCallback(), | 94 GetContentCallback(), |
| 95 ProgressCallback(), | 95 ProgressCallback(), |
| 96 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 96 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
| 97 base::FilePath::FromUTF8Unsafe("/dummy/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 base::MessageLoop::current()->Run(); | 100 base::MessageLoop::current()->Run(); |
| 102 | 101 |
| 103 std::string contents; | 102 std::string contents; |
| 104 file_util::ReadFileToString(temp_file, &contents); | 103 file_util::ReadFileToString(temp_file, &contents); |
| 105 file_util::Delete(temp_file, false); | 104 file_util::Delete(temp_file, false); |
| 106 | 105 |
| 107 EXPECT_EQ(HTTP_SUCCESS, result_code); | 106 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 120 base::FilePath temp_file; | 119 base::FilePath temp_file; |
| 121 DownloadFileRequest* request = new DownloadFileRequest( | 120 DownloadFileRequest* request = new DownloadFileRequest( |
| 122 request_sender_.get(), | 121 request_sender_.get(), |
| 123 request_context_getter_.get(), | 122 request_context_getter_.get(), |
| 124 CreateComposedCallback( | 123 CreateComposedCallback( |
| 125 base::Bind(&test_util::RunAndQuit), | 124 base::Bind(&test_util::RunAndQuit), |
| 126 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 125 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
| 127 GetContentCallback(), | 126 GetContentCallback(), |
| 128 ProgressCallback(), | 127 ProgressCallback(), |
| 129 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), | 128 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), |
| 130 base::FilePath::FromUTF8Unsafe("/dummy/gdata/no-such-file.txt"), | |
| 131 GetTestCachedFilePath( | 129 GetTestCachedFilePath( |
| 132 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); | 130 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); |
| 133 request_sender_->StartRequestWithRetry(request); | 131 request_sender_->StartRequestWithRetry(request); |
| 134 base::MessageLoop::current()->Run(); | 132 base::MessageLoop::current()->Run(); |
| 135 | 133 |
| 136 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 134 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
| 137 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 135 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 138 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", | 136 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", |
| 139 http_request_.relative_url); | 137 http_request_.relative_url); |
| 140 // Do not verify the not found message. | 138 // Do not verify the not found message. |
| 141 } | 139 } |
| 142 | 140 |
| 143 } // namespace google_apis | 141 } // namespace google_apis |
| OLD | NEW |