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/drive/drive_api_util.h" | 5 #include "chrome/browser/drive/drive_api_util.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/md5.h" | 8 #include "base/md5.h" |
9 #include "google_apis/drive/drive_api_parser.h" | 9 #include "google_apis/drive/drive_api_parser.h" |
10 #include "google_apis/drive/gdata_wapi_parser.h" | 10 #include "google_apis/drive/gdata_wapi_parser.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 | 196 |
197 TEST(FileSystemUtilTest, ConvertFileResourceToResource_Parents) { | 197 TEST(FileSystemUtilTest, ConvertFileResourceToResource_Parents) { |
198 google_apis::FileResource file_resource; | 198 google_apis::FileResource file_resource; |
199 | 199 |
200 std::vector<GURL> expected_links; | 200 std::vector<GURL> expected_links; |
201 expected_links.push_back(GURL("http://server/id1")); | 201 expected_links.push_back(GURL("http://server/id1")); |
202 expected_links.push_back(GURL("http://server/id2")); | 202 expected_links.push_back(GURL("http://server/id2")); |
203 expected_links.push_back(GURL("http://server/id3")); | 203 expected_links.push_back(GURL("http://server/id3")); |
204 | 204 |
205 ScopedVector<google_apis::ParentReference> parents; | |
206 for (size_t i = 0; i < expected_links.size(); ++i) { | 205 for (size_t i = 0; i < expected_links.size(); ++i) { |
207 google_apis::ParentReference* parent = new google_apis::ParentReference; | 206 google_apis::ParentReference parent; |
208 parent->set_parent_link(expected_links[i]); | 207 parent.set_parent_link(expected_links[i]); |
209 parents.push_back(parent); | 208 file_resource.mutable_parents()->push_back(parent); |
210 } | 209 } |
211 file_resource.set_parents(parents.Pass()); | |
212 | 210 |
213 scoped_ptr<google_apis::ResourceEntry> entry( | 211 scoped_ptr<google_apis::ResourceEntry> entry( |
214 ConvertFileResourceToResourceEntry(file_resource)); | 212 ConvertFileResourceToResourceEntry(file_resource)); |
215 std::vector<GURL> actual_links; | 213 std::vector<GURL> actual_links; |
216 for (size_t i = 0; i < entry->links().size(); ++i) { | 214 for (size_t i = 0; i < entry->links().size(); ++i) { |
217 if (entry->links()[i]->type() == google_apis::Link::LINK_PARENT) | 215 if (entry->links()[i]->type() == google_apis::Link::LINK_PARENT) |
218 actual_links.push_back(entry->links()[i]->href()); | 216 actual_links.push_back(entry->links()[i]->href()); |
219 } | 217 } |
220 | 218 |
221 EXPECT_EQ(expected_links, actual_links); | 219 EXPECT_EQ(expected_links, actual_links); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 319 |
322 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); | 320 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); |
323 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; | 321 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; |
324 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); | 322 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); |
325 | 323 |
326 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path)); | 324 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path)); |
327 } | 325 } |
328 | 326 |
329 } // namespace util | 327 } // namespace util |
330 } // namespace drive | 328 } // namespace drive |
OLD | NEW |