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

Unified Diff: chrome/browser/chromeos/drive/file_write_helper_unittest.cc

Issue 19596003: Remove CloseFile from FileSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/drive/file_write_helper.cc ('k') | chrome/browser/chromeos/drive/fileapi_worker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_write_helper_unittest.cc
diff --git a/chrome/browser/chromeos/drive/file_write_helper_unittest.cc b/chrome/browser/chromeos/drive/file_write_helper_unittest.cc
index af7bf9d3050c7e7c016bfd48493b6f8e19841d28..42703499b48c3f7de214ae501013026ac3525383 100644
--- a/chrome/browser/chromeos/drive/file_write_helper_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_write_helper_unittest.cc
@@ -23,6 +23,11 @@ const base::FilePath::CharType kLocalPath[] =
class TestFileSystem : public DummyFileSystem {
public:
+ TestFileSystem() : num_closed_(0) {
+ }
+
+ int num_closed() const { return num_closed_; }
+
// Mimics OpenFile. It fails if the |file_path| points to a hosted document.
virtual void OpenFile(const base::FilePath& file_path,
OpenMode open_mode,
@@ -31,17 +36,23 @@ class TestFileSystem : public DummyFileSystem {
// Emulate a case of opening a hosted document.
if (file_path == base::FilePath(kInvalidPath)) {
- callback.Run(FILE_ERROR_INVALID_OPERATION, base::FilePath());
+ callback.Run(FILE_ERROR_INVALID_OPERATION, base::FilePath(),
+ base::Closure());
return;
}
- callback.Run(FILE_ERROR_OK, base::FilePath(kLocalPath));
+ callback.Run(FILE_ERROR_OK, base::FilePath(kLocalPath),
+ base::Bind(&TestFileSystem::CloseFile,
+ base::Unretained(this)));
}
- virtual void CloseFile(const base::FilePath& file_path,
- const FileOperationCallback& callback) OVERRIDE {
- callback.Run(FILE_ERROR_OK);
+ private:
+
+ void CloseFile() {
+ ++num_closed_;
}
+
+ int num_closed_;
};
} // namespace
@@ -69,6 +80,9 @@ TEST_F(FileWriteHelperTest, PrepareFileForWritingSuccess) {
EXPECT_EQ(FILE_ERROR_OK, error);
EXPECT_EQ(kLocalPath, path.value());
+
+ // Make sure that the file is actually closed.
+ EXPECT_EQ(1, test_file_system_->num_closed());
}
TEST_F(FileWriteHelperTest, PrepareFileForWritingCreateFail) {
« no previous file with comments | « chrome/browser/chromeos/drive/file_write_helper.cc ('k') | chrome/browser/chromeos/drive/fileapi_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698