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/file_system/create_directory_operation.h
" | 5 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "chrome/browser/chromeos/drive/change_list_loader.h" | 10 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
12 #include "chrome/browser/chromeos/drive/drive_scheduler.h" | |
13 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" | 12 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" |
14 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 13 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" |
| 14 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
15 #include "chrome/browser/chromeos/drive/test_util.h" | 15 #include "chrome/browser/chromeos/drive/test_util.h" |
16 #include "chrome/browser/google_apis/fake_drive_service.h" | 16 #include "chrome/browser/google_apis/fake_drive_service.h" |
17 #include "chrome/browser/google_apis/test_util.h" | 17 #include "chrome/browser/google_apis/test_util.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 namespace drive { | 23 namespace drive { |
24 namespace file_system { | 24 namespace file_system { |
(...skipping 24 matching lines...) Expand all Loading... |
49 metadata_.reset(new DriveResourceMetadata(temp_dir_.path(), | 49 metadata_.reset(new DriveResourceMetadata(temp_dir_.path(), |
50 blocking_task_runner_)); | 50 blocking_task_runner_)); |
51 | 51 |
52 FileError error = FILE_ERROR_FAILED; | 52 FileError error = FILE_ERROR_FAILED; |
53 metadata_->Initialize( | 53 metadata_->Initialize( |
54 google_apis::test_util::CreateCopyResultCallback(&error)); | 54 google_apis::test_util::CreateCopyResultCallback(&error)); |
55 google_apis::test_util::RunBlockingPoolTask(); | 55 google_apis::test_util::RunBlockingPoolTask(); |
56 ASSERT_EQ(FILE_ERROR_OK, error); | 56 ASSERT_EQ(FILE_ERROR_OK, error); |
57 | 57 |
58 scheduler_.reset( | 58 scheduler_.reset( |
59 new DriveScheduler(profile_.get(), fake_drive_service_.get())); | 59 new JobScheduler(profile_.get(), fake_drive_service_.get())); |
60 | 60 |
61 DriveWebAppsRegistry drive_web_apps_registry; | 61 DriveWebAppsRegistry drive_web_apps_registry; |
62 ChangeListLoader change_list_loader( | 62 ChangeListLoader change_list_loader( |
63 metadata_.get(), scheduler_.get(), &drive_web_apps_registry); | 63 metadata_.get(), scheduler_.get(), &drive_web_apps_registry); |
64 | 64 |
65 // Makes sure the FakeDriveService's content is loaded to the metadata_. | 65 // Makes sure the FakeDriveService's content is loaded to the metadata_. |
66 change_list_loader.LoadIfNeeded( | 66 change_list_loader.LoadIfNeeded( |
67 DirectoryFetchInfo(), | 67 DirectoryFetchInfo(), |
68 google_apis::test_util::CreateCopyResultCallback(&error)); | 68 google_apis::test_util::CreateCopyResultCallback(&error)); |
69 google_apis::test_util::RunBlockingPoolTask(); | 69 google_apis::test_util::RunBlockingPoolTask(); |
(...skipping 27 matching lines...) Expand all Loading... |
97 // The order of the test threads is important, do not change the order. | 97 // The order of the test threads is important, do not change the order. |
98 // See also content/browser/browser_thread_impl.cc. | 98 // See also content/browser/browser_thread_impl.cc. |
99 content::TestBrowserThread ui_thread_; | 99 content::TestBrowserThread ui_thread_; |
100 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 100 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
101 | 101 |
102 scoped_ptr<TestingProfile> profile_; | 102 scoped_ptr<TestingProfile> profile_; |
103 base::ScopedTempDir temp_dir_; | 103 base::ScopedTempDir temp_dir_; |
104 | 104 |
105 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; | 105 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; |
106 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> metadata_; | 106 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> metadata_; |
107 scoped_ptr<DriveScheduler> scheduler_; | 107 scoped_ptr<JobScheduler> scheduler_; |
108 | 108 |
109 scoped_ptr<CreateDirectoryOperation> operation_; | 109 scoped_ptr<CreateDirectoryOperation> operation_; |
110 }; | 110 }; |
111 | 111 |
112 TEST_F(CreateDirectoryOperationTest, FindFirstMissingParentDirectory) { | 112 TEST_F(CreateDirectoryOperationTest, FindFirstMissingParentDirectory) { |
113 CreateDirectoryOperation::FindFirstMissingParentDirectoryResult result; | 113 CreateDirectoryOperation::FindFirstMissingParentDirectoryResult result; |
114 | 114 |
115 // Create directory in root. | 115 // Create directory in root. |
116 base::FilePath dir_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); | 116 base::FilePath dir_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); |
117 operation()->FindFirstMissingParentDirectory( | 117 operation()->FindFirstMissingParentDirectory( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 operation()->FindFirstMissingParentDirectory( | 160 operation()->FindFirstMissingParentDirectory( |
161 base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")), | 161 base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")), |
162 google_apis::test_util::CreateCopyResultCallback(&result)); | 162 google_apis::test_util::CreateCopyResultCallback(&result)); |
163 google_apis::test_util::RunBlockingPoolTask(); | 163 google_apis::test_util::RunBlockingPoolTask(); |
164 EXPECT_EQ(CreateDirectoryOperation::FIND_FIRST_DIRECTORY_ALREADY_PRESENT, | 164 EXPECT_EQ(CreateDirectoryOperation::FIND_FIRST_DIRECTORY_ALREADY_PRESENT, |
165 result.error); | 165 result.error); |
166 } | 166 } |
167 | 167 |
168 } // namespace file_system | 168 } // namespace file_system |
169 } // namespace drive | 169 } // namespace drive |
OLD | NEW |