| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 scheduler_.reset(new JobScheduler(profile_.get(), drive_service_.get())); | 88 scheduler_.reset(new JobScheduler(profile_.get(), drive_service_.get())); |
| 89 | 89 |
| 90 metadata_storage_.reset(new ResourceMetadataStorage( | 90 metadata_storage_.reset(new ResourceMetadataStorage( |
| 91 temp_dir_.path(), base::MessageLoopProxy::current())); | 91 temp_dir_.path(), base::MessageLoopProxy::current())); |
| 92 ASSERT_TRUE(metadata_storage_->Initialize()); | 92 ASSERT_TRUE(metadata_storage_->Initialize()); |
| 93 | 93 |
| 94 metadata_.reset(new internal::ResourceMetadata( | 94 metadata_.reset(new internal::ResourceMetadata( |
| 95 metadata_storage_.get(), base::MessageLoopProxy::current())); | 95 metadata_storage_.get(), base::MessageLoopProxy::current())); |
| 96 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); | 96 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); |
| 97 | 97 |
| 98 cache_.reset(new FileCache(temp_dir_.path(), | 98 cache_.reset(new FileCache(metadata_storage_.get(), |
| 99 temp_dir_.path(), | 99 temp_dir_.path(), |
| 100 base::MessageLoopProxy::current(), | 100 base::MessageLoopProxy::current(), |
| 101 NULL /* free_disk_space_getter */)); | 101 NULL /* free_disk_space_getter */)); |
| 102 ASSERT_TRUE(cache_->Initialize()); | 102 ASSERT_TRUE(cache_->Initialize()); |
| 103 | 103 |
| 104 ASSERT_NO_FATAL_FAILURE(SetUpTestData()); | 104 ASSERT_NO_FATAL_FAILURE(SetUpTestData()); |
| 105 | 105 |
| 106 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current(), | 106 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current(), |
| 107 &observer_, | 107 &observer_, |
| 108 scheduler_.get(), | 108 scheduler_.get(), |
| 109 metadata_.get(), | 109 metadata_.get(), |
| 110 cache_.get(), | 110 cache_.get(), |
| 111 temp_dir_.path())); | 111 temp_dir_.path())); |
| 112 | 112 |
| 113 // Disable delaying so that DoSyncLoop() starts immediately. | 113 // Disable delaying so that DoSyncLoop() starts immediately. |
| 114 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); | 114 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void TearDown() OVERRIDE { | |
| 118 sync_client_.reset(); | |
| 119 cache_.reset(); | |
| 120 metadata_.reset(); | |
| 121 } | |
| 122 | |
| 123 // Adds a file to the service root and |resource_ids_|. | 117 // Adds a file to the service root and |resource_ids_|. |
| 124 void AddFileEntry(const std::string& title) { | 118 void AddFileEntry(const std::string& title) { |
| 125 google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR; | 119 google_apis::GDataErrorCode error = google_apis::GDATA_FILE_ERROR; |
| 126 scoped_ptr<google_apis::ResourceEntry> entry; | 120 scoped_ptr<google_apis::ResourceEntry> entry; |
| 127 drive_service_->AddNewFile( | 121 drive_service_->AddNewFile( |
| 128 "text/plain", | 122 "text/plain", |
| 129 kRemoteContent, | 123 kRemoteContent, |
| 130 drive_service_->GetRootResourceId(), | 124 drive_service_->GetRootResourceId(), |
| 131 title, | 125 title, |
| 132 false, // shared_with_me | 126 false, // shared_with_me |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 content.clear(); | 283 content.clear(); |
| 290 | 284 |
| 291 EXPECT_EQ(FILE_ERROR_OK, cache_->GetFile(resource_ids_["dirty"], | 285 EXPECT_EQ(FILE_ERROR_OK, cache_->GetFile(resource_ids_["dirty"], |
| 292 std::string(), &cache_file)); | 286 std::string(), &cache_file)); |
| 293 EXPECT_TRUE(file_util::ReadFileToString(cache_file, &content)); | 287 EXPECT_TRUE(file_util::ReadFileToString(cache_file, &content)); |
| 294 EXPECT_EQ(kLocalContent, content); | 288 EXPECT_EQ(kLocalContent, content); |
| 295 } | 289 } |
| 296 | 290 |
| 297 } // namespace internal | 291 } // namespace internal |
| 298 } // namespace drive | 292 } // namespace drive |
| OLD | NEW |