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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/registry_unittest.cc

Issue 2459823002: [Sync] Rename syncable_prefs to sync_preferences. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
13 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h" 13 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy stem_provider_capabilities_handler.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "chrome/test/base/testing_profile_manager.h" 17 #include "chrome/test/base/testing_profile_manager.h"
18 #include "components/syncable_prefs/testing_pref_service_syncable.h" 18 #include "components/sync_preferences/testing_pref_service_syncable.h"
19 #include "components/user_prefs/user_prefs.h" 19 #include "components/user_prefs/user_prefs.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace chromeos { 23 namespace chromeos {
24 namespace file_system_provider { 24 namespace file_system_provider {
25 namespace { 25 namespace {
26 26
27 const char kTemporaryOrigin[] = 27 const char kTemporaryOrigin[] =
28 "chrome-extension://abcabcabcabcabcabcabcabcabcabcabcabca/"; 28 "chrome-extension://abcabcabcabcabcabcabcabcabcabcabcabca/";
(...skipping 14 matching lines...) Expand all
43 void RememberFakeFileSystem(TestingProfile* profile, 43 void RememberFakeFileSystem(TestingProfile* profile,
44 const std::string& extension_id, 44 const std::string& extension_id,
45 const std::string& file_system_id, 45 const std::string& file_system_id,
46 const std::string& display_name, 46 const std::string& display_name,
47 bool writable, 47 bool writable,
48 bool supports_notify_tag, 48 bool supports_notify_tag,
49 int opened_files_limit, 49 int opened_files_limit,
50 const Watcher& watcher) { 50 const Watcher& watcher) {
51 // Warning. Updating this code means that backward compatibility may be 51 // Warning. Updating this code means that backward compatibility may be
52 // broken, what is unexpected and should be avoided. 52 // broken, what is unexpected and should be avoided.
53 syncable_prefs::TestingPrefServiceSyncable* const pref_service = 53 sync_preferences::TestingPrefServiceSyncable* const pref_service =
54 profile->GetTestingPrefService(); 54 profile->GetTestingPrefService();
55 ASSERT_TRUE(pref_service); 55 ASSERT_TRUE(pref_service);
56 56
57 base::DictionaryValue extensions; 57 base::DictionaryValue extensions;
58 base::DictionaryValue* const file_systems = new base::DictionaryValue(); 58 base::DictionaryValue* const file_systems = new base::DictionaryValue();
59 base::DictionaryValue* const file_system = new base::DictionaryValue(); 59 base::DictionaryValue* const file_system = new base::DictionaryValue();
60 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId, 60 file_system->SetStringWithoutPathExpansion(kPrefKeyFileSystemId,
61 kFileSystemId); 61 kFileSystemId);
62 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName); 62 file_system->SetStringWithoutPathExpansion(kPrefKeyDisplayName, kDisplayName);
63 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable); 63 file_system->SetBooleanWithoutPathExpansion(kPrefKeyWritable, writable);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 ProvidedFileSystemInfo file_system_info( 160 ProvidedFileSystemInfo file_system_info(
161 kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c")), 161 kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c")),
162 false /* configurable */, true /* watchable */, extensions::SOURCE_FILE); 162 false /* configurable */, true /* watchable */, extensions::SOURCE_FILE);
163 163
164 Watchers watchers; 164 Watchers watchers;
165 watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = 165 watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] =
166 fake_watcher_; 166 fake_watcher_;
167 167
168 registry_->RememberFileSystem(file_system_info, watchers); 168 registry_->RememberFileSystem(file_system_info, watchers);
169 169
170 syncable_prefs::TestingPrefServiceSyncable* const pref_service = 170 sync_preferences::TestingPrefServiceSyncable* const pref_service =
171 profile_->GetTestingPrefService(); 171 profile_->GetTestingPrefService();
172 ASSERT_TRUE(pref_service); 172 ASSERT_TRUE(pref_service);
173 173
174 const base::DictionaryValue* const extensions = 174 const base::DictionaryValue* const extensions =
175 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); 175 pref_service->GetDictionary(prefs::kFileSystemProviderMounted);
176 ASSERT_TRUE(extensions); 176 ASSERT_TRUE(extensions);
177 177
178 const base::DictionaryValue* file_systems = NULL; 178 const base::DictionaryValue* file_systems = NULL;
179 ASSERT_TRUE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, 179 ASSERT_TRUE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId,
180 &file_systems)); 180 &file_systems));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 248 }
249 249
250 TEST_F(FileSystemProviderRegistryTest, ForgetFileSystem) { 250 TEST_F(FileSystemProviderRegistryTest, ForgetFileSystem) {
251 // Create a fake file systems in the preferences. 251 // Create a fake file systems in the preferences.
252 RememberFakeFileSystem(profile_, kExtensionId, kFileSystemId, kDisplayName, 252 RememberFakeFileSystem(profile_, kExtensionId, kFileSystemId, kDisplayName,
253 true /* writable */, true /* supports_notify_tag */, 253 true /* writable */, true /* supports_notify_tag */,
254 kOpenedFilesLimit, fake_watcher_); 254 kOpenedFilesLimit, fake_watcher_);
255 255
256 registry_->ForgetFileSystem(kExtensionId, kFileSystemId); 256 registry_->ForgetFileSystem(kExtensionId, kFileSystemId);
257 257
258 syncable_prefs::TestingPrefServiceSyncable* const pref_service = 258 sync_preferences::TestingPrefServiceSyncable* const pref_service =
259 profile_->GetTestingPrefService(); 259 profile_->GetTestingPrefService();
260 ASSERT_TRUE(pref_service); 260 ASSERT_TRUE(pref_service);
261 261
262 const base::DictionaryValue* const extensions = 262 const base::DictionaryValue* const extensions =
263 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); 263 pref_service->GetDictionary(prefs::kFileSystemProviderMounted);
264 ASSERT_TRUE(extensions); 264 ASSERT_TRUE(extensions);
265 265
266 const base::DictionaryValue* file_systems = NULL; 266 const base::DictionaryValue* file_systems = NULL;
267 EXPECT_FALSE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, 267 EXPECT_FALSE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId,
268 &file_systems)); 268 &file_systems));
(...skipping 10 matching lines...) Expand all
279 279
280 Watchers watchers; 280 Watchers watchers;
281 watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = 281 watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] =
282 fake_watcher_; 282 fake_watcher_;
283 283
284 registry_->RememberFileSystem(file_system_info, watchers); 284 registry_->RememberFileSystem(file_system_info, watchers);
285 285
286 fake_watcher_.last_tag = "updated-tag"; 286 fake_watcher_.last_tag = "updated-tag";
287 registry_->UpdateWatcherTag(file_system_info, fake_watcher_); 287 registry_->UpdateWatcherTag(file_system_info, fake_watcher_);
288 288
289 syncable_prefs::TestingPrefServiceSyncable* const pref_service = 289 sync_preferences::TestingPrefServiceSyncable* const pref_service =
290 profile_->GetTestingPrefService(); 290 profile_->GetTestingPrefService();
291 ASSERT_TRUE(pref_service); 291 ASSERT_TRUE(pref_service);
292 292
293 const base::DictionaryValue* const extensions = 293 const base::DictionaryValue* const extensions =
294 pref_service->GetDictionary(prefs::kFileSystemProviderMounted); 294 pref_service->GetDictionary(prefs::kFileSystemProviderMounted);
295 ASSERT_TRUE(extensions); 295 ASSERT_TRUE(extensions);
296 296
297 const base::DictionaryValue* file_systems = NULL; 297 const base::DictionaryValue* file_systems = NULL;
298 ASSERT_TRUE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId, 298 ASSERT_TRUE(extensions->GetDictionaryWithoutPathExpansion(kExtensionId,
299 &file_systems)); 299 &file_systems));
(...skipping 14 matching lines...) Expand all
314 fake_watcher_.entry_path.value(), &watcher)); 314 fake_watcher_.entry_path.value(), &watcher));
315 315
316 std::string last_tag; 316 std::string last_tag;
317 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag, 317 EXPECT_TRUE(watcher->GetStringWithoutPathExpansion(kPrefKeyWatcherLastTag,
318 &last_tag)); 318 &last_tag));
319 EXPECT_EQ(fake_watcher_.last_tag, last_tag); 319 EXPECT_EQ(fake_watcher_.last_tag, last_tag);
320 } 320 }
321 321
322 } // namespace file_system_provider 322 } // namespace file_system_provider
323 } // namespace chromeos 323 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698