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_operations.h" | 5 #include "chrome/browser/google_apis/base_operations.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 TEST_F(BaseOperationsServerTest, DownloadFileOperation_ValidFile) { | 82 TEST_F(BaseOperationsServerTest, DownloadFileOperation_ValidFile) { |
83 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 83 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
84 base::FilePath temp_file; | 84 base::FilePath temp_file; |
85 DownloadFileOperation* operation = new DownloadFileOperation( | 85 DownloadFileOperation* operation = new DownloadFileOperation( |
86 &operation_registry_, | 86 &operation_registry_, |
87 request_context_getter_.get(), | 87 request_context_getter_.get(), |
88 CreateComposedCallback( | 88 CreateComposedCallback( |
89 base::Bind(&test_util::RunAndQuit), | 89 base::Bind(&test_util::RunAndQuit), |
90 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 90 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
91 GetContentCallback(), | 91 GetContentCallback(), |
| 92 ProgressCallback(), |
92 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 93 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
93 base::FilePath::FromUTF8Unsafe("/dummy/gdata/testfile.txt"), | 94 base::FilePath::FromUTF8Unsafe("/dummy/gdata/testfile.txt"), |
94 GetTestCachedFilePath( | 95 GetTestCachedFilePath( |
95 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); | 96 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); |
96 operation->Start(kTestAuthToken, kTestUserAgent, | 97 operation->Start(kTestAuthToken, kTestUserAgent, |
97 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 98 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
98 MessageLoop::current()->Run(); | 99 MessageLoop::current()->Run(); |
99 | 100 |
100 std::string contents; | 101 std::string contents; |
101 file_util::ReadFileToString(temp_file, &contents); | 102 file_util::ReadFileToString(temp_file, &contents); |
(...skipping 15 matching lines...) Expand all Loading... |
117 DISABLED_DownloadFileOperation_NonExistentFile) { | 118 DISABLED_DownloadFileOperation_NonExistentFile) { |
118 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 119 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
119 base::FilePath temp_file; | 120 base::FilePath temp_file; |
120 DownloadFileOperation* operation = new DownloadFileOperation( | 121 DownloadFileOperation* operation = new DownloadFileOperation( |
121 &operation_registry_, | 122 &operation_registry_, |
122 request_context_getter_.get(), | 123 request_context_getter_.get(), |
123 CreateComposedCallback( | 124 CreateComposedCallback( |
124 base::Bind(&test_util::RunAndQuit), | 125 base::Bind(&test_util::RunAndQuit), |
125 test_util::CreateCopyResultCallback(&result_code, &temp_file)), | 126 test_util::CreateCopyResultCallback(&result_code, &temp_file)), |
126 GetContentCallback(), | 127 GetContentCallback(), |
| 128 ProgressCallback(), |
127 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), | 129 test_server_.GetURL("/files/chromeos/gdata/no-such-file.txt"), |
128 base::FilePath::FromUTF8Unsafe("/dummy/gdata/no-such-file.txt"), | 130 base::FilePath::FromUTF8Unsafe("/dummy/gdata/no-such-file.txt"), |
129 GetTestCachedFilePath( | 131 GetTestCachedFilePath( |
130 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); | 132 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); |
131 operation->Start(kTestAuthToken, kTestUserAgent, | 133 operation->Start(kTestAuthToken, kTestUserAgent, |
132 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 134 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
133 MessageLoop::current()->Run(); | 135 MessageLoop::current()->Run(); |
134 | 136 |
135 std::string contents; | 137 std::string contents; |
136 file_util::ReadFileToString(temp_file, &contents); | 138 file_util::ReadFileToString(temp_file, &contents); |
137 file_util::Delete(temp_file, false); | 139 file_util::Delete(temp_file, false); |
138 | 140 |
139 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 141 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
140 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 142 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
141 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", | 143 EXPECT_EQ("/files/chromeos/gdata/no-such-file.txt", |
142 http_request_.relative_url); | 144 http_request_.relative_url); |
143 // Do not verify the not found message. | 145 // Do not verify the not found message. |
144 } | 146 } |
145 | 147 |
146 } // namespace google_apis | 148 } // namespace google_apis |
OLD | NEW |