Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/password_manager/password_store_win_unittest.cc

Issue 364343002: Kill WebDataService, move (WIN only) Password code into separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments and clean up Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 14 #include "base/message_loop/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/time.h" 18 #include "base/time/time.h"
19 #include "chrome/browser/password_manager/password_store_win.h" 19 #include "chrome/browser/password_manager/password_store_win.h"
20 #include "chrome/browser/webdata/logins_table.h" 20 #include "chrome/browser/webdata/logins_table.h"
21 #include "chrome/browser/webdata/web_data_service.h" 21 #include "chrome/browser/webdata/password_web_data_service_win.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "components/os_crypt/ie7_password_win.h" 23 #include "components/os_crypt/ie7_password_win.h"
24 #include "components/password_manager/core/browser/password_form_data.h" 24 #include "components/password_manager/core/browser/password_form_data.h"
25 #include "components/password_manager/core/browser/password_store_consumer.h" 25 #include "components/password_manager/core/browser/password_store_consumer.h"
26 #include "components/password_manager/core/common/password_manager_pref_names.h" 26 #include "components/password_manager/core/common/password_manager_pref_names.h"
27 #include "components/webdata/common/web_database_service.h" 27 #include "components/webdata/common/web_database_service.h"
28 #include "content/public/test/test_browser_thread.h" 28 #include "content/public/test/test_browser_thread.h"
29 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
31 31
(...skipping 13 matching lines...) Expand all
45 45
46 class MockPasswordStoreConsumer : public PasswordStoreConsumer { 46 class MockPasswordStoreConsumer : public PasswordStoreConsumer {
47 public: 47 public:
48 MOCK_METHOD1(OnGetPasswordStoreResults, 48 MOCK_METHOD1(OnGetPasswordStoreResults,
49 void(const std::vector<autofill::PasswordForm*>&)); 49 void(const std::vector<autofill::PasswordForm*>&));
50 }; 50 };
51 51
52 class MockWebDataServiceConsumer : public WebDataServiceConsumer { 52 class MockWebDataServiceConsumer : public WebDataServiceConsumer {
53 public: 53 public:
54 MOCK_METHOD2(OnWebDataServiceRequestDone, 54 MOCK_METHOD2(OnWebDataServiceRequestDone,
55 void(WebDataService::Handle, const WDTypedResult*)); 55 void(PasswordWebDataService::Handle, const WDTypedResult*));
56 }; 56 };
57 57
58 } // anonymous namespace 58 } // anonymous namespace
59 59
60 typedef std::vector<PasswordForm*> VectorOfForms; 60 typedef std::vector<PasswordForm*> VectorOfForms;
61 61
62 class PasswordStoreWinTest : public testing::Test { 62 class PasswordStoreWinTest : public testing::Test {
63 protected: 63 protected:
64 PasswordStoreWinTest() 64 PasswordStoreWinTest()
65 : ui_thread_(BrowserThread::UI, &message_loop_), 65 : ui_thread_(BrowserThread::UI, &message_loop_),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 login_db_.reset(new LoginDatabase()); 118 login_db_.reset(new LoginDatabase());
119 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append( 119 ASSERT_TRUE(login_db_->Init(temp_dir_.path().Append(
120 FILE_PATH_LITERAL("login_test")))); 120 FILE_PATH_LITERAL("login_test"))));
121 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test"); 121 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test");
122 wdbs_ = new WebDatabaseService(path, 122 wdbs_ = new WebDatabaseService(path,
123 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 123 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
124 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); 124 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB));
125 // Need to add at least one table so the database gets created. 125 // Need to add at least one table so the database gets created.
126 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); 126 wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable()));
127 wdbs_->LoadDatabase(); 127 wdbs_->LoadDatabase();
128 wds_ = new WebDataService(wdbs_, 128 wds_ = new PasswordWebDataService(
129 WebDataServiceBase::ProfileErrorCallback()); 129 wdbs_, WebDataServiceBase::ProfileErrorCallback());
130 wds_->Init(); 130 wds_->Init();
131 } 131 }
132 132
133 virtual void TearDown() { 133 virtual void TearDown() {
134 if (store_) 134 if (store_)
135 store_->Shutdown(); 135 store_->Shutdown();
136 wds_->ShutdownOnUIThread(); 136 wds_->ShutdownOnUIThread();
137 wdbs_->ShutdownDatabase(); 137 wdbs_->ShutdownDatabase();
138 wds_ = NULL; 138 wds_ = NULL;
139 wdbs_ = NULL; 139 wdbs_ = NULL;
(...skipping 16 matching lines...) Expand all
156 } 156 }
157 157
158 base::MessageLoopForUI message_loop_; 158 base::MessageLoopForUI message_loop_;
159 content::TestBrowserThread ui_thread_; 159 content::TestBrowserThread ui_thread_;
160 // PasswordStore, WDS schedule work on this thread. 160 // PasswordStore, WDS schedule work on this thread.
161 content::TestBrowserThread db_thread_; 161 content::TestBrowserThread db_thread_;
162 162
163 base::ScopedTempDir temp_dir_; 163 base::ScopedTempDir temp_dir_;
164 scoped_ptr<TestingProfile> profile_; 164 scoped_ptr<TestingProfile> profile_;
165 scoped_ptr<LoginDatabase> login_db_; 165 scoped_ptr<LoginDatabase> login_db_;
166 scoped_refptr<WebDataService> wds_; 166 scoped_refptr<PasswordWebDataService> wds_;
167 scoped_refptr<WebDatabaseService> wdbs_; 167 scoped_refptr<WebDatabaseService> wdbs_;
168 scoped_refptr<PasswordStore> store_; 168 scoped_refptr<PasswordStore> store_;
169 }; 169 };
170 170
171 ACTION(STLDeleteElements0) { 171 ACTION(STLDeleteElements0) {
172 STLDeleteContainerPointers(arg0.begin(), arg0.end()); 172 STLDeleteContainerPointers(arg0.begin(), arg0.end());
173 } 173 }
174 174
175 ACTION(QuitUIMessageLoop) { 175 ACTION(QuitUIMessageLoop) {
176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 VectorOfForms expect_none; 427 VectorOfForms expect_none;
428 // expect that we get no results; 428 // expect that we get no results;
429 EXPECT_CALL( 429 EXPECT_CALL(
430 consumer, 430 consumer,
431 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) 431 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none)))
432 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); 432 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop()));
433 433
434 store_->GetAutofillableLogins(&consumer); 434 store_->GetAutofillableLogins(&consumer);
435 base::MessageLoop::current()->Run(); 435 base::MessageLoop::current()->Run();
436 } 436 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_win.cc ('k') | chrome/browser/profiles/profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698