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

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

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return ValuesEq(_1, _2, &expected, &actual->settings()); 88 return ValuesEq(_1, _2, &expected, &actual->settings());
89 } 89 }
90 90
91 // SyncChangeProcessor which just records the changes made, accessed after 91 // SyncChangeProcessor which just records the changes made, accessed after
92 // being converted to the more useful SettingSyncData via changes(). 92 // being converted to the more useful SettingSyncData via changes().
93 class MockSyncChangeProcessor : public syncer::SyncChangeProcessor { 93 class MockSyncChangeProcessor : public syncer::SyncChangeProcessor {
94 public: 94 public:
95 MockSyncChangeProcessor() : fail_all_requests_(false) {} 95 MockSyncChangeProcessor() : fail_all_requests_(false) {}
96 96
97 // syncer::SyncChangeProcessor implementation. 97 // syncer::SyncChangeProcessor implementation.
98 virtual syncer::SyncError ProcessSyncChanges( 98 syncer::SyncError ProcessSyncChanges(
99 const tracked_objects::Location& from_here, 99 const tracked_objects::Location& from_here,
100 const syncer::SyncChangeList& change_list) override { 100 const syncer::SyncChangeList& change_list) override {
101 if (fail_all_requests_) { 101 if (fail_all_requests_) {
102 return syncer::SyncError( 102 return syncer::SyncError(
103 FROM_HERE, 103 FROM_HERE,
104 syncer::SyncError::DATATYPE_ERROR, 104 syncer::SyncError::DATATYPE_ERROR,
105 "MockSyncChangeProcessor: configured to fail", 105 "MockSyncChangeProcessor: configured to fail",
106 change_list[0].sync_data().GetDataType()); 106 change_list[0].sync_data().GetDataType());
107 } 107 }
108 for (syncer::SyncChangeList::const_iterator it = change_list.begin(); 108 for (syncer::SyncChangeList::const_iterator it = change_list.begin();
109 it != change_list.end(); ++it) { 109 it != change_list.end(); ++it) {
110 changes_.push_back(SettingSyncData(*it)); 110 changes_.push_back(SettingSyncData(*it));
111 } 111 }
112 return syncer::SyncError(); 112 return syncer::SyncError();
113 } 113 }
114 114
115 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const 115 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override {
116 override {
117 return syncer::SyncDataList(); 116 return syncer::SyncDataList();
118 } 117 }
119 118
120 // Mock methods. 119 // Mock methods.
121 120
122 const SettingSyncDataList& changes() { return changes_; } 121 const SettingSyncDataList& changes() { return changes_; }
123 122
124 void ClearChanges() { 123 void ClearChanges() {
125 changes_.clear(); 124 changes_.clear();
126 } 125 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // SettingsStorageFactory which always returns TestingValueStore objects, 163 // SettingsStorageFactory which always returns TestingValueStore objects,
165 // and allows individually created objects to be returned. 164 // and allows individually created objects to be returned.
166 class TestingValueStoreFactory : public SettingsStorageFactory { 165 class TestingValueStoreFactory : public SettingsStorageFactory {
167 public: 166 public:
168 TestingValueStore* GetExisting(const std::string& extension_id) { 167 TestingValueStore* GetExisting(const std::string& extension_id) {
169 DCHECK(created_.count(extension_id)); 168 DCHECK(created_.count(extension_id));
170 return created_[extension_id]; 169 return created_[extension_id];
171 } 170 }
172 171
173 // SettingsStorageFactory implementation. 172 // SettingsStorageFactory implementation.
174 virtual ValueStore* Create(const base::FilePath& base_path, 173 ValueStore* Create(const base::FilePath& base_path,
175 const std::string& extension_id) override { 174 const std::string& extension_id) override {
176 TestingValueStore* new_storage = new TestingValueStore(); 175 TestingValueStore* new_storage = new TestingValueStore();
177 DCHECK(!created_.count(extension_id)); 176 DCHECK(!created_.count(extension_id));
178 created_[extension_id] = new_storage; 177 created_[extension_id] = new_storage;
179 return new_storage; 178 return new_storage;
180 } 179 }
181 180
182 // Testing value stores don't actually create a real database. Don't delete 181 // Testing value stores don't actually create a real database. Don't delete
183 // any files. 182 // any files.
184 virtual void DeleteDatabaseIfExists( 183 void DeleteDatabaseIfExists(const base::FilePath& base_path,
185 const base::FilePath& base_path, 184 const std::string& extension_id) override {}
186 const std::string& extension_id) override {}
187 185
188 private: 186 private:
189 // SettingsStorageFactory is refcounted. 187 // SettingsStorageFactory is refcounted.
190 virtual ~TestingValueStoreFactory() {} 188 ~TestingValueStoreFactory() override {}
191 189
192 // None of these storage areas are owned by this factory, so care must be 190 // None of these storage areas are owned by this factory, so care must be
193 // taken when calling GetExisting. 191 // taken when calling GetExisting.
194 std::map<std::string, TestingValueStore*> created_; 192 std::map<std::string, TestingValueStore*> created_;
195 }; 193 };
196 194
197 } // namespace 195 } // namespace
198 196
199 class ExtensionSettingsSyncTest : public testing::Test { 197 class ExtensionSettingsSyncTest : public testing::Test {
200 public: 198 public:
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 settings_namespace::SYNC, 1501 settings_namespace::SYNC,
1504 base::Bind(&UnlimitedSyncStorageTestCallback)); 1502 base::Bind(&UnlimitedSyncStorageTestCallback));
1505 frontend_->RunWithStorage(extension, 1503 frontend_->RunWithStorage(extension,
1506 settings_namespace::LOCAL, 1504 settings_namespace::LOCAL,
1507 base::Bind(&UnlimitedLocalStorageTestCallback)); 1505 base::Bind(&UnlimitedLocalStorageTestCallback));
1508 1506
1509 base::MessageLoop::current()->RunUntilIdle(); 1507 base::MessageLoop::current()->RunUntilIdle();
1510 } 1508 }
1511 1509
1512 } // namespace extensions 1510 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698