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

Side by Side Diff: chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc

Issue 14108009: chromeos: Use WriteBatch to update DriveResourceMetadata DB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "chrome/browser/chromeos/drive/drive_resource_metadata.h" 5 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 scoped_ptr<DriveEntryProto> entry_proto; 702 scoped_ptr<DriveEntryProto> entry_proto;
703 703
704 // Get file9. 704 // Get file9.
705 entry_proto = GetEntryInfoByPathSync( 705 entry_proto = GetEntryInfoByPathSync(
706 base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9")); 706 base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9"));
707 ASSERT_TRUE(entry_proto.get()); 707 ASSERT_TRUE(entry_proto.get());
708 EXPECT_EQ("file9", entry_proto->base_name()); 708 EXPECT_EQ("file9", entry_proto->base_name());
709 ASSERT_TRUE(!entry_proto->file_info().is_directory()); 709 ASSERT_TRUE(!entry_proto->file_info().is_directory());
710 EXPECT_EQ("md5:file9", entry_proto->file_specific_info().file_md5()); 710 EXPECT_EQ("md5:file9", entry_proto->file_specific_info().file_md5());
711 711
712 // Rename it and change the file size. 712 // Rename it.
713 DriveEntryProto file_entry_proto(*entry_proto); 713 DriveEntryProto file_entry_proto(*entry_proto);
714 const std::string updated_md5("md5:updated");
715 file_entry_proto.mutable_file_specific_info()->set_file_md5(updated_md5);
716 file_entry_proto.set_title("file100"); 714 file_entry_proto.set_title("file100");
717 entry_proto.reset(); 715 entry_proto.reset();
718 resource_metadata_->RefreshEntry( 716 resource_metadata_->RefreshEntry(
719 file_entry_proto, 717 file_entry_proto,
718 google_apis::test_util::CreateCopyResultCallback(
719 &error, &drive_file_path, &entry_proto));
720 google_apis::test_util::RunBlockingPoolTask();
721 EXPECT_EQ(FILE_ERROR_OK, error);
722 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"),
723 drive_file_path);
724 ASSERT_TRUE(entry_proto.get());
725 EXPECT_EQ("file100", entry_proto->base_name());
726 ASSERT_TRUE(!entry_proto->file_info().is_directory());
727 EXPECT_EQ("md5:file9", entry_proto->file_specific_info().file_md5());
728
729 // Update the file md5.
730 const std::string updated_md5("md5:updated");
731 file_entry_proto = *entry_proto;
732 file_entry_proto.mutable_file_specific_info()->set_file_md5(updated_md5);
733 entry_proto.reset();
734 resource_metadata_->RefreshEntry(
735 file_entry_proto,
720 google_apis::test_util::CreateCopyResultCallback( 736 google_apis::test_util::CreateCopyResultCallback(
721 &error, &drive_file_path, &entry_proto)); 737 &error, &drive_file_path, &entry_proto));
722 google_apis::test_util::RunBlockingPoolTask(); 738 google_apis::test_util::RunBlockingPoolTask();
723 EXPECT_EQ(FILE_ERROR_OK, error); 739 EXPECT_EQ(FILE_ERROR_OK, error);
724 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"), 740 EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file100"),
725 drive_file_path); 741 drive_file_path);
726 ASSERT_TRUE(entry_proto.get()); 742 ASSERT_TRUE(entry_proto.get());
727 EXPECT_EQ("file100", entry_proto->base_name()); 743 EXPECT_EQ("file100", entry_proto->base_name());
728 ASSERT_TRUE(!entry_proto->file_info().is_directory()); 744 ASSERT_TRUE(!entry_proto->file_info().is_directory());
729 EXPECT_EQ(updated_md5, entry_proto->file_specific_info().file_md5()); 745 EXPECT_EQ(updated_md5, entry_proto->file_specific_info().file_md5());
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 base::Bind(&CountFile, &count), 1187 base::Bind(&CountFile, &count),
1172 base::Bind(google_apis::test_util::CreateCopyResultCallback(&completed), 1188 base::Bind(google_apis::test_util::CreateCopyResultCallback(&completed),
1173 true)); 1189 true));
1174 google_apis::test_util::RunBlockingPoolTask(); 1190 google_apis::test_util::RunBlockingPoolTask();
1175 1191
1176 EXPECT_EQ(7, count); 1192 EXPECT_EQ(7, count);
1177 EXPECT_TRUE(completed); 1193 EXPECT_TRUE(completed);
1178 } 1194 }
1179 1195
1180 } // namespace drive 1196 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698