Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/chromeos/gdata/drive_file_system_unittest.cc

Issue 10876075: AddEntryToDirectory now takes a FilePath and scoped_ptr<DocumentEntry> (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(directory_path,
329 DRIVE_FILE_OK) 328 directory_path,
330 << "Failed adding " 329 false, // is_exclusive
331 << directory_path.DirName().value(); 330 false, // is_recursive
331 base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error));
332 file_system_->AddNewDirectory(params, HTTP_SUCCESS, atom.Pass());
333 test_util::RunBlockingPoolTask();
334 EXPECT_EQ(DRIVE_FILE_OK, error);
332 } 335 }
333 336
334 // Updates the content of directory under |directory_path| with parsed feed 337 // Updates the content of directory under |directory_path| with parsed feed
335 // |value|. 338 // |value|.
336 bool UpdateContent(const std::vector<DocumentFeed*>& list, 339 bool UpdateContent(const std::vector<DocumentFeed*>& list,
337 int largest_changestamp) { 340 int largest_changestamp) {
338 GURL unused; 341 GURL unused;
339 return file_system_->UpdateFromFeedForTesting( 342 return file_system_->UpdateFromFeedForTesting(
340 list, 343 list,
341 largest_changestamp, 344 largest_changestamp,
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 2658
2656 // Try to close the same file twice. 2659 // Try to close the same file twice.
2657 file_system_->CloseFile(kFileInRoot, close_file_callback); 2660 file_system_->CloseFile(kFileInRoot, close_file_callback);
2658 message_loop_.Run(); 2661 message_loop_.Run();
2659 2662
2660 // It must fail. 2663 // It must fail.
2661 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2664 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2662 } 2665 }
2663 2666
2664 } // namespace gdata 2667 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_file_system_interface.h ('k') | chrome/browser/chromeos/gdata/drive_resource_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698