OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 update_cc.push_back(creditcard0); | 272 update_cc.push_back(creditcard0); |
273 update_cc.push_back(creditcard1); | 273 update_cc.push_back(creditcard1); |
274 personal_data_->SetCreditCards(&update_cc); | 274 personal_data_->SetCreditCards(&update_cc); |
275 | 275 |
276 | 276 |
277 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 277 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
278 ASSERT_EQ(2U, results2.size()); | 278 ASSERT_EQ(2U, results2.size()); |
279 EXPECT_EQ(creditcard0, *results2.at(0)); | 279 EXPECT_EQ(creditcard0, *results2.at(0)); |
280 EXPECT_EQ(creditcard1, *results2.at(1)); | 280 EXPECT_EQ(creditcard1, *results2.at(1)); |
281 | 281 |
| 282 // The message loop will exit when the mock observer is notified. |
| 283 MessageLoop::current()->Run(); |
| 284 |
282 // Determine uniqueness by inserting all of the GUIDs into a set and verifying | 285 // Determine uniqueness by inserting all of the GUIDs into a set and verifying |
283 // the size of the set matches the number of GUIDs. | 286 // the size of the set matches the number of GUIDs. |
284 std::set<std::string> guids; | 287 std::set<std::string> guids; |
285 guids.insert(profile0.guid()); | 288 guids.insert(profile0.guid()); |
286 guids.insert(profile1.guid()); | 289 guids.insert(profile1.guid()); |
287 guids.insert(creditcard0.guid()); | 290 guids.insert(creditcard0.guid()); |
288 guids.insert(creditcard1.guid()); | 291 guids.insert(creditcard1.guid()); |
289 EXPECT_EQ(4U, guids.size()); | 292 EXPECT_EQ(4U, guids.size()); |
290 } | 293 } |
291 | 294 |
(...skipping 23 matching lines...) Expand all Loading... |
315 | 318 |
316 // The message loop will exit when the PersonalDataLoadedObserver is notified. | 319 // The message loop will exit when the PersonalDataLoadedObserver is notified. |
317 MessageLoop::current()->Run(); | 320 MessageLoop::current()->Run(); |
318 | 321 |
319 // Verify that we've loaded the profiles from the web database. | 322 // Verify that we've loaded the profiles from the web database. |
320 const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles(); | 323 const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles(); |
321 ASSERT_EQ(1U, results2.size()); | 324 ASSERT_EQ(1U, results2.size()); |
322 | 325 |
323 // Add a new profile. | 326 // Add a new profile. |
324 AutoFillProfile profile1; | 327 AutoFillProfile profile1; |
| 328 // Need to be different from results2[0] by contents or it will be dropped. |
325 autofill_test::SetProfileInfo(&profile1, | 329 autofill_test::SetProfileInfo(&profile1, |
326 "", "y", "", "", "", "", "", "", "", "", "", "", "", ""); | 330 "", "y", "1", "", "", "", "", "", "", "", "", "", "", ""); |
327 update.clear(); | 331 update.clear(); |
328 update.push_back(*results2[0]); | 332 update.push_back(*results2[0]); |
329 update.push_back(profile1); | 333 update.push_back(profile1); |
330 personal_data_->SetProfiles(&update); | 334 personal_data_->SetProfiles(&update); |
331 | 335 |
| 336 // The message loop will exit when the PersonalDataLoadedObserver is notified. |
| 337 MessageLoop::current()->Run(); |
| 338 |
332 // Make sure the two profiles have different ids (and neither equal to 0, | 339 // Make sure the two profiles have different ids (and neither equal to 0, |
333 // which is an invalid id). | 340 // which is an invalid id). |
334 const std::vector<AutoFillProfile*>& results3 = personal_data_->profiles(); | 341 const std::vector<AutoFillProfile*>& results3 = personal_data_->profiles(); |
335 ASSERT_EQ(2U, results3.size()); | 342 ASSERT_EQ(2U, results3.size()); |
336 EXPECT_NE(results3[0]->guid(), results3[1]->guid()); | 343 EXPECT_NE(results3[0]->guid(), results3[1]->guid()); |
337 EXPECT_TRUE(guid::IsValidGUID(results3[0]->guid())); | 344 EXPECT_TRUE(guid::IsValidGUID(results3[0]->guid())); |
338 EXPECT_TRUE(guid::IsValidGUID(results3[1]->guid())); | 345 EXPECT_TRUE(guid::IsValidGUID(results3[1]->guid())); |
339 } | 346 } |
340 | 347 |
341 TEST_F(PersonalDataManagerTest, SetEmptyProfile) { | 348 TEST_F(PersonalDataManagerTest, SetEmptyProfile) { |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 | 1387 |
1381 // Expect that the newer information is saved. In this case the year is | 1388 // Expect that the newer information is saved. In this case the year is |
1382 // added to the existing credit card. | 1389 // added to the existing credit card. |
1383 CreditCard expected2; | 1390 CreditCard expected2; |
1384 autofill_test::SetCreditCardInfo(&expected2, | 1391 autofill_test::SetCreditCardInfo(&expected2, |
1385 "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); | 1392 "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); |
1386 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 1393 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
1387 ASSERT_EQ(1U, results2.size()); | 1394 ASSERT_EQ(1U, results2.size()); |
1388 EXPECT_EQ(0, expected2.Compare(*results2[0])); | 1395 EXPECT_EQ(0, expected2.Compare(*results2[0])); |
1389 } | 1396 } |
| 1397 |
OLD | NEW |