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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 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
OLDNEW
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/sync_file_system/local/local_file_change_tracker.h" 5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <deque> 9 #include <deque>
10 #include <memory> 10 #include <memory>
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 change_tracker()->OnCreateDirectory(URL(kPath2)); 171 change_tracker()->OnCreateDirectory(URL(kPath2));
172 change_tracker()->OnRemoveFile(URL(kPath3)); 172 change_tracker()->OnRemoveFile(URL(kPath3));
173 change_tracker()->OnModifyFile(URL(kPath4)); 173 change_tracker()->OnModifyFile(URL(kPath4));
174 change_tracker()->OnCreateFile(URL(kPath5)); 174 change_tracker()->OnCreateFile(URL(kPath5));
175 change_tracker()->OnRemoveFile(URL(kPath5)); // Recorded as 'delete'. 175 change_tracker()->OnRemoveFile(URL(kPath5)); // Recorded as 'delete'.
176 176
177 FileSystemURLSet urls; 177 FileSystemURLSet urls;
178 file_system_.GetChangedURLsInTracker(&urls); 178 file_system_.GetChangedURLsInTracker(&urls);
179 179
180 EXPECT_EQ(5U, urls.size()); 180 EXPECT_EQ(5U, urls.size());
181 EXPECT_TRUE(ContainsKey(urls, URL(kPath1))); 181 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath1)));
182 EXPECT_TRUE(ContainsKey(urls, URL(kPath2))); 182 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath2)));
183 EXPECT_TRUE(ContainsKey(urls, URL(kPath3))); 183 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath3)));
184 EXPECT_TRUE(ContainsKey(urls, URL(kPath4))); 184 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath4)));
185 EXPECT_TRUE(ContainsKey(urls, URL(kPath5))); 185 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath5)));
186 186
187 // Changes for kPath0 must have been offset and removed. 187 // Changes for kPath0 must have been offset and removed.
188 EXPECT_FALSE(ContainsKey(urls, URL(kPath0))); 188 EXPECT_FALSE(base::ContainsKey(urls, URL(kPath0)));
189 189
190 // GetNextChangedURLs only returns up to max_urls (i.e. 3) urls. 190 // GetNextChangedURLs only returns up to max_urls (i.e. 3) urls.
191 std::deque<FileSystemURL> urls_to_process; 191 std::deque<FileSystemURL> urls_to_process;
192 change_tracker()->GetNextChangedURLs(&urls_to_process, 3); 192 change_tracker()->GetNextChangedURLs(&urls_to_process, 3);
193 ASSERT_EQ(3U, urls_to_process.size()); 193 ASSERT_EQ(3U, urls_to_process.size());
194 194
195 // Let it return all. 195 // Let it return all.
196 urls_to_process.clear(); 196 urls_to_process.clear();
197 change_tracker()->GetNextChangedURLs(&urls_to_process, 0); 197 change_tracker()->GetNextChangedURLs(&urls_to_process, 0);
198 ASSERT_EQ(5U, urls_to_process.size()); 198 ASSERT_EQ(5U, urls_to_process.size());
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // 663 //
664 // NOTE: This will cause 2 local sync for deleting nonexistent files 664 // NOTE: This will cause 2 local sync for deleting nonexistent files
665 // on the remote side. 665 // on the remote side.
666 // 666 //
667 // TODO(kinuko): For micro optimization we could probably restore the ADD 667 // TODO(kinuko): For micro optimization we could probably restore the ADD
668 // change type (other than ADD_OR_UPDATE) and offset file ADD+DELETE 668 // change type (other than ADD_OR_UPDATE) and offset file ADD+DELETE
669 // changes too. 669 // changes too.
670 ASSERT_EQ(2U, urls.size()); 670 ASSERT_EQ(2U, urls.size());
671 671
672 // The exact order of recursive removal cannot be determined. 672 // The exact order of recursive removal cannot be determined.
673 EXPECT_TRUE(ContainsKey(urls, URL(kPath1))); 673 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath1)));
674 EXPECT_TRUE(ContainsKey(urls, URL(kPath2))); 674 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath2)));
675 } 675 }
676 676
677 TEST_F(LocalFileChangeTrackerTest, ResetForFileSystem) { 677 TEST_F(LocalFileChangeTrackerTest, ResetForFileSystem) {
678 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem()); 678 EXPECT_EQ(base::File::FILE_OK, file_system_.OpenFileSystem());
679 679
680 const char kPath0[] = "dir a"; 680 const char kPath0[] = "dir a";
681 const char kPath1[] = "dir a/file"; 681 const char kPath1[] = "dir a/file";
682 const char kPath2[] = "dir a/subdir"; 682 const char kPath2[] = "dir a/subdir";
683 const char kPath3[] = "dir b"; 683 const char kPath3[] = "dir b";
684 684
685 EXPECT_EQ(base::File::FILE_OK, 685 EXPECT_EQ(base::File::FILE_OK,
686 file_system_.CreateDirectory(URL(kPath0))); 686 file_system_.CreateDirectory(URL(kPath0)));
687 EXPECT_EQ(base::File::FILE_OK, 687 EXPECT_EQ(base::File::FILE_OK,
688 file_system_.CreateFile(URL(kPath1))); 688 file_system_.CreateFile(URL(kPath1)));
689 EXPECT_EQ(base::File::FILE_OK, 689 EXPECT_EQ(base::File::FILE_OK,
690 file_system_.CreateDirectory(URL(kPath2))); 690 file_system_.CreateDirectory(URL(kPath2)));
691 EXPECT_EQ(base::File::FILE_OK, 691 EXPECT_EQ(base::File::FILE_OK,
692 file_system_.CreateDirectory(URL(kPath3))); 692 file_system_.CreateDirectory(URL(kPath3)));
693 693
694 FileSystemURLSet urls; 694 FileSystemURLSet urls;
695 GetAllChangedURLs(&urls); 695 GetAllChangedURLs(&urls);
696 EXPECT_EQ(4u, urls.size()); 696 EXPECT_EQ(4u, urls.size());
697 EXPECT_TRUE(ContainsKey(urls, URL(kPath0))); 697 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath0)));
698 EXPECT_TRUE(ContainsKey(urls, URL(kPath1))); 698 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath1)));
699 EXPECT_TRUE(ContainsKey(urls, URL(kPath2))); 699 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath2)));
700 EXPECT_TRUE(ContainsKey(urls, URL(kPath3))); 700 EXPECT_TRUE(base::ContainsKey(urls, URL(kPath3)));
701 701
702 // Reset all changes for the file system. 702 // Reset all changes for the file system.
703 change_tracker()->ResetForFileSystem( 703 change_tracker()->ResetForFileSystem(
704 file_system_.origin(), file_system_.type()); 704 file_system_.origin(), file_system_.type());
705 705
706 GetAllChangedURLs(&urls); 706 GetAllChangedURLs(&urls);
707 EXPECT_TRUE(urls.empty()); 707 EXPECT_TRUE(urls.empty());
708 708
709 // Make sure they're gone from the database too. 709 // Make sure they're gone from the database too.
710 DropChangesInTracker(); 710 DropChangesInTracker();
711 RestoreChangesFromTrackerDB(); 711 RestoreChangesFromTrackerDB();
712 712
713 GetAllChangedURLs(&urls); 713 GetAllChangedURLs(&urls);
714 EXPECT_TRUE(urls.empty()); 714 EXPECT_TRUE(urls.empty());
715 } 715 }
716 716
717 } // namespace sync_file_system 717 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698