OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/chromeos/drive/file_system/update_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" | 7 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
8 #include "chrome/browser/google_apis/fake_drive_service.h" | 8 #include "chrome/browser/google_apis/fake_drive_service.h" |
9 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 9 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
10 #include "chrome/browser/google_apis/test_util.h" | 10 #include "chrome/browser/google_apis/test_util.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 google_apis::test_util::RunBlockingPoolTask(); | 74 google_apis::test_util::RunBlockingPoolTask(); |
75 EXPECT_EQ(FILE_ERROR_OK, error); | 75 EXPECT_EQ(FILE_ERROR_OK, error); |
76 | 76 |
77 int64 original_changestamp = fake_service()->largest_changestamp(); | 77 int64 original_changestamp = fake_service()->largest_changestamp(); |
78 | 78 |
79 // The callback will be called upon completion of | 79 // The callback will be called upon completion of |
80 // UpdateFileByResourceId(). | 80 // UpdateFileByResourceId(). |
81 error = FILE_ERROR_FAILED; | 81 error = FILE_ERROR_FAILED; |
82 operation_->UpdateFileByResourceId( | 82 operation_->UpdateFileByResourceId( |
83 kResourceId, | 83 kResourceId, |
84 DriveClientContext(USER_INITIATED), | 84 ClientContext(USER_INITIATED), |
85 google_apis::test_util::CreateCopyResultCallback(&error)); | 85 google_apis::test_util::CreateCopyResultCallback(&error)); |
86 google_apis::test_util::RunBlockingPoolTask(); | 86 google_apis::test_util::RunBlockingPoolTask(); |
87 EXPECT_EQ(FILE_ERROR_OK, error); | 87 EXPECT_EQ(FILE_ERROR_OK, error); |
88 | 88 |
89 // Check that the server has received an update. | 89 // Check that the server has received an update. |
90 EXPECT_LT(original_changestamp, fake_service()->largest_changestamp()); | 90 EXPECT_LT(original_changestamp, fake_service()->largest_changestamp()); |
91 | 91 |
92 // Check that the file size is updated to that of the updated content. | 92 // Check that the file size is updated to that of the updated content. |
93 google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; | 93 google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; |
94 scoped_ptr<google_apis::ResourceEntry> server_entry; | 94 scoped_ptr<google_apis::ResourceEntry> server_entry; |
95 fake_service()->GetResourceEntry( | 95 fake_service()->GetResourceEntry( |
96 kResourceId, | 96 kResourceId, |
97 google_apis::test_util::CreateCopyResultCallback(&gdata_error, | 97 google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
98 &server_entry)); | 98 &server_entry)); |
99 google_apis::test_util::RunBlockingPoolTask(); | 99 google_apis::test_util::RunBlockingPoolTask(); |
100 EXPECT_EQ(google_apis::HTTP_SUCCESS, gdata_error); | 100 EXPECT_EQ(google_apis::HTTP_SUCCESS, gdata_error); |
101 EXPECT_EQ(static_cast<int64>(kTestFileContent.size()), | 101 EXPECT_EQ(static_cast<int64>(kTestFileContent.size()), |
102 server_entry->file_size()); | 102 server_entry->file_size()); |
103 } | 103 } |
104 | 104 |
105 TEST_F(UpdateOperationTest, UpdateFileByResourceId_NonexistentFile) { | 105 TEST_F(UpdateOperationTest, UpdateFileByResourceId_NonexistentFile) { |
106 FileError error = FILE_ERROR_OK; | 106 FileError error = FILE_ERROR_OK; |
107 operation_->UpdateFileByResourceId( | 107 operation_->UpdateFileByResourceId( |
108 "file:nonexistent_resource_id", | 108 "file:nonexistent_resource_id", |
109 DriveClientContext(USER_INITIATED), | 109 ClientContext(USER_INITIATED), |
110 google_apis::test_util::CreateCopyResultCallback(&error)); | 110 google_apis::test_util::CreateCopyResultCallback(&error)); |
111 google_apis::test_util::RunBlockingPoolTask(); | 111 google_apis::test_util::RunBlockingPoolTask(); |
112 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); | 112 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); |
113 } | 113 } |
114 | 114 |
115 } // namespace file_system | 115 } // namespace file_system |
116 } // namespace drive | 116 } // namespace drive |
OLD | NEW |