0

Revert "[sheriff] Revert "Reduce usage of base::UTF8ToUTF16().""

This reverts commit d30ba32898.

The original CL exposed a pre-existing bug in the tests.  This fixes it.

Bug: 1189439
Change-Id: I832366e83092d39a6224f4ee75db2265886ff85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2880897
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880613}
This commit is contained in:
Peter Kasting
2021-05-07 22:58:25 +00:00
committed by Chromium LUCI CQ
parent 80c947fbe5
commit cc07b335a3
79 changed files with 2548 additions and 2788 deletions
base
chrome/browser
components
content
device/fido
extensions
services/device/public/cpp/bluetooth
third_party/blink/common/page_state
ui
url

@ -95,10 +95,7 @@ TEST(BreakIteratorTest, BreakWordWide16) {
}
TEST(BreakIteratorTest, BreakWordWide32) {
// U+1D49C MATHEMATICAL SCRIPT CAPITAL A
const char very_wide_char[] = "\xF0\x9D\x92\x9C";
const std::u16string str(
UTF8ToUTF16(base::StringPrintf("%s a", very_wide_char)));
const std::u16string str = u"\U0001d49c a";
const std::u16string very_wide_word(str.substr(0, 2));
BreakIterator iter(str, BreakIterator::BREAK_WORD);
@ -120,23 +117,22 @@ TEST(BreakIteratorTest, BreakWordWide32) {
TEST(BreakIteratorTest, BreakWordThai) {
// Terms in Thai, without spaces in between.
const char term1[] = "พิมพ์";
const char term2[] = "น้อย";
const char term3[] = "ลง";
const std::u16string str(
UTF8ToUTF16(base::JoinString({term1, term2, term3}, "")));
const char16_t term1[] = u"พิมพ์";
const char16_t term2[] = u"น้อย";
const char16_t term3[] = u"ลง";
const std::u16string str(base::JoinString({term1, term2, term3}, u""));
BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term1), iter.GetString());
EXPECT_EQ(term1, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term2), iter.GetString());
EXPECT_EQ(term2, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term3), iter.GetString());
EXPECT_EQ(term3, iter.GetString());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
}
@ -149,41 +145,40 @@ TEST(BreakIteratorTest, BreakWordThai) {
TEST(BreakIteratorTest, BreakWordChinese) {
// Terms in Traditional Chinese, without spaces in between.
const char term1[] = "瀏覽";
const char term2[] = "速度";
const char term3[] = "飛快";
const std::u16string str(
UTF8ToUTF16(base::JoinString({term1, term2, term3}, "")));
const char16_t term1[] = u"瀏覽";
const char16_t term2[] = u"速度";
const char16_t term3[] = u"飛快";
const std::u16string str(base::JoinString({term1, term2, term3}, u""));
BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term1), iter.GetString());
EXPECT_EQ(term1, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term2), iter.GetString());
EXPECT_EQ(term2, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term3), iter.GetString());
EXPECT_EQ(term3, iter.GetString());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
}
TEST(BreakIteratorTest, BreakWordJapanese) {
// Terms in Japanese, without spaces in between.
const char term1[] = "モバイル";
const char term2[] = "でも";
const std::u16string str(UTF8ToUTF16(base::JoinString({term1, term2}, "")));
const char16_t term1[] = u"モバイル";
const char16_t term2[] = u"でも";
const std::u16string str(base::JoinString({term1, term2}, u""));
BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term1), iter.GetString());
EXPECT_EQ(term1, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(term2), iter.GetString());
EXPECT_EQ(term2, iter.GetString());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
}
@ -191,21 +186,21 @@ TEST(BreakIteratorTest, BreakWordJapanese) {
TEST(BreakIteratorTest, BreakWordChineseEnglish) {
// Terms in Simplified Chinese mixed with English and wide punctuations.
std::u16string space(u" ");
const char token1[] = "下载";
const char token2[] = "Chrome";
const char token3[] = "";
const char token4[] = "Mac";
const char token5[] = "";
const char token6[] = "";
const std::u16string str(UTF8ToUTF16(base::JoinString(
{token1, " ", token2, token3, token4, " ", token5, token6}, "")));
const char16_t token1[] = u"下载";
const char16_t token2[] = u"Chrome";
const char16_t token3[] = u"";
const char16_t token4[] = u"Mac";
const char16_t token5[] = u"";
const char16_t token6[] = u"";
const std::u16string str(base::JoinString(
{token1, u" ", token2, token3, token4, u" ", token5, token6}, u""));
BreakIterator iter(str, BreakIterator::BREAK_WORD);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(token1), iter.GetString());
EXPECT_EQ(token1, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@ -213,15 +208,15 @@ TEST(BreakIteratorTest, BreakWordChineseEnglish) {
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(token2), iter.GetString());
EXPECT_EQ(token2, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(token3), iter.GetString());
EXPECT_EQ(token3, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(token4), iter.GetString());
EXPECT_EQ(token4, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@ -229,11 +224,11 @@ TEST(BreakIteratorTest, BreakWordChineseEnglish) {
EXPECT_TRUE(iter.Advance());
EXPECT_TRUE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(token5), iter.GetString());
EXPECT_EQ(token5, iter.GetString());
EXPECT_TRUE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
EXPECT_EQ(UTF8ToUTF16(token6), iter.GetString());
EXPECT_EQ(token6, iter.GetString());
EXPECT_FALSE(iter.Advance());
EXPECT_FALSE(iter.IsWord());
@ -323,10 +318,7 @@ TEST(BreakIteratorTest, BreakSpacekWide16) {
}
TEST(BreakIteratorTest, BreakSpaceWide32) {
// U+1D49C MATHEMATICAL SCRIPT CAPITAL A
const char very_wide_char[] = "\xF0\x9D\x92\x9C";
const std::u16string str(
UTF8ToUTF16(base::StringPrintf("%s a", very_wide_char)));
const std::u16string str = u"\U0001d49c a";
const std::u16string very_wide_word(str.substr(0, 3));
BreakIterator iter(str, BreakIterator::BREAK_SPACE);
@ -378,8 +370,8 @@ TEST(BreakIteratorTest, BreakLine) {
TEST(BreakIteratorTest, BreakSentence) {
std::u16string nl(u"\n");
std::u16string str(UTF8ToUTF16(
"\nFoo bar!\nOne sentence.\n\n\tAnother sentence?One more thing"));
std::u16string str(
u"\nFoo bar!\nOne sentence.\n\n\tAnother sentence?One more thing");
BreakIterator iter(str, BreakIterator::BREAK_SENTENCE);
ASSERT_TRUE(iter.Init());
EXPECT_TRUE(iter.Advance());
@ -405,8 +397,8 @@ TEST(BreakIteratorTest, BreakSentence) {
}
TEST(BreakIteratorTest, IsSentenceBoundary) {
std::u16string str(UTF8ToUTF16(
"Foo bar!\nOne sentence.\n\n\tAnother sentence?One more thing"));
std::u16string str(
u"Foo bar!\nOne sentence.\n\n\tAnother sentence?One more thing");
BreakIterator iter(str, BreakIterator::BREAK_SENTENCE);
ASSERT_TRUE(iter.Init());
@ -470,10 +462,7 @@ TEST(BreakIteratorTest, BreakLineWide16) {
}
TEST(BreakIteratorTest, BreakLineWide32) {
// U+1D49C MATHEMATICAL SCRIPT CAPITAL A
const char very_wide_char[] = "\xF0\x9D\x92\x9C";
const std::u16string str(
UTF8ToUTF16(base::StringPrintf("%s\na", very_wide_char)));
const std::u16string str = u"\U0001d49c\na";
const std::u16string very_wide_line(str.substr(0, 3));
BreakIterator iter(str, BreakIterator::BREAK_NEWLINE);
ASSERT_TRUE(iter.Init());
@ -490,29 +479,29 @@ TEST(BreakIteratorTest, BreakLineWide32) {
}
TEST(BreakIteratorTest, BreakCharacter) {
static const char* kCharacters[] = {
static const char16_t* const kCharacters[] = {
// An English word consisting of four ASCII characters.
"w",
"o",
"r",
"d",
" ",
u"w",
u"o",
u"r",
u"d",
u" ",
// A Hindi word (which means "Hindi") consisting of two Devanagari
// grapheme clusters.
"\u0939\u093F",
"\u0928\u094D\u0926\u0940",
" ",
u"हि",
u"न्दी",
u" ",
// A Thai word (which means "feel") consisting of three Thai grapheme
// clusters.
"\u0E23\u0E39\u0E49",
"\u0E2A\u0E36",
"\u0E01",
" ",
u"รู้",
u"สึ",
u"",
u" ",
};
std::vector<std::u16string> characters;
std::u16string text;
for (auto*& i : kCharacters) {
characters.push_back(base::UTF8ToUTF16(i));
for (const auto* i : kCharacters) {
characters.push_back(i);
text.append(characters.back());
}
BreakIterator iter(text, BreakIterator::BREAK_CHARACTER);

@ -633,12 +633,11 @@ TEST(StringPiece16Test, CheckSTL) {
ASSERT_EQ(f.size(), 6U);
}
TEST(StringPiece16Test, CheckConversion) {
// Make sure that we can convert from UTF8 to UTF16 and back. We use a two
// byte character (G clef) to test this.
ASSERT_EQ(UTF16ToUTF8(UTF8ToUTF16("\xf0\x9d\x84\x9e")), "\xf0\x9d\x84\x9e");
// Make sure that we can convert from UTF8 to UTF16 and back. We use a
// character (G clef) outside the BMP to test this.
const char kTest[] = "\U0001D11E";
ASSERT_EQ(UTF16ToUTF8(UTF8ToUTF16(kTest)), kTest);
}
TYPED_TEST(CommonStringPieceTest, CheckConstructors) {

@ -35,6 +35,7 @@ namespace {
const int kMaxNumberOfExtensionRequest = 1000;
constexpr char kProfile[] = "Profile";
constexpr char16_t kProfile16[] = u"Profile";
constexpr char kIdleProfile[] = "IdleProfile";
constexpr char16_t kIdleProfile16[] = u"IdleProfile";
constexpr char kExtensionId[] = "abcdefghijklmnopabcdefghijklmnop";
@ -68,7 +69,7 @@ class ProfileReportGeneratorTest : public ::testing::Test {
InitPolicyMap();
profile_ = profile_manager_.CreateTestingProfile(
kProfile, {}, base::UTF8ToUTF16(kProfile), 0, {},
kProfile, {}, kProfile16, 0, {},
IdentityTestEnvironmentProfileAdaptor::
GetIdentityTestEnvironmentFactories(),
base::nullopt, std::move(policy_service_));

@ -82,9 +82,9 @@ class SkBitmap;
namespace {
const char kAppUrl[] = "http://www.google.com";
const char kAppTitle[] = "Test title";
const char kAppDescription[] = "Test description";
const char kShortcutItemName[] = "shortcut";
const char16_t kAppTitle[] = u"Test title";
const char16_t kAppDescription[] = u"Test description";
const char16_t kShortcutItemName[] = u"shortcut";
const char kShortcutUrl[] = "http://www.google.com/shortcut";
const char kShortcutIconUrl[] = "http://www.google.com/shortcut/icon.png";
@ -140,14 +140,14 @@ SkBitmap CreateSquareBitmap(int size) {
return bitmap;
}
WebApplicationInfo CreateWebAppInfo(const char* title,
const char* description,
WebApplicationInfo CreateWebAppInfo(const char16_t* title,
const char16_t* description,
const char* start_url,
int size,
bool create_with_shortcuts) {
WebApplicationInfo web_app_info;
web_app_info.title = base::UTF8ToUTF16(title);
web_app_info.description = base::UTF8ToUTF16(description);
web_app_info.title = title;
web_app_info.description = description;
web_app_info.start_url = GURL(start_url);
web_app_info.scope = GURL(start_url);
web_app_info.icon_bitmaps.any[size] = CreateSquareBitmap(size);
@ -155,7 +155,7 @@ WebApplicationInfo CreateWebAppInfo(const char* title,
WebApplicationShortcutsMenuItemInfo shortcut_item;
WebApplicationShortcutsMenuItemInfo::Icon icon;
IconBitmaps shortcut_icon_bitmaps;
shortcut_item.name = base::UTF8ToUTF16(kShortcutItemName);
shortcut_item.name = kShortcutItemName;
shortcut_item.url = GURL(kShortcutUrl);
icon.url = GURL(kShortcutIconUrl);
icon.square_size_px = size;

@ -20,7 +20,7 @@ namespace chrome_browser_interstitials {
testing::AssertionResult SecurityInterstitialIDNTest::VerifyIDNDecoded() const {
const char kHostname[] = "xn--d1abbgf6aiiy.xn--p1ai";
const char kHostnameUnicode[] = "президент.рф";
const char16_t kHostnameUnicode[] = u"президент.рф";
std::string request_url_spec = base::StringPrintf("https://%s/", kHostname);
GURL request_url(request_url_spec);
@ -35,9 +35,9 @@ testing::AssertionResult SecurityInterstitialIDNTest::VerifyIDNDecoded() const {
net::ERR_BLOCKED_BY_CLIENT);
observer.Wait();
delete blocking_page;
if (ui_test_utils::FindInPage(contents, base::UTF8ToUTF16(kHostnameUnicode),
true /*forward*/, true /*case_sensitive*/,
nullptr, nullptr) == 1) {
if (ui_test_utils::FindInPage(contents, kHostnameUnicode, true /*forward*/,
true /*case_sensitive*/, nullptr,
nullptr) == 1) {
return testing::AssertionSuccess();
}
return testing::AssertionFailure() << "Interstitial not displaying text";

@ -38,7 +38,7 @@ namespace notifications {
namespace {
const char kGuid[] = "guid";
const char kTitle[] = "title";
const char16_t kTitle[] = u"title";
class NotificationSchedulerTest : public testing::Test {
public:
@ -293,8 +293,8 @@ TEST_F(NotificationSchedulerTest, BackgroundTaskStartShowNothing) {
OnStartTask();
}
MATCHER_P(NotifcationDataEq, title, "Verify notification data.") {
EXPECT_EQ(arg->title, base::UTF8ToUTF16(title));
MATCHER_P(NotificationDataEq, title, "Verify notification data.") {
EXPECT_EQ(arg->title, title);
return true;
}
@ -313,7 +313,7 @@ TEST_F(NotificationSchedulerTest, BackgroundTaskStartShowNotification) {
std::make_unique<NotificationEntry>(SchedulerClientType::kTest1, kGuid);
EXPECT_CALL(
*display_agent(),
ShowNotification(NotifcationDataEq(kTitle),
ShowNotification(NotificationDataEq(kTitle),
SystemDataEq(SchedulerClientType::kTest1, kGuid)));
DisplayDecider::Results result({kGuid});
EXPECT_CALL(*display_decider(), FindNotificationsToShow(_, _, _))
@ -333,7 +333,7 @@ TEST_F(NotificationSchedulerTest, BackgroundTaskStartShowNotification) {
[&](std::unique_ptr<NotificationData> notification_data,
NotificationSchedulerClient::NotificationDataCallback callback) {
// The client updates the notification data here.
notification_data->title = base::UTF8ToUTF16(kTitle);
notification_data->title = kTitle;
std::move(callback).Run(std::move(notification_data));
}));

@ -30,7 +30,7 @@ namespace {
const char kGuid[] = "test_guid_1234";
const char kNonExistentGuid[] = "guid_non_existent";
const char kTitle[] = "test_title";
const char16_t kTitle[] = u"test_title";
const char kSmallIconUuid[] = "test_small_icon_uuid";
const char kLargeIconUuid[] = "test_large_icon_uuid";
@ -298,7 +298,7 @@ TEST_F(ScheduledNotificationManagerTest, IconDbInitAndLoadKeys) {
TEST_F(ScheduledNotificationManagerTest, ScheduleNotification) {
InitWithData(std::vector<NotificationEntry>());
NotificationData notification_data;
notification_data.title = base::UTF8ToUTF16(kTitle);
notification_data.title = kTitle;
ScheduleParams schedule_params;
schedule_params.priority = ScheduleParams::Priority::kLow;
auto params = std::make_unique<NotificationParams>(
@ -333,7 +333,7 @@ TEST_F(ScheduledNotificationManagerTest, ScheduleNotification) {
EXPECT_NE(entry->create_time, base::Time());
// TODO(xingliu): change these to compare with operator==.
EXPECT_EQ(base::UTF16ToUTF8(entry->notification_data.title), kTitle);
EXPECT_EQ(entry->notification_data.title, kTitle);
EXPECT_EQ(entry->schedule_params.priority, ScheduleParams::Priority::kLow);
// Verify that |enable_ihnr_buttons| will add the helpful/unhelpful buttons.
@ -349,7 +349,7 @@ TEST_F(ScheduledNotificationManagerTest, ScheduleNotification) {
TEST_F(ScheduledNotificationManagerTest, ScheduleInvalidNotification) {
InitWithData(std::vector<NotificationEntry>());
NotificationData notification_data;
notification_data.title = base::UTF8ToUTF16(kTitle);
notification_data.title = kTitle;
ScheduleParams schedule_params;
// Client type kTest3 is not registered.
auto params = std::make_unique<NotificationParams>(
@ -367,7 +367,7 @@ TEST_F(ScheduledNotificationManagerTest, ScheduleNotificationDuplicateGuid) {
InitWithData(std::vector<NotificationEntry>({entry}));
NotificationData notification_data;
notification_data.title = base::UTF8ToUTF16(kTitle);
notification_data.title = kTitle;
ScheduleParams schedule_params;
auto params = std::make_unique<NotificationParams>(
SchedulerClientType::kTest1, notification_data, schedule_params);

@ -29,8 +29,8 @@ namespace {
const char kContextMenuLabel[] = "settings";
const char kEncodedId[] = "0|0|Default|0|https://example.com/|notification_id";
const char kNotificationId[] = "notification_id";
const char kNotificationTitle[] = "My Title";
const char kNotificationMessage[] = "My Message";
const char16_t kNotificationTitle[] = u"My Title";
const char16_t kNotificationMessage[] = u"My Message";
const char kNotificationOrigin[] = "https://example.com";
base::Time FixedTime() {
@ -67,8 +67,7 @@ class NotificationTemplateBuilderTest : public ::testing::Test {
GURL origin_url(kNotificationOrigin);
message_center::Notification notification(
message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId,
base::UTF8ToUTF16(kNotificationTitle),
base::UTF8ToUTF16(kNotificationMessage), gfx::Image() /* icon */,
kNotificationTitle, kNotificationMessage, gfx::Image() /* icon */,
std::u16string() /* display_source */, origin_url,
NotifierId(origin_url), RichNotificationData(), nullptr /* delegate */);
// Set a fixed timestamp, to avoid having to test against current timestamp.

@ -37,6 +37,7 @@ namespace {
constexpr char kGaiaUsername[] = "username";
constexpr char16_t kGaiaUsername16[] = u"username";
constexpr char kGaiaEmail[] = "username@gmail.com";
constexpr char16_t kGaiaEmail16[] = u"username@gmail.com";
constexpr char kGaiaId[] = "test_gaia_id";
} // namespace
@ -102,7 +103,7 @@ void PasswordManagerSigninInterceptTestHelper::SetupProfilesForInterception(
params.profile_path = profile_path;
params.profile_name = u"TestProfileName";
params.gaia_id = kGaiaId;
params.user_name = base::UTF8ToUTF16(kGaiaEmail);
params.user_name = kGaiaEmail16;
profile_storage->AddProfile(std::move(params));
// Check that the signin qualifies for interception.

@ -215,9 +215,8 @@ class ContextMenuBrowserTest : public InProcessBrowserTest {
auto web_app_info = std::make_unique<WebApplicationInfo>();
web_app_info->start_url = start_url;
web_app_info->scope = start_url;
web_app_info->title = base::UTF8ToUTF16("Test app \xF0\x9F\x90\x90");
web_app_info->description =
base::UTF8ToUTF16("Test description \xF0\x9F\x90\x90");
web_app_info->title = u"Test app 🐐";
web_app_info->description = u"Test description 🐐";
web_app_info->open_as_window = open_as_window;
return web_app::test::InstallWebApp(browser()->profile(),

@ -31,8 +31,6 @@
namespace {
using base::ASCIIToUTF16;
constexpr int32_t kRequestID = 10;
bool GetTestFilePath(const std::string& file_name, base::FilePath* path) {
@ -299,8 +297,7 @@ TEST_F(TemplateURLFetcherTest, UnicodeTest) {
WaitForDownloadToFinish();
const TemplateURL* t_url =
test_util()->model()->GetTemplateURLForKeyword(keyword);
EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"),
t_url->short_name());
EXPECT_EQ(u"тест", t_url->short_name());
}
} // namespace

@ -34,10 +34,8 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::ASCIIToUTF16;
using base::Time;
using base::TimeDelta;
using base::UTF8ToUTF16;
using testing::NotNull;
namespace {
@ -971,9 +969,8 @@ TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordMigrated) {
GURL google_url(model()->search_terms_data().GoogleBaseURLValue());
TemplateURL* guid2 = model()->GetTemplateURLForHost(google_url.host());
ASSERT_THAT(guid2, NotNull());
std::u16string google_keyword(
base::ASCIIToUTF16(url_formatter::StripWWW(google_url.host())));
EXPECT_EQ(google_keyword, guid2->keyword());
std::string google_keyword(url_formatter::StripWWW(google_url.host()));
EXPECT_EQ(base::ASCIIToUTF16(google_keyword), guid2->keyword());
// We should also have gotten some corresponding UPDATEs pushed upstream.
EXPECT_GE(processor()->change_list_size(), 2U);
@ -984,18 +981,19 @@ TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordMigrated) {
ASSERT_TRUE(processor()->contains_guid("guid2"));
syncer::SyncChange guid2_change = processor()->change_for_guid("guid2");
EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, guid2_change.change_type());
EXPECT_EQ(google_keyword, UTF8ToUTF16(GetKeyword(guid2_change.sync_data())));
EXPECT_EQ(google_keyword, GetKeyword(guid2_change.sync_data()));
}
TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordConflicts) {
// Sync brings in some autogenerated keywords, but the generated keywords we
// try to create conflict with ones in the model.
std::u16string google_keyword(base::ASCIIToUTF16(url_formatter::StripWWW(
GURL(model()->search_terms_data().GoogleBaseURLValue()).host())));
std::string google_keyword(url_formatter::StripWWW(
GURL(model()->search_terms_data().GoogleBaseURLValue()).host()));
std::u16string google_keyword16(base::ASCIIToUTF16(google_keyword));
const std::string local_google_url =
"{google:baseURL}1/search?q={searchTerms}";
TemplateURL* google =
model()->Add(CreateTestTemplateURL(google_keyword, local_google_url));
model()->Add(CreateTestTemplateURL(google_keyword16, local_google_url));
TemplateURL* other =
model()->Add(CreateTestTemplateURL(u"other.com", "http://other.com/foo"));
syncer::SyncDataList initial_data;
@ -1024,7 +1022,8 @@ TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordConflicts) {
// the sync TemplateURLs (GUIDs transferred over).
EXPECT_FALSE(model()->GetTemplateURLForGUID(local_google_guid));
ASSERT_TRUE(model()->GetTemplateURLForGUID("sync1"));
EXPECT_EQ(google_keyword, model()->GetTemplateURLForGUID("sync1")->keyword());
EXPECT_EQ(google_keyword16,
model()->GetTemplateURLForGUID("sync1")->keyword());
EXPECT_FALSE(model()->GetTemplateURLForGUID(local_other_guid));
ASSERT_TRUE(model()->GetTemplateURLForGUID("sync2"));
EXPECT_EQ(u"other.com", model()->GetTemplateURLForGUID("sync2")->keyword());
@ -1035,7 +1034,7 @@ TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordConflicts) {
ASSERT_TRUE(processor()->contains_guid("sync1"));
syncer::SyncChange sync1_change = processor()->change_for_guid("sync1");
EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, sync1_change.change_type());
EXPECT_EQ(google_keyword, UTF8ToUTF16(GetKeyword(sync1_change.sync_data())));
EXPECT_EQ(google_keyword, GetKeyword(sync1_change.sync_data()));
EXPECT_EQ(local_google_url, GetURL(sync1_change.sync_data()));
ASSERT_TRUE(processor()->contains_guid("sync2"));
syncer::SyncChange sync2_change = processor()->change_for_guid("sync2");
@ -1765,7 +1764,8 @@ TEST_F(TemplateURLServiceSyncTest, PreSyncDeletes) {
}
TEST_F(TemplateURLServiceSyncTest, PreSyncUpdates) {
const char* kNewKeyword = "somethingnew";
const char kNewKeyword[] = "somethingnew";
const char16_t kNewKeyword16[] = u"somethingnew";
// Fetch the prepopulate search engines so we know what they are.
std::vector<std::unique_ptr<TemplateURLData>> prepop_turls =
TemplateURLPrepopulateData::GetPrepopulatedEngines(
@ -1780,7 +1780,7 @@ TEST_F(TemplateURLServiceSyncTest, PreSyncUpdates) {
TemplateURLData data_copy(*prepop_turls[0]);
data_copy.last_modified = Time::FromTimeT(10);
std::u16string original_keyword = data_copy.keyword();
data_copy.SetKeyword(ASCIIToUTF16(kNewKeyword));
data_copy.SetKeyword(kNewKeyword16);
// Set safe_for_autoreplace to false so our keyword survives.
data_copy.safe_for_autoreplace = false;
model()->Add(std::make_unique<TemplateURL>(data_copy));
@ -1792,8 +1792,7 @@ TEST_F(TemplateURLServiceSyncTest, PreSyncUpdates) {
// The newly added search engine should have been safely merged, with an
// updated time.
TemplateURL* added_turl = model()->GetTemplateURLForKeyword(
ASCIIToUTF16(kNewKeyword));
TemplateURL* added_turl = model()->GetTemplateURLForKeyword(kNewKeyword16);
ASSERT_TRUE(added_turl);
base::Time new_timestamp = added_turl->last_modified();
EXPECT_GE(new_timestamp, pre_merge_time);
@ -1818,8 +1817,7 @@ TEST_F(TemplateURLServiceSyncTest, PreSyncUpdates) {
EXPECT_EQ(prepop_turls.size(),
model()->GetAllSyncData(syncer::SEARCH_ENGINES).size());
ASSERT_EQ(added_turl, model()->GetTemplateURLForKeyword(
ASCIIToUTF16(kNewKeyword)));
ASSERT_EQ(added_turl, model()->GetTemplateURLForKeyword(kNewKeyword16));
EXPECT_EQ(new_timestamp, added_turl->last_modified());
syncer::SyncChange change = processor()->change_for_guid(sync_guid);
EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, change.change_type());
@ -2548,7 +2546,6 @@ TEST_F(TemplateURLServiceSyncTest, GUIDUpdatedOnDefaultSearchChange) {
}
TEST_F(TemplateURLServiceSyncTest, NonAsciiKeywordDoesNotCrash) {
model()->Add(CreateTestTemplateURL(UTF8ToUTF16("\xf0\xaf\xa6\x8d"),
"http://key1.com"));
model()->Add(CreateTestTemplateURL(u"\U0002f98d", "http://key1.com"));
MergeAndExpectNotify(CreateInitialSyncData(), 1);
}

@ -33,7 +33,7 @@ using ::testing::Property;
namespace {
const char kText[] = "Text to be copied";
const char16_t kText[] = u"Text to be copied";
const char kExpectedText[] = "Text to be copied";
const char kReceiverGuid[] = "test_receiver_guid";
const char kReceiverName[] = "test_receiver_name";
@ -54,7 +54,7 @@ class SharedClipboardUiControllerTest : public testing::Test {
CreateFakeDeviceInfo(kReceiverGuid, kReceiverName);
controller_ = SharedClipboardUiController::GetOrCreateFromWebContents(
web_contents_.get());
controller_->OnDeviceSelected(base::UTF8ToUTF16(kText), *device_info.get());
controller_->OnDeviceSelected(kText, *device_info.get());
}
protected:

@ -29,7 +29,7 @@
namespace {
const char kProfileTestName[] = "profile_test_name";
const char16_t kProfileTestName[] = u"profile_test_name";
std::unique_ptr<TestingProfile> BuildTestingProfile(const base::FilePath& path,
Profile::Delegate* delegate,
@ -165,12 +165,11 @@ TEST_P(DiceSignedInProfileCreatorTest, CreateWithTokensLoaded) {
AccountInfo account_info =
identity_test_env()->MakeAccountAvailable("bob@example.com");
size_t kTestIcon = profiles::GetModernAvatarIconStartIndex();
std::u16string kProfileTestName16 = base::UTF8ToUTF16(kProfileTestName);
base::RunLoop loop;
std::unique_ptr<DiceSignedInProfileCreator> creator =
std::make_unique<DiceSignedInProfileCreator>(
profile(), account_info.account_id, kProfileTestName16, kTestIcon,
profile(), account_info.account_id, kProfileTestName, kTestIcon,
use_guest_profile(),
base::BindOnce(&DiceSignedInProfileCreatorTest::OnProfileCreated,
base::Unretained(this), loop.QuitClosure()));
@ -201,7 +200,7 @@ TEST_P(DiceSignedInProfileCreatorTest, CreateWithTokensLoaded) {
ASSERT_TRUE(entry);
ASSERT_EQ(entry->IsGuest(), use_guest_profile());
if (!use_guest_profile()) {
EXPECT_EQ(kProfileTestName16, entry->GetLocalProfileName());
EXPECT_EQ(kProfileTestName, entry->GetLocalProfileName());
EXPECT_EQ(kTestIcon, entry->GetAvatarIconIndex());
}
}

@ -35,6 +35,7 @@
#include "testing/gtest/include/gtest/gtest.h"
static const char kTestEmail[] = "testuser@test.com";
static const char16_t kTestEmail16[] = u"testuser@test.com";
class SigninGlobalErrorTest : public testing::Test {
public:
@ -64,7 +65,7 @@ class SigninGlobalErrorTest : public testing::Test {
->GetProfileAttributesWithPath(profile()->GetPath());
ASSERT_NE(entry, nullptr);
entry->SetAuthInfo(account_info.gaia, base::UTF8ToUTF16(kTestEmail),
entry->SetAuthInfo(account_info.gaia, kTestEmail16,
/*is_consented_primary_account=*/true);
global_error_ = SigninGlobalErrorFactory::GetForProfile(profile());

@ -139,6 +139,7 @@ const char kCreateBlobUrlJavascript[] =
enum CertificateStatus { VALID_CERTIFICATE, INVALID_CERTIFICATE };
const char kTestCertificateIssuerName[] = "Test Root CA";
const char16_t kTestCertificateIssuerName16[] = u"Test Root CA";
bool IsShowingInterstitial(content::WebContents* tab) {
security_interstitials::SecurityInterstitialTabHelper* helper =
@ -294,10 +295,9 @@ void CheckSecureCertificateExplanation(
expected_cert->issuer().GetDisplayName());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_VALID_SERVER_CERTIFICATE),
explanation.summary);
EXPECT_EQ(
l10n_util::GetStringFUTF8(IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION,
base::UTF8ToUTF16(kTestCertificateIssuerName)),
explanation.description);
EXPECT_EQ(l10n_util::GetStringFUTF8(IDS_VALID_SERVER_CERTIFICATE_DESCRIPTION,
kTestCertificateIssuerName16),
explanation.description);
net::X509Certificate* cert = browser->tab_strip_model()
->GetActiveWebContents()
->GetController()

@ -7278,6 +7278,7 @@ IN_PROC_BROWSER_TEST_F(SSLUICaptivePortalListResourceBundleTest,
namespace {
char kTestMITMSoftwareName[] = "Misconfigured Firewall";
char16_t kTestMITMSoftwareName16[] = u"Misconfigured Firewall";
class SSLUIMITMSoftwareTest : public CertVerifierBrowserTest {
public:
@ -7671,12 +7672,12 @@ IN_PROC_BROWSER_TEST_F(SSLUIMITMSoftwareEnabledTest, EnterpriseManaged) {
SetUpMITMSoftwareCertList(kLargeVersionId);
TestMITMSoftwareInterstitial();
const std::string expected_primary_paragraph = l10n_util::GetStringFUTF8(
IDS_MITM_SOFTWARE_PRIMARY_PARAGRAPH_ENTERPRISE,
net::EscapeForHTML(base::UTF8ToUTF16(kTestMITMSoftwareName)));
const std::string expected_primary_paragraph =
l10n_util::GetStringFUTF8(IDS_MITM_SOFTWARE_PRIMARY_PARAGRAPH_ENTERPRISE,
net::EscapeForHTML(kTestMITMSoftwareName16));
const std::string expected_explanation = l10n_util::GetStringFUTF8(
IDS_MITM_SOFTWARE_EXPLANATION_ENTERPRISE,
net::EscapeForHTML(base::UTF8ToUTF16(kTestMITMSoftwareName)),
net::EscapeForHTML(kTestMITMSoftwareName16),
l10n_util::GetStringUTF16(IDS_MITM_SOFTWARE_EXPLANATION));
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
@ -7699,7 +7700,7 @@ IN_PROC_BROWSER_TEST_F(SSLUIMITMSoftwareEnabledTest, NotEnterpriseManaged) {
// has escaped HTML characters which throw an error.
const std::string expected_explanation = l10n_util::GetStringFUTF8(
IDS_MITM_SOFTWARE_EXPLANATION_NONENTERPRISE,
net::EscapeForHTML(base::UTF8ToUTF16(kTestMITMSoftwareName)),
net::EscapeForHTML(kTestMITMSoftwareName16),
l10n_util::GetStringUTF16(IDS_MITM_SOFTWARE_EXPLANATION));
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();

@ -40,7 +40,9 @@ namespace {
const int kDefaultCardExpMonth = 8;
const int kDefaultCardExpYear = 2087;
const char kDefaultCardLastFour[] = "1234";
const char16_t kDefaultCardLastFour16[] = u"1234";
const char kDefaultCardName[] = "Patrick Valenzuela";
const char16_t kDefaultCardName16[] = u"Patrick Valenzuela";
const sync_pb::WalletMaskedCreditCard_WalletCardType kDefaultCardType =
sync_pb::WalletMaskedCreditCard::AMEX;
@ -405,17 +407,11 @@ sync_pb::SyncEntity CreateDefaultSyncPaymentsCustomerData() {
}
CreditCard GetDefaultCreditCard() {
return GetCreditCard(kDefaultCardID, kDefaultCardLastFour);
}
autofill::CreditCard GetCreditCard(const std::string& name,
const std::string& last_four) {
CreditCard card(CreditCard::MASKED_SERVER_CARD, name);
CreditCard card(CreditCard::MASKED_SERVER_CARD, kDefaultCardID);
card.SetExpirationMonth(kDefaultCardExpMonth);
card.SetExpirationYear(kDefaultCardExpYear);
card.SetNumber(base::UTF8ToUTF16(last_four));
card.SetRawInfo(autofill::CREDIT_CARD_NAME_FULL,
base::UTF8ToUTF16(kDefaultCardName));
card.SetNumber(kDefaultCardLastFour16);
card.SetRawInfo(autofill::CREDIT_CARD_NAME_FULL, kDefaultCardName16);
card.SetServerStatus(CreditCard::OK);
card.SetNetworkForMaskedCard(autofill::kAmericanExpressCard);
card.set_billing_address_id(kDefaultBillingAddressID);
@ -489,11 +485,11 @@ sync_pb::SyncEntity CreateDefaultSyncCreditCardCloudTokenData() {
void ExpectDefaultCreditCardValues(const CreditCard& card) {
EXPECT_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type());
EXPECT_EQ(kDefaultCardID, card.server_id());
EXPECT_EQ(base::UTF8ToUTF16(kDefaultCardLastFour), card.LastFourDigits());
EXPECT_EQ(kDefaultCardLastFour16, card.LastFourDigits());
EXPECT_EQ(autofill::kAmericanExpressCard, card.network());
EXPECT_EQ(kDefaultCardExpMonth, card.expiration_month());
EXPECT_EQ(kDefaultCardExpYear, card.expiration_year());
EXPECT_EQ(base::UTF8ToUTF16(kDefaultCardName),
EXPECT_EQ(kDefaultCardName16,
card.GetRawInfo(autofill::ServerFieldType::CREDIT_CARD_NAME_FULL));
EXPECT_EQ(kDefaultBillingAddressID, card.billing_address_id());
}

@ -18,10 +18,10 @@ IN_PROC_BROWSER_TEST_F(LanguageDetectionServiceTest,
DetermineLanguageReliable) {
mojo::Remote<language_detection::mojom::LanguageDetectionService> service =
language_detection::LaunchLanguageDetectionService();
std::u16string text = base::UTF8ToUTF16(
"El niño atrapó un dorado muy grande con cebo vivo. Fileteó el "
"pescado y lo asó a la parrilla. Sabía excelente. Espera pescar otro "
"buen pescado mañana.");
std::u16string text =
u"El niño atrapó un dorado muy grande con cebo vivo. Fileteó el "
u"pescado y lo asó a la parrilla. Sabía excelente. Espera pescar otro "
u"buen pescado mañana.";
base::RunLoop run_loop;
service->DetermineLanguage(

@ -1220,7 +1220,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BackspaceDeleteHalfWidthKatakana) {
// Insert text: ダ. This is two, 3-byte UTF-8 characters:
// U+FF80 "HALFWIDTH KATAKANA LETTER TA" and
// U+FF9E "HALFWIDTH KATAKANA VOICED SOUND MARK".
omnibox_view->SetUserText(base::UTF8ToUTF16("\357\276\200\357\276\236"));
omnibox_view->SetUserText(u"\uFF80\uFF9E");
EXPECT_FALSE(omnibox_view->GetText().empty());
// Move the cursor to the end.
@ -1236,7 +1236,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BackspaceDeleteHalfWidthKatakana) {
EXPECT_TRUE(omnibox_view->GetText().empty());
#else
// Toolkit-views text fields delete just the sound mark.
EXPECT_EQ(base::UTF8ToUTF16("\357\276\200"), omnibox_view->GetText());
EXPECT_EQ(u"\uFF80", omnibox_view->GetText());
#endif
}

@ -149,7 +149,7 @@ namespace {
#if !BUILDFLAG(IS_CHROMEOS_ASH)
const char kAppId[] = "dofnemchnjfeendjmdhaldenaiabpiad";
const char kAppName[] = "Test App";
const char16_t kAppName[] = u"Test App";
const char kStartUrl[] = "https://test.com";
// Check that there are two browsers. Find the one that is not |browser|.
@ -1341,7 +1341,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserWithWebAppTest,
base::RunLoop run_loop;
WebApplicationInfo info;
info.start_url = GURL(kStartUrl);
info.title = base::UTF8ToUTF16(kAppName);
info.title = kAppName;
info.open_as_window = true;
web_app_finalizer.FinalizeInstall(
info, options,
@ -1445,7 +1445,7 @@ class StartupBrowserWebAppUrlHandlingTest : public InProcessBrowserTest {
std::unique_ptr<WebApplicationInfo> info =
std::make_unique<WebApplicationInfo>();
info->start_url = GURL(kStartUrl);
info->title = base::UTF8ToUTF16(kAppName);
info->title = kAppName;
info->open_as_window = true;
info->url_handlers = url_handlers;
web_app::AppId app_id =
@ -1586,7 +1586,7 @@ class StartupBrowserWebAppProtocolHandlingTest : public InProcessBrowserTest {
std::unique_ptr<WebApplicationInfo> info =
std::make_unique<WebApplicationInfo>();
info->start_url = GURL(kStartUrl);
info->title = base::UTF8ToUTF16(kAppName);
info->title = kAppName;
info->open_as_window = true;
info->protocol_handlers = protocol_handlers;
web_app::AppId app_id =

@ -34,11 +34,12 @@ namespace {
constexpr char kSinkId[] = "sink_id";
constexpr char kSinkFriendlyName[] = "Nest Hub";
constexpr char16_t kSinkFriendlyName16[] = u"Nest Hub";
UIMediaSink CreateMediaSink(
UIMediaSinkState state = UIMediaSinkState::AVAILABLE) {
UIMediaSink sink;
sink.friendly_name = base::UTF8ToUTF16(kSinkFriendlyName);
sink.friendly_name = kSinkFriendlyName16;
sink.id = kSinkId;
sink.state = state;
sink.cast_modes = {media_router::MediaCastMode::PRESENTATION};

@ -75,8 +75,8 @@ namespace {
enum class ForceEphemeralProfilesPolicy { kUnset, kEnabled, kDisabled };
const SkColor kProfileColor = SK_ColorRED;
const char kWork[] = "Work";
const char kOriginalProfileName[] = "OriginalProfile";
const char16_t kWork[] = u"Work";
const char16_t kOriginalProfileName[] = u"OriginalProfile";
AccountInfo FillAccountInfo(
const CoreAccountInfo& core_info,
@ -654,7 +654,7 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
ASSERT_NE(entry, nullptr);
EXPECT_FALSE(entry->IsEphemeral());
EXPECT_FALSE(entry->IsAuthenticated());
EXPECT_EQ(entry->GetLocalProfileName(), base::UTF8ToUTF16(kWork));
EXPECT_EQ(entry->GetLocalProfileName(), kWork);
// The color is not applied if the user enters the SAML flow.
EXPECT_FALSE(ThemeServiceFactory::GetForProfile(profile_being_created)
->UsingAutogeneratedTheme());
@ -1444,11 +1444,11 @@ class ProfilePickerCreationFlowEphemeralProfileBrowserTest
}
// Checks if a profile matching `name` exists in the profile manager.
bool ProfileWithNameExists(const std::string& name) {
bool ProfileWithNameExists(const std::u16string& name) {
for (const auto* entry : profile_manager()
->GetProfileAttributesStorage()
.GetAllProfilesAttributes()) {
if (entry->GetLocalProfileName() == base::UTF8ToUTF16(name))
if (entry->GetLocalProfileName() == name)
return true;
}
return false;
@ -1491,7 +1491,7 @@ class ProfilePickerCreationFlowEphemeralProfileBrowserTest
->GetProfileAttributesStorage()
.GetProfileAttributesWithPath(browser()->profile()->GetPath());
ASSERT_NE(entry, nullptr);
entry->SetLocalProfileName(base::UTF8ToUTF16(kOriginalProfileName),
entry->SetLocalProfileName(kOriginalProfileName,
entry->IsUsingDefaultName());
}
CheckPolicyApplied(browser()->profile());
@ -1549,14 +1549,14 @@ IN_PROC_BROWSER_TEST_P(ProfilePickerCreationFlowEphemeralProfileBrowserTest,
// If the policy is set, all profiles should have been deleted.
EXPECT_EQ(1u, profile_manager()->GetNumberOfProfiles());
// The current profile is not the one that was created in the previous run.
EXPECT_FALSE(ProfileWithNameExists("Joe"));
EXPECT_FALSE(ProfileWithNameExists(u"Joe"));
EXPECT_FALSE(OriginalProfileExists());
return;
}
// If the policy is disabled or unset, the two profiles are still here.
EXPECT_EQ(2u, profile_manager()->GetNumberOfProfiles());
EXPECT_TRUE(ProfileWithNameExists("Joe"));
EXPECT_TRUE(ProfileWithNameExists(u"Joe"));
EXPECT_TRUE(OriginalProfileExists());
}

@ -65,8 +65,8 @@ WebAuthnBubbleView::~WebAuthnBubbleView() = default;
std::u16string WebAuthnBubbleView::GetWindowTitle() const {
// TODO(crbug.com/1179014): go through ux review and i18n this string.
return base::UTF8ToUTF16(users_.empty() ? "Sign in with your security key"
: "Choose an account to sign in");
return users_.empty() ? u"Sign in with your security key"
: u"Choose an account to sign in";
}
void WebAuthnBubbleView::Init() {
@ -75,8 +75,7 @@ void WebAuthnBubbleView::Init() {
if (users_.empty()) {
// TODO(crbug.com/1179014): go through ux review and i18n this string.
std::u16string label_text = base::ReplaceStringPlaceholders(
base::UTF8ToUTF16(
"To sign in to $1 with your security key, insert it and tap it"),
u"To sign in to $1 with your security key, insert it and tap it",
webauthn_ui_helpers::RpIdToElidedHost(relying_party_id_, fixed_width()),
/*offset=*/nullptr);
auto label = std::make_unique<views::Label>(

@ -85,6 +85,7 @@
namespace {
constexpr const char kExampleURL[] = "http://example.org/";
constexpr const char16_t kExampleURL16[] = u"http://example.org/";
constexpr const char kExampleManifestURL[] = "http://example.org/manifest";
constexpr char kLaunchWebAppDisplayModeHistogram[] = "Launch.WebAppDisplayMode";
@ -672,7 +673,7 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, CopyURL) {
std::u16string result;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, /* data_dst = */ nullptr,
&result);
EXPECT_EQ(result, base::UTF8ToUTF16(kExampleURL));
EXPECT_EQ(result, kExampleURL16);
}
// Tests that the command for popping a tab out to a PWA window is disabled in
@ -985,8 +986,7 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, InstallToShelfContainsAppName) {
EXPECT_TRUE(app_menu_model->GetModelAndIndexForCommandId(IDC_INSTALL_PWA,
&model, &index));
EXPECT_EQ(app_menu_model.get(), model);
EXPECT_EQ(model->GetLabelAt(index),
base::UTF8ToUTF16("Install Manifest test app\xE2\x80\xA6"));
EXPECT_EQ(model->GetLabelAt(index), u"Install Manifest test app…");
}
// Check that no assertions are hit when showing a permission request bubble.

@ -92,14 +92,12 @@ CastFeedbackUI::CastFeedbackUI(content::WebUI* web_ui)
"formDescription",
l10n_util::GetStringFUTF8(
IDS_MEDIA_ROUTER_FEEDBACK_FORM_DESCRIPTION,
base::UTF8ToUTF16("https://support.google.com/"
"chromecast?p=troubleshoot_chromecast")));
u"https://support.google.com/chromecast?p=troubleshoot_chromecast"));
source->AddString(
"setupVisibilityQuestion",
l10n_util::GetStringFUTF8(
IDS_MEDIA_ROUTER_FEEDBACK_SETUP_VISIBILITY_QUESTION,
base::UTF8ToUTF16(
"https://support.google.com/chromecast?p=set_up_chromecast")));
u"https://support.google.com/chromecast?p=set_up_chromecast"));
// TODO(jrw): Attach real log data.
source->AddString("logData", "dummy log data");

@ -91,10 +91,9 @@ namespace printing {
namespace {
#if defined(OS_MAC)
// U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8
const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29";
const char16_t kBasicPrintShortcut[] = u"\u0028\u21e7\u2318\u0050\u0029";
#elif !BUILDFLAG(IS_CHROMEOS_ASH)
const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)";
const char16_t kBasicPrintShortcut[] = u"(Ctrl+Shift+P)";
#endif
constexpr char kInvalidArgsForDidStartPreview[] =
@ -380,7 +379,7 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
chrome::kCloudPrintCertificateErrorLearnMoreURL);
#if !BUILDFLAG(IS_CHROMEOS_ASH)
const std::u16string shortcut_text(base::UTF8ToUTF16(kBasicPrintShortcut));
const std::u16string shortcut_text(kBasicPrintShortcut);
source->AddString("systemDialogOption",
l10n_util::GetStringFUTF16(
IDS_PRINT_PREVIEW_SYSTEM_DIALOG_OPTION, shortcut_text));

@ -37,7 +37,7 @@ namespace web_app {
namespace {
const char kFooTitle[] = "Foo Title";
const char16_t kFooTitle[] = u"Foo Title";
} // namespace
@ -130,23 +130,6 @@ class WebAppDataRetrieverTest : public ChromeRenderViewHostTestHarness {
std::move(quit_closure).Run();
}
std::unique_ptr<WebApplicationInfo> CreateWebApplicationInfo(
const GURL& url,
const std::string name,
const std::string description,
const GURL& scope,
base::Optional<SkColor> theme_color) {
auto web_app_info = std::make_unique<WebApplicationInfo>();
web_app_info->start_url = url;
web_app_info->title = base::UTF8ToUTF16(name);
web_app_info->description = base::UTF8ToUTF16(description);
web_app_info->scope = scope;
web_app_info->theme_color = theme_color;
return web_app_info;
}
protected:
content::WebContentsTester* web_contents_tester() {
return content::WebContentsTester::For(web_contents());
@ -228,8 +211,7 @@ TEST_F(WebAppDataRetrieverTest, GetWebApplicationInfo_TitleAbsentFromRenderer) {
web_contents_tester()->NavigateAndCommit(GURL("https://foo.example"));
const auto web_contents_title = base::UTF8ToUTF16(kFooTitle);
web_contents_tester()->SetTitle(web_contents_title);
web_contents_tester()->SetTitle(kFooTitle);
WebApplicationInfo original_web_app_info;
original_web_app_info.title = u"";
@ -246,7 +228,7 @@ TEST_F(WebAppDataRetrieverTest, GetWebApplicationInfo_TitleAbsentFromRenderer) {
// If the WebApplicationInfo has no title, we fallback to the WebContents
// title.
EXPECT_EQ(web_contents_title, web_app_info()->title);
EXPECT_EQ(kFooTitle, web_app_info()->title);
}
TEST_F(WebAppDataRetrieverTest,
@ -362,8 +344,7 @@ TEST_F(WebAppDataRetrieverTest, GetIcons_WebContentsDestroyed) {
TEST_F(WebAppDataRetrieverTest, GetWebApplicationInfo_FrameNavigated) {
SetFakeWebPageMetadataAgent();
const auto web_contents_title = base::UTF8ToUTF16(kFooTitle);
web_contents_tester()->SetTitle(web_contents_title);
web_contents_tester()->SetTitle(kFooTitle);
const GURL kFooUrl("https://foo.example/bar");
web_contents_tester()->NavigateAndCommit(kFooUrl.GetOrigin());
@ -378,7 +359,7 @@ TEST_F(WebAppDataRetrieverTest, GetWebApplicationInfo_FrameNavigated) {
run_loop.Run();
EXPECT_EQ(kFooUrl.GetOrigin(), web_app_info()->start_url);
EXPECT_EQ(web_contents_title, web_app_info()->title);
EXPECT_EQ(kFooTitle, web_app_info()->title);
}
TEST_F(WebAppDataRetrieverTest, CheckInstallabilityAndRetrieveManifest) {

@ -28,8 +28,8 @@ namespace {
const char16_t kAppShortName[] = u"Test short name";
const char16_t kAppTitle[] = u"Test title";
const char kAlternativeAppTitle[] = "Different test title";
const char kShortcutItemName[] = "shortcut item ";
const char16_t kAlternativeAppTitle[] = u"Different test title";
const char16_t kShortcutItemName[] = u"shortcut item ";
constexpr SquareSizePx kIconSize = 64;
@ -51,7 +51,7 @@ class WebAppInstallUtilsWithShortcutsMenu : public testing::Test {
TEST(WebAppInstallUtils, UpdateWebAppInfoFromManifest) {
WebApplicationInfo web_app_info;
web_app_info.title = base::UTF8ToUTF16(kAlternativeAppTitle);
web_app_info.title = kAlternativeAppTitle;
web_app_info.start_url = GURL("http://www.notchromium.org");
WebApplicationIconInfo info;
const GURL kAppIcon1("fav1.png");
@ -289,7 +289,7 @@ TEST(WebAppInstallUtils, UpdateWebAppInfoFromManifest_ShareTarget) {
TEST_F(WebAppInstallUtilsWithShortcutsMenu,
UpdateWebAppInfoFromManifestWithShortcuts) {
WebApplicationInfo web_app_info;
web_app_info.title = base::UTF8ToUTF16(kAlternativeAppTitle);
web_app_info.title = kAlternativeAppTitle;
web_app_info.start_url = GURL("http://www.notchromium.org");
WebApplicationIconInfo info;
const GURL kAppIcon1("fav1.png");
@ -300,9 +300,8 @@ TEST_F(WebAppInstallUtilsWithShortcutsMenu,
for (int i = 0; i < 3; ++i) {
WebApplicationShortcutsMenuItemInfo shortcuts_menu_item_info;
WebApplicationShortcutsMenuItemInfo::Icon icon;
std::string shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(i + 1);
shortcuts_menu_item_info.name = base::UTF8ToUTF16(shortcut_name);
shortcuts_menu_item_info.name =
kShortcutItemName + base::NumberToString16(i + 1);
shortcuts_menu_item_info.url = kShortcutItemUrl;
icon.url = GURL("http://www.chromium.org/shortcuts/icon1.png");
@ -386,9 +385,7 @@ TEST_F(WebAppInstallUtilsWithShortcutsMenu,
// Test that shortcuts in the manifest replace those in |web_app_info|.
blink::Manifest::ShortcutItem shortcut_item;
std::string shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(4);
shortcut_item.name = base::UTF8ToUTF16(shortcut_name);
shortcut_item.name = std::u16string(kShortcutItemName) + u"4";
shortcut_item.url = kShortcutItemUrl;
const GURL kIconUrl2("http://www.chromium.org/shortcuts/icon2.png");
@ -399,9 +396,7 @@ TEST_F(WebAppInstallUtilsWithShortcutsMenu,
manifest.shortcuts.push_back(shortcut_item);
shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(5);
shortcut_item.name = base::UTF8ToUTF16(shortcut_name);
shortcut_item.name = std::u16string(kShortcutItemName) + u"5";
const GURL kIconUrl3("http://www.chromium.org/shortcuts/icon3.png");
icon.src = kIconUrl3;
@ -480,9 +475,7 @@ TEST_F(WebAppInstallUtilsWithShortcutsMenu,
blink::Manifest manifest;
for (unsigned int i = 0; i < kNumTestIcons; ++i) {
blink::Manifest::ShortcutItem shortcut_item;
std::string shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(i);
shortcut_item.name = base::UTF8ToUTF16(shortcut_name);
shortcut_item.name = kShortcutItemName + base::NumberToString16(i);
shortcut_item.url = GURL("http://www.chromium.org/shortcuts/action");
blink::Manifest::ImageResource icon;
@ -536,9 +529,7 @@ TEST_F(WebAppInstallUtilsWithShortcutsMenu,
blink::Manifest manifest;
for (int i = 1; i <= 20; ++i) {
blink::Manifest::ShortcutItem shortcut_item;
std::string shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(i);
shortcut_item.name = base::UTF8ToUTF16(shortcut_name);
shortcut_item.name = kShortcutItemName + base::NumberToString16(i);
shortcut_item.url = GURL("http://www.chromium.org/shortcuts/action");
blink::Manifest::ImageResource icon;
@ -574,9 +565,7 @@ TEST(WebAppInstallUtils, PopulateShortcutItemIcons) {
{
WebApplicationShortcutsMenuItemInfo shortcut_item;
std::vector<WebApplicationShortcutsMenuItemInfo::Icon> shortcut_icon_infos;
std::string shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(1);
shortcut_item.name = base::UTF8ToUTF16(shortcut_name);
shortcut_item.name = std::u16string(kShortcutItemName) + u"1";
shortcut_item.url = GURL("http://www.chromium.org/shortcuts/action");
icon.url = kIconUrl1;
icon.square_size_px = kIconSize;
@ -590,9 +579,7 @@ TEST(WebAppInstallUtils, PopulateShortcutItemIcons) {
{
WebApplicationShortcutsMenuItemInfo shortcut_item;
std::vector<WebApplicationShortcutsMenuItemInfo::Icon> shortcut_icon_infos;
std::string shortcut_name = kShortcutItemName;
shortcut_name += base::NumberToString(2);
shortcut_item.name = base::UTF8ToUTF16(shortcut_name);
shortcut_item.name = std::u16string(kShortcutItemName) + u"2";
icon.url = kIconUrl1;
icon.square_size_px = kIconSize;
shortcut_icon_infos.push_back(icon);
@ -773,7 +760,7 @@ TEST_F(WebAppInstallUtilsWithShortcutsMenu,
// Construct |shortcuts_menu_item_info| to add to
// |web_app_info.shortcuts_menu_item_infos|.
WebApplicationShortcutsMenuItemInfo shortcuts_menu_item_info;
shortcuts_menu_item_info.name = base::UTF8ToUTF16(kShortcutItemName);
shortcuts_menu_item_info.name = kShortcutItemName;
shortcuts_menu_item_info.url =
GURL("http://www.chromium.org/shortcuts/action");
// Construct |icon| to add to |shortcuts_menu_item_info.shortcut_icon_infos|.

@ -25,7 +25,7 @@ namespace web_app {
namespace {
constexpr char kAppTitle[] = {"app"};
constexpr char16_t kAppTitle[] = u"app";
} // namespace
class WebAppRunOnOsLoginWinTest : public WebAppTest {
@ -42,7 +42,7 @@ class WebAppRunOnOsLoginWinTest : public WebAppTest {
std::unique_ptr<ShortcutInfo> GetShortcutInfo() {
auto shortcut_info = std::make_unique<ShortcutInfo>();
shortcut_info->extension_id = "app-id";
shortcut_info->title = base::UTF8ToUTF16(kAppTitle);
shortcut_info->title = kAppTitle;
shortcut_info->profile_path = profile()->GetPath();
gfx::ImageFamily image_family;
@ -64,7 +64,7 @@ class WebAppRunOnOsLoginWinTest : public WebAppTest {
std::vector<base::FilePath> GetShortcuts() {
return internals::FindAppShortcutsByProfileAndTitle(
GetStartupFolder(), profile()->GetPath(), base::UTF8ToUTF16(kAppTitle));
GetStartupFolder(), profile()->GetPath(), kAppTitle);
}
void VerifyShortcutCreated() {
@ -116,8 +116,7 @@ TEST_F(WebAppRunOnOsLoginWinTest, Unregister) {
VerifyShortcutCreated();
internals::UnregisterRunOnOsLogin(shortcut_info->extension_id,
profile()->GetPath(),
base::UTF8ToUTF16(kAppTitle));
profile()->GetPath(), kAppTitle);
VerifyShortcutDeleted();
}

@ -97,6 +97,7 @@ constexpr char kAnotherInstallableIconList[] = R"(
)";
constexpr char kAnotherShortcutsItemName[] = "Timeline";
constexpr char16_t kAnotherShortcutsItemName16[] = u"Timeline";
constexpr char kAnotherShortcutsItemUrl[] = "/shortcut";
constexpr char kAnotherShortcutsItemShortName[] = "H";
constexpr char kAnotherShortcutsItemDescription[] = "Navigate home";
@ -1825,7 +1826,7 @@ IN_PROC_BROWSER_TEST_F(ManifestUpdateManagerBrowserTestWithShortcutsMenu,
ManifestUpdateResult::kAppUpdated, 1);
EXPECT_EQ(
GetProvider().registrar().GetAppShortcutsMenuItemInfos(app_id)[0].name,
base::UTF8ToUTF16(kAnotherShortcutsItemName));
kAnotherShortcutsItemName16);
}
IN_PROC_BROWSER_TEST_F(ManifestUpdateManagerBrowserTestWithShortcutsMenu,

@ -50,7 +50,7 @@ struct AutofillFieldLabelSourceCase {
struct AutofillFieldUtilCase {
const char* description;
const char* html;
const char* expected_label;
const char16_t* expected_label;
};
const char kElevenChildren[] =
@ -67,8 +67,8 @@ const char kElevenChildren[] =
"<div>child9</div>"
"<div>child10</div>"
"</div>";
const char kElevenChildrenExpected[] =
"child0child1child2child3child4child5child6child7child8";
const char16_t kElevenChildrenExpected[] =
u"child0child1child2child3child4child5child6child7child8";
const char kElevenChildrenNested[] =
"<div id='target'>"
@ -85,7 +85,8 @@ const char kElevenChildrenNested[] =
"<div>child10"
"</div></div></div></div></div></div></div></div></div></div></div></div>";
// Take 10 elements -1 for target element, -1 as text is a leaf element.
const char kElevenChildrenNestedExpected[] = "child0child1child2child3child4";
const char16_t kElevenChildrenNestedExpected[] =
u"child0child1child2child3child4";
const char kSkipElement[] =
"<div id='target'>"
@ -94,13 +95,13 @@ const char kSkipElement[] =
"<div>child2</div>"
"</div>";
// TODO(crbug.com/796918): Should be child0child2
const char kSkipElementExpected[] = "child0";
const char16_t kSkipElementExpected[] = u"child0";
const char kDivTableExample1[] =
"<div>"
"<div>label</div><div><input id='target'/></div>"
"</div>";
const char kDivTableExample1Expected[] = "label";
const char16_t kDivTableExample1Expected[] = u"label";
const char kDivTableExample2[] =
"<div>"
@ -108,7 +109,7 @@ const char kDivTableExample2[] =
"<div>should be skipped<input/></div>"
"<div><input id='target'/></div>"
"</div>";
const char kDivTableExample2Expected[] = "label";
const char16_t kDivTableExample2Expected[] = u"label";
const char kDivTableExample3[] =
"<div>"
@ -116,7 +117,7 @@ const char kDivTableExample3[] =
"<div>label</div>"
"<div><input id='target'/></div>"
"</div>";
const char kDivTableExample3Expected[] = "label";
const char16_t kDivTableExample3Expected[] = u"label";
const char kDivTableExample4[] =
"<div>"
@ -125,21 +126,21 @@ const char kDivTableExample4[] =
"<div><input id='target'/></div>"
"</div>";
// TODO(crbug.com/796918): Should be label
const char kDivTableExample4Expected[] = "";
const char16_t kDivTableExample4Expected[] = u"";
const char kDivTableExample5[] =
"<div>"
"<div>label<div><input id='target'/></div>behind</div>"
"</div>";
// TODO(crbug.com/796918): Should be label
const char kDivTableExample5Expected[] = "labelbehind";
const char16_t kDivTableExample5Expected[] = u"labelbehind";
const char kDivTableExample6[] =
"<div>"
"<div>label<div><div>-<div><input id='target'/></div></div>"
"</div>";
// TODO(crbug.com/796918): Should be "label" or "label-"
const char kDivTableExample6Expected[] = "";
const char16_t kDivTableExample6Expected[] = u"";
void VerifyButtonTitleCache(const WebFormElement& form_target,
const ButtonTitleList& expected_button_titles,
@ -163,13 +164,13 @@ class FormAutofillUtilsTest : public content::RenderViewTest {
TEST_F(FormAutofillUtilsTest, FindChildTextTest) {
static const AutofillFieldUtilCase test_cases[] = {
{"simple test", "<div id='target'>test</div>", "test"},
{"simple test", "<div id='target'>test</div>", u"test"},
{"Concatenate test", "<div id='target'><span>one</span>two</div>",
"onetwo"},
u"onetwo"},
// TODO(crbug.com/796918): should be "onetwo"
{"Ignore input", "<div id='target'>one<input value='test'/>two</div>",
"one"},
{"Trim", "<div id='target'> one<span>two </span></div>", "onetwo"},
u"one"},
{"Trim", "<div id='target'> one<span>two </span></div>", u"onetwo"},
{"eleven children", kElevenChildren, kElevenChildrenExpected},
// TODO(crbug.com/796918): Depth is only 5 elements
{"eleven children nested", kElevenChildrenNested,
@ -182,8 +183,7 @@ TEST_F(FormAutofillUtilsTest, FindChildTextTest) {
ASSERT_NE(nullptr, web_frame);
WebElement target = web_frame->GetDocument().GetElementById("target");
ASSERT_FALSE(target.IsNull());
EXPECT_EQ(base::UTF8ToUTF16(test_case.expected_label),
FindChildText(target));
EXPECT_EQ(test_case.expected_label, FindChildText(target));
}
}
@ -205,7 +205,7 @@ TEST_F(FormAutofillUtilsTest, FindChildTextSkipElementTest) {
to_skip.insert(web_to_skip[i]);
}
EXPECT_EQ(base::UTF8ToUTF16(test_case.expected_label),
EXPECT_EQ(test_case.expected_label,
FindChildTextWithIgnoreListForTesting(target, to_skip));
}
}
@ -234,12 +234,12 @@ TEST_F(FormAutofillUtilsTest, InferLabelForElementTest) {
FormFieldData::LabelSource::kUnknown;
std::u16string label;
InferLabelForElementForTesting(form_target, &label, &label_source);
EXPECT_EQ(base::UTF8ToUTF16(test_case.expected_label), label);
EXPECT_EQ(test_case.expected_label, label);
}
}
TEST_F(FormAutofillUtilsTest, InferLabelSourceTest) {
const char kLabelSourceExpectedLabel[] = "label";
const char16_t kLabelSourceExpectedLabel[] = u"label";
static const AutofillFieldLabelSourceCase test_cases[] = {
{"<div><div>label</div><div><input id='target'/></div></div>",
FormFieldData::LabelSource::kDivTable},
@ -279,7 +279,7 @@ TEST_F(FormAutofillUtilsTest, InferLabelSourceTest) {
std::u16string label;
EXPECT_TRUE(autofill::form_util::InferLabelForElementForTesting(
form_target, &label, &label_source));
EXPECT_EQ(base::UTF8ToUTF16(kLabelSourceExpectedLabel), label);
EXPECT_EQ(kLabelSourceExpectedLabel, label);
EXPECT_EQ(test_case.label_source, label_source);
}
}
@ -441,19 +441,18 @@ TEST_F(FormAutofillUtilsTest, IsEnabled) {
dummy_fieldsets, control_elements, nullptr, web_frame->GetDocument(),
nullptr, EXTRACT_NONE, &target, nullptr));
const struct {
const char* const name;
const char16_t* const name;
bool enabled;
} kExpectedFields[] = {
{"name1", true},
{"name2", false},
{"name3", true},
{"name4", false},
{u"name1", true},
{u"name2", false},
{u"name3", true},
{u"name4", false},
};
const size_t number_of_cases = base::size(kExpectedFields);
ASSERT_EQ(number_of_cases, target.fields.size());
for (size_t i = 0; i < number_of_cases; ++i) {
EXPECT_EQ(base::UTF8ToUTF16(kExpectedFields[i].name),
target.fields[i].name);
EXPECT_EQ(kExpectedFields[i].name, target.fields[i].name);
EXPECT_EQ(kExpectedFields[i].enabled, target.fields[i].is_enabled);
}
}
@ -482,19 +481,18 @@ TEST_F(FormAutofillUtilsTest, IsReadonly) {
dummy_fieldsets, control_elements, nullptr, web_frame->GetDocument(),
nullptr, EXTRACT_NONE, &target, nullptr));
const struct {
const char* const name;
const char16_t* const name;
bool readonly;
} kExpectedFields[] = {
{"name1", false},
{"name2", true},
{"name3", false},
{"name4", true},
{u"name1", false},
{u"name2", true},
{u"name3", false},
{u"name4", true},
};
const size_t number_of_cases = base::size(kExpectedFields);
ASSERT_EQ(number_of_cases, target.fields.size());
for (size_t i = 0; i < number_of_cases; ++i) {
EXPECT_EQ(base::UTF8ToUTF16(kExpectedFields[i].name),
target.fields[i].name);
EXPECT_EQ(kExpectedFields[i].name, target.fields[i].name);
EXPECT_EQ(kExpectedFields[i].readonly, target.fields[i].is_readonly);
}
}

@ -7,7 +7,6 @@
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::UTF8ToUTF16;
using autofill::AddressRewriter;
TEST(AddressRewriterTest, InvalidCountryCode) {
@ -41,8 +40,7 @@ TEST(AddressRewriterTest, AD) {
TEST(AddressRewriterTest, AR) {
AddressRewriter ar = AddressRewriter::ForCountryCode(u"ar");
EXPECT_EQ(ar.Rewrite(UTF8ToUTF16(
"tierra del fuego antartida e islas del atlantico sur")),
EXPECT_EQ(ar.Rewrite(u"tierra del fuego antartida e islas del atlantico sur"),
ar.Rewrite(u"tierra del fuego"));
EXPECT_EQ(ar.Rewrite(u"ciudad autonoma de buenos aires"),
ar.Rewrite(u"capital federal"));

@ -56,7 +56,6 @@ using autofill::EmailInfo;
using autofill::NameInfo;
using autofill::PhoneNumber;
using autofill::ServerFieldType;
using base::UTF8ToUTF16;
namespace autofill {
@ -102,22 +101,22 @@ class AutofillProfileComparatorTest
autofill::CountryNames::SetLocaleString(kLocale);
}
NameInfo CreateNameInfo(const char* first,
const char* middle,
const char* last,
const char* full) {
NameInfo CreateNameInfo(const char16_t* first,
const char16_t* middle,
const char16_t* last,
const char16_t* full) {
NameInfo name;
name.SetRawInfoWithVerificationStatus(
NAME_FIRST, base::UTF8ToUTF16(first),
NAME_FIRST, first,
autofill::structured_address::VerificationStatus::kObserved);
name.SetRawInfoWithVerificationStatus(
NAME_MIDDLE, base::UTF8ToUTF16(middle),
NAME_MIDDLE, middle,
autofill::structured_address::VerificationStatus::kObserved);
name.SetRawInfoWithVerificationStatus(
NAME_LAST, base::UTF8ToUTF16(last),
NAME_LAST, last,
autofill::structured_address::VerificationStatus::kObserved);
name.SetRawInfoWithVerificationStatus(
NAME_FULL, base::UTF8ToUTF16(full),
NAME_FULL, full,
autofill::structured_address::VerificationStatus::kObserved);
return name;
}
@ -190,10 +189,10 @@ class AutofillProfileComparatorTest
AutofillProfile CopyAndModify(
const AutofillProfile& profile,
const std::vector<std::pair<ServerFieldType, const char*>>& updates) {
const std::vector<std::pair<ServerFieldType, const char16_t*>>& updates) {
AutofillProfile new_profile = profile;
for (const auto& update : updates) {
new_profile.SetRawInfo(update.first, UTF8ToUTF16(update.second));
new_profile.SetRawInfo(update.first, update.second);
}
new_profile.FinalizeAfterImport();
return new_profile;
@ -242,7 +241,7 @@ class AutofillProfileComparatorTest
void MergePhoneNumbersAndExpect(const AutofillProfile& a,
const AutofillProfile& b,
const std::string& expected_str) {
const std::u16string& expected_str) {
AutofillProfile dummy;
// Merge the phone numbers.
@ -251,7 +250,7 @@ class AutofillProfileComparatorTest
// Construct the expected value.
PhoneNumber expected(&dummy);
expected.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, UTF8ToUTF16(expected_str));
expected.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, expected_str);
// Validate that we get what we expect.
EXPECT_EQ(expected.GetRawInfo(PHONE_HOME_WHOLE_NUMBER),
@ -712,20 +711,20 @@ TEST_P(AutofillProfileComparatorTest, HaveMergeableAddresses) {
"Carver City", "ca", "", "us");
AutofillProfile differentCountry =
CopyAndModify(p1, {{ADDRESS_HOME_COUNTRY, "CA"}});
CopyAndModify(p1, {{ADDRESS_HOME_COUNTRY, u"CA"}});
AutofillProfile differentZip =
CopyAndModify(p1, {{ADDRESS_HOME_ZIP, "32145"}});
CopyAndModify(p1, {{ADDRESS_HOME_ZIP, u"32145"}});
AutofillProfile differentState = CopyAndModify(
p1, {{ADDRESS_HOME_ZIP, ""}, {ADDRESS_HOME_STATE, "Florida"}});
p1, {{ADDRESS_HOME_ZIP, u""}, {ADDRESS_HOME_STATE, u"Florida"}});
AutofillProfile differentCity = CopyAndModify(
p1, {{ADDRESS_HOME_ZIP, ""}, {ADDRESS_HOME_CITY, "Metropolis"}});
p1, {{ADDRESS_HOME_ZIP, u""}, {ADDRESS_HOME_CITY, u"Metropolis"}});
AutofillProfile differentAddress =
CopyAndModify(p1, {{ADDRESS_HOME_LINE1, "17 Park Lane"},
{ADDRESS_HOME_LINE2, "Suite 150"}});
CopyAndModify(p1, {{ADDRESS_HOME_LINE1, u"17 Park Lane"},
{ADDRESS_HOME_LINE2, u"Suite 150"}});
AutofillProfile differentLocality =
CopyAndModify(p1, {{ADDRESS_HOME_DEPENDENT_LOCALITY, "Funky Chicken"}});
CopyAndModify(p1, {{ADDRESS_HOME_DEPENDENT_LOCALITY, u"Funky Chicken"}});
AutofillProfile differentSortingCode =
CopyAndModify(p1, {{ADDRESS_HOME_SORTING_CODE, "98000 Monaco"}});
CopyAndModify(p1, {{ADDRESS_HOME_SORTING_CODE, u"98000 Monaco"}});
EXPECT_TRUE(comparator_.HaveMergeableAddresses(p1, empty));
EXPECT_TRUE(comparator_.HaveMergeableAddresses(empty, p2));
@ -758,26 +757,26 @@ TEST_P(AutofillProfileComparatorTest, AreMergeable) {
"+1 (234) 567-8910", /*finalize=*/false);
AutofillProfile mergeable =
CopyAndModify(p, {{NAME_FIRST, "MÁRÍÕÑ"},
{NAME_MIDDLE, "M."},
{EMAIL_ADDRESS, "MARION@ME.XYZ"},
{COMPANY_NAME, "Fox Industries Inc."},
{ADDRESS_HOME_LINE1, "123 zoo st. w., #5"},
{ADDRESS_HOME_LINE1, ""},
{ADDRESS_HOME_STATE, "california"},
{PHONE_HOME_WHOLE_NUMBER, "5678910 ext. 77"}});
CopyAndModify(p, {{NAME_FIRST, u"MÁRÍÕÑ"},
{NAME_MIDDLE, u"M."},
{EMAIL_ADDRESS, u"MARION@ME.XYZ"},
{COMPANY_NAME, u"Fox Industries Inc."},
{ADDRESS_HOME_LINE1, u"123 zoo st. w., #5"},
{ADDRESS_HOME_LINE1, u""},
{ADDRESS_HOME_STATE, u"california"},
{PHONE_HOME_WHOLE_NUMBER, u"5678910 ext. 77"}});
AutofillProfile not_mergeable_by_name =
CopyAndModify(p, {{NAME_FIRST, "Steven"},
{NAME_FULL, ""},
{autofill::NAME_LAST_SECOND, ""}});
CopyAndModify(p, {{NAME_FIRST, u"Steven"},
{NAME_FULL, u""},
{autofill::NAME_LAST_SECOND, u""}});
AutofillProfile not_mergeable_by_email_address =
CopyAndModify(p, {{EMAIL_ADDRESS, "marion.morrision@me.xyz"}});
CopyAndModify(p, {{EMAIL_ADDRESS, u"marion.morrision@me.xyz"}});
AutofillProfile not_mergeable_by_company_name =
CopyAndModify(p, {{COMPANY_NAME, "Hound Corp"}});
CopyAndModify(p, {{COMPANY_NAME, u"Hound Corp"}});
AutofillProfile not_mergeable_by_address =
CopyAndModify(p, {{ADDRESS_HOME_LINE2, "Unit 7"}});
CopyAndModify(p, {{ADDRESS_HOME_LINE2, u"Unit 7"}});
AutofillProfile not_mergeable_by_phone_number =
CopyAndModify(p, {{PHONE_HOME_WHOLE_NUMBER, "555-1234"}});
CopyAndModify(p, {{PHONE_HOME_WHOLE_NUMBER, u"555-1234"}});
// Finalize the initial profile.
// Note, all other profiles are already finalized.
@ -921,15 +920,15 @@ TEST_P(AutofillProfileComparatorTest, MergeNames) {
TEST_P(AutofillProfileComparatorTest, MergeCJKNames) {
// Korean names that are all mergeable, but constructed differently.
NameInfo name1 = CreateNameInfo("", "", "이영", "이영 호");
NameInfo name2 = CreateNameInfo("이영호", "", "", "이영호");
NameInfo name3 = CreateNameInfo("영호", "", "", "이영호");
NameInfo name4 = CreateNameInfo("영호", "", "", "");
NameInfo name5 = CreateNameInfo("영호", "", "", "이 영호");
NameInfo name1 = CreateNameInfo(u"", u"", u"이영", u"이영 호");
NameInfo name2 = CreateNameInfo(u"이영호", u"", u"", u"이영호");
NameInfo name3 = CreateNameInfo(u"영호", u"", u"", u"이영호");
NameInfo name4 = CreateNameInfo(u"영호", u"", u"", u"");
NameInfo name5 = CreateNameInfo(u"영호", u"", u"", u"이 영호");
// Mergeable foreign name in Japanese with a 'KATAKANA MIDDLE DOT'.
NameInfo name6 = CreateNameInfo("", "", "", "ゲイツ・ビル");
NameInfo name7 = CreateNameInfo("ビル", "", "ゲイツ", "");
NameInfo name6 = CreateNameInfo(u"", u"", u"", u"ゲイツ・ビル");
NameInfo name7 = CreateNameInfo(u"ビル", u"", u"ゲイツ", u"");
// Set the use dates for the profiles, because |MergeCJKNames()| tries to use
// the most recent profile if there is a conflict. The ordering is
@ -949,10 +948,10 @@ TEST_P(AutofillProfileComparatorTest, MergeCJKNames) {
AutofillProfile p7 = CreateProfileWithName(name7);
// Because |p1| is the most recent, it always wins over others.
MergeNamesAndExpect(p1, p2, CreateNameInfo("", "", "이영", "이영 호"));
MergeNamesAndExpect(p1, p3, CreateNameInfo("", "", "이영", "이영 호"));
MergeNamesAndExpect(p1, p4, CreateNameInfo("", "", "이영", "이영 호"));
MergeNamesAndExpect(p1, p5, CreateNameInfo("", "", "이영", "이영 호"));
MergeNamesAndExpect(p1, p2, CreateNameInfo(u"", u"", u"이영", u"이영 호"));
MergeNamesAndExpect(p1, p3, CreateNameInfo(u"", u"", u"이영", u"이영 호"));
MergeNamesAndExpect(p1, p4, CreateNameInfo(u"", u"", u"이영", u"이영 호"));
MergeNamesAndExpect(p1, p5, CreateNameInfo(u"", u"", u"이영", u"이영 호"));
// The following tests are not applicable to the logic of the new structured
// name. Because we consider not having a surname a valid option for the user.
@ -963,34 +962,36 @@ TEST_P(AutofillProfileComparatorTest, MergeCJKNames) {
// |p2| is more recent than |p3|, |p4|, and |p5|. However, it does not
// have a surname entry (it was probably parsed with the old logic), so
// the other profiles are used as the source for given/surname.
MergeNamesAndExpect(p2, p3, CreateNameInfo("영호", "", "", "이영호"));
MergeNamesAndExpect(p2, p4, CreateNameInfo("영호", "", "", "이영호"));
MergeNamesAndExpect(p2, p5, CreateNameInfo("영호", "", "", "이영호"));
MergeNamesAndExpect(p2, p3, CreateNameInfo(u"영호", u"", u"", u"이영호"));
MergeNamesAndExpect(p2, p4, CreateNameInfo(u"영호", u"", u"", u"이영호"));
MergeNamesAndExpect(p2, p5, CreateNameInfo(u"영호", u"", u"", u"이영호"));
}
// |p3| is more recent than |p4| and |p5|.
MergeNamesAndExpect(p3, p4, CreateNameInfo("영호", "", "", "이영호"));
MergeNamesAndExpect(p3, p5, CreateNameInfo("영호", "", "", "이영호"));
MergeNamesAndExpect(p3, p4, CreateNameInfo(u"영호", u"", u"", u"이영호"));
MergeNamesAndExpect(p3, p5, CreateNameInfo(u"영호", u"", u"", u"이영호"));
// |p4| is more recent than |p5|. However, it does not have an explicit
// full name, so use the one from |p5|.
MergeNamesAndExpect(p4, p5, CreateNameInfo("영호", "", "", "이 영호"));
MergeNamesAndExpect(p4, p5, CreateNameInfo(u"영호", u"", u"", u"이 영호"));
// There is no conflict between |p6| and |p7|, so use the parts from both.
MergeNamesAndExpect(p6, p7,
CreateNameInfo("ビル", "", "ゲイツ", "ゲイツ・ビル"));
CreateNameInfo(u"ビル", u"", u"ゲイツ", u"ゲイツ・ビル"));
}
TEST_P(AutofillProfileComparatorTest, MergeEmailAddresses) {
static const char kEmailA[] = "testaccount@domain.net";
static const char16_t kEmailA16[] = u"testaccount@domain.net";
static const char kEmailB[] = "TestAccount@Domain.Net";
static const char16_t kEmailB16[] = u"TestAccount@Domain.Net";
EmailInfo email_a;
email_a.SetRawInfo(EMAIL_ADDRESS, UTF8ToUTF16(kEmailA));
email_a.SetRawInfo(EMAIL_ADDRESS, kEmailA16);
AutofillProfile profile_a = CreateProfileWithEmail(kEmailA);
profile_a.set_use_date(AutofillClock::Now());
EmailInfo email_b;
email_b.SetRawInfo(EMAIL_ADDRESS, UTF8ToUTF16(kEmailB));
email_b.SetRawInfo(EMAIL_ADDRESS, kEmailB16);
AutofillProfile profile_b = CreateProfileWithEmail(kEmailB);
profile_b.set_use_date(profile_a.use_date() + base::TimeDelta::FromDays(1));
@ -1002,32 +1003,36 @@ TEST_P(AutofillProfileComparatorTest, MergeEmailAddresses) {
TEST_P(AutofillProfileComparatorTest, MergeCompanyNames) {
static const char kCompanyA[] = "Some Company";
static const char16_t kCompanyA16[] = u"Some Company";
static const char kCompanyB[] = "SÔMÈ ÇÖMPÁÑÝ";
static const char16_t kCompanyB16[] = u"SÔMÈ ÇÖMPÁÑÝ";
static const char kCompanyC[] = "SÔMÈ ÇÖMPÁÑÝ A.G.";
static const char16_t kCompanyC16[] = u"SÔMÈ ÇÖMPÁÑÝ A.G.";
static const char kCompanyD[] = "1987";
static const char16_t kCompanyD16[] = u"1987";
CompanyInfo company_a;
company_a.SetRawInfo(COMPANY_NAME, UTF8ToUTF16(kCompanyA));
company_a.SetRawInfo(COMPANY_NAME, kCompanyA16);
AutofillProfile profile_a = CreateProfileWithCompanyName(kCompanyA);
profile_a.set_use_date(AutofillClock::Now());
// Company Name B is post_normalization identical to Company Name A. The use
// date will be used to choose between them.
CompanyInfo company_b;
company_b.SetRawInfo(COMPANY_NAME, UTF8ToUTF16(kCompanyB));
company_b.SetRawInfo(COMPANY_NAME, kCompanyB16);
AutofillProfile profile_b = CreateProfileWithCompanyName(kCompanyB);
profile_b.set_use_date(profile_a.use_date() + base::TimeDelta::FromDays(1));
// Company Name C is the most complete. Even though it has the earliest use
// date, it will be preferred to the other two.
CompanyInfo company_c;
company_c.SetRawInfo(COMPANY_NAME, UTF8ToUTF16(kCompanyC));
company_c.SetRawInfo(COMPANY_NAME, kCompanyC16);
AutofillProfile profile_c = CreateProfileWithCompanyName(kCompanyC);
profile_c.set_use_date(profile_a.use_date() - base::TimeDelta::FromDays(1));
// Company Name D is in the format of a birthyear, invalid and non-verified.
CompanyInfo company_d;
company_d.SetRawInfo(COMPANY_NAME, UTF8ToUTF16(kCompanyD));
company_d.SetRawInfo(COMPANY_NAME, kCompanyD16);
AutofillProfile profile_d = CreateProfileWithCompanyName(kCompanyD);
profile_a.set_use_date(AutofillClock::Now());
@ -1054,16 +1059,23 @@ TEST_P(AutofillProfileComparatorTest, MergeCompanyNames) {
TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
static const char kPhoneA[] = "5550199";
static const char16_t kPhoneA16[] = u"5550199";
static const char kPhoneB[] = "555.0199";
static const char16_t kPhoneB16[] = u"555.0199";
static const char kPhoneC[] = "555-0199 ext321";
static const char16_t kPhoneC16[] = u"555-0199 ext321";
static const char kPhoneD[] = "8005550199";
static const char16_t kPhoneD16[] = u"8005550199";
static const char kPhoneE[] = "800-555-0199 #321";
static const char16_t kPhoneE16[] = u"800-555-0199 #321";
static const char kPhoneF[] = "1-800-555-0199 #321";
static const char16_t kPhoneF16[] = u"1-800-555-0199 #321";
static const char kPhoneG[] = "+1 (800) 555.0199;ext=321";
static const char kMergedShortNumber[] = "5550199";
static const char kMergedShortNumberExt[] = "5550199 ext. 321";
static const char kMergedFullNumber[] = "+1 800-555-0199";
static const char kMergedFullNumberExt[] = "+1 800-555-0199 ext. 321";
static const char16_t kPhoneG16[] = u"+1 (800) 555.0199;ext=321";
static const char16_t kMergedShortNumber[] = u"5550199";
static const char16_t kMergedShortNumberExt[] = u"5550199 ext. 321";
static const char16_t kMergedFullNumber[] = u"+1 800-555-0199";
static const char16_t kMergedFullNumberExt[] = u"+1 800-555-0199 ext. 321";
AutofillProfile profile_a = CreateProfileWithPhoneNumber(kPhoneA);
AutofillProfile profile_b = CreateProfileWithPhoneNumber(kPhoneB);
@ -1074,7 +1086,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
AutofillProfile profile_g = CreateProfileWithPhoneNumber(kPhoneG);
// Profile A
MergePhoneNumbersAndExpect(profile_a, profile_a, kPhoneA);
MergePhoneNumbersAndExpect(profile_a, profile_a, kPhoneA16);
MergePhoneNumbersAndExpect(profile_a, profile_b, kMergedShortNumber);
MergePhoneNumbersAndExpect(profile_a, profile_c, kMergedShortNumberExt);
MergePhoneNumbersAndExpect(profile_a, profile_d, kMergedFullNumber);
@ -1084,7 +1096,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
// Profile B
MergePhoneNumbersAndExpect(profile_b, profile_a, kMergedShortNumber);
MergePhoneNumbersAndExpect(profile_b, profile_b, kPhoneB);
MergePhoneNumbersAndExpect(profile_b, profile_b, kPhoneB16);
MergePhoneNumbersAndExpect(profile_b, profile_c, kMergedShortNumberExt);
MergePhoneNumbersAndExpect(profile_b, profile_d, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_b, profile_e, kMergedFullNumberExt);
@ -1094,7 +1106,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
// Profile C
MergePhoneNumbersAndExpect(profile_c, profile_a, kMergedShortNumberExt);
MergePhoneNumbersAndExpect(profile_c, profile_b, kMergedShortNumberExt);
MergePhoneNumbersAndExpect(profile_c, profile_c, kPhoneC);
MergePhoneNumbersAndExpect(profile_c, profile_c, kPhoneC16);
MergePhoneNumbersAndExpect(profile_c, profile_d, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_c, profile_e, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_c, profile_f, kMergedFullNumberExt);
@ -1104,7 +1116,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
MergePhoneNumbersAndExpect(profile_d, profile_a, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_d, profile_b, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_d, profile_c, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_d, profile_d, kPhoneD);
MergePhoneNumbersAndExpect(profile_d, profile_d, kPhoneD16);
MergePhoneNumbersAndExpect(profile_d, profile_e, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_d, profile_f, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_d, profile_g, kMergedFullNumberExt);
@ -1114,7 +1126,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
MergePhoneNumbersAndExpect(profile_e, profile_b, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_e, profile_c, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_e, profile_d, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_e, profile_e, kPhoneE);
MergePhoneNumbersAndExpect(profile_e, profile_e, kPhoneE16);
MergePhoneNumbersAndExpect(profile_e, profile_f, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_e, profile_g, kMergedFullNumberExt);
@ -1124,7 +1136,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
MergePhoneNumbersAndExpect(profile_f, profile_c, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_f, profile_d, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_f, profile_e, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_f, profile_f, kPhoneF);
MergePhoneNumbersAndExpect(profile_f, profile_f, kPhoneF16);
MergePhoneNumbersAndExpect(profile_f, profile_g, kMergedFullNumberExt);
// Profile G
@ -1134,7 +1146,7 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_NA) {
MergePhoneNumbersAndExpect(profile_g, profile_d, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_g, profile_e, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_g, profile_f, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_g, profile_g, kPhoneG);
MergePhoneNumbersAndExpect(profile_g, profile_g, kPhoneG16);
}
TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_Intl) {
@ -1142,11 +1154,15 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_Intl) {
const AutofillType kCountry(ADDRESS_HOME_COUNTRY);
static const char kPhoneA[] = "+49492180185611";
static const char16_t kPhoneA16[] = u"+49492180185611";
static const char kPhoneB[] = "+49 4921 801 856-11";
static const char16_t kPhoneB16[] = u"+49 4921 801 856-11";
static const char kPhoneC[] = "+49 4921 8018 5611;ext=22";
static const char16_t kPhoneC16[] = u"+49 4921 8018 5611;ext=22";
static const char kPhoneD[] = "04921 80185611"; // National Format.
static const char kMergedFullNumber[] = "+49 4921 80185611";
static const char kMergedFullNumberExt[] = "+49 4921 80185611 ext. 22";
static const char16_t kPhoneD16[] = u"04921 80185611"; // National Format.
static const char16_t kMergedFullNumber[] = u"+49 4921 80185611";
static const char16_t kMergedFullNumberExt[] = u"+49 4921 80185611 ext. 22";
AutofillProfile profile_a = CreateProfileWithPhoneNumber(kPhoneA);
AutofillProfile profile_b = CreateProfileWithPhoneNumber(kPhoneB);
@ -1159,25 +1175,25 @@ TEST_P(AutofillProfileComparatorTest, MergePhoneNumbers_Intl) {
profile_d.SetInfo(kCountry, kGermany, kLocale);
// Profile A
MergePhoneNumbersAndExpect(profile_a, profile_a, kPhoneA);
MergePhoneNumbersAndExpect(profile_a, profile_a, kPhoneA16);
MergePhoneNumbersAndExpect(profile_a, profile_b, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_a, profile_c, kMergedFullNumberExt);
// Profile B
MergePhoneNumbersAndExpect(profile_b, profile_a, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_b, profile_b, kPhoneB);
MergePhoneNumbersAndExpect(profile_b, profile_b, kPhoneB16);
MergePhoneNumbersAndExpect(profile_b, profile_c, kMergedFullNumberExt);
// Profile C
MergePhoneNumbersAndExpect(profile_c, profile_a, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_c, profile_b, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_c, profile_c, kPhoneC);
MergePhoneNumbersAndExpect(profile_c, profile_c, kPhoneC16);
// Profile D
MergePhoneNumbersAndExpect(profile_d, profile_a, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_d, profile_b, kMergedFullNumber);
MergePhoneNumbersAndExpect(profile_d, profile_c, kMergedFullNumberExt);
MergePhoneNumbersAndExpect(profile_d, profile_d, kPhoneD);
MergePhoneNumbersAndExpect(profile_d, profile_d, kPhoneD16);
}
TEST_P(AutofillProfileComparatorTest, MergeAddresses) {

@ -150,9 +150,8 @@ std::u16string StreetAddress::GetBestFormatString() const {
base::UTF16ToUTF8(GetRootNode().GetValueForType(ADDRESS_HOME_COUNTRY));
if (country_code == "BR") {
return base::UTF8ToUTF16(
"${ADDRESS_HOME_STREET_NAME}${ADDRESS_HOME_HOUSE_NUMBER;, }"
"${ADDRESS_HOME_FLOOR;, ;º andar}${ADDRESS_HOME_APT_NUM;, apto ;}");
return u"${ADDRESS_HOME_STREET_NAME}${ADDRESS_HOME_HOUSE_NUMBER;, }"
u"${ADDRESS_HOME_FLOOR;, ;º andar}${ADDRESS_HOME_APT_NUM;, apto ;}";
}
if (country_code == "DE") {

@ -36,9 +36,7 @@
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
#include "third_party/libaddressinput/src/cpp/test/testdata_source.h"
using base::ASCIIToUTF16;
using base::StringToInt;
using base::UTF8ToUTF16;
namespace autofill {
@ -136,10 +134,10 @@ void TestFillingInvalidFields(const std::u16string& state,
}
struct CreditCardTestCase {
std::string card_number_;
std::u16string card_number_;
size_t total_splits_;
std::vector<int> splits_;
std::vector<std::string> expected_results_;
std::vector<std::u16string> expected_results_;
};
// Returns the offset to be set within the credit card number field.
@ -539,23 +537,23 @@ TEST_F(AutofillFieldFillerTest, FillFormField_Validity_CountryEmpty) {
struct AutofillFieldFillerTestCase {
HtmlFieldType field_type;
size_t field_max_length;
std::string expected_value;
std::u16string expected_value;
AutofillFieldFillerTestCase(HtmlFieldType field_type,
size_t field_max_length,
std::string expected_value)
std::u16string expected_value)
: field_type(field_type),
field_max_length(field_max_length),
expected_value(expected_value) {}
};
struct AutofillPhoneFieldFillerTestCase : public AutofillFieldFillerTestCase {
std::string phone_home_whole_number_value;
std::u16string phone_home_whole_number_value;
AutofillPhoneFieldFillerTestCase(HtmlFieldType field_type,
size_t field_max_length,
std::string expected_value,
std::string phone_home_whole_number_value)
std::u16string expected_value,
std::u16string phone_home_whole_number_value)
: AutofillFieldFillerTestCase(field_type,
field_max_length,
expected_value),
@ -576,10 +574,10 @@ TEST_P(PhoneNumberTest, FillPhoneNumber) {
AutofillProfile address;
address.SetRawInfo(PHONE_HOME_WHOLE_NUMBER,
ASCIIToUTF16(test_case.phone_home_whole_number_value));
test_case.phone_home_whole_number_value);
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string());
EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value);
EXPECT_EQ(test_case.expected_value, field.value);
}
INSTANTIATE_TEST_SUITE_P(
@ -588,43 +586,43 @@ INSTANTIATE_TEST_SUITE_P(
testing::Values(
// Filling a prefix type field should just fill the prefix.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL_LOCAL_PREFIX,
/*field_max_length=*/0, "555",
"+15145554578"},
/*field_max_length=*/0, u"555",
u"+15145554578"},
// Filling a suffix type field with a phone number of 7 digits should
// just fill the suffix.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL_LOCAL_SUFFIX,
/*field_max_length=*/0, "4578",
"+15145554578"},
/*field_max_length=*/0, u"4578",
u"+15145554578"},
// Filling a phone type field with a max length of 3 should fill only
// the prefix.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL_LOCAL,
/*field_max_length=*/3, "555",
"+15145554578"},
/*field_max_length=*/3, u"555",
u"+15145554578"},
// TODO(crbug.com/581485): There should be a test case where the full
// number is requested (HTML_TYPE_TEL) but a field_max_length of 3 would
// fill the prefix.
// Filling a phone type field with a max length of 4 should fill only
// the suffix.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL,
/*field_max_length=*/4, "4578",
"+15145554578"},
/*field_max_length=*/4, u"4578",
u"+15145554578"},
// Filling a phone type field with a max length of 10 with a phone
// number including the country code should fill the phone number
// without the country code.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL,
/*field_max_length=*/10, "5145554578",
"+15145554578"},
/*field_max_length=*/10, u"5145554578",
u"+15145554578"},
// Filling a phone type field with a max length of 5 with a phone number
// should fill with the last 5 digits of that phone number.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL,
/*field_max_length=*/5, "54578",
"+15145554578"},
/*field_max_length=*/5, u"54578",
u"+15145554578"},
// Filling a phone type field with a max length of 10 with a phone
// number including the country code should fill the phone number
// without the country code.
AutofillPhoneFieldFillerTestCase{HTML_TYPE_TEL,
/*field_max_length=*/10, "123456789",
"+886123456789"}));
/*field_max_length=*/10, u"123456789",
u"+886123456789"}));
class ExpirationYearTest
: public testing::TestWithParam<AutofillFieldFillerTestCase> {
@ -643,7 +641,7 @@ TEST_P(ExpirationYearTest, FillExpirationYearInput) {
card.SetExpirationDateFromString(u"12/2023");
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string());
EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value);
EXPECT_EQ(test_case.expected_value, field.value);
}
INSTANTIATE_TEST_SUITE_P(
@ -654,37 +652,37 @@ INSTANTIATE_TEST_SUITE_P(
// 2 digits of the expiration year if the field has an unspecified max
// length (0) or if it's greater than 1.
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR,
/* default value */ 0, "23"},
/* default value */ 0, u"23"},
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR, 2,
"23"},
u"23"},
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR, 12,
"23"},
u"23"},
// A field predicted as a 2 digit expiration year should fill the last
// digit of the expiration year if the field has a max length of 1.
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_2_DIGIT_YEAR, 1,
"3"},
u"3"},
// A field predicted as a 4 digit expiration year should fill the 4
// digits of the expiration year if the field has an unspecified max
// length (0) or if it's greater than 3 .
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR,
/* default value */ 0, "2023"},
/* default value */ 0, u"2023"},
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 4,
"2023"},
u"2023"},
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 12,
"2023"},
u"2023"},
// A field predicted as a 4 digits expiration year should fill the last
// 2 digits of the expiration year if the field has a max length of 2.
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 2,
"23"},
u"23"},
// A field predicted as a 4 digits expiration year should fill the last
// digit of the expiration year if the field has a max length of 1.
AutofillFieldFillerTestCase{HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, 1,
"3"}));
u"3"}));
struct FillUtilExpirationDateTestCase {
HtmlFieldType field_type;
size_t field_max_length;
std::string expected_value;
std::u16string expected_value;
bool expected_response;
};
@ -706,7 +704,7 @@ TEST_P(ExpirationDateTest, FillExpirationDateInput) {
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
bool response =
filler.FillFormField(field, &card, &field, /*cvc=*/std::u16string());
EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value);
EXPECT_EQ(test_case.expected_value, field.value);
EXPECT_EQ(response, test_case.expected_response);
}
@ -721,30 +719,30 @@ INSTANTIATE_TEST_SUITE_P(
// 7: Use format MM/YYYY
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR,
/* default value */ 0, "03/22", true},
/* default value */ 0, u"03/22", true},
// Unsupported max lengths of 1-3, fail
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 1, "", false},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 1, u"", false},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 2, "", false},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 2, u"", false},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 3, "", false},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 3, u"", false},
// A max length of 4 indicates a format of MMYY.
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 4, "0322", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 4, u"0322", true},
// A max length of 6 indicates a format of MMYYYY, the 21st century is
// assumed.
// Desired case of proper max length >= 5
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 5, "03/22", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 5, u"03/22", true},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 6, "032022", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 6, u"032022", true},
// A max length of 7 indicates a format of MM/YYYY, the 21st century is
// assumed.
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 7, "03/2022", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 7, u"03/2022", true},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 12, "03/22", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR, 12, u"03/22", true},
// A field predicted as a expiration date w/ 4 digit year should fill
// with a format of MM/YYYY unless it has max-length of:
@ -753,28 +751,29 @@ INSTANTIATE_TEST_SUITE_P(
// 6: Use format MMYYYY
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR,
/* default value */ 0, "03/2022", true},
/* default value */ 0, u"03/2022", true},
// Unsupported max lengths of 1-3, fail
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 1, "", false},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 1, u"", false},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 2, "", false},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 2, u"", false},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 3, "", false},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 3, u"", false},
// A max length of 4 indicates a format of MMYY.
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 4, "0322", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 4, u"0322", true},
// A max length of 5 indicates a format of MM/YY.
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 5, "03/22", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 5, u"03/22", true},
// A max length of 6 indicates a format of MMYYYY.
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 6, "032022", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 6, u"032022", true},
// Desired case of proper max length >= 7
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 7, "03/2022", true},
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 7, u"03/2022", true},
FillUtilExpirationDateTestCase{
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 12, "03/2022", true}));
HTML_TYPE_CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, 12, u"03/2022",
true}));
TEST_F(AutofillFieldFillerTest, FillSelectControlByValue) {
std::vector<const char*> kOptions = {
@ -823,9 +822,9 @@ TEST_F(AutofillFieldFillerTest, FillSelectControlByContents) {
struct FillSelectTestCase {
std::vector<const char*> select_values;
const char* input_value;
const char* expected_value_without_normalization;
const char* expected_value_with_normalization = nullptr;
const char16_t* input_value;
const char16_t* expected_value_without_normalization;
const char16_t* expected_value_with_normalization = nullptr;
};
class AutofillSelectWithStatesTest
@ -880,19 +879,17 @@ TEST_P(AutofillSelectWithStatesTest, FillSelectWithStates) {
// Without a normalizer.
AutofillProfile address = test::GetFullProfile();
address.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16(test_case.input_value));
address.SetRawInfo(ADDRESS_HOME_STATE, test_case.input_value);
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string());
// nullptr means we expect them not to match without normalization.
if (test_case.expected_value_without_normalization != nullptr) {
EXPECT_EQ(UTF8ToUTF16(test_case.expected_value_without_normalization),
field.value);
EXPECT_EQ(test_case.expected_value_without_normalization, field.value);
}
// With a normalizer.
AutofillProfile canadian_address = test::GetFullCanadianProfile();
canadian_address.SetRawInfo(ADDRESS_HOME_STATE,
UTF8ToUTF16(test_case.input_value));
canadian_address.SetRawInfo(ADDRESS_HOME_STATE, test_case.input_value);
// Fill a first time without loading the rules for the region.
FieldFiller canadian_filler(/*app_locale=*/"en-US", normalizer());
canadian_filler.FillFormField(field, &canadian_address, &field,
@ -900,20 +897,17 @@ TEST_P(AutofillSelectWithStatesTest, FillSelectWithStates) {
// If the expectation with normalization is nullptr, this means that the same
// result than without a normalizer is expected.
if (test_case.expected_value_with_normalization == nullptr) {
EXPECT_EQ(UTF8ToUTF16(test_case.expected_value_without_normalization),
field.value);
EXPECT_EQ(test_case.expected_value_without_normalization, field.value);
} else {
// We needed a normalizer with loaded rules. The first fill should have
// failed.
EXPECT_NE(UTF8ToUTF16(test_case.expected_value_with_normalization),
field.value);
EXPECT_NE(test_case.expected_value_with_normalization, field.value);
// Load the rules and try again.
normalizer()->LoadRulesForRegion("CA");
canadian_filler.FillFormField(field, &canadian_address, &field,
/*cvc=*/std::u16string());
EXPECT_EQ(UTF8ToUTF16(test_case.expected_value_with_normalization),
field.value);
EXPECT_EQ(test_case.expected_value_with_normalization, field.value);
}
}
@ -922,54 +916,54 @@ INSTANTIATE_TEST_SUITE_P(
AutofillSelectWithStatesTest,
testing::Values(
// Filling the abbreviation.
FillSelectTestCase{{"Alabama", "California"}, "CA", "California"},
FillSelectTestCase{{"Alabama", "California"}, u"CA", u"California"},
// Attempting to fill the full name in a select full of abbreviations.
FillSelectTestCase{{"AL", "CA"}, "California", "CA"},
FillSelectTestCase{{"AL", "CA"}, u"California", u"CA"},
// Different case and diacritics.
FillSelectTestCase{{"QUÉBEC", "ALBERTA"}, "Quebec", "QUÉBEC"},
FillSelectTestCase{{"QUÉBEC", "ALBERTA"}, u"Quebec", u"QUÉBEC"},
// The value and the field options are different but normalize to the
// same (NB).
FillSelectTestCase{{"Nouveau-Brunswick", "Alberta"},
"New Brunswick",
u"New Brunswick",
nullptr,
"Nouveau-Brunswick"},
FillSelectTestCase{{"NB", "AB"}, "New Brunswick", nullptr, "NB"},
FillSelectTestCase{{"NB", "AB"}, "Nouveau-Brunswick", nullptr, "NB"},
u"Nouveau-Brunswick"},
FillSelectTestCase{{"NB", "AB"}, u"New Brunswick", nullptr, u"NB"},
FillSelectTestCase{{"NB", "AB"}, u"Nouveau-Brunswick", nullptr, u"NB"},
FillSelectTestCase{{"Nouveau-Brunswick", "Alberta"},
"NB",
u"NB",
nullptr,
"Nouveau-Brunswick"},
u"Nouveau-Brunswick"},
FillSelectTestCase{{"New Brunswick", "Alberta"},
"NB",
u"NB",
nullptr,
"New Brunswick"},
u"New Brunswick"},
// Inexact state names.
FillSelectTestCase{
{"SC - South Carolina", "CA - California", "NC - North Carolina"},
"California",
"CA - California"},
u"California",
u"CA - California"},
// Don't accidentally match "Virginia" to "West Virginia".
FillSelectTestCase{
{"WV - West Virginia", "VA - Virginia", "NV - North Virginia"},
"Virginia",
"VA - Virginia"},
u"Virginia",
u"VA - Virginia"},
// Do accidentally match "Virginia" to "West Virginia".
// TODO(crbug.com/624770): This test should not pass, but it does
// because "Virginia" is a substring of "West Virginia".
FillSelectTestCase{{"WV - West Virginia", "TX - Texas"},
"Virginia",
"WV - West Virginia"},
u"Virginia",
u"WV - West Virginia"},
// Tests that substring matches work for full state names (a full token
// match isn't required). Also tests that matches work for states with
// whitespace in the middle.
FillSelectTestCase{{"California.", "North Carolina."},
"North Carolina",
"North Carolina."},
u"North Carolina",
u"North Carolina."},
FillSelectTestCase{{"NC - North Carolina", "CA - California"},
"CA",
"CA - California"},
u"CA",
u"CA - California"},
// These are not states.
FillSelectTestCase{{"NCNCA", "SCNCA"}, "NC", ""}));
FillSelectTestCase{{"NCNCA", "SCNCA"}, u"NC", u""}));
TEST_F(AutofillFieldFillerTest, FillSelectWithCountries) {
AutofillField field;
@ -1278,16 +1272,12 @@ TEST_F(AutofillFieldFillerTest, FillStreetAddressTextArea) {
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
field.set_heuristic_type(ADDRESS_HOME_STREET_ADDRESS);
std::u16string value =
u"123 Fake St.\n"
u"Apt. 42";
std::u16string value = u"123 Fake St.\nApt. 42";
address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), value, "en-US");
filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string());
EXPECT_EQ(value, field.value);
std::u16string ja_value = UTF8ToUTF16(
"桜丘町26-1\n"
"セルリアンタワー6階");
std::u16string ja_value = u"桜丘町26-1\nセルリアンタワー6階";
address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), ja_value,
"ja-JP");
address()->set_language_code("ja-JP");
@ -1301,16 +1291,12 @@ TEST_F(AutofillFieldFillerTest, FillStreetAddressTextField) {
field.set_server_type(ADDRESS_HOME_STREET_ADDRESS);
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
std::u16string value =
u"123 Fake St.\n"
u"Apt. 42";
std::u16string value = u"123 Fake St.\nApt. 42";
address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), value, "en-US");
filler.FillFormField(field, address(), &field, /*cvc=*/std::u16string());
EXPECT_EQ(u"123 Fake St., Apt. 42", field.value);
std::u16string ja_value = UTF8ToUTF16(
"桜丘町26-1\n"
"セルリアンタワー6階");
std::u16string ja_value = u"桜丘町26-1\nセルリアンタワー6階";
address()->SetInfo(AutofillType(ADDRESS_HOME_STREET_ADDRESS), ja_value,
"ja-JP");
address()->set_language_code("ja-JP");
@ -1336,13 +1322,11 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithoutSplits) {
TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithEqualSizeSplits) {
// Case 2: card number broken up into four equal groups, of length 4.
CreditCardTestCase test;
test.card_number_ = "5187654321098765";
test.card_number_ = u"5187654321098765";
test.total_splits_ = 4;
int splits[] = {4, 4, 4, 4};
test.splits_ = std::vector<int>(splits, splits + base::size(splits));
std::string results[] = {"5187", "6543", "2109", "8765"};
test.expected_results_ =
std::vector<std::string>(results, results + base::size(results));
test.expected_results_ = {u"5187", u"6543", u"2109", u"8765"};
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
for (size_t i = 0; i < test.total_splits_; ++i) {
@ -1352,12 +1336,12 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithEqualSizeSplits) {
cc_number_part.set_credit_card_number_offset(4 * i);
// Fill with a card-number; should fill just the card_number_part.
credit_card()->SetNumber(ASCIIToUTF16(test.card_number_));
credit_card()->SetNumber(test.card_number_);
filler.FillFormField(cc_number_part, credit_card(), &cc_number_part,
/*cvc=*/std::u16string());
// Verify for expected results.
EXPECT_EQ(ASCIIToUTF16(test.expected_results_[i]),
EXPECT_EQ(test.expected_results_[i],
cc_number_part.value.substr(0, cc_number_part.max_length));
EXPECT_EQ(4 * i, cc_number_part.credit_card_number_offset());
}
@ -1366,25 +1350,23 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithEqualSizeSplits) {
AutofillField cc_number_full;
cc_number_full.set_heuristic_type(CREDIT_CARD_NUMBER);
credit_card()->SetNumber(ASCIIToUTF16(test.card_number_));
credit_card()->SetNumber(test.card_number_);
filler.FillFormField(cc_number_full, credit_card(), &cc_number_full,
/*cvc=*/std::u16string());
// Verify for expected results.
EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value);
EXPECT_EQ(test.card_number_, cc_number_full.value);
}
TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithUnequalSizeSplits) {
// Case 3: card with 15 digits number, broken up into three unequal groups, of
// lengths 4, 6, and 5.
CreditCardTestCase test;
test.card_number_ = "423456789012345";
test.card_number_ = u"423456789012345";
test.total_splits_ = 3;
int splits[] = {4, 6, 5};
test.splits_ = std::vector<int>(splits, splits + base::size(splits));
std::string results[] = {"4234", "567890", "12345"};
test.expected_results_ =
std::vector<std::string>(results, results + base::size(results));
test.expected_results_ = {u"4234", u"567890", u"12345"};
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
// Start executing test cases to verify parts and full credit card number.
@ -1395,12 +1377,12 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithUnequalSizeSplits) {
cc_number_part.set_credit_card_number_offset(GetNumberOffset(i, test));
// Fill with a card-number; should fill just the card_number_part.
credit_card()->SetNumber(ASCIIToUTF16(test.card_number_));
credit_card()->SetNumber(test.card_number_);
filler.FillFormField(cc_number_part, credit_card(), &cc_number_part,
/*cvc=*/std::u16string());
// Verify for expected results.
EXPECT_EQ(ASCIIToUTF16(test.expected_results_[i]),
EXPECT_EQ(test.expected_results_[i],
cc_number_part.value.substr(0, cc_number_part.max_length));
EXPECT_EQ(GetNumberOffset(i, test),
cc_number_part.credit_card_number_offset());
@ -1409,12 +1391,12 @@ TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithUnequalSizeSplits) {
// Verify that full card-number shall get fill properly as well.
AutofillField cc_number_full;
cc_number_full.set_heuristic_type(CREDIT_CARD_NUMBER);
credit_card()->SetNumber(ASCIIToUTF16(test.card_number_));
credit_card()->SetNumber(test.card_number_);
filler.FillFormField(cc_number_full, credit_card(), &cc_number_full,
/*cvc=*/std::u16string());
// Verify for expected results.
EXPECT_EQ(ASCIIToUTF16(test.card_number_), cc_number_full.value);
EXPECT_EQ(test.card_number_, cc_number_full.value);
}
TEST_F(AutofillFieldFillerTest, FindShortestSubstringMatchInSelect) {
@ -1464,8 +1446,8 @@ TEST_F(AutofillFieldFillerTest, FindShortestSubstringMatchInSelect) {
struct FillStateTextTestCase {
HtmlFieldType field_type;
size_t field_max_length;
std::string value_to_fill;
std::string expected_value;
std::u16string value_to_fill;
std::u16string expected_value;
bool should_fill;
};
@ -1483,12 +1465,12 @@ TEST_P(AutofillStateTextTest, FillStateText) {
FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
AutofillProfile address = test::GetFullProfile();
address.SetRawInfo(ADDRESS_HOME_STATE, UTF8ToUTF16(test_case.value_to_fill));
address.SetRawInfo(ADDRESS_HOME_STATE, test_case.value_to_fill);
bool has_filled =
filler.FillFormField(field, &address, &field, /*cvc=*/std::u16string());
EXPECT_EQ(test_case.should_fill, has_filled);
EXPECT_EQ(ASCIIToUTF16(test_case.expected_value), field.value);
EXPECT_EQ(test_case.expected_value, field.value);
}
INSTANTIATE_TEST_SUITE_P(
@ -1499,28 +1481,28 @@ INSTANTIATE_TEST_SUITE_P(
// should
// fill the state value as is.
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, /* default value */ 0,
"New York", "New York", true},
u"New York", u"New York", true},
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, /* default value */ 0,
"NY", "NY", true},
u"NY", u"NY", true},
// Filling a state to a text field with a maxlength value equal to the
// value's length should fill the state value as is.
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 8, "New York",
"New York", true},
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 8, u"New York",
u"New York", true},
// Filling a state to a text field with a maxlength value lower than the
// value's length but higher than the value's abbreviation should fill
// the state abbreviation.
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 2, "New York", "NY",
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 2, u"New York", u"NY",
true},
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 2, "NY", "NY", true},
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 2, u"NY", u"NY", true},
// Filling a state to a text field with a maxlength value lower than the
// value's length and the value's abbreviation should not fill at all.
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 1, "New York", "",
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 1, u"New York", u"",
false},
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 1, "NY", "", false},
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 1, u"NY", u"", false},
// Filling a state to a text field with a maxlength value lower than the
// value's length and that has no associated abbreviation should not
// fill at all.
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 3, "Quebec", "",
FillStateTextTestCase{HTML_TYPE_ADDRESS_LEVEL1, 3, u"Quebec", u"",
false}));
// Tests that the correct option is chosen in the selection box when one of the

@ -15,7 +15,6 @@
#include "testing/gtest/include/gtest/gtest.h"
using autofill::features::kAutofillFixFillableFieldTypes;
using base::ASCIIToUTF16;
namespace autofill {
@ -26,9 +25,9 @@ FieldRendererId MakeFieldRendererId() {
}
// Sets both the field label and parseable label to |label|.
void SetFieldLabels(AutofillField* field, const std::string& label) {
field->label = base::UTF8ToUTF16(label);
field->set_parseable_label(base::UTF8ToUTF16(label));
void SetFieldLabels(AutofillField* field, const std::u16string& label) {
field->label = label;
field->set_parseable_label(label);
}
} // namespace
@ -40,76 +39,76 @@ TEST(FormFieldTest, Match) {
EXPECT_TRUE(FormField::Match(&field, std::u16string(), MATCH_LABEL));
// Empty pattern matches non-empty string.
SetFieldLabels(&field, "a");
SetFieldLabels(&field, u"a");
EXPECT_TRUE(FormField::Match(&field, std::u16string(), MATCH_LABEL));
// Strictly empty pattern matches empty string.
SetFieldLabels(&field, "");
SetFieldLabels(&field, u"");
EXPECT_TRUE(FormField::Match(&field, u"^$", MATCH_LABEL));
// Strictly empty pattern does not match non-empty string.
SetFieldLabels(&field, "a");
SetFieldLabels(&field, u"a");
EXPECT_FALSE(FormField::Match(&field, u"^$", MATCH_LABEL));
// Non-empty pattern doesn't match empty string.
SetFieldLabels(&field, "");
SetFieldLabels(&field, u"");
EXPECT_FALSE(FormField::Match(&field, u"a", MATCH_LABEL));
// Beginning of line.
SetFieldLabels(&field, "head_tail");
SetFieldLabels(&field, u"head_tail");
EXPECT_TRUE(FormField::Match(&field, u"^head", MATCH_LABEL));
EXPECT_FALSE(FormField::Match(&field, u"^tail", MATCH_LABEL));
// End of line.
SetFieldLabels(&field, "head_tail");
SetFieldLabels(&field, u"head_tail");
EXPECT_FALSE(FormField::Match(&field, u"head$", MATCH_LABEL));
EXPECT_TRUE(FormField::Match(&field, u"tail$", MATCH_LABEL));
// Exact.
SetFieldLabels(&field, "head_tail");
SetFieldLabels(&field, u"head_tail");
EXPECT_FALSE(FormField::Match(&field, u"^head$", MATCH_LABEL));
EXPECT_FALSE(FormField::Match(&field, u"^tail$", MATCH_LABEL));
EXPECT_TRUE(FormField::Match(&field, u"^head_tail$", MATCH_LABEL));
// Escaped dots.
SetFieldLabels(&field, "m.i.");
SetFieldLabels(&field, u"m.i.");
// Note: This pattern is misleading as the "." characters are wild cards.
EXPECT_TRUE(FormField::Match(&field, u"m.i.", MATCH_LABEL));
EXPECT_TRUE(FormField::Match(&field, u"m\\.i\\.", MATCH_LABEL));
SetFieldLabels(&field, "mXiX");
SetFieldLabels(&field, u"mXiX");
EXPECT_TRUE(FormField::Match(&field, u"m.i.", MATCH_LABEL));
EXPECT_FALSE(FormField::Match(&field, u"m\\.i\\.", MATCH_LABEL));
// Repetition.
SetFieldLabels(&field, "headtail");
SetFieldLabels(&field, u"headtail");
EXPECT_TRUE(FormField::Match(&field, u"head.*tail", MATCH_LABEL));
SetFieldLabels(&field, "headXtail");
SetFieldLabels(&field, u"headXtail");
EXPECT_TRUE(FormField::Match(&field, u"head.*tail", MATCH_LABEL));
SetFieldLabels(&field, "headXXXtail");
SetFieldLabels(&field, u"headXXXtail");
EXPECT_TRUE(FormField::Match(&field, u"head.*tail", MATCH_LABEL));
SetFieldLabels(&field, "headtail");
SetFieldLabels(&field, u"headtail");
EXPECT_FALSE(FormField::Match(&field, u"head.+tail", MATCH_LABEL));
SetFieldLabels(&field, "headXtail");
SetFieldLabels(&field, u"headXtail");
EXPECT_TRUE(FormField::Match(&field, u"head.+tail", MATCH_LABEL));
SetFieldLabels(&field, "headXXXtail");
SetFieldLabels(&field, u"headXXXtail");
EXPECT_TRUE(FormField::Match(&field, u"head.+tail", MATCH_LABEL));
// Alternation.
SetFieldLabels(&field, "head_tail");
SetFieldLabels(&field, u"head_tail");
EXPECT_TRUE(FormField::Match(&field, u"head|other", MATCH_LABEL));
EXPECT_TRUE(FormField::Match(&field, u"tail|other", MATCH_LABEL));
EXPECT_FALSE(FormField::Match(&field, u"bad|good", MATCH_LABEL));
// Case sensitivity.
SetFieldLabels(&field, "xxxHeAd_tAiLxxx");
SetFieldLabels(&field, u"xxxHeAd_tAiLxxx");
EXPECT_TRUE(FormField::Match(&field, u"head_tail", MATCH_LABEL));
// Word boundaries.
SetFieldLabels(&field, "contains word:");
SetFieldLabels(&field, u"contains word:");
EXPECT_TRUE(FormField::Match(&field, u"\\bword\\b", MATCH_LABEL));
EXPECT_FALSE(FormField::Match(&field, u"\\bcon\\b", MATCH_LABEL));
// Make sure the circumflex in 'crepe' is not treated as a word boundary.
field.label = base::UTF8ToUTF16("cr\xC3\xAApe");
// Make sure the circumflex in 'crêpe' is not treated as a word boundary.
field.label = u"crêpe";
EXPECT_FALSE(FormField::Match(&field, u"\\bcr\\b", MATCH_LABEL));
}

@ -28,7 +28,7 @@ constexpr int kMinCommonNameAffixLength = 3;
constexpr int kMinCommonNameLongPrefixLength = 16;
// Regular expression for checking if |parseable_name| is valid after stripping
// affixes.
constexpr char kParseableNameValidationRe[] = "\\D";
constexpr char16_t kParseableNameValidationRe[] = u"\\D";
using NamePieces = std::vector<base::StringPiece16>;
using OptionalNamePieces = base::Optional<NamePieces>;
@ -85,7 +85,7 @@ size_t FindLongestCommonPrefixLengthInStringsWithMinimalLength(
// is the |autofill::kParseableNameValidationRe| regex.
bool IsValidParseableName(const base::StringPiece16 parseable_name) {
static const std::u16string kParseableNameValidationPattern =
base::UTF8ToUTF16(kParseableNameValidationRe);
kParseableNameValidationRe;
return MatchesPattern(parseable_name, kParseableNameValidationPattern);
}

@ -15,9 +15,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libphonenumber/phonenumber_api.h"
using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
namespace autofill {
using i18n::ConstructPhoneNumber;
@ -26,20 +23,15 @@ using i18n::ParsePhoneNumber;
using i18n::PhoneNumbersMatch;
TEST(PhoneNumberI18NTest, NormalizePhoneNumber) {
// "Large" digits.
std::u16string phone1(
UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90"
"\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98"
"\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93"));
// "Large" digits; these are not ASCII.
std::u16string phone1(u"");
EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), u"16507498323");
// Devanagari script digits.
std::u16string phone2(
UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3"
"\xD9\xA2\xD9\xA3\xD9\xA7\xD9\xA4\xD9\xA9"));
std::u16string phone2(u"١٦٥٠٨٣٢٣٧٤٩");
EXPECT_EQ(NormalizePhoneNumber(phone2, "US"), u"16508323749");
std::u16string phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5"));
std::u16string phone3(u"165033345٥");
EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), u"16503334255");
std::u16string phone4(u"+1(650)2346789");
@ -53,20 +45,20 @@ struct ParseNumberTestCase {
// Expected parsing result.
bool isPossibleNumber;
// Inputs.
std::string input;
std::u16string input;
std::string assumed_region;
// Further expectations.
std::string number;
std::string city_code;
std::string country_code;
std::u16string number;
std::u16string city_code;
std::u16string country_code;
std::string deduced_region;
};
namespace {
// Returns a string which is too long to be considered a phone number.
std::string GenerateTooLongString() {
return std::string(i18n::kMaxPhoneNumberSize + 1, '7');
std::u16string GenerateTooLongString() {
return std::u16string(i18n::kMaxPhoneNumberSize + 1, u'7');
}
} // namespace
@ -75,19 +67,18 @@ class ParseNumberTest : public testing::TestWithParam<ParseNumberTestCase> {};
TEST_P(ParseNumberTest, ParsePhoneNumber) {
auto test_case = GetParam();
SCOPED_TRACE("Testing phone number " + test_case.input);
SCOPED_TRACE(test_case.input.c_str());
std::u16string country_code, city_code, number;
std::string deduced_region;
::i18n::phonenumbers::PhoneNumber unused_i18n_number;
EXPECT_EQ(
test_case.isPossibleNumber,
ParsePhoneNumber(UTF8ToUTF16(test_case.input), test_case.assumed_region,
&country_code, &city_code, &number, &deduced_region,
&unused_i18n_number));
EXPECT_EQ(ASCIIToUTF16(test_case.number), number);
EXPECT_EQ(ASCIIToUTF16(test_case.city_code), city_code);
EXPECT_EQ(ASCIIToUTF16(test_case.country_code), country_code);
EXPECT_EQ(test_case.isPossibleNumber,
ParsePhoneNumber(test_case.input, test_case.assumed_region,
&country_code, &city_code, &number,
&deduced_region, &unused_i18n_number));
EXPECT_EQ(test_case.number, number);
EXPECT_EQ(test_case.city_code, city_code);
EXPECT_EQ(test_case.country_code, country_code);
EXPECT_EQ(test_case.deduced_region, deduced_region);
}
@ -96,99 +87,93 @@ INSTANTIATE_TEST_SUITE_P(
ParseNumberTest,
testing::Values(
// Test for empty string. Should give back empty strings.
ParseNumberTestCase{false, "", "US"},
ParseNumberTestCase{false, u"", "US"},
// Test for string with less than 7 digits. Should give back empty
// strings.
ParseNumberTestCase{false, "1234", "US"},
ParseNumberTestCase{false, u"1234", "US"},
// Too long strings should not be parsed.
ParseNumberTestCase{false, GenerateTooLongString(), "US"},
// Test for string with exactly 7 digits. It is too short.
// Should fail parsing in US.
ParseNumberTestCase{false, "17134567", "US"},
ParseNumberTestCase{false, u"17134567", "US"},
// Does not have area code, but still a possible number with
// unknown("ZZ") deduced region.
ParseNumberTestCase{true, "7134567", "US", "7134567", "", "", "ZZ"},
ParseNumberTestCase{true, u"7134567", "US", u"7134567", u"", u"", "ZZ"},
// Valid Canadian toll-free number.
ParseNumberTestCase{true, "3101234", "CA", "3101234", "", "", "ZZ"},
ParseNumberTestCase{true, u"3101234", "CA", u"3101234", u"", u"", "ZZ"},
// Test for string with greater than 7 digits but less than 10 digits.
// Should fail parsing in US.
ParseNumberTestCase{false, "123456789", "US"},
ParseNumberTestCase{false, u"123456789", "US"},
// Test for string with greater than 7 digits but less than 10 digits
// and
// separators.
// Should fail parsing in US.
ParseNumberTestCase{false, "12.345-6789", "US"},
ParseNumberTestCase{false, u"12.345-6789", "US"},
// Non-printable ASCII.
ParseNumberTestCase{false, "123\x11", "US"},
ParseNumberTestCase{false,
"123\x7F"
"567",
"US"},
ParseNumberTestCase{false, u"123", "US"},
ParseNumberTestCase{false, u"123\u007f567", "US"},
// Unicode noncharacters.
ParseNumberTestCase{false,
"1\xEF\xB7\xAF"
"23",
"US"},
// Invalid UTF8.
ParseNumberTestCase{false, "1\xC0", "US"},
ParseNumberTestCase{false, u"1\ufdef23", "US"},
// Invalid UTF16.
ParseNumberTestCase{false, u"1\xdfff", "US"},
// Test for string with exactly 10 digits.
// Should give back phone number and city code.
// This one has an incorrect area code but could still be a possible
// number with unknown("ZZ") deducted region.
ParseNumberTestCase{true, "1234567890", "US", "1234567890", "", "",
ParseNumberTestCase{true, u"1234567890", "US", u"1234567890", u"", u"",
"ZZ"},
// This is actually not a valid number because the first number after
// area code is 1. But it's still a possible number, just with deduced
// country set to unknown("ZZ").
ParseNumberTestCase{true, "6501567890", "US", "1567890", "650", "",
ParseNumberTestCase{true, u"6501567890", "US", u"1567890", u"650", u"",
"ZZ"},
ParseNumberTestCase{true, "6504567890", "US", "4567890", "650", "",
ParseNumberTestCase{true, u"6504567890", "US", u"4567890", u"650", u"",
"US"},
// Test for string with exactly 10 digits and separators.
// Should give back phone number and city code.
ParseNumberTestCase{true, "(650) 456-7890", "US", "4567890", "650", "",
"US"},
ParseNumberTestCase{true, u"(650) 456-7890", "US", u"4567890", u"650",
u"", "US"},
// Tests for string with over 10 digits.
// 01 is incorrect prefix in the USA, we interpret 011 as prefix, and
// rest is parsed as a Singapore number(country code "SG").
ParseNumberTestCase{true, "0116504567890", "US", "04567890", "", "65",
"SG"},
ParseNumberTestCase{true, u"0116504567890", "US", u"04567890", u"",
u"65", "SG"},
// 011 is a correct "dial out" prefix in the USA - the parsing should
// succeed.
ParseNumberTestCase{true, "01116504567890", "US", "4567890", "650", "1",
"US"},
ParseNumberTestCase{true, u"01116504567890", "US", u"4567890", u"650",
u"1", "US"},
// 011 is a correct "dial out" prefix in the USA but the rest of the
// number
// can't parse as a US number.
ParseNumberTestCase{true, "01178124567890", "US", "4567890", "812", "7",
"RU"},
ParseNumberTestCase{true, u"01178124567890", "US", u"4567890", u"812",
u"7", "RU"},
// Test for string with over 10 digits with separator characters.
// Should give back phone number, city code, and country code. "011" is
// US "dial out" code, which is discarded.
ParseNumberTestCase{true, "(0111) 650-456.7890", "US", "4567890", "650",
"1", "US"},
ParseNumberTestCase{true, u"(0111) 650-456.7890", "US", u"4567890",
u"650", u"1", "US"},
// Now try phone from Czech republic - it has 00 dial out code, 420
// country
// code and variable length area codes.
ParseNumberTestCase{true, "+420 27-89.10.112", "US", "910112", "278",
"420", "CZ"},
ParseNumberTestCase{false, "27-89.10.112", "US"},
ParseNumberTestCase{true, "27-89.10.112", "CZ", "910112", "278", "",
ParseNumberTestCase{true, u"+420 27-89.10.112", "US", u"910112", u"278",
u"420", "CZ"},
ParseNumberTestCase{false, u"27-89.10.112", "US"},
ParseNumberTestCase{true, u"27-89.10.112", "CZ", u"910112", u"278", u"",
"CZ"},
ParseNumberTestCase{false, "420 57-89.10.112", "US"},
ParseNumberTestCase{true, "420 57-89.10.112", "CZ", "910112", "578",
"420", "CZ"},
ParseNumberTestCase{false, u"420 57-89.10.112", "US"},
ParseNumberTestCase{true, u"420 57-89.10.112", "CZ", u"910112", u"578",
u"420", "CZ"},
// Parses vanity numbers.
ParseNumberTestCase{true, "1-650-FLOWERS", "US", "3569377", "650", "1",
"US"},
ParseNumberTestCase{true, u"1-650-FLOWERS", "US", u"3569377", u"650",
u"1", "US"},
// 800 is not an area code, but the destination code. In our library
// these
// codes should be treated the same as area codes.
ParseNumberTestCase{true, "1-800-FLOWERS", "US", "3569377", "800", "1",
"US"},
ParseNumberTestCase{true, u"1-800-FLOWERS", "US", u"3569377", u"800",
u"1", "US"},
// Don't add a country code where there was none.
ParseNumberTestCase{true, "(08) 450 777 7777", "DE", "7777777", "8450",
"", "DE"}));
ParseNumberTestCase{true, u"(08) 450 777 7777", "DE", u"7777777",
u"8450", u"", "DE"}));
TEST(PhoneNumberI18NTest, ConstructPhoneNumber) {
std::u16string number;
@ -316,18 +301,18 @@ TEST(PhoneNumberUtilTest, FormatPhoneForDisplay) {
// Test for the GetFormattedPhoneNumberForDisplay method.
struct PhoneNumberFormatCase {
PhoneNumberFormatCase(const char* phone,
const char* country,
const char* expected_format,
PhoneNumberFormatCase(const char16_t* phone,
const char16_t* country,
const char16_t* expected_format,
const char* locale = "")
: phone(phone),
country(country),
expected_format(expected_format),
locale(locale) {}
const char* phone;
const char* country;
const char* expected_format;
const char16_t* phone;
const char16_t* country;
const char16_t* expected_format;
const char* locale;
};
@ -337,13 +322,10 @@ class GetFormattedPhoneNumberForDisplayTest
TEST_P(GetFormattedPhoneNumberForDisplayTest,
GetFormattedPhoneNumberForDisplay) {
AutofillProfile profile;
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER,
base::UTF8ToUTF16(GetParam().phone));
profile.SetRawInfo(ADDRESS_HOME_COUNTRY,
base::UTF8ToUTF16(GetParam().country));
EXPECT_EQ(GetParam().expected_format,
base::UTF16ToUTF8(i18n::GetFormattedPhoneNumberForDisplay(
profile, GetParam().locale)));
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, GetParam().phone);
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, GetParam().country);
EXPECT_EQ(GetParam().expected_format, i18n::GetFormattedPhoneNumberForDisplay(
profile, GetParam().locale));
}
INSTANTIATE_TEST_SUITE_P(
@ -354,104 +336,104 @@ INSTANTIATE_TEST_SUITE_P(
// US phone in US.
//////////////////////////
// Formatted phone numbers.
PhoneNumberFormatCase("+1 415-555-5555", "US", "+1 415-555-5555"),
PhoneNumberFormatCase("1 415-555-5555", "US", "+1 415-555-5555"),
PhoneNumberFormatCase("415-555-5555", "US", "+1 415-555-5555"),
PhoneNumberFormatCase(u"+1 415-555-5555", u"US", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"1 415-555-5555", u"US", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"415-555-5555", u"US", u"+1 415-555-5555"),
// Raw phone numbers.
PhoneNumberFormatCase("+14155555555", "US", "+1 415-555-5555"),
PhoneNumberFormatCase("14155555555", "US", "+1 415-555-5555"),
PhoneNumberFormatCase("4155555555", "US", "+1 415-555-5555"),
PhoneNumberFormatCase(u"+14155555555", u"US", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"14155555555", u"US", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"4155555555", u"US", u"+1 415-555-5555"),
//////////////////////////
// US phone in CA.
//////////////////////////
// Formatted phone numbers.
PhoneNumberFormatCase("+1 415-555-5555", "CA", "+1 415-555-5555"),
PhoneNumberFormatCase("1 415-555-5555", "CA", "+1 415-555-5555"),
PhoneNumberFormatCase("415-555-5555", "CA", "+1 415-555-5555"),
PhoneNumberFormatCase(u"+1 415-555-5555", u"CA", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"1 415-555-5555", u"CA", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"415-555-5555", u"CA", u"+1 415-555-5555"),
// Raw phone numbers.
PhoneNumberFormatCase("+14155555555", "CA", "+1 415-555-5555"),
PhoneNumberFormatCase("14155555555", "CA", "+1 415-555-5555"),
PhoneNumberFormatCase("4155555555", "CA", "+1 415-555-5555"),
PhoneNumberFormatCase(u"+14155555555", u"CA", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"14155555555", u"CA", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"4155555555", u"CA", u"+1 415-555-5555"),
//////////////////////////
// US phone in AU.
//////////////////////////
// A US phone with the country code is correctly formatted as an US
// number.
PhoneNumberFormatCase("+1 415-555-5555", "AU", "+1 415-555-5555"),
PhoneNumberFormatCase("1 415-555-5555", "AU", "+1 415-555-5555"),
PhoneNumberFormatCase(u"+1 415-555-5555", u"AU", u"+1 415-555-5555"),
PhoneNumberFormatCase(u"1 415-555-5555", u"AU", u"+1 415-555-5555"),
// Without a country code, the phone is formatted for the profile's
// country, if it's valid.
PhoneNumberFormatCase("2 9374 4000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase(u"2 9374 4000", u"AU", u"+61 2 9374 4000"),
// Without a country code, formatting returns the number as entered by
// user, if it's invalid.
PhoneNumberFormatCase("415-555-5555", "AU", "4155555555"),
PhoneNumberFormatCase(u"415-555-5555", u"AU", u"4155555555"),
//////////////////////////
// US phone in MX.
//////////////////////////
// A US phone with the country code is correctly formatted as an US
// number.
PhoneNumberFormatCase("+1 415-555-5555", "MX", "+1 415-555-5555"),
PhoneNumberFormatCase(u"+1 415-555-5555", u"MX", u"+1 415-555-5555"),
// "+52 415 555 5555" is a valid number for Mexico,
PhoneNumberFormatCase("1 415-555-5555", "MX", "+52 415 555 5555"),
PhoneNumberFormatCase(u"1 415-555-5555", u"MX", u"+52 415 555 5555"),
// Without a country code, the phone is formatted for the profile's
// country.
PhoneNumberFormatCase("415-555-5555", "MX", "+52 415 555 5555"),
PhoneNumberFormatCase(u"415-555-5555", u"MX", u"+52 415 555 5555"),
//////////////////////////
// AU phone in AU.
//////////////////////////
// Formatted phone numbers.
PhoneNumberFormatCase("+61 2 9374 4000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase("61 2 9374 4000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase("02 9374 4000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase("2 9374 4000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase(u"+61 2 9374 4000", u"AU", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"61 2 9374 4000", u"AU", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"02 9374 4000", u"AU", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"2 9374 4000", u"AU", u"+61 2 9374 4000"),
// Raw phone numbers.
PhoneNumberFormatCase("+61293744000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase("61293744000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase("0293744000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase("293744000", "AU", "+61 2 9374 4000"),
PhoneNumberFormatCase(u"+61293744000", u"AU", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"61293744000", u"AU", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"0293744000", u"AU", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"293744000", u"AU", u"+61 2 9374 4000"),
//////////////////////////
// AU phone in US.
//////////////////////////
// An AU phone with the country code is correctly formatted as an AU
// number.
PhoneNumberFormatCase("+61 2 9374 4000", "US", "+61 2 9374 4000"),
PhoneNumberFormatCase("61 2 9374 4000", "US", "+61 2 9374 4000"),
PhoneNumberFormatCase(u"+61 2 9374 4000", u"US", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"61 2 9374 4000", u"US", u"+61 2 9374 4000"),
// Without a country code, the phone is formatted for the profile's
// country.
// This local AU number is associated with US profile, the number is
// not a valid US number, therefore formatting will just return what
// user entered.
PhoneNumberFormatCase("02 9374 4000", "US", "0293744000"),
PhoneNumberFormatCase(u"02 9374 4000", u"US", u"0293744000"),
// This local GR(Greece) number is formatted as an US number, if it's
// valid US number.
PhoneNumberFormatCase("22 6800 0090", "US", "+1 226-800-0090"),
PhoneNumberFormatCase(u"22 6800 0090", u"US", u"+1 226-800-0090"),
//////////////////////////
// MX phone in MX.
//////////////////////////
// Formatted phone numbers.
PhoneNumberFormatCase("+52 55 5342 8400", "MX", "+52 55 5342 8400"),
PhoneNumberFormatCase("52 55 5342 8400", "MX", "+52 55 5342 8400"),
PhoneNumberFormatCase("55 5342 8400", "MX", "+52 55 5342 8400"),
PhoneNumberFormatCase(u"+52 55 5342 8400", u"MX", u"+52 55 5342 8400"),
PhoneNumberFormatCase(u"52 55 5342 8400", u"MX", u"+52 55 5342 8400"),
PhoneNumberFormatCase(u"55 5342 8400", u"MX", u"+52 55 5342 8400"),
// Raw phone numbers.
PhoneNumberFormatCase("+525553428400", "MX", "+52 55 5342 8400"),
PhoneNumberFormatCase("525553428400", "MX", "+52 55 5342 8400"),
PhoneNumberFormatCase("5553428400", "MX", "+52 55 5342 8400"),
PhoneNumberFormatCase(u"+525553428400", u"MX", u"+52 55 5342 8400"),
PhoneNumberFormatCase(u"525553428400", u"MX", u"+52 55 5342 8400"),
PhoneNumberFormatCase(u"5553428400", u"MX", u"+52 55 5342 8400"),
//////////////////////////
// MX phone in US.
//////////////////////////
// A MX phone with the country code is correctly formatted as a MX
// number.
PhoneNumberFormatCase("+52 55 5342 8400", "US", "+52 55 5342 8400"),
PhoneNumberFormatCase("52 55 5342 8400", "US", "+52 55 5342 8400"),
PhoneNumberFormatCase(u"+52 55 5342 8400", u"US", u"+52 55 5342 8400"),
PhoneNumberFormatCase(u"52 55 5342 8400", u"US", u"+52 55 5342 8400"),
// This number is not a valid US number, we won't try to format.
PhoneNumberFormatCase("55 5342 8400", "US", "5553428400")));
PhoneNumberFormatCase(u"55 5342 8400", u"US", u"5553428400")));
INSTANTIATE_TEST_SUITE_P(
GetFormattedPhoneNumberForDisplay_EdgeCases,
@ -461,31 +443,40 @@ INSTANTIATE_TEST_SUITE_P(
// No country.
//////////////////////////
// Fallback to locale if no country is set.
PhoneNumberFormatCase("52 55 5342 8400",
"",
"+52 55 5342 8400",
PhoneNumberFormatCase(u"52 55 5342 8400",
u"",
u"+52 55 5342 8400",
"es_MX"),
PhoneNumberFormatCase("55 5342 8400", "", "+52 55 5342 8400", "es_MX"),
PhoneNumberFormatCase("61 2 9374 4000", "", "+61 2 9374 4000", "en_AU"),
PhoneNumberFormatCase("02 9374 4000", "", "+61 2 9374 4000", "en_AU"),
PhoneNumberFormatCase(u"55 5342 8400",
u"",
u"+52 55 5342 8400",
"es_MX"),
PhoneNumberFormatCase(u"61 2 9374 4000",
u"",
u"+61 2 9374 4000",
"en_AU"),
PhoneNumberFormatCase(u"02 9374 4000",
u"",
u"+61 2 9374 4000",
"en_AU"),
// Numbers in local format yet are invalid with user locale, user might
// be trying to enter a foreign number, calling formatting will just
// return what the user entered.
PhoneNumberFormatCase("55 5342 8400", "", "5553428400", "en_US"),
PhoneNumberFormatCase("55 5342 8400", "", "5553428400"),
PhoneNumberFormatCase("226 123 1234", "", "2261231234", "en_US"),
PhoneNumberFormatCase("293744000", "", "293744000"),
PhoneNumberFormatCase("02 9374 4000", "", "0293744000"),
PhoneNumberFormatCase(u"55 5342 8400", u"", u"5553428400", "en_US"),
PhoneNumberFormatCase(u"55 5342 8400", u"", u"5553428400"),
PhoneNumberFormatCase(u"226 123 1234", u"", u"2261231234", "en_US"),
PhoneNumberFormatCase(u"293744000", u"", u"293744000"),
PhoneNumberFormatCase(u"02 9374 4000", u"", u"0293744000"),
//////////////////////////
// No country or locale.
//////////////////////////
// Format according to the country code.
PhoneNumberFormatCase("61 2 9374 4000", "", "+61 2 9374 4000"),
PhoneNumberFormatCase("52 55 5342 8400", "", "+52 55 5342 8400"),
PhoneNumberFormatCase("1 415 555 5555", "", "+1 415-555-5555"),
PhoneNumberFormatCase(u"61 2 9374 4000", u"", u"+61 2 9374 4000"),
PhoneNumberFormatCase(u"52 55 5342 8400", u"", u"+52 55 5342 8400"),
PhoneNumberFormatCase(u"1 415 555 5555", u"", u"+1 415-555-5555"),
// If no country code is found, formats for US.
PhoneNumberFormatCase("415-555-5555", "", "+1 415-555-5555")));
PhoneNumberFormatCase(u"415-555-5555", u"", u"+1 415-555-5555")));
} // namespace autofill

@ -82,10 +82,10 @@ namespace {
const char kTestGUID[] = "00000000-0000-0000-0000-000000000001";
const char kTestNumber[] = "4234567890123456"; // Visa
const char16_t kTestNumber16[] = u"4234567890123456";
const char kTestCvc[] = "123";
const char16_t kTestCvc16[] = u"123";
#if !defined(OS_IOS)
const char kTestCvc[] = "123";
// Base64 encoding of "This is a test challenge".
constexpr char kTestChallenge[] = "VGhpcyBpcyBhIHRlc3QgY2hhbGxlbmdl";
// Base64 encoding of "This is a test Credential ID".
@ -1844,8 +1844,8 @@ TEST_F(CreditCardAccessManagerTest, FetchCreditCardUsesUnmaskedCardCache) {
CreateServerCard(kTestGUID, kTestNumber, /*masked=*/false);
CreditCard* unmasked_card =
credit_card_access_manager_->GetCreditCard(kTestGUID);
credit_card_access_manager_->CacheUnmaskedCardInfo(
*unmasked_card, base::UTF8ToUTF16(kTestCvc));
credit_card_access_manager_->CacheUnmaskedCardInfo(*unmasked_card,
kTestCvc16);
CreateServerCard(kTestGUID, kTestNumber, /*masked=*/true);
CreditCard* masked_card =

@ -78,6 +78,7 @@ using structured_address::StructuredNamesEnabled;
namespace {
const char kPrimaryAccountEmail[] = "syncuser@example.com";
const char16_t kPrimaryAccountEmail16[] = u"syncuser@example.com";
const char kSyncTransportAccountEmail[] = "transport@example.com";
enum UserMode { USER_MODE_NORMAL, USER_MODE_INCOGNITO };
@ -3975,7 +3976,7 @@ TEST_F(PersonalDataManagerTest, ClearAllLocalData) {
// merge logic works correctly.
typedef struct {
autofill::ServerFieldType field_type;
std::string field_value;
std::u16string field_value;
} ProfileField;
typedef std::vector<ProfileField> ProfileFields;
@ -4036,7 +4037,7 @@ TEST_P(SaveImportedProfileTest, SaveImportedProfile) {
// Apply changes to the original profile (if applicable).
for (ProfileField change : test_case.changes_to_original) {
original_profile.SetRawInfoWithVerificationStatus(
change.field_type, base::UTF8ToUTF16(change.field_value),
change.field_type, change.field_value,
structured_address::VerificationStatus::kObserved);
}
@ -4052,7 +4053,7 @@ TEST_P(SaveImportedProfileTest, SaveImportedProfile) {
// Apply changes to the second profile (if applicable).
for (ProfileField change : test_case.changes_to_new) {
profile2.SetRawInfoWithVerificationStatus(
change.field_type, base::UTF8ToUTF16(change.field_value),
change.field_type, change.field_value,
structured_address::VerificationStatus::kObserved);
}
@ -4085,7 +4086,7 @@ TEST_P(SaveImportedProfileTest, SaveImportedProfile) {
// Make sure the new information was merged correctly.
for (ProfileField changed_field : test_case.changed_field_values) {
EXPECT_EQ(base::UTF8ToUTF16(changed_field.field_value),
EXPECT_EQ(changed_field.field_value,
saved_profiles.front()->GetRawInfo(changed_field.field_type));
}
// Verify that the merged profile's use count, use date and modification
@ -4121,66 +4122,66 @@ INSTANTIATE_TEST_SUITE_P(
// Test that saving an identical profile except for the name results
// in two profiles being saved.
SaveImportedProfileTestCase{ProfileFields(),
{{NAME_FIRST, "Marionette"}}},
{{NAME_FIRST, u"Marionette"}}},
// Test that saving an identical profile except with the middle name
// initial instead of the full middle name results in the profiles
// getting merged and the full middle name being kept.
SaveImportedProfileTestCase{
ProfileFields(),
{{NAME_MIDDLE, "M"}},
{{NAME_MIDDLE, "Mitchell"},
{NAME_FULL, "Marion Mitchell Morrison"}}},
{{NAME_MIDDLE, u"M"}},
{{NAME_MIDDLE, u"Mitchell"},
{NAME_FULL, u"Marion Mitchell Morrison"}}},
// Test that saving an identical profile except with the full middle
// name instead of the middle name initial results in the profiles
// getting merged and the full middle name replacing the initial.
SaveImportedProfileTestCase{{{NAME_MIDDLE, "M"}},
{{NAME_MIDDLE, "Mitchell"}},
{{NAME_MIDDLE, "Mitchell"}}},
SaveImportedProfileTestCase{{{NAME_MIDDLE, u"M"}},
{{NAME_MIDDLE, u"Mitchell"}},
{{NAME_MIDDLE, u"Mitchell"}}},
// Test that saving an identical profile except with no middle name
// results in the profiles getting merged and the full middle name
// being kept.
SaveImportedProfileTestCase{ProfileFields(),
{{NAME_MIDDLE, ""}},
{{NAME_MIDDLE, "Mitchell"}}},
{{NAME_MIDDLE, u""}},
{{NAME_MIDDLE, u"Mitchell"}}},
// Test that saving an identical profile except with a middle name
// initial results in the profiles getting merged and the middle
// name initial being saved.
SaveImportedProfileTestCase{{{NAME_MIDDLE, ""}},
{{NAME_MIDDLE, "M"}},
{{NAME_MIDDLE, "M"}}},
SaveImportedProfileTestCase{{{NAME_MIDDLE, u""}},
{{NAME_MIDDLE, u"M"}},
{{NAME_MIDDLE, u"M"}}},
// Test that saving an identical profile except with a middle name
// results in the profiles getting merged and the full middle name
// being saved.
SaveImportedProfileTestCase{{{NAME_MIDDLE, ""}},
{{NAME_MIDDLE, "Mitchell"}},
{{NAME_MIDDLE, "Mitchell"}}},
SaveImportedProfileTestCase{{{NAME_MIDDLE, u""}},
{{NAME_MIDDLE, u"Mitchell"}},
{{NAME_MIDDLE, u"Mitchell"}}},
// Test that saving a identical profile except with the full name
// set instead of the name parts results in the two profiles being
// merged and all the name parts kept and the full name being added.
SaveImportedProfileTestCase{
{
{NAME_FIRST, "Marion"},
{NAME_MIDDLE, "Mitchell"},
{NAME_LAST, "Morrison"},
{NAME_FULL, ""},
{NAME_FIRST, u"Marion"},
{NAME_MIDDLE, u"Mitchell"},
{NAME_LAST, u"Morrison"},
{NAME_FULL, u""},
},
{
{NAME_FIRST, ""},
{NAME_MIDDLE, ""},
{NAME_LAST, ""},
{NAME_FULL, "Marion Mitchell Morrison"},
{NAME_FIRST, u""},
{NAME_MIDDLE, u""},
{NAME_LAST, u""},
{NAME_FULL, u"Marion Mitchell Morrison"},
},
{
{NAME_FIRST, "Marion"},
{NAME_MIDDLE, "Mitchell"},
{NAME_LAST, "Morrison"},
{NAME_FULL, "Marion Mitchell Morrison"},
{NAME_FIRST, u"Marion"},
{NAME_MIDDLE, u"Mitchell"},
{NAME_LAST, u"Morrison"},
{NAME_FULL, u"Marion Mitchell Morrison"},
},
},
@ -4190,22 +4191,22 @@ INSTANTIATE_TEST_SUITE_P(
// added.
SaveImportedProfileTestCase{
{
{NAME_FIRST, ""},
{NAME_MIDDLE, ""},
{NAME_LAST, ""},
{NAME_FULL, "Marion Mitchell Morrison"},
{NAME_FIRST, u""},
{NAME_MIDDLE, u""},
{NAME_LAST, u""},
{NAME_FULL, u"Marion Mitchell Morrison"},
},
{
{NAME_FIRST, "Marion"},
{NAME_MIDDLE, "Mitchell"},
{NAME_LAST, "Morrison"},
{NAME_FULL, ""},
{NAME_FIRST, u"Marion"},
{NAME_MIDDLE, u"Mitchell"},
{NAME_LAST, u"Morrison"},
{NAME_FULL, u""},
},
{
{NAME_FIRST, "Marion"},
{NAME_MIDDLE, "Mitchell"},
{NAME_LAST, "Morrison"},
{NAME_FULL, "Marion Mitchell Morrison"},
{NAME_FIRST, u"Marion"},
{NAME_MIDDLE, u"Mitchell"},
{NAME_LAST, u"Morrison"},
{NAME_FULL, u"Marion Mitchell Morrison"},
},
},
@ -4214,16 +4215,16 @@ INSTANTIATE_TEST_SUITE_P(
// names are different.
SaveImportedProfileTestCase{
{
{NAME_FIRST, "Marion"},
{NAME_MIDDLE, "Mitchell"},
{NAME_LAST, "Morrison"},
{NAME_FULL, ""},
{NAME_FIRST, u"Marion"},
{NAME_MIDDLE, u"Mitchell"},
{NAME_LAST, u"Morrison"},
{NAME_FULL, u""},
},
{
{NAME_FIRST, ""},
{NAME_MIDDLE, ""},
{NAME_LAST, ""},
{NAME_FULL, "John Thompson Smith"},
{NAME_FIRST, u""},
{NAME_MIDDLE, u""},
{NAME_LAST, u""},
{NAME_FULL, u"John Thompson Smith"},
},
},
@ -4232,16 +4233,16 @@ INSTANTIATE_TEST_SUITE_P(
// names are different.
SaveImportedProfileTestCase{
{
{NAME_FIRST, ""},
{NAME_MIDDLE, ""},
{NAME_LAST, ""},
{NAME_FULL, "John Thompson Smith"},
{NAME_FIRST, u""},
{NAME_MIDDLE, u""},
{NAME_LAST, u""},
{NAME_FULL, u"John Thompson Smith"},
},
{
{NAME_FIRST, "Marion"},
{NAME_MIDDLE, "Mitchell"},
{NAME_LAST, "Morrison"},
{NAME_FULL, ""},
{NAME_FIRST, u"Marion"},
{NAME_MIDDLE, u"Mitchell"},
{NAME_LAST, u"Morrison"},
{NAME_FULL, u""},
},
},
@ -4249,146 +4250,147 @@ INSTANTIATE_TEST_SUITE_P(
// address line results in two profiles being saved.
SaveImportedProfileTestCase{
ProfileFields(),
{{ADDRESS_HOME_LINE1, "123 Aquarium St."}}},
{{ADDRESS_HOME_LINE1, u"123 Aquarium St."}}},
// Test that saving an identical profile except for the second
// address line results in two profiles being saved.
SaveImportedProfileTestCase{ProfileFields(),
{{ADDRESS_HOME_LINE2, "unit 7"}}},
{{ADDRESS_HOME_LINE2, u"unit 7"}}},
// Tests that saving an identical profile that has a new piece of
// information (company name) results in a merge and that the
// original empty value gets overwritten by the new information.
SaveImportedProfileTestCase{{{COMPANY_NAME, ""}},
SaveImportedProfileTestCase{{{COMPANY_NAME, u""}},
ProfileFields(),
{{COMPANY_NAME, "Fox"}}},
{{COMPANY_NAME, u"Fox"}}},
// Tests that saving an identical profile except a loss of
// information results in a merge but the original value is not
// overwritten (no information loss).
SaveImportedProfileTestCase{ProfileFields(),
{{COMPANY_NAME, ""}},
{{COMPANY_NAME, "Fox"}}},
{{COMPANY_NAME, u""}},
{{COMPANY_NAME, u"Fox"}}},
// Tests that saving an identical profile except a slightly
// different postal code results in a merge with the new value kept.
SaveImportedProfileTestCase{{{ADDRESS_HOME_ZIP, "R2C 0A1"}},
{{ADDRESS_HOME_ZIP, "R2C0A1"}},
{{ADDRESS_HOME_ZIP, "R2C0A1"}}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_ZIP, "R2C0A1"}},
{{ADDRESS_HOME_ZIP, "R2C 0A1"}},
{{ADDRESS_HOME_ZIP, "R2C 0A1"}}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_ZIP, "r2c 0a1"}},
{{ADDRESS_HOME_ZIP, "R2C0A1"}},
{{ADDRESS_HOME_ZIP, "R2C0A1"}}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_ZIP, u"R2C 0A1"}},
{{ADDRESS_HOME_ZIP, u"R2C0A1"}},
{{ADDRESS_HOME_ZIP, u"R2C0A1"}}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_ZIP, u"R2C0A1"}},
{{ADDRESS_HOME_ZIP, u"R2C 0A1"}},
{{ADDRESS_HOME_ZIP, u"R2C 0A1"}}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_ZIP, u"r2c 0a1"}},
{{ADDRESS_HOME_ZIP, u"R2C0A1"}},
{{ADDRESS_HOME_ZIP, u"R2C0A1"}}},
// Tests that saving an identical profile plus a new piece of
// information on the address line 2 results in a merge and that the
// original empty value gets overwritten by the new information.
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE2, ""}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE2, u""}},
ProfileFields(),
{{ADDRESS_HOME_LINE2, "unit 5"}}},
{{ADDRESS_HOME_LINE2, u"unit 5"}}},
// Tests that saving an identical profile except a loss of
// information on the address line 2 results in a merge but that the
// original value gets not overwritten (no information loss).
SaveImportedProfileTestCase{ProfileFields(),
{{ADDRESS_HOME_LINE2, ""}},
{{ADDRESS_HOME_LINE2, "unit 5"}}},
{{ADDRESS_HOME_LINE2, u""}},
{{ADDRESS_HOME_LINE2, u"unit 5"}}},
// Tests that saving an identical except with more punctuation in
// the fist address line, while the second is empty, results in a
// merge and that the original address gets overwritten.
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE2, ""}},
{{ADDRESS_HOME_LINE2, ""},
{ADDRESS_HOME_LINE1, "123, Zoo St."}},
{{ADDRESS_HOME_LINE1, "123, Zoo St."}}},
SaveImportedProfileTestCase{
{{ADDRESS_HOME_LINE2, u""}},
{{ADDRESS_HOME_LINE2, u""},
{ADDRESS_HOME_LINE1, u"123, Zoo St."}},
{{ADDRESS_HOME_LINE1, u"123, Zoo St."}}},
// Tests that saving an identical profile except with less
// punctuation in the fist address line, while the second is empty,
// results in a merge and that the longer address is retained.
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE2, ""},
{ADDRESS_HOME_LINE1, "123, Zoo St."}},
{{ADDRESS_HOME_LINE2, ""}},
{{ADDRESS_HOME_LINE1, "123 Zoo St"}}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE2, u""},
{ADDRESS_HOME_LINE1, u"123, Zoo St."}},
{{ADDRESS_HOME_LINE2, u""}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St"}}},
// Tests that saving an identical profile except additional
// punctuation in the two address lines results in a merge and that
// the newer address is retained.
SaveImportedProfileTestCase{ProfileFields(),
{{ADDRESS_HOME_LINE1, "123, Zoo St."},
{ADDRESS_HOME_LINE2, "unit. 5"}},
{{ADDRESS_HOME_LINE1, "123, Zoo St."},
{ADDRESS_HOME_LINE2, "unit. 5"}}},
{{ADDRESS_HOME_LINE1, u"123, Zoo St."},
{ADDRESS_HOME_LINE2, u"unit. 5"}},
{{ADDRESS_HOME_LINE1, u"123, Zoo St."},
{ADDRESS_HOME_LINE2, u"unit. 5"}}},
// Tests that saving an identical profile except less punctuation in
// the two address lines results in a merge and that the newer
// address is retained.
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE1, "123, Zoo St."},
{ADDRESS_HOME_LINE2, "unit. 5"}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE1, u"123, Zoo St."},
{ADDRESS_HOME_LINE2, u"unit. 5"}},
ProfileFields(),
{{ADDRESS_HOME_LINE1, "123 Zoo St"},
{ADDRESS_HOME_LINE2, "unit 5"}}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St"},
{ADDRESS_HOME_LINE2, u"unit 5"}}},
// Tests that saving an identical profile with accented characters
// in the two address lines results in a merge and that the newer
// address is retained.
SaveImportedProfileTestCase{ProfileFields(),
{{ADDRESS_HOME_LINE1, "123 Zôö St"},
{ADDRESS_HOME_LINE2, "üñìt 5"}},
{{ADDRESS_HOME_LINE1, "123 Zôö St"},
{ADDRESS_HOME_LINE2, "üñìt 5"}}},
{{ADDRESS_HOME_LINE1, u"123 Zôö St"},
{ADDRESS_HOME_LINE2, u"üñìt 5"}},
{{ADDRESS_HOME_LINE1, u"123 Zôö St"},
{ADDRESS_HOME_LINE2, u"üñìt 5"}}},
// Tests that saving an identical profile without accented
// characters in the two address lines results in a merge and that
// the newer address is retained.
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE1, "123 Zôö St"},
{ADDRESS_HOME_LINE2, "üñìt 5"}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_LINE1, u"123 Zôö St"},
{ADDRESS_HOME_LINE2, u"üñìt 5"}},
ProfileFields(),
{{ADDRESS_HOME_LINE1, "123 Zoo St"},
{ADDRESS_HOME_LINE2, "unit 5"}}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St"},
{ADDRESS_HOME_LINE2, u"unit 5"}}},
// Tests that saving an identical profile except that the address
// line 1 is in the address line 2 results in a merge and that the
// multi-lne address is retained.
SaveImportedProfileTestCase{
ProfileFields(),
{{ADDRESS_HOME_LINE1, "123 Zoo St, unit 5"},
{ADDRESS_HOME_LINE2, ""}},
{{ADDRESS_HOME_LINE1, "123 Zoo St"},
{ADDRESS_HOME_LINE2, "unit 5"}}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St, unit 5"},
{ADDRESS_HOME_LINE2, u""}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St"},
{ADDRESS_HOME_LINE2, u"unit 5"}}},
// Tests that saving an identical profile except that the address
// line 2 contains part of the old address line 1 results in a merge
// and that the original address lines of the reference profile get
// overwritten.
SaveImportedProfileTestCase{
{{ADDRESS_HOME_LINE1, "123 Zoo St, unit 5"},
{ADDRESS_HOME_LINE2, ""}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St, unit 5"},
{ADDRESS_HOME_LINE2, u""}},
ProfileFields(),
{{ADDRESS_HOME_LINE1, "123 Zoo St"},
{ADDRESS_HOME_LINE2, "unit 5"}}},
{{ADDRESS_HOME_LINE1, u"123 Zoo St"},
{ADDRESS_HOME_LINE2, u"unit 5"}}},
// Tests that saving an identical profile except that the state is
// the abbreviation instead of the full form results in a merge and
// that the original state gets overwritten.
SaveImportedProfileTestCase{{{ADDRESS_HOME_STATE, "California"}},
SaveImportedProfileTestCase{{{ADDRESS_HOME_STATE, u"California"}},
ProfileFields(),
{{ADDRESS_HOME_STATE, "CA"}}},
{{ADDRESS_HOME_STATE, u"CA"}}},
// Tests that saving an identical profile except that the state is
// the full form instead of the abbreviation results in a merge and
// that the abbreviated state is retained.
SaveImportedProfileTestCase{ProfileFields(),
{{ADDRESS_HOME_STATE, "California"}},
{{ADDRESS_HOME_STATE, "CA"}}},
{{ADDRESS_HOME_STATE, u"California"}},
{{ADDRESS_HOME_STATE, u"CA"}}},
// Tests that saving and identical profile except that the company
// name has different punctuation and case results in a merge and
// that the syntax of the new profile replaces the old one.
SaveImportedProfileTestCase{{{COMPANY_NAME, "Stark inc"}},
{{COMPANY_NAME, "Stark Inc."}},
{{COMPANY_NAME, "Stark Inc."}}})));
SaveImportedProfileTestCase{{{COMPANY_NAME, u"Stark inc"}},
{{COMPANY_NAME, u"Stark Inc."}},
{{COMPANY_NAME, u"Stark Inc."}}})));
// Tests that MergeProfile tries to merge the imported profile into the
// existing profile in decreasing order of frecency.
@ -5667,8 +5669,7 @@ TEST_F(PersonalDataManagerTest,
// Make sure that the added address has the email address of the currently
// signed-in user.
EXPECT_EQ(base::UTF8ToUTF16(kPrimaryAccountEmail),
profiles[0]->GetRawInfo(EMAIL_ADDRESS));
EXPECT_EQ(kPrimaryAccountEmail16, profiles[0]->GetRawInfo(EMAIL_ADDRESS));
}
// Tests that the converted wallet address is merged into an existing local
@ -7839,16 +7840,16 @@ TEST_F(PersonalDataManagerTest, AddAndGetUpiId) {
}
struct ShareNicknameTestParam {
std::string local_nickname;
std::string server_nickname;
std::string expected_nickname;
std::u16string local_nickname;
std::u16string server_nickname;
std::u16string expected_nickname;
};
const ShareNicknameTestParam kShareNicknameTestParam[] = {
{"", "", ""},
{"", "server nickname", "server nickname"},
{"local nickname", "", "local nickname"},
{"local nickname", "server nickname", "local nickname"},
{u"", u"", u""},
{u"", u"server nickname", u"server nickname"},
{u"local nickname", u"", u"local nickname"},
{u"local nickname", u"server nickname", u"local nickname"},
};
class PersonalDataManagerTestForSharingNickname
@ -7856,9 +7857,9 @@ class PersonalDataManagerTestForSharingNickname
public testing::WithParamInterface<ShareNicknameTestParam> {
public:
PersonalDataManagerTestForSharingNickname()
: local_nickname_(base::UTF8ToUTF16(GetParam().local_nickname)),
server_nickname_(base::UTF8ToUTF16(GetParam().server_nickname)),
expected_nickname_(base::UTF8ToUTF16(GetParam().expected_nickname)) {}
: local_nickname_(GetParam().local_nickname),
server_nickname_(GetParam().server_nickname),
expected_nickname_(GetParam().expected_nickname) {}
CreditCard GetLocalCard() {
CreditCard local_card("287151C8-6AB1-487C-9095-28E80BE5DA15",

@ -175,9 +175,8 @@ TEST(AddressFormLabelFormatterTest, GetLabelsForBRProfilesAndFocusedName) {
LabelFormatter::Create(profiles, "pt-BR", NAME_FIRST, GetFieldTypes());
EXPECT_THAT(formatter->GetLabels(),
ElementsAre(base::UTF8ToUTF16(
"Av. Pedro Álvares Cabral, 1301, Vila Mariana, São "
"Paulo-SP, 04094-050")));
ElementsAre(u"Av. Pedro Álvares Cabral, 1301, Vila Mariana, São "
u"Paulo-SP, 04094-050"));
}
TEST(AddressFormLabelFormatterTest, GetLabelsForFormWithoutName) {

@ -568,13 +568,13 @@ class InMemoryHistoryBackendTest : public HistoryBackendTestBase {
const SimulateNotificationCallback& callback);
static const KeywordID kTestKeywordId;
static const char kTestSearchTerm1[];
static const char kTestSearchTerm2[];
static const char16_t kTestSearchTerm1[];
static const char16_t kTestSearchTerm2[];
};
const KeywordID InMemoryHistoryBackendTest::kTestKeywordId = 42;
const char InMemoryHistoryBackendTest::kTestSearchTerm1[] = "banana";
const char InMemoryHistoryBackendTest::kTestSearchTerm2[] = "orange";
const char16_t InMemoryHistoryBackendTest::kTestSearchTerm1[] = u"banana";
const char16_t InMemoryHistoryBackendTest::kTestSearchTerm2[] = u"orange";
// http://crbug.com/114287
#if defined(OS_WIN)
@ -1168,7 +1168,7 @@ TEST_F(HistoryBackendTest, UpdateURLs) {
// This verifies that a notification is fired. In-depth testing of logic should
// be done in HistoryTest.SetTitle.
TEST_F(HistoryBackendTest, SetPageTitleFiresNotificationWithCorrectDetails) {
const char kTestUrlTitle[] = "Google Search";
const char16_t kTestUrlTitle[] = u"Google Search";
ASSERT_TRUE(backend_.get());
@ -1186,7 +1186,7 @@ TEST_F(HistoryBackendTest, SetPageTitleFiresNotificationWithCorrectDetails) {
backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED);
ClearBroadcastedNotifications();
backend_->SetPageTitle(row2.url(), base::UTF8ToUTF16(kTestUrlTitle));
backend_->SetPageTitle(row2.url(), kTestUrlTitle);
// Ensure that a notification was fired, and further verify that the IDs in
// the notification are set to those that are in effect in the main database.
@ -1197,7 +1197,7 @@ TEST_F(HistoryBackendTest, SetPageTitleFiresNotificationWithCorrectDetails) {
const URLRows& changed_urls = urls_modified_notifications()[0];
ASSERT_EQ(1u, changed_urls.size());
EXPECT_EQ(base::UTF8ToUTF16(kTestUrlTitle), changed_urls[0].title());
EXPECT_EQ(kTestUrlTitle, changed_urls[0].title());
EXPECT_EQ(stored_row2.id(), changed_urls[0].id());
}
@ -2901,8 +2901,8 @@ TEST_F(HistoryBackendTest, ClientRedirectScoring) {
// between them is the type of the notification sent out.
void InMemoryHistoryBackendTest::TestAddingAndChangingURLRows(
const SimulateNotificationCallback& callback) {
const char kTestTypedURLAlternativeTitle[] = "Google Search Again";
const char kTestNonTypedURLAlternativeTitle[] = "Google News Again";
const char16_t kTestTypedURLAlternativeTitle[] = u"Google Search Again";
const char16_t kTestNonTypedURLAlternativeTitle[] = u"Google News Again";
// Notify the in-memory database that a typed and non-typed URLRow (which were
// never before seen by the cache) have been modified.
@ -2919,15 +2919,14 @@ void InMemoryHistoryBackendTest::TestAddingAndChangingURLRows(
EXPECT_EQ(row1.id(), cached_row1.id());
// Try changing attributes (other than typed_count) for existing URLRows.
row1.set_title(base::UTF8ToUTF16(kTestTypedURLAlternativeTitle));
row2.set_title(base::UTF8ToUTF16(kTestNonTypedURLAlternativeTitle));
row1.set_title(kTestTypedURLAlternativeTitle);
row2.set_title(kTestNonTypedURLAlternativeTitle);
callback.Run(&row1, &row2, nullptr);
// URLRows that are cached by the in-memory database should be updated.
EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1));
EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2));
EXPECT_EQ(base::UTF8ToUTF16(kTestTypedURLAlternativeTitle),
cached_row1.title());
EXPECT_EQ(kTestTypedURLAlternativeTitle, cached_row1.title());
// Now decrease the typed count for the typed URLRow, and increase it for the
// previously non-typed URLRow.
@ -2940,8 +2939,7 @@ void InMemoryHistoryBackendTest::TestAddingAndChangingURLRows(
EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1));
EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2));
EXPECT_EQ(row2.id(), cached_row2.id());
EXPECT_EQ(base::UTF8ToUTF16(kTestNonTypedURLAlternativeTitle),
cached_row2.title());
EXPECT_EQ(kTestNonTypedURLAlternativeTitle, cached_row2.title());
}
TEST_F(InMemoryHistoryBackendTest, OnURLsModified) {
@ -3014,8 +3012,8 @@ void InMemoryHistoryBackendTest::PopulateTestURLsAndSearchTerms(
TEST_F(InMemoryHistoryBackendTest, SetKeywordSearchTerms) {
URLRow row1(CreateTestTypedURL());
URLRow row2(CreateTestNonTypedURL());
std::u16string term1(base::UTF8ToUTF16(kTestSearchTerm1));
std::u16string term2(base::UTF8ToUTF16(kTestSearchTerm2));
std::u16string term1(kTestSearchTerm1);
std::u16string term2(kTestSearchTerm2);
PopulateTestURLsAndSearchTerms(&row1, &row2, term1, term2);
// Both URLs now have associated search terms, so the in-memory database
@ -3037,8 +3035,8 @@ TEST_F(InMemoryHistoryBackendTest, SetKeywordSearchTerms) {
TEST_F(InMemoryHistoryBackendTest, DeleteKeywordSearchTerms) {
URLRow row1(CreateTestTypedURL());
URLRow row2(CreateTestNonTypedURL());
std::u16string term1(base::UTF8ToUTF16(kTestSearchTerm1));
std::u16string term2(base::UTF8ToUTF16(kTestSearchTerm2));
std::u16string term1(kTestSearchTerm1);
std::u16string term2(kTestSearchTerm2);
PopulateTestURLsAndSearchTerms(&row1, &row2, term1, term2);
// Delete both search terms. This should be reflected in the in-memory DB.
@ -3062,8 +3060,8 @@ TEST_F(InMemoryHistoryBackendTest, DeleteKeywordSearchTerms) {
TEST_F(InMemoryHistoryBackendTest, DeleteAllSearchTermsForKeyword) {
URLRow row1(CreateTestTypedURL());
URLRow row2(CreateTestNonTypedURL());
std::u16string term1(base::UTF8ToUTF16(kTestSearchTerm1));
std::u16string term2(base::UTF8ToUTF16(kTestSearchTerm2));
std::u16string term1(kTestSearchTerm1);
std::u16string term2(kTestSearchTerm2);
PopulateTestURLsAndSearchTerms(&row1, &row2, term1, term2);
// Delete all corresponding search terms from the in-memory database.
@ -3087,8 +3085,8 @@ TEST_F(InMemoryHistoryBackendTest, DeleteAllSearchTermsForKeyword) {
TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedWithSearchTerms) {
URLRow row1(CreateTestTypedURL());
URLRow row2(CreateTestNonTypedURL());
std::u16string term1(base::UTF8ToUTF16(kTestSearchTerm1));
std::u16string term2(base::UTF8ToUTF16(kTestSearchTerm2));
std::u16string term1(kTestSearchTerm1);
std::u16string term2(kTestSearchTerm2);
PopulateTestURLsAndSearchTerms(&row1, &row2, term1, term2);
// Notify the in-memory database that the second typed URL has been deleted.

@ -124,7 +124,7 @@ const char kImageUrl[] = "http://image/image.png";
const char kSuggestionUrl2[] = "http://foo.com/bar";
const char kTestJsonDefaultCategoryTitle[] = "Some title";
const char16_t kTestJsonDefaultCategoryTitle[] = u"Some title";
const int kOtherCategoryId = 2;
const int kUnknownRemoteCategoryId = 1234;
@ -592,8 +592,7 @@ TEST_F(RemoteSuggestionsProviderImplTest, Full) {
}
TEST_F(RemoteSuggestionsProviderImplTest, CategoryTitle) {
const std::u16string test_default_title =
base::UTF8ToUTF16(kTestJsonDefaultCategoryTitle);
const std::u16string test_default_title = kTestJsonDefaultCategoryTitle;
// Don't send an initial response -- we want to test what happens without any
// server status.

@ -26,28 +26,29 @@ namespace {
struct TestCaseItem {
const char* url;
const char* title;
const char16_t* title;
};
const TestCaseItem kTestCase1[] = {{"http://foo1.com/", "Foo1"}};
const TestCaseItem kTestCase1[] = {{"http://foo1.com/", u"Foo1"}};
const TestCaseItem kTestCase2[] = {
{"http://foo1.com/", "Foo1"},
{"http://foo2.com/", "Foo2"},
{"http://foo1.com/", u"Foo1"},
{"http://foo2.com/", u"Foo2"},
};
const TestCaseItem kTestCase3[] = {
{"http://foo1.com/", "Foo1"},
{"http://foo2.com/", "Foo2"},
{"http://foo3.com/", "Foo3"},
{"http://foo1.com/", u"Foo1"},
{"http://foo2.com/", u"Foo2"},
{"http://foo3.com/", u"Foo3"},
};
const TestCaseItem kTestCaseMax[] = {
{"http://foo1.com/", "Foo1"}, {"http://foo2.com/", "Foo2"},
{"http://foo3.com/", "Foo3"}, {"http://foo4.com/", "Foo4"},
{"http://foo5.com/", "Foo5"}, {"http://foo6.com/", "Foo6"},
{"http://foo7.com/", "Foo7"}, {"http://foo8.com/", "Foo8"},
{"http://foo9.com/", "Foo9"}, {"http://foo10.com/", "Foo10"},
{"http://foo1.com/", u"Foo1"}, {"http://foo2.com/", u"Foo2"},
{"http://foo3.com/", u"Foo3"}, {"http://foo4.com/", u"Foo4"},
{"http://foo5.com/", u"Foo5"}, {"http://foo6.com/", u"Foo6"},
{"http://foo7.com/", u"Foo7"}, {"http://foo8.com/", u"Foo8"},
{"http://foo9.com/", u"Foo9"}, {"http://foo10.com/", u"Foo10"},
};
const char kTestTitle[] = "Test";
const char16_t kTestTitle16[] = u"Test";
const char kTestUrl[] = "http://test.com/";
base::Value::ListStorage FillTestListStorage(const char* url,
@ -62,10 +63,10 @@ base::Value::ListStorage FillTestListStorage(const char* url,
return new_link_list;
}
void AddTile(NTPTilesVector* tiles, const char* url, const char* title) {
void AddTile(NTPTilesVector* tiles, const char* url, const char16_t* title) {
NTPTile tile;
tile.url = GURL(url);
tile.title = base::UTF8ToUTF16(title);
tile.title = title;
tiles->push_back(std::move(tile));
}
@ -80,8 +81,7 @@ NTPTilesVector FillTestTiles(base::span<const TestCaseItem> test_cases) {
std::vector<Link> FillTestLinks(base::span<const TestCaseItem> test_cases) {
std::vector<Link> links;
for (const auto& test_case : test_cases) {
links.emplace_back(
Link{GURL(test_case.url), base::UTF8ToUTF16(test_case.title), true});
links.emplace_back(Link{GURL(test_case.url), test_case.title, true});
}
return links;
}
@ -160,10 +160,8 @@ TEST_F(CustomLinksManagerImplTest, AddLink) {
// Add link.
std::vector<Link> expected_links = initial_links;
expected_links.emplace_back(
Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false});
EXPECT_TRUE(
custom_links_->AddLink(GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle)));
expected_links.emplace_back(Link{GURL(kTestUrl), kTestTitle16, false});
EXPECT_TRUE(custom_links_->AddLink(GURL(kTestUrl), kTestTitle16));
EXPECT_EQ(expected_links, custom_links_->GetLinks());
}
@ -174,8 +172,7 @@ TEST_F(CustomLinksManagerImplTest, AddLinkWhenAtMaxLinks) {
ASSERT_EQ(initial_links, custom_links_->GetLinks());
// Try to add link. This should fail and not modify the list.
EXPECT_FALSE(
custom_links_->AddLink(GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle)));
EXPECT_FALSE(custom_links_->AddLink(GURL(kTestUrl), kTestTitle16));
EXPECT_EQ(initial_links, custom_links_->GetLinks());
}
@ -186,8 +183,8 @@ TEST_F(CustomLinksManagerImplTest, AddDuplicateLink) {
ASSERT_EQ(initial_links, custom_links_->GetLinks());
// Try to add duplicate link. This should fail and not modify the list.
EXPECT_FALSE(custom_links_->AddLink(GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestCase1[0].title)));
EXPECT_FALSE(
custom_links_->AddLink(GURL(kTestCase1[0].url), kTestCase1[0].title));
EXPECT_EQ(initial_links, custom_links_->GetLinks());
}
@ -200,25 +197,20 @@ TEST_F(CustomLinksManagerImplTest, UpdateLink) {
EXPECT_TRUE(custom_links_->UpdateLink(GURL(kTestCase1[0].url), GURL(kTestUrl),
std::u16string()));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestUrl),
base::UTF8ToUTF16(kTestCase1[0].title), false}}),
std::vector<Link>({Link{GURL(kTestUrl), kTestCase1[0].title, false}}),
custom_links_->GetLinks());
// Update the link's title.
EXPECT_TRUE(custom_links_->UpdateLink(GURL(kTestUrl), GURL(),
base::UTF8ToUTF16(kTestTitle)));
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}}),
EXPECT_TRUE(custom_links_->UpdateLink(GURL(kTestUrl), GURL(), kTestTitle16));
EXPECT_EQ(std::vector<Link>({Link{GURL(kTestUrl), kTestTitle16, false}}),
custom_links_->GetLinks());
// Update the link's URL and title.
EXPECT_TRUE(
custom_links_->UpdateLink(GURL(kTestUrl), GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestCase1[0].title)));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestCase1[0].title), false}}),
custom_links_->GetLinks());
EXPECT_TRUE(custom_links_->UpdateLink(GURL(kTestUrl), GURL(kTestCase1[0].url),
kTestCase1[0].title));
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestCase1[0].url), kTestCase1[0].title, false}}),
custom_links_->GetLinks());
}
TEST_F(CustomLinksManagerImplTest, UpdateLinkWithInvalidParams) {
@ -229,8 +221,7 @@ TEST_F(CustomLinksManagerImplTest, UpdateLinkWithInvalidParams) {
// Try to update a link that does not exist. This should fail and not modify
// the list.
EXPECT_FALSE(custom_links_->UpdateLink(GURL(kTestUrl), GURL(),
base::UTF8ToUTF16(kTestTitle)));
EXPECT_FALSE(custom_links_->UpdateLink(GURL(kTestUrl), GURL(), kTestTitle16));
EXPECT_EQ(initial_links, custom_links_->GetLinks());
// Try to pass empty params. This should fail and not modify the list.
@ -239,8 +230,7 @@ TEST_F(CustomLinksManagerImplTest, UpdateLinkWithInvalidParams) {
EXPECT_EQ(initial_links, custom_links_->GetLinks());
// Try to pass an invalid URL. This should fail and not modify the list.
EXPECT_FALSE(custom_links_->UpdateLink(GURL("test"), GURL(),
base::UTF8ToUTF16(kTestTitle)));
EXPECT_FALSE(custom_links_->UpdateLink(GURL("test"), GURL(), kTestTitle16));
EXPECT_EQ(initial_links, custom_links_->GetLinks());
EXPECT_FALSE(custom_links_->UpdateLink(GURL(kTestCase1[0].url), GURL("test"),
std::u16string()));
@ -288,25 +278,19 @@ TEST_F(CustomLinksManagerImplTest, ReorderLink) {
// Move the last link to the front.
EXPECT_TRUE(custom_links_->ReorderLink(GURL(kTestCase3[2].url), (size_t)0));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestCase3[2].url),
base::UTF8ToUTF16(kTestCase3[2].title), true},
Link{GURL(kTestCase3[0].url),
base::UTF8ToUTF16(kTestCase3[0].title), true},
Link{GURL(kTestCase3[1].url),
base::UTF8ToUTF16(kTestCase3[1].title), true}}),
custom_links_->GetLinks());
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestCase3[2].url), kTestCase3[2].title, true},
Link{GURL(kTestCase3[0].url), kTestCase3[0].title, true},
Link{GURL(kTestCase3[1].url), kTestCase3[1].title, true}}),
custom_links_->GetLinks());
// Move the same link to the right.
EXPECT_TRUE(custom_links_->ReorderLink(GURL(kTestCase3[2].url), (size_t)1));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestCase3[0].url),
base::UTF8ToUTF16(kTestCase3[0].title), true},
Link{GURL(kTestCase3[2].url),
base::UTF8ToUTF16(kTestCase3[2].title), true},
Link{GURL(kTestCase3[1].url),
base::UTF8ToUTF16(kTestCase3[1].title), true}}),
custom_links_->GetLinks());
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestCase3[0].url), kTestCase3[0].title, true},
Link{GURL(kTestCase3[2].url), kTestCase3[2].title, true},
Link{GURL(kTestCase3[1].url), kTestCase3[1].title, true}}),
custom_links_->GetLinks());
// Move the same link to the end.
EXPECT_TRUE(custom_links_->ReorderLink(GURL(kTestCase3[2].url), (size_t)2));
@ -316,10 +300,9 @@ TEST_F(CustomLinksManagerImplTest, ReorderLink) {
TEST_F(CustomLinksManagerImplTest, DeleteLink) {
// Initialize.
NTPTilesVector initial_tiles;
AddTile(&initial_tiles, kTestUrl, kTestTitle);
AddTile(&initial_tiles, kTestUrl, kTestTitle16);
ASSERT_TRUE(custom_links_->Initialize(initial_tiles));
ASSERT_EQ(std::vector<Link>(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), true}}),
ASSERT_EQ(std::vector<Link>({Link{GURL(kTestUrl), kTestTitle16, true}}),
custom_links_->GetLinks());
// Delete link.
@ -348,12 +331,10 @@ TEST_F(CustomLinksManagerImplTest, UndoAddLink) {
EXPECT_EQ(initial_links, custom_links_->GetLinks());
// Add link.
EXPECT_TRUE(
custom_links_->AddLink(GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle)));
EXPECT_TRUE(custom_links_->AddLink(GURL(kTestUrl), kTestTitle16));
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestCase1[0].title), true},
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}}}),
{Link{GURL(kTestCase1[0].url), kTestCase1[0].title, true},
{Link{GURL(kTestUrl), kTestTitle16, false}}}),
custom_links_->GetLinks());
// Undo add link.
@ -375,8 +356,7 @@ TEST_F(CustomLinksManagerImplTest, UndoUpdateLink) {
EXPECT_TRUE(custom_links_->UpdateLink(GURL(kTestCase1[0].url), GURL(kTestUrl),
std::u16string()));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestUrl),
base::UTF8ToUTF16(kTestCase1[0].title), false}}),
std::vector<Link>({Link{GURL(kTestUrl), kTestCase1[0].title, false}}),
custom_links_->GetLinks());
// Undo update link.
@ -384,11 +364,11 @@ TEST_F(CustomLinksManagerImplTest, UndoUpdateLink) {
EXPECT_EQ(initial_links, custom_links_->GetLinks());
// Update the link's title.
EXPECT_TRUE(custom_links_->UpdateLink(GURL(kTestCase1[0].url), GURL(),
base::UTF8ToUTF16(kTestTitle)));
EXPECT_EQ(std::vector<Link>({Link{GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestTitle), false}}),
custom_links_->GetLinks());
EXPECT_TRUE(
custom_links_->UpdateLink(GURL(kTestCase1[0].url), GURL(), kTestTitle16));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestCase1[0].url), kTestTitle16, false}}),
custom_links_->GetLinks());
// Undo update link.
EXPECT_TRUE(custom_links_->UndoAction());
@ -402,9 +382,8 @@ TEST_F(CustomLinksManagerImplTest, UndoUpdateLink) {
TEST_F(CustomLinksManagerImplTest, UndoDeleteLink) {
// Initialize.
NTPTilesVector initial_tiles;
AddTile(&initial_tiles, kTestUrl, kTestTitle);
std::vector<Link> expected_links(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), true}});
AddTile(&initial_tiles, kTestUrl, kTestTitle16);
std::vector<Link> expected_links({Link{GURL(kTestUrl), kTestTitle16, true}});
ASSERT_TRUE(custom_links_->Initialize(initial_tiles));
ASSERT_EQ(expected_links, custom_links_->GetLinks());
@ -423,10 +402,8 @@ TEST_F(CustomLinksManagerImplTest, UndoDeleteLinkAfterAdd) {
ASSERT_TRUE(custom_links_->GetLinks().empty());
// Add link.
std::vector<Link> expected_links(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}});
ASSERT_TRUE(
custom_links_->AddLink(GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle)));
std::vector<Link> expected_links({Link{GURL(kTestUrl), kTestTitle16, false}});
ASSERT_TRUE(custom_links_->AddLink(GURL(kTestUrl), kTestTitle16));
ASSERT_EQ(expected_links, custom_links_->GetLinks());
// Delete link.
@ -464,10 +441,9 @@ TEST_F(CustomLinksManagerImplTest, ShouldDeleteMostVisitedOnHistoryDeletion) {
{history::URLRow(GURL(kTestCase2[1].url))},
/*favicon_urls=*/std::set<GURL>(),
/*restrict_urls=*/base::nullopt));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestCase2[0].url),
base::UTF8ToUTF16(kTestCase2[0].title), true}}),
custom_links_->GetLinks());
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestCase2[0].url), kTestCase2[0].title, true}}),
custom_links_->GetLinks());
task_environment_.RunUntilIdle();
}
@ -534,14 +510,12 @@ TEST_F(CustomLinksManagerImplTest, ShouldNotDeleteCustomLinkOnHistoryDeletion) {
// Initialize.
std::vector<Link> links_after_add(
{Link{GURL(kTestCase1[0].url), base::UTF8ToUTF16(kTestCase1[0].title),
true},
Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}});
{Link{GURL(kTestCase1[0].url), kTestCase1[0].title, true},
Link{GURL(kTestUrl), kTestTitle16, false}});
ASSERT_TRUE(custom_links_->Initialize(FillTestTiles(kTestCase1)));
ASSERT_EQ(FillTestLinks(kTestCase1), custom_links_->GetLinks());
// Add link.
ASSERT_TRUE(
custom_links_->AddLink(GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle)));
ASSERT_TRUE(custom_links_->AddLink(GURL(kTestUrl), kTestTitle16));
ASSERT_EQ(links_after_add, custom_links_->GetLinks());
// Try to delete the added link. This should fail and not modify the list.
@ -563,8 +537,7 @@ TEST_F(CustomLinksManagerImplTest, ShouldNotDeleteCustomLinkOnHistoryDeletion) {
/*expired=*/false, history::URLRows(),
/*favicon_urls=*/std::set<GURL>(),
/*restrict_urls=*/base::nullopt));
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}}),
EXPECT_EQ(std::vector<Link>({Link{GURL(kTestUrl), kTestTitle16, false}}),
custom_links_->GetLinks());
task_environment_.RunUntilIdle();
@ -636,11 +609,9 @@ TEST_F(CustomLinksManagerImplTest, ShouldNotUndoAfterHistoryDeletion) {
ASSERT_EQ(FillTestLinks(kTestCase1), custom_links_->GetLinks());
// Add link.
std::vector<Link> links_after_add(
{Link{GURL(kTestCase1[0].url), base::UTF8ToUTF16(kTestCase1[0].title),
true},
Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}});
ASSERT_TRUE(
custom_links_->AddLink(GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle)));
{Link{GURL(kTestCase1[0].url), kTestCase1[0].title, true},
Link{GURL(kTestUrl), kTestTitle16, false}});
ASSERT_TRUE(custom_links_->AddLink(GURL(kTestUrl), kTestTitle16));
ASSERT_EQ(links_after_add, custom_links_->GetLinks());
// Try an empty history deletion. This should do nothing.
@ -669,12 +640,11 @@ TEST_F(CustomLinksManagerImplTest, UpdateListAfterRemoteChange) {
// Modifying ourselves should not notify.
EXPECT_CALL(callback, Run()).Times(0);
EXPECT_TRUE(custom_links_->AddLink(GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestCase1[0].title)));
EXPECT_EQ(
std::vector<Link>({Link{GURL(kTestCase1[0].url),
base::UTF8ToUTF16(kTestCase1[0].title), false}}),
custom_links_->GetLinks());
EXPECT_TRUE(
custom_links_->AddLink(GURL(kTestCase1[0].url), kTestCase1[0].title));
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestCase1[0].url), kTestCase1[0].title, false}}),
custom_links_->GetLinks());
// Modify the preference. This should notify and update the current list of
// links.
@ -682,8 +652,7 @@ TEST_F(CustomLinksManagerImplTest, UpdateListAfterRemoteChange) {
prefs_.SetUserPref(prefs::kCustomLinksList,
std::make_unique<base::Value>(
FillTestListStorage(kTestUrl, kTestTitle, true)));
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), true}}),
EXPECT_EQ(std::vector<Link>({Link{GURL(kTestUrl), kTestTitle16, true}}),
custom_links_->GetLinks());
}
@ -703,8 +672,7 @@ TEST_F(CustomLinksManagerImplTest, InitializeListAfterRemoteChange) {
std::make_unique<base::Value>(
FillTestListStorage(kTestUrl, kTestTitle, false)));
EXPECT_TRUE(custom_links_->IsInitialized());
EXPECT_EQ(std::vector<Link>(
{Link{GURL(kTestUrl), base::UTF8ToUTF16(kTestTitle), false}}),
EXPECT_EQ(std::vector<Link>({Link{GURL(kTestUrl), kTestTitle16, false}}),
custom_links_->GetLinks());
}

@ -19,8 +19,8 @@ namespace ntp_tiles {
namespace {
const char kTestTitle1[] = "Foo1";
const char kTestTitle2[] = "Foo2";
const char16_t kTestTitle1[] = u"Foo1";
const char16_t kTestTitle2[] = u"Foo2";
const char kTestUrl1[] = "http://foo1.com/";
const char kTestUrl2[] = "http://foo2.com/";
@ -41,8 +41,8 @@ class CustomLinksStoreTest : public testing::Test {
};
TEST_F(CustomLinksStoreTest, StoreAndRetrieveLinks) {
std::vector<CustomLinksManager::Link> initial_links({CustomLinksManager::Link{
GURL(kTestUrl1), base::UTF8ToUTF16(kTestTitle1), true}});
std::vector<CustomLinksManager::Link> initial_links(
{CustomLinksManager::Link{GURL(kTestUrl1), kTestTitle1, true}});
custom_links_store_->StoreLinks(initial_links);
std::vector<CustomLinksManager::Link> retrieved_links =
@ -52,10 +52,8 @@ TEST_F(CustomLinksStoreTest, StoreAndRetrieveLinks) {
TEST_F(CustomLinksStoreTest, StoreEmptyList) {
std::vector<CustomLinksManager::Link> populated_links(
{CustomLinksManager::Link{GURL(kTestUrl1), base::UTF8ToUTF16(kTestTitle1),
false},
CustomLinksManager::Link{GURL(kTestUrl2), base::UTF8ToUTF16(kTestTitle2),
true}});
{CustomLinksManager::Link{GURL(kTestUrl1), kTestTitle1, false},
CustomLinksManager::Link{GURL(kTestUrl2), kTestTitle2, true}});
custom_links_store_->StoreLinks(populated_links);
std::vector<CustomLinksManager::Link> retrieved_links =
@ -68,8 +66,8 @@ TEST_F(CustomLinksStoreTest, StoreEmptyList) {
}
TEST_F(CustomLinksStoreTest, ClearLinks) {
std::vector<CustomLinksManager::Link> initial_links({CustomLinksManager::Link{
GURL(kTestUrl1), base::UTF8ToUTF16(kTestTitle1)}});
std::vector<CustomLinksManager::Link> initial_links(
{CustomLinksManager::Link{GURL(kTestUrl1), kTestTitle1}});
custom_links_store_->StoreLinks(initial_links);
std::vector<CustomLinksManager::Link> retrieved_links =
@ -83,10 +81,8 @@ TEST_F(CustomLinksStoreTest, ClearLinks) {
TEST_F(CustomLinksStoreTest, LinksSavedAfterShutdown) {
std::vector<CustomLinksManager::Link> initial_links(
{CustomLinksManager::Link{GURL(kTestUrl1), base::UTF8ToUTF16(kTestTitle1),
false},
CustomLinksManager::Link{GURL(kTestUrl2), base::UTF8ToUTF16(kTestTitle2),
true}});
{CustomLinksManager::Link{GURL(kTestUrl1), kTestTitle1, false},
CustomLinksManager::Link{GURL(kTestUrl2), kTestTitle2, true}});
custom_links_store_->StoreLinks(initial_links);
std::vector<CustomLinksManager::Link> retrieved_links =

@ -74,7 +74,6 @@ TEST(AutocompleteMatchTypeTest, AccessibilityLabelAnswer) {
ASSERT_TRUE(ParseAnswer(answer_json, &answer));
match.answer = answer;
EXPECT_EQ(kSearch + base::UTF8ToUTF16(
", answer, sunny with a chance of hail, 4 of 6"),
EXPECT_EQ(kSearch + u", answer, sunny with a chance of hail, 4 of 6",
AutocompleteMatchType::ToAccessibilityLabel(match, kSearch, 3, 6));
}

@ -36,8 +36,8 @@ namespace {
const char kCurrentURL[] = "http://example.com/current";
const char kClipboardURL[] = "http://example.com/clipboard";
const char kClipboardText[] = "Search for me";
const char kClipboardTitleText[] = "\"Search for me\"";
const char16_t kClipboardText[] = u"Search for me";
const char16_t kClipboardTitleText[] = u"\"Search for me\"";
class CreateMatchWithContentCallbackWaiter {
public:
@ -185,13 +185,11 @@ TEST_F(ClipboardProviderTest, MatchesText) {
auto template_url_service = std::make_unique<TemplateURLService>(
/*initializers=*/nullptr, /*count=*/0);
client_->set_template_url_service(std::move(template_url_service));
SetClipboardText(base::UTF8ToUTF16(kClipboardText));
SetClipboardText(kClipboardText);
provider_->Start(CreateAutocompleteInput(OmniboxFocusType::ON_FOCUS), false);
ASSERT_GE(provider_->matches().size(), 1U);
EXPECT_EQ(base::UTF8ToUTF16(kClipboardTitleText),
provider_->matches().back().contents);
EXPECT_EQ(base::UTF8ToUTF16(kClipboardText),
provider_->matches().back().fill_into_edit);
EXPECT_EQ(kClipboardTitleText, provider_->matches().back().contents);
EXPECT_EQ(kClipboardText, provider_->matches().back().fill_into_edit);
EXPECT_EQ(AutocompleteMatchType::CLIPBOARD_TEXT,
provider_->matches().back().type);
}
@ -218,7 +216,7 @@ TEST_F(ClipboardProviderTest, DeleteMatch) {
auto template_url_service = std::make_unique<TemplateURLService>(
/*initializers=*/nullptr, /*count=*/0);
client_->set_template_url_service(std::move(template_url_service));
SetClipboardText(base::UTF8ToUTF16(kClipboardText));
SetClipboardText(kClipboardText);
provider_->Start(CreateAutocompleteInput(OmniboxFocusType::ON_FOCUS), false);
ASSERT_EQ(provider_->matches().size(), 1U);
@ -253,7 +251,7 @@ TEST_F(ClipboardProviderTest, CreateBlankTextMatchOnStart) {
auto template_url_service = std::make_unique<TemplateURLService>(
/*initializers=*/nullptr, /*count=*/0);
client_->set_template_url_service(std::move(template_url_service));
SetClipboardText(base::UTF8ToUTF16(kClipboardText));
SetClipboardText(kClipboardText);
provider_->Start(CreateAutocompleteInput(OmniboxFocusType::ON_FOCUS), false);
ASSERT_GE(provider_->matches().size(), 1U);
EXPECT_EQ(AutocompleteMatchType::CLIPBOARD_TEXT,
@ -299,7 +297,7 @@ TEST_F(ClipboardProviderTest, CreateURLMatchWithContent) {
}
TEST_F(ClipboardProviderTest, CreateTextMatchWithContent) {
SetClipboardText(base::UTF8ToUTF16(kClipboardText));
SetClipboardText(kClipboardText);
auto template_url_service = std::make_unique<TemplateURLService>(
/*initializers=*/nullptr, /*count=*/0);
client_->set_template_url_service(std::move(template_url_service));
@ -307,8 +305,8 @@ TEST_F(ClipboardProviderTest, CreateTextMatchWithContent) {
CreateMatchWithContentCallbackWaiter waiter(provider_, &match);
waiter.WaitForMatchUpdated();
EXPECT_EQ(base::UTF8ToUTF16(kClipboardTitleText), match.contents);
EXPECT_EQ(base::UTF8ToUTF16(kClipboardText), match.fill_into_edit);
EXPECT_EQ(kClipboardTitleText, match.contents);
EXPECT_EQ(kClipboardText, match.fill_into_edit);
EXPECT_EQ(AutocompleteMatchType::CLIPBOARD_TEXT, match.type);
}

@ -559,9 +559,9 @@ TEST_F(HistoryQuickProviderTest, ContentsClass) {
"%95%8C%E5%A4%A7%E6%88%A6#.E3.83.B4.E3.82.A7.E3.83.AB.E3.82.B5.E3.82."
"A4.E3.83.A6.E4.BD.93.E5.88.B6");
RunTest(u"第二 e3", false, expected_urls, false,
base::UTF8ToUTF16("ja.wikipedia.org/wiki/第二次世界大戦#.E3.83.B4.E3."
"82.A7.E3.83.AB.E3.82.B5.E3.82.A4.E3.83.A6.E4.BD."
"93.E5.88.B6"),
u"ja.wikipedia.org/wiki/第二次世界大戦#.E3.83.B4.E3."
u"82.A7.E3.83.AB.E3.82.B5.E3.82.A4.E3.83.A6.E4.BD."
u"93.E5.88.B6",
std::u16string());
#if DCHECK_IS_ON()
ac_matches()[0].Validate();
@ -813,10 +813,9 @@ TEST_F(HistoryQuickProviderTest, DoesNotProvideMatchesOnFocus) {
}
ScoredHistoryMatch BuildScoredHistoryMatch(const std::string& url_text,
const std::string& input_term) {
const std::u16string& input_term) {
return ScoredHistoryMatch(history::URLRow(GURL(url_text)), VisitInfoVector(),
base::UTF8ToUTF16(input_term),
String16Vector(1, base::UTF8ToUTF16(input_term)),
input_term, String16Vector(1, input_term),
WordStarts(1, 0), RowWordStarts(), false, 0,
base::Time());
}
@ -827,7 +826,7 @@ TEST_F(HistoryQuickProviderTest, DoTrimHttpScheme) {
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("http://www.facebook.com", "face");
BuildScoredHistoryMatch("http://www.facebook.com", u"face");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(u"facebook.com", match.contents);
@ -840,7 +839,7 @@ TEST_F(HistoryQuickProviderTest, DontTrimHttpSchemeIfInputHasScheme) {
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("http://www.facebook.com", "http://face");
BuildScoredHistoryMatch("http://www.facebook.com", u"http://face");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(u"http://facebook.com", match.contents);
@ -853,7 +852,7 @@ TEST_F(HistoryQuickProviderTest, DontTrimHttpSchemeIfInputMatches) {
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("http://www.facebook.com", "ht");
BuildScoredHistoryMatch("http://www.facebook.com", u"ht");
history_match.match_in_scheme = true;
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
@ -867,7 +866,7 @@ TEST_F(HistoryQuickProviderTest, DontTrimHttpsSchemeIfInputHasScheme) {
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("https://www.facebook.com", "https://face");
BuildScoredHistoryMatch("https://www.facebook.com", u"https://face");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(u"https://facebook.com", match.contents);
@ -879,7 +878,7 @@ TEST_F(HistoryQuickProviderTest, DoTrimHttpsScheme) {
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("https://www.facebook.com", "face");
BuildScoredHistoryMatch("https://www.facebook.com", u"face");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(u"facebook.com", match.contents);

@ -374,8 +374,8 @@ TEST_F(VotesUploaderTest, GeneratePasswordAttributesVote_AllAsciiCharacters) {
FormStructure form_structure(form);
VotesUploader votes_uploader(&client_, true);
votes_uploader.GeneratePasswordAttributesVote(
base::UTF8ToUTF16("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr"
"stuvwxyz!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"),
u"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr"
u"stuvwxyz!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
&form_structure);
base::Optional<std::pair<PasswordAttribute, bool>> vote =
form_structure.get_password_attributes_vote();
@ -386,14 +386,13 @@ TEST_F(VotesUploaderTest, GeneratePasswordAttributesVote_NonAsciiPassword) {
// Checks that password attributes vote is not generated if the password has
// non-ascii characters.
for (const auto* password :
{"пароль1", "パスワード", "münchen", "סיסמה-A", "Σ-12345",
"գաղտնաբառըTTT", "Slaptažodis", "密碼", "كلمهالسر", "mậtkhẩu!",
"ລະຫັດຜ່ານ-l", "စကားှက်ကို3", "პაროლი", "पारण शब्द"}) {
{u"пароль1", u"パスワード", u"münchen", u"סיסמה-A", u"Σ-12345",
u"գաղտնաբառըTTT", u"Slaptažodis", u"密碼", u"كلمهالسر", u"mậtkhẩu!",
u"ລະຫັດຜ່ານ-l", u"စကားှက်ကို3", u"პაროლი", u"पारण शब्द"}) {
FormData form;
FormStructure form_structure(form);
VotesUploader votes_uploader(&client_, true);
votes_uploader.GeneratePasswordAttributesVote(base::UTF8ToUTF16(password),
&form_structure);
votes_uploader.GeneratePasswordAttributesVote(password, &form_structure);
base::Optional<std::pair<PasswordAttribute, bool>> vote =
form_structure.get_password_attributes_vote();

@ -15,9 +15,10 @@ TEST(PaymentCredentialEnrollmentModelTest, SmokeTest) {
PaymentCredentialEnrollmentModel model;
std::u16string title(u"Use Touch ID to verify and complete your purchase?");
std::u16string description(base::UTF8ToUTF16(
"Save payment information to this device and skip bank verification next "
"time when you use Touch ID to verify your payment with Visa ••••4444."));
std::u16string description(
u"Save payment information to this device and skip bank verification "
u"next "
u"time when you use Touch ID to verify your payment with Visa ••••4444.");
std::u16string accept_button_label(u"Use Touch ID");
std::u16string cancel_button_label(u"No thanks");

@ -36,7 +36,7 @@ const char kTestPolicyName7[] = "policy.test.7";
const char kTestPolicyName8[] = "policy.test.8";
// Dummy error message.
const char kTestError[] = "Test error message";
const char16_t kTestError[] = u"Test error message";
// Utility functions for the tests.
void SetPolicy(PolicyMap* map, const char* name, base::Value value) {
@ -83,20 +83,19 @@ TEST_F(PolicyMapTest, SetAndGet) {
EXPECT_TRUE(expected_b.Equals(map.GetValue(kTestPolicyName1)));
SetPolicy(&map, kTestPolicyName1, CreateExternalDataFetcher("dummy"));
map.AddMessage(kTestPolicyName1, PolicyMap::MessageType::kError,
IDS_POLICY_STORE_STATUS_VALIDATION_ERROR,
{base::UTF8ToUTF16(kTestError)});
IDS_POLICY_STORE_STATUS_VALIDATION_ERROR, {kTestError});
EXPECT_FALSE(map.GetValue(kTestPolicyName1));
const PolicyMap::Entry* entry = map.Get(kTestPolicyName1);
ASSERT_TRUE(entry != nullptr);
EXPECT_EQ(POLICY_LEVEL_MANDATORY, entry->level);
EXPECT_EQ(POLICY_SCOPE_USER, entry->scope);
EXPECT_EQ(POLICY_SOURCE_CLOUD, entry->source);
std::string error_string = base::StrCat({"Validation error: ", kTestError});
std::u16string error_string =
base::StrCat({u"Validation error: ", kTestError});
PolicyMap::Entry::L10nLookupFunction lookup = base::BindRepeating(
static_cast<std::u16string (*)(int)>(&base::NumberToString16));
EXPECT_EQ(
base::UTF8ToUTF16(error_string),
entry->GetLocalizedMessages(PolicyMap::MessageType::kError, lookup));
EXPECT_EQ(error_string, entry->GetLocalizedMessages(
PolicyMap::MessageType::kError, lookup));
EXPECT_TRUE(
ExternalDataFetcher::Equals(entry->external_data_fetcher.get(),
CreateExternalDataFetcher("dummy").get()));
@ -137,28 +136,27 @@ TEST_F(PolicyMapTest, AddMessage_Error) {
EXPECT_EQ(u"1234\n5678", entry1->GetLocalizedMessages(
PolicyMap::MessageType::kError, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("This policy is deprecated. You should use the "
"SomeNewPolicy policy instead."),
u"This policy is deprecated. You should use the "
u"SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kError, lookup));
map.AddMessage(kTestPolicyName2, PolicyMap::MessageType::kError, 1357);
EXPECT_EQ(u"1234\n5678", entry1->GetLocalizedMessages(
PolicyMap::MessageType::kError, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("1357\nThis policy is deprecated. You should use "
"the SomeNewPolicy policy instead."),
u"1357\nThis policy is deprecated. You should use "
u"the SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kError, lookup));
// Test adding Error message with placeholder replacement (two args)
map.AddMessage(kTestPolicyName1, PolicyMap::MessageType::kError,
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM,
{u"SomeSource", u"SomeDestination"});
EXPECT_EQ(
base::UTF8ToUTF16(
"1234\n5678\nSharing from SomeSource to SomeDestination has "
"been blocked by administrator policy"),
u"1234\n5678\nSharing from SomeSource to SomeDestination has "
u"been blocked by administrator policy",
entry1->GetLocalizedMessages(PolicyMap::MessageType::kError, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("1357\nThis policy is deprecated. You should use "
"the SomeNewPolicy policy instead."),
u"1357\nThis policy is deprecated. You should use "
u"the SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kError, lookup));
// Ensure other message types are empty
@ -192,28 +190,27 @@ TEST_F(PolicyMapTest, AddMessage_Warning) {
EXPECT_EQ(u"1234\n5678", entry1->GetLocalizedMessages(
PolicyMap::MessageType::kWarning, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("This policy is deprecated. You should use the "
"SomeNewPolicy policy instead."),
u"This policy is deprecated. You should use the "
u"SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kWarning, lookup));
entry2->AddMessage(PolicyMap::MessageType::kWarning, 1357);
EXPECT_EQ(u"1234\n5678", entry1->GetLocalizedMessages(
PolicyMap::MessageType::kWarning, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("1357\nThis policy is deprecated. You should use "
"the SomeNewPolicy policy instead."),
u"1357\nThis policy is deprecated. You should use "
u"the SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kWarning, lookup));
// Test adding Warning message with placeholder replacement (two args)
entry1->AddMessage(PolicyMap::MessageType::kWarning,
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM,
{u"SomeSource", u"SomeDestination"});
EXPECT_EQ(
base::UTF8ToUTF16(
"1234\n5678\nSharing from SomeSource to SomeDestination has "
"been blocked by administrator policy"),
u"1234\n5678\nSharing from SomeSource to SomeDestination has "
u"been blocked by administrator policy",
entry1->GetLocalizedMessages(PolicyMap::MessageType::kWarning, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("1357\nThis policy is deprecated. You should use "
"the SomeNewPolicy policy instead."),
u"1357\nThis policy is deprecated. You should use "
u"the SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kWarning, lookup));
// Ensure other message types are empty
@ -247,28 +244,27 @@ TEST_F(PolicyMapTest, AddMessage_Info) {
EXPECT_EQ(u"1234\n5678", entry1->GetLocalizedMessages(
PolicyMap::MessageType::kInfo, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("This policy is deprecated. You should use the "
"SomeNewPolicy policy instead."),
u"This policy is deprecated. You should use the "
u"SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kInfo, lookup));
entry2->AddMessage(PolicyMap::MessageType::kInfo, 1357);
EXPECT_EQ(u"1234\n5678", entry1->GetLocalizedMessages(
PolicyMap::MessageType::kInfo, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("1357\nThis policy is deprecated. You should use "
"the SomeNewPolicy policy instead."),
u"1357\nThis policy is deprecated. You should use "
u"the SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kInfo, lookup));
// Test adding Info message with placeholder replacement (two args)
entry1->AddMessage(PolicyMap::MessageType::kInfo,
IDS_POLICY_DLP_CLIPBOARD_BLOCKED_ON_COPY_VM,
{u"SomeSource", u"SomeDestination"});
EXPECT_EQ(
base::UTF8ToUTF16(
"1234\n5678\nSharing from SomeSource to SomeDestination has "
"been blocked by administrator policy"),
u"1234\n5678\nSharing from SomeSource to SomeDestination has "
u"been blocked by administrator policy",
entry1->GetLocalizedMessages(PolicyMap::MessageType::kInfo, lookup));
EXPECT_EQ(
base::UTF8ToUTF16("1357\nThis policy is deprecated. You should use "
"the SomeNewPolicy policy instead."),
u"1357\nThis policy is deprecated. You should use "
u"the SomeNewPolicy policy instead.",
entry2->GetLocalizedMessages(PolicyMap::MessageType::kInfo, lookup));
// Ensure other message types are empty

@ -263,19 +263,15 @@ TEST_F(PhishingTermFeatureExtractorTest, ExtractFeatures) {
// Chinese translation of the phrase "hello goodbye hello goodbye". This tests
// that we can correctly separate terms in languages that don't use spaces.
page_text = base::UTF8ToUTF16(
"\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81"
"\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81");
page_text = u"你好再见你好再见";
expected_features.Clear();
expected_features.AddBooleanFeature(features::kPageTerm +
std::string("\xe4\xbd\xa0\xe5\xa5\xbd"));
std::string("你好"));
expected_features.AddBooleanFeature(features::kPageTerm +
std::string("\xe5\x86\x8d\xe8\xa7\x81"));
std::string("再见"));
expected_shingle_hashes.clear();
expected_shingle_hashes.insert(
MurmurHash3String("\xe4\xbd\xa0\xe5\xa5\xbd \xe5\x86\x8d\xe8\xa7\x81 "
"\xe4\xbd\xa0\xe5\xa5\xbd \xe5\x86\x8d\xe8\xa7\x81 ",
kMurmurHash3Seed));
MurmurHash3String("你好 再见 你好 再见 ", kMurmurHash3Seed));
features.Clear();
shingle_hashes.clear();

@ -522,14 +522,14 @@ TEST_F(TemplateURLTest, ReplaceArbitrarySearchTerms) {
const std::string url;
const std::string expected_result;
} test_data[] = {
{"BIG5", u"\x60BD", "http://foo/?{searchTerms}{inputEncoding}",
{"BIG5", u"", "http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%B1~BIG5"},
{"UTF-8", u"blah", "http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?blahUTF-8"},
{"Shift_JIS", base::UTF8ToUTF16("\xe3\x81\x82"),
"http://foo/{searchTerms}/bar", "http://foo/%82%A0/bar"},
{"Shift_JIS", base::UTF8ToUTF16("\xe3\x81\x82 \xe3\x81\x84"),
"http://foo/{searchTerms}/bar", "http://foo/%82%A0%20%82%A2/bar"},
{"Shift_JIS", u"", "http://foo/{searchTerms}/bar",
"http://foo/%82%A0/bar"},
{"Shift_JIS", u"あ い", "http://foo/{searchTerms}/bar",
"http://foo/%82%A0%20%82%A2/bar"},
};
TemplateURLData data;
for (size_t i = 0; i < base::size(test_data); ++i) {
@ -558,27 +558,27 @@ TEST_F(TemplateURLTest, ReplaceSearchTermsMultipleEncodings) {
} test_data[] = {
// First and third encodings are valid. First is used.
{{"windows-1251", "cp-866", "UTF-8"},
base::UTF8ToUTF16("\xD1\x8F"),
u"я",
"http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%FFwindows-1251"},
// Second and third encodings are valid, second is used.
{{"cp-866", "GB2312", "UTF-8"},
base::UTF8ToUTF16("\xE7\x8B\x97"),
u"",
"http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%B9%B7GB2312"},
// Second and third encodings are valid in another order, second is used.
{{"cp-866", "UTF-8", "GB2312"},
base::UTF8ToUTF16("\xE7\x8B\x97"),
u"",
"http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%E7%8B%97UTF-8"},
// Both encodings are invalid, fallback to UTF-8.
{{"cp-866", "windows-1251"},
base::UTF8ToUTF16("\xE7\x8B\x97"),
u"",
"http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%E7%8B%97UTF-8"},
// No encodings are given, fallback to UTF-8.
{{},
base::UTF8ToUTF16("\xE7\x8B\x97"),
u"",
"http://foo/?{searchTerms}{inputEncoding}",
"http://foo/?%E7%8B%97UTF-8"},
};
@ -1854,9 +1854,7 @@ TEST_F(TemplateURLTest, GenerateKeyword) {
ASSERT_EQ(u"blah", TemplateURL::GenerateKeyword(GURL("http://blah/")));
// Don't generate the empty string.
ASSERT_EQ(u"www.", TemplateURL::GenerateKeyword(GURL("http://www.")));
ASSERT_EQ(
base::UTF8ToUTF16("\xd0\xb0\xd0\xb1\xd0\xb2"),
TemplateURL::GenerateKeyword(GURL("http://xn--80acd")));
ASSERT_EQ(u"абв", TemplateURL::GenerateKeyword(GURL("http://xn--80acd")));
// Generated keywords must always be in lowercase, because TemplateURLs always
// converts keywords to lowercase in its constructor and TemplateURLService

@ -1065,12 +1065,12 @@ TEST_F(SpellCheckTest, SpellCheckParagraphMultipleMisspellings) {
TEST_F(SpellCheckTest, SpellCheckParagraphLongSentence) {
std::vector<SpellCheckResult> expected;
// The text is taken from US constitution preamble.
const std::u16string text = base::UTF8ToUTF16(
"We the people of the United States, in order to form a more perfect "
"union, establish justice, insure domestic tranquility, provide for "
"the common defense, promote the general welfare, and secure the "
"blessings of liberty to ourselves and our posterity, do ordain and "
"establish this Constitution for the United States of America.");
const std::u16string text =
u"We the people of the United States, in order to form a more perfect "
u"union, establish justice, insure domestic tranquility, provide for "
u"the common defense, promote the general welfare, and secure the "
u"blessings of liberty to ourselves and our posterity, do ordain and "
u"establish this Constitution for the United States of America.";
TestSpellCheckParagraph(text, expected);
}
@ -1080,12 +1080,12 @@ TEST_F(SpellCheckTest, SpellCheckParagraphLongSentenceMultipleMisspellings) {
std::vector<SpellCheckResult> expected;
// All 'the' are converted to 'hte' in US consitition preamble.
const std::u16string text = base::UTF8ToUTF16(
"We hte people of hte United States, in order to form a more perfect "
"union, establish justice, insure domestic tranquility, provide for "
"hte common defense, promote hte general welfare, and secure hte "
"blessings of liberty to ourselves and our posterity, do ordain and "
"establish this Constitution for hte United States of America.");
const std::u16string text =
u"We hte people of hte United States, in order to form a more perfect "
u"union, establish justice, insure domestic tranquility, provide for "
u"hte common defense, promote hte general welfare, and secure hte "
u"blessings of liberty to ourselves and our posterity, do ordain and "
u"establish this Constitution for hte United States of America.";
expected.push_back(SpellCheckResult(
SpellCheckResult::SPELLING, 3, 3));

@ -102,15 +102,15 @@ void AccessibilityBrowserTest::LoadSampleParagraphInScrollableEditable() {
AccessibilityNotificationWaiter selection_waiter(
shell()->web_contents(), ui::kAXModeComplete,
ax::mojom::Event::kTextSelectionChanged);
ExecuteScript(base::UTF8ToUTF16(
"let selection=document.getSelection();"
"let range=document.createRange();"
"let editable=document.querySelector('p[contenteditable=\"true\"]');"
"editable.focus();"
"range.setStart(editable.lastChild, 0);"
"range.setEnd(editable.lastChild, 0);"
"selection.removeAllRanges();"
"selection.addRange(range);"));
ExecuteScript(
u"let selection=document.getSelection();"
u"let range=document.createRange();"
u"let editable=document.querySelector('p[contenteditable=\"true\"]');"
u"editable.focus();"
u"range.setStart(editable.lastChild, 0);"
u"range.setEnd(editable.lastChild, 0);"
u"selection.removeAllRanges();"
u"selection.addRange(range);");
selection_waiter.WaitForNotification();
}

@ -3683,11 +3683,12 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
ui::kAXModeComplete,
ax::mojom::Event::kValueChanged);
// Place an e acute, and two emoticons in the text field.
ExecuteScript(base::UTF8ToUTF16(R"SCRIPT(
ExecuteScript(
uR"SCRIPT(
const input = document.querySelector('input');
input.value =
'e\u0301\uD83D\uDC69\u200D\u2764\uFE0F\u200D\uD83D\uDC69\uD83D\uDC36';
)SCRIPT"));
)SCRIPT");
waiter.WaitForNotification();
LONG n_characters;
@ -4035,10 +4036,11 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
ui::kAXModeComplete,
ax::mojom::Event::kValueChanged);
// Add a blank line at the end of the textarea.
ExecuteScript(base::UTF8ToUTF16(R"SCRIPT(
ExecuteScript(
uR"SCRIPT(
const textarea = document.querySelector('textarea');
textarea.value += '\n';
)SCRIPT"));
)SCRIPT");
waiter.WaitForNotification();
// The second last line should have an additional trailing newline. Also,

@ -237,19 +237,19 @@ TEST_F(FileSystemChooserTest, DescriptionSanitization) {
new CancellingSelectFileDialogFactory(&dialog_params));
std::vector<blink::mojom::ChooseFileSystemEntryAcceptsOptionPtr> accepts;
accepts.emplace_back(blink::mojom::ChooseFileSystemEntryAcceptsOption::New(
base::UTF8ToUTF16("Description with \t a \r lot of \n "
" spaces"),
u"Description with \t a \r lot of \n "
u" spaces",
std::vector<std::string>({}), std::vector<std::string>({"txt"})));
accepts.emplace_back(blink::mojom::ChooseFileSystemEntryAcceptsOption::New(
base::UTF8ToUTF16("Description that is very long and should be "
"truncated to 64 code points if it works"),
u"Description that is very long and should be "
u"truncated to 64 code points if it works",
std::vector<std::string>({}), std::vector<std::string>({"js"})));
accepts.emplace_back(blink::mojom::ChooseFileSystemEntryAcceptsOption::New(
base::UTF8ToUTF16("Unbalanced RTL \xe2\x80\xae section"),
std::vector<std::string>({}), std::vector<std::string>({"js"})));
u"Unbalanced RTL \u202e section", std::vector<std::string>({}),
std::vector<std::string>({"js"})));
accepts.emplace_back(blink::mojom::ChooseFileSystemEntryAcceptsOption::New(
base::UTF8ToUTF16("Unbalanced RTL \xe2\x80\xae section in a otherwise "
"very long description that will be truncated"),
u"Unbalanced RTL \u202e section in a otherwise "
u"very long description that will be truncated",
std::vector<std::string>({}), std::vector<std::string>({"js"})));
SyncShowDialog(std::move(accepts), /*include_accepts_all=*/false);
@ -258,16 +258,14 @@ TEST_F(FileSystemChooserTest, DescriptionSanitization) {
dialog_params.file_types->extension_description_overrides.size());
EXPECT_EQ(u"Description with a lot of spaces",
dialog_params.file_types->extension_description_overrides[0]);
EXPECT_EQ(u"Description that is very long and should be truncated to 64 cod…",
dialog_params.file_types->extension_description_overrides[1]);
EXPECT_EQ(u"Unbalanced RTL \u202e section\u202c",
dialog_params.file_types->extension_description_overrides[2]);
EXPECT_EQ(
base::UTF8ToUTF16(
"Description that is very long and should be truncated to 64 cod…"),
dialog_params.file_types->extension_description_overrides[1]);
EXPECT_EQ(
base::UTF8ToUTF16("Unbalanced RTL \xe2\x80\xae section\xe2\x80\xac"),
dialog_params.file_types->extension_description_overrides[2]);
EXPECT_EQ(base::UTF8ToUTF16("Unbalanced RTL \xe2\x80\xae section in a "
"otherwise very long description t…\xe2\x80\xac"),
dialog_params.file_types->extension_description_overrides[3]);
u"Unbalanced RTL \u202e section in a "
u"otherwise very long description t…\u202c",
dialog_params.file_types->extension_description_overrides[3]);
}
} // namespace content

@ -81,7 +81,7 @@ MATCHER_P(MatchesIDBKey, key, "") {
return arg.Equals(key);
}
static const char kDatabaseName[] = "db";
static const char16_t kDatabaseName[] = u"db";
static const char kOrigin[] = "https://www.example.com";
base::FilePath CreateAndReturnTempDir(base::ScopedTempDir* temp_dir) {
@ -255,7 +255,7 @@ TEST_F(IndexedDBDispatcherHostTest, CloseConnectionBeforeUpgrade) {
FROM_HERE, base::BindLambdaForTesting([&]() {
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), url::Origin::Create(GURL(kOrigin)),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
kDatabaseName, kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
IndexedDBDatabaseMetadata::NO_VERSION,
@ -287,7 +287,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_CloseAfterUpgrade) {
const int64_t kDBVersion = 1;
const int64_t kTransactionId = 1;
const int64_t kObjectStoreId = 10;
const char kObjectStoreName[] = "os";
const char16_t kObjectStoreName[] = u"os";
std::unique_ptr<TestDatabaseConnection> connection;
IndexedDBDatabaseMetadata metadata;
mojo::PendingAssociatedRemote<blink::mojom::IDBDatabase> pending_database;
@ -297,8 +297,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_CloseAfterUpgrade) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
@ -337,8 +337,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_CloseAfterUpgrade) {
ASSERT_TRUE(connection->database.is_bound());
ASSERT_TRUE(connection->version_change_transaction.is_bound());
connection->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(), false);
connection->version_change_transaction->Commit(0);
}));
loop2.Run();
@ -357,7 +356,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_OpenNewConnectionWhileUpgrading) {
const int64_t kDBVersion = 1;
const int64_t kTransactionId = 1;
const int64_t kObjectStoreId = 10;
const char kObjectStoreName[] = "os";
const char16_t kObjectStoreName[] = u"os";
std::unique_ptr<TestDatabaseConnection> connection1;
mojo::PendingAssociatedRemote<blink::mojom::IDBDatabase> pending_database1;
IndexedDBDatabaseMetadata metadata1;
@ -368,7 +367,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_OpenNewConnectionWhileUpgrading) {
// Open connection 1, and expect the upgrade needed.
connection1 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), url::Origin::Create(GURL(kOrigin)),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
kDatabaseName, kDBVersion, kTransactionId);
EXPECT_CALL(*connection1->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
@ -394,8 +393,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_OpenNewConnectionWhileUpgrading) {
context_impl_->IDBTaskRunner()->PostTask(
FROM_HERE, base::BindLambdaForTesting([&]() {
connection2 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, 0);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, 0);
// Check that we're called in order and the second connection gets it's
// database after the first connection completes.
@ -425,8 +424,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_OpenNewConnectionWhileUpgrading) {
// Create object store.
connection1->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(), false);
connection1->version_change_transaction->Commit(0);
}));
loop2.Run();
@ -457,7 +455,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_PutWithInvalidBlob) {
const int64_t kDBVersion = 1;
const int64_t kTransactionId = 1;
const int64_t kObjectStoreId = 10;
const char kObjectStoreName[] = "os";
const char16_t kObjectStoreName[] = u"os";
std::unique_ptr<TestDatabaseConnection> connection;
IndexedDBDatabaseMetadata metadata;
mojo::PendingAssociatedRemote<blink::mojom::IDBDatabase> pending_database;
@ -468,7 +466,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_PutWithInvalidBlob) {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), url::Origin::Create(GURL(kOrigin)),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
kDatabaseName, kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
@ -518,8 +516,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_PutWithInvalidBlob) {
ASSERT_TRUE(connection->database.is_bound());
ASSERT_TRUE(connection->version_change_transaction.is_bound());
connection->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(), false);
// Call Put with an invalid blob.
std::vector<blink::mojom::IDBExternalObjectPtr> external_objects;
mojo::PendingRemote<blink::mojom::Blob> blob;
@ -571,8 +568,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_CompactDatabaseWithConnection) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
IndexedDBDatabaseMetadata::NO_VERSION,
@ -633,7 +630,7 @@ TEST_F(IndexedDBDispatcherHostTest, CompactDatabaseWhileDoingTransaction) {
const int64_t kDBVersion = 1;
const int64_t kTransactionId = 1;
const int64_t kObjectStoreId = 10;
const char kObjectStoreName[] = "os";
const char16_t kObjectStoreName[] = u"os";
std::unique_ptr<TestDatabaseConnection> connection;
IndexedDBDatabaseMetadata metadata;
mojo::PendingAssociatedRemote<blink::mojom::IDBDatabase> pending_database;
@ -643,8 +640,8 @@ TEST_F(IndexedDBDispatcherHostTest, CompactDatabaseWhileDoingTransaction) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
IndexedDBDatabaseMetadata::NO_VERSION,
@ -689,8 +686,7 @@ TEST_F(IndexedDBDispatcherHostTest, CompactDatabaseWhileDoingTransaction) {
ASSERT_TRUE(connection->database.is_bound());
ASSERT_TRUE(connection->version_change_transaction.is_bound());
connection->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(), false);
idb_mojo_factory_->AbortTransactionsAndCompactDatabase(base::BindOnce(
&TestStatusCallback, std::move(quit_closure2), &callback_result));
}));
@ -719,8 +715,8 @@ TEST_F(IndexedDBDispatcherHostTest, CompactDatabaseWhileUpgrading) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
IndexedDBDatabaseMetadata::NO_VERSION,
@ -793,8 +789,8 @@ TEST_F(IndexedDBDispatcherHostTest,
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
{
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(
@ -859,7 +855,7 @@ TEST_F(IndexedDBDispatcherHostTest, AbortTransactionsWhileDoingTransaction) {
const int64_t kDBVersion = 1;
const int64_t kTransactionId = 1;
const int64_t kObjectStoreId = 10;
const char kObjectStoreName[] = "os";
const char16_t kObjectStoreName[] = u"os";
std::unique_ptr<TestDatabaseConnection> connection;
IndexedDBDatabaseMetadata metadata;
mojo::PendingAssociatedRemote<blink::mojom::IDBDatabase> pending_database;
@ -869,8 +865,8 @@ TEST_F(IndexedDBDispatcherHostTest, AbortTransactionsWhileDoingTransaction) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
@ -916,8 +912,7 @@ TEST_F(IndexedDBDispatcherHostTest, AbortTransactionsWhileDoingTransaction) {
ASSERT_TRUE(connection->database.is_bound());
ASSERT_TRUE(connection->version_change_transaction.is_bound());
connection->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(), false);
idb_mojo_factory_->AbortTransactionsForDatabase(base::BindOnce(
&TestStatusCallback, std::move(quit_closure2), &callback_result));
}));
@ -946,8 +941,8 @@ TEST_F(IndexedDBDispatcherHostTest, AbortTransactionsWhileUpgrading) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
@ -1018,8 +1013,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBListChanged) {
const int64_t kTransactionId3 = 3;
const int64_t kObjectStoreId = 10;
const int64_t kIndexId = 100;
const char kObjectStoreName[] = "os";
const char kIndexName[] = "index";
const char16_t kObjectStoreName[] = u"os";
const char16_t kIndexName[] = u"index";
mojo::PendingReceiver<storage::mojom::IndexedDBObserver> receiver;
mojo::PendingRemote<storage::mojom::IndexedDBObserver> remote;
@ -1037,8 +1032,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBListChanged) {
context_impl_->IDBTaskRunner()->PostTask(
FROM_HERE, base::BindLambdaForTesting([&]() {
connection1 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion1, kTransactionId1);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion1, kTransactionId1);
EXPECT_CALL(*connection1->open_callbacks,
MockedUpgradeNeeded(
@ -1082,12 +1077,11 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBListChanged) {
ASSERT_TRUE(connection1->database.is_bound());
connection1->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
connection1->database->CreateIndex(
kTransactionId1, kObjectStoreId, kIndexId,
base::UTF8ToUTF16(kIndexName), blink::IndexedDBKeyPath(), false,
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(),
false);
connection1->database->CreateIndex(
kTransactionId1, kObjectStoreId, kIndexId, kIndexName,
blink::IndexedDBKeyPath(), false, false);
connection1->version_change_transaction->Commit(0);
}));
loop.Run();
@ -1111,8 +1105,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBListChanged) {
connection2 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(),
url::Origin::Create(GURL(kOrigin)),
base::UTF8ToUTF16(kDatabaseName), kDBVersion2, kTransactionId2);
url::Origin::Create(GURL(kOrigin)), kDatabaseName, kDBVersion2,
kTransactionId2);
EXPECT_CALL(*connection2->open_callbacks,
MockedUpgradeNeeded(
@ -1174,8 +1168,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBListChanged) {
FROM_HERE, base::BindLambdaForTesting([&]() {
connection2->database->Close();
connection3 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion3, kTransactionId3);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion3, kTransactionId3);
EXPECT_CALL(*connection3->open_callbacks,
MockedUpgradeNeeded(
@ -1249,7 +1243,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBContentChanged) {
const int64_t kTransactionId1 = 1;
const int64_t kTransactionId2 = 2;
const int64_t kObjectStoreId = 10;
const char kObjectStoreName[] = "os";
const char16_t kObjectStoreName[] = u"os";
mojo::PendingReceiver<storage::mojom::IndexedDBObserver> receiver;
mojo::PendingRemote<storage::mojom::IndexedDBObserver> remote;
@ -1268,7 +1262,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBContentChanged) {
// Open connection 1.
connection1 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), url::Origin::Create(GURL(kOrigin)),
base::UTF8ToUTF16(kDatabaseName), kDBVersion1, kTransactionId1);
kDatabaseName, kDBVersion1, kTransactionId1);
EXPECT_CALL(*connection1->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),
@ -1315,8 +1309,7 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBContentChanged) {
ASSERT_TRUE(connection1->database.is_bound());
ASSERT_TRUE(connection1->version_change_transaction.is_bound());
connection1->version_change_transaction->CreateObjectStore(
kObjectStoreId, base::UTF8ToUTF16(kObjectStoreName),
blink::IndexedDBKeyPath(), false);
kObjectStoreId, kObjectStoreName, blink::IndexedDBKeyPath(), false);
std::string value = "value";
const char* value_data = value.data();
@ -1357,8 +1350,8 @@ TEST_F(IndexedDBDispatcherHostTest, DISABLED_NotifyIndexedDBContentChanged) {
::testing::InSequence dummy;
connection2 = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion2, kTransactionId2);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion2, kTransactionId2);
EXPECT_CALL(*connection2->open_callbacks,
MockedUpgradeNeeded(
@ -1450,8 +1443,8 @@ TEST_F(IndexedDBDispatcherHostTest, MAYBE_DatabaseOperationSequencing) {
FROM_HERE, base::BindLambdaForTesting([&]() {
// Open connection.
connection = std::make_unique<TestDatabaseConnection>(
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin),
base::UTF8ToUTF16(kDatabaseName), kDBVersion, kTransactionId);
context_impl_->IDBTaskRunner(), ToOrigin(kOrigin), kDatabaseName,
kDBVersion, kTransactionId);
EXPECT_CALL(*connection->open_callbacks,
MockedUpgradeNeeded(IsAssociatedInterfacePtrInfoValid(true),

@ -308,8 +308,8 @@ INSTANTIATE_TEST_SUITE_P(
namespace {
// Test page titles.
const char kTestTitle1[] = "Test Title 1";
const char kTestTitle2[] = "Test Title 2";
const char16_t kTestTitle1[] = u"Test Title 1";
const char16_t kTestTitle2[] = u"Test Title 2";
} // namespace
@ -415,8 +415,7 @@ class MediaInternalsAudioFocusTest : public RenderViewHostTestHarness,
TEST_F(MediaInternalsAudioFocusTest, AudioFocusStateIsUpdated) {
// Create a test media session and request audio focus.
std::unique_ptr<WebContents> web_contents1 = CreateTestWebContents();
static_cast<TestWebContents*>(web_contents1.get())
->SetTitle(base::UTF8ToUTF16(kTestTitle1));
static_cast<TestWebContents*>(web_contents1.get())->SetTitle(kTestTitle1);
MediaSessionImpl* media_session1 = MediaSessionImpl::Get(web_contents1.get());
media_session1->RequestSystemAudioFocus(AudioFocusType::kGain);
WaitForCallbackCount(1);
@ -438,8 +437,7 @@ TEST_F(MediaInternalsAudioFocusTest, AudioFocusStateIsUpdated) {
// Create another media session.
std::unique_ptr<WebContents> web_contents2 = CreateTestWebContents();
static_cast<TestWebContents*>(web_contents2.get())
->SetTitle(base::UTF8ToUTF16(kTestTitle2));
static_cast<TestWebContents*>(web_contents2.get())->SetTitle(kTestTitle2);
MediaSessionImpl* media_session2 = MediaSessionImpl::Get(web_contents2.get());
media_session2->RequestSystemAudioFocus(
AudioFocusType::kGainTransientMayDuck);

@ -36,7 +36,7 @@ namespace content {
namespace {
struct FontExpectation {
const char font_name[64];
const char* font_name;
uint16_t ttc_index;
};
@ -354,10 +354,10 @@ TEST_F(DWriteFontProxyLocalMatchingTest, TestSingleLookupUnavailable) {
return;
base::FilePath result_path;
uint32_t ttc_index;
std::string unavailable_font_name =
"Unavailable_Font_Name_56E7EA7E-2C69-4E23-99DC-750BC19B250E";
dwrite_font_proxy().MatchUniqueFont(base::UTF8ToUTF16(unavailable_font_name),
&result_path, &ttc_index);
std::u16string unavailable_font_name =
u"Unavailable_Font_Name_56E7EA7E-2C69-4E23-99DC-750BC19B250E";
dwrite_font_proxy().MatchUniqueFont(unavailable_font_name, &result_path,
&ttc_index);
ASSERT_EQ(result_path.value().size(), 0u);
ASSERT_EQ(ttc_index, 0u);
}

@ -3783,6 +3783,7 @@ TEST_F(AuthenticatorImplTest, CredBlob) {
}
static constexpr char kTestPIN[] = "1234";
static constexpr char16_t kTestPIN16[] = u"1234";
class UVTestAuthenticatorClientDelegate
: public AuthenticatorRequestClientDelegate {
@ -3807,8 +3808,7 @@ class UVTestAuthenticatorClientDelegate
*collected_pin_ = true;
*min_pin_length_ = options.min_pin_length;
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(provide_pin_cb), base::UTF8ToUTF16(kTestPIN)));
FROM_HERE, base::BindOnce(std::move(provide_pin_cb), kTestPIN16));
}
void StartBioEnrollment(base::OnceClosure next_callback) override {
@ -3933,7 +3933,7 @@ using PINError = device::pin::PINEntryError;
// the PIN to answer with.
struct PINExpectation {
PINReason reason;
std::string pin;
std::u16string pin;
int attempts;
uint32_t min_pin_length = device::kMinPinLength;
PINError error = PINError::kNoError;
@ -3969,12 +3969,11 @@ class PINTestAuthenticatorRequestDelegate
DCHECK_EQ(expected_.front().min_pin_length, options.min_pin_length);
DCHECK_EQ(expected_.front().reason, options.reason);
DCHECK_EQ(expected_.front().error, options.error);
std::string pin = std::move(expected_.front().pin);
std::u16string pin = std::move(expected_.front().pin);
expected_.pop_front();
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(provide_pin_cb),
base::UTF8ToUTF16(std::move(pin))));
FROM_HERE, base::BindOnce(std::move(provide_pin_cb), std::move(pin)));
}
void FinishCollectToken() override {}
@ -4160,12 +4159,13 @@ TEST_F(PINAuthenticatorImplTest, MakeCredential) {
case kSetPIN:
// A single PIN prompt to set a PIN is expected.
test_client_.expected = {{PINReason::kSet, kTestPIN}};
test_client_.expected = {{PINReason::kSet, kTestPIN16}};
break;
case kUsePIN:
// A single PIN prompt to get the PIN is expected.
test_client_.expected = {{PINReason::kChallenge, kTestPIN, 8}};
test_client_.expected = {
{PINReason::kChallenge, kTestPIN16, 8}};
break;
default:
@ -4210,10 +4210,10 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialSoftLock) {
virtual_device_factory_->mutable_state()->pin_retries =
device::kMaxPinRetries;
test_client_.expected = {{PINReason::kChallenge, "wrong", 8},
{PINReason::kChallenge, "wrong", 7,
test_client_.expected = {{PINReason::kChallenge, u"wrong", 8},
{PINReason::kChallenge, u"wrong", 7,
device::kMinPinLength, PINError::kWrongPIN},
{PINReason::kChallenge, "wrong", 6,
{PINReason::kChallenge, u"wrong", 6,
device::kMinPinLength, PINError::kWrongPIN}};
EXPECT_EQ(AuthenticatorMakeCredential(make_credential_options()).status,
AuthenticatorStatus::NOT_ALLOWED_ERROR);
@ -4228,7 +4228,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialHardLock) {
virtual_device_factory_->mutable_state()->pin = kTestPIN;
virtual_device_factory_->mutable_state()->pin_retries = 1;
test_client_.expected = {{PINReason::kChallenge, "wrong", 1}};
test_client_.expected = {{PINReason::kChallenge, u"wrong", 1}};
EXPECT_EQ(AuthenticatorMakeCredential().status,
AuthenticatorStatus::NOT_ALLOWED_ERROR);
EXPECT_EQ(0, virtual_device_factory_->mutable_state()->pin_retries);
@ -4243,8 +4243,8 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialWrongPINFirst) {
device::kMaxPinRetries;
// Test that we can successfully get a PIN token after a failure.
test_client_.expected = {{PINReason::kChallenge, "wrong", 8},
{PINReason::kChallenge, kTestPIN, 7,
test_client_.expected = {{PINReason::kChallenge, u"wrong", 8},
{PINReason::kChallenge, kTestPIN16, 7,
device::kMinPinLength, PINError::kWrongPIN}};
EXPECT_EQ(AuthenticatorMakeCredential().status, AuthenticatorStatus::SUCCESS);
EXPECT_EQ(static_cast<int>(device::kMaxPinRetries),
@ -4262,7 +4262,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialSkipPINTouch) {
virtual_device_factory_->mutable_state()->pin_retries =
device::kMaxPinRetries;
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
EXPECT_EQ(AuthenticatorMakeCredential().status, AuthenticatorStatus::SUCCESS);
EXPECT_EQ(taps, 1);
}
@ -4293,7 +4293,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialDontSkipPINTouch) {
->ReplaceDefaultDiscoveryFactoryForTesting(std::move(discovery));
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
EXPECT_EQ(AuthenticatorMakeCredential().status, AuthenticatorStatus::SUCCESS);
EXPECT_EQ(taps, 2);
}
@ -4312,7 +4312,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialAlwaysUv) {
virtual_device_factory_->SetCtap2Config(config);
virtual_device_factory_->mutable_state()->pin = kTestPIN;
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
MakeCredentialResult result =
AuthenticatorMakeCredential(make_credential_options(
@ -4365,7 +4365,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialMinPINLengthNewPIN) {
config.ctap2_versions = {device::Ctap2Version::kCtap2_1};
virtual_device_factory_->SetCtap2Config(config);
virtual_device_factory_->mutable_state()->min_pin_length = 6;
test_client_.expected = {{PINReason::kSet, "123456", 0, 6}};
test_client_.expected = {{PINReason::kSet, u"123456", 0, 6}};
MakeCredentialResult result =
AuthenticatorMakeCredential(make_credential_options());
@ -4385,7 +4385,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialMinPINLengthExistingPIN) {
virtual_device_factory_->mutable_state()->min_pin_length = 6;
virtual_device_factory_->mutable_state()->pin = "123456";
test_client_.expected = {
{PINReason::kChallenge, "123456", device::kMaxPinRetries, 6}};
{PINReason::kChallenge, u"123456", device::kMaxPinRetries, 6}};
MakeCredentialResult result =
AuthenticatorMakeCredential(make_credential_options());
@ -4408,9 +4408,9 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialForcePINChange) {
virtual_device_factory_->mutable_state()->pin_retries =
device::kMaxPinRetries;
virtual_device_factory_->mutable_state()->min_pin_length = 6;
test_client_.expected = {{PINReason::kChallenge, kTestPIN,
test_client_.expected = {{PINReason::kChallenge, kTestPIN16,
device::kMaxPinRetries, device::kMinPinLength},
{PINReason::kChange, "567890", 0, 6}};
{PINReason::kChange, u"567890", 0, 6}};
MakeCredentialResult result =
AuthenticatorMakeCredential(make_credential_options());
@ -4440,7 +4440,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredUvNotRqd) {
// PIN is still required for discoverable credentials, or if the caller
// requests it.
if (discoverable || request_uv) {
test_client_.expected = {{PINReason::kChallenge, kTestPIN,
test_client_.expected = {{PINReason::kChallenge, kTestPIN16,
device::kMaxPinRetries,
device::kMinPinLength}};
} else {
@ -4485,10 +4485,10 @@ TEST_F(PINAuthenticatorImplTest, MakeCredUvNotRqdAndAlwaysUv) {
virtual_device_factory_->SetCtap2Config(config);
if (pin_set) {
virtual_device_factory_->mutable_state()->pin = kTestPIN;
test_client_.expected = {{PINReason::kChallenge, kTestPIN,
test_client_.expected = {{PINReason::kChallenge, kTestPIN16,
device::kMaxPinRetries, device::kMinPinLength}};
} else {
test_client_.expected = {{PINReason::kSet, kTestPIN,
test_client_.expected = {{PINReason::kSet, kTestPIN16,
device::kMaxPinRetries, device::kMinPinLength}};
}
@ -4556,7 +4556,8 @@ TEST_F(PINAuthenticatorImplTest, GetAssertion) {
case kUsePIN:
// A single prompt to get the PIN is expected.
test_client_.expected = {{PINReason::kChallenge, kTestPIN, 8}};
test_client_.expected = {
{PINReason::kChallenge, kTestPIN16, 8}};
break;
default:
@ -4603,10 +4604,10 @@ TEST_F(PINAuthenticatorImplTest, GetAssertionSoftLock) {
ASSERT_TRUE(virtual_device_factory_->mutable_state()->InjectRegistration(
options->allow_credentials[0].id(), kTestRelyingPartyId));
test_client_.expected = {{PINReason::kChallenge, "wrong", 8},
{PINReason::kChallenge, "wrong", 7,
test_client_.expected = {{PINReason::kChallenge, u"wrong", 8},
{PINReason::kChallenge, u"wrong", 7,
device::kMinPinLength, PINError::kWrongPIN},
{PINReason::kChallenge, "wrong", 6,
{PINReason::kChallenge, u"wrong", 6,
device::kMinPinLength, PINError::kWrongPIN}};
EXPECT_EQ(AuthenticatorGetAssertion(std::move(options)).status,
AuthenticatorStatus::NOT_ALLOWED_ERROR);
@ -4625,7 +4626,7 @@ TEST_F(PINAuthenticatorImplTest, GetAssertionHardLock) {
ASSERT_TRUE(virtual_device_factory_->mutable_state()->InjectRegistration(
options->allow_credentials[0].id(), kTestRelyingPartyId));
test_client_.expected = {{PINReason::kChallenge, "wrong", 1}};
test_client_.expected = {{PINReason::kChallenge, u"wrong", 1}};
EXPECT_EQ(AuthenticatorGetAssertion(std::move(options)).status,
AuthenticatorStatus::NOT_ALLOWED_ERROR);
EXPECT_EQ(0, virtual_device_factory_->mutable_state()->pin_retries);
@ -4646,7 +4647,7 @@ TEST_F(PINAuthenticatorImplTest, GetAssertionSkipPINTouch) {
ASSERT_TRUE(virtual_device_factory_->mutable_state()->InjectRegistration(
options->allow_credentials[0].id(), kTestRelyingPartyId));
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
EXPECT_EQ(AuthenticatorGetAssertion(std::move(options)).status,
AuthenticatorStatus::SUCCESS);
EXPECT_EQ(taps, 1);
@ -4681,7 +4682,7 @@ TEST_F(PINAuthenticatorImplTest, GetAssertionDontSkipPINTouch) {
->ReplaceDefaultDiscoveryFactoryForTesting(std::move(discovery));
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
EXPECT_EQ(AuthenticatorGetAssertion(std::move(options)).status,
AuthenticatorStatus::SUCCESS);
EXPECT_EQ(taps, 2);
@ -4701,7 +4702,7 @@ TEST_F(PINAuthenticatorImplTest, GetAssertionAlwaysUv) {
ASSERT_TRUE(virtual_device_factory_->mutable_state()->InjectRegistration(
options->allow_credentials[0].id(), kTestRelyingPartyId));
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
GetAssertionResult result = AuthenticatorGetAssertion(std::move(options));
EXPECT_EQ(result.status, AuthenticatorStatus::SUCCESS);
@ -4772,7 +4773,7 @@ TEST_F(PINAuthenticatorImplTest, MakeCredentialNoSupportedAlgorithm) {
device::kMaxPinRetries;
virtual_device_factory_->SetCtap2Config(config);
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
// Since converting to U2F isn't possible, this will trigger a PIN prompt
// and succeed because the device does actually support the algorithm.
expected_to_succeed = true;
@ -4832,7 +4833,7 @@ TEST_F(PINAuthenticatorImplTest, PRFCreatedOnCTAP2) {
// test infrastructure will CHECK if |expected| is set and not used.)
options->prf_enable = true;
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
} else {
// If PRF is requested, but the authenticator doesn't support it, then we
// should still use U2F.
@ -4870,7 +4871,7 @@ TEST_F(PINAuthenticatorImplTest, ExcludeListBatchesIncludePinToken) {
device::kMaxPinRetries;
test_client_.expected = {
{PINReason::kChallenge, kTestPIN, device::kMaxPinRetries}};
{PINReason::kChallenge, kTestPIN16, device::kMaxPinRetries}};
// Craft an exclude list that is large enough to trigger batched probing and
// includes one match for a credProtect=uvRequired credential.
@ -5479,8 +5480,7 @@ class ResidentKeyTestAuthenticatorRequestDelegate
CollectPINOptions options,
base::OnceCallback<void(std::u16string)> provide_pin_cb) override {
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(provide_pin_cb), base::UTF8ToUTF16(kTestPIN)));
FROM_HERE, base::BindOnce(std::move(provide_pin_cb), kTestPIN16));
}
void FinishCollectToken() override {}

@ -20,7 +20,7 @@ const int kDummyDefaultResourceId = 456;
const int kDummyResourceId = 789;
const int kDummyJSResourceId = 790;
const char kDummyString[] = "foo";
const char16_t kDummyString[] = u"foo";
const char kDummyDefaultResource[] = "<html>foo</html>";
const char kDummyResource[] = "<html>blah</html>";
const char kDummyJSResource[] = "export const bar = 5;";
@ -31,7 +31,7 @@ class TestClient : public TestContentClient {
std::u16string GetLocalizedString(int message_id) override {
if (message_id == kDummyStringId)
return base::UTF8ToUTF16(kDummyString);
return kDummyString;
return std::u16string();
}

@ -2375,8 +2375,7 @@ TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
0, base::DoNothing());
// Non surrogate pair unicode character.
const std::u16string unicode_composition = base::UTF8ToUTF16(
"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A");
const std::u16string unicode_composition = u"あいうえお";
widget_input_handler->ImeSetComposition(unicode_composition,
empty_ime_text_span,
gfx::Range::InvalidRange(), 0, 0);
@ -2389,8 +2388,7 @@ TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
base::DoNothing());
// Surrogate pair character.
const std::u16string surrogate_pair_char =
base::UTF8ToUTF16("\xF0\xA0\xAE\x9F");
const std::u16string surrogate_pair_char = u"𠮟";
widget_input_handler->ImeSetComposition(surrogate_pair_char,
empty_ime_text_span,
gfx::Range::InvalidRange(), 0, 0);
@ -2404,8 +2402,8 @@ TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
// Mixed string.
const std::u16string surrogate_pair_mixed_composition =
surrogate_pair_char + base::UTF8ToUTF16("\xE3\x81\x82") +
surrogate_pair_char + u"b" + surrogate_pair_char;
surrogate_pair_char + u"" + surrogate_pair_char + u"b" +
surrogate_pair_char;
const size_t utf16_length = 8UL;
const bool is_surrogate_pair_empty_rect[8] = {false, true, false, false,
true, false, false, true};

@ -34,14 +34,15 @@ using UserVerificationAvailability =
device::AuthenticatorSupportedOptions::UserVerificationAvailability;
constexpr char kTestPIN[] = "1234";
constexpr char kNewPIN[] = "5678";
constexpr char16_t kTestPIN16[] = u"1234";
constexpr char16_t kNewPIN[] = u"5678";
struct TestExpectation {
pin::PINEntryReason reason;
pin::PINEntryError error = pin::PINEntryError::kNoError;
uint32_t min_pin_length = kMinPinLength;
int attempts = 8;
std::u16string pin = base::UTF8ToUTF16(kTestPIN);
std::u16string pin = kTestPIN16;
};
struct TestCase {
@ -471,7 +472,7 @@ TEST_F(AuthTokenRequesterTest, ForcePINChange) {
{
.reason = pin::PINEntryReason::kChange,
.attempts = 0,
.pin = base::UTF8ToUTF16(kNewPIN),
.pin = kNewPIN,
}}});
EXPECT_EQ(*delegate_->result(), AuthTokenRequester::Result::kSuccess);
@ -500,7 +501,7 @@ TEST_F(AuthTokenRequesterTest, ForcePINChangeSameAsCurrent) {
.reason = pin::PINEntryReason::kChange,
.error = pin::PINEntryError::kSameAsCurrentPIN,
.attempts = 0,
.pin = base::UTF8ToUTF16(kNewPIN),
.pin = kNewPIN,
}}});
EXPECT_EQ(*delegate_->result(), AuthTokenRequester::Result::kSuccess);

@ -13,7 +13,7 @@
namespace extensions {
namespace {
const char kAnonymousFunction[] = "(anonymous function)";
const char16_t kAnonymousFunction[] = u"(anonymous function)";
}
StackFrame::StackFrame() : line_number(1), column_number(1) {
@ -33,8 +33,7 @@ StackFrame::StackFrame(uint32_t line_number,
: line_number(line_number),
column_number(column_number),
source(source),
function(function.empty() ? base::UTF8ToUTF16(kAnonymousFunction)
: function) {}
function(function.empty() ? kAnonymousFunction : function) {}
StackFrame::~StackFrame() {
}

@ -26,7 +26,7 @@ namespace extensions {
namespace {
// The delimiter for a stack trace provided by WebKit.
const char kStackFrameDelimiter[] = "\n at ";
const char16_t kStackFrameDelimiter[] = u"\n at ";
// Get a stack trace from a WebKit console message.
// There are three possible scenarios:
@ -46,17 +46,16 @@ StackTrace GetStackTraceFromMessage(std::u16string* message,
std::vector<std::u16string> pieces;
size_t index = 0;
if (message->find(base::UTF8ToUTF16(kStackFrameDelimiter)) !=
std::u16string::npos) {
pieces = base::SplitStringUsingSubstr(
*message, base::UTF8ToUTF16(kStackFrameDelimiter),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
if (message->find(kStackFrameDelimiter) != std::u16string::npos) {
pieces = base::SplitStringUsingSubstr(*message, kStackFrameDelimiter,
base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL);
*message = pieces[0];
index = 1;
} else if (!stack_trace.empty()) {
pieces = base::SplitStringUsingSubstr(
stack_trace, base::UTF8ToUTF16(kStackFrameDelimiter),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
pieces = base::SplitStringUsingSubstr(stack_trace, kStackFrameDelimiter,
base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL);
}
// If we got a stack trace, parse each frame from the text.

@ -21,7 +21,9 @@ using mojom::BluetoothDeviceInfoPtr;
constexpr std::array<uint8_t, 6> kAddress = {0x00, 0x00, 0x00,
0x00, 0x00, 0x00};
constexpr char kName[] = "Foo Bar";
constexpr char16_t kName16[] = u"Foo Bar";
constexpr char kUnicodeName[] = "❤❤❤❤";
constexpr char16_t kUnicodeName16[] = u"❤❤❤❤";
constexpr char kEmptyName[] = "";
constexpr char kWhitespaceName[] = " ";
constexpr char kUnicodeWhitespaceName[] = "    ";
@ -62,7 +64,7 @@ TEST(BluetoothUtilsTest,
info->address = kAddress;
info->name = kName;
info->device_type = BluetoothDeviceInfo::DeviceType::kUnknown;
EXPECT_EQ(base::UTF8ToUTF16(kName), GetBluetoothDeviceNameForDisplay(info));
EXPECT_EQ(kName16, GetBluetoothDeviceNameForDisplay(info));
}
TEST(BluetoothUtilsTest,
@ -71,7 +73,7 @@ TEST(BluetoothUtilsTest,
info->address = kAddress;
info->name = kName;
info->device_type = BluetoothDeviceInfo::DeviceType::kComputer;
EXPECT_EQ(base::UTF8ToUTF16(kName), GetBluetoothDeviceNameForDisplay(info));
EXPECT_EQ(kName16, GetBluetoothDeviceNameForDisplay(info));
}
TEST(BluetoothUtilsTest, GetBluetoothDeviceNameForDisplay_UnicodeName) {
@ -79,8 +81,7 @@ TEST(BluetoothUtilsTest, GetBluetoothDeviceNameForDisplay_UnicodeName) {
info->address = kAddress;
info->name = kUnicodeName;
info->device_type = BluetoothDeviceInfo::DeviceType::kComputer;
EXPECT_EQ(base::UTF8ToUTF16(kUnicodeName),
GetBluetoothDeviceNameForDisplay(info));
EXPECT_EQ(kUnicodeName16, GetBluetoothDeviceNameForDisplay(info));
}
TEST(BluetoothUtilsTest, GetBluetoothDeviceNameForDisplay_EmptyName) {
@ -129,15 +130,14 @@ static std::u16string LabelFromTypeWithName(
TEST(BluetoothUtilsTest, GetBluetoothDeviceLabelForAccessibility) {
EXPECT_EQ(
l10n_util::GetStringFUTF16(
IDS_BLUETOOTH_ACCESSIBILITY_DEVICE_TYPE_COMPUTER,
base::UTF8ToUTF16(kName)),
IDS_BLUETOOTH_ACCESSIBILITY_DEVICE_TYPE_COMPUTER, kName16),
LabelFromTypeWithName(BluetoothDeviceInfo::DeviceType::kComputer, kName));
EXPECT_EQ(l10n_util::GetStringFUTF16(
IDS_BLUETOOTH_ACCESSIBILITY_DEVICE_TYPE_CAR_AUDIO,
base::UTF8ToUTF16(kUnicodeName)),
LabelFromTypeWithName(BluetoothDeviceInfo::DeviceType::kCarAudio,
kUnicodeName));
EXPECT_EQ(
l10n_util::GetStringFUTF16(
IDS_BLUETOOTH_ACCESSIBILITY_DEVICE_TYPE_CAR_AUDIO, kUnicodeName16),
LabelFromTypeWithName(BluetoothDeviceInfo::DeviceType::kCarAudio,
kUnicodeName));
EXPECT_EQ(l10n_util::GetStringFUTF16(
IDS_BLUETOOTH_ACCESSIBILITY_DEVICE_TYPE_KEYBOARD,
u"00:00:00:00:00:00"),

@ -197,8 +197,8 @@ class PageStateSerializationTest : public testing::Test {
frame_state->document_sequence_number = 456;
frame_state->page_scale_factor = 2.0f;
frame_state->document_state.push_back(base::UTF8ToUTF16(
"\n\r?% WebKit serialized form state version 8 \n\r=&"));
frame_state->document_state.push_back(
u"\n\r?% WebKit serialized form state version 8 \n\r=&");
frame_state->document_state.push_back(u"form key");
frame_state->document_state.push_back(u"1");
frame_state->document_state.push_back(u"foo");
@ -459,9 +459,8 @@ TEST_F(PageStateSerializationTest, ScrollAnchorSelectorLengthLimited) {
ExplodedPageState input;
PopulateFrameState(&input.top);
std::string excessive_length_string(kMaxScrollAnchorSelectorLength + 1, 'a');
input.top.scroll_anchor_selector = base::UTF8ToUTF16(excessive_length_string);
input.top.scroll_anchor_selector =
std::u16string(kMaxScrollAnchorSelectorLength + 1, u'a');
std::string encoded;
EncodePageState(input, &encoded);

@ -290,14 +290,14 @@ TEST(AXTextUtils, GetWordStartOffsetsMalformedInputTest) {
}
TEST(AXTextUtils, GetSentenceStartOffsetsBasicTest) {
const std::u16string text = base::UTF8ToUTF16(
"This is the first sentence. This is the second sentence");
const std::u16string text =
u"This is the first sentence. This is the second sentence";
EXPECT_THAT(GetSentenceStartOffsets(text), testing::ElementsAre(0, 28));
}
TEST(AXTextUtils, GetSentenceEndOffsetsBasicTest) {
const std::u16string text = base::UTF8ToUTF16(
"This is the first sentence. This is the second sentence");
const std::u16string text =
u"This is the first sentence. This is the second sentence";
EXPECT_THAT(GetSentenceEndOffsets(text), testing::ElementsAre(28, 55));
}

@ -63,7 +63,6 @@
using base::ASCIIToUTF16;
using base::UTF16ToUTF8;
using base::UTF8ToUTF16;
using testing::Contains;
@ -366,8 +365,7 @@ TYPED_TEST(ClipboardTest, TrickyHTMLTest) {
// Some platforms store HTML as UTF-8 internally. Make sure fragment indices are
// adjusted appropriately when converting back to UTF-16.
TYPED_TEST(ClipboardTest, UnicodeHTMLTest) {
std::u16string markup(UTF8ToUTF16("<div>A \xc3\xb8 \xe6\xb0\xb4</div>")),
markup_result;
std::u16string markup(u"<div>A ø 水</div>"), markup_result;
std::string url, url_result;
{
@ -443,7 +441,7 @@ TYPED_TEST(ClipboardTest, FilenamesTest) {
this->clipboard().ReadAvailableTypes(ClipboardBuffer::kCopyPaste,
/* data_dst = */ nullptr, &types);
EXPECT_EQ(1u, types.size());
EXPECT_EQ("text/uri-list", base::UTF16ToUTF8(types[0]));
EXPECT_EQ(u"text/uri-list", types[0]);
std::vector<ui::FileInfo> filenames;
this->clipboard().ReadFilenames(ClipboardBuffer::kCopyPaste,
@ -708,6 +706,7 @@ TYPED_TEST(ClipboardTest, MultiplePickleTest) {
TYPED_TEST(ClipboardTest, DataTest) {
const std::string kFormatString = "chromium/x-test-format";
const std::u16string kFormatString16 = u"chromium/x-test-format";
const ClipboardFormatType kFormat =
ClipboardFormatType::GetType(kFormatString);
const std::string payload = "test string";
@ -716,7 +715,7 @@ TYPED_TEST(ClipboardTest, DataTest) {
{
ScopedClipboardWriter clipboard_writer(ClipboardBuffer::kCopyPaste);
clipboard_writer.WriteData(UTF8ToUTF16(kFormatString),
clipboard_writer.WriteData(kFormatString16,
mojo_base::BigBuffer(payload_span));
}
@ -736,6 +735,7 @@ TYPED_TEST(ClipboardTest, DataTest) {
!BUILDFLAG(IS_CHROMEOS_ASH)
TYPED_TEST(ClipboardTest, MultipleDataTest) {
const std::string kFormatString1 = "chromium/x-test-format1";
const std::u16string kFormatString116 = u"chromium/x-test-format1";
const ClipboardFormatType kFormat1 =
ClipboardFormatType::GetType(kFormatString1);
const std::string payload1("test string1");
@ -743,6 +743,7 @@ TYPED_TEST(ClipboardTest, MultipleDataTest) {
reinterpret_cast<const uint8_t*>(payload1.data()), payload1.size());
const std::string kFormatString2 = "chromium/x-test-format2";
const std::u16string kFormatString216 = u"chromium/x-test-format2";
const ClipboardFormatType kFormat2 =
ClipboardFormatType::GetType(kFormatString2);
const std::string payload2("test string2");
@ -752,16 +753,16 @@ TYPED_TEST(ClipboardTest, MultipleDataTest) {
{
ScopedClipboardWriter clipboard_writer(ClipboardBuffer::kCopyPaste);
// Both payloads should write successfully and not overwrite one another.
clipboard_writer.WriteData(UTF8ToUTF16(kFormatString1),
clipboard_writer.WriteData(kFormatString116,
mojo_base::BigBuffer(payload_span1));
clipboard_writer.WriteData(UTF8ToUTF16(kFormatString2),
clipboard_writer.WriteData(kFormatString216,
mojo_base::BigBuffer(payload_span2));
}
// Check format 1.
EXPECT_THAT(this->clipboard().ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer::kCopyPaste, /* data_dst = */ nullptr),
Contains(ASCIIToUTF16(kFormatString1)));
Contains(kFormatString116));
EXPECT_TRUE(this->clipboard().IsFormatAvailable(
kFormat1, ClipboardBuffer::kCopyPaste, /* data_dst = */ nullptr));
std::string output1;
@ -771,7 +772,7 @@ TYPED_TEST(ClipboardTest, MultipleDataTest) {
// Check format 2.
EXPECT_THAT(this->clipboard().ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer::kCopyPaste, /* data_dst = */ nullptr),
Contains(ASCIIToUTF16(kFormatString2)));
Contains(kFormatString216));
EXPECT_TRUE(this->clipboard().IsFormatAvailable(
kFormat2, ClipboardBuffer::kCopyPaste, /* data_dst = */ nullptr));
std::string output2;
@ -904,9 +905,9 @@ TYPED_TEST(ClipboardTest, PlatformSpecificDataTest) {
TYPED_TEST(ClipboardTest, HyperlinkTest) {
const std::string kTitle("The <Example> Company's \"home page\"");
const std::string kUrl("http://www.example.com?x=3&lt=3#\"'<>");
const std::u16string kExpectedHtml(UTF8ToUTF16(
"<a href=\"http://www.example.com?x=3&amp;lt=3#&quot;&#39;&lt;&gt;\">"
"The &lt;Example&gt; Company&#39;s &quot;home page&quot;</a>"));
const std::u16string kExpectedHtml(
u"<a href=\"http://www.example.com?x=3&amp;lt=3#&quot;&#39;&lt;&gt;\">"
u"The &lt;Example&gt; Company&#39;s &quot;home page&quot;</a>");
std::string url_result;
std::u16string html_result;

@ -121,9 +121,10 @@ TEST_P(BiDiLineIteratorTest, Mixed) {
TEST_P(BiDiLineIteratorTest, RTLPunctuationNoCustomBehavior) {
// This string features Hebrew characters interleaved with ASCII punctuation.
iterator()->Open(base::UTF8ToUTF16("א!ב\"ג#ד$ה%ו&ז'ח(ט)י*ך+כ,ל-ם.מ/"
"ן:נ;ס<ע=ף>פ?ץ@צ[ק\\ר]ש^ת_א`ב{ג|ד}ה~ו"),
GetParam());
iterator()->Open(
u"א!ב\"ג#ד$ה%ו&ז'ח(ט)י*ך+כ,ל-ם.מ/"
u"ן:נ;ס<ע=ף>פ?ץ@צ[ק\\ר]ש^ת_א`ב{ג|ד}ה~ו",
GetParam());
// Expect a single RTL run.
ASSERT_EQ(1, iterator()->CountRuns());

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -11,6 +11,7 @@
#include "base/i18n/time_formatting.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@ -21,8 +22,6 @@
#include "ui/message_center/public/cpp/notification_types.h"
#include "ui/message_center/public/cpp/notifier_id.h"
using base::UTF8ToUTF16;
namespace message_center {
using NotificationState = NotificationList::NotificationState;
@ -61,13 +60,13 @@ class NotificationListTest : public testing::Test {
const RichNotificationData& optional_fields,
std::string* id_out) {
*id_out = base::StringPrintf(kIdFormat, counter_);
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, *id_out,
UTF8ToUTF16(base::StringPrintf(kTitleFormat, counter_)),
UTF8ToUTF16(base::StringPrintf(kMessageFormat, counter_)), gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), optional_fields,
nullptr));
std::unique_ptr<Notification> notification(
new Notification(NOTIFICATION_TYPE_SIMPLE, *id_out,
u"id" + base::NumberToString16(counter_),
u"message" + base::NumberToString16(counter_),
gfx::Image(), kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId),
optional_fields, nullptr));
return notification;
}
@ -104,9 +103,7 @@ class NotificationListTest : public testing::Test {
}
static const char kIdFormat[];
static const char kTitleFormat[];
static const char kMessageFormat[];
static const char kDisplaySource[];
static const char16_t kDisplaySource[];
static const char kExtensionId[];
std::unique_ptr<FakeMessageCenter> message_center_;
@ -128,9 +125,7 @@ bool IsInNotifications(const NotificationList::Notifications& notifications,
}
const char NotificationListTest::kIdFormat[] = "id%ld";
const char NotificationListTest::kTitleFormat[] = "id%ld";
const char NotificationListTest::kMessageFormat[] = "message%ld";
const char NotificationListTest::kDisplaySource[] = "source";
const char16_t NotificationListTest::kDisplaySource[] = u"source";
const char NotificationListTest::kExtensionId[] = "ext";
TEST_F(NotificationListTest, Basic) {
@ -174,11 +169,11 @@ TEST_F(NotificationListTest, UpdateNotification) {
std::string id0 = AddNotification();
std::string replaced = id0 + "_replaced";
EXPECT_EQ(1u, notification_list_->NotificationCount(blockers_));
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle", u"newbody", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId),
RichNotificationData(), nullptr));
std::unique_ptr<Notification> notification(
new Notification(NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle",
u"newbody", gfx::Image(), kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId),
RichNotificationData(), nullptr));
notification_list_->UpdateNotificationMessage(id0, std::move(notification));
EXPECT_EQ(1u, notification_list_->NotificationCount(blockers_));
const NotificationList::Notifications notifications =
@ -465,11 +460,11 @@ TEST_F(NotificationListTest, UpdateWithoutMessageCenterView) {
EXPECT_EQ(0u, GetPopupCounts());
RichNotificationData optional;
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle", u"newbody",
gfx::Image(), UTF8ToUTF16(kDisplaySource), GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), optional,
nullptr));
std::unique_ptr<Notification> notification(
new Notification(NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle",
u"newbody", gfx::Image(), kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId),
optional, nullptr));
notification_list_->UpdateNotificationMessage(id0, std::move(notification));
EXPECT_EQ(1u, notification_list_->NotificationCount(blockers_));
EXPECT_EQ(has_message_center_view ? 0U : 1U, GetPopupCounts());
@ -498,7 +493,7 @@ TEST_F(NotificationListTest, Renotify) {
optional.renotify = true;
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle", u"newbody", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), optional, nullptr));
notification_list_->UpdateNotificationMessage(id0, std::move(notification));
EXPECT_EQ(1u, notification_list_->NotificationCount(blockers_));
@ -522,7 +517,7 @@ TEST_F(NotificationListTest, PriorityAndRenotify) {
priority.priority = DEFAULT_PRIORITY;
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, id0, u"newtitle", u"newbody", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), priority, nullptr));
notification_list_->UpdateNotificationMessage(id0, std::move(notification));
EXPECT_EQ(1u, GetPopupCounts());
@ -532,7 +527,7 @@ TEST_F(NotificationListTest, PriorityAndRenotify) {
// update with no promotion change for id0, it won't appear as a toast.
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_SIMPLE, id0, u"newtitle2", u"newbody2", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), priority, nullptr);
notification_list_->UpdateNotificationMessage(id0, std::move(notification));
EXPECT_EQ(0u, GetPopupCounts());
@ -541,7 +536,7 @@ TEST_F(NotificationListTest, PriorityAndRenotify) {
priority.priority = HIGH_PRIORITY;
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_SIMPLE, id1, u"newtitle", u"newbody", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), priority, nullptr);
notification_list_->UpdateNotificationMessage(id1, std::move(notification));
EXPECT_EQ(0u, GetPopupCounts());
@ -550,7 +545,7 @@ TEST_F(NotificationListTest, PriorityAndRenotify) {
priority.renotify = true;
notification = std::make_unique<Notification>(
NOTIFICATION_TYPE_SIMPLE, id1, u"newtitle", u"newbody", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId), priority, nullptr);
notification_list_->UpdateNotificationMessage(id1, std::move(notification));
EXPECT_EQ(1u, GetPopupCounts());
@ -648,11 +643,11 @@ TEST_F(NotificationListTest, UpdateAfterMarkedAsShown) {
EXPECT_TRUE(n1_state.is_read);
const std::string replaced("test-replaced-id");
std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle", u"newbody", gfx::Image(),
UTF8ToUTF16(kDisplaySource), GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId),
RichNotificationData(), nullptr));
std::unique_ptr<Notification> notification(
new Notification(NOTIFICATION_TYPE_SIMPLE, replaced, u"newtitle",
u"newbody", gfx::Image(), kDisplaySource, GURL(),
NotifierId(NotifierType::APPLICATION, kExtensionId),
RichNotificationData(), nullptr));
notification_list_->UpdateNotificationMessage(id1, std::move(notification));
Notification* n1 = GetNotification(id1);
EXPECT_TRUE(n1 == nullptr);

@ -77,9 +77,6 @@
#include "ui/base/cocoa/text_services_context_menu.h"
#endif
using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
namespace views {
namespace test {
@ -428,8 +425,8 @@ std::u16string TextfieldTest::GetClipboardText(
}
void TextfieldTest::SetClipboardText(ui::ClipboardBuffer clipboard_buffer,
const std::string& text) {
ui::ScopedClipboardWriter(clipboard_buffer).WriteText(ASCIIToUTF16(text));
const std::u16string& text) {
ui::ScopedClipboardWriter(clipboard_buffer).WriteText(text);
}
void TextfieldTest::ContentsChanged(Textfield* sender,
@ -1430,7 +1427,7 @@ TEST_F(TextfieldTest, PasswordTest) {
EXPECT_EQ(u"password", textfield_->GetText());
EXPECT_TRUE(last_contents_.empty());
model_->SelectAll(false);
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "foo");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"foo");
// Cut and copy should be disabled.
EXPECT_FALSE(textfield_->IsCommandIdEnabled(Textfield::kCut));
@ -1794,7 +1791,7 @@ TEST_F(TextfieldTest, ContextMenuDisplayTest) {
VerifyTextfieldContextMenuContents(true, true, GetContextMenuModel());
// Exercise the "paste enabled?" check in the verifier.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"Test");
VerifyTextfieldContextMenuContents(true, true, GetContextMenuModel());
}
@ -1893,10 +1890,10 @@ TEST_F(TextfieldTest, DragToSelect) {
TEST_F(TextfieldTest, DragUpOrDownSelectsToEnd) {
InitTextfield();
textfield_->SetText(u"hello world");
const std::u16string expected_left = base::ASCIIToUTF16(
gfx::RenderText::kDragToEndIfOutsideVerticalBounds ? "hello" : "lo");
const std::u16string expected_right = base::ASCIIToUTF16(
gfx::RenderText::kDragToEndIfOutsideVerticalBounds ? " world" : " w");
const std::u16string expected_left =
gfx::RenderText::kDragToEndIfOutsideVerticalBounds ? u"hello" : u"lo";
const std::u16string expected_right =
gfx::RenderText::kDragToEndIfOutsideVerticalBounds ? u" world" : u" w";
const int right_x = GetCursorPositionX(7);
const int left_x = GetCursorPositionX(3);
@ -2166,7 +2163,7 @@ TEST_F(TextfieldTest, ReadOnlyTest) {
EXPECT_EQ(u"read only", textfield_->GetSelectedText());
// Cut should be disabled.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"Test");
EXPECT_FALSE(textfield_->IsCommandIdEnabled(Textfield::kCut));
textfield_->ExecuteCommand(Textfield::kCut, 0);
SendKeyEvent(ui::VKEY_X, false, true);
@ -2182,14 +2179,14 @@ TEST_F(TextfieldTest, ReadOnlyTest) {
EXPECT_EQ(u"read only", textfield_->GetText());
// Copy should work normally.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"Test");
EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kCopy));
textfield_->ExecuteCommand(Textfield::kCopy, 0);
EXPECT_EQ(u"read only", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"Test");
SendKeyEvent(ui::VKEY_C, false, true);
EXPECT_EQ(u"read only", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"Test");
SendAlternateCopy();
EXPECT_EQ(u"read only", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
@ -2530,7 +2527,7 @@ TEST_F(TextfieldTest, CutCopyPaste) {
EXPECT_EQ(ui::ClipboardBuffer::kCopyPaste, GetAndResetCopiedToClipboard());
// Reset clipboard text.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"");
// Ensure [Shift]+[Delete] is a no-op in case there is no selection.
textfield_->SetText(u"123");
@ -2568,7 +2565,7 @@ TEST_F(TextfieldTest, CutCopyPaste) {
// Ensure kPaste, [Ctrl]+[V], and [Shift]+[Insert] pastes;
// also ensure that [Ctrl]+[Alt]+[V] does nothing.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "abc");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"abc");
textfield_->SetText(std::u16string());
EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kPaste));
textfield_->ExecuteCommand(Textfield::kPaste, 0);
@ -3252,7 +3249,7 @@ TEST_F(TextfieldTest, SelectionClipboard) {
EXPECT_EQ(u"0123", GetClipboardText(ui::ClipboardBuffer::kSelection));
// Middle clicking with an empty selection clipboard should still focus.
SetClipboardText(ui::ClipboardBuffer::kSelection, std::string());
SetClipboardText(ui::ClipboardBuffer::kSelection, std::u16string());
textfield_->GetFocusManager()->ClearFocus();
EXPECT_FALSE(textfield_->HasFocus());
textfield_->OnMousePressed(middle);
@ -3264,7 +3261,7 @@ TEST_F(TextfieldTest, SelectionClipboard) {
// Middle clicking in the selection should insert the selection clipboard
// contents into the middle of the selection, and move the cursor to the end
// of the pasted content.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "foo");
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, u"foo");
textfield_->SetSelectedRange(gfx::Range(2, 6));
textfield_->OnMousePressed(middle);
EXPECT_EQ(u"0123foo01230123", textfield_->GetText());
@ -3304,7 +3301,7 @@ TEST_F(TextfieldTest, SelectionClipboard) {
EXPECT_EQ(u"ab cd ef", GetClipboardText(ui::ClipboardBuffer::kSelection));
EXPECT_EQ(ui::ClipboardBuffer::kMaxValue, GetAndResetCopiedToClipboard());
SetClipboardText(ui::ClipboardBuffer::kSelection, "other");
SetClipboardText(ui::ClipboardBuffer::kSelection, u"other");
textfield_->SelectAll(false);
EXPECT_EQ(u"other", GetClipboardText(ui::ClipboardBuffer::kSelection));
EXPECT_EQ(ui::ClipboardBuffer::kMaxValue, GetAndResetCopiedToClipboard());
@ -3380,7 +3377,7 @@ TEST_F(TextfieldTest, GetTextfieldBaseline_FontFallbackTest) {
// Set text which may fall back to a font which has taller baseline than
// the default font.
textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91"));
textfield_->SetText(u"");
const int new_baseline = textfield_->GetBaseline();
// Regardless of the text, the baseline must be the same.
@ -3425,7 +3422,7 @@ TEST_F(TextfieldTest, SetAccessibleNameNotifiesAccessibilityEvent) {
textfield_->GetAccessibleNodeData(&data);
const std::string& name =
data.GetStringAttribute(ax::mojom::StringAttribute::kName);
EXPECT_EQ(test_tooltip_text, ASCIIToUTF16(name));
EXPECT_EQ(test_tooltip_text, base::ASCIIToUTF16(name));
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
@ -3768,12 +3765,12 @@ TEST_F(TextfieldTest, SwitchFocusInKeyDown) {
}
TEST_F(TextfieldTest, FocusChangesScrollToStart) {
const std::string& kText = "abcdef";
const std::u16string kText = u"abcdef";
InitTextfield();
textfield_->SetText(ASCIIToUTF16(kText));
EXPECT_EQ(base::ASCIIToUTF16(std::string()), textfield_->GetSelectedText());
textfield_->SetText(kText);
EXPECT_EQ(std::u16string(), textfield_->GetSelectedText());
textfield_->AboutToRequestFocusFromTabTraversal(false);
EXPECT_EQ(base::ASCIIToUTF16(kText), textfield_->GetSelectedText());
EXPECT_EQ(kText, textfield_->GetSelectedText());
if (PlatformStyle::kTextfieldScrollsToStartOnFocusChange)
EXPECT_EQ(0U, textfield_->GetCursorPosition());
else
@ -3929,9 +3926,9 @@ TEST_F(TextfieldTest, SecurePasswordInput) {
#endif // defined(OS_MAC)
TEST_F(TextfieldTest, AccessibilitySelectionEvents) {
const std::string& kText = "abcdef";
const std::u16string kText = u"abcdef";
InitTextfield();
textfield_->SetText(ASCIIToUTF16(kText));
textfield_->SetText(kText);
EXPECT_TRUE(textfield_->HasFocus());
int previous_selection_fired_count =
textfield_->GetAccessibilitySelectionFiredCount();

@ -42,7 +42,7 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
ui::ClipboardBuffer GetAndResetCopiedToClipboard();
std::u16string GetClipboardText(ui::ClipboardBuffer type);
void SetClipboardText(ui::ClipboardBuffer type, const std::string& text);
void SetClipboardText(ui::ClipboardBuffer type, const std::u16string& text);
// TextfieldController:
void ContentsChanged(Textfield* sender,

@ -18,16 +18,16 @@ namespace examples {
TextareaExample::TextareaExample() : ExampleBase("Textarea") {}
void TextareaExample::CreateExampleView(View* container) {
constexpr char kLongText[] =
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
" tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
"commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate "
"velit esse cillum dolore eu fugiat nulla pariatur.\n\nExcepteur sint "
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
"mollit anim id est laborum.";
constexpr char16_t kLongText[] =
u"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do "
u"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad "
u"minim veniam, quis nostrud exercitation ullamco laboris nisi ut "
u"aliquip ex ea commodo consequat.\nDuis aute irure dolor in "
u"reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla "
u"pariatur.\n\nExcepteur sint occaecat cupidatat non proident, sunt in "
u"culpa qui officia deserunt mollit anim id est laborum.";
auto textarea = std::make_unique<Textarea>();
textarea->SetText(base::UTF8ToUTF16(kLongText));
textarea->SetText(kLongText);
container->SetLayoutManager(std::make_unique<views::FillLayout>());
container->AddChildView(std::move(textarea));
}

@ -117,8 +117,7 @@ TEST(GURLTest, Empty) {
}
TEST(GURLTest, Copy) {
GURL url(base::UTF8ToUTF16(
"http://user:pass@google.com:99/foo;bar?q=a#ref"));
GURL url(u"http://user:pass@google.com:99/foo;bar?q=a#ref");
GURL url2(url);
EXPECT_TRUE(url2.is_valid());
@ -151,8 +150,7 @@ TEST(GURLTest, Copy) {
}
TEST(GURLTest, Assign) {
GURL url(base::UTF8ToUTF16(
"http://user:pass@google.com:99/foo;bar?q=a#ref"));
GURL url(u"http://user:pass@google.com:99/foo;bar?q=a#ref");
GURL url2;
url2 = url;
@ -194,8 +192,7 @@ TEST(GURLTest, SelfAssign) {
}
TEST(GURLTest, CopyFileSystem) {
GURL url(base::UTF8ToUTF16(
"filesystem:https://user:pass@google.com:99/t/foo;bar?q=a#ref"));
GURL url(u"filesystem:https://user:pass@google.com:99/t/foo;bar?q=a#ref");
GURL url2(url);
EXPECT_TRUE(url2.is_valid());