OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/change_list_processor.h" | 5 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 }; | 132 }; |
133 | 133 |
134 } // namespace | 134 } // namespace |
135 | 135 |
136 TEST_F(ChangeListProcessorTest, ApplyFullResourceList) { | 136 TEST_F(ChangeListProcessorTest, ApplyFullResourceList) { |
137 EXPECT_EQ(FILE_ERROR_OK, | 137 EXPECT_EQ(FILE_ERROR_OK, |
138 ApplyFullResourceList(ParseChangeList(kBaseResourceListFile))); | 138 ApplyFullResourceList(ParseChangeList(kBaseResourceListFile))); |
139 | 139 |
140 const EntryExpectation kExpected[] = { | 140 const EntryExpectation kExpected[] = { |
141 // Root files | 141 // Root files |
142 {"drive/root", kRootId, util::kDriveGrandRootLocalId, DIRECTORY}, | 142 {"drive/root", kRootId, "", DIRECTORY}, |
143 {"drive/root/File 1.txt", | 143 {"drive/root/File 1.txt", |
144 "file:2_file_resource_id", kRootId, FILE}, | 144 "file:2_file_resource_id", kRootId, FILE}, |
145 {"drive/root/Slash _ in file 1.txt", | 145 {"drive/root/Slash _ in file 1.txt", |
146 "file:slash_file_resource_id", kRootId, FILE}, | 146 "file:slash_file_resource_id", kRootId, FILE}, |
147 {"drive/root/Document 1 excludeDir-test.gdoc", | 147 {"drive/root/Document 1 excludeDir-test.gdoc", |
148 "document:5_document_resource_id", kRootId, FILE}, | 148 "document:5_document_resource_id", kRootId, FILE}, |
149 // Subdirectory files | 149 // Subdirectory files |
150 {"drive/root/Directory 1", | 150 {"drive/root/Directory 1", |
151 "folder:1_folder_resource_id", kRootId, DIRECTORY}, | 151 "folder:1_folder_resource_id", kRootId, DIRECTORY}, |
152 {"drive/root/Directory 1/SubDirectory File 1.txt", | 152 {"drive/root/Directory 1/SubDirectory File 1.txt", |
(...skipping 10 matching lines...) Expand all Loading... |
163 "folder:slash_dir_folder_resource_id", FILE}, | 163 "folder:slash_dir_folder_resource_id", FILE}, |
164 // Deeper | 164 // Deeper |
165 {"drive/root/Directory 1/Sub Directory Folder", | 165 {"drive/root/Directory 1/Sub Directory Folder", |
166 "folder:sub_dir_folder_resource_id", | 166 "folder:sub_dir_folder_resource_id", |
167 "folder:1_folder_resource_id", DIRECTORY}, | 167 "folder:1_folder_resource_id", DIRECTORY}, |
168 {"drive/root/Directory 1/Sub Directory Folder/Sub Sub Directory Folder", | 168 {"drive/root/Directory 1/Sub Directory Folder/Sub Sub Directory Folder", |
169 "folder:sub_sub_directory_folder_id", | 169 "folder:sub_sub_directory_folder_id", |
170 "folder:sub_dir_folder_resource_id", DIRECTORY}, | 170 "folder:sub_dir_folder_resource_id", DIRECTORY}, |
171 // Orphan | 171 // Orphan |
172 {"drive/other/Orphan File 1.txt", "file:1_orphanfile_resource_id", | 172 {"drive/other/Orphan File 1.txt", "file:1_orphanfile_resource_id", |
173 util::kDriveOtherDirLocalId, FILE}, | 173 "", FILE}, |
174 }; | 174 }; |
175 | 175 |
176 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kExpected); ++i) { | 176 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kExpected); ++i) { |
177 scoped_ptr<ResourceEntry> entry = GetResourceEntry(kExpected[i].path); | 177 scoped_ptr<ResourceEntry> entry = GetResourceEntry(kExpected[i].path); |
178 ASSERT_TRUE(entry) << "for path: " << kExpected[i].path; | 178 ASSERT_TRUE(entry) << "for path: " << kExpected[i].path; |
179 EXPECT_EQ(kExpected[i].id, entry->resource_id()); | 179 EXPECT_EQ(kExpected[i].id, entry->resource_id()); |
180 | 180 |
181 ResourceEntry parent_entry; | 181 ResourceEntry parent_entry; |
182 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById( | 182 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById( |
183 entry->parent_local_id(), &parent_entry)); | 183 entry->parent_local_id(), &parent_entry)); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 EXPECT_EQ(FILE_ERROR_OK, ApplyChangeList(change_lists.Pass(), &changed_dirs)); | 609 EXPECT_EQ(FILE_ERROR_OK, ApplyChangeList(change_lists.Pass(), &changed_dirs)); |
610 | 610 |
611 // "new_file" should be added under drive/other. | 611 // "new_file" should be added under drive/other. |
612 ResourceEntry entry; | 612 ResourceEntry entry; |
613 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 613 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
614 util::GetDriveGrandRootPath().AppendASCII("other/new_file"), &entry)); | 614 util::GetDriveGrandRootPath().AppendASCII("other/new_file"), &entry)); |
615 } | 615 } |
616 | 616 |
617 } // namespace internal | 617 } // namespace internal |
618 } // namespace drive | 618 } // namespace drive |
OLD | NEW |