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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_sync_unittest.cc

Issue 165223003: Add a Restore() method to ValueStore and make StorageAPI use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 // SettingsStorageFactory implementation. 170 // SettingsStorageFactory implementation.
171 virtual ValueStore* Create(const base::FilePath& base_path, 171 virtual ValueStore* Create(const base::FilePath& base_path,
172 const std::string& extension_id) OVERRIDE { 172 const std::string& extension_id) OVERRIDE {
173 TestingValueStore* new_storage = new TestingValueStore(); 173 TestingValueStore* new_storage = new TestingValueStore();
174 DCHECK(!created_.count(extension_id)); 174 DCHECK(!created_.count(extension_id));
175 created_[extension_id] = new_storage; 175 created_[extension_id] = new_storage;
176 return new_storage; 176 return new_storage;
177 } 177 }
178 178
179 // Testing value stores don't actually create a real database. Don't delete
180 // any files.
181 virtual void DeleteDatabaseIfExists(
182 const base::FilePath& base_path,
183 const std::string& extension_id) OVERRIDE {}
184
179 private: 185 private:
180 // SettingsStorageFactory is refcounted. 186 // SettingsStorageFactory is refcounted.
181 virtual ~TestingValueStoreFactory() {} 187 virtual ~TestingValueStoreFactory() {}
182 188
183 // None of these storage areas are owned by this factory, so care must be 189 // None of these storage areas are owned by this factory, so care must be
184 // taken when calling GetExisting. 190 // taken when calling GetExisting.
185 std::map<std::string, TestingValueStore*> created_; 191 std::map<std::string, TestingValueStore*> created_;
186 }; 192 };
187 193
188 } // namespace 194 } // namespace
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 ASSERT_EQ(1u, sync_processor_->changes().size()); 1417 ASSERT_EQ(1u, sync_processor_->changes().size());
1412 SettingSyncData sync_data = sync_processor_->changes()[0]; 1418 SettingSyncData sync_data = sync_processor_->changes()[0];
1413 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); 1419 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type());
1414 EXPECT_EQ("ext", sync_data.extension_id()); 1420 EXPECT_EQ("ext", sync_data.extension_id());
1415 EXPECT_EQ("key.with.spot", sync_data.key()); 1421 EXPECT_EQ("key.with.spot", sync_data.key());
1416 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); 1422 EXPECT_TRUE(sync_data.value().Equals(string_value.get()));
1417 } 1423 }
1418 } 1424 }
1419 1425
1420 } // namespace extensions 1426 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698