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

Unified Diff: webkit/fileapi/syncable/local_file_change_tracker_unittest.cc

Issue 10966003: Add LocalFileChangeTracker database to record non-synced dirty files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Normalize expected file path Created 8 years, 3 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/syncable/local_file_change_tracker.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
diff --git a/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc b/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
index 0eb77af71934bb5b41c21695e1eca7b68f2bb5fd..d11c0dca9272583958e646efc4af3c0032c3b288 100644
--- a/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
+++ b/webkit/fileapi/syncable/local_file_change_tracker_unittest.cc
@@ -8,7 +8,9 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
+#include "base/scoped_temp_dir.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/fileapi/isolated_context.h"
#include "webkit/fileapi/syncable/local_file_change_tracker.h"
#include "webkit/fileapi/syncable/local_file_sync_status.h"
@@ -24,6 +26,8 @@ const char kURL2[] = "filesystem:http://foo.com/test/foo.txt";
const char kURL3[] = "filesystem:http://foo.com/test/bar";
const char kURL4[] = "filesystem:http://foo.com/temporary/dir a";
+const char kExternalFileSystemID[] = "drive";
+
FileSystemURL URL(const char* spec) {
return FileSystemURL(GURL(spec));
}
@@ -33,9 +37,19 @@ FileSystemURL URL(const char* spec) {
class LocalFileChangeTrackerTest : public testing::Test {
public:
LocalFileChangeTrackerTest()
- : sync_status_(new LocalFileSyncStatus),
- change_tracker_(new LocalFileChangeTracker(
- sync_status_.get(), base::MessageLoopProxy::current())) {}
+ : sync_status_(new LocalFileSyncStatus) {}
+
+ virtual void SetUp() OVERRIDE {
+ EXPECT_TRUE(data_dir_.CreateUniqueTempDir());
+ change_tracker_.reset(new LocalFileChangeTracker(
+ sync_status_.get(),
+ data_dir_.path(),
+ base::MessageLoopProxy::current()));
+ IsolatedContext::GetInstance()->RegisterExternalFileSystem(
+ kExternalFileSystemID,
+ kFileSystemTypeSyncable,
+ FilePath());
+ }
protected:
LocalFileSyncStatus* sync_status() const {
@@ -46,6 +60,16 @@ class LocalFileChangeTrackerTest : public testing::Test {
return change_tracker_.get();
}
+ std::string SerializeExternalFileSystemURL(const FileSystemURL& url) {
+ return change_tracker_->SerializeExternalFileSystemURL(url);
+ }
+
+ bool DeserializeExternalFileSystemURL(
+ const std::string& serialized_url, FileSystemURL* url) {
+ return change_tracker_->DeserializeExternalFileSystemURL(
+ serialized_url, url);
+ }
+
void VerifyChange(const FileSystemURL& url,
const FileChange& expected_change) {
SCOPED_TRACE(testing::Message() << url.spec() <<
@@ -73,6 +97,7 @@ class LocalFileChangeTrackerTest : public testing::Test {
}
private:
+ ScopedTempDir data_dir_;
MessageLoop message_loop_;
scoped_ptr<LocalFileSyncStatus> sync_status_;
scoped_ptr<LocalFileChangeTracker> change_tracker_;
@@ -114,4 +139,27 @@ TEST_F(LocalFileChangeTrackerTest, GetChanges) {
FileChange::FILE_TYPE_FILE));
}
+TEST_F(LocalFileChangeTrackerTest, SerializeExternalFileSystemURL) {
+ const std::string kFileSystemRootURI = "filesystem:http://foo.com/external/";
+
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+ const std::string kRelativePath = "dir a\\file";
+#else
+ const std::string kRelativePath = "dir a/file";
+#endif // FILE_PATH_USES_WIN_SEPARATORS
+
+ const std::string kExternalFileSystemURL =
+ kFileSystemRootURI + kExternalFileSystemID + "/" + kRelativePath;
+ const FileSystemURL url = FileSystemURL(GURL(kExternalFileSystemURL));
+
+ const std::string serialized = SerializeExternalFileSystemURL(url);
+ EXPECT_EQ(kExternalFileSystemURL, serialized);
+
+ FileSystemURL deserialized;
+ EXPECT_TRUE(DeserializeExternalFileSystemURL(serialized, &deserialized));
+ EXPECT_EQ(url, deserialized);
+}
+
+// TODO(nhiroki): add unittests to ensure the database works successfully.
+
} // namespace fileapi
« no previous file with comments | « webkit/fileapi/syncable/local_file_change_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698