| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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(), | 
| 84         test_server_.GetURL("/files/gdata/testfile.txt"), | 84         test_server_.GetURL("/files/drive/testfile.txt"), | 
| 85         GetTestCachedFilePath( | 85         GetTestCachedFilePath( | 
| 86             base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); | 86             base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); | 
| 87     request_sender_->StartRequestWithRetry(request); | 87     request_sender_->StartRequestWithRetry(request); | 
| 88     run_loop.Run(); | 88     run_loop.Run(); | 
| 89   } | 89   } | 
| 90 | 90 | 
| 91   std::string contents; | 91   std::string contents; | 
| 92   base::ReadFileToString(temp_file, &contents); | 92   base::ReadFileToString(temp_file, &contents); | 
| 93   base::DeleteFile(temp_file, false); | 93   base::DeleteFile(temp_file, false); | 
| 94 | 94 | 
| 95   EXPECT_EQ(HTTP_SUCCESS, result_code); | 95   EXPECT_EQ(HTTP_SUCCESS, result_code); | 
| 96   EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 96   EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 
| 97   EXPECT_EQ("/files/gdata/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("gdata/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   GDataErrorCode result_code = GDATA_OTHER_ERROR; | 
| 108   base::FilePath temp_file; | 108   base::FilePath temp_file; | 
| 109   { | 109   { | 
| 110     base::RunLoop run_loop; | 110     base::RunLoop run_loop; | 
| (...skipping 11 matching lines...) Expand all  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 | 
|---|