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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_browsertest.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 (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 // Disable everything on windows only. http://crbug.com/306144 5 // Disable everything on windows only. http://crbug.com/306144
6 #ifndef OS_WIN 6 #ifndef OS_WIN
7 7
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // Writes an HTML5 file so that it can be downloaded. 702 // Writes an HTML5 file so that it can be downloaded.
703 class HTML5FileWriter { 703 class HTML5FileWriter {
704 public: 704 public:
705 static bool CreateFileForTesting(fileapi::FileSystemContext* context, 705 static bool CreateFileForTesting(fileapi::FileSystemContext* context,
706 const fileapi::FileSystemURL& path, 706 const fileapi::FileSystemURL& path,
707 const char*data, 707 const char*data,
708 int length) { 708 int length) {
709 // Create a temp file. 709 // Create a temp file.
710 base::FilePath temp_file; 710 base::FilePath temp_file;
711 if (!base::CreateTemporaryFile(&temp_file) || 711 if (!base::CreateTemporaryFile(&temp_file) ||
712 file_util::WriteFile(temp_file, data, length) != length) { 712 base::WriteFile(temp_file, data, length) != length) {
713 return false; 713 return false;
714 } 714 }
715 // Invoke the fileapi to copy it into the sandboxed filesystem. 715 // Invoke the fileapi to copy it into the sandboxed filesystem.
716 bool result = false; 716 bool result = false;
717 base::WaitableEvent done_event(true, false); 717 base::WaitableEvent done_event(true, false);
718 BrowserThread::PostTask( 718 BrowserThread::PostTask(
719 BrowserThread::IO, FROM_HERE, 719 BrowserThread::IO, FROM_HERE,
720 base::Bind(&CreateFileForTestingOnIOThread, 720 base::Bind(&CreateFileForTestingOnIOThread,
721 base::Unretained(context), 721 base::Unretained(context),
722 path, temp_file, 722 path, temp_file,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 DownloadItem::COMPLETE, 1032 DownloadItem::COMPLETE,
1033 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS } 1033 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS }
1034 }; 1034 };
1035 DownloadManager::DownloadVector all_downloads; 1035 DownloadManager::DownloadVector all_downloads;
1036 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo), 1036 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
1037 &all_downloads)); 1037 &all_downloads));
1038 1038
1039 base::FilePath real_path = all_downloads[0]->GetTargetFilePath(); 1039 base::FilePath real_path = all_downloads[0]->GetTargetFilePath();
1040 base::FilePath fake_path = all_downloads[1]->GetTargetFilePath(); 1040 base::FilePath fake_path = all_downloads[1]->GetTargetFilePath();
1041 1041
1042 EXPECT_EQ(0, file_util::WriteFile(real_path, "", 0)); 1042 EXPECT_EQ(0, base::WriteFile(real_path, "", 0));
1043 ASSERT_TRUE(base::PathExists(real_path)); 1043 ASSERT_TRUE(base::PathExists(real_path));
1044 ASSERT_FALSE(base::PathExists(fake_path)); 1044 ASSERT_FALSE(base::PathExists(fake_path));
1045 1045
1046 for (DownloadManager::DownloadVector::iterator iter = all_downloads.begin(); 1046 for (DownloadManager::DownloadVector::iterator iter = all_downloads.begin();
1047 iter != all_downloads.end(); 1047 iter != all_downloads.end();
1048 ++iter) { 1048 ++iter) {
1049 std::string result_string; 1049 std::string result_string;
1050 // Use a MockIconExtractorImpl to test if the correct path is being passed 1050 // Use a MockIconExtractorImpl to test if the correct path is being passed
1051 // into the DownloadFileIconExtractor. 1051 // into the DownloadFileIconExtractor.
1052 EXPECT_TRUE(RunFunctionAndReturnString(MockedGetFileIconFunction( 1052 EXPECT_TRUE(RunFunctionAndReturnString(MockedGetFileIconFunction(
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 EXPECT_EQ("suggester", winner_id); 3635 EXPECT_EQ("suggester", winner_id);
3636 EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value()); 3636 EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value());
3637 EXPECT_EQ(api::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); 3637 EXPECT_EQ(api::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action);
3638 EXPECT_FALSE(warnings.empty()); 3638 EXPECT_FALSE(warnings.empty());
3639 EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, 3639 EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict,
3640 warnings.begin()->warning_type()); 3640 warnings.begin()->warning_type());
3641 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); 3641 EXPECT_EQ("incumbent", warnings.begin()->extension_id());
3642 } 3642 }
3643 3643
3644 #endif // http://crbug.com/3061144 3644 #endif // http://crbug.com/3061144
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698