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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/webdata/autofill_change.h" | 20 #include "chrome/browser/webdata/autofill_change.h" |
21 #include "chrome/browser/webdata/autofill_entry.h" | 21 #include "chrome/browser/webdata/autofill_entry.h" |
| 22 #include "chrome/browser/webdata/autofill_table.h" |
22 #include "chrome/browser/webdata/web_data_service.h" | 23 #include "chrome/browser/webdata/web_data_service.h" |
23 #include "chrome/browser/webdata/web_data_service_test_util.h" | 24 #include "chrome/browser/webdata/web_data_service_test_util.h" |
24 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
26 #include "chrome/test/base/thread_observer_helper.h" | 27 #include "chrome/test/base/thread_observer_helper.h" |
27 #include "components/autofill/browser/autofill_profile.h" | 28 #include "components/autofill/browser/autofill_profile.h" |
28 #include "components/autofill/browser/credit_card.h" | 29 #include "components/autofill/browser/credit_card.h" |
29 #include "components/autofill/common/form_field_data.h" | 30 #include "components/autofill/common/form_field_data.h" |
30 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 public: | 70 public: |
70 WebDataServiceTest() | 71 WebDataServiceTest() |
71 : ui_thread_(BrowserThread::UI, &message_loop_), | 72 : ui_thread_(BrowserThread::UI, &message_loop_), |
72 db_thread_(BrowserThread::DB) {} | 73 db_thread_(BrowserThread::DB) {} |
73 | 74 |
74 protected: | 75 protected: |
75 virtual void SetUp() { | 76 virtual void SetUp() { |
76 db_thread_.Start(); | 77 db_thread_.Start(); |
77 | 78 |
78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 79 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
79 wds_ = new WebDataService(WebDataServiceBase::ProfileErrorCallback()); | |
80 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); | 80 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); |
81 wds_->Init(path); | 81 wds_ = new WebDataService(path, WebDataServiceBase::ProfileErrorCallback()); |
| 82 // Need to add at least one table so the database gets created. |
| 83 wds_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable).Pass()); |
| 84 wds_->Init(); |
82 } | 85 } |
83 | 86 |
84 virtual void TearDown() { | 87 virtual void TearDown() { |
85 wds_->ShutdownOnUIThread(); | 88 wds_->ShutdownOnUIThread(); |
86 wds_ = NULL; | 89 wds_ = NULL; |
87 WaitForDatabaseThread(); | 90 WaitForDatabaseThread(); |
88 | 91 |
89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 92 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
90 MessageLoop::current()->Run(); | 93 MessageLoop::current()->Run(); |
91 db_thread_.Stop(); | 94 db_thread_.Stop(); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 EXPECT_EQ(handle2, profile_consumer2.handle()); | 543 EXPECT_EQ(handle2, profile_consumer2.handle()); |
541 ASSERT_EQ(0U, profile_consumer2.result().size()); | 544 ASSERT_EQ(0U, profile_consumer2.result().size()); |
542 | 545 |
543 // Check that the credit card was removed. | 546 // Check that the credit card was removed. |
544 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; | 547 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; |
545 handle2 = wds_->GetCreditCards(&card_consumer2); | 548 handle2 = wds_->GetCreditCards(&card_consumer2); |
546 MessageLoop::current()->Run(); | 549 MessageLoop::current()->Run(); |
547 EXPECT_EQ(handle2, card_consumer2.handle()); | 550 EXPECT_EQ(handle2, card_consumer2.handle()); |
548 ASSERT_EQ(0U, card_consumer2.result().size()); | 551 ASSERT_EQ(0U, card_consumer2.result().size()); |
549 } | 552 } |
OLD | NEW |