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

Side by Side Diff: chrome/browser/sync/glue/generic_change_processor_unittest.cc

Issue 23129007: sync: Add GetAllSyncData to sync/api (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments 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/glue/generic_change_processor.h" 5 #include "chrome/browser/sync/glue/generic_change_processor.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 syncer::FakeSyncableService fake_syncable_service_; 86 syncer::FakeSyncableService fake_syncable_service_;
87 base::WeakPtrFactory<syncer::FakeSyncableService> 87 base::WeakPtrFactory<syncer::FakeSyncableService>
88 syncable_service_ptr_factory_; 88 syncable_service_ptr_factory_;
89 89
90 DataTypeErrorHandlerMock data_type_error_handler_; 90 DataTypeErrorHandlerMock data_type_error_handler_;
91 syncer::TestUserShare test_user_share_; 91 syncer::TestUserShare test_user_share_;
92 92
93 scoped_ptr<GenericChangeProcessor> change_processor_; 93 scoped_ptr<GenericChangeProcessor> change_processor_;
94 }; 94 };
95 95
96 // This test exercises GenericChangeProcessor's GetSyncDataForType function. 96 // Similar to above, but focused on the method that implements sync/api
97 // It's not a great test, but, by modifying some of the parameters, you could 97 // interfaces and is hence exposed to datatypes directly.
98 // turn it into a micro-benchmark for model association. 98 TEST_F(SyncGenericChangeProcessorTest, StressGetAllSyncData) {
99 TEST_F(SyncGenericChangeProcessorTest, StressGetSyncDataForType) {
100 const int kNumChildNodes = 1000; 99 const int kNumChildNodes = 1000;
101 const int kRepeatCount = 1; 100 const int kRepeatCount = 1;
102 101
103 ASSERT_NO_FATAL_FAILURE(BuildChildNodes(kNumChildNodes)); 102 ASSERT_NO_FATAL_FAILURE(BuildChildNodes(kNumChildNodes));
104 103
105 for (int i = 0; i < kRepeatCount; ++i) { 104 for (int i = 0; i < kRepeatCount; ++i) {
106 syncer::SyncDataList sync_data; 105 syncer::SyncDataList sync_data =
107 change_processor()->GetSyncDataForType(kType, &sync_data); 106 change_processor()->GetAllSyncData(kType);
108 107
109 // Start with a simple test. We can add more in-depth testing later. 108 // Start with a simple test. We can add more in-depth testing later.
110 EXPECT_EQ(static_cast<size_t>(kNumChildNodes), sync_data.size()); 109 EXPECT_EQ(static_cast<size_t>(kNumChildNodes), sync_data.size());
111 } 110 }
112 } 111 }
113 112
114 TEST_F(SyncGenericChangeProcessorTest, SetGetPasswords) { 113 TEST_F(SyncGenericChangeProcessorTest, SetGetPasswords) {
115 const int kNumPasswords = 10; 114 const int kNumPasswords = 10;
116 sync_pb::PasswordSpecificsData password_data; 115 sync_pb::PasswordSpecificsData password_data;
117 password_data.set_username_value("user"); 116 password_data.set_username_value("user");
(...skipping 11 matching lines...) Expand all
129 syncer::SyncChange::ACTION_ADD, 128 syncer::SyncChange::ACTION_ADD,
130 syncer::SyncData::CreateLocalData( 129 syncer::SyncData::CreateLocalData(
131 base::StringPrintf("tag%i", i), 130 base::StringPrintf("tag%i", i),
132 base::StringPrintf("title%i", i), 131 base::StringPrintf("title%i", i),
133 password_holder))); 132 password_holder)));
134 } 133 }
135 134
136 ASSERT_FALSE( 135 ASSERT_FALSE(
137 change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); 136 change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet());
138 137
139 syncer::SyncDataList password_list; 138 syncer::SyncDataList password_list(
140 ASSERT_FALSE( 139 change_processor()->GetAllSyncData(syncer::PASSWORDS));
141 change_processor()->GetSyncDataForType(syncer::PASSWORDS, &password_list).
142 IsSet());
143 140
144 ASSERT_EQ(password_list.size(), change_list.size()); 141 ASSERT_EQ(password_list.size(), change_list.size());
145 for (int i = 0; i < kNumPasswords; ++i) { 142 for (int i = 0; i < kNumPasswords; ++i) {
146 // Verify the password is returned properly. 143 // Verify the password is returned properly.
147 ASSERT_TRUE(password_list[i].GetSpecifics().has_password()); 144 ASSERT_TRUE(password_list[i].GetSpecifics().has_password());
148 ASSERT_TRUE(password_list[i].GetSpecifics().password(). 145 ASSERT_TRUE(password_list[i].GetSpecifics().password().
149 has_client_only_encrypted_data()); 146 has_client_only_encrypted_data());
150 ASSERT_FALSE(password_list[i].GetSpecifics().password().has_encrypted()); 147 ASSERT_FALSE(password_list[i].GetSpecifics().password().has_encrypted());
151 const sync_pb::PasswordSpecificsData& sync_password = 148 const sync_pb::PasswordSpecificsData& sync_password =
152 password_list[i].GetSpecifics().password().client_only_encrypted_data(); 149 password_list[i].GetSpecifics().password().client_only_encrypted_data();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 base::StringPrintf("tag%i", i), 199 base::StringPrintf("tag%i", i),
203 base::StringPrintf("title_m%i", i), 200 base::StringPrintf("title_m%i", i),
204 password_holder))); 201 password_holder)));
205 } 202 }
206 203
207 ASSERT_FALSE( 204 ASSERT_FALSE(
208 change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); 205 change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet());
209 ASSERT_FALSE( 206 ASSERT_FALSE(
210 change_processor()->ProcessSyncChanges(FROM_HERE, change_list2).IsSet()); 207 change_processor()->ProcessSyncChanges(FROM_HERE, change_list2).IsSet());
211 208
212 syncer::SyncDataList password_list; 209 syncer::SyncDataList password_list(
213 ASSERT_FALSE( 210 change_processor()->GetAllSyncData(syncer::PASSWORDS));
214 change_processor()->GetSyncDataForType(syncer::PASSWORDS, &password_list).
215 IsSet());
216 211
217 ASSERT_EQ(password_list.size(), change_list2.size()); 212 ASSERT_EQ(password_list.size(), change_list2.size());
218 for (int i = 0; i < kNumPasswords; ++i) { 213 for (int i = 0; i < kNumPasswords; ++i) {
219 // Verify the password is returned properly. 214 // Verify the password is returned properly.
220 ASSERT_TRUE(password_list[i].GetSpecifics().has_password()); 215 ASSERT_TRUE(password_list[i].GetSpecifics().has_password());
221 ASSERT_TRUE(password_list[i].GetSpecifics().password(). 216 ASSERT_TRUE(password_list[i].GetSpecifics().password().
222 has_client_only_encrypted_data()); 217 has_client_only_encrypted_data());
223 ASSERT_FALSE(password_list[i].GetSpecifics().password().has_encrypted()); 218 ASSERT_FALSE(password_list[i].GetSpecifics().password().has_encrypted());
224 const sync_pb::PasswordSpecificsData& sync_password = 219 const sync_pb::PasswordSpecificsData& sync_password =
225 password_list[i].GetSpecifics().password().client_only_encrypted_data(); 220 password_list[i].GetSpecifics().password().client_only_encrypted_data();
(...skipping 14 matching lines...) Expand all
240 ASSERT_TRUE(raw_specifics.has_password()); 235 ASSERT_TRUE(raw_specifics.has_password());
241 ASSERT_TRUE(raw_specifics.password().has_encrypted()); 236 ASSERT_TRUE(raw_specifics.password().has_encrypted());
242 ASSERT_FALSE(raw_specifics.password().has_client_only_encrypted_data()); 237 ASSERT_FALSE(raw_specifics.password().has_client_only_encrypted_data());
243 } 238 }
244 } 239 }
245 240
246 } // namespace 241 } // namespace
247 242
248 } // namespace browser_sync 243 } // namespace browser_sync
249 244
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/generic_change_processor.cc ('k') | chrome/browser/sync/glue/non_ui_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698