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

Unified Diff: chrome/browser/chromeos/gdata/gdata_files_unittest.cc

Issue 10444082: Refresh drive file system metadata for entries in search results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_files_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_files_unittest.cc b/chrome/browser/chromeos/gdata/gdata_files_unittest.cc
index a161491e3a451665f2360cc5dcc89709777d2b82..d7c6fdf2f1bb45bb16eeea5491426ffd61c01a58 100644
--- a/chrome/browser/chromeos/gdata/gdata_files_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_files_unittest.cc
@@ -71,6 +71,41 @@ TEST(GDataRootDirectoryTest, ParseFromString_DetectBadResourceID) {
EXPECT_EQ(kGDataRootDirectoryResourceId, root.resource_id());
}
+TEST(GDataRootDirectoryTest, RefreshFile) {
+ GDataRootDirectory root;
+ // Add a directory to the file system.
+ GDataDirectory* directory_entry = new GDataDirectory(&root, &root);
+ directory_entry->set_resource_id("folder:directory_resource_id");
+ root.AddEntry(directory_entry);
+
+ // Add a new file to the directory.
+ GDataFile* initial_file_entry = new GDataFile(NULL, &root);
+ initial_file_entry->set_resource_id("file:file_resource_id");
satorux1 2012/05/31 20:36:18 it's a bit more interesting to set a thumbnail URL
tbarzic 2012/05/31 20:56:33 I don't see why. We test that, after RefreshEntry,
satorux1 2012/05/31 21:44:17 You confirm that the file is replaced by: ASSERT_
+ directory_entry->AddEntry(initial_file_entry);
+ ASSERT_EQ(directory_entry, initial_file_entry->parent());
+
+ // Initial file system state set, let's try refreshing entries.
+
+ // New value for the entry with resource id "file:file_resource_id".
+ GDataFile* new_file_entry = new GDataFile(NULL, &root);
+ new_file_entry->set_resource_id("file:file_resource_id");
+ root.RefreshFile(scoped_ptr<GDataFile>(new_file_entry).Pass());
+ // Root should have |new_file_entry|, not |initial_file_entry|.
+ // If this is not true, |new_file_entry| has probably been destroyed, hence
+ // ASSERT (we're trying to access |new_file_entry| later on).
+ ASSERT_EQ(new_file_entry, root.GetEntryByResourceId("file:file_resource_id"));
+ // We have just verified new_file_entry exists inside root, so accessing
+ // |new_file_entry->parent()| should be safe.
+ EXPECT_EQ(directory_entry, new_file_entry->parent());
+
+ // Let's try refreshing file that didn't prviously exist.
+ GDataFile* non_existent_entry = new GDataFile(NULL, &root);
+ non_existent_entry->set_resource_id("file:does_not_exist");
+ root.RefreshFile(scoped_ptr<GDataFile>(non_existent_entry).Pass());
+ // File with non existent resource id should not be added.
+ EXPECT_FALSE(root.GetEntryByResourceId("file:does_not_exist"));
+}
+
TEST(GDataRootDirectoryTest, GetEntryByResourceId_RootDirectory) {
GDataRootDirectory root;
// Look up the root directory by its resource ID.
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698