OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void(const AutofillChangeList& changes)); | 89 void(const AutofillChangeList& changes)); |
90 MOCK_METHOD1(AutofillProfileChanged, | 90 MOCK_METHOD1(AutofillProfileChanged, |
91 void(const AutofillProfileChange& change)); | 91 void(const AutofillProfileChange& change)); |
92 }; | 92 }; |
93 | 93 |
94 class WebDataServiceTest : public testing::Test { | 94 class WebDataServiceTest : public testing::Test { |
95 public: | 95 public: |
96 WebDataServiceTest() : db_thread_("DBThread") {} | 96 WebDataServiceTest() : db_thread_("DBThread") {} |
97 | 97 |
98 protected: | 98 protected: |
99 virtual void SetUp() { | 99 void SetUp() override { |
100 db_thread_.Start(); | 100 db_thread_.Start(); |
101 | 101 |
102 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 102 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
103 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); | 103 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); |
104 | 104 |
105 wdbs_ = new WebDatabaseService(path, | 105 wdbs_ = new WebDatabaseService(path, |
106 base::MessageLoopProxy::current(), | 106 base::MessageLoopProxy::current(), |
107 db_thread_.message_loop_proxy()); | 107 db_thread_.message_loop_proxy()); |
108 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable("en-US"))); | 108 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new AutofillTable("en-US"))); |
109 wdbs_->LoadDatabase(); | 109 wdbs_->LoadDatabase(); |
110 | 110 |
111 wds_ = | 111 wds_ = |
112 new AutofillWebDataService(wdbs_, | 112 new AutofillWebDataService(wdbs_, |
113 base::MessageLoopProxy::current(), | 113 base::MessageLoopProxy::current(), |
114 db_thread_.message_loop_proxy(), | 114 db_thread_.message_loop_proxy(), |
115 WebDataServiceBase::ProfileErrorCallback()); | 115 WebDataServiceBase::ProfileErrorCallback()); |
116 wds_->Init(); | 116 wds_->Init(); |
117 } | 117 } |
118 | 118 |
119 virtual void TearDown() { | 119 void TearDown() override { |
120 wds_->ShutdownOnUIThread(); | 120 wds_->ShutdownOnUIThread(); |
121 wdbs_->ShutdownDatabase(); | 121 wdbs_->ShutdownDatabase(); |
122 wds_ = NULL; | 122 wds_ = NULL; |
123 wdbs_ = NULL; | 123 wdbs_ = NULL; |
124 WaitForDatabaseThread(); | 124 WaitForDatabaseThread(); |
125 | 125 |
126 base::MessageLoop::current()->PostTask(FROM_HERE, | 126 base::MessageLoop::current()->PostTask(FROM_HERE, |
127 base::MessageLoop::QuitClosure()); | 127 base::MessageLoop::QuitClosure()); |
128 base::MessageLoop::current()->Run(); | 128 base::MessageLoop::current()->Run(); |
129 db_thread_.Stop(); | 129 db_thread_.Stop(); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 536 |
537 // Check that the credit card was removed. | 537 // Check that the credit card was removed. |
538 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; | 538 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; |
539 handle2 = wds_->GetCreditCards(&card_consumer2); | 539 handle2 = wds_->GetCreditCards(&card_consumer2); |
540 base::MessageLoop::current()->Run(); | 540 base::MessageLoop::current()->Run(); |
541 EXPECT_EQ(handle2, card_consumer2.handle()); | 541 EXPECT_EQ(handle2, card_consumer2.handle()); |
542 ASSERT_EQ(0U, card_consumer2.result().size()); | 542 ASSERT_EQ(0U, card_consumer2.result().size()); |
543 } | 543 } |
544 | 544 |
545 } // namespace autofill | 545 } // namespace autofill |
OLD | NEW |