Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: chrome/browser/chromeos/drive/file_system_unittest.cc

Issue 18419004: Remove destruction-only TearDown() methods in Drive related test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_system.h" 5 #include "chrome/browser/chromeos/drive/file_system.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } // namespace 76 } // namespace
77 77
78 class FileSystemTest : public testing::Test { 78 class FileSystemTest : public testing::Test {
79 protected: 79 protected:
80 virtual void SetUp() OVERRIDE { 80 virtual void SetUp() OVERRIDE {
81 profile_.reset(new TestingProfile); 81 profile_.reset(new TestingProfile);
82 82
83 fake_network_change_notifier_.reset( 83 fake_network_change_notifier_.reset(
84 new test_util::FakeNetworkChangeNotifier); 84 new test_util::FakeNetworkChangeNotifier);
85 85
86 // The fake object will be manually deleted in TearDown().
87 fake_drive_service_.reset(new FakeDriveService); 86 fake_drive_service_.reset(new FakeDriveService);
88 fake_drive_service_->LoadResourceListForWapi( 87 fake_drive_service_->LoadResourceListForWapi(
89 "gdata/root_feed.json"); 88 "gdata/root_feed.json");
90 fake_drive_service_->LoadAccountMetadataForWapi( 89 fake_drive_service_->LoadAccountMetadataForWapi(
91 "gdata/account_metadata.json"); 90 "gdata/account_metadata.json");
92 91
93 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); 92 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter);
94 93
95 scheduler_.reset(new JobScheduler(profile_.get(), 94 scheduler_.reset(new JobScheduler(profile_.get(),
96 fake_drive_service_.get(), 95 fake_drive_service_.get(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 file_system_->AddObserver(mock_directory_observer_.get()); 136 file_system_->AddObserver(mock_directory_observer_.get());
138 file_system_->Initialize(); 137 file_system_->Initialize();
139 138
140 // Disable delaying so that the sync starts immediately. 139 // Disable delaying so that the sync starts immediately.
141 file_system_->sync_client_for_testing()->set_delay_for_testing( 140 file_system_->sync_client_for_testing()->set_delay_for_testing(
142 base::TimeDelta::FromSeconds(0)); 141 base::TimeDelta::FromSeconds(0));
143 142
144 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); 143 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize());
145 } 144 }
146 145
147 virtual void TearDown() OVERRIDE {
148 ASSERT_TRUE(file_system_);
149 file_system_.reset();
150 scheduler_.reset();
151 fake_drive_service_.reset();
152 cache_.reset();
153 fake_network_change_notifier_.reset();
154 profile_.reset();
155 }
156
157 // Loads the full resource list via FakeDriveService. 146 // Loads the full resource list via FakeDriveService.
158 bool LoadFullResourceList() { 147 bool LoadFullResourceList() {
159 FileError error = FILE_ERROR_FAILED; 148 FileError error = FILE_ERROR_FAILED;
160 file_system_->change_list_loader()->LoadIfNeeded( 149 file_system_->change_list_loader()->LoadIfNeeded(
161 DirectoryFetchInfo(), 150 DirectoryFetchInfo(),
162 google_apis::test_util::CreateCopyResultCallback(&error)); 151 google_apis::test_util::CreateCopyResultCallback(&error));
163 google_apis::test_util::RunBlockingPoolTask(); 152 google_apis::test_util::RunBlockingPoolTask();
164 return error == FILE_ERROR_OK; 153 return error == FILE_ERROR_OK;
165 } 154 }
166 155
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 SetUpResourceMetadataAndFileSystem(); 290 SetUpResourceMetadataAndFileSystem();
302 291
303 return true; 292 return true;
304 } 293 }
305 294
306 content::TestBrowserThreadBundle thread_bundle_; 295 content::TestBrowserThreadBundle thread_bundle_;
307 scoped_ptr<TestingProfile> profile_; 296 scoped_ptr<TestingProfile> profile_;
308 scoped_ptr<test_util::FakeNetworkChangeNotifier> 297 scoped_ptr<test_util::FakeNetworkChangeNotifier>
309 fake_network_change_notifier_; 298 fake_network_change_notifier_;
310 299
300 scoped_ptr<FakeDriveService> fake_drive_service_;
hashimoto 2013/07/03 07:58:47 nit: Could you make the order here and the order i
kinaba 2013/07/03 10:06:58 Done.
311 scoped_ptr<internal::ResourceMetadataStorage, 301 scoped_ptr<internal::ResourceMetadataStorage,
312 test_util::DestroyHelperForTests> metadata_storage_; 302 test_util::DestroyHelperForTests> metadata_storage_;
313 scoped_ptr<internal::FileCache, test_util::DestroyHelperForTests> cache_;
314 scoped_ptr<FileSystem> file_system_;
315 scoped_ptr<FakeDriveService> fake_drive_service_;
316 scoped_ptr<JobScheduler> scheduler_;
317 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests> 303 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests>
318 resource_metadata_; 304 resource_metadata_;
319 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; 305 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_;
306 scoped_ptr<internal::FileCache, test_util::DestroyHelperForTests> cache_;
307 scoped_ptr<JobScheduler> scheduler_;
308 scoped_ptr<FileSystem> file_system_;
320 scoped_ptr<MockDirectoryChangeObserver> mock_directory_observer_; 309 scoped_ptr<MockDirectoryChangeObserver> mock_directory_observer_;
321 }; 310 };
322 311
323 TEST_F(FileSystemTest, DuplicatedAsyncInitialization) { 312 TEST_F(FileSystemTest, DuplicatedAsyncInitialization) {
324 base::RunLoop loop; 313 base::RunLoop loop;
325 314
326 int counter = 0; 315 int counter = 0;
327 const GetResourceEntryCallback& callback = base::Bind( 316 const GetResourceEntryCallback& callback = base::Bind(
328 &AsyncInitializationCallback, &counter, 2, loop.QuitClosure()); 317 &AsyncInitializationCallback, &counter, 2, loop.QuitClosure());
329 318
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 file_path, 867 file_path,
879 google_apis::test_util::CreateCopyResultCallback(&error)); 868 google_apis::test_util::CreateCopyResultCallback(&error));
880 google_apis::test_util::RunBlockingPoolTask(); 869 google_apis::test_util::RunBlockingPoolTask();
881 EXPECT_EQ(FILE_ERROR_OK, error); 870 EXPECT_EQ(FILE_ERROR_OK, error);
882 871
883 // Now able to remove the cache entry. 872 // Now able to remove the cache entry.
884 EXPECT_EQ(FILE_ERROR_OK, cache_->Remove(entry->resource_id())); 873 EXPECT_EQ(FILE_ERROR_OK, cache_->Remove(entry->resource_id()));
885 } 874 }
886 875
887 } // namespace drive 876 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698