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