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

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

Issue 2531863002: Delete all the traces of federation providers in the account chooser. (Closed)
Patch Set: android2 Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/account_chooser_dialog_android.h" 5 #include "chrome/browser/password_manager/account_chooser_dialog_android.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }; 56 };
57 57
58 void AccountChooserDialogAndroidTest::SetUp() { 58 void AccountChooserDialogAndroidTest::SetUp() {
59 ChromeRenderViewHostTestHarness::SetUp(); 59 ChromeRenderViewHostTestHarness::SetUp();
60 ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( 60 ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
61 web_contents(), nullptr); 61 web_contents(), nullptr);
62 } 62 }
63 63
64 AccountChooserDialogAndroid* AccountChooserDialogAndroidTest::CreateDialog( 64 AccountChooserDialogAndroid* AccountChooserDialogAndroidTest::CreateDialog(
65 std::vector<std::unique_ptr<autofill::PasswordForm>> credentials) { 65 std::vector<std::unique_ptr<autofill::PasswordForm>> credentials) {
66 std::vector<std::unique_ptr<autofill::PasswordForm>> deprecated_federated;
67 return new AccountChooserDialogAndroid( 66 return new AccountChooserDialogAndroid(
68 web_contents(), std::move(credentials), std::move(deprecated_federated), 67 web_contents(), std::move(credentials), GURL("https://example.com"),
69 GURL("https://example.com"),
70 base::Bind(&AccountChooserDialogAndroidTest::OnChooseCredential, 68 base::Bind(&AccountChooserDialogAndroidTest::OnChooseCredential,
71 base::Unretained(this))); 69 base::Unretained(this)));
72 } 70 }
73 71
74 AccountChooserDialogAndroid* 72 AccountChooserDialogAndroid*
75 AccountChooserDialogAndroidTest::CreateDialogOneAccount() { 73 AccountChooserDialogAndroidTest::CreateDialogOneAccount() {
76 std::vector<std::unique_ptr<autofill::PasswordForm>> credentials; 74 std::vector<std::unique_ptr<autofill::PasswordForm>> credentials;
77 credentials.push_back(CreatePasswordFormFromDataForTesting(kFormData)); 75 credentials.push_back(CreatePasswordFormFromDataForTesting(kFormData));
78 return CreateDialog(std::move(credentials)); 76 return CreateDialog(std::move(credentials));
79 } 77 }
80 78
81 AccountChooserDialogAndroid* 79 AccountChooserDialogAndroid*
82 AccountChooserDialogAndroidTest::CreateDialogManyAccounts() { 80 AccountChooserDialogAndroidTest::CreateDialogManyAccounts() {
83 std::vector<std::unique_ptr<autofill::PasswordForm>> credentials; 81 std::vector<std::unique_ptr<autofill::PasswordForm>> credentials;
84 credentials.push_back(CreatePasswordFormFromDataForTesting(kFormData)); 82 credentials.push_back(CreatePasswordFormFromDataForTesting(kFormData));
85 credentials.push_back(CreatePasswordFormFromDataForTesting(kFormData)); 83 credentials.push_back(CreatePasswordFormFromDataForTesting(kFormData));
86 return CreateDialog(std::move(credentials)); 84 return CreateDialog(std::move(credentials));
87 } 85 }
88 86
89 TEST_F(AccountChooserDialogAndroidTest, 87 TEST_F(AccountChooserDialogAndroidTest,
90 CheckHistogramsReportingOnceAccountViaOnAccountClick) { 88 CheckHistogramsReportingOnceAccountViaOnAccountClick) {
91 base::HistogramTester histogram_tester; 89 base::HistogramTester histogram_tester;
92 AccountChooserDialogAndroid* dialog = CreateDialogOneAccount(); 90 AccountChooserDialogAndroid* dialog = CreateDialogOneAccount();
93 dialog->OnCredentialClicked( 91 dialog->OnCredentialClicked(
94 base::android::AttachCurrentThread(), nullptr /* obj */, 92 base::android::AttachCurrentThread(), nullptr /* obj */,
95 0 /* credential_item */, 93 0 /* credential_item */,
96 static_cast<int>(
97 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD),
98 false /* signin_button_clicked */); 94 false /* signin_button_clicked */);
99 dialog->Destroy(base::android::AttachCurrentThread(), nullptr); 95 dialog->Destroy(base::android::AttachCurrentThread(), nullptr);
100 96
101 histogram_tester.ExpectUniqueSample( 97 histogram_tester.ExpectUniqueSample(
102 "PasswordManager.AccountChooserDialogOneAccount", 98 "PasswordManager.AccountChooserDialogOneAccount",
103 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); 99 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1);
104 histogram_tester.ExpectTotalCount( 100 histogram_tester.ExpectTotalCount(
105 "PasswordManager.AccountChooserDialogMultipleAccounts", 0); 101 "PasswordManager.AccountChooserDialogMultipleAccounts", 0);
106 } 102 }
107 103
108 TEST_F(AccountChooserDialogAndroidTest, 104 TEST_F(AccountChooserDialogAndroidTest,
109 CheckHistogramsReportingOneAccountChoosenViaSigninButton) { 105 CheckHistogramsReportingOneAccountChoosenViaSigninButton) {
110 base::HistogramTester histogram_tester; 106 base::HistogramTester histogram_tester;
111 AccountChooserDialogAndroid* dialog = CreateDialogOneAccount(); 107 AccountChooserDialogAndroid* dialog = CreateDialogOneAccount();
112 dialog->OnCredentialClicked( 108 dialog->OnCredentialClicked(
113 base::android::AttachCurrentThread(), nullptr /* obj */, 109 base::android::AttachCurrentThread(), nullptr /* obj */,
114 0 /* credential_item */, 110 0 /* credential_item */,
115 static_cast<int>(
116 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD),
117 true /* signin_button_clicked */); 111 true /* signin_button_clicked */);
118 dialog->Destroy(base::android::AttachCurrentThread(), nullptr); 112 dialog->Destroy(base::android::AttachCurrentThread(), nullptr);
119 histogram_tester.ExpectUniqueSample( 113 histogram_tester.ExpectUniqueSample(
120 "PasswordManager.AccountChooserDialogOneAccount", 114 "PasswordManager.AccountChooserDialogOneAccount",
121 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); 115 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1);
122 histogram_tester.ExpectTotalCount( 116 histogram_tester.ExpectTotalCount(
123 "PasswordManager.AccountChooserDialogMultipleAccounts", 0); 117 "PasswordManager.AccountChooserDialogMultipleAccounts", 0);
124 } 118 }
125 119
126 TEST_F(AccountChooserDialogAndroidTest, CheckHistogramsReportingManyAccounts) { 120 TEST_F(AccountChooserDialogAndroidTest, CheckHistogramsReportingManyAccounts) {
127 base::HistogramTester histogram_tester; 121 base::HistogramTester histogram_tester;
128 AccountChooserDialogAndroid* dialog = CreateDialogManyAccounts(); 122 AccountChooserDialogAndroid* dialog = CreateDialogManyAccounts();
129 dialog->OnCredentialClicked( 123 dialog->OnCredentialClicked(
130 base::android::AttachCurrentThread(), nullptr /* obj */, 124 base::android::AttachCurrentThread(), nullptr /* obj */,
131 0 /* credential_item */, 125 0 /* credential_item */,
132 static_cast<int>(
133 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD),
134 false /* signin_button_clicked */); 126 false /* signin_button_clicked */);
135 dialog->Destroy(base::android::AttachCurrentThread(), nullptr); 127 dialog->Destroy(base::android::AttachCurrentThread(), nullptr);
136 128
137 histogram_tester.ExpectUniqueSample( 129 histogram_tester.ExpectUniqueSample(
138 "PasswordManager.AccountChooserDialogMultipleAccounts", 130 "PasswordManager.AccountChooserDialogMultipleAccounts",
139 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); 131 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1);
140 histogram_tester.ExpectTotalCount( 132 histogram_tester.ExpectTotalCount(
141 "PasswordManager.AccountChooserDialogOneAccount", 0); 133 "PasswordManager.AccountChooserDialogOneAccount", 0);
142 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698