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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 WebDataServiceTest() | 70 WebDataServiceTest() |
71 : ui_thread_(BrowserThread::UI, &message_loop_), | 71 : ui_thread_(BrowserThread::UI, &message_loop_), |
72 db_thread_(BrowserThread::DB) {} | 72 db_thread_(BrowserThread::DB) {} |
73 | 73 |
74 protected: | 74 protected: |
75 virtual void SetUp() { | 75 virtual void SetUp() { |
76 db_thread_.Start(); | 76 db_thread_.Start(); |
77 | 77 |
78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
79 wds_ = new WebDataService(); | 79 wds_ = new WebDataService(); |
80 wds_->Init(temp_dir_.path()); | 80 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); |
| 81 wds_->Init(path); |
81 } | 82 } |
82 | 83 |
83 virtual void TearDown() { | 84 virtual void TearDown() { |
84 wds_->ShutdownOnUIThread(); | 85 wds_->ShutdownOnUIThread(); |
85 wds_ = NULL; | 86 wds_ = NULL; |
86 WaitForDatabaseThread(); | 87 WaitForDatabaseThread(); |
87 | 88 |
88 db_thread_.Stop(); | |
89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
90 MessageLoop::current()->Run(); | 90 MessageLoop::current()->Run(); |
| 91 db_thread_.Stop(); |
91 } | 92 } |
92 | 93 |
93 void WaitForDatabaseThread() { | 94 void WaitForDatabaseThread() { |
94 base::WaitableEvent done(false, false); | 95 base::WaitableEvent done(false, false); |
95 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
96 BrowserThread::DB, | 97 BrowserThread::DB, |
97 FROM_HERE, | 98 FROM_HERE, |
98 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 99 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
99 done.Wait(); | 100 done.Wait(); |
100 } | 101 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 EXPECT_EQ(handle2, profile_consumer2.handle()); | 540 EXPECT_EQ(handle2, profile_consumer2.handle()); |
540 ASSERT_EQ(0U, profile_consumer2.result().size()); | 541 ASSERT_EQ(0U, profile_consumer2.result().size()); |
541 | 542 |
542 // Check that the credit card was removed. | 543 // Check that the credit card was removed. |
543 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; | 544 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; |
544 handle2 = wds_->GetCreditCards(&card_consumer2); | 545 handle2 = wds_->GetCreditCards(&card_consumer2); |
545 MessageLoop::current()->Run(); | 546 MessageLoop::current()->Run(); |
546 EXPECT_EQ(handle2, card_consumer2.handle()); | 547 EXPECT_EQ(handle2, card_consumer2.handle()); |
547 ASSERT_EQ(0U, card_consumer2.result().size()); | 548 ASSERT_EQ(0U, card_consumer2.result().size()); |
548 } | 549 } |
OLD | NEW |