OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/file_system_provider/registry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/registry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 "chrome-extension://efgefgefgefgefgefgefgefgefgefgefgefge/"; | 29 "chrome-extension://efgefgefgefgefgefgefgefgefgefgefgefge/"; |
30 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; | 30 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; |
31 const char kDisplayName[] = "Camera Pictures"; | 31 const char kDisplayName[] = "Camera Pictures"; |
32 | 32 |
33 // The dot in the file system ID is there in order to check that saving to | 33 // The dot in the file system ID is there in order to check that saving to |
34 // preferences works correctly. File System ID is used as a key in | 34 // preferences works correctly. File System ID is used as a key in |
35 // a base::DictionaryValue, so it has to be stored without path expansion. | 35 // a base::DictionaryValue, so it has to be stored without path expansion. |
36 const char kFileSystemId[] = "camera/pictures/id .!@#$%^&*()_+"; | 36 const char kFileSystemId[] = "camera/pictures/id .!@#$%^&*()_+"; |
37 | 37 |
38 // Stores a provided file system information in preferences together with a | 38 // Stores a provided file system information in preferences together with a |
39 // fake observed entry. | 39 // fake watcher. |
40 void RememberFakeFileSystem(TestingProfile* profile, | 40 void RememberFakeFileSystem(TestingProfile* profile, |
41 const std::string& extension_id, | 41 const std::string& extension_id, |
42 const std::string& file_system_id, | 42 const std::string& file_system_id, |
43 const std::string& display_name, | 43 const std::string& display_name, |
44 bool writable, | 44 bool writable, |
45 bool supports_notify_tag, | 45 bool supports_notify_tag, |
46 const ObservedEntry& observed_entry) { | 46 const Watcher& watcher) { |
47 // Warning. Updating this code means that backward compatibility may be | 47 // Warning. Updating this code means that backward compatibility may be |
48 // broken, what is unexpected and should be avoided. | 48 // broken, what is unexpected and should be avoided. |
49 TestingPrefServiceSyncable* const pref_service = | 49 TestingPrefServiceSyncable* const pref_service = |
50 profile->GetTestingPrefService(); | 50 profile->GetTestingPrefService(); |
51 ASSERT_TRUE(pref_service); | 51 ASSERT_TRUE(pref_service); |
52 | 52 |
53 base::DictionaryValue extensions; | 53 base::DictionaryValue extensions; |
54 base::DictionaryValue* const file_systems = new base::DictionaryValue(); | 54 base::DictionaryValue* const file_systems = new base::DictionaryValue(); |
55 base::DictionaryValue* const file_system = new base::DictionaryValue(); | 55 base::DictionaryValue* const file_system = new base::DictionaryValue(); |
56 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId, | 56 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId, |
57 kFileSystemId); | 57 kFileSystemId); |
58 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName); | 58 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName); |
59 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable); | 59 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable); |
60 file_system->SetBooleanWithoutPathExpansion(kPrefKeySupportsNotifyTag, | 60 file_system->SetBooleanWithoutPathExpansion(kPrefKeySupportsNotifyTag, |
61 supports_notify_tag); | 61 supports_notify_tag); |
62 file_systems->SetWithoutPathExpansion(kFileSystemId, file_system); | 62 file_systems->SetWithoutPathExpansion(kFileSystemId, file_system); |
63 extensions.SetWithoutPathExpansion(kExtensionId, file_systems); | 63 extensions.SetWithoutPathExpansion(kExtensionId, file_systems); |
64 | 64 |
65 // Remember observed entries. | 65 // Remember watchers. |
66 base::DictionaryValue* const observed_entries = new base::DictionaryValue(); | 66 base::DictionaryValue* const watchers = new base::DictionaryValue(); |
67 file_system->SetWithoutPathExpansion(kPrefKeyObservedEntries, | 67 file_system->SetWithoutPathExpansion(kPrefKeyWatchers, watchers); |
68 observed_entries); | 68 base::DictionaryValue* const watcher_value = new base::DictionaryValue(); |
69 base::DictionaryValue* const observed_entry_value = | 69 watchers->SetWithoutPathExpansion(watcher.entry_path.value(), watcher_value); |
70 new base::DictionaryValue(); | 70 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath, |
71 observed_entries->SetWithoutPathExpansion(observed_entry.entry_path.value(), | 71 watcher.entry_path.value()); |
72 observed_entry_value); | 72 watcher_value->SetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive, |
73 observed_entry_value->SetStringWithoutPathExpansion( | 73 watcher.recursive); |
74 kPrefKeyObservedEntryEntryPath, observed_entry.entry_path.value()); | 74 watcher_value->SetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, |
75 observed_entry_value->SetBooleanWithoutPathExpansion( | 75 watcher.last_tag); |
76 kPrefKeyObservedEntryRecursive, observed_entry.recursive); | |
77 observed_entry_value->SetStringWithoutPathExpansion( | |
78 kPrefKeyObservedEntryLastTag, observed_entry.last_tag); | |
79 base::ListValue* const persistent_origins_value = new base::ListValue(); | 76 base::ListValue* const persistent_origins_value = new base::ListValue(); |
80 observed_entry_value->SetWithoutPathExpansion( | 77 watcher_value->SetWithoutPathExpansion(kPrefKeyWatcherPersistentOrigins, |
81 kPrefKeyObservedEntryPersistentOrigins, persistent_origins_value); | 78 persistent_origins_value); |
82 for (const auto& subscriber_it : observed_entry.subscribers) { | 79 for (const auto& subscriber_it : watcher.subscribers) { |
83 if (subscriber_it.second.persistent) | 80 if (subscriber_it.second.persistent) |
84 persistent_origins_value->AppendString(subscriber_it.first.spec()); | 81 persistent_origins_value->AppendString(subscriber_it.first.spec()); |
85 } | 82 } |
86 | 83 |
87 pref_service->Set(prefs::kFileSystemProviderMounted, extensions); | 84 pref_service->Set(prefs::kFileSystemProviderMounted, extensions); |
88 } | 85 } |
89 | 86 |
90 } // namespace | 87 } // namespace |
91 | 88 |
92 class FileSystemProviderRegistryTest : public testing::Test { | 89 class FileSystemProviderRegistryTest : public testing::Test { |
93 protected: | 90 protected: |
94 FileSystemProviderRegistryTest() : profile_(NULL) {} | 91 FileSystemProviderRegistryTest() : profile_(NULL) {} |
95 | 92 |
96 virtual ~FileSystemProviderRegistryTest() {} | 93 virtual ~FileSystemProviderRegistryTest() {} |
97 | 94 |
98 virtual void SetUp() override { | 95 virtual void SetUp() override { |
99 profile_manager_.reset( | 96 profile_manager_.reset( |
100 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 97 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
101 ASSERT_TRUE(profile_manager_->SetUp()); | 98 ASSERT_TRUE(profile_manager_->SetUp()); |
102 profile_ = profile_manager_->CreateTestingProfile("test-user@example.com"); | 99 profile_ = profile_manager_->CreateTestingProfile("test-user@example.com"); |
103 registry_.reset(new Registry(profile_)); | 100 registry_.reset(new Registry(profile_)); |
104 fake_observed_entry_.entry_path = | 101 fake_watcher_.entry_path = base::FilePath(FILE_PATH_LITERAL("/a/b/c")); |
105 base::FilePath(FILE_PATH_LITERAL("/a/b/c")); | 102 fake_watcher_.recursive = true; |
106 fake_observed_entry_.recursive = true; | 103 fake_watcher_.subscribers[GURL(kTemporaryOrigin)].origin = |
107 fake_observed_entry_.subscribers[GURL(kTemporaryOrigin)].origin = | |
108 GURL(kTemporaryOrigin); | 104 GURL(kTemporaryOrigin); |
109 fake_observed_entry_.subscribers[GURL(kTemporaryOrigin)].persistent = false; | 105 fake_watcher_.subscribers[GURL(kTemporaryOrigin)].persistent = false; |
110 fake_observed_entry_.subscribers[GURL(kPersistentOrigin)].origin = | 106 fake_watcher_.subscribers[GURL(kPersistentOrigin)].origin = |
111 GURL(kPersistentOrigin); | 107 GURL(kPersistentOrigin); |
112 fake_observed_entry_.subscribers[GURL(kPersistentOrigin)].persistent = true; | 108 fake_watcher_.subscribers[GURL(kPersistentOrigin)].persistent = true; |
113 fake_observed_entry_.last_tag = "hello-world"; | 109 fake_watcher_.last_tag = "hello-world"; |
114 } | 110 } |
115 | 111 |
116 content::TestBrowserThreadBundle thread_bundle_; | 112 content::TestBrowserThreadBundle thread_bundle_; |
117 scoped_ptr<TestingProfileManager> profile_manager_; | 113 scoped_ptr<TestingProfileManager> profile_manager_; |
118 TestingProfile* profile_; | 114 TestingProfile* profile_; |
119 scoped_ptr<RegistryInterface> registry_; | 115 scoped_ptr<RegistryInterface> registry_; |
120 ObservedEntry fake_observed_entry_; | 116 Watcher fake_watcher_; |
121 }; | 117 }; |
122 | 118 |
123 TEST_F(FileSystemProviderRegistryTest, RestoreFileSystems) { | 119 TEST_F(FileSystemProviderRegistryTest, RestoreFileSystems) { |
124 // Create a fake entry in the preferences. | 120 // Create a fake entry in the preferences. |
125 RememberFakeFileSystem(profile_, | 121 RememberFakeFileSystem(profile_, |
126 kExtensionId, | 122 kExtensionId, |
127 kFileSystemId, | 123 kFileSystemId, |
128 kDisplayName, | 124 kDisplayName, |
129 true /* writable */, | 125 true /* writable */, |
130 true /* supports_notify_tag */, | 126 true /* supports_notify_tag */, |
131 fake_observed_entry_); | 127 fake_watcher_); |
132 | 128 |
133 scoped_ptr<RegistryInterface::RestoredFileSystems> restored_file_systems = | 129 scoped_ptr<RegistryInterface::RestoredFileSystems> restored_file_systems = |
134 registry_->RestoreFileSystems(kExtensionId); | 130 registry_->RestoreFileSystems(kExtensionId); |
135 | 131 |
136 ASSERT_EQ(1u, restored_file_systems->size()); | 132 ASSERT_EQ(1u, restored_file_systems->size()); |
137 const RegistryInterface::RestoredFileSystem& restored_file_system = | 133 const RegistryInterface::RestoredFileSystem& restored_file_system = |
138 restored_file_systems->at(0); | 134 restored_file_systems->at(0); |
139 EXPECT_EQ(kExtensionId, restored_file_system.extension_id); | 135 EXPECT_EQ(kExtensionId, restored_file_system.extension_id); |
140 EXPECT_EQ(kFileSystemId, restored_file_system.options.file_system_id); | 136 EXPECT_EQ(kFileSystemId, restored_file_system.options.file_system_id); |
141 EXPECT_EQ(kDisplayName, restored_file_system.options.display_name); | 137 EXPECT_EQ(kDisplayName, restored_file_system.options.display_name); |
142 EXPECT_TRUE(restored_file_system.options.writable); | 138 EXPECT_TRUE(restored_file_system.options.writable); |
143 EXPECT_TRUE(restored_file_system.options.supports_notify_tag); | 139 EXPECT_TRUE(restored_file_system.options.supports_notify_tag); |
144 | 140 |
145 ASSERT_EQ(1u, restored_file_system.observed_entries.size()); | 141 ASSERT_EQ(1u, restored_file_system.watchers.size()); |
146 const auto& restored_observed_entry_it = | 142 const auto& restored_watcher_it = restored_file_system.watchers.find( |
147 restored_file_system.observed_entries.find(ObservedEntryKey( | 143 WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)); |
148 fake_observed_entry_.entry_path, fake_observed_entry_.recursive)); | 144 ASSERT_NE(restored_file_system.watchers.end(), restored_watcher_it); |
149 ASSERT_NE(restored_file_system.observed_entries.end(), | |
150 restored_observed_entry_it); | |
151 | 145 |
152 EXPECT_EQ(fake_observed_entry_.entry_path, | 146 EXPECT_EQ(fake_watcher_.entry_path, restored_watcher_it->second.entry_path); |
153 restored_observed_entry_it->second.entry_path); | 147 EXPECT_EQ(fake_watcher_.recursive, restored_watcher_it->second.recursive); |
154 EXPECT_EQ(fake_observed_entry_.recursive, | 148 EXPECT_EQ(fake_watcher_.last_tag, restored_watcher_it->second.last_tag); |
155 restored_observed_entry_it->second.recursive); | |
156 EXPECT_EQ(fake_observed_entry_.last_tag, | |
157 restored_observed_entry_it->second.last_tag); | |
158 } | 149 } |
159 | 150 |
160 TEST_F(FileSystemProviderRegistryTest, RememberFileSystem) { | 151 TEST_F(FileSystemProviderRegistryTest, RememberFileSystem) { |
161 MountOptions options(kFileSystemId, kDisplayName); | 152 MountOptions options(kFileSystemId, kDisplayName); |
162 options.writable = true; | 153 options.writable = true; |
163 options.supports_notify_tag = true; | 154 options.supports_notify_tag = true; |
164 | 155 |
165 ProvidedFileSystemInfo file_system_info( | 156 ProvidedFileSystemInfo file_system_info( |
166 kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c"))); | 157 kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c"))); |
167 | 158 |
168 ObservedEntries observed_entries; | 159 Watchers watchers; |
169 observed_entries[ObservedEntryKey(fake_observed_entry_.entry_path, | 160 watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = |
170 fake_observed_entry_.recursive)] = | 161 fake_watcher_; |
171 fake_observed_entry_; | |
172 | 162 |
173 registry_->RememberFileSystem(file_system_info, observed_entries); | 163 registry_->RememberFileSystem(file_system_info, watchers); |
174 | 164 |
175 TestingPrefServiceSyncable* const pref_service = | 165 TestingPrefServiceSyncable* const pref_service = |
176 profile_->GetTestingPrefService(); | 166 profile_->GetTestingPrefService(); |
177 ASSERT_TRUE(pref_service); | 167 ASSERT_TRUE(pref_service); |
178 | 168 |
179 const base::DictionaryValue* const extensions = | 169 const base::DictionaryValue* const extensions = |
180 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); | 170 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); |
181 ASSERT_TRUE(extensions); | 171 ASSERT_TRUE(extensions); |
182 | 172 |
183 const base::DictionaryValue* file_systems = NULL; | 173 const base::DictionaryValue* file_systems = NULL; |
(...skipping 20 matching lines...) Expand all Loading... |
204 bool writable = false; | 194 bool writable = false; |
205 EXPECT_TRUE( | 195 EXPECT_TRUE( |
206 file_system->GetBooleanWithoutPathExpansion(kPrefKeyWritable, &writable)); | 196 file_system->GetBooleanWithoutPathExpansion(kPrefKeyWritable, &writable)); |
207 EXPECT_TRUE(writable); | 197 EXPECT_TRUE(writable); |
208 | 198 |
209 bool supports_notify_tag = false; | 199 bool supports_notify_tag = false; |
210 EXPECT_TRUE(file_system->GetBooleanWithoutPathExpansion( | 200 EXPECT_TRUE(file_system->GetBooleanWithoutPathExpansion( |
211 kPrefKeySupportsNotifyTag, &supports_notify_tag)); | 201 kPrefKeySupportsNotifyTag, &supports_notify_tag)); |
212 EXPECT_TRUE(supports_notify_tag); | 202 EXPECT_TRUE(supports_notify_tag); |
213 | 203 |
214 const base::DictionaryValue* observed_entries_value = NULL; | 204 const base::DictionaryValue* watchers_value = NULL; |
215 ASSERT_TRUE(file_system->GetDictionaryWithoutPathExpansion( | 205 ASSERT_TRUE(file_system->GetDictionaryWithoutPathExpansion(kPrefKeyWatchers, |
216 kPrefKeyObservedEntries, &observed_entries_value)); | 206 &watchers_value)); |
217 | 207 |
218 const base::DictionaryValue* observed_entry = NULL; | 208 const base::DictionaryValue* watcher = NULL; |
219 ASSERT_TRUE(observed_entries_value->GetDictionaryWithoutPathExpansion( | 209 ASSERT_TRUE(watchers_value->GetDictionaryWithoutPathExpansion( |
220 fake_observed_entry_.entry_path.value(), &observed_entry)); | 210 fake_watcher_.entry_path.value(), &watcher)); |
221 | 211 |
222 std::string entry_path; | 212 std::string entry_path; |
223 EXPECT_TRUE(observed_entry->GetStringWithoutPathExpansion( | 213 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherEntryPath, |
224 kPrefKeyObservedEntryEntryPath, &entry_path)); | 214 &entry_path)); |
225 EXPECT_EQ(fake_observed_entry_.entry_path.value(), entry_path); | 215 EXPECT_EQ(fake_watcher_.entry_path.value(), entry_path); |
226 | 216 |
227 bool recursive = false; | 217 bool recursive = false; |
228 EXPECT_TRUE(observed_entry->GetBooleanWithoutPathExpansion( | 218 EXPECT_TRUE(watcher->GetBooleanWithoutPathExpansion(kPrefKeyWatcherRecursive, |
229 kPrefKeyObservedEntryRecursive, &recursive)); | 219 &recursive)); |
230 EXPECT_EQ(fake_observed_entry_.recursive, recursive); | 220 EXPECT_EQ(fake_watcher_.recursive, recursive); |
231 | 221 |
232 std::string last_tag; | 222 std::string last_tag; |
233 EXPECT_TRUE(observed_entry->GetStringWithoutPathExpansion( | 223 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, |
234 kPrefKeyObservedEntryLastTag, &last_tag)); | 224 &last_tag)); |
235 EXPECT_EQ(fake_observed_entry_.last_tag, last_tag); | 225 EXPECT_EQ(fake_watcher_.last_tag, last_tag); |
236 | 226 |
237 const base::ListValue* persistent_origins = NULL; | 227 const base::ListValue* persistent_origins = NULL; |
238 ASSERT_TRUE(observed_entry->GetListWithoutPathExpansion( | 228 ASSERT_TRUE(watcher->GetListWithoutPathExpansion( |
239 kPrefKeyObservedEntryPersistentOrigins, &persistent_origins)); | 229 kPrefKeyWatcherPersistentOrigins, &persistent_origins)); |
240 ASSERT_GT(fake_observed_entry_.subscribers.size(), | 230 ASSERT_GT(fake_watcher_.subscribers.size(), persistent_origins->GetSize()); |
241 persistent_origins->GetSize()); | |
242 ASSERT_EQ(1u, persistent_origins->GetSize()); | 231 ASSERT_EQ(1u, persistent_origins->GetSize()); |
243 std::string persistent_origin; | 232 std::string persistent_origin; |
244 EXPECT_TRUE(persistent_origins->GetString(0, &persistent_origin)); | 233 EXPECT_TRUE(persistent_origins->GetString(0, &persistent_origin)); |
245 const auto& fake_subscriber_it = | 234 const auto& fake_subscriber_it = |
246 fake_observed_entry_.subscribers.find(GURL(persistent_origin)); | 235 fake_watcher_.subscribers.find(GURL(persistent_origin)); |
247 ASSERT_NE(fake_observed_entry_.subscribers.end(), fake_subscriber_it); | 236 ASSERT_NE(fake_watcher_.subscribers.end(), fake_subscriber_it); |
248 EXPECT_TRUE(fake_subscriber_it->second.persistent); | 237 EXPECT_TRUE(fake_subscriber_it->second.persistent); |
249 } | 238 } |
250 | 239 |
251 TEST_F(FileSystemProviderRegistryTest, ForgetFileSystem) { | 240 TEST_F(FileSystemProviderRegistryTest, ForgetFileSystem) { |
252 // Create a fake file systems in the preferences. | 241 // Create a fake file systems in the preferences. |
253 RememberFakeFileSystem(profile_, | 242 RememberFakeFileSystem(profile_, |
254 kExtensionId, | 243 kExtensionId, |
255 kFileSystemId, | 244 kFileSystemId, |
256 kDisplayName, | 245 kDisplayName, |
257 true /* writable */, | 246 true /* writable */, |
258 true /* supports_notify_tag */, | 247 true /* supports_notify_tag */, |
259 fake_observed_entry_); | 248 fake_watcher_); |
260 | 249 |
261 registry_->ForgetFileSystem(kExtensionId, kFileSystemId); | 250 registry_->ForgetFileSystem(kExtensionId, kFileSystemId); |
262 | 251 |
263 TestingPrefServiceSyncable* const pref_service = | 252 TestingPrefServiceSyncable* const pref_service = |
264 profile_->GetTestingPrefService(); | 253 profile_->GetTestingPrefService(); |
265 ASSERT_TRUE(pref_service); | 254 ASSERT_TRUE(pref_service); |
266 | 255 |
267 const base::DictionaryValue* const extensions = | 256 const base::DictionaryValue* const extensions = |
268 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); | 257 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); |
269 ASSERT_TRUE(extensions); | 258 ASSERT_TRUE(extensions); |
270 | 259 |
271 const base::DictionaryValue* file_systems = NULL; | 260 const base::DictionaryValue* file_systems = NULL; |
272 EXPECT_FALSE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, | 261 EXPECT_FALSE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, |
273 &file_systems)); | 262 &file_systems)); |
274 } | 263 } |
275 | 264 |
276 TEST_F(FileSystemProviderRegistryTest, UpdateObservedEntryTag) { | 265 TEST_F(FileSystemProviderRegistryTest, UpdateWatcherTag) { |
277 MountOptions options(kFileSystemId, kDisplayName); | 266 MountOptions options(kFileSystemId, kDisplayName); |
278 options.writable = true; | 267 options.writable = true; |
279 options.supports_notify_tag = true; | 268 options.supports_notify_tag = true; |
280 | 269 |
281 ProvidedFileSystemInfo file_system_info( | 270 ProvidedFileSystemInfo file_system_info( |
282 kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c"))); | 271 kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c"))); |
283 | 272 |
284 ObservedEntries observed_entries; | 273 Watchers watchers; |
285 observed_entries[ObservedEntryKey(fake_observed_entry_.entry_path, | 274 watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = |
286 fake_observed_entry_.recursive)] = | 275 fake_watcher_; |
287 fake_observed_entry_; | |
288 | 276 |
289 registry_->RememberFileSystem(file_system_info, observed_entries); | 277 registry_->RememberFileSystem(file_system_info, watchers); |
290 | 278 |
291 fake_observed_entry_.last_tag = "updated-tag"; | 279 fake_watcher_.last_tag = "updated-tag"; |
292 registry_->UpdateObservedEntryTag(file_system_info, fake_observed_entry_); | 280 registry_->UpdateWatcherTag(file_system_info, fake_watcher_); |
293 | 281 |
294 TestingPrefServiceSyncable* const pref_service = | 282 TestingPrefServiceSyncable* const pref_service = |
295 profile_->GetTestingPrefService(); | 283 profile_->GetTestingPrefService(); |
296 ASSERT_TRUE(pref_service); | 284 ASSERT_TRUE(pref_service); |
297 | 285 |
298 const base::DictionaryValue* const extensions = | 286 const base::DictionaryValue* const extensions = |
299 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); | 287 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); |
300 ASSERT_TRUE(extensions); | 288 ASSERT_TRUE(extensions); |
301 | 289 |
302 const base::DictionaryValue* file_systems = NULL; | 290 const base::DictionaryValue* file_systems = NULL; |
303 ASSERT_TRUE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, | 291 ASSERT_TRUE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, |
304 &file_systems)); | 292 &file_systems)); |
305 EXPECT_EQ(1u, file_systems->size()); | 293 EXPECT_EQ(1u, file_systems->size()); |
306 | 294 |
307 const base::Value* file_system_value = NULL; | 295 const base::Value* file_system_value = NULL; |
308 const base::DictionaryValue* file_system = NULL; | 296 const base::DictionaryValue* file_system = NULL; |
309 ASSERT_TRUE( | 297 ASSERT_TRUE( |
310 file_systems->GetWithoutPathExpansion(kFileSystemId, &file_system_value)); | 298 file_systems->GetWithoutPathExpansion(kFileSystemId, &file_system_value)); |
311 ASSERT_TRUE(file_system_value->GetAsDictionary(&file_system)); | 299 ASSERT_TRUE(file_system_value->GetAsDictionary(&file_system)); |
312 | 300 |
313 const base::DictionaryValue* observed_entries_value = NULL; | 301 const base::DictionaryValue* watchers_value = NULL; |
314 ASSERT_TRUE(file_system->GetDictionaryWithoutPathExpansion( | 302 ASSERT_TRUE(file_system->GetDictionaryWithoutPathExpansion(kPrefKeyWatchers, |
315 kPrefKeyObservedEntries, &observed_entries_value)); | 303 &watchers_value)); |
316 | 304 |
317 const base::DictionaryValue* observed_entry = NULL; | 305 const base::DictionaryValue* watcher = NULL; |
318 ASSERT_TRUE(observed_entries_value->GetDictionaryWithoutPathExpansion( | 306 ASSERT_TRUE(watchers_value->GetDictionaryWithoutPathExpansion( |
319 fake_observed_entry_.entry_path.value(), &observed_entry)); | 307 fake_watcher_.entry_path.value(), &watcher)); |
320 | 308 |
321 std::string last_tag; | 309 std::string last_tag; |
322 EXPECT_TRUE(observed_entry->GetStringWithoutPathExpansion( | 310 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, |
323 kPrefKeyObservedEntryLastTag, &last_tag)); | 311 &last_tag)); |
324 EXPECT_EQ(fake_observed_entry_.last_tag, last_tag); | 312 EXPECT_EQ(fake_watcher_.last_tag, last_tag); |
325 } | 313 } |
326 | 314 |
327 } // namespace file_system_provider | 315 } // namespace file_system_provider |
328 } // namespace chromeos | 316 } // namespace chromeos |
OLD | NEW |