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

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

Issue 1837043003: Add a title for the account chooser for one credential displayed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_view_utils.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 GURL(kDomainsTestCases[i].user_visible_url), 138 GURL(kDomainsTestCases[i].user_visible_url),
139 GURL(kDomainsTestCases[i].form_origin_url), &title); 139 GURL(kDomainsTestCases[i].form_origin_url), &title);
140 140
141 // Verify against expectations. 141 // Verify against expectations.
142 base::string16 domain = 142 base::string16 domain =
143 base::ASCIIToUTF16(kDomainsTestCases[i].expected_domain_placeholder); 143 base::ASCIIToUTF16(kDomainsTestCases[i].expected_domain_placeholder);
144 EXPECT_TRUE(title.find(domain) != base::string16::npos); 144 EXPECT_TRUE(title.find(domain) != base::string16::npos);
145 } 145 }
146 } 146 }
147 147
148 TEST(ManagePasswordsViewUtilTest, 148 // The parameter is |many_accounts| passed to
149 GetAccountChooserDialogTitleTextAndLinkRangeSmartLockUsers) { 149 // GetAccountChooserDialogTitleTextAndLinkRange
150 class AccountChooserDialogTitleTest : public ::testing::TestWithParam<bool> {
151 };
152
153 TEST_P(AccountChooserDialogTitleTest,
154 GetAccountChooserDialogTitleTextAndLinkRangeSmartLockUsers) {
150 base::string16 branding = 155 base::string16 branding =
151 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); 156 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK);
152 base::string16 title; 157 base::string16 title;
153 gfx::Range title_link_range; 158 gfx::Range title_link_range;
154 GetAccountChooserDialogTitleTextAndLinkRange( 159 GetAccountChooserDialogTitleTextAndLinkRange(
155 true /* is_smartlock_branding_enabled */, &title, &title_link_range); 160 true /* is_smartlock_branding_enabled */,
161 GetParam(),
162 &title, &title_link_range);
156 163
157 // Check that branding string is a part of a title. 164 // Check that branding string is a part of a title.
158 EXPECT_LT(title.find(branding, 0), title.size()); 165 EXPECT_LT(title.find(branding, 0), title.size());
159 EXPECT_GT(title.find(branding, 0), 0U); 166 EXPECT_GT(title.find(branding, 0), 0U);
160 // Check that link range is not empty. 167 // Check that link range is not empty.
161 EXPECT_NE(0U, title_link_range.start()); 168 EXPECT_NE(0U, title_link_range.start());
162 EXPECT_NE(0U, title_link_range.end()); 169 EXPECT_NE(0U, title_link_range.end());
163 } 170 }
164 171
165 TEST(ManagePasswordsViewUtilTest, 172 TEST_P(AccountChooserDialogTitleTest,
166 GetAccountChooserDialogTitleTextAndLinkRangeNonSmartLockUsers) { 173 GetAccountChooserDialogTitleTextAndLinkRangeNonSmartLockUsers) {
167 base::string16 branding = 174 base::string16 branding =
168 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK); 175 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK);
169 base::string16 title; 176 base::string16 title;
170 gfx::Range title_link_range; 177 gfx::Range title_link_range;
171 GetAccountChooserDialogTitleTextAndLinkRange( 178 GetAccountChooserDialogTitleTextAndLinkRange(
172 false /* is_smartlock_branding_enabled */, &title, &title_link_range); 179 false /* is_smartlock_branding_enabled */,
180 GetParam(),
181 &title, &title_link_range);
173 EXPECT_GE(title.find(branding, 0), title.size()); 182 EXPECT_GE(title.find(branding, 0), title.size());
174 EXPECT_EQ(0U, title_link_range.start()); 183 EXPECT_EQ(0U, title_link_range.start());
175 EXPECT_EQ(0U, title_link_range.end()); 184 EXPECT_EQ(0U, title_link_range.end());
176 } 185 }
186
187 INSTANTIATE_TEST_CASE_P(, AccountChooserDialogTitleTest,
188 ::testing::Bool());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698