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

Side by Side Diff: components/autofill/browser/personal_data_manager_unittest.cc

Issue 16092013: Use base::MessageLoop in more files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again, sigh Created 7 years, 6 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 (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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 "John Dillinger", "423456789012" /* Visa */, "01", "2010"); 295 "John Dillinger", "423456789012" /* Visa */, "01", "2010");
296 EXPECT_FALSE(credit_card.IsVerified()); 296 EXPECT_FALSE(credit_card.IsVerified());
297 297
298 // Add the data to the database. 298 // Add the data to the database.
299 personal_data_->AddProfile(profile); 299 personal_data_->AddProfile(profile);
300 personal_data_->AddCreditCard(credit_card); 300 personal_data_->AddCreditCard(credit_card);
301 301
302 // Verify that the web database has been updated and the notification sent. 302 // Verify that the web database has been updated and the notification sent.
303 EXPECT_CALL(personal_data_observer_, 303 EXPECT_CALL(personal_data_observer_,
304 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 304 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
305 MessageLoop::current()->Run(); 305 base::MessageLoop::current()->Run();
306 306
307 const std::vector<AutofillProfile*>& profiles1 = 307 const std::vector<AutofillProfile*>& profiles1 =
308 personal_data_->GetProfiles(); 308 personal_data_->GetProfiles();
309 const std::vector<CreditCard*>& cards1 = personal_data_->GetCreditCards(); 309 const std::vector<CreditCard*>& cards1 = personal_data_->GetCreditCards();
310 ASSERT_EQ(1U, profiles1.size()); 310 ASSERT_EQ(1U, profiles1.size());
311 ASSERT_EQ(1U, cards1.size()); 311 ASSERT_EQ(1U, cards1.size());
312 EXPECT_EQ(0, profile.Compare(*profiles1[0])); 312 EXPECT_EQ(0, profile.Compare(*profiles1[0]));
313 EXPECT_EQ(0, credit_card.Compare(*cards1[0])); 313 EXPECT_EQ(0, credit_card.Compare(*cards1[0]));
314 314
315 // Try to update with just the origin changed. 315 // Try to update with just the origin changed.
(...skipping 23 matching lines...) Expand all
339 // Try to update with data changed as well. 339 // Try to update with data changed as well.
340 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); 340 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
341 credit_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Joe")); 341 credit_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Joe"));
342 342
343 personal_data_->UpdateProfile(profile); 343 personal_data_->UpdateProfile(profile);
344 personal_data_->UpdateCreditCard(credit_card); 344 personal_data_->UpdateCreditCard(credit_card);
345 345
346 // Verify that the web database has been updated and the notification sent. 346 // Verify that the web database has been updated and the notification sent.
347 EXPECT_CALL(personal_data_observer_, 347 EXPECT_CALL(personal_data_observer_,
348 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 348 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
349 MessageLoop::current()->Run(); 349 base::MessageLoop::current()->Run();
350 350
351 const std::vector<AutofillProfile*>& profiles3 = 351 const std::vector<AutofillProfile*>& profiles3 =
352 personal_data_->GetProfiles(); 352 personal_data_->GetProfiles();
353 const std::vector<CreditCard*>& cards3 = personal_data_->GetCreditCards(); 353 const std::vector<CreditCard*>& cards3 = personal_data_->GetCreditCards();
354 ASSERT_EQ(1U, profiles3.size()); 354 ASSERT_EQ(1U, profiles3.size());
355 ASSERT_EQ(1U, cards3.size()); 355 ASSERT_EQ(1U, cards3.size());
356 EXPECT_EQ(0, profile.Compare(*profiles3[0])); 356 EXPECT_EQ(0, profile.Compare(*profiles3[0]));
357 EXPECT_EQ(0, credit_card.Compare(*cards3[0])); 357 EXPECT_EQ(0, credit_card.Compare(*cards3[0]));
358 EXPECT_EQ(profile.origin(), profiles3[0]->origin()); 358 EXPECT_EQ(profile.origin(), profiles3[0]->origin());
359 EXPECT_EQ(credit_card.origin(), cards3[0]->origin()); 359 EXPECT_EQ(credit_card.origin(), cards3[0]->origin());
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", 1922 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA",
1923 "91601", "US", "12345678910"); 1923 "91601", "US", "12345678910");
1924 EXPECT_TRUE(profile.IsVerified()); 1924 EXPECT_TRUE(profile.IsVerified());
1925 1925
1926 // Add the profile to the database. 1926 // Add the profile to the database.
1927 personal_data_->AddProfile(profile); 1927 personal_data_->AddProfile(profile);
1928 1928
1929 // Verify that the web database has been updated and the notification sent. 1929 // Verify that the web database has been updated and the notification sent.
1930 EXPECT_CALL(personal_data_observer_, 1930 EXPECT_CALL(personal_data_observer_,
1931 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 1931 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
1932 MessageLoop::current()->Run(); 1932 base::MessageLoop::current()->Run();
1933 1933
1934 // Simulate a form submission with conflicting info. 1934 // Simulate a form submission with conflicting info.
1935 FormData form; 1935 FormData form;
1936 FormFieldData field; 1936 FormFieldData field;
1937 test::CreateTestFormField( 1937 test::CreateTestFormField(
1938 "First name:", "first_name", "Marion", "text", &field); 1938 "First name:", "first_name", "Marion", "text", &field);
1939 form.fields.push_back(field); 1939 form.fields.push_back(field);
1940 test::CreateTestFormField( 1940 test::CreateTestFormField(
1941 "Last name:", "last_name", "Morrison", "text", &field); 1941 "Last name:", "last_name", "Morrison", "text", &field);
1942 form.fields.push_back(field); 1942 form.fields.push_back(field);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 test::SetCreditCardInfo(&credit_card, 1980 test::SetCreditCardInfo(&credit_card,
1981 "Biggie Smalls", "4111 1111 1111 1111" /* Visa */, "01", "2011"); 1981 "Biggie Smalls", "4111 1111 1111 1111" /* Visa */, "01", "2011");
1982 EXPECT_TRUE(credit_card.IsVerified()); 1982 EXPECT_TRUE(credit_card.IsVerified());
1983 1983
1984 // Add the credit card to the database. 1984 // Add the credit card to the database.
1985 personal_data_->AddCreditCard(credit_card); 1985 personal_data_->AddCreditCard(credit_card);
1986 1986
1987 // Verify that the web database has been updated and the notification sent. 1987 // Verify that the web database has been updated and the notification sent.
1988 EXPECT_CALL(personal_data_observer_, 1988 EXPECT_CALL(personal_data_observer_,
1989 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 1989 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
1990 MessageLoop::current()->Run(); 1990 base::MessageLoop::current()->Run();
1991 1991
1992 // Simulate a form submission with conflicting expiration year. 1992 // Simulate a form submission with conflicting expiration year.
1993 FormData form; 1993 FormData form;
1994 FormFieldData field; 1994 FormFieldData field;
1995 test::CreateTestFormField( 1995 test::CreateTestFormField(
1996 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); 1996 "Name on card:", "name_on_card", "Biggie Smalls", "text", &field);
1997 form.fields.push_back(field); 1997 form.fields.push_back(field);
1998 test::CreateTestFormField( 1998 test::CreateTestFormField(
1999 "Card Number:", "card_number", "4111 1111 1111 1111", "text", &field); 1999 "Card Number:", "card_number", "4111 1111 1111 1111", "text", &field);
2000 form.fields.push_back(field); 2000 form.fields.push_back(field);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 // Removing shouldn't work. 2298 // Removing shouldn't work.
2299 personal_data_->RemoveByGUID(steve_jobs.guid()); 2299 personal_data_->RemoveByGUID(steve_jobs.guid());
2300 personal_data_->RemoveByGUID(bill_gates.guid()); 2300 personal_data_->RemoveByGUID(bill_gates.guid());
2301 2301
2302 ResetPersonalDataManager(); 2302 ResetPersonalDataManager();
2303 EXPECT_EQ(1U, personal_data_->GetProfiles().size()); 2303 EXPECT_EQ(1U, personal_data_->GetProfiles().size());
2304 EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); 2304 EXPECT_EQ(1U, personal_data_->GetCreditCards().size());
2305 } 2305 }
2306 2306
2307 } // namespace autofill 2307 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/pyautolib/pyautolib.cc ('k') | components/webdata/common/web_data_request_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698