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

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

Issue 2403773002: Remove stl_util's STLDeleteContainerPointers from autofill. (Closed)
Patch Set: rebase Created 4 years, 2 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
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 "chrome/browser/password_manager/password_store_win.h" 5 #include "chrome/browser/password_manager/password_store_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // GMock cannot mock methods with move-only args. 60 // GMock cannot mock methods with move-only args.
61 void OnGetPasswordStoreResults( 61 void OnGetPasswordStoreResults(
62 std::vector<std::unique_ptr<PasswordForm>> results) override { 62 std::vector<std::unique_ptr<PasswordForm>> results) override {
63 OnGetPasswordStoreResultsConstRef(results); 63 OnGetPasswordStoreResultsConstRef(results);
64 } 64 }
65 }; 65 };
66 66
67 class MockWebDataServiceConsumer : public WebDataServiceConsumer { 67 class MockWebDataServiceConsumer : public WebDataServiceConsumer {
68 public: 68 public:
69 MOCK_METHOD2(OnWebDataServiceRequestDone, 69 MOCK_METHOD0(OnWebDataServiceRequestDoneStub, void());
70 void(PasswordWebDataService::Handle, const WDTypedResult*)); 70
71 // GMock cannot mock methods with move-only args.
72 void OnWebDataServiceRequestDone(WebDataServiceBase::Handle h,
73 std::unique_ptr<WDTypedResult> result) {
74 OnWebDataServiceRequestDoneStub();
75 }
71 }; 76 };
72 77
73 } // anonymous namespace 78 } // anonymous namespace
74 79
75 class PasswordStoreWinTest : public testing::Test { 80 class PasswordStoreWinTest : public testing::Test {
76 protected: 81 protected:
77 PasswordStoreWinTest() 82 PasswordStoreWinTest()
78 : ui_thread_(BrowserThread::UI, &message_loop_), 83 : ui_thread_(BrowserThread::UI, &message_loop_),
79 db_thread_(BrowserThread::DB) {} 84 db_thread_(BrowserThread::DB) {}
80 85
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ACTION(STLDeleteElements0) { 196 ACTION(STLDeleteElements0) {
192 base::STLDeleteContainerPointers(arg0.begin(), arg0.end()); 197 base::STLDeleteContainerPointers(arg0.begin(), arg0.end());
193 } 198 }
194 199
195 ACTION(QuitUIMessageLoop) { 200 ACTION(QuitUIMessageLoop) {
196 DCHECK_CURRENTLY_ON(BrowserThread::UI); 201 DCHECK_CURRENTLY_ON(BrowserThread::UI);
197 base::MessageLoop::current()->QuitWhenIdle(); 202 base::MessageLoop::current()->QuitWhenIdle();
198 } 203 }
199 204
200 MATCHER(EmptyWDResult, "") { 205 MATCHER(EmptyWDResult, "") {
201 return static_cast<const WDResult<std::vector<PasswordForm*>>*>(arg) 206 return static_cast<
207 const WDResult<std::vector<std::unique_ptr<PasswordForm>>>*>(arg)
202 ->GetValue() 208 ->GetValue()
203 .empty(); 209 .empty();
204 } 210 }
205 211
206 // Hangs flakily, http://crbug.com/71385. 212 // Hangs flakily, http://crbug.com/71385.
207 TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) { 213 TEST_F(PasswordStoreWinTest, DISABLED_ConvertIE7Login) {
208 IE7PasswordInfo password_info; 214 IE7PasswordInfo password_info;
209 ASSERT_TRUE(CreateIE7PasswordInfo(L"http://example.com/origin", 215 ASSERT_TRUE(CreateIE7PasswordInfo(L"http://example.com/origin",
210 base::Time::FromDoubleT(1), 216 base::Time::FromDoubleT(1),
211 &password_info)); 217 &password_info));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 377
372 // The IE7 password should be returned. 378 // The IE7 password should be returned.
373 EXPECT_CALL(password_consumer, 379 EXPECT_CALL(password_consumer,
374 OnGetPasswordStoreResultsConstRef( 380 OnGetPasswordStoreResultsConstRef(
375 UnorderedPasswordFormElementsAre(&expected_forms))); 381 UnorderedPasswordFormElementsAre(&expected_forms)));
376 382
377 store_->GetLogins(form, &password_consumer); 383 store_->GetLogins(form, &password_consumer);
378 384
379 MockWebDataServiceConsumer wds_consumer; 385 MockWebDataServiceConsumer wds_consumer;
380 386
381 EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDone(_, _)) 387 EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDoneStub())
382 .WillOnce(QuitUIMessageLoop()); 388 .WillOnce(QuitUIMessageLoop());
383 389
384 wds_->GetIE7Login(password_info, &wds_consumer); 390 wds_->GetIE7Login(password_info, &wds_consumer);
385 391
386 // Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin 392 // Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin
387 // schedules on the DB thread and once for the one we just scheduled on the UI 393 // schedules on the DB thread and once for the one we just scheduled on the UI
388 // thread. 394 // thread.
389 base::RunLoop().Run(); 395 base::RunLoop().Run();
390 base::RunLoop().Run(); 396 base::RunLoop().Run();
391 } 397 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 452
447 // Make sure we quit the MessageLoop even if the test fails. 453 // Make sure we quit the MessageLoop even if the test fails.
448 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) 454 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_))
449 .WillByDefault(QuitUIMessageLoop()); 455 .WillByDefault(QuitUIMessageLoop());
450 456
451 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); 457 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
452 458
453 store_->GetAutofillableLogins(&consumer); 459 store_->GetAutofillableLogins(&consumer);
454 base::RunLoop().Run(); 460 base::RunLoop().Run();
455 } 461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698