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

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

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 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_sync_context.h" 5 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 file_system.GetChangedURLsInTracker(&urls); 794 file_system.GetChangedURLsInTracker(&urls);
795 ASSERT_EQ(1U, urls.size()); 795 ASSERT_EQ(1U, urls.size());
796 EXPECT_TRUE(ContainsKey(urls, kFile1)); 796 EXPECT_TRUE(ContainsKey(urls, kFile1));
797 file_system.ClearChangeForURLInTracker(*urls.begin()); 797 file_system.ClearChangeForURLInTracker(*urls.begin());
798 798
799 // Prepare temporary files which represent the remote file data. 799 // Prepare temporary files which represent the remote file data.
800 const base::FilePath kFilePath1(temp_dir.path().Append(FPL("file1"))); 800 const base::FilePath kFilePath1(temp_dir.path().Append(FPL("file1")));
801 const base::FilePath kFilePath2(temp_dir.path().Append(FPL("file2"))); 801 const base::FilePath kFilePath2(temp_dir.path().Append(FPL("file2")));
802 802
803 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1), 803 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
804 file_util::WriteFile(kFilePath1, kTestFileData1, 804 base::WriteFile(kFilePath1, kTestFileData1,
805 arraysize(kTestFileData1) - 1)); 805 arraysize(kTestFileData1) - 1));
806 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1), 806 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
807 file_util::WriteFile(kFilePath2, kTestFileData2, 807 base::WriteFile(kFilePath2, kTestFileData2,
808 arraysize(kTestFileData2) - 1)); 808 arraysize(kTestFileData2) - 1));
809 809
810 // Record the usage. 810 // Record the usage.
811 int64 usage = -1, new_usage = -1; 811 int64 usage = -1, new_usage = -1;
812 int64 quota = -1; 812 int64 quota = -1;
813 EXPECT_EQ(quota::kQuotaStatusOk, 813 EXPECT_EQ(quota::kQuotaStatusOk,
814 file_system.GetUsageAndQuota(&usage, &quota)); 814 file_system.GetUsageAndQuota(&usage, &quota));
815 815
816 // Here in the local filesystem we have: 816 // Here in the local filesystem we have:
817 // * kFile1 with kTestFileData0 817 // * kFile1 with kTestFileData0
818 // 818 //
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 const FileSystemURL kDir(file_system.URL("dir")); 925 const FileSystemURL kDir(file_system.URL("dir"));
926 const FileSystemURL kFile(file_system.URL("dir/file")); 926 const FileSystemURL kFile(file_system.URL("dir/file"));
927 927
928 // Either kDir or kFile not exist yet. 928 // Either kDir or kFile not exist yet.
929 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file_system.FileExists(kDir)); 929 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file_system.FileExists(kDir));
930 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file_system.FileExists(kFile)); 930 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file_system.FileExists(kFile));
931 931
932 // Prepare a temporary file which represents remote file data. 932 // Prepare a temporary file which represents remote file data.
933 const base::FilePath kFilePath(temp_dir.path().Append(FPL("file"))); 933 const base::FilePath kFilePath(temp_dir.path().Append(FPL("file")));
934 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData) - 1), 934 ASSERT_EQ(static_cast<int>(arraysize(kTestFileData) - 1),
935 file_util::WriteFile(kFilePath, kTestFileData, 935 base::WriteFile(kFilePath, kTestFileData,
936 arraysize(kTestFileData) - 1)); 936 arraysize(kTestFileData) - 1));
937 937
938 // Calling ApplyChange's with kFilePath should create 938 // Calling ApplyChange's with kFilePath should create
939 // kFile along with kDir. 939 // kFile along with kDir.
940 FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 940 FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
941 SYNC_FILE_TYPE_FILE); 941 SYNC_FILE_TYPE_FILE);
942 EXPECT_EQ(SYNC_STATUS_OK, 942 EXPECT_EQ(SYNC_STATUS_OK,
943 ApplyRemoteChange(file_system.file_system_context(), 943 ApplyRemoteChange(file_system.file_system_context(),
944 change, kFilePath, kFile, 944 change, kFilePath, kFile,
945 SYNC_FILE_TYPE_UNKNOWN)); 945 SYNC_FILE_TYPE_UNKNOWN));
946 946
947 // The changes applied by ApplyRemoteChange should not be recorded in 947 // The changes applied by ApplyRemoteChange should not be recorded in
948 // the change tracker. 948 // the change tracker.
949 FileSystemURLSet urls; 949 FileSystemURLSet urls;
950 urls.clear(); 950 urls.clear();
951 file_system.GetChangedURLsInTracker(&urls); 951 file_system.GetChangedURLsInTracker(&urls);
952 EXPECT_TRUE(urls.empty()); 952 EXPECT_TRUE(urls.empty());
953 953
954 // Make sure kDir and kFile are created by ApplyRemoteChange. 954 // Make sure kDir and kFile are created by ApplyRemoteChange.
955 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile)); 955 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile));
956 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir)); 956 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir));
957 957
958 sync_context_->ShutdownOnUIThread(); 958 sync_context_->ShutdownOnUIThread();
959 file_system.TearDown(); 959 file_system.TearDown();
960 } 960 }
961 961
962 } // namespace sync_file_system 962 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698