OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/fake_file_system.h" | 5 #include "chrome/browser/chromeos/drive/fake_file_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "chrome/browser/chromeos/drive/drive.pb.h" | 13 #include "chrome/browser/chromeos/drive/drive.pb.h" |
14 #include "chrome/browser/chromeos/drive/file_errors.h" | 14 #include "chrome/browser/chromeos/drive/file_errors.h" |
15 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
16 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 16 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
17 #include "chrome/browser/drive/drive_service_interface.h" | 17 #include "chrome/browser/drive/drive_service_interface.h" |
18 #include "chrome/browser/google_apis/drive_api_parser.h" | 18 #include "chrome/browser/google_apis/drive_api_parser.h" |
19 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 19 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace drive { | 23 namespace drive { |
23 namespace test_util { | 24 namespace test_util { |
24 | 25 |
25 using content::BrowserThread; | 26 using content::BrowserThread; |
26 | 27 |
27 FakeFileSystem::FakeFileSystem(DriveServiceInterface* drive_service) | 28 FakeFileSystem::FakeFileSystem(DriveServiceInterface* drive_service) |
28 : drive_service_(drive_service), | 29 : drive_service_(drive_service), |
29 weak_ptr_factory_(this) { | 30 weak_ptr_factory_(this) { |
| 31 CHECK(cache_dir_.CreateUniqueTempDir()); |
30 } | 32 } |
31 | 33 |
32 FakeFileSystem::~FakeFileSystem() { | 34 FakeFileSystem::~FakeFileSystem() { |
33 } | 35 } |
34 | 36 |
35 bool FakeFileSystem::InitializeForTesting() { | |
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
37 return cache_dir_.CreateUniqueTempDir(); | |
38 } | |
39 | |
40 void FakeFileSystem::Initialize() { | |
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
42 InitializeForTesting(); | |
43 } | |
44 | |
45 void FakeFileSystem::AddObserver(FileSystemObserver* observer) { | 37 void FakeFileSystem::AddObserver(FileSystemObserver* observer) { |
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
47 } | 39 } |
48 | 40 |
49 void FakeFileSystem::RemoveObserver(FileSystemObserver* observer) { | 41 void FakeFileSystem::RemoveObserver(FileSystemObserver* observer) { |
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
51 } | 43 } |
52 | 44 |
53 void FakeFileSystem::CheckForUpdates() { | 45 void FakeFileSystem::CheckForUpdates() { |
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 callback.Run(FILE_ERROR_OK, entry.Pass()); | 377 callback.Run(FILE_ERROR_OK, entry.Pass()); |
386 return; | 378 return; |
387 } | 379 } |
388 } | 380 } |
389 | 381 |
390 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); | 382 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); |
391 } | 383 } |
392 | 384 |
393 } // namespace test_util | 385 } // namespace test_util |
394 } // namespace drive | 386 } // namespace drive |
OLD | NEW |