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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_test.cc

Issue 1096983002: Update usages of std::map to use ScopedPtrMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@passwordmanager-scopedmemory
Patch Set: Rebase. Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/passwords/manage_passwords_test.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 28 matching lines...) Expand all
39 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE)); 39 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE));
40 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE)); 40 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE));
41 41
42 // Wait for the command execution to pop up the bubble. 42 // Wait for the command execution to pop up the bubble.
43 content::RunAllPendingInMessageLoop(); 43 content::RunAllPendingInMessageLoop();
44 } 44 }
45 45
46 void ManagePasswordsTest::SetupManagingPasswords() { 46 void ManagePasswordsTest::SetupManagingPasswords() {
47 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); 47 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
48 autofill::PasswordFormMap map; 48 autofill::PasswordFormMap map;
49 map[kTestUsername] = test_form(); 49 map.insert(kTestUsername,
50 make_scoped_ptr(new autofill::PasswordForm(*test_form())));
50 GetController()->OnPasswordAutofilled(map); 51 GetController()->OnPasswordAutofilled(map);
51 } 52 }
52 53
53 void ManagePasswordsTest::SetupPendingPassword() { 54 void ManagePasswordsTest::SetupPendingPassword() {
54 password_manager::StubPasswordManagerClient client; 55 password_manager::StubPasswordManagerClient client;
55 password_manager::StubPasswordManagerDriver driver; 56 password_manager::StubPasswordManagerDriver driver;
56 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( 57 scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
57 new password_manager::PasswordFormManager( 58 new password_manager::PasswordFormManager(
58 NULL, &client, driver.AsWeakPtr(), *test_form(), false)); 59 NULL, &client, driver.AsWeakPtr(), *test_form(), false));
59 GetController()->OnPasswordSubmitted(test_form_manager.Pass()); 60 GetController()->OnPasswordSubmitted(test_form_manager.Pass());
60 } 61 }
61 62
62 void ManagePasswordsTest::SetupAutomaticPassword() { 63 void ManagePasswordsTest::SetupAutomaticPassword() {
63 password_manager::StubPasswordManagerClient client; 64 password_manager::StubPasswordManagerClient client;
64 password_manager::StubPasswordManagerDriver driver; 65 password_manager::StubPasswordManagerDriver driver;
65 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( 66 scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
66 new password_manager::PasswordFormManager( 67 new password_manager::PasswordFormManager(
67 NULL, &client, driver.AsWeakPtr(), *test_form(), false)); 68 NULL, &client, driver.AsWeakPtr(), *test_form(), false));
68 GetController()->OnAutomaticPasswordSave(test_form_manager.Pass()); 69 GetController()->OnAutomaticPasswordSave(test_form_manager.Pass());
69 } 70 }
70 71
71 void ManagePasswordsTest::SetupBlackistedPassword() { 72 void ManagePasswordsTest::SetupBlackistedPassword() {
72 test_form()->blacklisted_by_user = true; 73 test_form()->blacklisted_by_user = true;
73 test_form()->username_value.clear(); 74 test_form()->username_value.clear();
74 autofill::PasswordFormMap map; 75 autofill::PasswordFormMap map;
75 map[test_form()->username_value] = test_form(); 76 map.insert(test_form()->username_value,
77 make_scoped_ptr(new autofill::PasswordForm(*test_form())));
76 GetController()->OnBlacklistBlockedAutofill(map); 78 GetController()->OnBlacklistBlockedAutofill(map);
77 } 79 }
78 80
79 void ManagePasswordsTest::SetupChooseCredentials( 81 void ManagePasswordsTest::SetupChooseCredentials(
80 ScopedVector<autofill::PasswordForm> local_credentials, 82 ScopedVector<autofill::PasswordForm> local_credentials,
81 ScopedVector<autofill::PasswordForm> federated_credentials, 83 ScopedVector<autofill::PasswordForm> federated_credentials,
82 const GURL& origin) { 84 const GURL& origin) {
83 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); 85 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
84 autofill::PasswordFormMap map; 86 autofill::PasswordFormMap map;
85 map[kTestUsername] = test_form(); 87 map.insert(kTestUsername,
88 make_scoped_ptr(new autofill::PasswordForm(*test_form())));
86 GetController()->OnChooseCredentials( 89 GetController()->OnChooseCredentials(
87 local_credentials.Pass(), federated_credentials.Pass(), origin, 90 local_credentials.Pass(), federated_credentials.Pass(), origin,
88 base::Bind(&ManagePasswordsTest::OnChooseCredential, this)); 91 base::Bind(&ManagePasswordsTest::OnChooseCredential, this));
89 } 92 }
90 93
91 void ManagePasswordsTest::SetupAutoSignin( 94 void ManagePasswordsTest::SetupAutoSignin(
92 ScopedVector<autofill::PasswordForm> local_credentials) { 95 ScopedVector<autofill::PasswordForm> local_credentials) {
93 GetController()->OnAutoSignin(local_credentials.Pass()); 96 GetController()->OnAutoSignin(local_credentials.Pass());
94 } 97 }
95 98
96 base::HistogramSamples* ManagePasswordsTest::GetSamples( 99 base::HistogramSamples* ManagePasswordsTest::GetSamples(
97 const char* histogram) { 100 const char* histogram) {
98 // Ensure that everything has been properly recorded before pulling samples. 101 // Ensure that everything has been properly recorded before pulling samples.
99 content::RunAllPendingInMessageLoop(); 102 content::RunAllPendingInMessageLoop();
100 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram) 103 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram)
101 .release(); 104 .release();
102 } 105 }
103 106
104 ManagePasswordsUIController* ManagePasswordsTest::GetController() { 107 ManagePasswordsUIController* ManagePasswordsTest::GetController() {
105 return ManagePasswordsUIController::FromWebContents( 108 return ManagePasswordsUIController::FromWebContents(
106 browser()->tab_strip_model()->GetActiveWebContents()); 109 browser()->tab_strip_model()->GetActiveWebContents());
107 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698