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/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // IDs of pinned files, with stale local cache files. | 279 // IDs of pinned files, with stale local cache files. |
280 sync_client_->StartCheckingExistingPinnedFiles(); | 280 sync_client_->StartCheckingExistingPinnedFiles(); |
281 base::RunLoop().RunUntilIdle(); | 281 base::RunLoop().RunUntilIdle(); |
282 | 282 |
283 // "fetched" and "dirty" are the existing pinned files. | 283 // "fetched" and "dirty" are the existing pinned files. |
284 // The non-dirty one should be synced, but the dirty one should not. | 284 // The non-dirty one should be synced, but the dirty one should not. |
285 base::FilePath cache_file; | 285 base::FilePath cache_file; |
286 std::string content; | 286 std::string content; |
287 EXPECT_EQ(FILE_ERROR_OK, cache_->GetFile(resource_ids_["fetched"], | 287 EXPECT_EQ(FILE_ERROR_OK, cache_->GetFile(resource_ids_["fetched"], |
288 &cache_file)); | 288 &cache_file)); |
289 EXPECT_TRUE(file_util::ReadFileToString(cache_file, &content)); | 289 EXPECT_TRUE(base::ReadFileToString(cache_file, &content)); |
290 EXPECT_EQ(kRemoteContent, content); | 290 EXPECT_EQ(kRemoteContent, content); |
291 content.clear(); | 291 content.clear(); |
292 | 292 |
293 EXPECT_EQ(FILE_ERROR_OK, cache_->GetFile(resource_ids_["dirty"], | 293 EXPECT_EQ(FILE_ERROR_OK, cache_->GetFile(resource_ids_["dirty"], |
294 &cache_file)); | 294 &cache_file)); |
295 EXPECT_TRUE(file_util::ReadFileToString(cache_file, &content)); | 295 EXPECT_TRUE(base::ReadFileToString(cache_file, &content)); |
296 EXPECT_EQ(kLocalContent, content); | 296 EXPECT_EQ(kLocalContent, content); |
297 } | 297 } |
298 | 298 |
299 TEST_F(SyncClientTest, RetryOnDisconnection) { | 299 TEST_F(SyncClientTest, RetryOnDisconnection) { |
300 // Let the service go down. | 300 // Let the service go down. |
301 drive_service_->set_offline(true); | 301 drive_service_->set_offline(true); |
302 // Change the network connection state after some delay, to test that | 302 // Change the network connection state after some delay, to test that |
303 // FILE_ERROR_NO_CONNECTION is handled by SyncClient correctly. | 303 // FILE_ERROR_NO_CONNECTION is handled by SyncClient correctly. |
304 // Without this delay, JobScheduler will keep the jobs unrun and SyncClient | 304 // Without this delay, JobScheduler will keep the jobs unrun and SyncClient |
305 // will receive no error. | 305 // will receive no error. |
(...skipping 24 matching lines...) Expand all Loading... |
330 | 330 |
331 // Fetched and uploaded. | 331 // Fetched and uploaded. |
332 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["foo"], &cache_entry)); | 332 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["foo"], &cache_entry)); |
333 EXPECT_TRUE(cache_entry.is_present()); | 333 EXPECT_TRUE(cache_entry.is_present()); |
334 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["dirty"], &cache_entry)); | 334 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["dirty"], &cache_entry)); |
335 EXPECT_FALSE(cache_entry.is_dirty()); | 335 EXPECT_FALSE(cache_entry.is_dirty()); |
336 } | 336 } |
337 | 337 |
338 } // namespace internal | 338 } // namespace internal |
339 } // namespace drive | 339 } // namespace drive |
OLD | NEW |