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 <windows.h> | 5 #include <windows.h> |
6 #include <wincrypt.h> | 6 #include <wincrypt.h> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_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 "chrome/browser/password_manager/ie7_password.h" | 19 #include "chrome/browser/password_manager/ie7_password.h" |
20 #include "chrome/browser/password_manager/password_form_data.h" | 20 #include "chrome/browser/password_manager/password_form_data.h" |
21 #include "chrome/browser/password_manager/password_store_consumer.h" | 21 #include "chrome/browser/password_manager/password_store_consumer.h" |
22 #include "chrome/browser/password_manager/password_store_win.h" | 22 #include "chrome/browser/password_manager/password_store_win.h" |
23 #include "chrome/browser/webdata/logins_table.h" | 23 #include "chrome/browser/webdata/logins_table.h" |
24 #include "chrome/browser/webdata/web_data_service.h" | 24 #include "chrome/browser/webdata/web_data_service.h" |
| 25 #include "chrome/browser/webdata/web_database_service.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
27 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 using base::WaitableEvent; | 32 using base::WaitableEvent; |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 using testing::_; | 34 using testing::_; |
34 using testing::DoAll; | 35 using testing::DoAll; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 virtual void SetUp() { | 110 virtual void SetUp() { |
110 ASSERT_TRUE(db_thread_.Start()); | 111 ASSERT_TRUE(db_thread_.Start()); |
111 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 112 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
112 | 113 |
113 profile_.reset(new TestingProfile()); | 114 profile_.reset(new TestingProfile()); |
114 | 115 |
115 login_db_.reset(new LoginDatabase()); | 116 login_db_.reset(new LoginDatabase()); |
116 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append( | 117 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append( |
117 FILE_PATH_LITERAL("login_test")))); | 118 FILE_PATH_LITERAL("login_test")))); |
118 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test"); | 119 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test"); |
119 wds_ = new WebDataService(path, | 120 wdbs_ = new WebDatabaseService(path); |
| 121 // Need to add at least one table so the database gets created. |
| 122 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); |
| 123 wdbs_->LoadDatabase(WebDatabaseService::InitCallback()); |
| 124 wds_ = new WebDataService(wdbs_, |
120 WebDataServiceBase::ProfileErrorCallback()); | 125 WebDataServiceBase::ProfileErrorCallback()); |
121 // Need to add at least one table so the database gets created. | |
122 wds_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); | |
123 wds_->Init(); | 126 wds_->Init(); |
124 } | 127 } |
125 | 128 |
126 virtual void TearDown() { | 129 virtual void TearDown() { |
127 if (store_.get()) | 130 if (store_.get()) |
128 store_->ShutdownOnUIThread(); | 131 store_->ShutdownOnUIThread(); |
129 wds_->ShutdownOnUIThread(); | 132 wds_->ShutdownOnUIThread(); |
| 133 wdbs_->ShutdownDatabase(); |
130 wds_ = NULL; | 134 wds_ = NULL; |
| 135 wdbs_ = NULL; |
131 base::WaitableEvent done(false, false); | 136 base::WaitableEvent done(false, false); |
132 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 137 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
133 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 138 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
134 done.Wait(); | 139 done.Wait(); |
135 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 140 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
136 MessageLoop::current()->Run(); | 141 MessageLoop::current()->Run(); |
137 db_thread_.Stop(); | 142 db_thread_.Stop(); |
138 } | 143 } |
139 | 144 |
140 MessageLoopForUI message_loop_; | 145 MessageLoopForUI message_loop_; |
141 content::TestBrowserThread ui_thread_; | 146 content::TestBrowserThread ui_thread_; |
142 // PasswordStore, WDS schedule work on this thread. | 147 // PasswordStore, WDS schedule work on this thread. |
143 content::TestBrowserThread db_thread_; | 148 content::TestBrowserThread db_thread_; |
144 | 149 |
145 scoped_ptr<LoginDatabase> login_db_; | 150 scoped_ptr<LoginDatabase> login_db_; |
146 scoped_ptr<TestingProfile> profile_; | 151 scoped_ptr<TestingProfile> profile_; |
147 scoped_refptr<WebDataService> wds_; | 152 scoped_refptr<WebDataService> wds_; |
| 153 scoped_refptr<WebDatabaseService> wdbs_; |
148 scoped_refptr<PasswordStore> store_; | 154 scoped_refptr<PasswordStore> store_; |
149 base::ScopedTempDir temp_dir_; | 155 base::ScopedTempDir temp_dir_; |
150 }; | 156 }; |
151 | 157 |
152 ACTION(STLDeleteElements0) { | 158 ACTION(STLDeleteElements0) { |
153 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 159 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
154 } | 160 } |
155 | 161 |
156 ACTION(QuitUIMessageLoop) { | 162 ACTION(QuitUIMessageLoop) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 VectorOfForms expect_none; | 418 VectorOfForms expect_none; |
413 // expect that we get no results; | 419 // expect that we get no results; |
414 EXPECT_CALL( | 420 EXPECT_CALL( |
415 consumer, | 421 consumer, |
416 OnPasswordStoreRequestDone(_, ContainsAllPasswordForms(expect_none))) | 422 OnPasswordStoreRequestDone(_, ContainsAllPasswordForms(expect_none))) |
417 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); | 423 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); |
418 | 424 |
419 store_->GetAutofillableLogins(&consumer); | 425 store_->GetAutofillableLogins(&consumer); |
420 MessageLoop::current()->Run(); | 426 MessageLoop::current()->Run(); |
421 } | 427 } |
OLD | NEW |