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/chromeos/drive/file_system_interface.h" | 8 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
9 #include "chrome/browser/drive/fake_drive_service.h" | 9 #include "chrome/browser/drive/fake_drive_service.h" |
10 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 10 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 cache()->StoreOnUIThread( | 50 cache()->StoreOnUIThread( |
51 kResourceId, kMd5, kTestFile, | 51 kResourceId, kMd5, kTestFile, |
52 internal::FileCache::FILE_OPERATION_COPY, | 52 internal::FileCache::FILE_OPERATION_COPY, |
53 google_apis::test_util::CreateCopyResultCallback(&error)); | 53 google_apis::test_util::CreateCopyResultCallback(&error)); |
54 test_util::RunBlockingPoolTask(); | 54 test_util::RunBlockingPoolTask(); |
55 EXPECT_EQ(FILE_ERROR_OK, error); | 55 EXPECT_EQ(FILE_ERROR_OK, error); |
56 | 56 |
57 // Add the dirty bit. | 57 // Add the dirty bit. |
58 error = FILE_ERROR_FAILED; | 58 error = FILE_ERROR_FAILED; |
59 cache()->MarkDirtyOnUIThread( | 59 cache()->MarkDirtyOnUIThread( |
60 kResourceId, kMd5, | 60 kResourceId, |
61 google_apis::test_util::CreateCopyResultCallback(&error)); | 61 google_apis::test_util::CreateCopyResultCallback(&error)); |
62 test_util::RunBlockingPoolTask(); | 62 test_util::RunBlockingPoolTask(); |
63 EXPECT_EQ(FILE_ERROR_OK, error); | 63 EXPECT_EQ(FILE_ERROR_OK, error); |
64 | 64 |
65 int64 original_changestamp = fake_service()->largest_changestamp(); | 65 int64 original_changestamp = fake_service()->largest_changestamp(); |
66 | 66 |
67 // The callback will be called upon completion of | 67 // The callback will be called upon completion of |
68 // UpdateFileByResourceId(). | 68 // UpdateFileByResourceId(). |
69 error = FILE_ERROR_FAILED; | 69 error = FILE_ERROR_FAILED; |
70 operation_->UpdateFileByResourceId( | 70 operation_->UpdateFileByResourceId( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 cache()->StoreOnUIThread( | 125 cache()->StoreOnUIThread( |
126 kResourceId, kMd5, kTestFile, | 126 kResourceId, kMd5, kTestFile, |
127 internal::FileCache::FILE_OPERATION_COPY, | 127 internal::FileCache::FILE_OPERATION_COPY, |
128 google_apis::test_util::CreateCopyResultCallback(&error)); | 128 google_apis::test_util::CreateCopyResultCallback(&error)); |
129 test_util::RunBlockingPoolTask(); | 129 test_util::RunBlockingPoolTask(); |
130 EXPECT_EQ(FILE_ERROR_OK, error); | 130 EXPECT_EQ(FILE_ERROR_OK, error); |
131 | 131 |
132 // Add the dirty bit. | 132 // Add the dirty bit. |
133 error = FILE_ERROR_FAILED; | 133 error = FILE_ERROR_FAILED; |
134 cache()->MarkDirtyOnUIThread( | 134 cache()->MarkDirtyOnUIThread( |
135 kResourceId, kMd5, | 135 kResourceId, |
136 google_apis::test_util::CreateCopyResultCallback(&error)); | 136 google_apis::test_util::CreateCopyResultCallback(&error)); |
137 test_util::RunBlockingPoolTask(); | 137 test_util::RunBlockingPoolTask(); |
138 EXPECT_EQ(FILE_ERROR_OK, error); | 138 EXPECT_EQ(FILE_ERROR_OK, error); |
139 | 139 |
140 int64 original_changestamp = fake_service()->largest_changestamp(); | 140 int64 original_changestamp = fake_service()->largest_changestamp(); |
141 | 141 |
142 // The callback will be called upon completion of | 142 // The callback will be called upon completion of |
143 // UpdateFileByResourceId(). | 143 // UpdateFileByResourceId(). |
144 error = FILE_ERROR_FAILED; | 144 error = FILE_ERROR_FAILED; |
145 operation_->UpdateFileByResourceId( | 145 operation_->UpdateFileByResourceId( |
(...skipping 25 matching lines...) Expand all Loading... |
171 server_entry->resource_id(), | 171 server_entry->resource_id(), |
172 server_entry->file_md5(), | 172 server_entry->file_md5(), |
173 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry)); | 173 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry)); |
174 test_util::RunBlockingPoolTask(); | 174 test_util::RunBlockingPoolTask(); |
175 ASSERT_TRUE(success); | 175 ASSERT_TRUE(success); |
176 EXPECT_FALSE(cache_entry.is_dirty()); | 176 EXPECT_FALSE(cache_entry.is_dirty()); |
177 | 177 |
178 // Again mark the cache file dirty. | 178 // Again mark the cache file dirty. |
179 error = FILE_ERROR_FAILED; | 179 error = FILE_ERROR_FAILED; |
180 cache()->MarkDirtyOnUIThread( | 180 cache()->MarkDirtyOnUIThread( |
181 kResourceId, server_entry->file_md5(), | 181 kResourceId, |
182 google_apis::test_util::CreateCopyResultCallback(&error)); | 182 google_apis::test_util::CreateCopyResultCallback(&error)); |
183 test_util::RunBlockingPoolTask(); | 183 test_util::RunBlockingPoolTask(); |
184 EXPECT_EQ(FILE_ERROR_OK, error); | 184 EXPECT_EQ(FILE_ERROR_OK, error); |
185 | 185 |
186 // And call UpdateFileByResourceId again. | 186 // And call UpdateFileByResourceId again. |
187 // In this case, although the file is marked as dirty, but the content | 187 // In this case, although the file is marked as dirty, but the content |
188 // hasn't been changed. Thus, the actual uploading should be skipped. | 188 // hasn't been changed. Thus, the actual uploading should be skipped. |
189 original_changestamp = fake_service()->largest_changestamp(); | 189 original_changestamp = fake_service()->largest_changestamp(); |
190 error = FILE_ERROR_FAILED; | 190 error = FILE_ERROR_FAILED; |
191 operation_->UpdateFileByResourceId( | 191 operation_->UpdateFileByResourceId( |
(...skipping 11 matching lines...) Expand all Loading... |
203 server_entry->resource_id(), | 203 server_entry->resource_id(), |
204 server_entry->file_md5(), | 204 server_entry->file_md5(), |
205 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry)); | 205 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry)); |
206 test_util::RunBlockingPoolTask(); | 206 test_util::RunBlockingPoolTask(); |
207 ASSERT_TRUE(success); | 207 ASSERT_TRUE(success); |
208 EXPECT_FALSE(cache_entry.is_dirty()); | 208 EXPECT_FALSE(cache_entry.is_dirty()); |
209 } | 209 } |
210 | 210 |
211 } // namespace file_system | 211 } // namespace file_system |
212 } // namespace drive | 212 } // namespace drive |
OLD | NEW |