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

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

Issue 13928035: WIP Component build of autofill Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make windows compiling Created 7 years, 8 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"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/webdata/web_data_service_factory.h"
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
15 #include "components/autofill/browser/autofill_common_test.h" 16 #include "components/autofill/browser/autofill_common_test.h"
16 #include "components/autofill/browser/autofill_metrics.h" 17 #include "components/autofill/browser/autofill_metrics.h"
17 #include "components/autofill/browser/autofill_profile.h" 18 #include "components/autofill/browser/autofill_profile.h"
18 #include "components/autofill/browser/form_structure.h" 19 #include "components/autofill/browser/form_structure.h"
19 #include "components/autofill/browser/personal_data_manager.h" 20 #include "components/autofill/browser/personal_data_manager.h"
20 #include "components/autofill/browser/personal_data_manager_observer.h" 21 #include "components/autofill/browser/personal_data_manager_observer.h"
21 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 22 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
22 #include "components/autofill/common/form_data.h" 23 #include "components/autofill/common/form_data.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 88 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
88 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); 89 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
89 done.Wait(); 90 done.Wait();
90 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 91 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
91 MessageLoop::current()->Run(); 92 MessageLoop::current()->Run();
92 db_thread_.Stop(); 93 db_thread_.Stop();
93 } 94 }
94 95
95 void ResetPersonalDataManager() { 96 void ResetPersonalDataManager() {
96 personal_data_.reset(new PersonalDataManager("en-US")); 97 personal_data_.reset(new PersonalDataManager("en-US"));
97 personal_data_->Init(profile_.get()); 98 personal_data_->Init(
99 profile_.get(),
100 WebDataServiceFactory::GetAutofillWebDataServiceForProfile(
101 profile_.get()));
98 personal_data_->AddObserver(&personal_data_observer_); 102 personal_data_->AddObserver(&personal_data_observer_);
99 103
100 // Verify that the web database has been updated and the notification sent. 104 // Verify that the web database has been updated and the notification sent.
101 EXPECT_CALL(personal_data_observer_, 105 EXPECT_CALL(personal_data_observer_,
102 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 106 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
103 MessageLoop::current()->Run(); 107 MessageLoop::current()->Run();
104 } 108 }
105 109
106 MessageLoopForUI message_loop_; 110 MessageLoopForUI message_loop_;
107 content::TestBrowserThread ui_thread_; 111 content::TestBrowserThread ui_thread_;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 test::SetProfileInfo(&profile2, 458 test::SetProfileInfo(&profile2,
455 "Josephine", "Alicia", "Saenz", 459 "Josephine", "Alicia", "Saenz",
456 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", 460 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL",
457 "32801", "US", "19482937549"); 461 "32801", "US", "19482937549");
458 462
459 // Adjust all labels. 463 // Adjust all labels.
460 profile_pointers.push_back(&profile2); 464 profile_pointers.push_back(&profile2);
461 AutofillProfile::AdjustInferredLabels(&profile_pointers); 465 AutofillProfile::AdjustInferredLabels(&profile_pointers);
462 466
463 scoped_refptr<AutofillWebDataService> wds = 467 scoped_refptr<AutofillWebDataService> wds =
464 AutofillWebDataService::FromBrowserContext(profile_.get()); 468 WebDataServiceFactory::GetAutofillWebDataServiceForProfile(
469 profile_.get());
465 ASSERT_TRUE(wds.get()); 470 ASSERT_TRUE(wds.get());
466 wds->AddAutofillProfile(profile2); 471 wds->AddAutofillProfile(profile2);
467 472
468 personal_data_->Refresh(); 473 personal_data_->Refresh();
469 474
470 // Verify that the web database has been updated and the notification sent. 475 // Verify that the web database has been updated and the notification sent.
471 EXPECT_CALL(personal_data_observer_, 476 EXPECT_CALL(personal_data_observer_,
472 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); 477 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop());
473 MessageLoop::current()->Run(); 478 MessageLoop::current()->Run();
474 479
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 std::vector<base::string16> values; 2038 std::vector<base::string16> values;
2034 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); 2039 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
2035 values.push_back(ASCIIToUTF16("(214) 555-1234")); 2040 values.push_back(ASCIIToUTF16("(214) 555-1234"));
2036 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); 2041 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
2037 2042
2038 ASSERT_EQ(1U, results2.size()); 2043 ASSERT_EQ(1U, results2.size());
2039 EXPECT_EQ(0, expected.Compare(*results2[0])); 2044 EXPECT_EQ(0, expected.Compare(*results2[0]));
2040 } 2045 }
2041 2046
2042 } // namespace autofill 2047 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698