OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/drive/drive_scheduler.h" | 5 #include "chrome/browser/chromeos/drive/drive_scheduler.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/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 TEST_F(DriveSchedulerTest, GetResourceEntry) { | 224 TEST_F(DriveSchedulerTest, GetResourceEntry) { |
225 ConnectToWifi(); | 225 ConnectToWifi(); |
226 | 226 |
227 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 227 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
228 scoped_ptr<google_apis::ResourceEntry> entry; | 228 scoped_ptr<google_apis::ResourceEntry> entry; |
229 | 229 |
230 scheduler_->GetResourceEntry( | 230 scheduler_->GetResourceEntry( |
231 "file:2_file_resource_id", // resource ID | 231 "file:2_file_resource_id", // resource ID |
232 DriveClientContext(USER_INITIATED), | 232 DriveClientContext(USER_INITIATED), |
233 base::Bind( | 233 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
234 &google_apis::test_util::CopyResultsFromGetResourceEntryCallback, | |
235 &error, | |
236 &entry)); | |
237 google_apis::test_util::RunBlockingPoolTask(); | 234 google_apis::test_util::RunBlockingPoolTask(); |
238 | 235 |
239 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); | 236 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); |
240 ASSERT_TRUE(entry); | 237 ASSERT_TRUE(entry); |
241 } | 238 } |
242 | 239 |
243 TEST_F(DriveSchedulerTest, DeleteResource) { | 240 TEST_F(DriveSchedulerTest, DeleteResource) { |
244 ConnectToWifi(); | 241 ConnectToWifi(); |
245 | 242 |
246 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 243 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
247 | 244 |
248 scheduler_->DeleteResource( | 245 scheduler_->DeleteResource( |
249 "file:2_file_resource_id", | 246 "file:2_file_resource_id", |
250 google_apis::test_util::CreateCopyResultCallback(&error)); | 247 google_apis::test_util::CreateCopyResultCallback(&error)); |
251 google_apis::test_util::RunBlockingPoolTask(); | 248 google_apis::test_util::RunBlockingPoolTask(); |
252 | 249 |
253 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); | 250 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); |
254 } | 251 } |
255 | 252 |
256 TEST_F(DriveSchedulerTest, CopyHostedDocument) { | 253 TEST_F(DriveSchedulerTest, CopyHostedDocument) { |
257 ConnectToWifi(); | 254 ConnectToWifi(); |
258 | 255 |
259 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 256 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
260 scoped_ptr<google_apis::ResourceEntry> entry; | 257 scoped_ptr<google_apis::ResourceEntry> entry; |
261 | 258 |
262 scheduler_->CopyHostedDocument( | 259 scheduler_->CopyHostedDocument( |
263 "document:5_document_resource_id", // resource ID | 260 "document:5_document_resource_id", // resource ID |
264 "New Document", // new name | 261 "New Document", // new name |
265 base::Bind( | 262 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
266 &google_apis::test_util::CopyResultsFromGetResourceEntryCallback, | |
267 &error, | |
268 &entry)); | |
269 google_apis::test_util::RunBlockingPoolTask(); | 263 google_apis::test_util::RunBlockingPoolTask(); |
270 | 264 |
271 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); | 265 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); |
272 ASSERT_TRUE(entry); | 266 ASSERT_TRUE(entry); |
273 } | 267 } |
274 | 268 |
275 TEST_F(DriveSchedulerTest, RenameResource) { | 269 TEST_F(DriveSchedulerTest, RenameResource) { |
276 ConnectToWifi(); | 270 ConnectToWifi(); |
277 | 271 |
278 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 272 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 310 |
317 TEST_F(DriveSchedulerTest, AddNewDirectory) { | 311 TEST_F(DriveSchedulerTest, AddNewDirectory) { |
318 ConnectToWifi(); | 312 ConnectToWifi(); |
319 | 313 |
320 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | 314 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; |
321 scoped_ptr<google_apis::ResourceEntry> entry; | 315 scoped_ptr<google_apis::ResourceEntry> entry; |
322 | 316 |
323 scheduler_->AddNewDirectory( | 317 scheduler_->AddNewDirectory( |
324 fake_drive_service_->GetRootResourceId(), // Root directory. | 318 fake_drive_service_->GetRootResourceId(), // Root directory. |
325 "New Directory", | 319 "New Directory", |
326 base::Bind( | 320 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); |
327 &google_apis::test_util::CopyResultsFromGetResourceEntryCallback, | |
328 &error, | |
329 &entry)); | |
330 google_apis::test_util::RunBlockingPoolTask(); | 321 google_apis::test_util::RunBlockingPoolTask(); |
331 | 322 |
332 ASSERT_EQ(google_apis::HTTP_CREATED, error); | 323 ASSERT_EQ(google_apis::HTTP_CREATED, error); |
333 ASSERT_TRUE(entry); | 324 ASSERT_TRUE(entry); |
334 } | 325 } |
335 | 326 |
336 TEST_F(DriveSchedulerTest, GetResourceEntryPriority) { | 327 TEST_F(DriveSchedulerTest, GetResourceEntryPriority) { |
337 // Disconnect from the network to prevent jobs from starting. | 328 // Disconnect from the network to prevent jobs from starting. |
338 ConnectToNone(); | 329 ConnectToNone(); |
339 | 330 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // Check the download | 605 // Check the download |
615 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); | 606 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); |
616 std::string content; | 607 std::string content; |
617 EXPECT_EQ(output_file_path, kOutputFilePath); | 608 EXPECT_EQ(output_file_path, kOutputFilePath); |
618 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); | 609 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); |
619 // The content is "x"s of the file size specified in root_feed.json. | 610 // The content is "x"s of the file size specified in root_feed.json. |
620 EXPECT_EQ("xxxxxxxxxx", content); | 611 EXPECT_EQ("xxxxxxxxxx", content); |
621 } | 612 } |
622 | 613 |
623 } // namespace drive | 614 } // namespace drive |
OLD | NEW |