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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 scoped_ptr<DocumentFeed> document_feed( | 298 scoped_ptr<DocumentFeed> document_feed( |
299 DocumentFeed::ExtractAndParse(*document)); | 299 DocumentFeed::ExtractAndParse(*document)); |
300 ASSERT_TRUE(document_feed.get()); | 300 ASSERT_TRUE(document_feed.get()); |
301 std::vector<DocumentFeed*> feed_list; | 301 std::vector<DocumentFeed*> feed_list; |
302 feed_list.push_back(document_feed.get()); | 302 feed_list.push_back(document_feed.get()); |
303 ASSERT_TRUE(UpdateContent(feed_list, largest_changestamp)); | 303 ASSERT_TRUE(UpdateContent(feed_list, largest_changestamp)); |
304 } | 304 } |
305 | 305 |
306 void AddDirectoryFromFile(const FilePath& directory_path, | 306 void AddDirectoryFromFile(const FilePath& directory_path, |
307 const std::string& filename) { | 307 const std::string& filename) { |
308 std::string error; | |
309 scoped_ptr<Value> atom(LoadJSONFile(filename)); | 308 scoped_ptr<Value> atom(LoadJSONFile(filename)); |
310 ASSERT_TRUE(atom.get()); | 309 ASSERT_TRUE(atom.get()); |
311 ASSERT_TRUE(atom->GetType() == Value::TYPE_DICTIONARY); | 310 ASSERT_TRUE(atom->GetType() == Value::TYPE_DICTIONARY); |
312 | 311 |
313 DictionaryValue* dict_value = NULL; | 312 DictionaryValue* dict_value = NULL; |
314 Value* entry_value = NULL; | 313 Value* entry_value = NULL; |
315 ASSERT_TRUE(atom->GetAsDictionary(&dict_value)); | 314 ASSERT_TRUE(atom->GetAsDictionary(&dict_value)); |
316 ASSERT_TRUE(dict_value->Get("entry", &entry_value)); | 315 ASSERT_TRUE(dict_value->Get("entry", &entry_value)); |
317 | 316 |
318 DictionaryValue* entry_dict = NULL; | 317 DictionaryValue* entry_dict = NULL; |
319 ASSERT_TRUE(entry_value->GetAsDictionary(&entry_dict)); | 318 ASSERT_TRUE(entry_value->GetAsDictionary(&entry_dict)); |
320 | 319 |
321 // Tweak entry title to match the last segment of the directory path | 320 // Tweak entry title to match the last segment of the directory path |
322 // (new directory name). | 321 // (new directory name). |
323 std::vector<FilePath::StringType> dir_parts; | 322 std::vector<FilePath::StringType> dir_parts; |
324 directory_path.GetComponents(&dir_parts); | 323 directory_path.GetComponents(&dir_parts); |
325 entry_dict->SetString("title.$t", dir_parts[dir_parts.size() - 1]); | 324 entry_dict->SetString("title.$t", dir_parts[dir_parts.size() - 1]); |
326 | 325 |
327 ASSERT_EQ(file_system_->AddNewDirectory(directory_path.DirName(), | 326 DriveFileError error; |
328 entry_value), | 327 DriveFileSystem::CreateDirectoryParams params( |
329 DRIVE_FILE_OK) | 328 directory_path, directory_path, false, false, |
satorux1
2012/08/27 22:45:57
align parameters vertically? please also add comme
achuithb
2012/08/27 23:10:03
Done.
| |
330 << "Failed adding " | 329 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error)); |
331 << directory_path.DirName().value(); | 330 file_system_->AddNewDirectory(params, HTTP_SUCCESS, atom.Pass()); |
331 test_util::RunBlockingPoolTask(); | |
332 EXPECT_EQ(DRIVE_FILE_OK, error); | |
332 } | 333 } |
333 | 334 |
334 // Updates the content of directory under |directory_path| with parsed feed | 335 // Updates the content of directory under |directory_path| with parsed feed |
335 // |value|. | 336 // |value|. |
336 bool UpdateContent(const std::vector<DocumentFeed*>& list, | 337 bool UpdateContent(const std::vector<DocumentFeed*>& list, |
337 int largest_changestamp) { | 338 int largest_changestamp) { |
338 GURL unused; | 339 GURL unused; |
339 return file_system_->UpdateFromFeedForTesting( | 340 return file_system_->UpdateFromFeedForTesting( |
340 list, | 341 list, |
341 largest_changestamp, | 342 largest_changestamp, |
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2655 | 2656 |
2656 // Try to close the same file twice. | 2657 // Try to close the same file twice. |
2657 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2658 file_system_->CloseFile(kFileInRoot, close_file_callback); |
2658 message_loop_.Run(); | 2659 message_loop_.Run(); |
2659 | 2660 |
2660 // It must fail. | 2661 // It must fail. |
2661 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2662 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
2662 } | 2663 } |
2663 | 2664 |
2664 } // namespace gdata | 2665 } // namespace gdata |
OLD | NEW |