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

Side by Side Diff: chrome/browser/sync_file_system/syncable_file_system_util_unittest.cc

Issue 23526076: [Retry] SyncFS: Support resolveLocalFileSystemURL on SyncFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 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 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/syncable_file_system_util.h" 5 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // non-registered filesystem and non-syncable filesystem. 105 // non-registered filesystem and non-syncable filesystem.
106 FileSystemURL deserialized; 106 FileSystemURL deserialized;
107 EXPECT_FALSE(DeserializeSyncableFileSystemURL( 107 EXPECT_FALSE(DeserializeSyncableFileSystemURL(
108 non_registered_url, &deserialized)); 108 non_registered_url, &deserialized));
109 EXPECT_FALSE(DeserializeSyncableFileSystemURL( 109 EXPECT_FALSE(DeserializeSyncableFileSystemURL(
110 non_syncable_url, &deserialized)); 110 non_syncable_url, &deserialized));
111 111
112 RevokeSyncableFileSystem(); 112 RevokeSyncableFileSystem();
113 } 113 }
114 114
115 TEST(SyncableFileSystemUtilTest, SerializeBeforeOpenFileSystem) {
116 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_;
117 const std::string serialized = kSyncableFileSystemRootURI +
118 CreateNormalizedFilePath(kPath).AsUTF8Unsafe();
119 FileSystemURL deserialized;
120 base::MessageLoop message_loop;
121
122 // Setting up a full syncable filesystem environment.
123 CannedSyncableFileSystem file_system(GURL(kOrigin),
124 base::MessageLoopProxy::current().get(),
125 base::MessageLoopProxy::current().get());
126 file_system.SetUp();
127 scoped_refptr<LocalFileSyncContext> sync_context =
128 new LocalFileSyncContext(base::FilePath(),
129 base::MessageLoopProxy::current().get(),
130 base::MessageLoopProxy::current().get());
131
132 // Before calling initialization we would not be able to get a valid
133 // deserialized URL.
134 EXPECT_FALSE(DeserializeSyncableFileSystemURL(serialized, &deserialized));
135 EXPECT_FALSE(deserialized.is_valid());
136
137 ASSERT_EQ(sync_file_system::SYNC_STATUS_OK,
138 file_system.MaybeInitializeFileSystemContext(sync_context.get()));
139
140 // After initialization this should be ok (even before opening the file
141 // system).
142 EXPECT_TRUE(DeserializeSyncableFileSystemURL(serialized, &deserialized));
143 EXPECT_TRUE(deserialized.is_valid());
144
145 // Shutting down.
146 file_system.TearDown();
147 RevokeSyncableFileSystem();
148 sync_context->ShutdownOnUIThread();
149 sync_context = NULL;
150 base::MessageLoop::current()->RunUntilIdle();
151 }
152
153 TEST(SyncableFileSystemUtilTest, SyncableFileSystemURL_IsParent) { 115 TEST(SyncableFileSystemUtilTest, SyncableFileSystemURL_IsParent) {
154 RegisterSyncableFileSystem(); 116 RegisterSyncableFileSystem();
155 117
156 const std::string root1 = sync_file_system::GetSyncableFileSystemRootURI( 118 const std::string root1 = sync_file_system::GetSyncableFileSystemRootURI(
157 GURL("http://foo.com")).spec(); 119 GURL("http://foo.com")).spec();
158 const std::string root2 = sync_file_system::GetSyncableFileSystemRootURI( 120 const std::string root2 = sync_file_system::GetSyncableFileSystemRootURI(
159 GURL("http://bar.com")).spec(); 121 GURL("http://bar.com")).spec();
160 122
161 const std::string parent("dir"); 123 const std::string parent("dir");
162 const std::string child("dir/child"); 124 const std::string child("dir/child");
163 125
164 // True case. 126 // True case.
165 EXPECT_TRUE(CreateFileSystemURL(root1 + parent).IsParent( 127 EXPECT_TRUE(CreateFileSystemURL(root1 + parent).IsParent(
166 CreateFileSystemURL(root1 + child))); 128 CreateFileSystemURL(root1 + child)));
167 EXPECT_TRUE(CreateFileSystemURL(root2 + parent).IsParent( 129 EXPECT_TRUE(CreateFileSystemURL(root2 + parent).IsParent(
168 CreateFileSystemURL(root2 + child))); 130 CreateFileSystemURL(root2 + child)));
169 131
170 // False case: different origin. 132 // False case: different origin.
171 EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent( 133 EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent(
172 CreateFileSystemURL(root2 + child))); 134 CreateFileSystemURL(root2 + child)));
173 EXPECT_FALSE(CreateFileSystemURL(root2 + parent).IsParent( 135 EXPECT_FALSE(CreateFileSystemURL(root2 + parent).IsParent(
174 CreateFileSystemURL(root1 + child))); 136 CreateFileSystemURL(root1 + child)));
175 137
176 RevokeSyncableFileSystem(); 138 RevokeSyncableFileSystem();
177 } 139 }
178 140
179 } // namespace sync_file_system 141 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service_factory.cc ('k') | content/browser/fileapi/fileapi_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698