OLD | NEW |
---|---|
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/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/password_manager/encryptor.h" | 13 #include "chrome/browser/password_manager/encryptor.h" |
13 #include "chrome/browser/webdata/web_data_service.h" | 14 #include "chrome/browser/webdata/web_data_service.h" |
14 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "components/autofill/browser/autofill_common_test.h" | 17 #include "components/autofill/browser/autofill_common_test.h" |
17 #include "components/autofill/browser/autofill_metrics.h" | 18 #include "components/autofill/browser/autofill_metrics.h" |
18 #include "components/autofill/browser/autofill_profile.h" | 19 #include "components/autofill/browser/autofill_profile.h" |
19 #include "components/autofill/browser/form_structure.h" | 20 #include "components/autofill/browser/form_structure.h" |
20 #include "components/autofill/browser/personal_data_manager.h" | 21 #include "components/autofill/browser/personal_data_manager.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 profile_->CreateWebDataService(); | 72 profile_->CreateWebDataService(); |
72 | 73 |
73 autofill_test::DisableSystemServices(profile_.get()); | 74 autofill_test::DisableSystemServices(profile_.get()); |
74 ResetPersonalDataManager(); | 75 ResetPersonalDataManager(); |
75 } | 76 } |
76 | 77 |
77 virtual void TearDown() { | 78 virtual void TearDown() { |
78 // Destruction order is imposed explicitly here. | 79 // Destruction order is imposed explicitly here. |
79 personal_data_.reset(NULL); | 80 personal_data_.reset(NULL); |
80 profile_.reset(NULL); | 81 profile_.reset(NULL); |
81 | 82 base::WaitableEvent done(false, false); |
Jói
2013/03/20 16:18:42
Is the point of these 4 lines just to make sure to
Cait (Slow)
2013/03/20 16:49:02
Done.
| |
82 db_thread_.Stop(); | 83 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
84 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | |
85 done.Wait(); | |
83 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 86 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
84 MessageLoop::current()->Run(); | 87 MessageLoop::current()->Run(); |
88 db_thread_.Stop(); | |
85 } | 89 } |
86 | 90 |
87 void ResetPersonalDataManager() { | 91 void ResetPersonalDataManager() { |
88 personal_data_.reset(new PersonalDataManager); | 92 personal_data_.reset(new PersonalDataManager); |
89 personal_data_->Init(profile_.get()); | 93 personal_data_->Init(profile_.get()); |
90 personal_data_->AddObserver(&personal_data_observer_); | 94 personal_data_->AddObserver(&personal_data_observer_); |
91 | 95 |
92 // Verify that the web database has been updated and the notification sent. | 96 // Verify that the web database has been updated and the notification sent. |
93 EXPECT_CALL(personal_data_observer_, | 97 EXPECT_CALL(personal_data_observer_, |
94 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 98 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1964 | 1968 |
1965 // Modify expected to include multi-valued fields. | 1969 // Modify expected to include multi-valued fields. |
1966 std::vector<string16> values; | 1970 std::vector<string16> values; |
1967 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 1971 expected.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
1968 values.push_back(ASCIIToUTF16("(214) 555-1234")); | 1972 values.push_back(ASCIIToUTF16("(214) 555-1234")); |
1969 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); | 1973 expected.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, values); |
1970 | 1974 |
1971 ASSERT_EQ(1U, results2.size()); | 1975 ASSERT_EQ(1U, results2.size()); |
1972 EXPECT_EQ(0, expected.Compare(*results2[0])); | 1976 EXPECT_EQ(0, expected.Compare(*results2[0])); |
1973 } | 1977 } |
OLD | NEW |