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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 16 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
17 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 17 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
18 #include "chrome/browser/chromeos/gdata/drive_file_system.h" | 18 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_uploader.h" |
19 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 20 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
20 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
21 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | |
22 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
23 #include "chrome/browser/chromeos/gdata/mock_directory_change_observer.h" | 23 #include "chrome/browser/chromeos/gdata/mock_directory_change_observer.h" |
24 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" | 24 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" |
25 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" | 25 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" |
| 26 #include "chrome/browser/chromeos/gdata/mock_drive_uploader.h" |
26 #include "chrome/browser/chromeos/gdata/mock_drive_web_apps_registry.h" | 27 #include "chrome/browser/chromeos/gdata/mock_drive_web_apps_registry.h" |
27 #include "chrome/browser/chromeos/gdata/mock_free_disk_space_getter.h" | 28 #include "chrome/browser/chromeos/gdata/mock_free_disk_space_getter.h" |
28 #include "chrome/browser/chromeos/gdata/mock_gdata_uploader.h" | |
29 #include "chrome/browser/chromeos/gdata/stale_cache_files_remover.h" | 29 #include "chrome/browser/chromeos/gdata/stale_cache_files_remover.h" |
30 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/test/test_browser_thread.h" | 32 #include "content/public/test/test_browser_thread.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
35 | 35 |
36 using ::testing::AtLeast; | 36 using ::testing::AtLeast; |
37 using ::testing::Eq; | 37 using ::testing::Eq; |
38 using ::testing::NotNull; | 38 using ::testing::NotNull; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); | 83 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); |
84 | 84 |
85 scoped_refptr<base::SequencedWorkerPool> pool = | 85 scoped_refptr<base::SequencedWorkerPool> pool = |
86 content::BrowserThread::GetBlockingPool(); | 86 content::BrowserThread::GetBlockingPool(); |
87 blocking_task_runner_ = | 87 blocking_task_runner_ = |
88 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); | 88 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); |
89 | 89 |
90 cache_ = DriveCache::CreateDriveCacheOnUIThread( | 90 cache_ = DriveCache::CreateDriveCacheOnUIThread( |
91 DriveCache::GetCacheRootPath(profile_.get()), blocking_task_runner_); | 91 DriveCache::GetCacheRootPath(profile_.get()), blocking_task_runner_); |
92 | 92 |
93 mock_uploader_.reset(new StrictMock<MockGDataUploader>); | 93 mock_uploader_.reset(new StrictMock<MockDriveUploader>); |
94 mock_webapps_registry_.reset(new StrictMock<MockDriveWebAppsRegistry>); | 94 mock_webapps_registry_.reset(new StrictMock<MockDriveWebAppsRegistry>); |
95 | 95 |
96 ASSERT_FALSE(file_system_); | 96 ASSERT_FALSE(file_system_); |
97 file_system_ = new DriveFileSystem(profile_.get(), | 97 file_system_ = new DriveFileSystem(profile_.get(), |
98 cache_, | 98 cache_, |
99 mock_drive_service_, | 99 mock_drive_service_, |
100 mock_uploader_.get(), | 100 mock_uploader_.get(), |
101 mock_webapps_registry_.get(), | 101 mock_webapps_registry_.get(), |
102 blocking_task_runner_); | 102 blocking_task_runner_); |
103 | 103 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 | 142 |
143 MessageLoopForUI message_loop_; | 143 MessageLoopForUI message_loop_; |
144 // The order of the test threads is important, do not change the order. | 144 // The order of the test threads is important, do not change the order. |
145 // See also content/browser/browser_thread_impl.cc. | 145 // See also content/browser/browser_thread_impl.cc. |
146 content::TestBrowserThread ui_thread_; | 146 content::TestBrowserThread ui_thread_; |
147 content::TestBrowserThread io_thread_; | 147 content::TestBrowserThread io_thread_; |
148 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 148 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
149 scoped_ptr<TestingProfile> profile_; | 149 scoped_ptr<TestingProfile> profile_; |
150 DriveCache* cache_; | 150 DriveCache* cache_; |
151 scoped_ptr<StrictMock<MockGDataUploader> > mock_uploader_; | 151 scoped_ptr<StrictMock<MockDriveUploader> > mock_uploader_; |
152 DriveFileSystem* file_system_; | 152 DriveFileSystem* file_system_; |
153 StrictMock<MockDriveService>* mock_drive_service_; | 153 StrictMock<MockDriveService>* mock_drive_service_; |
154 scoped_ptr<StrictMock<MockDriveWebAppsRegistry> > mock_webapps_registry_; | 154 scoped_ptr<StrictMock<MockDriveWebAppsRegistry> > mock_webapps_registry_; |
155 StrictMock<MockFreeDiskSpaceGetter>* mock_free_disk_space_checker_; | 155 StrictMock<MockFreeDiskSpaceGetter>* mock_free_disk_space_checker_; |
156 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; | 156 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; |
157 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; | 157 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; |
158 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_; | 158 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_; |
159 | 159 |
160 int root_feed_changestamp_; | 160 int root_feed_changestamp_; |
161 }; | 161 }; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 // Verify that the cache file is deleted. | 217 // Verify that the cache file is deleted. |
218 path = cache_->GetCacheFilePath(resource_id, | 218 path = cache_->GetCacheFilePath(resource_id, |
219 md5, | 219 md5, |
220 DriveCache::CACHE_TYPE_TMP, | 220 DriveCache::CACHE_TYPE_TMP, |
221 DriveCache::CACHED_FILE_FROM_SERVER); | 221 DriveCache::CACHED_FILE_FROM_SERVER); |
222 EXPECT_FALSE(file_util::PathExists(path)); | 222 EXPECT_FALSE(file_util::PathExists(path)); |
223 } | 223 } |
224 | 224 |
225 } // namespace gdata | 225 } // namespace gdata |
OLD | NEW |