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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
10 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 10 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 virtual void SetUp() OVERRIDE { | 151 virtual void SetUp() OVERRIDE { |
152 chromeos::CrosLibrary::Initialize(true /* use_stub */); | 152 chromeos::CrosLibrary::Initialize(true /* use_stub */); |
153 io_thread_.StartIOThread(); | 153 io_thread_.StartIOThread(); |
154 | 154 |
155 profile_.reset(new TestingProfile); | 155 profile_.reset(new TestingProfile); |
156 | 156 |
157 // Allocate and keep a pointer to the mock, and inject it into the | 157 // Allocate and keep a pointer to the mock, and inject it into the |
158 // GDataFileSystem object, which will own the mock object. | 158 // GDataFileSystem object, which will own the mock object. |
159 mock_doc_service_ = new MockDocumentsService; | 159 mock_doc_service_ = new MockDocumentsService; |
160 | 160 |
161 EXPECT_CALL(*mock_doc_service_, Initialize(profile_.get())).Times(1); | 161 EXPECT_CALL(*mock_doc_service_, Initialize(profile_.get(), false)).Times(1); |
162 | 162 |
163 // Likewise, this will be owned by GDataFileSystem. | 163 // Likewise, this will be owned by GDataFileSystem. |
164 mock_free_disk_space_checker_ = new MockFreeDiskSpaceGetter; | 164 mock_free_disk_space_checker_ = new MockFreeDiskSpaceGetter; |
165 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); | 165 SetFreeDiskSpaceGetterForTesting(mock_free_disk_space_checker_); |
166 | 166 |
167 cache_ = GDataCache::CreateGDataCacheOnUIThread( | 167 cache_ = GDataCache::CreateGDataCacheOnUIThread( |
168 GDataCache::GetCacheRootPath(profile_.get()), | 168 GDataCache::GetCacheRootPath(profile_.get()), |
169 content::BrowserThread::GetBlockingPool(), | 169 content::BrowserThread::GetBlockingPool(), |
170 sequence_token_); | 170 sequence_token_); |
171 | 171 |
172 mock_uploader_.reset(new StrictMock<MockGDataUploader>); | 172 mock_uploader_.reset(new StrictMock<MockGDataUploader>); |
173 mock_webapps_registry_.reset(new StrictMock<MockDriveWebAppsRegistry>); | 173 mock_webapps_registry_.reset(new StrictMock<MockDriveWebAppsRegistry>); |
174 | 174 |
175 ASSERT_FALSE(file_system_); | 175 ASSERT_FALSE(file_system_); |
176 file_system_ = new GDataFileSystem(profile_.get(), | 176 file_system_ = new GDataFileSystem(profile_.get(), |
177 cache_, | 177 cache_, |
178 mock_doc_service_, | 178 mock_doc_service_, |
179 mock_uploader_.get(), | 179 mock_uploader_.get(), |
180 mock_webapps_registry_.get(), | 180 mock_webapps_registry_.get(), |
181 sequence_token_); | 181 sequence_token_); |
182 | 182 |
183 mock_sync_client_.reset(new StrictMock<MockGDataSyncClient>); | 183 mock_sync_client_.reset(new StrictMock<MockGDataSyncClient>); |
184 cache_->AddObserver(mock_sync_client_.get()); | 184 cache_->AddObserver(mock_sync_client_.get()); |
185 | 185 |
186 file_system_->Initialize(); | 186 file_system_->Initialize(false); |
187 cache_->RequestInitializeOnUIThread(); | 187 cache_->RequestInitializeOnUIThread(); |
188 test_util::RunBlockingPoolTask(); | 188 test_util::RunBlockingPoolTask(); |
189 } | 189 } |
190 | 190 |
191 virtual void TearDown() OVERRIDE { | 191 virtual void TearDown() OVERRIDE { |
192 ASSERT_TRUE(file_system_); | 192 ASSERT_TRUE(file_system_); |
193 EXPECT_CALL(*mock_doc_service_, CancelAll()).Times(1); | 193 EXPECT_CALL(*mock_doc_service_, CancelAll()).Times(1); |
194 delete file_system_; | 194 delete file_system_; |
195 file_system_ = NULL; | 195 file_system_ = NULL; |
196 delete mock_doc_service_; | 196 delete mock_doc_service_; |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 EXPECT_EQ(1, num_callback_invocations_); | 1602 EXPECT_EQ(1, num_callback_invocations_); |
1603 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); | 1603 EXPECT_TRUE(CacheEntryExists(resource_id, md5)); |
1604 | 1604 |
1605 // Try to remove the file. | 1605 // Try to remove the file. |
1606 num_callback_invocations_ = 0; | 1606 num_callback_invocations_ = 0; |
1607 TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK); | 1607 TestRemoveFromCache(resource_id, base::PLATFORM_FILE_OK); |
1608 EXPECT_EQ(1, num_callback_invocations_); | 1608 EXPECT_EQ(1, num_callback_invocations_); |
1609 } | 1609 } |
1610 | 1610 |
1611 } // namespace gdata | 1611 } // namespace gdata |
OLD | NEW |