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

Unified Diff: webkit/fileapi/local_file_system_operation_write_unittest.cc

Issue 11043015: Merge 158784 - Send OnModifyFile Notification when File Write completes successfully or fails but s… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 2 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 | « webkit/fileapi/local_file_system_operation.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/local_file_system_operation_write_unittest.cc
===================================================================
--- webkit/fileapi/local_file_system_operation_write_unittest.cc (revision 159825)
+++ webkit/fileapi/local_file_system_operation_write_unittest.cc (working copy)
@@ -24,6 +24,7 @@
#include "webkit/fileapi/local_file_system_operation.h"
#include "webkit/fileapi/local_file_system_test_helper.h"
#include "webkit/fileapi/local_file_util.h"
+#include "webkit/fileapi/mock_file_change_observer.h"
#include "webkit/quota/quota_manager.h"
using quota::QuotaManager;
@@ -76,7 +77,9 @@
status_(base::PLATFORM_FILE_OK),
cancel_status_(base::PLATFORM_FILE_ERROR_FAILED),
bytes_written_(0),
- complete_(false) {}
+ complete_(false) {
+ change_observers_ = MockFileChangeObserver::CreateList(&change_observer_);
+ }
LocalFileSystemOperation* operation();
@@ -94,6 +97,14 @@
virtual void TearDown();
protected:
+ const ChangeObserverList& change_observers() const {
+ return change_observers_;
+ }
+
+ MockFileChangeObserver* change_observer() {
+ return &change_observer_;
+ }
+
FileSystemURL URLForPath(const FilePath& path) const {
return test_helper_.CreateURL(path);
}
@@ -147,6 +158,10 @@
bool complete_;
DISALLOW_COPY_AND_ASSIGN(LocalFileSystemOperationWriteTest);
+
+ private:
+ MockFileChangeObserver change_observer_;
+ ChangeObserverList change_observers_;
};
namespace {
@@ -222,7 +237,9 @@
}
LocalFileSystemOperation* LocalFileSystemOperationWriteTest::operation() {
- return test_helper_.NewOperation();
+ LocalFileSystemOperation* operation = test_helper_.NewOperation();
+ operation->operation_context()->set_change_observers(change_observers());
+ return operation;
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteSuccess) {
@@ -243,6 +260,8 @@
EXPECT_EQ(14, bytes_written());
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteZero) {
@@ -262,6 +281,8 @@
EXPECT_EQ(0, bytes_written());
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteInvalidBlobUrl) {
@@ -274,6 +295,8 @@
EXPECT_EQ(0, bytes_written());
EXPECT_EQ(base::PLATFORM_FILE_ERROR_FAILED, status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteInvalidFile) {
@@ -295,6 +318,8 @@
EXPECT_EQ(0, bytes_written());
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteDir) {
@@ -325,6 +350,8 @@
status() == base::PLATFORM_FILE_ERROR_ACCESS_DENIED ||
status() == base::PLATFORM_FILE_ERROR_FAILED);
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestWriteFailureByQuota) {
@@ -346,6 +373,8 @@
EXPECT_EQ(10, bytes_written());
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestImmediateCancelSuccessfulWrite) {
@@ -374,6 +403,8 @@
EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status());
EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
}
TEST_F(LocalFileSystemOperationWriteTest, TestImmediateCancelFailingWrite) {
@@ -403,6 +434,8 @@
EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status());
EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status());
EXPECT_TRUE(complete());
+
+ EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count());
}
// TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases.
« no previous file with comments | « webkit/fileapi/local_file_system_operation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698