diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 159d7988a5d5f0..714e25616a2210 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -950,15 +950,6 @@ False, (), ), - ( - r'/\bASCIIToUTF16\("(\\.|[^\\"])*"\)', - ( - 'base::ASCIIToUTF16 should not be used with a string literal.', - 'Consider using a UTF16 string literal (u"...") instead.', - ), - False, - (), - ), ( r'/\bUTF8ToUTF16\("(\\.|[^\\"])*"\)', ( diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 1d0b7e1699f915..d5b727c5a3c190 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py @@ -2334,8 +2334,6 @@ def testBannedCppFunctions(self): ['using namespace std; // nocheck']), MockFile('some/cpp/comment/file.cc', [' // A comment about `using namespace std;`']), - MockFile('ascii/to/utf16/banned.cc', ['ASCIIToUTF16("Hello World")']), - MockFile('ascii/to/utf16/allowed.cc', ['ASCIIToUTF16("Hello" + kWorld)']), MockFile('utf8/to/utf16/banned.cc', [r'UTF8ToUTF16("Hello \" World")']), MockFile('utf8/to/utf16/allowed.cc', ['UTF8ToUTF16(kHello + "World")']), ] @@ -2353,9 +2351,6 @@ def testBannedCppFunctions(self): self.assertFalse('some/cpp/nocheck/file.cc' in results[1].message) self.assertFalse('some/cpp/comment/file.cc' in results[0].message) self.assertFalse('some/cpp/comment/file.cc' in results[1].message) - self.assertTrue('ascii/to/utf16/banned.cc' in results[0].message) - self.assertFalse('ascii/to/utf16/allowed.cc' in results[0].message) - self.assertFalse('ascii/to/utf16/allowed.cc' in results[1].message) self.assertTrue('utf8/to/utf16/banned.cc' in results[0].message) self.assertFalse('utf8/to/utf16/allowed.cc' in results[0].message) self.assertFalse('utf8/to/utf16/allowed.cc' in results[1].message) diff --git a/ash/multi_device_setup/multi_device_notification_presenter_unittest.cc b/ash/multi_device_setup/multi_device_notification_presenter_unittest.cc index f01ff6fdcf0bae..487fd4b489ed4b 100644 --- a/ash/multi_device_setup/multi_device_notification_presenter_unittest.cc +++ b/ash/multi_device_setup/multi_device_notification_presenter_unittest.cc @@ -33,8 +33,9 @@ namespace { const char kTestUserEmail[] = "test@example.com"; const char kTestHostDeviceName[] = "Test Device"; +const char16_t kTestHostDeviceName16[] = u"Test Device"; // This is the expected return value from GetChromeOSDeviceName() in tests. -const char kTestDeviceType[] = "Chrome device"; +const char16_t kTestDeviceType[] = u"Chrome device"; class TestMessageCenter : public message_center::FakeMessageCenter { public: @@ -220,8 +221,7 @@ class MultiDeviceNotificationPresenterTest : public NoSessionAshTestBase { std::u16string title = l10n_util::GetStringUTF16( IDS_ASH_MULTI_DEVICE_WIFI_SYNC_AVAILABLE_TITLE); std::u16string message = l10n_util::GetStringFUTF16( - IDS_ASH_MULTI_DEVICE_WIFI_SYNC_AVAILABLE_MESSAGE, - base::ASCIIToUTF16(kTestDeviceType)); + IDS_ASH_MULTI_DEVICE_WIFI_SYNC_AVAILABLE_MESSAGE, kTestDeviceType); EXPECT_EQ(title, kVisibleNotification->title()); EXPECT_EQ(message, kVisibleNotification->message()); } @@ -306,25 +306,25 @@ class MultiDeviceNotificationPresenterTest : public NoSessionAshTestBase { IDS_ASH_MULTI_DEVICE_SETUP_NEW_USER_POTENTIAL_HOST_EXISTS_TITLE); message = l10n_util::GetStringFUTF16( IDS_ASH_MULTI_DEVICE_SETUP_NEW_USER_POTENTIAL_HOST_EXISTS_MESSAGE, - base::ASCIIToUTF16(kTestDeviceType)); + kTestDeviceType); break; case MultiDeviceNotificationPresenter::Status:: kExistingUserHostSwitchedNotificationVisible: title = l10n_util::GetStringFUTF16( IDS_ASH_MULTI_DEVICE_SETUP_EXISTING_USER_HOST_SWITCHED_TITLE, - base::ASCIIToUTF16(kTestHostDeviceName)); + kTestHostDeviceName16); message = l10n_util::GetStringFUTF16( IDS_ASH_MULTI_DEVICE_SETUP_EXISTING_USER_HOST_SWITCHED_MESSAGE, - base::ASCIIToUTF16(kTestDeviceType)); + kTestDeviceType); break; case MultiDeviceNotificationPresenter::Status:: kExistingUserNewChromebookNotificationVisible: title = l10n_util::GetStringFUTF16( IDS_ASH_MULTI_DEVICE_SETUP_EXISTING_USER_NEW_CHROME_DEVICE_ADDED_TITLE, - base::ASCIIToUTF16(kTestHostDeviceName)); + kTestHostDeviceName16); message = l10n_util::GetStringFUTF16( IDS_ASH_MULTI_DEVICE_SETUP_EXISTING_USER_NEW_CHROME_DEVICE_ADDED_MESSAGE, - base::ASCIIToUTF16(kTestDeviceType)); + kTestDeviceType); break; case MultiDeviceNotificationPresenter::Status::kNoNotificationVisible: NOTREACHED(); diff --git a/ash/system/power/peripheral_battery_listener_unittest.cc b/ash/system/power/peripheral_battery_listener_unittest.cc index c8a519e81a2e19..b5d26d450d7119 100644 --- a/ash/system/power/peripheral_battery_listener_unittest.cc +++ b/ash/system/power/peripheral_battery_listener_unittest.cc @@ -459,7 +459,7 @@ TEST_F(PeripheralBatteryListenerTest, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(5)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), - AFIELD(&BI::name, Eq(base::ASCIIToUTF16(kBluetoothDeviceName1))), + AFIELD(&BI::name, Eq(kBluetoothDeviceName116)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); EXPECT_CALL(listener_observer_mock, @@ -469,7 +469,7 @@ TEST_F(PeripheralBatteryListenerTest, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId2)), AFIELD(&BI::level, Eq(0)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), - AFIELD(&BI::name, Eq(base::ASCIIToUTF16(kBluetoothDeviceName2))), + AFIELD(&BI::name, Eq(kBluetoothDeviceName216)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress2))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), @@ -497,7 +497,7 @@ TEST_F(PeripheralBatteryListenerTest, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(5)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), - AFIELD(&BI::name, Eq(base::ASCIIToUTF16(kBluetoothDeviceName1))), + AFIELD(&BI::name, Eq(kBluetoothDeviceName116)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); EXPECT_CALL(listener_observer_mock, @@ -507,7 +507,7 @@ TEST_F(PeripheralBatteryListenerTest, OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId2)), AFIELD(&BI::level, Eq(0)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), - AFIELD(&BI::name, Eq(base::ASCIIToUTF16(kBluetoothDeviceName2))), + AFIELD(&BI::name, Eq(kBluetoothDeviceName216)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress2))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), @@ -1160,7 +1160,7 @@ TEST_F(PeripheralBatteryListenerTest, BluetoothDoesNotDiscardZeros) { OnUpdatedBatteryLevel(AllOf( AFIELD(&BI::key, Eq(kBluetoothDeviceId1)), AFIELD(&BI::level, Eq(0)), AFIELD(&BI::type, Eq(BI::PeripheralType::kOther)), - AFIELD(&BI::name, Eq(base::ASCIIToUTF16(kBluetoothDeviceName1))), + AFIELD(&BI::name, Eq(kBluetoothDeviceName116)), AFIELD(&BI::bluetooth_address, Eq(kBluetoothDeviceAddress1))))); battery_listener_->DeviceBatteryChanged(mock_adapter_.get(), diff --git a/ash/system/power/peripheral_battery_notifier_unittest.cc b/ash/system/power/peripheral_battery_notifier_unittest.cc index 0f3f8200e1ab08..dd4ab6e0104951 100644 --- a/ash/system/power/peripheral_battery_notifier_unittest.cc +++ b/ash/system/power/peripheral_battery_notifier_unittest.cc @@ -103,11 +103,11 @@ class PeripheralBatteryNotifierTest : public AshTestBase { void UpdateBatteryLevel(bool add_first, const std::string key, - const std::string name, + const std::u16string name, base::Optional level, BI::PeripheralType type, const std::string btaddr) { - BI info(key, base::ASCIIToUTF16(name), level, GetTestingClock(), type, + BI info(key, name, level, GetTestingClock(), type, BI::ChargeStatus::kUnknown, btaddr); if (add_first) battery_notifier_->OnAddingBattery(info); @@ -115,11 +115,11 @@ class PeripheralBatteryNotifierTest : public AshTestBase { } void RemoveBattery(const std::string key, - const std::string name, + const std::u16string name, base::Optional level, BI::PeripheralType type, const std::string btaddr) { - BI info(key, base::ASCIIToUTF16(name), level, GetTestingClock(), type, + BI info(key, name, level, GetTestingClock(), type, BI::ChargeStatus::kUnknown, btaddr); battery_notifier_->OnRemovingBattery(info); } @@ -142,7 +142,7 @@ TEST_F(PeripheralBatteryNotifierTest, Basic) { // Level 50 at time 100, no low-battery notification. ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kTestBatteryId, kTestDeviceName, 50, + UpdateBatteryLevel(true, kTestBatteryId, kTestDeviceName16, 50, BI::PeripheralType::kOther, kTestBatteryAddress); EXPECT_EQ(1u, battery_notifier_->battery_notifications_.count(kTestBatteryId)); @@ -157,7 +157,7 @@ TEST_F(PeripheralBatteryNotifierTest, Basic) { // Level 5 at time 110, low-battery notification. ClockAdvance(base::TimeDelta::FromSeconds(10)); - UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName, 5, + UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName16, 5, BI::PeripheralType::kOther, kTestBatteryAddress); EXPECT_EQ(5, info.level); @@ -171,7 +171,7 @@ TEST_F(PeripheralBatteryNotifierTest, Basic) { // Level -1 at time 115, cancel previous notification. ClockAdvance(base::TimeDelta::FromSeconds(5)); - UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName, base::nullopt, + UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName16, base::nullopt, BI::PeripheralType::kOther, kTestBatteryAddress); EXPECT_EQ(base::nullopt, info.level); EXPECT_EQ(GetTestingClock() - base::TimeDelta::FromSeconds(5), @@ -181,7 +181,7 @@ TEST_F(PeripheralBatteryNotifierTest, Basic) { // Level 50 at time 120, no low-battery notification. ClockAdvance(base::TimeDelta::FromSeconds(5)); - UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName, 50, + UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName16, 50, BI::PeripheralType::kOther, kTestBatteryAddress); EXPECT_EQ(base::nullopt, info.level); EXPECT_EQ(GetTestingClock() - base::TimeDelta::FromSeconds(10), @@ -191,7 +191,7 @@ TEST_F(PeripheralBatteryNotifierTest, Basic) { // Level 5 at time 130, no low-battery notification (throttling). ClockAdvance(base::TimeDelta::FromSeconds(10)); - UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName, 5, + UpdateBatteryLevel(false, kTestBatteryId, kTestDeviceName16, 5, BI::PeripheralType::kOther, kTestBatteryAddress); EXPECT_EQ(5, info.level); EXPECT_EQ(GetTestingClock() - base::TimeDelta::FromSeconds(20), @@ -203,7 +203,7 @@ TEST_F(PeripheralBatteryNotifierTest, Basic) { TEST_F(PeripheralBatteryNotifierTest, EarlyNotification) { // Level 15 at time 10, low-battery notification. ClockAdvance(base::TimeDelta::FromSeconds(10)); - UpdateBatteryLevel(true, kTestBatteryId, kTestDeviceName, 15, + UpdateBatteryLevel(true, kTestBatteryId, kTestDeviceName16, 15, BI::PeripheralType::kOther, kTestBatteryAddress); EXPECT_EQ(1u, battery_notifier_->battery_notifications_.count(kTestBatteryId)); @@ -223,6 +223,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotification) { const std::string kTestStylusBatteryId = "???hxxxxid-AAAA:BBBB:CCCC.DDDD-battery"; const std::string kTestStylusName = "test_stylus"; + const std::u16string kTestStylusName16 = u"test_stylus"; base::test::ScopedFeatureList flags; flags.InitAndEnableFeature(features::kStylusBatteryStatus); @@ -237,7 +238,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotification) { // Verify that when the battery level is 50, no stylus low battery // notification is shown. - UpdateBatteryLevel(true, kTestStylusBatteryId, kTestStylusName, 50, + UpdateBatteryLevel(true, kTestStylusBatteryId, kTestStylusName16, 50, BI::PeripheralType::kStylusViaScreen, ""); EXPECT_FALSE(message_center_->FindVisibleNotificationById( PeripheralBatteryNotifier::kStylusNotificationId)); @@ -245,7 +246,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotification) { // Verify that when the battery level is 5, a stylus low battery notification // is shown. Also check that a non stylus device low battery notification will // not show up. - UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName, 5, + UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName16, 5, BI::PeripheralType::kStylusViaScreen, ""); EXPECT_TRUE(message_center_->FindVisibleNotificationById( PeripheralBatteryNotifier::kStylusNotificationId)); @@ -254,7 +255,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotification) { // Verify that when the battery level is -1, the previous stylus low battery // notification is cancelled. - UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName, + UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName16, base::nullopt, BI::PeripheralType::kStylusViaScreen, ""); EXPECT_FALSE(message_center_->FindVisibleNotificationById( PeripheralBatteryNotifier::kStylusNotificationId)); @@ -266,6 +267,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotificationDisabled) { const std::string kTestStylusBatteryId = "???hxxxxid-AAAA:BBBB:CCCC.DDDD-battery"; const std::string kTestStylusName = "test_stylus"; + const std::u16string kTestStylusName16 = u"test_stylus"; base::test::ScopedFeatureList flags; flags.InitAndDisableFeature(features::kStylusBatteryStatus); @@ -280,7 +282,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotificationDisabled) { // Verify that when the battery level is 50, no stylus low battery // notification is shown. - UpdateBatteryLevel(true, kTestStylusBatteryId, kTestStylusName, 50, + UpdateBatteryLevel(true, kTestStylusBatteryId, kTestStylusName16, 50, BI::PeripheralType::kStylusViaScreen, ""); EXPECT_FALSE(message_center_->FindVisibleNotificationById( PeripheralBatteryNotifier::kStylusNotificationId)); @@ -288,7 +290,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotificationDisabled) { // Verify that when the battery level is 5, a stylus low battery notification // is shown. Also check that a non stylus device low battery notification will // not show up. - UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName, 5, + UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName16, 5, BI::PeripheralType::kStylusViaScreen, ""); EXPECT_FALSE(message_center_->FindVisibleNotificationById( PeripheralBatteryNotifier::kStylusNotificationId)); @@ -297,7 +299,7 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotificationDisabled) { // Verify that when the battery level is -1, the previous stylus low battery // notification is cancelled. - UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName, + UpdateBatteryLevel(false, kTestStylusBatteryId, kTestStylusName16, base::nullopt, BI::PeripheralType::kStylusViaScreen, ""); EXPECT_FALSE(message_center_->FindVisibleNotificationById( PeripheralBatteryNotifier::kStylusNotificationId)); @@ -305,9 +307,9 @@ TEST_F(PeripheralBatteryNotifierTest, StylusNotificationDisabled) { TEST_F(PeripheralBatteryNotifierTest, Bluetooth_CreatesANotificationForEachDevice) { - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); - UpdateBatteryLevel(true, kBluetoothDeviceId2, kBluetoothDeviceName2, 0, + UpdateBatteryLevel(true, kBluetoothDeviceId2, kBluetoothDeviceName216, 0, BI::PeripheralType::kOther, kBluetoothDeviceAddress2); // Verify 2 notifications were posted with the correct values. @@ -320,45 +322,45 @@ TEST_F(PeripheralBatteryNotifierTest, kBluetoothDeviceNotificationId2); EXPECT_TRUE(notification_1); - EXPECT_EQ(base::ASCIIToUTF16(kBluetoothDeviceName1), notification_1->title()); + EXPECT_EQ(kBluetoothDeviceName116, notification_1->title()); EXPECT_EQ(5, ExtractBatteryPercentage(notification_1)); EXPECT_TRUE(notification_2); - EXPECT_EQ(base::ASCIIToUTF16(kBluetoothDeviceName2), notification_2->title()); + EXPECT_EQ(kBluetoothDeviceName216, notification_2->title()); EXPECT_EQ(0, ExtractBatteryPercentage(notification_2)); } TEST_F(PeripheralBatteryNotifierTest, Bluetooth_RemovesNotificationForDisconnectedDevices) { - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); - UpdateBatteryLevel(true, kBluetoothDeviceId2, kBluetoothDeviceName2, 0, + UpdateBatteryLevel(true, kBluetoothDeviceId2, kBluetoothDeviceName216, 0, BI::PeripheralType::kOther, kBluetoothDeviceAddress2); // Verify 2 notifications were posted. EXPECT_EQ(2u, message_center_->NotificationCount()); // Verify only the notification for device 1 gets removed. - RemoveBattery(kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + RemoveBattery(kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_EQ(1u, message_center_->NotificationCount()); EXPECT_TRUE(message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId2)); // Remove the second notification. - RemoveBattery(kBluetoothDeviceId2, kBluetoothDeviceName2, 0, + RemoveBattery(kBluetoothDeviceId2, kBluetoothDeviceName216, 0, BI::PeripheralType::kOther, kBluetoothDeviceAddress2); EXPECT_EQ(0u, message_center_->NotificationCount()); } TEST_F(PeripheralBatteryNotifierTest, Bluetooth_CancelNotificationForInvalidBatteryLevel) { - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 1, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_TRUE(message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId1)); // The notification should get canceled. - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, base::nullopt, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_FALSE(message_center_->FindVisibleNotificationById( @@ -372,14 +374,14 @@ TEST_F(PeripheralBatteryNotifierTest, ClockAdvance(base::TimeDelta::FromSeconds(100)); // Post a notification. - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 1, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_TRUE(message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId1)); // Cancel the notification. ClockAdvance(base::TimeDelta::FromSeconds(1)); - UpdateBatteryLevel(false, kBluetoothDeviceId1, kBluetoothDeviceName1, + UpdateBatteryLevel(false, kBluetoothDeviceId1, kBluetoothDeviceName116, base::nullopt, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_FALSE(message_center_->FindVisibleNotificationById( @@ -388,7 +390,7 @@ TEST_F(PeripheralBatteryNotifierTest, // The battery level falls below the threshold after a short time period. No // notification should get posted. ClockAdvance(base::TimeDelta::FromSeconds(1)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 1, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_FALSE(message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId1)); @@ -401,14 +403,14 @@ TEST_F(PeripheralBatteryNotifierTest, ClockAdvance(base::TimeDelta::FromSeconds(100)); // Post a notification. - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 1, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_TRUE(message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId1)); // Cancel the notification. ClockAdvance(base::TimeDelta::FromSeconds(1)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, base::nullopt, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_FALSE(message_center_->FindVisibleNotificationById( @@ -416,7 +418,7 @@ TEST_F(PeripheralBatteryNotifierTest, // Post notification if we are out of the kNotificationInterval. ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 1, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 1, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_TRUE(message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId1)); @@ -428,7 +430,7 @@ TEST_F(PeripheralBatteryNotifierTest, DontRepostNotificationIfUserDismissedPreviousOne) { ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_EQ(1u, message_center_->NotificationCount()); @@ -438,7 +440,7 @@ TEST_F(PeripheralBatteryNotifierTest, // The battery level remains low, but shouldn't post a notification. ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_EQ(0u, message_center_->NotificationCount()); } @@ -448,26 +450,26 @@ TEST_F(PeripheralBatteryNotifierTest, TEST_F(PeripheralBatteryNotifierTest, UpdateNotificationIfVisible) { ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_EQ(1u, message_center_->NotificationCount()); // The battery level remains low, should update the notification. ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 3, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 3, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); message_center::Notification* notification = message_center_->FindVisibleNotificationById( kBluetoothDeviceNotificationId1); EXPECT_TRUE(notification); - EXPECT_EQ(base::ASCIIToUTF16(kBluetoothDeviceName1), notification->title()); + EXPECT_EQ(kBluetoothDeviceName116, notification->title()); EXPECT_EQ(3, ExtractBatteryPercentage(notification)); } TEST_F(PeripheralBatteryNotifierTest, OpenBluetoothSettingsUi) { ClockAdvance(base::TimeDelta::FromSeconds(100)); - UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName1, 5, + UpdateBatteryLevel(true, kBluetoothDeviceId1, kBluetoothDeviceName116, 5, BI::PeripheralType::kOther, kBluetoothDeviceAddress1); EXPECT_EQ(1u, message_center_->NotificationCount()); diff --git a/ash/system/power/peripheral_battery_tests.h b/ash/system/power/peripheral_battery_tests.h index f56e326268b313..166c110d9e85ec 100644 --- a/ash/system/power/peripheral_battery_tests.h +++ b/ash/system/power/peripheral_battery_tests.h @@ -17,6 +17,7 @@ constexpr char kTestBatteryPath[] = "/sys/class/power_supply/hid-AA:BB:CC:DD:EE:FF-battery"; constexpr char kTestBatteryAddress[] = "aa:bb:cc:dd:ee:ff"; constexpr char kTestDeviceName[] = "test device"; +constexpr char16_t kTestDeviceName16[] = u"test device"; const auto kTestBatteryStatusIn = power_manager:: PeripheralBatteryStatus_ChargeStatus_CHARGE_STATUS_DISCHARGING; const auto kTestBatteryStatusOut = @@ -37,7 +38,9 @@ constexpr char kTestOtherChargerId[] = "PCHG1"; constexpr char kBluetoothDeviceAddress1[] = "aa:bb:cc:dd:ee:ff"; constexpr char kBluetoothDeviceAddress2[] = "11:22:33:44:55:66"; constexpr char kBluetoothDeviceName1[] = "device_name_1"; +constexpr char16_t kBluetoothDeviceName116[] = u"device_name_1"; constexpr char kBluetoothDeviceName2[] = "device_name_2"; +constexpr char16_t kBluetoothDeviceName216[] = u"device_name_2"; constexpr char kBluetoothDeviceId1[] = "battery_bluetooth-aa:bb:cc:dd:ee:ff"; constexpr char kBluetoothDeviceNotificationId1[] = "battery_notification-battery_bluetooth-aa:bb:cc:dd:ee:ff"; diff --git a/base/strings/utf_string_conversions.h b/base/strings/utf_string_conversions.h index 9eb7658e5abcd0..52e9c9e8014ac9 100644 --- a/base/strings/utf_string_conversions.h +++ b/base/strings/utf_string_conversions.h @@ -74,8 +74,6 @@ std::u16string WideToUTF16(const wchar_t (&str)[N]) { return std::u16string(); } -// TODO(crbug.com/1189439): Also disallow passing string constants in tests. -#if !defined(UNIT_TEST) template std::u16string ASCIIToUTF16(const char (&str)[N]) { static_assert(N == 0, "Error: Use the u\"...\" prefix instead."); @@ -88,7 +86,6 @@ template std::u16string ASCIIToUTF16(char (&str)[N]) { return ASCIIToUTF16(StringPiece(str)); } -#endif } // namespace base diff --git a/chrome/browser/ash/accessibility/dictation_browsertest.cc b/chrome/browser/ash/accessibility/dictation_browsertest.cc index 8254b10a92cc67..00308d4be88c5a 100644 --- a/chrome/browser/ash/accessibility/dictation_browsertest.cc +++ b/chrome/browser/ash/accessibility/dictation_browsertest.cc @@ -30,8 +30,11 @@ namespace ash { namespace { const char kFirstSpeechResult[] = "help"; +const char16_t kFirstSpeechResult16[] = u"help"; const char kSecondSpeechResult[] = "help oh"; +const char16_t kSecondSpeechResult16[] = u"help oh"; const char kFinalSpeechResult[] = "hello world"; +const char16_t kFinalSpeechResult16[] = u"hello world"; const int kNoSpeechTimeoutInSeconds = 10; const int kShortNoSpeechTimeoutInSeconds = 5; const int kVeryShortNoSpeechTimeoutInSeconds = 2; @@ -252,17 +255,14 @@ IN_PROC_BROWSER_TEST_P(DictationTest, RecognitionEnds) { EXPECT_EQ(GetLastCompositionText().text, empty_composition_text_.text); SendSpeechResult(kFirstSpeechResult, false /* is_final */); - EXPECT_EQ(base::ASCIIToUTF16(kFirstSpeechResult), - GetLastCompositionText().text); + EXPECT_EQ(kFirstSpeechResult16, GetLastCompositionText().text); SendSpeechResult(kSecondSpeechResult, false /* is_final */); - EXPECT_EQ(base::ASCIIToUTF16(kSecondSpeechResult), - GetLastCompositionText().text); + EXPECT_EQ(kSecondSpeechResult16, GetLastCompositionText().text); SendSpeechResult(kFinalSpeechResult, true /* is_final */); EXPECT_EQ(1, input_context_handler_->commit_text_call_count()); - EXPECT_EQ(base::ASCIIToUTF16(kFinalSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFinalSpeechResult16, input_context_handler_->last_commit_text()); if (GetParam().first == kTestDefaultListening) { EXPECT_TRUE(IsDictationOff()); @@ -290,8 +290,7 @@ IN_PROC_BROWSER_TEST_P(DictationTest, RecognitionEndsWithChromeVoxEnabled) { SendSpeechResult(kFinalSpeechResult, true /* is_final */); EXPECT_EQ(1, input_context_handler_->commit_text_call_count()); - EXPECT_EQ(base::ASCIIToUTF16(kFinalSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFinalSpeechResult16, input_context_handler_->last_commit_text()); if (GetParam().first == kTestDefaultListening) { EXPECT_TRUE(IsDictationOff()); @@ -331,8 +330,7 @@ IN_PROC_BROWSER_TEST_P(DictationTest, RecognitionEndsWithoutFinalizedSpeech) { timer->FireNow(); EXPECT_TRUE(IsDictationOff()); EXPECT_EQ(1, input_context_handler_->commit_text_call_count()); - EXPECT_EQ(base::ASCIIToUTF16(kFirstSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFirstSpeechResult16, input_context_handler_->last_commit_text()); } IN_PROC_BROWSER_TEST_P(DictationTest, UserEndsDictationBeforeSpeech) { @@ -347,13 +345,11 @@ IN_PROC_BROWSER_TEST_P(DictationTest, UserEndsDictation) { EXPECT_EQ(GetLastCompositionText().text, empty_composition_text_.text); SendSpeechResult(kFinalSpeechResult, false /* is_final */); - EXPECT_EQ(base::ASCIIToUTF16(kFinalSpeechResult), - GetLastCompositionText().text); + EXPECT_EQ(kFinalSpeechResult16, GetLastCompositionText().text); ToggleDictation(); EXPECT_EQ(1, input_context_handler_->commit_text_call_count()); - EXPECT_EQ(base::ASCIIToUTF16(kFinalSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFinalSpeechResult16, input_context_handler_->last_commit_text()); } IN_PROC_BROWSER_TEST_P(DictationTest, UserEndsDictationWhenChromeVoxEnabled) { @@ -370,8 +366,7 @@ IN_PROC_BROWSER_TEST_P(DictationTest, UserEndsDictationWhenChromeVoxEnabled) { ToggleDictation(); EXPECT_EQ(1, input_context_handler_->commit_text_call_count()); - EXPECT_EQ(base::ASCIIToUTF16(kFinalSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFinalSpeechResult16, input_context_handler_->last_commit_text()); } IN_PROC_BROWSER_TEST_P(DictationTest, SwitchInputContext) { @@ -380,8 +375,7 @@ IN_PROC_BROWSER_TEST_P(DictationTest, SwitchInputContext) { SendSpeechResult(kFirstSpeechResult, true /* is final */); // Speech goes to the default IMEInputContextHandler. - EXPECT_EQ(base::ASCIIToUTF16(kFirstSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFirstSpeechResult16, input_context_handler_->last_commit_text()); // Simulate a remote app instantiating a new IMEInputContextHandler, like // the keyboard shortcut viewer app creating a second InputMethodChromeOS. @@ -399,10 +393,9 @@ IN_PROC_BROWSER_TEST_P(DictationTest, SwitchInputContext) { SendSpeechResult(kSecondSpeechResult, true /* is final*/); - std::u16string expected = - GetParam().first == kTestDefaultListening - ? base::ASCIIToUTF16(kSecondSpeechResult) - : u" " + base::ASCIIToUTF16(kSecondSpeechResult); + std::u16string expected = kSecondSpeechResult16; + if (GetParam().first != kTestDefaultListening) + expected = u" " + expected; // Speech goes to the new IMEInputContextHandler. EXPECT_EQ(expected, input_context_handler2.last_commit_text()); @@ -422,8 +415,7 @@ IN_PROC_BROWSER_TEST_P(DictationTest, ChangeInputField) { // Check that dictation has turned off. EXPECT_EQ(1, input_context_handler_->commit_text_call_count()); - EXPECT_EQ(base::ASCIIToUTF16(kFinalSpeechResult), - input_context_handler_->last_commit_text()); + EXPECT_EQ(kFinalSpeechResult16, input_context_handler_->last_commit_text()); } IN_PROC_BROWSER_TEST_P(DictationTest, MightListenForMultipleResults) { diff --git a/chrome/browser/ash/app_mode/app_session_unittest.cc b/chrome/browser/ash/app_mode/app_session_unittest.cc index a82437343d5d2c..d976a48f4349be 100644 --- a/chrome/browser/ash/app_mode/app_session_unittest.cc +++ b/chrome/browser/ash/app_mode/app_session_unittest.cc @@ -22,9 +22,9 @@ namespace { using ::chromeos::FakePowerManagerClient; -constexpr char kPepperPluginName1[] = "pepper_plugin_name1"; -constexpr char kPepperPluginName2[] = "pepper_plugin_name2"; -constexpr char kBrowserPluginName[] = "browser_plugin_name"; +constexpr char16_t kPepperPluginName1[] = u"pepper_plugin_name1"; +constexpr char16_t kPepperPluginName2[] = u"pepper_plugin_name2"; +constexpr char16_t kBrowserPluginName[] = u"browser_plugin_name"; constexpr char kPepperPluginFilePath1[] = "/path/to/pepper_plugin1"; constexpr char kPepperPluginFilePath2[] = "/path/to/pepper_plugin2"; constexpr char kBrowserPluginFilePath[] = "/path/to/browser_plugin"; @@ -71,19 +71,19 @@ TEST_F(AppSessionTest, WebKioskTracksBrowserCreation) { TEST_F(AppSessionTest, ShouldHandlePlugin) { // Create an out-of-process pepper plugin. content::WebPluginInfo info1; - info1.name = base::ASCIIToUTF16(kPepperPluginName1); + info1.name = kPepperPluginName1; info1.path = base::FilePath(kPepperPluginFilePath1); info1.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS; // Create an in-of-process pepper plugin. content::WebPluginInfo info2; - info2.name = base::ASCIIToUTF16(kPepperPluginName2); + info2.name = kPepperPluginName2; info2.path = base::FilePath(kPepperPluginFilePath2); info2.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; // Create an in-of-process browser (non-pepper) plugin. content::WebPluginInfo info3; - info3.name = base::ASCIIToUTF16(kBrowserPluginName); + info3.name = kBrowserPluginName; info3.path = base::FilePath(kBrowserPluginFilePath); info3.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; diff --git a/chrome/browser/ash/kerberos/kerberos_ticket_expiry_notification_test.cc b/chrome/browser/ash/kerberos/kerberos_ticket_expiry_notification_test.cc index 09db86ce879b3d..a4773e7a35bd73 100644 --- a/chrome/browser/ash/kerberos/kerberos_ticket_expiry_notification_test.cc +++ b/chrome/browser/ash/kerberos/kerberos_ticket_expiry_notification_test.cc @@ -21,6 +21,7 @@ namespace chromeos { namespace { constexpr char kUser[] = "user@EXAMPLE.COM"; +constexpr char16_t kUser16[] = u"user@EXAMPLE.COM"; constexpr char kNotificationId[] = "kerberos.ticket-expiry-notification"; @@ -69,8 +70,7 @@ TEST_F(KerberosTicketExpiryNotificationTest, ShowClose) { ASSERT_TRUE(Notification().has_value()); // Don't check the exact text here, just check if the username is there. - EXPECT_NE(std::string::npos, - Notification()->message().find(base::ASCIIToUTF16(kUser))); + EXPECT_NE(std::string::npos, Notification()->message().find(kUser16)); kerberos_ticket_expiry_notification::Close(profile_); EXPECT_FALSE(Notification().has_value()); diff --git a/chrome/browser/ash/login/profile_auth_data_unittest.cc b/chrome/browser/ash/login/profile_auth_data_unittest.cc index 9a3b412c9068eb..cf620126f160dd 100644 --- a/chrome/browser/ash/login/profile_auth_data_unittest.cc +++ b/chrome/browser/ash/login/profile_auth_data_unittest.cc @@ -47,8 +47,8 @@ namespace { const char kProxyAuthURL[] = "https://example.com/"; const char kProxyAuthRealm[] = "realm"; const char kProxyAuthChallenge[] = "challenge"; -const char kProxyAuthPassword1[] = "password 1"; -const char kProxyAuthPassword2[] = "password 2"; +const char16_t kProxyAuthPassword1[] = u"password 1"; +const char16_t kProxyAuthPassword2[] = u"password 2"; const char kGAIACookieURL[] = "https://google.com/"; const char kSAMLIdPCookieURL[] = "https://example.com/"; @@ -105,7 +105,7 @@ class ProfileAuthDataTest : public testing::Test { private: void PopulateBrowserContext(TestingProfile* browser_context, network::NetworkContext* network_context, - const std::string& proxy_auth_password, + const std::u16string& proxy_auth_password, const std::string& cookie_value); net::HttpAuthCache* GetAuthCache(network::NetworkContext* network_context); @@ -178,8 +178,7 @@ void ProfileAuthDataTest::VerifyTransferredUserProxyAuthEntry() { kProxyAuthRealm, net::HttpAuth::AUTH_SCHEME_BASIC, net::NetworkIsolationKey()); ASSERT_TRUE(entry); - EXPECT_EQ(base::ASCIIToUTF16(kProxyAuthPassword1), - entry->credentials().password()); + EXPECT_EQ(kProxyAuthPassword1, entry->credentials().password()); } void ProfileAuthDataTest::VerifyUserCookies( @@ -208,14 +207,13 @@ void ProfileAuthDataTest::VerifyUserCookies( void ProfileAuthDataTest::PopulateBrowserContext( TestingProfile* browser_context, network::NetworkContext* network_context, - const std::string& proxy_auth_password, + const std::u16string& proxy_auth_password, const std::string& cookie_value) { GetAuthCache(network_context) ->Add(GURL(kProxyAuthURL), net::HttpAuth::AUTH_PROXY, kProxyAuthRealm, net::HttpAuth::AUTH_SCHEME_BASIC, net::NetworkIsolationKey(), kProxyAuthChallenge, - net::AuthCredentials(std::u16string(), - base::ASCIIToUTF16(proxy_auth_password)), + net::AuthCredentials(std::u16string(), proxy_auth_password), std::string()); network::mojom::CookieManager* cookies = GetCookies(browser_context); diff --git a/chrome/browser/ash/notifications/request_system_proxy_credentials_view_unittest.cc b/chrome/browser/ash/notifications/request_system_proxy_credentials_view_unittest.cc index 1c110218df02f0..9721228a03c3c1 100644 --- a/chrome/browser/ash/notifications/request_system_proxy_credentials_view_unittest.cc +++ b/chrome/browser/ash/notifications/request_system_proxy_credentials_view_unittest.cc @@ -19,8 +19,8 @@ namespace { constexpr char kProxy[] = "http://localserver"; -constexpr char kUsername[] = "testuser"; -constexpr char kPassword[] = "testpwd"; +constexpr char16_t kUsername[] = u"testuser"; +constexpr char16_t kPassword[] = u"testpwd"; } // namespace namespace ash { @@ -76,17 +76,15 @@ class RequestSystemProxyCredentialsViewTest : public BrowserWithTestWindowTest { // credentials as arguments. TEST_F(RequestSystemProxyCredentialsViewTest, AcceptCallback) { CreateDialog(/*show_error=*/false); - system_proxy_dialog_->username_textfield_for_testing()->SetText( - base::ASCIIToUTF16(kUsername)); - system_proxy_dialog_->password_textfield_for_testing()->SetText( - base::ASCIIToUTF16(kPassword)); + system_proxy_dialog_->username_textfield_for_testing()->SetText(kUsername); + system_proxy_dialog_->password_textfield_for_testing()->SetText(kPassword); // Simulate pressing the "OK" button. system_proxy_dialog_->Accept(); EXPECT_TRUE(accepted_); - EXPECT_EQ(base::UTF16ToUTF8(system_proxy_dialog_->GetUsername()), kUsername); - EXPECT_EQ(base::UTF16ToUTF8(system_proxy_dialog_->GetPassword()), kPassword); + EXPECT_EQ(system_proxy_dialog_->GetUsername(), kUsername); + EXPECT_EQ(system_proxy_dialog_->GetPassword(), kPassword); } TEST_F(RequestSystemProxyCredentialsViewTest, CancelCallback) { diff --git a/chrome/browser/ash/notifications/update_required_notification_unittest.cc b/chrome/browser/ash/notifications/update_required_notification_unittest.cc index 1ba14a86050e69..6a30ee34fff193 100644 --- a/chrome/browser/ash/notifications/update_required_notification_unittest.cc +++ b/chrome/browser/ash/notifications/update_required_notification_unittest.cc @@ -221,9 +221,10 @@ TEST_F(UpdateRequiredNotificationTest, NoNetworkNotifications) { // Check notification is shown for offline devices with the warning time. std::u16string expected_title = u"Update Chrome device within 10 days"; - std::u16string expected_message = base::ASCIIToUTF16( - "managed.com requires you to download an update before the deadline. The " - "update will download automatically when you connect to the internet."); + std::u16string expected_message = + u"managed.com requires you to download an update before the deadline. " + u"The update will download automatically when you connect to the " + u"internet."; VerifyUpdateRequiredNotification(expected_title, expected_message); // Expire the notification timer to show new notification on the last day. @@ -231,9 +232,9 @@ TEST_F(UpdateRequiredNotificationTest, NoNetworkNotifications) { base::TimeDelta::FromDays(kLongWarningInDays - 1); task_environment_.FastForwardBy(warning); std::u16string expected_title_last_day = u"Last day to update Chrome device"; - std::u16string expected_message_last_day = base::ASCIIToUTF16( - "managed.com requires you to download an update today. The " - "update will download automatically when you connect to the internet."); + std::u16string expected_message_last_day = + u"managed.com requires you to download an update today. The " + u"update will download automatically when you connect to the internet."; VerifyUpdateRequiredNotification(expected_title_last_day, expected_message_last_day); } @@ -264,10 +265,10 @@ TEST_F(UpdateRequiredNotificationTest, MeteredNetworkNotifications) { // Check notification is shown for metered network with the warning time. std::u16string expected_title = u"Update Chrome device within 10 days"; - std::u16string expected_message = base::ASCIIToUTF16( - "managed.com requires you to connect to Wi-Fi and download an update " - "before the deadline. Or, download from a metered connection (charges " - "may apply)."); + std::u16string expected_message = + u"managed.com requires you to connect to Wi-Fi and download an update " + u"before the deadline. Or, download from a metered connection (charges " + u"may apply)."; VerifyUpdateRequiredNotification(expected_title, expected_message); // Expire the notification timer to show new notification on the last day. @@ -275,9 +276,9 @@ TEST_F(UpdateRequiredNotificationTest, MeteredNetworkNotifications) { base::TimeDelta::FromDays(kLongWarningInDays - 1); task_environment_.FastForwardBy(warning); std::u16string expected_title_last_day = u"Last day to update Chrome device"; - std::u16string expected_message_last_day = base::ASCIIToUTF16( - "managed.com requires you to connect to Wi-Fi today to download an " - "update. Or, download from a metered connection (charges may apply)."); + std::u16string expected_message_last_day = + u"managed.com requires you to connect to Wi-Fi today to download an " + u"update. Or, download from a metered connection (charges may apply)."; VerifyUpdateRequiredNotification(expected_title_last_day, expected_message_last_day); } @@ -302,9 +303,9 @@ TEST_F(UpdateRequiredNotificationTest, EolNotifications) { // Check notification is shown for end of life with the warning time. std::u16string expected_title = u"Return Chrome device within 10 days"; - std::u16string expected_message = base::ASCIIToUTF16( - "managed.com requires you to back up your data and return this Chrome " - "device before the deadline."); + std::u16string expected_message = + u"managed.com requires you to back up your data and return this Chrome " + u"device before the deadline."; VerifyUpdateRequiredNotification(expected_title, expected_message); // Expire notification timer to show new notification a week before deadline. @@ -319,9 +320,9 @@ TEST_F(UpdateRequiredNotificationTest, EolNotifications) { const base::TimeDelta warning_last_day = base::TimeDelta::FromDays(6); task_environment_.FastForwardBy(warning_last_day); std::u16string expected_title_last_day = u"Immediate return required"; - std::u16string expected_message_last_day = base::ASCIIToUTF16( - "managed.com requires you to back up your data and return this Chrome " - "device today."); + std::u16string expected_message_last_day = + u"managed.com requires you to back up your data and return this Chrome " + u"device today."; VerifyUpdateRequiredNotification(expected_title_last_day, expected_message_last_day); } @@ -355,9 +356,9 @@ TEST_F(UpdateRequiredNotificationTest, LastHourEolNotifications) { GetMinimumVersionPolicyHandler()->IsDeadlineTimerRunningForTesting()); std::u16string expected_title_last_day = u"Immediate return required"; - std::u16string expected_message_last_day = base::ASCIIToUTF16( - "managed.com requires you to back up your data and return this Chrome " - "device today."); + std::u16string expected_message_last_day = + u"managed.com requires you to back up your data and return this Chrome " + u"device today."; VerifyUpdateRequiredNotification(expected_title_last_day, expected_message_last_day); } @@ -385,9 +386,9 @@ TEST_F(UpdateRequiredNotificationTest, ChromeboxNotifications) { // Check Chromebox notification is shown for end of life with the warning // time. std::u16string expected_title = u"Return Chromebox within 10 days"; - std::u16string expected_message = base::ASCIIToUTF16( - "managed.com requires you to back up your data and return this Chromebox " - "before the deadline."); + std::u16string expected_message = + u"managed.com requires you to back up your data and return this " + u"Chromebox before the deadline."; VerifyUpdateRequiredNotification(expected_title, expected_message); // Expire notification timer to show new notification a week before deadline. diff --git a/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc b/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc index 4ac3095f44738c..2e2cf96a0e1891 100644 --- a/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc +++ b/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc @@ -38,7 +38,6 @@ using autofill::AccessoryAction; using autofill::AccessorySheetData; using autofill::AccessoryTabType; using autofill::mojom::FocusedFieldType; -using base::ASCIIToUTF16; using testing::_; using testing::AnyNumber; using testing::AtLeast; @@ -51,9 +50,8 @@ using FillingSource = ManualFillingController::FillingSource; using IsFillingSourceAvailable = AccessoryController::IsFillingSourceAvailable; AccessorySheetData empty_passwords_sheet() { - constexpr char kTitle[] = "Example title"; - return AccessorySheetData(AccessoryTabType::PASSWORDS, - base::ASCIIToUTF16(kTitle)); + constexpr char16_t kTitle[] = u"Example title"; + return AccessorySheetData(AccessoryTabType::PASSWORDS, kTitle); } AccessorySheetData filled_passwords_sheet() { @@ -65,10 +63,8 @@ AccessorySheetData filled_passwords_sheet() { } AccessorySheetData populate_sheet(AccessoryTabType type) { - constexpr char kTitle[] = "Suggestions available!"; - return AccessorySheetData::Builder(type, base::ASCIIToUTF16(kTitle)) - .AddUserInfo() - .Build(); + constexpr char16_t kTitle[] = u"Suggestions available!"; + return AccessorySheetData::Builder(type, kTitle).AddUserInfo().Build(); } constexpr autofill::FieldRendererId kFocusedFieldId(123); @@ -435,8 +431,8 @@ TEST_F(ManualFillingControllerLegacyTest, OnAutomaticGenerationStatusChanged) { TEST_F(ManualFillingControllerLegacyTest, OnFillingTriggeredFillsAndClosesSheet) { - const char kTextToFill[] = "TextToFill"; - const std::u16string text_to_fill(base::ASCIIToUTF16(kTextToFill)); + const char16_t kTextToFill[] = u"TextToFill"; + const std::u16string text_to_fill(kTextToFill); const autofill::UserInfo::Field field(text_to_fill, text_to_fill, false, true); diff --git a/chrome/browser/chromeos/crostini/crostini_package_service_unittest.cc b/chrome/browser/chromeos/crostini/crostini_package_service_unittest.cc index 7d8f86fed5dfcd..6f79c7173c50ed 100644 --- a/chrome/browser/chromeos/crostini/crostini_package_service_unittest.cc +++ b/chrome/browser/chromeos/crostini/crostini_package_service_unittest.cc @@ -70,22 +70,31 @@ using ::vm_tools::seneschal::SharePathResponse; // These are on the default VM / default container. constexpr char kDefaultAppFileId[] = "default_file_id"; constexpr char kDefaultAppName[] = "The Default"; +constexpr char16_t kDefaultAppName16[] = u"The Default"; constexpr char kSecondAppFileId[] = "second_file_id"; constexpr char kSecondAppName[] = "Another Fine App"; +constexpr char16_t kSecondAppName16[] = u"Another Fine App"; constexpr char kThirdAppFileId[] = "third_file_id"; constexpr char kThirdAppName[] = "Yet Another App"; +constexpr char16_t kThirdAppName16[] = u"Yet Another App"; // Different VM name, but container name is the default. constexpr char kDifferentVmAppFileId[] = "different_vm_app"; constexpr char kDifferentVmAppName[] = "I'm in a VM!"; +constexpr char16_t kDifferentVmAppName16[] = u"I'm in a VM!"; constexpr char kDifferentVmApp2FileId[] = "different_vm_app_2"; constexpr char kDifferentVmApp2Name[] = "I'm in a VM also"; +constexpr char16_t kDifferentVmApp2Name16[] = u"I'm in a VM also"; constexpr char kDifferentVmVmName[] = "second_vm_name"; // Default VM name, but container name is different. constexpr char kDifferentContainerAppFileId[] = "different_container_app"; constexpr char kDifferentContainerAppName[] = "Just Over The Container Boundary"; +constexpr char16_t kDifferentContainerAppName16[] = + u"Just Over The Container Boundary"; constexpr char kDifferentContainerApp2FileId[] = "different_container_app_2"; constexpr char kDifferentContainerApp2Name[] = "Severe Lack of Containers"; +constexpr char16_t kDifferentContainerApp2Name16[] = + u"Severe Lack of Containers"; constexpr char kDifferentContainerContainerName[] = "second_container_name"; constexpr char kPackageFilePath[] = "/tmp/nethack.deb"; constexpr char kPackageFileContainerPath[] = @@ -435,19 +444,19 @@ enum KnownApp { std::u16string GetAppName(KnownApp app) { switch (app) { case DEFAULT_APP: - return base::ASCIIToUTF16(kDefaultAppName); + return kDefaultAppName16; case SECOND_APP: - return base::ASCIIToUTF16(kSecondAppName); + return kSecondAppName16; case THIRD_APP: - return base::ASCIIToUTF16(kThirdAppName); + return kThirdAppName16; case DIFFERENT_VM: - return base::ASCIIToUTF16(kDifferentVmAppName); + return kDifferentVmAppName16; case DIFFERENT_VM_2: - return base::ASCIIToUTF16(kDifferentVmApp2Name); + return kDifferentVmApp2Name16; case DIFFERENT_CONTAINER: - return base::ASCIIToUTF16(kDifferentContainerAppName); + return kDifferentContainerAppName16; case DIFFERENT_CONTAINER_2: - return base::ASCIIToUTF16(kDifferentContainerApp2Name); + return kDifferentContainerApp2Name16; default: NOTREACHED(); } diff --git a/chrome/browser/chromeos/eol_notification_unittest.cc b/chrome/browser/chromeos/eol_notification_unittest.cc index 42204538fb58d1..8421acdd44eba8 100644 --- a/chrome/browser/chromeos/eol_notification_unittest.cc +++ b/chrome/browser/chromeos/eol_notification_unittest.cc @@ -101,9 +101,9 @@ TEST_F(EolNotificationTest, TestFirstWarningNotification) { ASSERT_TRUE(notification); std::u16string expected_title = u"Updates end December 2019"; - std::u16string expected_message = base::ASCIIToUTF16( - "You'll still be able to use this Chrome device after that time, but it " - "will no longer get automatic software and security updates"); + std::u16string expected_message = + u"You'll still be able to use this Chrome device after that time, but it " + u"will no longer get automatic software and security updates"; EXPECT_EQ(notification->title(), expected_title); EXPECT_EQ(notification->message(), expected_message); @@ -124,9 +124,9 @@ TEST_F(EolNotificationTest, TestSecondWarningNotification) { ASSERT_TRUE(notification); std::u16string expected_title = u"Updates end December 2019"; - std::u16string expected_message = base::ASCIIToUTF16( - "You'll still be able to use this Chrome device after that time, but it " - "will no longer get automatic software and security updates"); + std::u16string expected_message = + u"You'll still be able to use this Chrome device after that time, but it " + u"will no longer get automatic software and security updates"; EXPECT_EQ(notification->title(), expected_title); EXPECT_EQ(notification->message(), expected_message); @@ -152,9 +152,9 @@ TEST_F(EolNotificationTest, TestFinalEolNotification) { ASSERT_TRUE(notification); std::u16string expected_title = u"Final software update"; - std::u16string expected_message = base::ASCIIToUTF16( - "This is the last automatic software and security update for this Chrome " - "device. To get future updates, upgrade to a newer model."); + std::u16string expected_message = + u"This is the last automatic software and security update for this " + u"Chrome device. To get future updates, upgrade to a newer model."; EXPECT_EQ(notification->title(), expected_title); EXPECT_EQ(notification->message(), expected_message); @@ -254,9 +254,9 @@ TEST_F(EolNotificationTest, TestNotificationUpdatesProperlyWithoutDismissal) { ASSERT_TRUE(notification); std::u16string expected_title = u"Updates end December 2019"; - std::u16string expected_message = base::ASCIIToUTF16( - "You'll still be able to use this Chrome device after that time, but it " - "will no longer get automatic software and security updates"); + std::u16string expected_message = + u"You'll still be able to use this Chrome device after that time, but it " + u"will no longer get automatic software and security updates"; EXPECT_EQ(notification->title(), expected_title); EXPECT_EQ(notification->message(), expected_message); @@ -266,9 +266,9 @@ TEST_F(EolNotificationTest, TestNotificationUpdatesProperlyWithoutDismissal) { notification = tester_->GetNotification("chrome://product_eol"); ASSERT_TRUE(notification); expected_title = u"Final software update"; - expected_message = base::ASCIIToUTF16( - "This is the last automatic software and security update for this Chrome " - "device. To get future updates, upgrade to a newer model."); + expected_message = + u"This is the last automatic software and security update for this " + u"Chrome device. To get future updates, upgrade to a newer model."; EXPECT_EQ(notification->title(), expected_title); EXPECT_EQ(notification->message(), expected_message); diff --git a/chrome/browser/chromeos/net/system_proxy_manager_browsertest.cc b/chrome/browser/chromeos/net/system_proxy_manager_browsertest.cc index 200b8da5a58d16..3e98d68fe0fcfd 100644 --- a/chrome/browser/chromeos/net/system_proxy_manager_browsertest.cc +++ b/chrome/browser/chromeos/net/system_proxy_manager_browsertest.cc @@ -75,7 +75,9 @@ constexpr char kScheme[] = "dIgEsT"; constexpr char kProxyAuthUrl[] = "http://example.com:3128"; constexpr char kSystemProxyNotificationId[] = "system-proxy.auth_required"; constexpr char kUsername[] = "testuser"; +constexpr char16_t kUsername16[] = u"testuser"; constexpr char kPassword[] = "testpwd"; +constexpr char16_t kPassword16[] = u"testpwd"; constexpr char kUserProfilePath[] = "user_profile"; constexpr char kDefaultServicePath[] = "default_wifi"; @@ -241,10 +243,8 @@ IN_PROC_BROWSER_TEST_F(SystemProxyManagerBrowserTest, AuthenticationDialog) { // Expect warning is not shown. ASSERT_FALSE(dialog()->error_label_for_testing()->GetVisible()); - dialog()->username_textfield_for_testing()->SetText( - base::ASCIIToUTF16(kUsername)); - dialog()->password_textfield_for_testing()->SetText( - base::ASCIIToUTF16(kPassword)); + dialog()->username_textfield_for_testing()->SetText(kUsername16); + dialog()->password_textfield_for_testing()->SetText(kPassword16); // Simulate clicking on "OK" button. dialog()->Accept(); @@ -288,10 +288,8 @@ IN_PROC_BROWSER_TEST_F(SystemProxyManagerBrowserTest, // Expect warning is not shown. ASSERT_FALSE(dialog()->error_label_for_testing()->GetVisible()); - dialog()->username_textfield_for_testing()->SetText( - base::ASCIIToUTF16(kUsername)); - dialog()->password_textfield_for_testing()->SetText( - base::ASCIIToUTF16(kPassword)); + dialog()->username_textfield_for_testing()->SetText(kUsername16); + dialog()->password_textfield_for_testing()->SetText(kPassword16); base::RunLoop run_loop; GetSystemProxyManager()->SetSendAuthDetailsClosureForTest( @@ -622,7 +620,9 @@ IN_PROC_BROWSER_TEST_F(SystemProxyManagerPolicyCredentialsBrowserTest, namespace { constexpr char kProxyUsername[] = "foo"; +constexpr char16_t kProxyUsername16[] = u"foo"; constexpr char kProxyPassword[] = "bar"; +constexpr char16_t kProxyPassword16[] = u"bar"; constexpr char kBadUsername[] = "bad-username"; constexpr char kBadPassword[] = "bad-pwd"; constexpr char kOriginHostname[] = "a.test"; @@ -678,8 +678,8 @@ class SystemProxyCredentialsReuseBrowserTest // Navigates to the test page "/simple.html" and authenticates in the proxy // login dialog with `username` and `password`. - void LoginWithDialog(const std::string& username, - const std::string& password) { + void LoginWithDialog(const std::u16string& username, + const std::u16string& password) { LoginPromptBrowserTestObserver login_observer; login_observer.Register(content::Source( &GetWebContents()->GetController())); @@ -689,8 +689,7 @@ class SystemProxyCredentialsReuseBrowserTest WindowedAuthSuppliedObserver auth_supplied( &GetWebContents()->GetController()); LoginHandler* login_handler = login_observer.handlers().front(); - login_handler->SetAuth(base::ASCIIToUTF16(username), - base::ASCIIToUTF16(password)); + login_handler->SetAuth(username, password); auth_supplied.Wait(); EXPECT_EQ(1, login_observer.auth_supplied_count()); } @@ -737,7 +736,7 @@ class SystemProxyCredentialsReuseBrowserTest IN_PROC_BROWSER_TEST_F(SystemProxyCredentialsReuseBrowserTest, RegularUser) { SetManagedProxy(); SetPolicyCredentials(kProxyUsername, kProxyPassword); - LoginWithDialog(kProxyUsername, kProxyPassword); + LoginWithDialog(kProxyUsername16, kProxyPassword16); CheckEntryInHttpAuthCache("Basic", kProxyUsername, kProxyPassword); } @@ -762,7 +761,7 @@ IN_PROC_BROWSER_TEST_F(SystemProxyCredentialsReuseBrowserTest, LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT_MANAGED); SetPolicyCredentials(kBadUsername, kBadPassword); - LoginWithDialog(kProxyUsername, kProxyPassword); + LoginWithDialog(kProxyUsername16, kProxyPassword16); CheckEntryInHttpAuthCache("Basic", kProxyUsername, kProxyPassword); } @@ -775,7 +774,7 @@ IN_PROC_BROWSER_TEST_F(SystemProxyCredentialsReuseBrowserTest, LoginState::LOGGED_IN_ACTIVE, LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT_MANAGED); SetPolicyCredentials(kProxyUsername, kProxyPassword, R"("ntlm","digest")"); - LoginWithDialog(kProxyUsername, kProxyPassword); + LoginWithDialog(kProxyUsername16, kProxyPassword16); CheckEntryInHttpAuthCache("Basic", kProxyUsername, kProxyPassword); } diff --git a/chrome/browser/chromeos/net/system_proxy_manager_unittest.cc b/chrome/browser/chromeos/net/system_proxy_manager_unittest.cc index 996af5ff2710a1..2e119c2cbf61f6 100644 --- a/chrome/browser/chromeos/net/system_proxy_manager_unittest.cc +++ b/chrome/browser/chromeos/net/system_proxy_manager_unittest.cc @@ -46,7 +46,9 @@ using testing::WithArg; namespace { constexpr char kBrowserUsername[] = "browser_username"; +constexpr char16_t kBrowserUsername16[] = u"browser_username"; constexpr char kBrowserPassword[] = "browser_password"; +constexpr char16_t kBrowserPassword16[] = u"browser_password"; constexpr char kPolicyUsername[] = "policy_username"; constexpr char kPolicyPassword[] = "policy_password"; constexpr char kKerberosActivePrincipalName[] = "kerberos_princ_name"; @@ -247,8 +249,7 @@ TEST_F(SystemProxyManagerTest, UserCredentialsRequestedFromNetworkService) { ->Add(GURL(kProxyAuthEmptyPath), net::HttpAuth::AUTH_PROXY, kRealm, net::HttpAuth::AUTH_SCHEME_DIGEST, net::NetworkIsolationKey(), kProxyAuthChallenge, - net::AuthCredentials(base::ASCIIToUTF16(kBrowserUsername), - base::ASCIIToUTF16(kBrowserPassword)), + net::AuthCredentials(kBrowserUsername16, kBrowserPassword16), std::string() /* path */); system_proxy::ProtectionSpace protection_space; diff --git a/chrome/browser/password_check/android/password_check_manager_unittest.cc b/chrome/browser/password_check/android/password_check_manager_unittest.cc index 2ab754a1f886e7..8b70376bd4bd5b 100644 --- a/chrome/browser/password_check/android/password_check_manager_unittest.cc +++ b/chrome/browser/password_check/android/password_check_manager_unittest.cc @@ -64,10 +64,10 @@ constexpr char kExampleCom[] = "https://example.com"; constexpr char kExampleOrg[] = "http://www.example.org"; constexpr char kExampleApp[] = "com.example.app"; -constexpr char kUsername1[] = "alice"; -constexpr char kUsername2[] = "bob"; +constexpr char16_t kUsername1[] = u"alice"; +constexpr char16_t kUsername2[] = u"bob"; -constexpr char kPassword1[] = "s3cre3t"; +constexpr char16_t kPassword1[] = u"s3cre3t"; constexpr char kTestEmail[] = "user@gmail.com"; @@ -135,15 +135,15 @@ syncer::TestSyncService* CreateAndUseSyncService(Profile* profile) { } PasswordForm MakeSavedPassword(base::StringPiece signon_realm, - base::StringPiece username, - base::StringPiece password = kPassword1, - base::StringPiece username_element = "") { + base::StringPiece16 username, + base::StringPiece16 password = kPassword1, + base::StringPiece16 username_element = u"") { PasswordForm form; form.signon_realm = std::string(signon_realm); form.url = GURL(signon_realm); - form.username_value = base::ASCIIToUTF16(username); - form.password_value = base::ASCIIToUTF16(password); - form.username_element = base::ASCIIToUTF16(username_element); + form.username_value = std::u16string(username); + form.password_value = std::u16string(password); + form.username_element = std::u16string(username_element); return form; } @@ -152,12 +152,12 @@ std::string MakeAndroidRealm(base::StringPiece package_name) { } PasswordForm MakeSavedAndroidPassword( base::StringPiece package_name, - base::StringPiece username, + base::StringPiece16 username, base::StringPiece app_display_name = "", base::StringPiece affiliated_web_realm = "") { PasswordForm form; form.signon_realm = MakeAndroidRealm(package_name); - form.username_value = base::ASCIIToUTF16(username); + form.username_value = std::u16string(username); form.app_display_name = std::string(app_display_name); form.affiliated_web_realm = std::string(affiliated_web_realm); return form; @@ -165,11 +165,10 @@ PasswordForm MakeSavedAndroidPassword( InsecureCredential MakeInsecureCredential( base::StringPiece signon_realm, - base::StringPiece username, + base::StringPiece16 username, base::TimeDelta time_since_creation = base::TimeDelta(), InsecureType compromise_type = InsecureType::kLeaked) { - return InsecureCredential(std::string(signon_realm), - base::ASCIIToUTF16(username), + return InsecureCredential(std::string(signon_realm), std::u16string(username), base::Time::Now() - time_since_creation, compromise_type, password_manager::IsMuted(false)); } @@ -345,14 +344,13 @@ TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForSiteCredential) { store().AddInsecureCredential( MakeInsecureCredential(kExampleCom, kUsername1)); RunUntilIdle(); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername1), u"example.com", GURL(kExampleCom), - base::nullopt, "https://example.com/.well-known/change-password", - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/false, - /*has_auto_change_button=*/false))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredentialForUI( + kUsername1, u"example.com", GURL(kExampleCom), base::nullopt, + "https://example.com/.well-known/change-password", + InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/false, + /*has_auto_change_button=*/false))); } TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForAppCredentials) { @@ -369,20 +367,20 @@ TEST_F(PasswordCheckManagerTest, CorrectlyCreatesUIStructForAppCredentials) { RunUntilIdle(); - EXPECT_THAT(manager().GetCompromisedCredentials(), - UnorderedElementsAre( - ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername1), u"App (com.example.app)", - GURL::EmptyGURL(), "com.example.app", base::nullopt, - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/false, - /*has_auto_change_button=*/false), - ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername2), u"Example App", - GURL(kExampleCom), "com.example.app", base::nullopt, - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/false, - /*has_auto_change_button=*/false))); + EXPECT_THAT( + manager().GetCompromisedCredentials(), + UnorderedElementsAre( + ExpectCompromisedCredentialForUI( + kUsername1, u"App (com.example.app)", GURL::EmptyGURL(), + "com.example.app", base::nullopt, + InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/false, + /*has_auto_change_button=*/false), + ExpectCompromisedCredentialForUI( + kUsername2, u"Example App", GURL(kExampleCom), "com.example.app", + base::nullopt, InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/false, + /*has_auto_change_button=*/false))); } TEST_F(PasswordCheckManagerTest, SetsTimestampOnSuccessfulCheck) { @@ -434,14 +432,13 @@ TEST_F(PasswordCheckManagerTest, manager().RefreshScripts(); EXPECT_CALL(fetcher(), IsScriptAvailable).Times(0); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername1), u"example.com", GURL(kExampleCom), - base::nullopt, "https://example.com/.well-known/change-password", - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/false, - /*has_auto_change_button=*/false))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredentialForUI( + kUsername1, u"example.com", GURL(kExampleCom), base::nullopt, + "https://example.com/.well-known/change-password", + InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/false, + /*has_auto_change_button=*/false))); } TEST_F(PasswordCheckManagerTest, @@ -465,14 +462,13 @@ TEST_F(PasswordCheckManagerTest, manager().RefreshScripts(); EXPECT_CALL(fetcher(), IsScriptAvailable).WillOnce(Return(true)); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername1), u"example.com", GURL(kExampleCom), - base::nullopt, "https://example.com/.well-known/change-password", - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/true, - /*has_auto_change_button=*/true))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredentialForUI( + kUsername1, u"example.com", GURL(kExampleCom), base::nullopt, + "https://example.com/.well-known/change-password", + InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/true, + /*has_auto_change_button=*/true))); } TEST_F(PasswordCheckManagerTest, @@ -484,8 +480,8 @@ TEST_F(PasswordCheckManagerTest, {password_manager::features::kPasswordScriptsFetching, password_manager::features::kPasswordChangeInSettings}, {}); - store().AddLogin(MakeSavedPassword(kExampleCom, "")); - store().AddInsecureCredential(MakeInsecureCredential(kExampleCom, "")); + store().AddLogin(MakeSavedPassword(kExampleCom, u"")); + store().AddInsecureCredential(MakeInsecureCredential(kExampleCom, u"")); RunUntilIdle(); EXPECT_CALL(fetcher(), RefreshScriptsIfNecessary) @@ -531,14 +527,13 @@ TEST_F(PasswordCheckManagerTest, // A script is available but an auto change button is not shown because // |kPasswordChangeInSettings| is disabled. EXPECT_CALL(fetcher(), IsScriptAvailable).WillOnce(Return(true)); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername1), u"example.com", GURL(kExampleCom), - base::nullopt, "https://example.com/.well-known/change-password", - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/true, - /*has_auto_change_button=*/false))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredentialForUI( + kUsername1, u"example.com", GURL(kExampleCom), base::nullopt, + "https://example.com/.well-known/change-password", + InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/true, + /*has_auto_change_button=*/false))); } TEST_F(PasswordCheckManagerTest, @@ -563,14 +558,13 @@ TEST_F(PasswordCheckManagerTest, // A script is not available and therefore no auto change button is shown. EXPECT_CALL(fetcher(), IsScriptAvailable).WillOnce(Return(false)); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredentialForUI( - base::ASCIIToUTF16(kUsername1), u"example.com", GURL(kExampleCom), - base::nullopt, "https://example.com/.well-known/change-password", - InsecureCredentialTypeFlags::kCredentialLeaked, - /*has_startable_script=*/false, - /*has_auto_change_button=*/false))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredentialForUI( + kUsername1, u"example.com", GURL(kExampleCom), base::nullopt, + "https://example.com/.well-known/change-password", + InsecureCredentialTypeFlags::kCredentialLeaked, + /*has_startable_script=*/false, + /*has_auto_change_button=*/false))); } TEST_F(PasswordCheckManagerTest, UpdatesProgressCorrectly) { @@ -589,8 +583,7 @@ TEST_F(PasswordCheckManagerTest, UpdatesProgressCorrectly) { EXPECT_CALL(mock_observer(), OnPasswordCheckProgressChanged(2, 1)); static_cast(service()) ->OnFinishedCredential( - password_manager::LeakCheckCredential(base::ASCIIToUTF16(kUsername1), - base::ASCIIToUTF16(kPassword1)), + password_manager::LeakCheckCredential(kUsername1, kPassword1), password_manager::IsLeaked(false)); } @@ -604,8 +597,7 @@ TEST_F(PasswordCheckManagerTest, DoesntUpdateNonExistingProgress) { EXPECT_CALL(mock_observer(), OnPasswordCheckProgressChanged).Times(0); static_cast(service()) ->OnFinishedCredential( - password_manager::LeakCheckCredential(base::ASCIIToUTF16(kUsername1), - base::ASCIIToUTF16(kPassword1)), + password_manager::LeakCheckCredential(kUsername1, kPassword1), password_manager::IsLeaked(false)); } diff --git a/chrome/browser/password_manager/android/all_passwords_bottom_sheet_controller_unittest.cc b/chrome/browser/password_manager/android/all_passwords_bottom_sheet_controller_unittest.cc index ce5011202f2e7f..3e20bf60e53a20 100644 --- a/chrome/browser/password_manager/android/all_passwords_bottom_sheet_controller_unittest.cc +++ b/chrome/browser/password_manager/android/all_passwords_bottom_sheet_controller_unittest.cc @@ -41,10 +41,10 @@ constexpr char kExampleCom[] = "https://example.com"; constexpr char kExampleOrg[] = "http://www.example.org"; constexpr char kExampleDe[] = "https://www.example.de"; -constexpr char kUsername1[] = "alice"; -constexpr char kUsername2[] = "bob"; +constexpr char16_t kUsername1[] = u"alice"; +constexpr char16_t kUsername2[] = u"bob"; -constexpr char kPassword[] = "password123"; +constexpr char16_t kPassword[] = u"password123"; class MockPasswordManagerDriver : public password_manager::StubPasswordManagerDriver { @@ -70,21 +70,20 @@ class MockPasswordManagerClient MOCK_METHOD(void, OnPasswordSelected, (const std::u16string&), (override)); }; -UiCredential MakeUiCredential(const std::string& username, - const std::string& password) { - return UiCredential(base::UTF8ToUTF16(username), base::UTF8ToUTF16(password), - url::Origin::Create(GURL(kExampleCom)), - IsPublicSuffixMatch(false), - IsAffiliationBasedMatch(false), base::Time()); +UiCredential MakeUiCredential(const std::u16string& username, + const std::u16string& password) { + return UiCredential( + username, password, url::Origin::Create(GURL(kExampleCom)), + IsPublicSuffixMatch(false), IsAffiliationBasedMatch(false), base::Time()); } PasswordForm MakeSavedPassword(const std::string& signon_realm, - const std::string& username) { + const std::u16string& username) { PasswordForm form; form.signon_realm = signon_realm; form.url = GURL(signon_realm); - form.username_value = base::ASCIIToUTF16(username); - form.password_value = base::ASCIIToUTF16(kPassword); + form.username_value = username; + form.password_value = kPassword; form.in_store = PasswordForm::Store::kProfileStore; return form; } @@ -175,11 +174,9 @@ TEST_F(AllPasswordsBottomSheetControllerTest, Show) { TEST_F(AllPasswordsBottomSheetControllerTest, OnCredentialSelected) { UiCredential credential = MakeUiCredential(kUsername1, kPassword); - EXPECT_CALL(driver(), - FillIntoFocusedField(true, base::ASCIIToUTF16(kPassword))); + EXPECT_CALL(driver(), FillIntoFocusedField(true, std::u16string(kPassword))); - all_passwords_controller()->OnCredentialSelected( - base::UTF8ToUTF16(kUsername1), base::UTF8ToUTF16(kPassword)); + all_passwords_controller()->OnCredentialSelected(kUsername1, kPassword); } TEST_F(AllPasswordsBottomSheetControllerTest, OnDismiss) { @@ -189,10 +186,9 @@ TEST_F(AllPasswordsBottomSheetControllerTest, OnDismiss) { TEST_F(AllPasswordsBottomSheetControllerTest, OnCredentialSelectedTriggersPhishGuard) { - EXPECT_CALL(client(), OnPasswordSelected(base::UTF8ToUTF16(kPassword))); + EXPECT_CALL(client(), OnPasswordSelected(std::u16string(kPassword))); - all_passwords_controller()->OnCredentialSelected( - base::UTF8ToUTF16(kUsername1), base::UTF8ToUTF16(kPassword)); + all_passwords_controller()->OnCredentialSelected(kUsername1, kPassword); } TEST_F(AllPasswordsBottomSheetControllerTest, @@ -200,6 +196,5 @@ TEST_F(AllPasswordsBottomSheetControllerTest, createAllPasswordsController(FocusedFieldType::kFillableUsernameField); EXPECT_CALL(client(), OnPasswordSelected).Times(0); - all_passwords_controller()->OnCredentialSelected( - base::UTF8ToUTF16(kUsername1), base::UTF8ToUTF16(kPassword)); + all_passwords_controller()->OnCredentialSelected(kUsername1, kPassword); } diff --git a/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper_unittest.cc b/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper_unittest.cc index b48a7a0cedff58..8b3b4946c1d067 100644 --- a/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper_unittest.cc +++ b/chrome/browser/password_manager/android/all_passwords_bottom_sheet_helper_unittest.cc @@ -18,18 +18,18 @@ using password_manager::PasswordForm; using password_manager::TestPasswordStore; constexpr char kExampleCom[] = "https://example.com"; -constexpr char kUsername[] = "alice"; -constexpr char kPassword[] = "password123"; +constexpr char16_t kUsername[] = u"alice"; +constexpr char16_t kPassword[] = u"password123"; namespace { PasswordForm MakeSavedPassword(base::StringPiece signon_realm, - base::StringPiece username) { + base::StringPiece16 username) { PasswordForm form; form.signon_realm = std::string(signon_realm); form.url = GURL(signon_realm); - form.username_value = base::ASCIIToUTF16(username); - form.password_value = base::ASCIIToUTF16(kPassword); + form.username_value = std::u16string(username); + form.password_value = kPassword; form.in_store = PasswordForm::Store::kProfileStore; return form; } diff --git a/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc b/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc index 182150174fd3e1..76ab6fc61d5fa2 100644 --- a/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc +++ b/chrome/browser/password_manager/android/password_accessory_controller_impl_unittest.cc @@ -55,7 +55,6 @@ using autofill::AccessoryTabType; using autofill::FooterCommand; using autofill::UserInfo; using autofill::mojom::FocusedFieldType; -using base::ASCIIToUTF16; using password_manager::CreateEntry; using password_manager::CredentialCache; using password_manager::MockPasswordStore; @@ -77,11 +76,12 @@ using IsPslMatch = autofill::UserInfo::IsPslMatch; constexpr char kExampleSite[] = "https://example.com"; constexpr char kExampleHttpSite[] = "http://example.com"; +constexpr char16_t kExampleHttpSite16[] = u"http://example.com"; constexpr char kExampleSiteMobile[] = "https://m.example.com"; constexpr char kExampleSignonRealm[] = "https://example.com/"; -constexpr char kExampleDomain[] = "example.com"; -constexpr char kUsername[] = "alice"; -constexpr char kPassword[] = "password123"; +constexpr char16_t kExampleDomain[] = u"example.com"; +constexpr char16_t kUsername[] = u"alice"; +constexpr char16_t kPassword[] = u"password123"; class MockPasswordGenerationController : public PasswordGenerationControllerImpl { @@ -134,19 +134,14 @@ std::u16string password_for_str(const std::u16string& user) { IDS_PASSWORD_MANAGER_ACCESSORY_PASSWORD_DESCRIPTION, user); } -std::u16string password_for_str(const std::string& user) { - return password_for_str(ASCIIToUTF16(user)); -} - -std::u16string passwords_empty_str(const std::string& domain) { +std::u16string passwords_empty_str(const std::u16string& domain) { return l10n_util::GetStringFUTF16( - IDS_PASSWORD_MANAGER_ACCESSORY_PASSWORD_LIST_EMPTY_MESSAGE, - ASCIIToUTF16(domain)); + IDS_PASSWORD_MANAGER_ACCESSORY_PASSWORD_LIST_EMPTY_MESSAGE, domain); } -std::u16string passwords_title_str(const std::string& domain) { +std::u16string passwords_title_str(const std::u16string& domain) { return l10n_util::GetStringFUTF16( - IDS_PASSWORD_MANAGER_ACCESSORY_PASSWORD_LIST_TITLE, ASCIIToUTF16(domain)); + IDS_PASSWORD_MANAGER_ACCESSORY_PASSWORD_LIST_TITLE, domain); } std::u16string no_user_str() { @@ -186,8 +181,8 @@ PasswordForm MakeSavedPassword() { PasswordForm form; form.signon_realm = std::string(kExampleSite); form.url = GURL(kExampleSite); - form.username_value = base::ASCIIToUTF16(kUsername); - form.password_value = base::ASCIIToUTF16(kPassword); + form.username_value = kUsername; + form.password_value = kPassword; form.username_element = u""; form.in_store = PasswordForm::Store::kProfileStore; return form; @@ -283,7 +278,7 @@ TEST_F(PasswordAccessoryControllerTest, TransformsMatchesToSuggestions) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -334,16 +329,16 @@ TEST_F(PasswordAccessoryControllerTest, SortsAlphabeticalDuringTransform) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Alf", u"Alf", false, true) - .AppendField(u"PWD", password_for_str("Alf"), true, false) + .AppendField(u"PWD", password_for_str(u"Alf"), true, false) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Cat", u"Cat", false, true) - .AppendField(u"M1@u", password_for_str("Cat"), true, false) + .AppendField(u"M1@u", password_for_str(u"Cat"), true, false) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Zebra", u"Zebra", false, true) - .AppendField(u"M3h", password_for_str("Zebra"), true, false) + .AppendField(u"M3h", password_for_str(u"Zebra"), true, false) .Build()); } @@ -361,7 +356,7 @@ TEST_F(PasswordAccessoryControllerTest, RepeatsSuggestionsForSameFrame) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -397,7 +392,7 @@ TEST_F(PasswordAccessoryControllerTest, PasswordFieldChangesSuggestionType) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -411,7 +406,7 @@ TEST_F(PasswordAccessoryControllerTest, PasswordFieldChangesSuggestionType) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, false) - .AppendField(u"S3cur3", password_for_str("Ben"), true, true) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, true) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillablePasswordField, @@ -430,7 +425,7 @@ TEST_F(PasswordAccessoryControllerTest, CachesIsReplacedByNewPasswords) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -446,7 +441,7 @@ TEST_F(PasswordAccessoryControllerTest, CachesIsReplacedByNewPasswords) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Alf", u"Alf", false, true) - .AppendField(u"M3lm4k", password_for_str("Alf"), true, false) + .AppendField(u"M3lm4k", password_for_str(u"Alf"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -479,7 +474,7 @@ TEST_F(PasswordAccessoryControllerTest, HidesEntriesForPSLMatchedOriginsInV1) { .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", /*is_obfuscated=*/false, /*selectable=*/true) - .AppendField(u"S3cur3", password_for_str("Ben"), + .AppendField(u"S3cur3", password_for_str(u"Ben"), /*is_obfuscated=*/true, /*selectable=*/false) .Build()); } @@ -508,12 +503,12 @@ TEST_F(PasswordAccessoryControllerTest, SetsTitleForPSLMatchedOriginsInV2) { .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", /*is_obfuscated=*/false, /*selectable=*/true) - .AppendField(u"S3cur3", password_for_str("Ben"), + .AppendField(u"S3cur3", password_for_str(u"Ben"), /*is_obfuscated=*/true, /*selectable=*/false) .AddUserInfo(kExampleSiteMobile, IsPslMatch(true)) .AppendField(u"Alf", u"Alf", /*is_obfuscated=*/false, /*selectable=*/true) - .AppendField(u"R4nd0m", password_for_str("Alf"), + .AppendField(u"R4nd0m", password_for_str(u"Alf"), /*is_obfuscated=*/true, /*selectable=*/false) .Build()); } @@ -532,7 +527,7 @@ TEST_F(PasswordAccessoryControllerTest, UnfillableFieldClearsSuggestions) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -563,7 +558,7 @@ TEST_F(PasswordAccessoryControllerTest, NavigatingMainFrameClearsSuggestions) { PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo(kExampleSite, IsPslMatch(false)) .AppendField(u"Ben", u"Ben", false, true) - .AppendField(u"S3cur3", password_for_str("Ben"), true, false) + .AppendField(u"S3cur3", password_for_str(u"Ben"), true, false) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, @@ -576,7 +571,7 @@ TEST_F(PasswordAccessoryControllerTest, NavigatingMainFrameClearsSuggestions) { EXPECT_CALL( mock_manual_filling_controller_, RefreshSuggestions(PasswordAccessorySheetDataBuilder( - passwords_empty_str("random.other-site.org")) + passwords_empty_str(u"random.other-site.org")) .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kUnfillableElement, @@ -957,7 +952,7 @@ TEST_F(PasswordAccessoryControllerWithTestStoreTest, EXPECT_EQ( last_sheet, AccessorySheetData::Builder(AccessoryTabType::PASSWORDS, - passwords_empty_str(kExampleHttpSite)) + passwords_empty_str(kExampleHttpSite16)) .AppendFooterCommand(manage_passwords_str(), autofill::AccessoryAction::MANAGE_PASSWORDS) .Build()); diff --git a/chrome/browser/password_manager/android/save_password_message_delegate_unittest.cc b/chrome/browser/password_manager/android/save_password_message_delegate_unittest.cc index fd0654003d5fce..77debd832da314 100644 --- a/chrome/browser/password_manager/android/save_password_message_delegate_unittest.cc +++ b/chrome/browser/password_manager/android/save_password_message_delegate_unittest.cc @@ -30,9 +30,10 @@ using password_manager::PasswordFormMetricsRecorder; namespace { constexpr char kDefaultUrl[] = "http://example.com"; -constexpr char kUsername[] = "username"; -constexpr char kPassword[] = "password"; +constexpr char16_t kUsername[] = u"username"; +constexpr char16_t kPassword[] = u"password"; constexpr char kAccountEmail[] = "account@example.com"; +constexpr char16_t kAccountEmail16[] = u"account@example.com"; constexpr char kDismissalReasonHistogramName[] = "PasswordManager.SaveUIDismissalReason"; } // namespace @@ -192,19 +193,18 @@ void SavePasswordMessageDelegateTest::VerifyUkmMetrics( // Tests that message properties (title, description, icon, button text) are // set correctly. TEST_F(SavePasswordMessageDelegateTest, MessagePropertyValues) { - SetUsernameAndPassword(base::ASCIIToUTF16(kUsername), - base::ASCIIToUTF16(kPassword)); + SetUsernameAndPassword(kUsername, kPassword); auto form_manager = CreateFormManager(GURL(kDefaultUrl)); EnqueueMessage(std::move(form_manager), false /*user_signed_in*/); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD), GetMessageWrapper()->GetTitle()); - EXPECT_NE(std::u16string::npos, GetMessageWrapper()->GetDescription().find( - base::ASCIIToUTF16(kUsername))); - EXPECT_EQ(std::u16string::npos, GetMessageWrapper()->GetDescription().find( - base::ASCIIToUTF16(kPassword))); - EXPECT_EQ(std::u16string::npos, GetMessageWrapper()->GetDescription().find( - base::ASCIIToUTF16(kAccountEmail))); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON), GetMessageWrapper()->GetPrimaryButtonText()); @@ -221,25 +221,23 @@ TEST_F(SavePasswordMessageDelegateTest, MessagePropertyValues) { // Tests that the description is set correctly when the user is signed. TEST_F(SavePasswordMessageDelegateTest, SignedInDescription) { - SetUsernameAndPassword(base::ASCIIToUTF16(kUsername), - base::ASCIIToUTF16(kPassword)); + SetUsernameAndPassword(kUsername, kPassword); auto form_manager = CreateFormManager(GURL(kDefaultUrl)); EnqueueMessage(std::move(form_manager), true /*user_signed_in*/); - EXPECT_NE(std::u16string::npos, GetMessageWrapper()->GetDescription().find( - base::ASCIIToUTF16(kUsername))); - EXPECT_EQ(std::u16string::npos, GetMessageWrapper()->GetDescription().find( - base::ASCIIToUTF16(kPassword))); - EXPECT_NE(std::u16string::npos, GetMessageWrapper()->GetDescription().find( - base::ASCIIToUTF16(kAccountEmail))); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kUsername)); + EXPECT_EQ(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kPassword)); + EXPECT_NE(std::u16string::npos, + GetMessageWrapper()->GetDescription().find(kAccountEmail16)); DismissMessage(messages::DismissReason::UNKNOWN); } // Tests that the previous prompt gets dismissed when the new one is enqueued. TEST_F(SavePasswordMessageDelegateTest, OnlyOnePromptAtATime) { - SetUsernameAndPassword(base::ASCIIToUTF16(kUsername), - base::ASCIIToUTF16(kPassword)); + SetUsernameAndPassword(kUsername, kPassword); auto form_manager = CreateFormManager(GURL(kDefaultUrl)); EnqueueMessage(std::move(form_manager), true /*user_signed_in*/); diff --git a/chrome/browser/supervised_user/supervised_user_url_filter_browsertest.cc b/chrome/browser/supervised_user/supervised_user_url_filter_browsertest.cc index 0b8f88a798e051..e46cf97cefac8f 100644 --- a/chrome/browser/supervised_user/supervised_user_url_filter_browsertest.cc +++ b/chrome/browser/supervised_user/supervised_user_url_filter_browsertest.cc @@ -76,8 +76,7 @@ class SupervisedUserURLFilterTest : public MixinBasedInProcessBrowserTest { void SendAccessRequest(WebContents* tab) { tab->GetMainFrame()->ExecuteJavaScriptForTests( - base::ASCIIToUTF16( - "supervisedUserErrorPageController.requestPermission()"), + u"supervisedUserErrorPageController.requestPermission()", base::NullCallback()); return; } diff --git a/chrome/browser/ui/app_list/search/tests/omnibox_result_unittest.cc b/chrome/browser/ui/app_list/search/tests/omnibox_result_unittest.cc index 8dfccc5923599a..5f00272911d1ed 100644 --- a/chrome/browser/ui/app_list/search/tests/omnibox_result_unittest.cc +++ b/chrome/browser/ui/app_list/search/tests/omnibox_result_unittest.cc @@ -22,7 +22,9 @@ namespace test { namespace { const char kFullQuery[] = "Hello World"; +const char16_t kFullQuery16[] = u"Hello World"; const char kExampleDescription[] = "A website"; +const char16_t kExampleDescription16[] = u"A website"; const char kExampleUrl[] = "http://example.com/hello"; const int kRelevance = 750; const double kAppListRelevance = 0.5; @@ -84,8 +86,8 @@ TEST_F(OmniboxResultTest, Basic) { kFullQuery, kRelevance, kExampleUrl, kFullQuery, kExampleDescription, AutocompleteMatchType::HISTORY_URL, kExampleKeyword); - EXPECT_EQ(base::ASCIIToUTF16(kExampleDescription), result->title()); - EXPECT_EQ(base::ASCIIToUTF16(kFullQuery), result->details()); + EXPECT_EQ(kExampleDescription16, result->title()); + EXPECT_EQ(kFullQuery16, result->details()); EXPECT_EQ(kAppListRelevance, result->relevance()); result->Open(0); diff --git a/chrome/browser/ui/ash/shelf/arc_app_shelf_browsertest.cc b/chrome/browser/ui/ash/shelf/arc_app_shelf_browsertest.cc index 8ecd6da88f2b48..5a1aee057d6ccd 100644 --- a/chrome/browser/ui/ash/shelf/arc_app_shelf_browsertest.cc +++ b/chrome/browser/ui/ash/shelf/arc_app_shelf_browsertest.cc @@ -95,8 +95,11 @@ constexpr char kTestShelfGroup3[] = "shelf_group_3"; constexpr char kTestLogicalWindow[] = "logical_window1"; constexpr char kTestLogicalWindow2[] = "logical_window2"; constexpr char kTestWindowTitle[] = "window1"; +constexpr char16_t kTestWindowTitle16[] = u"window1"; constexpr char kTestWindowTitle2[] = "window2"; +constexpr char16_t kTestWindowTitle216[] = u"window2"; constexpr char kTestWindowTitle3[] = "window3"; +constexpr char16_t kTestWindowTitle316[] = u"window3"; constexpr int kAppAnimatedThresholdMs = 100; constexpr int kGeneratedIconSize = 32; @@ -691,13 +694,6 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { kTestLogicalWindow2, kTestLogicalWindow, kTestLogicalWindow}; - const std::u16string kTestWindowUTF16Title = - base::ASCIIToUTF16(kTestWindowTitle); - const std::u16string kTestWindowUTF16Title2 = - base::ASCIIToUTF16(kTestWindowTitle2); - const std::u16string kTestWindowUTF16Title3 = - base::ASCIIToUTF16(kTestWindowTitle3); - // Create windows that will be associated with the tasks. Without this, // GetAppMenuItems() will only return an empty list. std::vector> test_windows; @@ -731,7 +727,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { ASSERT_TRUE(delegate1); ASSERT_EQ(1u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[0].title); app_host()->OnTaskCreated(2, info->package_name, info->activity, info->name, CreateIntentUriWithShelfGroupAndLogicalWindow( @@ -745,7 +741,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { WaitForDecompressTask(); ASSERT_EQ(delegate1, GetShelfItemDelegate(shelf_id1)); ASSERT_EQ(1u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[0].title); // Second logical window for (int task_id = 3; task_id <= 5; task_id++) { @@ -763,7 +759,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { WaitForDecompressTask(); ASSERT_EQ(delegate1, GetShelfItemDelegate(shelf_id1)); ASSERT_EQ(2u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[1].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[1].title); // Group 2 with one logical window out of 2 tasks. Same logical window id as // tasks 1 and 2, but different group. @@ -781,7 +777,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { ASSERT_TRUE(delegate2); ASSERT_NE(delegate1, delegate2); ASSERT_EQ(1u, GetAppMenuItems(delegate2, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate2, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate2, 0)[0].title); app_host()->OnTaskCreated(7, info->package_name, info->activity, info->name, CreateIntentUriWithShelfGroupAndLogicalWindow( @@ -795,35 +791,35 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { WaitForDecompressTask(); ASSERT_EQ(delegate2, GetShelfItemDelegate(shelf_id2)); ASSERT_EQ(1u, GetAppMenuItems(delegate2, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate2, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate2, 0)[0].title); // Group 1 should be unchanged. ASSERT_EQ(2u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[0].title); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[1].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[1].title); // Start closing, and see if the other parts of the logical windows show up. // Group 1: // Task 1 closes, task 2 should become visible: app_host()->OnTaskDestroyed(1); ASSERT_EQ(2u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title2, GetAppMenuItems(delegate1, 0)[0].title); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[1].title); + ASSERT_EQ(kTestWindowTitle216, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[1].title); // Task 4 is hidden, so should not change its entry's title. app_host()->OnTaskDestroyed(4); ASSERT_EQ(2u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title2, GetAppMenuItems(delegate1, 0)[0].title); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate1, 0)[1].title); + ASSERT_EQ(kTestWindowTitle216, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate1, 0)[1].title); // Task 3 closes, leaving only task 5 of this entry. This swaps the two // entries. app_host()->OnTaskDestroyed(3); ASSERT_EQ(2u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title3, GetAppMenuItems(delegate1, 0)[0].title); - ASSERT_EQ(kTestWindowUTF16Title2, GetAppMenuItems(delegate1, 0)[1].title); + ASSERT_EQ(kTestWindowTitle316, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle216, GetAppMenuItems(delegate1, 0)[1].title); // Task 5 closes, close this entry fully. app_host()->OnTaskDestroyed(5); ASSERT_EQ(1u, GetAppMenuItems(delegate1, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title2, GetAppMenuItems(delegate1, 0)[0].title); + ASSERT_EQ(kTestWindowTitle216, GetAppMenuItems(delegate1, 0)[0].title); // Task 2 closes, the full shelf group is closed now. ASSERT_EQ(delegate1, GetShelfItemDelegate(shelf_id1)); app_host()->OnTaskDestroyed(2); @@ -835,7 +831,7 @@ IN_PROC_BROWSER_TEST_F(ArcAppShelfBrowserTest, LogicalWindow) { // Task 7 is hidden, so should not change the entry: app_host()->OnTaskDestroyed(7); ASSERT_EQ(1u, GetAppMenuItems(delegate2, 0).size()); - ASSERT_EQ(kTestWindowUTF16Title, GetAppMenuItems(delegate2, 0)[0].title); + ASSERT_EQ(kTestWindowTitle16, GetAppMenuItems(delegate2, 0)[0].title); // Task 6 is the last task, close group: app_host()->OnTaskDestroyed(6); EXPECT_FALSE(GetShelfItemDelegate(shelf_id2)); diff --git a/chrome/utility/safe_browsing/mac/hfs_unittest.cc b/chrome/utility/safe_browsing/mac/hfs_unittest.cc index 7aeda9a05044bf..c9fe4e6a57bc65 100644 --- a/chrome/utility/safe_browsing/mac/hfs_unittest.cc +++ b/chrome/utility/safe_browsing/mac/hfs_unittest.cc @@ -28,40 +28,39 @@ class HFSIteratorTest : public testing::Test { void GetTargetFiles(bool case_sensitive, std::set* files, std::set* dirs) { - const char* kBaseFiles[] = { - "first/second/third/fourth/fifth/random", - "first/second/third/fourth/Hello World", - "first/second/third/symlink-random", - "first/second/goat-output.txt", - "first/unicode_name", - "README.txt", - ".metadata_never_index", + const char16_t* const kBaseFiles[] = { + u"first/second/third/fourth/fifth/random", + u"first/second/third/fourth/Hello World", + u"first/second/third/symlink-random", + u"first/second/goat-output.txt", + u"first/unicode_name", + u"README.txt", + u".metadata_never_index", }; - const char* kBaseDirs[] = { - "first/second/third/fourth/fifth", - "first/second/third/fourth", - "first/second/third", - "first/second", - "first", - ".Trashes", + const char16_t* const kBaseDirs[] = { + u"first/second/third/fourth/fifth", + u"first/second/third/fourth", + u"first/second/third", + u"first/second", + u"first", + u".Trashes", }; const std::u16string dmg_name = u"SafeBrowsingDMG/"; for (size_t i = 0; i < base::size(kBaseFiles); ++i) - files->insert(dmg_name + base::ASCIIToUTF16(kBaseFiles[i])); + files->insert(dmg_name + kBaseFiles[i]); files->insert(dmg_name + u"first/second/" + base::UTF8ToUTF16("Te\xCC\x86st\xCC\x88 \xF0\x9F\x90\x90 ")); dirs->insert(dmg_name.substr(0, dmg_name.size() - 1)); for (size_t i = 0; i < base::size(kBaseDirs); ++i) - dirs->insert(dmg_name + base::ASCIIToUTF16(kBaseDirs[i])); + dirs->insert(dmg_name + kBaseDirs[i]); if (case_sensitive) { - files->insert(base::ASCIIToUTF16( - "SafeBrowsingDMG/first/second/third/fourth/hEllo wOrld")); + files->insert(u"SafeBrowsingDMG/first/second/third/fourth/hEllo wOrld"); } } @@ -118,9 +117,9 @@ class HFSFileReadTest : public testing::TestWithParam { ASSERT_TRUE(hfs_reader_->Open()); } - bool GoToFile(const char* name) { + bool GoToFile(const char16_t* name) { while (hfs_reader_->Next()) { - if (EndsWith(hfs_reader_->GetPath(), base::ASCIIToUTF16(name), + if (EndsWith(hfs_reader_->GetPath(), name, base::CompareCase::SENSITIVE)) { return true; } @@ -137,7 +136,7 @@ class HFSFileReadTest : public testing::TestWithParam { }; TEST_P(HFSFileReadTest, ReadReadme) { - ASSERT_TRUE(GoToFile("README.txt")); + ASSERT_TRUE(GoToFile(u"README.txt")); std::unique_ptr stream = hfs_reader()->GetReadStream(); ASSERT_TRUE(stream.get()); @@ -167,7 +166,7 @@ TEST_P(HFSFileReadTest, ReadReadme) { } TEST_P(HFSFileReadTest, ReadRandom) { - ASSERT_TRUE(GoToFile("fifth/random")); + ASSERT_TRUE(GoToFile(u"fifth/random")); std::unique_ptr stream = hfs_reader()->GetReadStream(); ASSERT_TRUE(stream.get()); @@ -182,7 +181,7 @@ TEST_P(HFSFileReadTest, ReadRandom) { } TEST_P(HFSFileReadTest, Symlink) { - ASSERT_TRUE(GoToFile("symlink-random")); + ASSERT_TRUE(GoToFile(u"symlink-random")); std::unique_ptr stream = hfs_reader()->GetReadStream(); ASSERT_TRUE(stream.get()); @@ -200,7 +199,7 @@ TEST_P(HFSFileReadTest, Symlink) { } TEST_P(HFSFileReadTest, HardLink) { - ASSERT_TRUE(GoToFile("unicode_name")); + ASSERT_TRUE(GoToFile(u"unicode_name")); EXPECT_FALSE(hfs_reader()->IsSymbolicLink()); EXPECT_TRUE(hfs_reader()->IsHardLink()); @@ -208,7 +207,7 @@ TEST_P(HFSFileReadTest, HardLink) { } TEST_P(HFSFileReadTest, DecmpfsFile) { - ASSERT_TRUE(GoToFile("first/second/goat-output.txt")); + ASSERT_TRUE(GoToFile(u"first/second/goat-output.txt")); std::unique_ptr stream = hfs_reader()->GetReadStream(); ASSERT_TRUE(stream.get()); diff --git a/chromecast/browser/cast_web_contents_browsertest.cc b/chromecast/browser/cast_web_contents_browsertest.cc index 979db2879048c9..f61365eae53977 100644 --- a/chromecast/browser/cast_web_contents_browsertest.cc +++ b/chromecast/browser/cast_web_contents_browsertest.cc @@ -764,13 +764,15 @@ IN_PROC_BROWSER_TEST_F(CastWebContentsBrowserTest, PostMessageToMainFrame) { // would post a message to the test page to redirect it to |title1.html|. // =========================================================================== constexpr char kOriginalTitle[] = "postmessage"; + constexpr char16_t kOriginalTitle16[] = u"postmessage"; constexpr char kPage1Path[] = "title1.html"; constexpr char kPage1Title[] = "title 1"; + constexpr char16_t kPage1Title16[] = u"title 1"; EXPECT_CALL(mock_cast_wc_observer_, - UpdateTitle(base::ASCIIToUTF16(kPage1Title))); + UpdateTitle(std::u16string(kPage1Title16))); EXPECT_CALL(mock_cast_wc_observer_, - UpdateTitle(base::ASCIIToUTF16(kOriginalTitle))); + UpdateTitle(std::u16string(kOriginalTitle16))); embedded_test_server()->ServeFilesFromSourceDirectory(GetTestDataPath()); StartTestServer(); @@ -791,11 +793,12 @@ IN_PROC_BROWSER_TEST_F(CastWebContentsBrowserTest, PostMessagePassMessagePort) { // through the port. // =========================================================================== constexpr char kOriginalTitle[] = "messageport"; + constexpr char16_t kOriginalTitle16[] = u"messageport"; constexpr char kHelloMsg[] = "hi"; constexpr char kPingMsg[] = "ping"; EXPECT_CALL(mock_cast_wc_observer_, - UpdateTitle(base::ASCIIToUTF16(kOriginalTitle))); + UpdateTitle(std::u16string(kOriginalTitle16))); // Load test page. embedded_test_server()->ServeFilesFromSourceDirectory(GetTestDataPath()); @@ -860,10 +863,11 @@ IN_PROC_BROWSER_TEST_F(CastWebContentsBrowserTest, // MessagePort disconnection event. // =========================================================================== constexpr char kOriginalTitle[] = "messageport"; + constexpr char16_t kOriginalTitle16[] = u"messageport"; constexpr char kHelloMsg[] = "hi"; EXPECT_CALL(mock_cast_wc_observer_, - UpdateTitle(base::ASCIIToUTF16(kOriginalTitle))); + UpdateTitle(std::u16string(kOriginalTitle16))); // Load test page. embedded_test_server()->ServeFilesFromSourceDirectory(GetTestDataPath()); StartTestServer(); diff --git a/chromecast/browser/test/cast_navigation_browsertest.cc b/chromecast/browser/test/cast_navigation_browsertest.cc index 4a62fb5e6264ce..b4ea362cb8a4c1 100644 --- a/chromecast/browser/test/cast_navigation_browsertest.cc +++ b/chromecast/browser/test/cast_navigation_browsertest.cc @@ -16,9 +16,9 @@ namespace chromecast { namespace shell { namespace { -const char kEnded[] = "ENDED"; -const char kError[] = "ERROR"; -const char kFailed[] = "FAILED"; +const char16_t kEnded[] = u"ENDED"; +const char16_t kError[] = u"ERROR"; +const char16_t kFailed[] = u"FAILED"; const char kClearKeyKeySystem[] = "org.w3.clearkey"; const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; @@ -69,22 +69,21 @@ class CastNavigationBrowserTest : public CastBrowserTest { void RunMediaTestPage(const std::string& html_page, const base::StringPairs& query_params, - const std::string& expected_title) { + const std::u16string& expected_title) { std::string query = ::media::GetURLQueryString(query_params); GURL gurl = embedded_test_server()->GetURL("/" + html_page + "?" + query); - std::string final_title = RunTest(gurl, expected_title); + std::u16string final_title = RunTest(gurl, expected_title); EXPECT_EQ(expected_title, final_title); } - std::string RunTest(const GURL& gurl, const std::string& expected_title) { + std::u16string RunTest(const GURL& gurl, + const std::u16string& expected_title) { content::WebContents* web_contents = NavigateToURL(gurl); - content::TitleWatcher title_watcher(web_contents, - base::ASCIIToUTF16(expected_title)); - title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); - title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError)); - title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed)); - std::u16string result = title_watcher.WaitAndGetTitle(); - return base::UTF16ToASCII(result); + content::TitleWatcher title_watcher(web_contents, expected_title); + title_watcher.AlsoWaitForTitle(kEnded); + title_watcher.AlsoWaitForTitle(kError); + title_watcher.AlsoWaitForTitle(kFailed); + return title_watcher.WaitAndGetTitle(); } DISALLOW_COPY_AND_ASSIGN(CastNavigationBrowserTest); diff --git a/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc b/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc index 62d377d0a4e882..b2ba07baf5b4bf 100644 --- a/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc +++ b/components/autofill/core/browser/ui/mobile_label_formatter_unittest.cc @@ -301,10 +301,8 @@ TEST(MobileLabelFormatterTest, GetLabels_DistinctProfiles_ShowAll) { profiles, "en-US", NAME_FIRST, GetAddressPlusContactFieldTypes()); EXPECT_THAT( formatter->GetLabels(), - ElementsAre(base::ASCIIToUTF16( - "address1A, address2A, (617) 666-0000, emailA@gmail.com"), - base::ASCIIToUTF16( - "address1B, address2B, (518) 555-0000, emailB@gmail.com"), + ElementsAre(u"address1A, address2A, (617) 666-0000, emailA@gmail.com", + u"address1B, address2B, (518) 555-0000, emailB@gmail.com", std::u16string())); // Like the previous test, but focuses on an address field rather than a name diff --git a/components/autofill_assistant/browser/website_login_manager_impl_unittest.cc b/components/autofill_assistant/browser/website_login_manager_impl_unittest.cc index 363674e77722c3..9daa00b8a7574e 100644 --- a/components/autofill_assistant/browser/website_login_manager_impl_unittest.cc +++ b/components/autofill_assistant/browser/website_login_manager_impl_unittest.cc @@ -20,7 +20,6 @@ using autofill::FormData; using autofill::FormFieldData; -using base::ASCIIToUTF16; using password_manager::PasswordForm; using testing::_; using testing::Invoke; @@ -33,11 +32,13 @@ namespace autofill_assistant { namespace { const char kFakeUrl[] = "http://www.example.com/"; const char kFakeUsername[] = "user@example.com"; -const char kFakePassword[] = "old_password"; +const char16_t kFakeUsername16[] = u"user@example.com"; +const char16_t kFakePassword[] = u"old_password"; const char kFakeNewPassword[] = "new_password"; -const char kFormDataName[] = "the-form-name"; -const char kPasswordElement[] = "password-element"; -const char kUsernameElement[] = "username-element"; +const char16_t kFakeNewPassword16[] = u"new_password"; +const char16_t kFormDataName[] = u"the-form-name"; +const char16_t kPasswordElement[] = u"password-element"; +const char16_t kUsernameElement[] = u"username-element"; class MockPasswordManagerClient : public password_manager::StubPasswordManagerClient { @@ -55,13 +56,13 @@ FormData MakeFormDataWithPasswordField() { FormData form_data; form_data.url = GURL(kFakeUrl); form_data.action = GURL(kFakeUrl); - form_data.name = ASCIIToUTF16(kFormDataName); + form_data.name = kFormDataName; FormFieldData field; - field.name = ASCIIToUTF16(kPasswordElement); + field.name = kPasswordElement; field.id_attribute = field.name; field.name_attribute = field.name; - field.value = ASCIIToUTF16(kFakeNewPassword); + field.value = kFakeNewPassword16; field.form_control_type = "password"; form_data.fields.push_back(field); @@ -72,10 +73,10 @@ PasswordForm MakeSimplePasswordForm() { PasswordForm form; form.url = GURL(kFakeUrl); form.signon_realm = form.url.GetOrigin().spec(); - form.password_value = ASCIIToUTF16(kFakePassword); - form.username_value = ASCIIToUTF16(kFakeUsername); - form.username_element = ASCIIToUTF16(kUsernameElement); - form.password_element = ASCIIToUTF16(kPasswordElement); + form.password_value = kFakePassword; + form.username_value = kFakeUsername16; + form.username_element = kUsernameElement; + form.password_element = kPasswordElement; form.in_store = PasswordForm::Store::kProfileStore; return form; @@ -85,7 +86,7 @@ PasswordForm MakeSimplePasswordFormWithoutUsername() { PasswordForm form; form.url = GURL(kFakeUrl); form.signon_realm = form.url.GetOrigin().spec(); - form.password_value = ASCIIToUTF16(kFakeNewPassword); + form.password_value = kFakeNewPassword16; form.in_store = PasswordForm::Store::kProfileStore; return form; @@ -177,7 +178,7 @@ TEST_F(WebsiteLoginManagerImplTest, SaveGeneratedPassword) { // Commit generated password. EXPECT_TRUE(manager()->ReadyToCommitGeneratedPassword()); PasswordForm new_form = MakeSimplePasswordForm(); - new_form.password_value = ASCIIToUTF16(kFakeNewPassword); + new_form.password_value = kFakeNewPassword16; // Check that additional data is populated correctly from matched form. EXPECT_CALL(*store(), UpdateLoginWithPrimaryKey(FormMatches(new_form), _)); manager()->CommitGeneratedPassword(); diff --git a/components/password_manager/core/browser/login_database_unittest.cc b/components/password_manager/core/browser/login_database_unittest.cc index 0c88721d7acb50..53c7067c767aed 100644 --- a/components/password_manager/core/browser/login_database_unittest.cc +++ b/components/password_manager/core/browser/login_database_unittest.cc @@ -2026,8 +2026,11 @@ TEST_F(LoginDatabaseTest, EncryptionDisabled) { // accessible (this doesn't work for any plain-text value). TEST_F(LoginDatabaseTest, HandleObfuscationMix) { const char k_obfuscated_pw[] = "v10pass1"; + const char16_t k_obfuscated_pw16[] = u"v10pass1"; const char k_plain_text_pw1[] = "v10pass2"; + const char16_t k_plain_text_pw116[] = u"v10pass2"; const char k_plain_text_pw2[] = "v11pass3"; + const char16_t k_plain_text_pw216[] = u"v11pass3"; base::FilePath file = temp_dir_.GetPath().AppendASCII("TestUnencryptedDB"); { @@ -2035,15 +2038,15 @@ TEST_F(LoginDatabaseTest, HandleObfuscationMix) { ASSERT_TRUE(db.Init()); // Add obfuscated (new) entries. PasswordForm password_form = GenerateExamplePasswordForm(); - password_form.password_value = ASCIIToUTF16(k_obfuscated_pw); + password_form.password_value = k_obfuscated_pw16; EXPECT_EQ(AddChangeForForm(password_form), db.AddLogin(password_form)); // Add plain-text (old) entries. db.disable_encryption(); password_form.username_value = u"other_username"; - password_form.password_value = ASCIIToUTF16(k_plain_text_pw1); + password_form.password_value = k_plain_text_pw116; EXPECT_EQ(AddChangeForForm(password_form), db.AddLogin(password_form)); password_form.username_value = u"other_username2"; - password_form.password_value = ASCIIToUTF16(k_plain_text_pw2); + password_form.password_value = k_plain_text_pw216; EXPECT_EQ(AddChangeForForm(password_form), db.AddLogin(password_form)); } @@ -2061,9 +2064,9 @@ TEST_F(LoginDatabaseTest, HandleObfuscationMix) { k_plain_text_pw2)); // LoginDatabase serves the original values. ASSERT_THAT(forms, SizeIs(3)); - EXPECT_EQ(k_obfuscated_pw, UTF16ToASCII(forms[0]->password_value)); - EXPECT_EQ(k_plain_text_pw1, UTF16ToASCII(forms[1]->password_value)); - EXPECT_EQ(k_plain_text_pw2, UTF16ToASCII(forms[2]->password_value)); + EXPECT_EQ(k_obfuscated_pw16, forms[0]->password_value); + EXPECT_EQ(k_plain_text_pw116, forms[1]->password_value); + EXPECT_EQ(k_plain_text_pw216, forms[2]->password_value); } #endif // defined(OS_ANDROID) || BUILDFLAG(IS_CHROMEOS_ASH) diff --git a/components/storage_monitor/mtp_manager_client_chromeos_unittest.cc b/components/storage_monitor/mtp_manager_client_chromeos_unittest.cc index 1b6c8afac1e316..5f0b892e12a905 100644 --- a/components/storage_monitor/mtp_manager_client_chromeos_unittest.cc +++ b/components/storage_monitor/mtp_manager_client_chromeos_unittest.cc @@ -31,8 +31,10 @@ namespace { const char kStorageWithInvalidInfo[] = "usb:2,3:11111"; const char kStorageWithValidInfo[] = "usb:2,2:88888"; const char kStorageVendor[] = "ExampleVendor"; +const char16_t kStorageVendor16[] = u"ExampleVendor"; const uint32_t kStorageVendorId = 0x040a; const char kStorageProduct[] = "ExampleCamera"; +const char16_t kStorageProduct16[] = u"ExampleCamera"; const uint32_t kStorageProductId = 0x0160; const uint32_t kStorageDeviceFlags = 0x0004000; const uint32_t kStorageType = 3; // Fixed RAM @@ -155,10 +157,8 @@ TEST_F(MtpManagerClientChromeOSTest, BasicAttachDetach) { EXPECT_EQ(device_id, observer().last_attached().device_id()); EXPECT_EQ(GetDeviceLocationFromStorageName(kStorageWithValidInfo), observer().last_attached().location()); - EXPECT_EQ(base::ASCIIToUTF16(kStorageVendor), - observer().last_attached().vendor_name()); - EXPECT_EQ(base::ASCIIToUTF16(kStorageProduct), - observer().last_attached().model_name()); + EXPECT_EQ(kStorageVendor16, observer().last_attached().vendor_name()); + EXPECT_EQ(kStorageProduct16, observer().last_attached().model_name()); // Detach the attached storage. mtp_device_observer()->MtpStorageDetached(kStorageWithValidInfo); diff --git a/content/browser/media/media_browsertest.cc b/content/browser/media/media_browsertest.cc index 4a48e7a6092b1a..5f01bb9e9d4c3b 100644 --- a/content/browser/media/media_browsertest.cc +++ b/content/browser/media/media_browsertest.cc @@ -31,7 +31,7 @@ namespace content { #if defined(OS_ANDROID) // Title set by android cleaner page after short timeout. -const char kClean[] = "CLEAN"; +const char16_t kClean[] = u"CLEAN"; #endif void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { @@ -102,7 +102,7 @@ void MediaBrowserTest::CleanupTest() { #if defined(OS_ANDROID) // We only do this cleanup on Android, as a workaround for a test-only OOM // bug. See http://crbug.com/727542 - const std::u16string cleaner_title = base::ASCIIToUTF16(kClean); + const std::u16string cleaner_title = kClean; TitleWatcher clean_title_watcher(shell()->web_contents(), cleaner_title); GURL cleaner_url = content::GetFileUrlWithQuery( media::GetTestDataFilePath("cleaner.html"), ""); diff --git a/fuchsia/engine/browser/media_player_impl_unittest.cc b/fuchsia/engine/browser/media_player_impl_unittest.cc index cf81e993e50e6f..65b0c6cb171b76 100644 --- a/fuchsia/engine/browser/media_player_impl_unittest.cc +++ b/fuchsia/engine/browser/media_player_impl_unittest.cc @@ -193,13 +193,17 @@ TEST_F(MediaPlayerImplTest, WatchInfoChangeReturnsInitialState) { media_session::MediaMetadata metadata; constexpr char kExpectedTitle[] = "Love Like A Sunset, Pt.1"; - metadata.title = base::ASCIIToUTF16(kExpectedTitle); + constexpr char16_t kExpectedTitle16[] = u"Love Like A Sunset, Pt.1"; + metadata.title = kExpectedTitle16; constexpr char kExpectedArtist[] = "Phoenix"; - metadata.artist = base::ASCIIToUTF16(kExpectedArtist); + constexpr char16_t kExpectedArtist16[] = u"Phoenix"; + metadata.artist = kExpectedArtist16; constexpr char kExpectedAlbum[] = "Wolfgang Amadeus Phoenix"; - metadata.album = base::ASCIIToUTF16(kExpectedAlbum); + constexpr char16_t kExpectedAlbum16[] = u"Wolfgang Amadeus Phoenix"; + metadata.album = kExpectedAlbum16; constexpr char kExpectedSourceTitle[] = "Unknown"; - metadata.source_title = base::ASCIIToUTF16(kExpectedSourceTitle); + constexpr char16_t kExpectedSourceTitle16[] = u"Unknown"; + metadata.source_title = kExpectedSourceTitle16; fake_session_.observer()->MediaSessionMetadataChanged(metadata); std::vector actions = { diff --git a/ios/chrome/browser/passwords/ios_chrome_password_check_manager_unittest.mm b/ios/chrome/browser/passwords/ios_chrome_password_check_manager_unittest.mm index 4b32f3ee81f97e..8e4d53e527812d 100644 --- a/ios/chrome/browser/passwords/ios_chrome_password_check_manager_unittest.mm +++ b/ios/chrome/browser/passwords/ios_chrome_password_check_manager_unittest.mm @@ -42,9 +42,11 @@ constexpr char kExampleCom[] = "https://example.com"; constexpr char kUsername1[] = "alice"; +constexpr char16_t kUsername116[] = u"alice"; constexpr char kUsername2[] = "bob"; constexpr char kPassword1[] = "s3cre3t"; +constexpr char16_t kPassword116[] = u"s3cre3t"; constexpr char kPassword2[] = "bett3r_S3cre3t"; using password_manager::PasswordForm; @@ -103,42 +105,40 @@ InsecureCredential MakeInsecureCredential( base::StringPiece signon_realm, - base::StringPiece username, + base::StringPiece16 username, base::TimeDelta time_since_creation = base::TimeDelta(), InsecureType compromise_type = InsecureType::kLeaked) { - return InsecureCredential(std::string(signon_realm), - base::ASCIIToUTF16(username), + return InsecureCredential(std::string(signon_realm), std::u16string(username), base::Time::Now() - time_since_creation, compromise_type, password_manager::IsMuted(false)); } PasswordForm MakeSavedPassword( base::StringPiece signon_realm, - base::StringPiece username, - base::StringPiece password = kPassword1, - base::StringPiece username_element = base::StringPiece()) { + base::StringPiece16 username, + base::StringPiece16 password = kPassword116, + base::StringPiece16 username_element = base::StringPiece16()) { PasswordForm form; form.signon_realm = std::string(signon_realm); - form.username_value = base::ASCIIToUTF16(username); - form.password_value = base::ASCIIToUTF16(password); - form.username_element = base::ASCIIToUTF16(username_element); + form.username_value = std::u16string(username); + form.password_value = std::u16string(password); + form.username_element = std::u16string(username_element); form.in_store = PasswordForm::Store::kProfileStore; return form; } // Creates matcher for a given compromised credential auto ExpectCompromisedCredential(const std::string& signon_realm, - const base::StringPiece& username, - const base::StringPiece& password, + const base::StringPiece16& username, + const base::StringPiece16& password, base::TimeDelta elapsed_time_since_compromise, InsecureCredentialTypeFlags insecure_type) { - return AllOf( - Field(&CredentialWithPassword::signon_realm, signon_realm), - Field(&CredentialWithPassword::username, base::ASCIIToUTF16(username)), - Field(&CredentialWithPassword::password, base::ASCIIToUTF16(password)), - Field(&CredentialWithPassword::create_time, - (base::Time::Now() - elapsed_time_since_compromise)), - Field(&CredentialWithPassword::insecure_type, insecure_type)); + return AllOf(Field(&CredentialWithPassword::signon_realm, signon_realm), + Field(&CredentialWithPassword::username, username), + Field(&CredentialWithPassword::password, password), + Field(&CredentialWithPassword::create_time, + (base::Time::Now() - elapsed_time_since_compromise)), + Field(&CredentialWithPassword::insecure_type, insecure_type)); } // Returns vector of pairs with username, password only. @@ -188,28 +188,27 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Sets up the password store with a password and compromised // credential. Verifies that the result is matching expectation. TEST_F(IOSChromePasswordCheckManagerTest, GetCompromisedCredentials) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116)); store().AddInsecureCredential(MakeInsecureCredential( - kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1), + kExampleCom, kUsername116, base::TimeDelta::FromMinutes(1), InsecureType::kLeaked)); RunUntilIdle(); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredential( - kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1), - InsecureCredentialTypeFlags::kCredentialLeaked))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredential( + kExampleCom, kUsername116, kPassword116, + base::TimeDelta::FromMinutes(1), + InsecureCredentialTypeFlags::kCredentialLeaked))); } // Test that we don't create an entry in the password store if IsLeaked is // false. TEST_F(IOSChromePasswordCheckManagerTest, NoLeakedFound) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116, kPassword116)); RunUntilIdle(); static_cast(&manager()) - ->OnCredentialDone(LeakCheckCredential(base::ASCIIToUTF16(kUsername1), - base::ASCIIToUTF16(kPassword1)), + ->OnCredentialDone(LeakCheckCredential(kUsername116, kPassword116), IsLeaked(false)); RunUntilIdle(); @@ -219,20 +218,19 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Test that a found leak creates a compromised credential in the password // store. TEST_F(IOSChromePasswordCheckManagerTest, OnLeakFoundCreatesCredential) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116, kPassword116)); RunUntilIdle(); static_cast(&manager()) - ->OnCredentialDone(LeakCheckCredential(base::ASCIIToUTF16(kUsername1), - base::ASCIIToUTF16(kPassword1)), + ->OnCredentialDone(LeakCheckCredential(kUsername116, kPassword116), IsLeaked(true)); RunUntilIdle(); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredential( - kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(0), - InsecureCredentialTypeFlags::kCredentialLeaked))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredential( + kExampleCom, kUsername116, kPassword116, + base::TimeDelta::FromMinutes(0), + InsecureCredentialTypeFlags::kCredentialLeaked))); } // Verifies that the case where the user has no saved passwords is reported @@ -245,7 +243,7 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Verifies that the case where the user has saved passwords is reported // correctly. TEST_F(IOSChromePasswordCheckManagerTest, GetPasswordCheckStatusIdle) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116)); RunUntilIdle(); EXPECT_EQ(PasswordCheckState::kIdle, manager().GetPasswordCheckState()); @@ -273,7 +271,7 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests whether adding and removing an observer works as expected. TEST_F(IOSChromePasswordCheckManagerTest, NotifyObserversAboutCompromisedCredentialChanges) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116)); RunUntilIdle(); StrictMock observer; @@ -283,24 +281,25 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, EXPECT_CALL( observer, CompromisedCredentialsChanged(ElementsAre(ExpectCompromisedCredential( - kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1), + kExampleCom, kUsername116, kPassword116, + base::TimeDelta::FromMinutes(1), InsecureCredentialTypeFlags::kCredentialLeaked)))); store().AddInsecureCredential(MakeInsecureCredential( - kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1))); + kExampleCom, kUsername116, base::TimeDelta::FromMinutes(1))); RunUntilIdle(); // After an observer is removed it should no longer receive notifications. manager().RemoveObserver(&observer); EXPECT_CALL(observer, CompromisedCredentialsChanged).Times(0); store().AddInsecureCredential(MakeInsecureCredential( - kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1), + kExampleCom, kUsername116, base::TimeDelta::FromMinutes(1), InsecureType::kPhished)); RunUntilIdle(); } // Tests whether adding and removing an observer works as expected. TEST_F(IOSChromePasswordCheckManagerTest, NotifyObserversAboutStateChanges) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116)); RunUntilIdle(); StrictMock observer; manager().AddObserver(&observer); @@ -323,19 +322,19 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests password deleted. TEST_F(IOSChromePasswordCheckManagerTest, DeletePassword) { - PasswordForm form = MakeSavedPassword(kExampleCom, kUsername1); + PasswordForm form = MakeSavedPassword(kExampleCom, kUsername116); store().AddLogin(form); RunUntilIdle(); store().AddInsecureCredential(MakeInsecureCredential( - kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1), + kExampleCom, kUsername116, base::TimeDelta::FromMinutes(1), InsecureType::kLeaked)); RunUntilIdle(); - EXPECT_THAT( - manager().GetCompromisedCredentials(), - ElementsAre(ExpectCompromisedCredential( - kExampleCom, kUsername1, kPassword1, base::TimeDelta::FromMinutes(1), - InsecureCredentialTypeFlags::kCredentialLeaked))); + EXPECT_THAT(manager().GetCompromisedCredentials(), + ElementsAre(ExpectCompromisedCredential( + kExampleCom, kUsername116, kPassword116, + base::TimeDelta::FromMinutes(1), + InsecureCredentialTypeFlags::kCredentialLeaked))); manager().DeleteCompromisedPasswordForm(form); RunUntilIdle(); @@ -346,8 +345,8 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests duplicated passwords deleted. TEST_F(IOSChromePasswordCheckManagerTest, DeleteDuplicatedPasswords) { std::vector passwords = { - MakeSavedPassword(kExampleCom, kUsername1, kPassword1, "element_1"), - MakeSavedPassword(kExampleCom, kUsername1, kPassword1, "element_2")}; + MakeSavedPassword(kExampleCom, kUsername116, kPassword116, u"element_1"), + MakeSavedPassword(kExampleCom, kUsername116, kPassword116, u"element_2")}; store().AddLogin(passwords[0]); store().AddLogin(passwords[1]); @@ -361,7 +360,7 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests password value is updated properly. TEST_F(IOSChromePasswordCheckManagerTest, EditPassword) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116, kPassword116)); RunUntilIdle(); EXPECT_TRUE(manager().EditPasswordForm( @@ -376,7 +375,7 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests username value is updated properly. TEST_F(IOSChromePasswordCheckManagerTest, EditUsername) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116, kPassword116)); RunUntilIdle(); EXPECT_TRUE(manager().EditPasswordForm( @@ -391,7 +390,7 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests username and password values are updated properly. TEST_F(IOSChromePasswordCheckManagerTest, EditUsernameAndPassword) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1, kPassword1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116, kPassword116)); RunUntilIdle(); EXPECT_TRUE(manager().EditPasswordForm( @@ -406,12 +405,12 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests compromised password value is updated properly. TEST_F(IOSChromePasswordCheckManagerTest, EditCompromisedPassword) { - PasswordForm form = MakeSavedPassword(kExampleCom, kUsername1); + PasswordForm form = MakeSavedPassword(kExampleCom, kUsername116); store().AddLogin(form); RunUntilIdle(); store().AddInsecureCredential(MakeInsecureCredential( - kExampleCom, kUsername1, base::TimeDelta::FromMinutes(1), + kExampleCom, kUsername116, base::TimeDelta::FromMinutes(1), InsecureType::kLeaked)); RunUntilIdle(); @@ -424,7 +423,7 @@ auto ExpectCompromisedCredential(const std::string& signon_realm, // Tests expected delay is being added. TEST_F(IOSChromePasswordCheckManagerTest, CheckFinishedWithDelay) { - store().AddLogin(MakeSavedPassword(kExampleCom, kUsername1)); + store().AddLogin(MakeSavedPassword(kExampleCom, kUsername116)); RunUntilIdle(); StrictMock observer; diff --git a/ios/chrome/browser/ui/autofill/autofill_app_interface.mm b/ios/chrome/browser/ui/autofill/autofill_app_interface.mm index d1d9b6ba60019a..eacf9d6e1770be 100644 --- a/ios/chrome/browser/ui/autofill/autofill_app_interface.mm +++ b/ios/chrome/browser/ui/autofill/autofill_app_interface.mm @@ -37,8 +37,8 @@ namespace { -const char kExampleUsername[] = "concrete username"; -const char kExamplePassword[] = "concrete password"; +const char16_t kExampleUsername[] = u"concrete username"; +const char16_t kExamplePassword[] = u"concrete password"; // Gets the current password store. scoped_refptr GetPasswordStore() { @@ -121,8 +121,8 @@ void SaveToPasswordStore(const password_manager::PasswordForm& form) { // Saves an example form in the store. void SaveExamplePasswordForm() { password_manager::PasswordForm example; - example.username_value = base::ASCIIToUTF16(kExampleUsername); - example.password_value = base::ASCIIToUTF16(kExamplePassword); + example.username_value = kExampleUsername; + example.password_value = kExamplePassword; example.url = GURL("https://example.com/"); example.signon_realm = example.url.spec(); SaveToPasswordStore(example); @@ -131,8 +131,8 @@ void SaveExamplePasswordForm() { // Saves an example form in the store for the passed URL. void SaveLocalPasswordForm(const GURL& url) { password_manager::PasswordForm localForm; - localForm.username_value = base::ASCIIToUTF16(kExampleUsername); - localForm.password_value = base::ASCIIToUTF16(kExamplePassword); + localForm.username_value = kExampleUsername; + localForm.password_value = kExamplePassword; localForm.url = url; localForm.signon_realm = localForm.url.spec(); SaveToPasswordStore(localForm); diff --git a/printing/printing_context_chromeos_unittest.cc b/printing/printing_context_chromeos_unittest.cc index 9db836d452aa44..fed56d396867b4 100644 --- a/printing/printing_context_chromeos_unittest.cc +++ b/printing/printing_context_chromeos_unittest.cc @@ -22,10 +22,12 @@ using ::testing::Return; using ::testing::SaveArg; constexpr char kPrinterName[] = "printer"; +constexpr char16_t kPrinterName16[] = u"printer"; constexpr char kUsername[] = "test user"; constexpr char kDocumentName[] = "document name"; +constexpr char16_t kDocumentName16[] = u"document name"; const char* GetOptionValue(const std::vector& options, const char* option_name) { @@ -116,7 +118,7 @@ class PrintingContextTest : public testing::Test, printing_context_ = PrintingContextChromeos::CreateForTesting( this, std::move(unique_connection)); auto settings = std::make_unique(); - settings->set_device_name(base::ASCIIToUTF16(kPrinterName)); + settings->set_device_name(kPrinterName16); settings->set_send_user_info(send_user_info); settings->set_duplex_mode(mojom::DuplexMode::kLongEdge); settings->set_username(kUsername); @@ -191,7 +193,7 @@ TEST_F(PrintingContextTest, SettingsToCupsOptions_Resolution) { TEST_F(PrintingContextTest, SettingsToCupsOptions_SendUserInfo_Secure) { ipp_status_t status = ipp_status_t::IPP_STATUS_OK; - std::u16string document_name = base::ASCIIToUTF16(kDocumentName); + std::u16string document_name = kDocumentName16; SetDefaultSettings(/*send_user_info=*/true, "ipps://test-uri"); std::string create_job_document_name; std::string create_job_username; @@ -214,7 +216,7 @@ TEST_F(PrintingContextTest, SettingsToCupsOptions_SendUserInfo_Secure) { TEST_F(PrintingContextTest, SettingsToCupsOptions_SendUserInfo_Insecure) { ipp_status_t status = ipp_status_t::IPP_STATUS_OK; - std::u16string document_name = base::ASCIIToUTF16(kDocumentName); + std::u16string document_name = kDocumentName16; std::string default_username = "chronos"; std::string default_document_name = "-"; SetDefaultSettings(/*send_user_info=*/true, "ipp://test-uri"); @@ -239,7 +241,7 @@ TEST_F(PrintingContextTest, SettingsToCupsOptions_SendUserInfo_Insecure) { TEST_F(PrintingContextTest, SettingsToCupsOptions_DoNotSendUserInfo) { ipp_status_t status = ipp_status_t::IPP_STATUS_OK; - std::u16string document_name = base::ASCIIToUTF16(kDocumentName); + std::u16string document_name = kDocumentName16; SetDefaultSettings(/*send_user_info=*/false, "ipps://test-uri"); std::string create_job_document_name; std::string create_job_username; diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc b/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc index 703e0b28389c10..ab7dfcb183eff5 100644 --- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller_unittest.cc @@ -51,6 +51,8 @@ namespace { constexpr char kSampleTextForDragAndDrop[] = "This is a sample text for drag-and-drop."; +constexpr char16_t kSampleTextForDragAndDrop16[] = + u"This is a sample text for drag-and-drop."; constexpr FilenameToURLPolicy kFilenameToURLPolicy = FilenameToURLPolicy::CONVERT_FILENAMES; @@ -165,8 +167,7 @@ class WaylandDataDragControllerTest : public WaylandDragDropTest { WaylandWindow* window() { return window_.get(); } std::u16string sample_text_for_dnd() const { - static auto text = base::ASCIIToUTF16(kSampleTextForDragAndDrop); - return text; + return kSampleTextForDragAndDrop16; } void RunDragLoopWithSampleData(WaylandWindow* origin_window, int operations) { diff --git a/ui/views/widget/ax_native_widget_mac_unittest.mm b/ui/views/widget/ax_native_widget_mac_unittest.mm index 398d7f4dde1588..bf2974b118604d 100644 --- a/ui/views/widget/ax_native_widget_mac_unittest.mm +++ b/ui/views/widget/ax_native_widget_mac_unittest.mm @@ -95,18 +95,18 @@ bool OnMousePressed(const ui::MouseEvent& event) override { public: TestWidgetDelegate() = default; - static constexpr char kAccessibleWindowTitle[] = "My Accessible Window"; + static constexpr char16_t kAccessibleWindowTitle[] = u"My Accessible Window"; // WidgetDelegate: std::u16string GetAccessibleWindowTitle() const override { - return base::ASCIIToUTF16(kAccessibleWindowTitle); + return kAccessibleWindowTitle; } private: DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate); }; -constexpr char TestWidgetDelegate::kAccessibleWindowTitle[]; +constexpr char16_t TestWidgetDelegate::kAccessibleWindowTitle[]; // Widget-level tests for accessibility properties - these are actually mostly // tests of accessibility behavior for individual Views *as they appear* in @@ -347,7 +347,7 @@ void TearDown() override { EXPECT_NSEQ(window, ax_view.accessibilityWindow); EXPECT_NSEQ(window, ax_view.accessibilityTopLevelUIElement); EXPECT_NSEQ( - base::SysUTF8ToNSString(TestWidgetDelegate::kAccessibleWindowTitle), + base::SysUTF16ToNSString(TestWidgetDelegate::kAccessibleWindowTitle), window.accessibilityTitle); }