Convert text rendering, elision, and manipulation to string_view.
This also converts Label and TextField; these are closely intertwined with the classes above and converting them is easier than trying to demarcate the changes around them. The rest of this huge ball of changes are basically what happens when you pull this viral string. I could have gone further; l10n_util really wants to be converted to take string_view args, for example, and not doing it here results in a lot of string instantiations. But there has to be some kind of limit, and that was just a step too far. Bug: 364987728 Change-Id: I8f30313f3aef82a9dea219f84ab1f1d08d91b724 AX-Relnotes: n/a. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6238094 Reviewed-by: Gauthier Ambard <gambard@chromium.org> Reviewed-by: Mitsuru Oshima <oshima@chromium.org> Reviewed-by: Mike Wasserman <msw@chromium.org> Commit-Queue: Peter Kasting <pkasting@chromium.org> Reviewed-by: Elly FJ <ellyjones@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Reviewed-by: Colin Blundell <blundell@chromium.org> Reviewed-by: Allen Bauer <kylixrd@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1419410}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
631d8c10d0
commit
d6c295470c
ash
accessibility
mouse_keys
ambient
app_list
app_list_test_api.cc
views
app_list_a11y_announcer.ccapp_list_a11y_announcer.happ_list_item_view.ccapp_list_search_view_unittest.ccapps_grid_view.ccapps_grid_view_unittest.ccfolder_header_view.ccfolder_header_view.hsearch_box_view.ccsearch_box_view.hsearch_box_view_unittest.ccsearch_result_image_list_view.ccsearch_result_list_view.cc
app_menu
assistant
auth
active_session_auth_controller_impl.ccactive_session_auth_controller_impl.h
views
active_session_auth_view.ccactive_session_auth_view.hactive_session_auth_view_unittest.ccauth_container_view.ccauth_container_view.hauth_container_view_unittest.ccauth_header_view.ccauth_header_view.hauth_input_row_view.ccauth_input_row_view.hauth_input_row_view_unittest.ccauth_textfield.hauth_textfield_timer.ccauth_textfield_timer.hauth_textfield_timer_unittest.ccauth_textfield_unittest.ccpin_container_view_unittest.ccpin_status_view.ccpin_status_view.h
test_support
capture_mode
action_button_container_view.ccaction_button_container_view.hcapture_mode_menu_group.cccapture_mode_menu_group.hsearch_results_panel.cc
display
game_dashboard
game_dashboard_context_test_api.ccgame_dashboard_context_test_api.hgame_dashboard_context_unittest.cc
glanceables
in_session_auth
login
login_screen_test_api.cc
ui
access_code_input.ccaccess_code_input.hanimated_auth_factors_label_wrapper.ccdisabled_auth_message_view.ccdisabled_auth_message_view.hlocal_authentication_request_controller_impl.cclocal_authentication_request_controller_impl.hlocal_authentication_request_controller_impl_unittest.cclocal_authentication_request_view.cclocal_authentication_request_view.hlocal_authentication_test_api.cclocal_authentication_test_api.hlogin_auth_user_view.cclogin_auth_user_view.hlogin_password_view.cclogin_password_view.hlogin_password_view_test.cclogin_pin_input_view.cclogin_pin_input_view.hlogin_pin_input_view_unittest.cclogin_remove_account_dialog.cclogin_user_view.cclogin_user_view.hpin_status_message_view.ccpin_status_message_view.h
public
quick_insert
views
search_box
shelf
style
error_message_toast.ccerror_message_toast.hpill_button.ccpill_button.hsystem_textfield.ccsystem_textfield_controller.cc
system
accessibility
accessibility_detailed_view_unittest.ccdictation_bubble_controller_unittest.ccdictation_bubble_view.ccdictation_bubble_view.hfacegaze_bubble_controller_unittest.ccfacegaze_bubble_view.ccfacegaze_bubble_view.h
mouse_keys
audio
bluetooth
focus_mode
focus_mode_chip_carousel.ccfocus_mode_detailed_view.ccfocus_mode_detailed_view_unittest.ccfocus_mode_task_view.cc
holding_space
ime
ime_menu
locale
mahi
network
night_light
phonehub
enable_hotspot_quick_action_controller.cclocate_phone_quick_action_controller.ccphone_hub_notification_controller_unittest.ccquick_action_item.ccquick_action_item.hsilence_phone_quick_action_controller.cc
power
time
toast
anchored_nudge_manager_impl.ccanchored_nudge_manager_impl.hanchored_nudge_manager_impl_unittest.ccsystem_toast_view.ccsystem_toast_view.h
unified
video_conference
wm
chrome/browser
ash
accessibility
accessibility_extension_api_browsertest.ccdictation_bubble_test_helper.ccdictation_bubble_test_helper.h
app_list
arc
input_overlay
login
mahi
media_app
web_contents
notifications
policy
dlp
video_conference
password_manager
task_manager
ui
android
ash
magic_boost
quick_answers
autofill
cocoa
renderer_context_menu
find_bar
find_bar.hfind_bar_controller.ccfind_bar_controller.hfind_bar_host_browsertest.ccfind_bar_platform_helper.hfind_bar_platform_helper_mac.mmfind_bar_platform_helper_mac_interactive_uitest.mm
login
passwords
sync
task_manager
views
apps
app_dialog
autofill
address_editor_view.ccaddress_editor_view.h
bluetooth_device_credentials_view.ccpayments
card_unmask_otp_input_dialog_views.ccfilled_card_information_bubble_views_interactive_uitest.ccoffer_notification_icon_view.ccoffer_notification_icon_view.hsave_card_offer_bubble_views.cc
popup
bookmarks
bookmark_bar_view.ccbookmark_bar_view.hbookmark_button.ccbookmark_button.hbookmark_editor_view_unittest.ccbookmark_menu_button_base.ccbookmark_menu_button_base.h
saved_tab_groups
commerce
discounts_interactive_uitest.ccprice_insights_icon_view.ccprice_insights_icon_view.hprice_tracking_icon_view.ccprice_tracking_icon_view.h
controls
crostini
desktop_capture
desktop_media_content_pane_view.ccdesktop_media_content_pane_view.hdesktop_media_pane_view.ccdesktop_media_pane_view.hdesktop_media_picker_views_test_api.ccdesktop_media_picker_views_test_api.hdesktop_media_source_view.ccshare_audio_view.ccshare_audio_view.h
download
bubble
download_bubble_password_prompt_view.ccdownload_bubble_password_prompt_view.hdownload_bubble_row_view.ccdownload_bubble_row_view.hdownload_bubble_row_view_unittest.cc
download_item_view.ccextensions
extension_install_dialog_view.ccextensions_menu_button.hextensions_menu_main_page_view.ccextensions_menu_main_page_view.h
find_bar_host.ccfind_bar_host.hfind_bar_view.ccfind_bar_view.hfind_bar_views_interactive_uitest.ccglobal_media_controls
infobars
intent_picker_bubble_view.ccjavascript_tab_modal_dialog_view_views.ccjavascript_tab_modal_dialog_view_views.hlocation_bar
cookie_controls
icon_label_bubble_view.ccicon_label_bubble_view.hlocation_bar_view.cclocation_bar_view.hzoom_bubble_view_browsertest.ccmahi
media_preview
media_router
omnibox
omnibox_popup_view_views.ccomnibox_popup_view_views.homnibox_popup_view_webui.ccomnibox_popup_view_webui.homnibox_text_view.ccomnibox_text_view.homnibox_view_views.ccomnibox_view_views.h
overlay
page_info
chosen_object_view.ccchosen_object_view.hpage_info_bubble_view_unittest.ccpermission_toggle_row_view.hstar_rating_view.ccstar_rating_view.h
passwords
manage_passwords_details_view.ccmanage_passwords_details_view.hpassword_add_username_view.ccviews_utils.cc
payments
contact_info_editor_view_controller.cccontact_info_editor_view_controller.hpayment_request_browsertest_base.ccpayment_request_browsertest_base.hsecure_payment_confirmation_no_creds_dialog_view_browsertest.ccshipping_address_editor_view_controller.ccshipping_address_editor_view_controller.hvalidation_delegate.ccvalidation_delegate.h
performance_controls
profiles
sharing_hub
side_panel
status_bubble_views.cctab_sharing
tabs
fade_label_view.ccfade_label_view.hfilename_elider.ccfilename_elider.htab_group_editor_bubble_view.cctab_group_header.cctab_group_header.htab_hover_card_bubble_view.cctab_hover_card_bubble_view.htab_strip_browsertest.cc
task_manager_search_bar_view.htask_manager_search_bar_view_unittest.cctask_manager_view.cctask_manager_view.htoolbar
pinned_action_toolbar_button.cctoolbar_action_hover_card_bubble_view.cctoolbar_action_hover_card_bubble_view.htoolbar_button.cctoolbar_button.htoolbar_controller.ccwebui_tab_counter_button.cc
user_education
web_apps
frame_toolbar
chromeos
ash
components
components
ui
clipboard_history
components
autofill
core
exo
global_media_controls
public
javascript_dialogs
live_caption
views
media_message_center
media_controls_progress_view.ccmedia_controls_progress_view.hmedia_notification_view_impl.ccmedia_notification_view_impl.h
omnibox
browser
password_manager
user_education
content/browser/renderer_host
render_widget_host_view_mac.hrender_widget_host_view_mac.mmrender_widget_host_view_mac_browsertest.mm
ios/chrome/browser
autofill
omnibox
ui_bundled
ui
actions
base
clipboard
dragdrop
os_exchange_data.ccos_exchange_data.hos_exchange_data_provider.hos_exchange_data_provider_mac.hos_exchange_data_provider_mac.mmos_exchange_data_provider_non_backed.ccos_exchange_data_provider_non_backed.hos_exchange_data_provider_win.ccos_exchange_data_provider_win.h
models
x
gfx
bidi_line_iterator.ccbidi_line_iterator.hcanvas.cccanvas.hcanvas_skia.ccrender_text.ccrender_text.hrender_text_harfbuzz.ccrender_text_harfbuzz.hrender_text_test_api.hrender_text_unittest.cctext_elider.cctext_elider.htext_elider_unittest.cctext_utils.cctext_utils.htext_utils_ios.mmtext_utils_skia.ccutf16_indexing.ccutf16_indexing.h
menus
message_center
fake_message_center.ccfake_message_center.hmessage_center.hmessage_center_impl.ccmessage_center_impl.h
views
views
accessibility
bubble
color_chooser
controls
button
button.cclabel_button.cclabel_button.hlabel_button_label.cclabel_button_label.hmd_text_button.ccmd_text_button.hmenu_button.ccmenu_button.h
editable_combobox
label.cclabel.hlabel_unittest.cclink.cclink.hmessage_box_view.ccmessage_box_view.hstyled_label_unittest.cctabbed_pane
textfield
textfield.cctextfield.htextfield_model.cctextfield_model.htextfield_model_unittest.cctextfield_unittest.cc
tree
views_text_services_context_menu_mac.mmcorewm
examples
actions_example.cccolored_dialog_example.cccolored_dialog_example.hdialog_example.cclogin_bubble_dialog_example.cclogin_bubble_dialog_example.h
interaction
style
window
wm
public
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/accelerators/accelerator_controller_impl.h"
|
||||
#include "ash/accessibility/accessibility_controller.h"
|
||||
#include "ash/accessibility/drag_event_rewriter.h"
|
||||
@ -63,7 +65,7 @@ class TestTextInputView : public views::WidgetDelegateView {
|
||||
}
|
||||
|
||||
void FocusOnTextInput() { text_field_->RequestFocus(); }
|
||||
const std::u16string& GetText() { return text_field_->GetText(); }
|
||||
std::u16string_view GetText() { return text_field_->GetText(); }
|
||||
|
||||
private:
|
||||
raw_ptr<views::Textfield> text_field_; // owned by views hierarchy.
|
||||
@ -141,7 +143,7 @@ class MouseKeysTest : public AshTestBase {
|
||||
return GetBubbleController()->widget_->IsVisible();
|
||||
}
|
||||
|
||||
const std::u16string GetBubbleText() const {
|
||||
std::u16string_view GetBubbleText() const {
|
||||
return GetBubbleView()->GetTextForTesting();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/ambient/ui/media_string_view.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ambient/ambient_constants.h"
|
||||
#include "ash/ambient/test/ambient_ash_test_base.h"
|
||||
@ -37,7 +38,7 @@ class MediaStringViewTest : public AmbientAshTestBase {
|
||||
AmbientAshTestBase::TearDown();
|
||||
}
|
||||
|
||||
const std::u16string& GetText() {
|
||||
std::u16string_view GetText() {
|
||||
return GetMediaStringViewTextLabel()->GetText();
|
||||
}
|
||||
};
|
||||
|
@ -407,13 +407,10 @@ bool AppListTestApi::HasApp(const std::string& app_id) {
|
||||
return GetAppListModel()->FindItem(app_id);
|
||||
}
|
||||
|
||||
std::u16string AppListTestApi::GetAppListItemViewName(
|
||||
std::u16string_view AppListTestApi::GetAppListItemViewName(
|
||||
const std::string& item_id) {
|
||||
AppListItemView* item_view = GetTopLevelItemViewFromId(item_id);
|
||||
if (!item_view)
|
||||
return u"";
|
||||
|
||||
return item_view->title()->GetText();
|
||||
return item_view ? item_view->title()->GetText() : std::u16string_view();
|
||||
}
|
||||
|
||||
AppListItemView* AppListTestApi::GetTopLevelItemViewFromId(
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "ash/app_list/views/app_list_a11y_announcer.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
@ -28,30 +30,30 @@ void AppListA11yAnnouncer::AnnounceAppListShown() {
|
||||
}
|
||||
|
||||
void AppListA11yAnnouncer::AnnounceItemNotificationBadge(
|
||||
const std::u16string& selected_view_title) {
|
||||
std::u16string_view selected_view_title) {
|
||||
Announce(l10n_util::GetStringFUTF16(IDS_APP_LIST_APP_FOCUS_NOTIFICATION_BADGE,
|
||||
selected_view_title));
|
||||
std::u16string(selected_view_title)));
|
||||
}
|
||||
|
||||
void AppListA11yAnnouncer::AnnounceFolderDrop(
|
||||
const std::u16string& moving_view_title,
|
||||
const std::u16string& target_view_title,
|
||||
std::u16string_view moving_view_title,
|
||||
std::u16string_view target_view_title,
|
||||
bool target_is_folder) {
|
||||
Announce(l10n_util::GetStringFUTF16(
|
||||
target_is_folder ? IDS_APP_LIST_APP_DRAG_MOVE_TO_FOLDER_ACCESSIBILE_NAME
|
||||
: IDS_APP_LIST_APP_DRAG_CREATE_FOLDER_ACCESSIBILE_NAME,
|
||||
moving_view_title, target_view_title));
|
||||
std::u16string(moving_view_title), std::u16string(target_view_title)));
|
||||
}
|
||||
|
||||
void AppListA11yAnnouncer::AnnounceKeyboardFoldering(
|
||||
const std::u16string& moving_view_title,
|
||||
const std::u16string& target_view_title,
|
||||
std::u16string_view moving_view_title,
|
||||
std::u16string_view target_view_title,
|
||||
bool target_is_folder) {
|
||||
Announce(l10n_util::GetStringFUTF16(
|
||||
target_is_folder
|
||||
? IDS_APP_LIST_APP_KEYBOARD_MOVE_TO_FOLDER_ACCESSIBILE_NAME
|
||||
: IDS_APP_LIST_APP_KEYBOARD_CREATE_FOLDER_ACCESSIBILE_NAME,
|
||||
moving_view_title, target_view_title));
|
||||
std::u16string(moving_view_title), std::u16string(target_view_title)));
|
||||
}
|
||||
|
||||
void AppListA11yAnnouncer::AnnounceAppsGridReorder(int target_page,
|
||||
@ -76,7 +78,7 @@ void AppListA11yAnnouncer::AnnounceFolderClosed() {
|
||||
IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME));
|
||||
}
|
||||
|
||||
void AppListA11yAnnouncer::Announce(const std::u16string& announcement) {
|
||||
void AppListA11yAnnouncer::Announce(std::u16string_view announcement) {
|
||||
if (!announcement_view_)
|
||||
return;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef ASH_APP_LIST_VIEWS_APP_LIST_A11Y_ANNOUNCER_H_
|
||||
#define ASH_APP_LIST_VIEWS_APP_LIST_A11Y_ANNOUNCER_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
|
||||
@ -36,21 +36,21 @@ class AppListA11yAnnouncer {
|
||||
|
||||
// Modifies the announcement view to verbalize that the focused view has new
|
||||
// updates, based on the item having a notification badge.
|
||||
void AnnounceItemNotificationBadge(const std::u16string& selected_view_title);
|
||||
void AnnounceItemNotificationBadge(std::u16string_view selected_view_title);
|
||||
|
||||
// Modifies the announcement view to verbalize that the current drag will move
|
||||
// |moving_view_title| and create a folder or move it into an existing folder
|
||||
// with |target_view_title|.
|
||||
void AnnounceFolderDrop(const std::u16string& moving_view_title,
|
||||
const std::u16string& target_view_title,
|
||||
void AnnounceFolderDrop(std::u16string_view moving_view_title,
|
||||
std::u16string_view target_view_title,
|
||||
bool target_is_folder);
|
||||
|
||||
// Modifies the announcement view to verbalize that the most recent keyboard
|
||||
// foldering action has either moved |moving_view_title| into
|
||||
// |target_view_title| folder or that |moving_view_title| and
|
||||
// |target_view_title| have formed a new folder.
|
||||
void AnnounceKeyboardFoldering(const std::u16string& moving_view_title,
|
||||
const std::u16string& target_view_title,
|
||||
void AnnounceKeyboardFoldering(std::u16string_view moving_view_title,
|
||||
std::u16string_view target_view_title,
|
||||
bool target_is_folder);
|
||||
|
||||
// Modifies the announcement view to verbalize that an apps grid item has been
|
||||
@ -68,7 +68,7 @@ class AppListA11yAnnouncer {
|
||||
void AnnounceFolderClosed();
|
||||
|
||||
// Modifies the announcement view to verbalize the provided announcement.
|
||||
void Announce(const std::u16string& announcement);
|
||||
void Announce(std::u16string_view announcement);
|
||||
|
||||
private:
|
||||
// The view used to send accessibility announcements. Owned by the parent's
|
||||
|
@ -2316,7 +2316,7 @@ void AppListItemView::UpdateTooltipText() {
|
||||
// truncation in making the tooltip. We do not want the label itself to have a
|
||||
// tooltip, so we only temporarily enable it to get the tooltip text from the
|
||||
// label, then disable it again.
|
||||
std::u16string tooltip = title_->GetComputedTooltip();
|
||||
std::u16string tooltip(title_->GetComputedTooltip());
|
||||
if (new_install_dot_ && new_install_dot_->GetVisible() && !is_folder_) {
|
||||
// Tooltip becomes two lines: "App Name" + "New install".
|
||||
tooltip = l10n_util::GetStringFUTF16(IDS_APP_LIST_NEW_INSTALL, tooltip);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "ash/app_list/views/app_list_search_view.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
@ -190,7 +191,7 @@ class AppListSearchViewTest : public AshTestBase {
|
||||
.value();
|
||||
}
|
||||
|
||||
std::u16string GetListLabel(
|
||||
std::u16string_view GetListLabel(
|
||||
SearchResultContainerView* result_container_view) {
|
||||
return static_cast<SearchResultListView*>(result_container_view)
|
||||
->title_label_for_test()
|
||||
|
@ -1906,10 +1906,10 @@ void AppsGridView::HandleKeyboardFoldering(ui::KeyboardCode key_code) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::u16string moving_view_title = selected_view_->title()->GetText();
|
||||
const std::u16string moving_view_title(selected_view_->title()->GetText());
|
||||
AppListItemView* target_view =
|
||||
GetViewDisplayedAtSlotOnCurrentPage(target_index.slot);
|
||||
const std::u16string target_view_title = target_view->title()->GetText();
|
||||
const std::u16string target_view_title(target_view->title()->GetText());
|
||||
const bool target_view_is_folder = target_view->is_folder();
|
||||
|
||||
std::string folder_id;
|
||||
|
@ -6656,7 +6656,7 @@ TEST_P(AppsGridViewTabletTest, ChangeFolderNameShouldUpdateShadows) {
|
||||
app_list_folder_view()->folder_header_view()->GetFolderNameViewForTest();
|
||||
folder_header->RequestFocus();
|
||||
ASSERT_TRUE(folder_header->HasFocus());
|
||||
const std::u16string folder_name = folder_header->GetText();
|
||||
const std::u16string folder_name(folder_header->GetText());
|
||||
|
||||
GetEventGenerator()->PressAndReleaseKey(ui::VKEY_A);
|
||||
// Force app list to Update Layout to catch potential crashes.
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ash/app_list/app_list_util.h"
|
||||
@ -152,7 +153,7 @@ class FolderHeaderView::FolderNameView : public views::Textfield,
|
||||
void OnBlur() override {
|
||||
UpdateBackgroundColor(/*is_active=*/false);
|
||||
|
||||
folder_header_view_->ContentsChanged(this, GetText());
|
||||
folder_header_view_->ContentsChanged(this, std::u16string(GetText()));
|
||||
|
||||
// Ensure folder name is truncated when FolderNameView loses focus.
|
||||
SetText(folder_header_view_->GetElidedFolderName());
|
||||
@ -493,7 +494,7 @@ void FolderHeaderView::UpdateFolderNameAccessibleName() {
|
||||
folder_name_view_->GetViewAccessibility().SetName(accessible_name);
|
||||
}
|
||||
|
||||
const std::u16string& FolderHeaderView::GetFolderNameForTest() {
|
||||
std::u16string_view FolderHeaderView::GetFolderNameForTest() {
|
||||
return folder_name_view_->GetText();
|
||||
}
|
||||
|
||||
@ -566,9 +567,9 @@ void FolderHeaderView::Layout(PassKey) {
|
||||
|
||||
gfx::Rect text_bounds(rect);
|
||||
|
||||
std::u16string text = folder_name_view_->GetText().empty()
|
||||
? folder_name_placeholder_text_
|
||||
: folder_name_view_->GetText();
|
||||
std::u16string_view text = folder_name_view_->GetText().empty()
|
||||
? folder_name_placeholder_text_
|
||||
: folder_name_view_->GetText();
|
||||
int text_width =
|
||||
gfx::Canvas::GetStringWidth(text, folder_name_view_->GetFontList()) +
|
||||
folder_name_view_->GetCaretBounds().width() +
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/app_list/model/app_list_item_observer.h"
|
||||
#include "ash/ash_export.h"
|
||||
@ -66,7 +67,7 @@ class ASH_EXPORT FolderHeaderView : public views::View,
|
||||
void UpdateFolderNameAccessibleName();
|
||||
|
||||
// Gets and sets the folder name for test.
|
||||
const std::u16string& GetFolderNameForTest();
|
||||
std::u16string_view GetFolderNameForTest();
|
||||
void SetFolderNameForTest(const std::u16string& name);
|
||||
|
||||
// Returns true if folder name is enabled, only for testing use.
|
||||
|
@ -668,7 +668,7 @@ void SearchBoxView::UpdateKeyboardVisibility() {
|
||||
keyboard_controller->HideKeyboardByUser();
|
||||
}
|
||||
|
||||
void SearchBoxView::HandleQueryChange(const std::u16string& query,
|
||||
void SearchBoxView::HandleQueryChange(std::u16string_view query,
|
||||
bool initiated_by_user) {
|
||||
// Randomly select a new placeholder text when we get an empty new query.
|
||||
if (query.empty()) {
|
||||
@ -715,7 +715,7 @@ void SearchBoxView::HandleQueryChange(const std::u16string& query,
|
||||
const bool query_empty_changed =
|
||||
trimmed_query.empty() != IsTrimmedQueryEmpty(current_query_);
|
||||
|
||||
current_query_ = query;
|
||||
current_query_ = std::u16string(query);
|
||||
|
||||
if (query_changed_callback_) {
|
||||
query_changed_callback_.Run();
|
||||
@ -734,8 +734,9 @@ void SearchBoxView::HandleQueryChange(const std::u16string& query,
|
||||
// Don't reinitiate zero state search if the previous query was already empty
|
||||
// (to avoid issuing zero state search twice in a row while clearing up search
|
||||
// - see http://crbug.com/979594).
|
||||
if (initiated_by_user || !trimmed_query.empty() || query_empty_changed)
|
||||
view_delegate_->StartSearch(query);
|
||||
if (initiated_by_user || !trimmed_query.empty() || query_empty_changed) {
|
||||
view_delegate_->StartSearch(current_query_);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchBoxView::SetQueryChangedCallback(QueryChangedCallback callback) {
|
||||
@ -872,7 +873,7 @@ void SearchBoxView::AddedToWidget() {
|
||||
}
|
||||
}
|
||||
|
||||
void SearchBoxView::RunLauncherSearchQuery(const std::u16string& query) {
|
||||
void SearchBoxView::RunLauncherSearchQuery(std::u16string_view query) {
|
||||
UpdateQuery(query);
|
||||
}
|
||||
|
||||
@ -882,7 +883,7 @@ void SearchBoxView::OpenAssistantPage() {
|
||||
assistant::AssistantEntryPoint::kLauncherSearchIphChip);
|
||||
}
|
||||
|
||||
void SearchBoxView::OnLauncherSearchChipPressed(const std::u16string& query) {
|
||||
void SearchBoxView::OnLauncherSearchChipPressed(std::u16string_view query) {
|
||||
view_delegate_->EndAssistant(
|
||||
assistant::AssistantExitPoint::kLauncherSearchIphChip);
|
||||
UpdateQuery(query);
|
||||
@ -1111,8 +1112,8 @@ void SearchBoxView::ProcessAutocomplete(
|
||||
}
|
||||
|
||||
// Current non-autocompleted text.
|
||||
const std::u16string& user_typed_text =
|
||||
search_box()->GetText().substr(0, highlight_range_.start());
|
||||
std::u16string user_typed_text(
|
||||
search_box()->GetText().substr(0, highlight_range_.start()));
|
||||
if (last_key_pressed_ == ui::VKEY_BACK ||
|
||||
last_key_pressed_ == ui::VKEY_DELETE || IsArrowKey(last_key_pressed_) ||
|
||||
!first_visible_result ||
|
||||
@ -1404,7 +1405,7 @@ void SearchBoxView::SetAutocompleteText(
|
||||
// Clear existing autocomplete text and reset the highlight range.
|
||||
ClearAutocompleteText();
|
||||
|
||||
const std::u16string& current_text = search_box()->GetText();
|
||||
std::u16string_view current_text = search_box()->GetText();
|
||||
// Currrent text is a prefix of autocomplete text.
|
||||
DCHECK(base::StartsWith(autocomplete_text, current_text,
|
||||
base::CompareCase::INSENSITIVE_ASCII));
|
||||
@ -1460,12 +1461,12 @@ SearchBoxView::PlaceholderTextType SearchBoxView::SelectPlaceholderText()
|
||||
return kDefaultPlaceholders[rand() % std::size(kDefaultPlaceholders)];
|
||||
}
|
||||
|
||||
void SearchBoxView::UpdateQuery(const std::u16string& new_query) {
|
||||
void SearchBoxView::UpdateQuery(std::u16string_view new_query) {
|
||||
SetText(new_query);
|
||||
ContentsChanged(search_box(), new_query);
|
||||
ContentsChanged(search_box(), std::u16string(new_query));
|
||||
}
|
||||
|
||||
void SearchBoxView::SetText(const std::u16string& text) {
|
||||
void SearchBoxView::SetText(std::u16string_view text) {
|
||||
search_box()->SetText(text);
|
||||
UpdateAccessibleValue();
|
||||
}
|
||||
@ -1914,8 +1915,9 @@ void SearchBoxView::UpdateAccessibleValue() {
|
||||
GetViewAccessibility().RemoveValue();
|
||||
return;
|
||||
}
|
||||
GetViewAccessibility().SetValue(l10n_util::GetStringFUTF16(
|
||||
IDS_APP_LIST_SEARCH_BOX_AUTOCOMPLETE, search_box()->GetText()));
|
||||
GetViewAccessibility().SetValue(
|
||||
l10n_util::GetStringFUTF16(IDS_APP_LIST_SEARCH_BOX_AUTOCOMPLETE,
|
||||
std::u16string(search_box()->GetText())));
|
||||
}
|
||||
|
||||
BEGIN_METADATA(SearchBoxView)
|
||||
|
@ -93,7 +93,7 @@ class ASH_EXPORT SearchBoxView : public SearchBoxViewBase,
|
||||
// Overridden from SearchBoxViewBase:
|
||||
void UpdateSearchTextfieldAccessibleActiveDescendantId() override;
|
||||
void UpdateKeyboardVisibility() override;
|
||||
void HandleQueryChange(const std::u16string& query,
|
||||
void HandleQueryChange(std::u16string_view query,
|
||||
bool initiated_by_user) override;
|
||||
void UpdatePlaceholderTextStyle() override;
|
||||
void UpdateSearchBoxBorder() override;
|
||||
@ -114,11 +114,11 @@ class ASH_EXPORT SearchBoxView : public SearchBoxViewBase,
|
||||
void AddedToWidget() override;
|
||||
|
||||
// LauncherSearchIphView::Delegate:
|
||||
void RunLauncherSearchQuery(const std::u16string& query) override;
|
||||
void RunLauncherSearchQuery(std::u16string_view query) override;
|
||||
void OpenAssistantPage() override;
|
||||
|
||||
// AssistantViewDelegateObserver:
|
||||
void OnLauncherSearchChipPressed(const std::u16string& query) override;
|
||||
void OnLauncherSearchChipPressed(std::u16string_view query) override;
|
||||
|
||||
// Shows the category filter menu that allows users to enable/disable specific
|
||||
// search categories.
|
||||
@ -161,7 +161,7 @@ class ASH_EXPORT SearchBoxView : public SearchBoxViewBase,
|
||||
void ClearAutocompleteText();
|
||||
|
||||
// Updates the search box with |new_query| and starts a new search.
|
||||
void UpdateQuery(const std::u16string& new_query);
|
||||
void UpdateQuery(std::u16string_view new_query);
|
||||
|
||||
// Moves the focus back to search box and find a search result to select.
|
||||
void EnterSearchResultSelection(const ui::KeyEvent& event);
|
||||
@ -278,7 +278,7 @@ class ASH_EXPORT SearchBoxView : public SearchBoxViewBase,
|
||||
void UpdateAccessibleValue();
|
||||
|
||||
// Updates the search box's text value.
|
||||
void SetText(const std::u16string& text);
|
||||
void SetText(std::u16string_view text);
|
||||
|
||||
// Builds the menu model for the category filter menu. This returns a vector
|
||||
// of AppListSearchControlCategory that is shown in the filter menu.
|
||||
|
@ -932,15 +932,13 @@ TEST_F(SearchBoxViewAutocompleteTest, SearchBoxAutocompletesAcceptsNextChar) {
|
||||
|
||||
// After typing L, the highlighted text will be replaced by L.
|
||||
KeyPress(ui::VKEY_L);
|
||||
std::u16string selected_text = view()->search_box()->GetSelectedText();
|
||||
EXPECT_EQ(view()->search_box()->GetText(), u"hel");
|
||||
EXPECT_EQ(u"", selected_text);
|
||||
EXPECT_EQ(view()->search_box()->GetSelectedText(), u"");
|
||||
|
||||
// After handling autocomplete, the highlighted text will show again.
|
||||
ProcessAutocomplete();
|
||||
selected_text = view()->search_box()->GetSelectedText();
|
||||
EXPECT_EQ(view()->search_box()->GetText(), u"hello world!");
|
||||
EXPECT_EQ(u"lo world!", selected_text);
|
||||
EXPECT_EQ(view()->search_box()->GetSelectedText(), u"lo world!");
|
||||
|
||||
EXPECT_EQ("Websites", view()->GetSearchBoxGhostTextForTest());
|
||||
}
|
||||
@ -1035,9 +1033,8 @@ TEST_F(SearchBoxViewAutocompleteTest, SearchBoxAutocompletesNotHandledForIME) {
|
||||
|
||||
ProcessAutocomplete();
|
||||
|
||||
std::u16string selected_text = view()->search_box()->GetSelectedText();
|
||||
EXPECT_EQ(view()->search_box()->GetText(), u"hello world!");
|
||||
EXPECT_EQ(u"llo world!", selected_text);
|
||||
EXPECT_EQ(view()->search_box()->GetSelectedText(), u"llo world!");
|
||||
view()->search_box()->SetText(std::u16string());
|
||||
|
||||
// Simulate IME composition text. The autocomplete should not be handled.
|
||||
@ -1047,9 +1044,8 @@ TEST_F(SearchBoxViewAutocompleteTest, SearchBoxAutocompletesNotHandledForIME) {
|
||||
view()->set_highlight_range_for_test(gfx::Range(2, 2));
|
||||
ProcessAutocomplete();
|
||||
|
||||
selected_text = view()->search_box()->GetSelectedText();
|
||||
EXPECT_EQ(view()->search_box()->GetText(), u"he");
|
||||
EXPECT_EQ(u"", selected_text);
|
||||
EXPECT_EQ(view()->search_box()->GetSelectedText(), u"");
|
||||
|
||||
EXPECT_EQ("", view()->GetSearchBoxGhostTextForTest());
|
||||
}
|
||||
@ -1312,8 +1308,9 @@ TEST_F(SearchBoxViewAutocompleteTest, AccessibleValue) {
|
||||
ui::AXNodeData data;
|
||||
view()->GetViewAccessibility().GetAccessibleNodeData(&data);
|
||||
EXPECT_EQ(view()->search_box()->GetText(), u"hello list");
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_APP_LIST_SEARCH_BOX_AUTOCOMPLETE,
|
||||
view()->search_box()->GetText()),
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(
|
||||
IDS_APP_LIST_SEARCH_BOX_AUTOCOMPLETE,
|
||||
std::u16string(view()->search_box()->GetText())),
|
||||
data.GetString16Attribute(ax::mojom::StringAttribute::kValue));
|
||||
|
||||
EXPECT_EQ("Websites", view()->GetSearchBoxGhostTextForTest());
|
||||
@ -1323,8 +1320,9 @@ TEST_F(SearchBoxViewAutocompleteTest, AccessibleValue) {
|
||||
ui::AXNodeData data2;
|
||||
view()->GetViewAccessibility().GetAccessibleNodeData(&data2);
|
||||
EXPECT_EQ(view()->search_box()->GetText(), u"hello list2");
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_APP_LIST_SEARCH_BOX_AUTOCOMPLETE,
|
||||
view()->search_box()->GetText()),
|
||||
EXPECT_EQ(l10n_util::GetStringFUTF16(
|
||||
IDS_APP_LIST_SEARCH_BOX_AUTOCOMPLETE,
|
||||
std::u16string(view()->search_box()->GetText())),
|
||||
data2.GetString16Attribute(ax::mojom::StringAttribute::kValue));
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ SearchResultImageListView::SearchResultImageListView(
|
||||
GetViewAccessibility().SetRole(ax::mojom::Role::kListBox);
|
||||
GetViewAccessibility().SetName(l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_SEARCH_RESULT_CATEGORY_LABEL_ACCESSIBLE_NAME,
|
||||
title_label_->GetText()));
|
||||
std::u16string(title_label_->GetText())));
|
||||
|
||||
image_view_container_ =
|
||||
AddChildView(std::make_unique<views::FlexLayoutView>());
|
||||
|
@ -199,7 +199,7 @@ void SearchResultListView::SetListType(SearchResultListType list_type) {
|
||||
GetViewAccessibility().SetName(
|
||||
l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_SEARCH_RESULT_CATEGORY_LABEL_ACCESSIBLE_NAME,
|
||||
title_label_->GetText()),
|
||||
std::u16string(title_label_->GetText())),
|
||||
ax::mojom::NameFrom::kAttribute);
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "ash/app_menu/notification_menu_view_test_api.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/app_menu/notification_item_view.h"
|
||||
#include "ash/app_menu/notification_menu_header_view.h"
|
||||
#include "ash/app_menu/notification_menu_view.h"
|
||||
@ -19,7 +21,8 @@ NotificationMenuViewTestAPI::NotificationMenuViewTestAPI(
|
||||
|
||||
NotificationMenuViewTestAPI::~NotificationMenuViewTestAPI() = default;
|
||||
|
||||
std::u16string NotificationMenuViewTestAPI::GetCounterViewContents() const {
|
||||
std::u16string_view NotificationMenuViewTestAPI::GetCounterViewContents()
|
||||
const {
|
||||
return notification_menu_view_->header_view_->counter_->GetText();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef ASH_APP_MENU_NOTIFICATION_MENU_VIEW_TEST_API_H_
|
||||
#define ASH_APP_MENU_NOTIFICATION_MENU_VIEW_TEST_API_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
|
||||
@ -27,7 +27,7 @@ class NotificationMenuViewTestAPI {
|
||||
~NotificationMenuViewTestAPI();
|
||||
|
||||
// Returns the numeric string contained in the counter view.
|
||||
std::u16string GetCounterViewContents() const;
|
||||
std::u16string_view GetCounterViewContents() const;
|
||||
|
||||
// Returns the number of NotificationItemViews.
|
||||
int GetItemViewCount() const;
|
||||
|
@ -158,7 +158,7 @@ bool AssistantViewDelegateImpl::ShouldShowOnboarding() const {
|
||||
}
|
||||
|
||||
void AssistantViewDelegateImpl::OnLauncherSearchChipPressed(
|
||||
const std::u16string& query) {
|
||||
std::u16string_view query) {
|
||||
for (auto& observer : view_delegate_observers_) {
|
||||
observer.OnLauncherSearchChipPressed(query);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class AssistantViewDelegateImpl : public AssistantViewDelegate {
|
||||
void OnSuggestionPressed(
|
||||
const base::UnguessableToken& suggestion_id) override;
|
||||
bool ShouldShowOnboarding() const override;
|
||||
void OnLauncherSearchChipPressed(const std::u16string& query) override;
|
||||
void OnLauncherSearchChipPressed(std::u16string_view query) override;
|
||||
|
||||
private:
|
||||
const raw_ptr<AssistantControllerImpl> assistant_controller_;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/public/cpp/assistant/assistant_state.h"
|
||||
#include "ash/public/cpp/image_downloader.h"
|
||||
@ -48,7 +49,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantViewDelegateObserver
|
||||
const base::UnguessableToken& suggestion_id) {}
|
||||
|
||||
// Invoked when a launcher search chip is pressed.
|
||||
virtual void OnLauncherSearchChipPressed(const std::u16string& query) {}
|
||||
virtual void OnLauncherSearchChipPressed(std::u16string_view query) {}
|
||||
};
|
||||
|
||||
// A delegate of views in assistant/ui that handles views related actions e.g.
|
||||
@ -112,7 +113,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantViewDelegate {
|
||||
virtual bool ShouldShowOnboarding() const = 0;
|
||||
|
||||
// Invoked when a launcher search chip is pressed.
|
||||
virtual void OnLauncherSearchChipPressed(const std::u16string& query) = 0;
|
||||
virtual void OnLauncherSearchChipPressed(std::u16string_view query) = 0;
|
||||
};
|
||||
|
||||
} // namespace ash
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "ash/assistant/ui/main_stage/assistant_onboarding_suggestion_view.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/assistant/ui/assistant_ui_constants.h"
|
||||
#include "ash/assistant/ui/assistant_view_delegate.h"
|
||||
#include "ash/assistant/ui/assistant_view_ids.h"
|
||||
@ -174,7 +176,7 @@ gfx::ImageSkia AssistantOnboardingSuggestionView::GetIcon() const {
|
||||
return icon_->GetImage();
|
||||
}
|
||||
|
||||
const std::u16string& AssistantOnboardingSuggestionView::GetText() const {
|
||||
std::u16string_view AssistantOnboardingSuggestionView::GetText() const {
|
||||
return label_->GetText();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef ASH_ASSISTANT_UI_MAIN_STAGE_ASSISTANT_ONBOARDING_SUGGESTION_VIEW_H_
|
||||
#define ASH_ASSISTANT_UI_MAIN_STAGE_ASSISTANT_ONBOARDING_SUGGESTION_VIEW_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/unguessable_token.h"
|
||||
@ -53,7 +55,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantOnboardingSuggestionView
|
||||
gfx::ImageSkia GetIcon() const;
|
||||
|
||||
// Returns the text for the suggestion.
|
||||
const std::u16string& GetText() const;
|
||||
std::u16string_view GetText() const;
|
||||
|
||||
private:
|
||||
void InitLayout(const assistant::AssistantSuggestion& suggestion);
|
||||
|
@ -163,8 +163,7 @@ void AssistantZeroStateView::UpdateLayout() {
|
||||
iph_view_->SetVisible(show_iph);
|
||||
}
|
||||
|
||||
void AssistantZeroStateView::RunLauncherSearchQuery(
|
||||
const std::u16string& query) {
|
||||
void AssistantZeroStateView::RunLauncherSearchQuery(std::u16string_view query) {
|
||||
delegate_->OnLauncherSearchChipPressed(query);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AssistantZeroStateView
|
||||
std::optional<AssistantExitPoint> exit_point) override;
|
||||
|
||||
// LauncherSearchIphView::Delegate:
|
||||
void RunLauncherSearchQuery(const std::u16string& query) override;
|
||||
void RunLauncherSearchQuery(std::u16string_view query) override;
|
||||
void OpenAssistantPage() override;
|
||||
|
||||
private:
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/assistant/ui/main_stage/chip_view.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/assistant/ui/assistant_ui_constants.h"
|
||||
#include "ash/assistant/ui/assistant_view_ids.h"
|
||||
@ -190,7 +191,7 @@ void ChipView::SetText(const std::u16string& text) {
|
||||
GetViewAccessibility().SetName(text);
|
||||
}
|
||||
|
||||
const std::u16string& ChipView::GetText() const {
|
||||
std::u16string_view ChipView::GetText() const {
|
||||
return text_view_->GetText();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef ASH_ASSISTANT_UI_MAIN_STAGE_CHIP_VIEW_H_
|
||||
#define ASH_ASSISTANT_UI_MAIN_STAGE_CHIP_VIEW_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/component_export.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
@ -41,7 +43,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) ChipView : public views::Button {
|
||||
gfx::ImageSkia GetIcon() const;
|
||||
|
||||
void SetText(const std::u16string& text);
|
||||
const std::u16string& GetText() const;
|
||||
std::u16string_view GetText() const;
|
||||
|
||||
private:
|
||||
const Type type_;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ash/assistant/ui/main_stage/chip_view.h"
|
||||
@ -239,7 +240,7 @@ void LauncherSearchIphView::NotifyAssistantButtonPressedEvent() {
|
||||
}
|
||||
}
|
||||
|
||||
std::u16string LauncherSearchIphView::GetTitleText() const {
|
||||
std::u16string_view LauncherSearchIphView::GetTitleText() const {
|
||||
return title_label_->GetText();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/public/cpp/app_list/app_list_client.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -35,7 +36,7 @@ class LauncherSearchIphView : public views::View {
|
||||
public:
|
||||
virtual ~Delegate() = default;
|
||||
// Run `query` as a launcher search. `query` is localized.
|
||||
virtual void RunLauncherSearchQuery(const std::u16string& query) = 0;
|
||||
virtual void RunLauncherSearchQuery(std::u16string_view query) = 0;
|
||||
// Opens Assistant page in the launcher.
|
||||
virtual void OpenAssistantPage() = 0;
|
||||
};
|
||||
@ -76,7 +77,7 @@ class LauncherSearchIphView : public views::View {
|
||||
|
||||
void NotifyAssistantButtonPressedEvent();
|
||||
|
||||
std::u16string GetTitleText() const;
|
||||
std::u16string_view GetTitleText() const;
|
||||
|
||||
std::vector<raw_ptr<ChipView>> GetChipsForTesting();
|
||||
views::View* GetAssistantButtonForTesting();
|
||||
|
@ -82,7 +82,7 @@ class COMPONENT_EXPORT(ASSISTANT_UI) MockAssistantViewDelegate
|
||||
|
||||
MOCK_METHOD(void,
|
||||
OnLauncherSearchChipPressed,
|
||||
(const std::u16string&),
|
||||
(std::u16string_view),
|
||||
(override));
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/auth/views/active_session_auth_view.h"
|
||||
#include "ash/auth/views/auth_common.h"
|
||||
@ -217,7 +218,7 @@ void ActiveSessionAuthControllerImpl::TestApi::SetPinStatus(
|
||||
controller_->contents_view_->SetPinStatus(std::move(pin_status));
|
||||
}
|
||||
|
||||
const std::u16string&
|
||||
std::u16string_view
|
||||
ActiveSessionAuthControllerImpl::TestApi::GetPinStatusMessage() const {
|
||||
return controller_->contents_view_->GetPinStatusMessage();
|
||||
}
|
||||
@ -511,7 +512,7 @@ void ActiveSessionAuthControllerImpl::MoveToTheCenter() {
|
||||
}
|
||||
|
||||
void ActiveSessionAuthControllerImpl::OnPasswordSubmit(
|
||||
const std::u16string& password) {
|
||||
std::u16string_view password) {
|
||||
if (IsSucceedState()) {
|
||||
return;
|
||||
}
|
||||
@ -530,7 +531,7 @@ void ActiveSessionAuthControllerImpl::OnPasswordSubmit(
|
||||
weak_ptr_factory_.GetWeakPtr(), AuthInputType::kPassword));
|
||||
}
|
||||
|
||||
void ActiveSessionAuthControllerImpl::OnPinSubmit(const std::u16string& pin) {
|
||||
void ActiveSessionAuthControllerImpl::OnPinSubmit(std::u16string_view pin) {
|
||||
if (IsSucceedState()) {
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/active_session_auth_metrics_recorder.h"
|
||||
@ -63,7 +64,7 @@ class ASH_EXPORT ActiveSessionAuthControllerImpl
|
||||
|
||||
void SetPinStatus(std::unique_ptr<cryptohome::PinStatus> pin_status);
|
||||
|
||||
const std::u16string& GetPinStatusMessage() const;
|
||||
std::u16string_view GetPinStatusMessage() const;
|
||||
|
||||
void Close();
|
||||
|
||||
@ -88,8 +89,8 @@ class ASH_EXPORT ActiveSessionAuthControllerImpl
|
||||
void OnViewPreferredSizeChanged(views::View* observed_view) override;
|
||||
|
||||
// ActiveSessionAuthView::Observer:
|
||||
void OnPasswordSubmit(const std::u16string& password) override;
|
||||
void OnPinSubmit(const std::u16string& pin) override;
|
||||
void OnPasswordSubmit(std::u16string_view password) override;
|
||||
void OnPinSubmit(std::u16string_view pin) override;
|
||||
void OnClose() override;
|
||||
|
||||
// UserDataAuthClient::AuthFactorStatusUpdateObserver:
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/auth/views/auth_input_row_view.h"
|
||||
#include "ash/auth/views/auth_view_utils.h"
|
||||
@ -249,7 +250,7 @@ void ActiveSessionAuthView::SetPinStatus(
|
||||
auth_container_->SetPinStatus(std::move(pin_status));
|
||||
}
|
||||
|
||||
const std::u16string& ActiveSessionAuthView::GetPinStatusMessage() const {
|
||||
std::u16string_view ActiveSessionAuthView::GetPinStatusMessage() const {
|
||||
return auth_container_->GetPinStatusMessage();
|
||||
}
|
||||
|
||||
@ -260,13 +261,13 @@ void ActiveSessionAuthView::SetInputEnabled(bool enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
void ActiveSessionAuthView::OnPinSubmit(const std::u16string& pin) {
|
||||
void ActiveSessionAuthView::OnPinSubmit(std::u16string_view pin) {
|
||||
for (auto& observer : observers_) {
|
||||
observer.OnPinSubmit(pin);
|
||||
}
|
||||
}
|
||||
|
||||
void ActiveSessionAuthView::OnPasswordSubmit(const std::u16string& password) {
|
||||
void ActiveSessionAuthView::OnPasswordSubmit(std::u16string_view password) {
|
||||
for (auto& observer : observers_) {
|
||||
observer.OnPasswordSubmit(password);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_container_view.h"
|
||||
@ -46,8 +47,8 @@ class ASH_EXPORT ActiveSessionAuthView : public views::View,
|
||||
// request)
|
||||
class Observer : public base::CheckedObserver {
|
||||
public:
|
||||
virtual void OnPasswordSubmit(const std::u16string& password) {}
|
||||
virtual void OnPinSubmit(const std::u16string& pin) {}
|
||||
virtual void OnPasswordSubmit(std::u16string_view password) {}
|
||||
virtual void OnPinSubmit(std::u16string_view pin) {}
|
||||
virtual void OnClose() {}
|
||||
};
|
||||
|
||||
@ -86,8 +87,8 @@ class ASH_EXPORT ActiveSessionAuthView : public views::View,
|
||||
void RequestFocus() override;
|
||||
|
||||
// AuthContainerView::Observer:
|
||||
void OnPasswordSubmit(const std::u16string& password) override;
|
||||
void OnPinSubmit(const std::u16string& pin) override;
|
||||
void OnPasswordSubmit(std::u16string_view password) override;
|
||||
void OnPinSubmit(std::u16string_view pin) override;
|
||||
void OnEscape() override;
|
||||
void OnContentsChanged() override;
|
||||
|
||||
@ -102,7 +103,7 @@ class ASH_EXPORT ActiveSessionAuthView : public views::View,
|
||||
void SetHasPin(bool has_pin);
|
||||
bool HasPin() const;
|
||||
void SetPinStatus(std::unique_ptr<cryptohome::PinStatus> pin_status);
|
||||
const std::u16string& GetPinStatusMessage() const;
|
||||
std::u16string_view GetPinStatusMessage() const;
|
||||
|
||||
// Enables or disables the input area of the view. The header area (e.g.,
|
||||
// close button) remains accessible even in the disabled state.
|
||||
|
@ -148,7 +148,7 @@ TEST_F(ActiveSessionAuthViewUnitTest, CloseButtonWithDisabledInputTest) {
|
||||
|
||||
// Verify password submit observer.
|
||||
TEST_F(ActiveSessionAuthViewUnitTest, PasswordSubmitTest) {
|
||||
const std::u16string kPassword(u"password");
|
||||
static constexpr std::u16string_view kPassword(u"password");
|
||||
EXPECT_CALL(*mock_observer_, OnPasswordSubmit(kPassword)).Times(1);
|
||||
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
@ -167,7 +167,7 @@ TEST_F(ActiveSessionAuthViewUnitTest, PasswordSubmitTest) {
|
||||
|
||||
// Verify the password input is no op with disabled input area.
|
||||
TEST_F(ActiveSessionAuthViewUnitTest, PasswordSubmitWithDisabledInputTest) {
|
||||
const std::u16string kPassword(u"password");
|
||||
static constexpr std::u16string_view kPassword(u"password");
|
||||
EXPECT_CALL(*mock_observer_, OnPasswordSubmit(kPassword)).Times(0);
|
||||
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
@ -194,7 +194,7 @@ TEST_F(ActiveSessionAuthViewUnitTest, PinSubmitTest) {
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
test_api_pin_input_->GetTextfield());
|
||||
|
||||
const std::u16string kPin(u"6893112");
|
||||
static constexpr std::u16string_view kPin(u"6893112");
|
||||
EXPECT_CALL(*mock_observer_, OnPinSubmit(kPin)).Times(1);
|
||||
|
||||
for (const char16_t c : kPin) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/auth/views/auth_input_row_view.h"
|
||||
#include "ash/auth/views/auth_view_utils.h"
|
||||
@ -58,13 +59,13 @@ class PinObserverAdapter : public PinContainerView::Observer {
|
||||
PinObserverAdapter& operator=(const PinObserverAdapter&) = delete;
|
||||
|
||||
// PinContainerView::Observer:
|
||||
void OnSubmit(const std::u16string& text) override {
|
||||
void OnSubmit(std::u16string_view text) override {
|
||||
auth_container_->PinSubmit(text);
|
||||
}
|
||||
|
||||
void OnEscape() override { auth_container_->Escape(); }
|
||||
|
||||
void OnContentsChanged(const std::u16string& text) override {
|
||||
void OnContentsChanged(std::u16string_view text) override {
|
||||
auth_container_->ContentsChanged();
|
||||
}
|
||||
|
||||
@ -85,13 +86,13 @@ class PasswordObserverAdapter : public AuthInputRowView::Observer {
|
||||
PasswordObserverAdapter& operator=(const PasswordObserverAdapter&) = delete;
|
||||
|
||||
// AuthInputRowView::Observer:
|
||||
void OnSubmit(const std::u16string& text) override {
|
||||
void OnSubmit(std::u16string_view text) override {
|
||||
auth_container_->PasswordSubmit(text);
|
||||
}
|
||||
|
||||
void OnEscape() override { auth_container_->Escape(); }
|
||||
|
||||
void OnContentsChanged(const std::u16string& text) override {
|
||||
void OnContentsChanged(std::u16string_view text) override {
|
||||
auth_container_->ContentsChanged();
|
||||
}
|
||||
|
||||
@ -324,7 +325,7 @@ void AuthContainerView::SetPinStatus(
|
||||
PreferredSizeChanged();
|
||||
}
|
||||
|
||||
const std::u16string& AuthContainerView::GetPinStatusMessage() const {
|
||||
std::u16string_view AuthContainerView::GetPinStatusMessage() const {
|
||||
return pin_status_->GetCurrentText();
|
||||
}
|
||||
|
||||
@ -424,13 +425,13 @@ void AuthContainerView::UpdateSwitchButtonState() {
|
||||
}
|
||||
}
|
||||
|
||||
void AuthContainerView::PinSubmit(const std::u16string& pin) const {
|
||||
void AuthContainerView::PinSubmit(std::u16string_view pin) const {
|
||||
for (auto& observer : observers_) {
|
||||
observer.OnPinSubmit(pin);
|
||||
}
|
||||
}
|
||||
|
||||
void AuthContainerView::PasswordSubmit(const std::u16string& password) const {
|
||||
void AuthContainerView::PasswordSubmit(std::u16string_view password) const {
|
||||
for (auto& observer : observers_) {
|
||||
observer.OnPasswordSubmit(password);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_common.h"
|
||||
@ -46,8 +47,8 @@ class ASH_EXPORT AuthContainerView : public views::View {
|
||||
// (e.g., password submission, PIN submission, etc.)
|
||||
class Observer : public base::CheckedObserver {
|
||||
public:
|
||||
virtual void OnPasswordSubmit(const std::u16string& password) {}
|
||||
virtual void OnPinSubmit(const std::u16string& pin) {}
|
||||
virtual void OnPasswordSubmit(std::u16string_view password) {}
|
||||
virtual void OnPinSubmit(std::u16string_view pin) {}
|
||||
// Escape key was pressed.
|
||||
virtual void OnEscape() {}
|
||||
// Something happened on the view e.g: the switch button was pressed or the
|
||||
@ -104,7 +105,7 @@ class ASH_EXPORT AuthContainerView : public views::View {
|
||||
void SetHasPin(bool has_pin);
|
||||
bool HasPin() const;
|
||||
void SetPinStatus(std::unique_ptr<cryptohome::PinStatus> pin_status);
|
||||
const std::u16string& GetPinStatusMessage() const;
|
||||
std::u16string_view GetPinStatusMessage() const;
|
||||
|
||||
// Enables or disables the following UI elements:
|
||||
// - View
|
||||
@ -117,8 +118,8 @@ class ASH_EXPORT AuthContainerView : public views::View {
|
||||
|
||||
// Actions:
|
||||
void ToggleCurrentAuthType();
|
||||
void PinSubmit(const std::u16string& pin) const;
|
||||
void PasswordSubmit(const std::u16string& password) const;
|
||||
void PinSubmit(std::u16string_view pin) const;
|
||||
void PasswordSubmit(std::u16string_view password) const;
|
||||
void Escape() const;
|
||||
void ContentsChanged() const;
|
||||
// Reset the input fields text and visibility.
|
||||
|
@ -118,7 +118,7 @@ TEST_F(AuthContainerWithPasswordAndPinTest, PinUITestWithPinPad) {
|
||||
EXPECT_THAT(test_api_->GetCurrentInputType(),
|
||||
testing::Optional(AuthInputType::kPassword));
|
||||
|
||||
const std::u16string kPin(u"6893112");
|
||||
static constexpr std::u16string_view kPin(u"6893112");
|
||||
// The auth container content changes kPin times because of the input changes
|
||||
// + 1 times since at the beginning we switching from password to pin.
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged()).Times(kPin.size() + 1);
|
||||
@ -151,7 +151,7 @@ TEST_F(AuthContainerWithPasswordAndPinTest, PinUITestWithKeyPress) {
|
||||
EXPECT_TRUE(test_api_->GetCurrentInputType().has_value());
|
||||
EXPECT_EQ(test_api_->GetCurrentInputType(), AuthInputType::kPassword);
|
||||
|
||||
const std::u16string kPin(u"6893112");
|
||||
static constexpr std::u16string_view kPin(u"6893112");
|
||||
// The auth container content changes kPin times because of the input changes
|
||||
// + 1 times since at the beginning we switching from password to pin.
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged()).Times(kPin.size() + 1);
|
||||
@ -231,7 +231,7 @@ TEST_F(AuthContainerWithPasswordAndPinTest, DoubleSwitchTest) {
|
||||
}
|
||||
|
||||
TEST_F(AuthContainerWithPasswordAndPinTest, PasswordSubmitTest) {
|
||||
const std::u16string kPassword(u"password");
|
||||
static constexpr std::u16string_view kPassword(u"password");
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
test_api_password_->GetTextfield());
|
||||
for (const char16_t c : kPassword) {
|
||||
@ -249,7 +249,7 @@ TEST_F(AuthContainerWithPasswordAndPinTest, PasswordSubmitTest) {
|
||||
// Verify password is not functioning with disabled input area.
|
||||
TEST_F(AuthContainerWithPasswordAndPinTest, DisabledPasswordSubmitTest) {
|
||||
container_view_->SetInputEnabled(false);
|
||||
const std::u16string kPassword(u"password");
|
||||
static constexpr std::u16string_view kPassword(u"password");
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
test_api_password_->GetTextfield());
|
||||
for (const char16_t c : kPassword) {
|
||||
@ -259,7 +259,8 @@ TEST_F(AuthContainerWithPasswordAndPinTest, DisabledPasswordSubmitTest) {
|
||||
EXPECT_EQ(test_api_pin_input_->GetTextfield()->GetText(), std::u16string());
|
||||
EXPECT_EQ(test_api_password_->GetTextfield()->GetText(), std::u16string());
|
||||
|
||||
EXPECT_CALL(*mock_observer_, OnPasswordSubmit(std::u16string())).Times(0);
|
||||
EXPECT_CALL(*mock_observer_, OnPasswordSubmit(std::u16string_view()))
|
||||
.Times(0);
|
||||
// Click on Submit.
|
||||
LeftClickOn(test_api_password_->GetSubmitButton());
|
||||
}
|
||||
@ -316,7 +317,8 @@ TEST_F(AuthContainerWithPasswordAndPinTest, ResetInputfieldsWithSwitchTest) {
|
||||
}
|
||||
|
||||
TEST_F(AuthContainerWithPasswordAndPinTest, SetPinStatusTest) {
|
||||
const std::u16string status_message = u"Too many PIN attempts";
|
||||
static constexpr std::u16string_view status_message =
|
||||
u"Too many PIN attempts";
|
||||
|
||||
cryptohome::PinStatus pin_status(base::TimeDelta::Max());
|
||||
|
||||
@ -376,7 +378,7 @@ class AuthContainerWithPinTest : public AuthContainerBaseUnitTest {
|
||||
};
|
||||
|
||||
TEST_F(AuthContainerWithPinTest, PinSubmitTest) {
|
||||
const std::u16string kPin(u"6893112");
|
||||
static constexpr std::u16string_view kPin(u"6893112");
|
||||
// The auth container content changes kPin times because of the input changes
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged()).Times(kPin.size());
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "ash/auth/views/auth_header_view.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/login/ui/animated_rounded_image_view.h"
|
||||
#include "ash/login/ui/non_accessible_view.h"
|
||||
@ -50,7 +52,7 @@ AuthHeaderView::TestApi::~TestApi() = default;
|
||||
AuthHeaderView::Observer::Observer() = default;
|
||||
AuthHeaderView::Observer::~Observer() = default;
|
||||
|
||||
const std::u16string& AuthHeaderView::TestApi::GetCurrentTitle() const {
|
||||
std::u16string_view AuthHeaderView::TestApi::GetCurrentTitle() const {
|
||||
return view_->title_label_->GetText();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_AUTH_VIEWS_AUTH_HEADER_VIEW_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/login/ui/animated_rounded_image_view.h"
|
||||
@ -34,7 +35,7 @@ class ASH_EXPORT AuthHeaderView : public views::View {
|
||||
TestApi(const TestApi&) = delete;
|
||||
TestApi& operator=(const TestApi&) = delete;
|
||||
|
||||
const std::u16string& GetCurrentTitle() const;
|
||||
std::u16string_view GetCurrentTitle() const;
|
||||
|
||||
raw_ptr<AuthHeaderView> GetView();
|
||||
|
||||
|
@ -329,7 +329,7 @@ void AuthInputRowView::OnTextfieldFocus() {
|
||||
}
|
||||
}
|
||||
|
||||
void AuthInputRowView::OnContentsChanged(const std::u16string& new_contents) {
|
||||
void AuthInputRowView::OnContentsChanged(std::u16string_view new_contents) {
|
||||
bool enable_buttons = !textfield_->GetReadOnly() && !new_contents.empty();
|
||||
if (new_contents.empty() && textfield_->IsTextVisible()) {
|
||||
ToggleTextDisplayingState();
|
||||
|
@ -43,9 +43,9 @@ class ASH_EXPORT AuthInputRowView : public views::View,
|
||||
|
||||
class Observer : public base::CheckedObserver {
|
||||
public:
|
||||
virtual void OnSubmit(const std::u16string& text) {}
|
||||
virtual void OnSubmit(std::u16string_view text) {}
|
||||
virtual void OnEscape() {}
|
||||
virtual void OnContentsChanged(const std::u16string& text) {}
|
||||
virtual void OnContentsChanged(std::u16string_view text) {}
|
||||
virtual void OnCapsLockStateChanged(bool visible) {}
|
||||
virtual void OnTextVisibleChanged(bool visible) {}
|
||||
virtual void OnTextfieldBlur() {}
|
||||
@ -85,7 +85,7 @@ class ASH_EXPORT AuthInputRowView : public views::View,
|
||||
// AuthTextfield::Observer:
|
||||
void OnTextfieldBlur() override;
|
||||
void OnTextfieldFocus() override;
|
||||
void OnContentsChanged(const std::u16string& new_contents) override;
|
||||
void OnContentsChanged(std::u16string_view new_contents) override;
|
||||
void OnTextVisibleChanged(bool visible) override;
|
||||
void OnSubmit() override;
|
||||
void OnEscape() override;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "base/check.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/aura/window.h"
|
||||
@ -30,8 +31,8 @@ namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::u16string kPassword = u"password";
|
||||
constexpr std::u16string kPIN = u"123456";
|
||||
constexpr std::u16string_view kPassword = u"password";
|
||||
constexpr std::u16string_view kPin = u"123456";
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -105,8 +106,10 @@ TEST_F(InputRowWithPasswordUnitTest, OnFocusObserverWithClickTest) {
|
||||
|
||||
// Testing textfield OnContentsChanged observer.
|
||||
TEST_F(InputRowWithPasswordUnitTest, OnContentsChangedTest) {
|
||||
const std::u16string modifiedString = kPassword + u"s";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedString)).Times(1);
|
||||
const std::u16string modified_string = base::StrCat({kPassword, u"s"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_string)))
|
||||
.Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_S);
|
||||
}
|
||||
|
||||
@ -178,7 +181,8 @@ TEST_F(InputRowWithPasswordUnitTest, SubmitButtonOnEscapeTest) {
|
||||
TEST_F(InputRowWithPasswordUnitTest, RemoveTextTest) {
|
||||
LeftClickOn(test_api_->GetDisplayTextButton());
|
||||
// Select all and delete.
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(std::u16string())).Times(1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(std::u16string_view()))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*mock_observer_, OnTextVisibleChanged(false)).Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
|
||||
PressAndReleaseKey(ui::VKEY_BACK);
|
||||
@ -190,7 +194,8 @@ TEST_F(InputRowWithPasswordUnitTest, RemoveTextTest) {
|
||||
|
||||
// Testing ResetState functionality.
|
||||
TEST_F(InputRowWithPasswordUnitTest, ResetStateTest) {
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(std::u16string())).Times(1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(std::u16string_view()))
|
||||
.Times(1);
|
||||
auth_input_->ResetState();
|
||||
|
||||
// The textfield should be empty.
|
||||
@ -231,12 +236,12 @@ class InputRowWithPinUnitTest : public AshTestBase {
|
||||
// Initialize the textfield with some text.
|
||||
auth_input_->RequestFocus();
|
||||
|
||||
for (const char16_t c : kPIN) {
|
||||
for (const char16_t c : kPin) {
|
||||
PressAndReleaseKey(ui::DomCodeToUsLayoutNonLocatedKeyboardCode(
|
||||
ui::UsLayoutDomKeyToDomCode(ui::DomKey::FromCharacter(c))));
|
||||
}
|
||||
CHECK(test_api_->GetTextfield()->HasFocus());
|
||||
CHECK_EQ(test_api_->GetTextfield()->GetText(), kPIN);
|
||||
CHECK_EQ(test_api_->GetTextfield()->GetText(), kPin);
|
||||
CHECK(test_api_->GetSubmitButton()->GetEnabled());
|
||||
CHECK(test_api_->GetDisplayTextButton()->GetEnabled());
|
||||
CHECK_EQ(test_api_->GetDisplayTextButton()->GetToggled(), false);
|
||||
@ -263,40 +268,44 @@ class InputRowWithPinUnitTest : public AshTestBase {
|
||||
|
||||
// Testing PIN OnContentsChanged observer.
|
||||
TEST_F(InputRowWithPinUnitTest, OnContentsChangedTest) {
|
||||
const std::u16string modifiedPIN = kPIN + u"5";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
const std::u16string modified_pin = base::StrCat({kPin, u"5"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_pin)))
|
||||
.Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_5);
|
||||
}
|
||||
|
||||
// Testing PIN OnContentsChanged observer with disabled input area.
|
||||
TEST_F(InputRowWithPinUnitTest, DisabledDigitPressTest) {
|
||||
auth_input_->SetInputEnabled(false);
|
||||
const std::u16string modifiedPIN = kPIN + u"5";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(0);
|
||||
const std::u16string modified_pin = base::StrCat({kPin, u"5"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_pin)))
|
||||
.Times(0);
|
||||
PressAndReleaseKey(ui::VKEY_5);
|
||||
}
|
||||
|
||||
// Testing PIN OnContentsChanged observer with letter.
|
||||
TEST_F(InputRowWithPinUnitTest, OnContentsChangedWithLetterTest) {
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kPIN)).Times(0);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kPin)).Times(0);
|
||||
PressAndReleaseKey(ui::VKEY_E);
|
||||
CHECK_EQ(test_api_->GetTextfield()->GetText(), kPIN);
|
||||
CHECK_EQ(test_api_->GetTextfield()->GetText(), kPin);
|
||||
}
|
||||
|
||||
// Testing PIN backspace press.
|
||||
TEST_F(InputRowWithPinUnitTest, BackspacePressTest) {
|
||||
std::u16string modifiedPIN = kPIN;
|
||||
modifiedPIN.pop_back();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
static constexpr std::u16string_view kModifiedPin =
|
||||
kPin.substr(0, kPin.size() - 1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kModifiedPin)).Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_BACK);
|
||||
}
|
||||
|
||||
// Testing PIN backspace press with disabled input area.
|
||||
TEST_F(InputRowWithPinUnitTest, DisabledBackspacePressTest) {
|
||||
auth_input_->SetInputEnabled(false);
|
||||
std::u16string modifiedPIN = kPIN;
|
||||
modifiedPIN.pop_back();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(0);
|
||||
static constexpr std::u16string_view kModifiedPin =
|
||||
kPin.substr(0, kPin.size() - 1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kModifiedPin)).Times(0);
|
||||
PressAndReleaseKey(ui::VKEY_BACK);
|
||||
}
|
||||
|
||||
@ -307,9 +316,9 @@ TEST_F(InputRowWithPinUnitTest, ReenabledBackspacePressTest) {
|
||||
auth_input_->SetInputEnabled(true);
|
||||
auth_input_->RequestFocus();
|
||||
|
||||
std::u16string modifiedPIN = kPIN;
|
||||
modifiedPIN.pop_back();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
static constexpr std::u16string_view kModifiedPin =
|
||||
kPin.substr(0, kPin.size() - 1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kModifiedPin)).Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_BACK);
|
||||
}
|
||||
|
||||
@ -317,10 +326,12 @@ TEST_F(InputRowWithPinUnitTest, ReenabledBackspacePressTest) {
|
||||
TEST_F(InputRowWithPinUnitTest, ClearingInputDisabledButtonsTest) {
|
||||
auth_input_->SetInputEnabled(true);
|
||||
auth_input_->RequestFocus();
|
||||
std::u16string modifiedPIN = kPIN;
|
||||
while (!modifiedPIN.empty()) {
|
||||
modifiedPIN.pop_back();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
std::u16string modified_pin(kPin);
|
||||
while (!modified_pin.empty()) {
|
||||
modified_pin.pop_back();
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_pin)))
|
||||
.Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_BACK);
|
||||
}
|
||||
CHECK_EQ(test_api_->GetSubmitButton()->GetEnabled(), false);
|
||||
@ -335,7 +346,7 @@ TEST_F(InputRowWithPinUnitTest, ClearingInputDisabledButtonsTest) {
|
||||
|
||||
// Testing PIN OnSubmit observer.
|
||||
TEST_F(InputRowWithPinUnitTest, OnSubmitTest) {
|
||||
EXPECT_CALL(*mock_observer_, OnSubmit(kPIN)).Times(1);
|
||||
EXPECT_CALL(*mock_observer_, OnSubmit(kPin)).Times(1);
|
||||
PressAndReleaseKey(ui::VKEY_RETURN);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class ASH_EXPORT AuthTextfield : public SystemTextfield,
|
||||
public:
|
||||
virtual void OnTextfieldBlur() {}
|
||||
virtual void OnTextfieldFocus() {}
|
||||
virtual void OnContentsChanged(const std::u16string& new_contents) {}
|
||||
virtual void OnContentsChanged(std::u16string_view new_contents) {}
|
||||
virtual void OnTextVisibleChanged(bool visible) {}
|
||||
virtual void OnSubmit() {}
|
||||
virtual void OnEscape() {}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "ash/auth/views/auth_textfield_timer.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/accessibility/accessibility_controller.h"
|
||||
#include "ash/auth/views/auth_textfield.h"
|
||||
@ -46,7 +46,7 @@ AuthTextfieldTimer::~AuthTextfieldTimer() {
|
||||
auth_textfield_ = nullptr;
|
||||
}
|
||||
|
||||
void AuthTextfieldTimer::OnContentsChanged(const std::u16string& new_contents) {
|
||||
void AuthTextfieldTimer::OnContentsChanged(std::u16string_view new_contents) {
|
||||
if (new_contents.empty()) {
|
||||
hide_text_timer_.Stop();
|
||||
clear_text_timer_.Stop();
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef ASH_AUTH_VIEWS_AUTH_TEXTFIELD_TIMER_H_
|
||||
#define ASH_AUTH_VIEWS_AUTH_TEXTFIELD_TIMER_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_textfield.h"
|
||||
@ -16,7 +16,7 @@ namespace ash {
|
||||
|
||||
class ASH_EXPORT AuthTextfieldTimer : public AuthTextfield::Observer {
|
||||
public:
|
||||
void OnContentsChanged(const std::u16string& new_contents) override;
|
||||
void OnContentsChanged(std::u16string_view new_contents) override;
|
||||
void OnTextVisibleChanged(bool visible) override;
|
||||
|
||||
explicit AuthTextfieldTimer(AuthTextfield* auth_textfield);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/auth/views/auth_textfield.h"
|
||||
#include "ash/auth/views/test_support/mock_auth_textfield_observer.h"
|
||||
@ -13,6 +14,7 @@
|
||||
#include "base/check.h"
|
||||
#include "base/check_op.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/test/task_environment.h"
|
||||
#include "base/test/test_simple_task_runner.h"
|
||||
#include "base/time/tick_clock.h"
|
||||
@ -27,7 +29,7 @@ namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::u16string kPassword = u"password";
|
||||
constexpr std::u16string_view kPassword = u"password";
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -59,7 +61,7 @@ class AuthTextfieldWithTimerUnitTest : public AshTestBase {
|
||||
auth_textfield_ = widget_->SetContentsView(
|
||||
std::make_unique<AuthTextfield>(AuthTextfield::AuthType::kPassword));
|
||||
mock_observer_ = std::make_unique<MockAuthTextfieldObserver>();
|
||||
auth_textfield_->SetText(kPassword);
|
||||
auth_textfield_->SetText(std::u16string(kPassword));
|
||||
auth_textfield_->AddObserver(mock_observer_.get());
|
||||
auth_textfield_timer_ =
|
||||
std::make_unique<AuthTextfieldTimer>(auth_textfield_);
|
||||
@ -110,16 +112,18 @@ TEST_F(AuthTextfieldWithTimerUnitTest, ClearPasswordTest) {
|
||||
SetTextfieldToFocus();
|
||||
CHECK(!auth_textfield_->IsTextVisible());
|
||||
// Make a user interaction.
|
||||
const std::u16string modifiedString = kPassword + u"s";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedString)).Times(1);
|
||||
const std::u16string modified_string = base::StrCat({kPassword, u"s"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_string)))
|
||||
.Times(1);
|
||||
ui::test::EventGenerator* generator = GetEventGenerator();
|
||||
generator->PressAndReleaseKey(ui::VKEY_S);
|
||||
|
||||
// After 30 sec without user interaction the textfield should be cleared.
|
||||
const std::u16string emptyStr;
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(emptyStr)).Times(1);
|
||||
constexpr std::u16string_view kEmptyStr;
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kEmptyStr)).Times(1);
|
||||
task_environment()->FastForwardBy(base::Seconds(30));
|
||||
CHECK_EQ(auth_textfield_->GetText(), emptyStr);
|
||||
CHECK_EQ(auth_textfield_->GetText(), kEmptyStr);
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "base/check.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/aura/window.h"
|
||||
@ -26,8 +27,8 @@ namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr std::u16string kPassword = u"password";
|
||||
constexpr std::u16string kPIN = u"123456";
|
||||
constexpr std::u16string_view kPassword = u"password";
|
||||
constexpr std::u16string_view kPin = u"123456";
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -87,8 +88,10 @@ TEST_F(PasswordTextfieldUnitTest, OnFocusObserverTest) {
|
||||
TEST_F(PasswordTextfieldUnitTest, OnContentsChangedTest) {
|
||||
auth_textfield_->SetText(kPassword);
|
||||
SetTextfieldToFocus();
|
||||
const std::u16string modifiedString = kPassword + u"s";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedString)).Times(1);
|
||||
const std::u16string modified_string = base::StrCat({kPassword, u"s"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_string)))
|
||||
.Times(1);
|
||||
ui::test::EventGenerator* generator = GetEventGenerator();
|
||||
generator->PressAndReleaseKey(ui::VKEY_S);
|
||||
}
|
||||
@ -143,7 +146,7 @@ class PinTextfieldUnitTest : public AshTestBase {
|
||||
mock_observer_ = std::make_unique<MockAuthTextfieldObserver>();
|
||||
auth_textfield_ = widget_->SetContentsView(
|
||||
std::make_unique<AuthTextfield>(AuthTextfield::AuthType::kPin));
|
||||
auth_textfield_->SetText(kPIN);
|
||||
auth_textfield_->SetText(kPin);
|
||||
auth_textfield_->AddObserver(mock_observer_.get());
|
||||
}
|
||||
|
||||
@ -163,8 +166,10 @@ class PinTextfieldUnitTest : public AshTestBase {
|
||||
// Testing PIN textfield OnContentsChanged Observer.
|
||||
TEST_F(PinTextfieldUnitTest, OnContentsChangedTest) {
|
||||
SetTextfieldToFocus();
|
||||
const std::u16string modifiedPIN = kPIN + u"5";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
const std::u16string modified_pin = base::StrCat({kPin, u"5"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_pin)))
|
||||
.Times(1);
|
||||
ui::test::EventGenerator* generator = GetEventGenerator();
|
||||
generator->PressAndReleaseKey(ui::VKEY_5);
|
||||
}
|
||||
@ -172,34 +177,36 @@ TEST_F(PinTextfieldUnitTest, OnContentsChangedTest) {
|
||||
// Testing PIN textfield OnContentsChanged Observer with letter.
|
||||
TEST_F(PinTextfieldUnitTest, OnContentsChangedWithLetterTest) {
|
||||
SetTextfieldToFocus();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kPIN)).Times(0);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kPin)).Times(0);
|
||||
ui::test::EventGenerator* generator = GetEventGenerator();
|
||||
generator->PressAndReleaseKey(ui::VKEY_E);
|
||||
CHECK_EQ(auth_textfield_->GetText(), kPIN);
|
||||
CHECK_EQ(auth_textfield_->GetText(), kPin);
|
||||
}
|
||||
|
||||
// Testing PIN textfield InsertDigit function.
|
||||
TEST_F(PinTextfieldUnitTest, InsertDigitTest) {
|
||||
const std::u16string modifiedPIN = kPIN + u"5";
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
const std::u16string modified_pin = base::StrCat({kPin, u"5"});
|
||||
EXPECT_CALL(*mock_observer_,
|
||||
OnContentsChanged(std::u16string_view(modified_pin)))
|
||||
.Times(1);
|
||||
auth_textfield_->InsertDigit(5);
|
||||
}
|
||||
|
||||
// Testing PIN textfield backspace press.
|
||||
TEST_F(PinTextfieldUnitTest, BackspacePressTest) {
|
||||
std::u16string modifiedPIN = kPIN;
|
||||
modifiedPIN.pop_back();
|
||||
static constexpr std::u16string_view kModifiedPin =
|
||||
kPin.substr(0, kPin.size() - 1);
|
||||
SetTextfieldToFocus();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kModifiedPin)).Times(1);
|
||||
ui::test::EventGenerator* generator = GetEventGenerator();
|
||||
generator->PressAndReleaseKey(ui::VKEY_BACK);
|
||||
}
|
||||
|
||||
// Testing PIN textfield Backspace function.
|
||||
TEST_F(PinTextfieldUnitTest, BackspaceTest) {
|
||||
std::u16string modifiedPIN = kPIN;
|
||||
modifiedPIN.pop_back();
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modifiedPIN)).Times(1);
|
||||
static constexpr std::u16string_view kModifiedPin =
|
||||
kPin.substr(0, kPin.size() - 1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kModifiedPin)).Times(1);
|
||||
auth_textfield_->Backspace();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class PinContainerUnitTest : public AshTestBase {
|
||||
// Verify pin keyboard connected with auth input row.
|
||||
TEST_F(PinContainerUnitTest, TypePin) {
|
||||
// Press 1,2,3,4,5,6 buttons on the pin pad.
|
||||
const std::u16string kPin(u"123456");
|
||||
static constexpr std::u16string_view kPin(u"123456");
|
||||
for (size_t i = 1; i <= kPin.size(); ++i) {
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kPin.substr(0, i))).Times(1);
|
||||
LeftClickOn(test_api_pin_keyboard_->digit_button(kPin[i - 1] - u'0'));
|
||||
@ -83,7 +83,7 @@ TEST_F(PinContainerUnitTest, TypePin) {
|
||||
TEST_F(PinContainerUnitTest, DisabledTypePin) {
|
||||
container_view_->SetInputEnabled(false);
|
||||
// Press 1,2,3,4,5,6 buttons on the pin pad.
|
||||
const std::u16string kPin(u"123456");
|
||||
static constexpr std::u16string_view kPin(u"123456");
|
||||
for (size_t i = 1; i <= kPin.size(); ++i) {
|
||||
LeftClickOn(test_api_pin_keyboard_->digit_button(kPin[i - 1] - u'0'));
|
||||
}
|
||||
@ -92,19 +92,20 @@ TEST_F(PinContainerUnitTest, DisabledTypePin) {
|
||||
|
||||
// Verify pin keyboard connected with auth input row.
|
||||
TEST_F(PinContainerUnitTest, BackspaceTest) {
|
||||
const std::u16string kPin(u"6893112");
|
||||
static constexpr std::u16string_view kPin(u"6893112");
|
||||
for (size_t i = 1; i <= kPin.size(); ++i) {
|
||||
LeftClickOn(test_api_pin_keyboard_->digit_button(kPin[i - 1] - u'0'));
|
||||
}
|
||||
const std::u16string modified_pin = kPin.substr(0, kPin.size() - 1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(modified_pin)).Times(1);
|
||||
static constexpr std::u16string_view kModifiedPin =
|
||||
kPin.substr(0, kPin.size() - 1);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(kModifiedPin)).Times(1);
|
||||
LeftClickOn(test_api_pin_keyboard_->backspace_button());
|
||||
EXPECT_EQ(test_api_auth_input_->GetTextfield()->GetText(), modified_pin);
|
||||
EXPECT_EQ(test_api_auth_input_->GetTextfield()->GetText(), kModifiedPin);
|
||||
}
|
||||
|
||||
// Verify enter press on the textfield submits the pin.
|
||||
TEST_F(PinContainerUnitTest, SubmitTest) {
|
||||
const std::u16string kPin(u"60012345");
|
||||
static constexpr std::u16string_view kPin(u"60012345");
|
||||
// Set textfield to be focused.
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
test_api_auth_input_->GetTextfield());
|
||||
@ -117,7 +118,7 @@ TEST_F(PinContainerUnitTest, SubmitTest) {
|
||||
|
||||
// Verify enter press is not operating with disabled input.
|
||||
TEST_F(PinContainerUnitTest, SubmitDisabledTest) {
|
||||
const std::u16string kPin(u"60012345");
|
||||
static constexpr std::u16string_view kPin(u"60012345");
|
||||
// Set textfield to be focused.
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
test_api_auth_input_->GetTextfield());
|
||||
@ -131,7 +132,7 @@ TEST_F(PinContainerUnitTest, SubmitDisabledTest) {
|
||||
|
||||
// Verify enter press on the digit presses the key.
|
||||
TEST_F(PinContainerUnitTest, EnterOnPinkeyboardTest) {
|
||||
const std::u16string kPin(u"0894329");
|
||||
static constexpr std::u16string_view kPin(u"0894329");
|
||||
for (size_t i = 1; i <= kPin.size(); ++i) {
|
||||
// Set digit key to be focused and press enter on the button.
|
||||
container_view_->GetFocusManager()->SetFocusedView(
|
||||
@ -143,9 +144,9 @@ TEST_F(PinContainerUnitTest, EnterOnPinkeyboardTest) {
|
||||
|
||||
// Verify the ResetState functionality.
|
||||
TEST_F(PinContainerUnitTest, ResetStateTest) {
|
||||
const std::u16string kPin(u"0894329");
|
||||
static constexpr std::u16string_view kPin(u"0894329");
|
||||
test_api_auth_input_->GetTextfield()->SetText(kPin);
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(std::u16string()));
|
||||
EXPECT_CALL(*mock_observer_, OnContentsChanged(std::u16string_view()));
|
||||
test_api_->GetView()->ResetState();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_common.h"
|
||||
@ -67,7 +68,7 @@ namespace ash {
|
||||
PinStatusView::TestApi::TestApi(PinStatusView* view) : view_(view) {}
|
||||
PinStatusView::TestApi::~TestApi() = default;
|
||||
|
||||
const std::u16string& PinStatusView::TestApi::GetCurrentText() const {
|
||||
std::u16string_view PinStatusView::TestApi::GetCurrentText() const {
|
||||
return view_->GetCurrentText();
|
||||
}
|
||||
|
||||
@ -124,7 +125,7 @@ void PinStatusView::SetText(const std::u16string& text_str) {
|
||||
text_label_->SetText(text_str);
|
||||
}
|
||||
|
||||
const std::u16string& PinStatusView::GetCurrentText() const {
|
||||
std::u16string_view PinStatusView::GetCurrentText() const {
|
||||
return text_label_->GetText();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -36,7 +37,7 @@ class ASH_EXPORT PinStatusView : public views::View {
|
||||
TestApi(const TestApi&) = delete;
|
||||
TestApi& operator=(const TestApi&) = delete;
|
||||
|
||||
const std::u16string& GetCurrentText() const;
|
||||
std::u16string_view GetCurrentText() const;
|
||||
|
||||
raw_ptr<views::Label> GetTextLabel() const;
|
||||
|
||||
@ -62,7 +63,7 @@ class ASH_EXPORT PinStatusView : public views::View {
|
||||
}
|
||||
|
||||
void SetText(const std::u16string& text_str);
|
||||
const std::u16string& GetCurrentText() const;
|
||||
std::u16string_view GetCurrentText() const;
|
||||
|
||||
void SetPinStatus(std::unique_ptr<cryptohome::PinStatus> pin_status);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define ASH_AUTH_VIEWS_TEST_SUPPORT_MOCK_ACTIVE_SESSION_AUTH_VIEW_OBSERVER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/active_session_auth_view.h"
|
||||
@ -20,8 +20,8 @@ class ASH_EXPORT MockActiveSessionAuthViewObserver
|
||||
MockActiveSessionAuthViewObserver();
|
||||
~MockActiveSessionAuthViewObserver() override;
|
||||
|
||||
MOCK_METHOD(void, OnPasswordSubmit, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnPinSubmit, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnPasswordSubmit, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnPinSubmit, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnClose, (), (override));
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define ASH_AUTH_VIEWS_TEST_SUPPORT_MOCK_AUTH_CONTAINER_VIEW_OBSERVER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_container_view.h"
|
||||
@ -20,8 +20,8 @@ class ASH_EXPORT MockAuthContainerViewObserver
|
||||
MockAuthContainerViewObserver();
|
||||
~MockAuthContainerViewObserver() override;
|
||||
|
||||
MOCK_METHOD(void, OnPasswordSubmit, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnPinSubmit, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnPasswordSubmit, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnPinSubmit, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnEscape, (), (override));
|
||||
MOCK_METHOD(void, OnContentsChanged, (), (override));
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define ASH_AUTH_VIEWS_TEST_SUPPORT_MOCK_AUTH_INPUT_ROW_VIEW_OBSERVER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_input_row_view.h"
|
||||
@ -22,10 +22,10 @@ class ASH_EXPORT MockAuthInputRowViewObserver
|
||||
|
||||
MOCK_METHOD(void, OnTextfieldBlur, (), (override));
|
||||
MOCK_METHOD(void, OnTextfieldFocus, (), (override));
|
||||
MOCK_METHOD(void, OnContentsChanged, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnContentsChanged, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnCapsLockStateChanged, (bool), (override));
|
||||
MOCK_METHOD(void, OnTextVisibleChanged, (bool), (override));
|
||||
MOCK_METHOD(void, OnSubmit, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnSubmit, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnEscape, (), (override));
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define ASH_AUTH_VIEWS_TEST_SUPPORT_MOCK_AUTH_TEXTFIELD_OBSERVER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/auth/views/auth_textfield.h"
|
||||
@ -21,7 +21,7 @@ class ASH_EXPORT MockAuthTextfieldObserver : public AuthTextfield::Observer {
|
||||
|
||||
MOCK_METHOD(void, OnTextfieldBlur, (), (override));
|
||||
MOCK_METHOD(void, OnTextfieldFocus, (), (override));
|
||||
MOCK_METHOD(void, OnContentsChanged, (const std::u16string&), (override));
|
||||
MOCK_METHOD(void, OnContentsChanged, (std::u16string_view), (override));
|
||||
MOCK_METHOD(void, OnTextVisibleChanged, (bool), (override));
|
||||
MOCK_METHOD(void, OnSubmit, (), (override));
|
||||
MOCK_METHOD(void, OnEscape, (), (override));
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -178,7 +179,7 @@ void ActionButtonContainerView::ErrorView::SetTryAgainCallback(
|
||||
try_again_link_->SetCallback(std::move(try_again_callback));
|
||||
}
|
||||
|
||||
const std::u16string&
|
||||
std::u16string_view
|
||||
ActionButtonContainerView::ErrorView::GetErrorMessageForTesting() const {
|
||||
return error_label_->GetText();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
@ -65,7 +66,7 @@ class ASH_EXPORT ActionButtonContainerView : public views::View {
|
||||
// the try again link is only shown if `try_again_callback` is not null.
|
||||
void SetTryAgainCallback(base::RepeatingClosure try_again_callback);
|
||||
|
||||
const std::u16string& GetErrorMessageForTesting() const;
|
||||
std::u16string_view GetErrorMessageForTesting() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<SystemShadow> shadow_;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -103,7 +104,7 @@ class CaptureModeMenuHeader
|
||||
box_layout->SetFlexForView(label_view_, 1);
|
||||
|
||||
GetViewAccessibility().SetRole(ax::mojom::Role::kHeader);
|
||||
GetViewAccessibility().SetName(GetHeaderLabel());
|
||||
GetViewAccessibility().SetName(std::u16string(GetHeaderLabel()));
|
||||
}
|
||||
|
||||
CaptureModeMenuHeader(const CaptureModeMenuHeader&) = delete;
|
||||
@ -112,9 +113,7 @@ class CaptureModeMenuHeader
|
||||
|
||||
bool is_managed_by_policy() const { return !!managed_icon_view_; }
|
||||
|
||||
const std::u16string& GetHeaderLabel() const {
|
||||
return label_view_->GetText();
|
||||
}
|
||||
std::u16string_view GetHeaderLabel() const { return label_view_->GetText(); }
|
||||
|
||||
// CaptureModeSessionFocusCycler::HighlightableView:
|
||||
views::View* GetView() override { return this; }
|
||||
@ -158,7 +157,7 @@ class CaptureModeMenuItem
|
||||
capture_mode_util::CreateAndInitBoxLayoutForView(this);
|
||||
SetInkDropForButton(this);
|
||||
GetViewAccessibility().SetIsLeaf(true);
|
||||
GetViewAccessibility().SetName(label_view_->GetText());
|
||||
GetViewAccessibility().SetName(std::u16string(label_view_->GetText()));
|
||||
SetEnabled(enabled);
|
||||
}
|
||||
|
||||
@ -219,7 +218,7 @@ class CaptureModeOption
|
||||
box_layout->SetFlexForView(label_view_, 1);
|
||||
SetInkDropForButton(this);
|
||||
GetViewAccessibility().SetIsLeaf(true);
|
||||
GetViewAccessibility().SetName(GetOptionLabel());
|
||||
GetViewAccessibility().SetName(std::u16string(GetOptionLabel()));
|
||||
GetViewAccessibility().SetRole(ax::mojom::Role::kRadioButton);
|
||||
|
||||
SetEnabled(enabled);
|
||||
@ -231,9 +230,7 @@ class CaptureModeOption
|
||||
|
||||
int id() const { return id_; }
|
||||
|
||||
const std::u16string& GetOptionLabel() const {
|
||||
return label_view_->GetText();
|
||||
}
|
||||
std::u16string_view GetOptionLabel() const { return label_view_->GetText(); }
|
||||
|
||||
// If `icon` is `nullptr`, removes the `option_icon_view_` (if any).
|
||||
// Otherwise, a new image view will be created for the `option_icon_view_` (if
|
||||
@ -468,7 +465,7 @@ views::View* CaptureModeMenuGroup::GetSelectFolderMenuItemForTesting() {
|
||||
return menu_items_[0];
|
||||
}
|
||||
|
||||
std::u16string CaptureModeMenuGroup::GetOptionLabelForTesting(
|
||||
std::u16string_view CaptureModeMenuGroup::GetOptionLabelForTesting(
|
||||
int option_id) const {
|
||||
auto* option = GetOptionById(option_id);
|
||||
DCHECK(option);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
@ -124,7 +125,7 @@ class ASH_EXPORT CaptureModeMenuGroup : public views::View {
|
||||
// For tests only.
|
||||
views::View* GetOptionForTesting(int option_id);
|
||||
views::View* GetSelectFolderMenuItemForTesting();
|
||||
std::u16string GetOptionLabelForTesting(int option_id) const;
|
||||
std::u16string_view GetOptionLabelForTesting(int option_id) const;
|
||||
views::View* SetOptionCheckedForTesting(int option_id, bool checked) const;
|
||||
|
||||
private:
|
||||
|
@ -138,9 +138,8 @@ class SunfishSearchBoxView : public views::View,
|
||||
|
||||
if (event.type() == ui::EventType::kKeyPressed &&
|
||||
event.key_code() == ui::VKEY_RETURN) {
|
||||
const std::u16string& text = sender->GetText();
|
||||
CaptureModeController::Get()->SendMultimodalSearch(
|
||||
image_view_->GetImage(), base::UTF16ToUTF8(text));
|
||||
image_view_->GetImage(), base::UTF16ToUTF8(sender->GetText()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "ash/display/resolution_notification_controller.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/display/display_change_dialog.h"
|
||||
#include "ash/display/display_util.h"
|
||||
#include "ash/screen_util.h"
|
||||
@ -155,7 +157,7 @@ class ResolutionNotificationControllerTest
|
||||
new_is_native, source);
|
||||
}
|
||||
|
||||
static std::u16string GetNotificationMessage() {
|
||||
static std::u16string_view GetNotificationMessage() {
|
||||
return controller()->dialog_for_testing()->label_->GetText();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/game_dashboard/game_dashboard_context_test_api.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/capture_mode/capture_mode_test_util.h"
|
||||
#include "ash/game_dashboard/game_dashboard_battery_view.h"
|
||||
@ -120,7 +121,7 @@ FeatureTile* GameDashboardContextTestApi::GetMainMenuScreenshotTile() {
|
||||
GetMainMenuViewById(VIEW_ID_GD_SCREENSHOT_TILE));
|
||||
}
|
||||
|
||||
const std::u16string&
|
||||
std::u16string_view
|
||||
GameDashboardContextTestApi::GetMainMenuScreenSizeSubtitle() {
|
||||
auto* main_menu_view = GetMainMenuView();
|
||||
CHECK(main_menu_view);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_GAME_DASHBOARD_GAME_DASHBOARD_CONTEXT_TEST_API_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/game_dashboard/game_dashboard_context.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -75,7 +76,7 @@ class GameDashboardContextTestApi {
|
||||
FeatureTile* GetMainMenuToolbarTile();
|
||||
FeatureTile* GetMainMenuRecordGameTile();
|
||||
FeatureTile* GetMainMenuScreenshotTile();
|
||||
const std::u16string& GetMainMenuScreenSizeSubtitle();
|
||||
std::u16string_view GetMainMenuScreenSizeSubtitle();
|
||||
views::Button* GetMainMenuScreenSizeSettingsButton();
|
||||
views::Button* GetMainMenuGameControlsDetailsButton();
|
||||
PillButton* GetMainMenuGameControlsSetupButton();
|
||||
|
@ -1582,12 +1582,12 @@ TEST_F(GameDashboardContextTest, MainMenuClockView) {
|
||||
|
||||
const auto* horizontal_time_label =
|
||||
clock_view->GetHorizontalTimeLabelForTesting();
|
||||
const auto current_time = horizontal_time_label->GetText();
|
||||
const std::u16string current_time(horizontal_time_label->GetText());
|
||||
// Verify that the "AM/PM" text is visible.
|
||||
ASSERT_NE(current_time.ends_with(u"AM"), current_time.ends_with(u"PM"));
|
||||
// Ensure that the clock increments as the time changes.
|
||||
AdvanceClock(base::Hours(12));
|
||||
const auto next_time = horizontal_time_label->GetText();
|
||||
const std::u16string_view next_time = horizontal_time_label->GetText();
|
||||
const std::u16string next_am_pm =
|
||||
current_time.ends_with(u"AM") ? u"PM" : u"AM";
|
||||
ASSERT_NE(current_time, next_time);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ash/api/tasks/tasks_types.h"
|
||||
@ -123,7 +124,7 @@ class TaskViewTextField : public SystemTextfield,
|
||||
|
||||
public:
|
||||
using OnFinishedEditingCallback =
|
||||
base::RepeatingCallback<void(const std::u16string& title)>;
|
||||
base::RepeatingCallback<void(std::u16string_view title)>;
|
||||
|
||||
explicit TaskViewTextField(OnFinishedEditingCallback on_finished_editing)
|
||||
: SystemTextfield(Type::kMedium),
|
||||
@ -294,11 +295,12 @@ class GlanceablesTaskView::TaskTitleButton : public views::LabelButton {
|
||||
: gfx::Font::FontStyle::NORMAL));
|
||||
}
|
||||
|
||||
void SetText(const std::u16string& text) override {
|
||||
void SetText(std::u16string_view text) override {
|
||||
views::LabelButton::SetText(text);
|
||||
GetViewAccessibility().SetName(
|
||||
text, text.empty() ? ax::mojom::NameFrom::kAttributeExplicitlyEmpty
|
||||
: ax::mojom::NameFrom::kAttribute);
|
||||
std::u16string(text),
|
||||
text.empty() ? ax::mojom::NameFrom::kAttributeExplicitlyEmpty
|
||||
: ax::mojom::NameFrom::kAttribute);
|
||||
}
|
||||
};
|
||||
|
||||
@ -700,9 +702,9 @@ void GlanceablesTaskView::TaskTitleButtonPressed() {
|
||||
UpdateTaskTitleViewForState(TaskTitleViewState::kEdit);
|
||||
}
|
||||
|
||||
void GlanceablesTaskView::OnFinishedEditing(const std::u16string& title) {
|
||||
void GlanceablesTaskView::OnFinishedEditing(std::u16string_view title) {
|
||||
if (!title.empty()) {
|
||||
task_title_ = title;
|
||||
task_title_ = std::u16string(title);
|
||||
}
|
||||
|
||||
if (task_title_textfield_ && task_title_textfield_->HasFocus()) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_GLANCEABLES_TASKS_GLANCEABLES_TASK_VIEW_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/api/tasks/tasks_client.h"
|
||||
#include "ash/api/tasks/tasks_types.h"
|
||||
@ -118,7 +119,7 @@ class ASH_EXPORT GlanceablesTaskView : public views::FlexLayoutView,
|
||||
|
||||
// Handles finished editing event from the text field, updates `task_title_`
|
||||
// and propagates new `title` to the server.
|
||||
void OnFinishedEditing(const std::u16string& title);
|
||||
void OnFinishedEditing(std::u16string_view title);
|
||||
|
||||
// Handles completion of running `save_callback_` callback.
|
||||
// `task` - newly created or updated task.
|
||||
|
@ -672,7 +672,7 @@ void AuthDialogContentsView::OnInputTextChanged(bool is_empty) {
|
||||
}
|
||||
|
||||
void AuthDialogContentsView::OnAuthSubmit(bool authenticated_by_pin,
|
||||
const std::u16string& password) {
|
||||
std::u16string_view password) {
|
||||
if (authenticated_by_pin) {
|
||||
if (pin_autosubmit_on_) {
|
||||
pin_digit_input_view_->SetReadOnly(true);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/public/cpp/login_types.h"
|
||||
@ -141,7 +142,7 @@ class AuthDialogContentsView : public views::View {
|
||||
|
||||
// Called when the user submits password or PIN. If authenticated_by_pin is
|
||||
// false, the user authenticated by password.
|
||||
void OnAuthSubmit(bool authenticated_by_pin, const std::u16string& password);
|
||||
void OnAuthSubmit(bool authenticated_by_pin, std::u16string_view password);
|
||||
|
||||
// Called when password or PIN authentication of the user completes. If
|
||||
// authenticated_by_pin is false, the user authenticated by password.
|
||||
|
@ -462,22 +462,22 @@ void LoginScreenTestApi::SubmitPin(const AccountId& account_id,
|
||||
}
|
||||
|
||||
// static
|
||||
std::u16string LoginScreenTestApi::GetChallengeResponseLabel(
|
||||
std::u16string_view LoginScreenTestApi::GetChallengeResponseLabel(
|
||||
const AccountId& account_id) {
|
||||
if (GetFocusedUser() != account_id) {
|
||||
ADD_FAILURE() << "The user " << account_id.Serialize() << " is not focused";
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
LoginBigUserView* big_user_view = GetBigUserView(account_id);
|
||||
if (!big_user_view) {
|
||||
ADD_FAILURE() << "Could not find user " << account_id.Serialize();
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
LoginAuthUserView::TestApi auth_test(big_user_view->auth_user());
|
||||
if (!auth_test.challenge_response_label()->IsDrawn()) {
|
||||
ADD_FAILURE() << "Challenge-response label is not drawn for user "
|
||||
<< account_id.Serialize();
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
return auth_test.challenge_response_label()->GetText();
|
||||
}
|
||||
@ -807,12 +807,12 @@ std::string LoginScreenTestApi::GetDisplayedName(const AccountId& account_id) {
|
||||
}
|
||||
|
||||
// static
|
||||
std::u16string LoginScreenTestApi::GetDisabledAuthMessage(
|
||||
std::u16string_view LoginScreenTestApi::GetDisabledAuthMessage(
|
||||
const AccountId& account_id) {
|
||||
LoginBigUserView* big_user_view = GetBigUserView(account_id);
|
||||
if (!big_user_view) {
|
||||
ADD_FAILURE() << "Could not find user " << account_id.Serialize();
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
LoginAuthUserView::TestApi auth_test(big_user_view->auth_user());
|
||||
|
||||
@ -820,18 +820,18 @@ std::u16string LoginScreenTestApi::GetDisabledAuthMessage(
|
||||
}
|
||||
|
||||
// static
|
||||
std::u16string LoginScreenTestApi::GetManagementDisclosureText(
|
||||
std::u16string_view LoginScreenTestApi::GetManagementDisclosureText(
|
||||
const AccountId& account_id) {
|
||||
LoginBigUserView* big_user_view = GetBigUserView(account_id);
|
||||
if (!big_user_view) {
|
||||
ADD_FAILURE() << "Could not find user " << account_id.Serialize();
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
LoginAuthUserView::TestApi auth_test(big_user_view->auth_user());
|
||||
if (!auth_test.remove_account_dialog()) {
|
||||
ADD_FAILURE() << "Could not find dialog for user "
|
||||
<< account_id.Serialize();
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
LoginRemoveAccountDialog::TestApi dialog(auth_test.remove_account_dialog());
|
||||
return dialog.management_disclosure_label()->GetText();
|
||||
@ -845,10 +845,10 @@ bool LoginScreenTestApi::IsOobeDialogVisible() {
|
||||
}
|
||||
|
||||
// static
|
||||
std::u16string LoginScreenTestApi::GetShutDownButtonLabel() {
|
||||
std::u16string_view LoginScreenTestApi::GetShutDownButtonLabel() {
|
||||
views::View* button = GetShutDownButton();
|
||||
if (!button) {
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
|
||||
return static_cast<views::LabelButton*>(button)->GetText();
|
||||
@ -894,10 +894,10 @@ void LoginScreenTestApi::SetPinRequestWidgetShownCallback(
|
||||
}
|
||||
|
||||
// static
|
||||
std::u16string LoginScreenTestApi::GetPinRequestWidgetTitle() {
|
||||
std::u16string_view LoginScreenTestApi::GetPinRequestWidgetTitle() {
|
||||
if (!PinRequestWidget::Get()) {
|
||||
ADD_FAILURE() << "No PIN request widget is shown";
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
PinRequestWidget::TestApi pin_widget_test(PinRequestWidget::Get());
|
||||
PinRequestView::TestApi pin_view_test(pin_widget_test.pin_request_view());
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/login/ui/access_code_input.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/style/system_textfield.h"
|
||||
@ -88,8 +89,8 @@ void FlexCodeInput::InsertDigit(int value) {
|
||||
DCHECK_LE(0, value);
|
||||
DCHECK_GE(9, value);
|
||||
if (code_field_->GetEnabled()) {
|
||||
code_field_->SetText(code_field_->GetText() +
|
||||
base::NumberToString16(value));
|
||||
code_field_->SetText(
|
||||
base::StrCat({code_field_->GetText(), base::NumberToString16(value)}));
|
||||
on_input_change_.Run(true);
|
||||
}
|
||||
}
|
||||
@ -108,7 +109,7 @@ void FlexCodeInput::Backspace() {
|
||||
}
|
||||
|
||||
std::optional<std::string> FlexCodeInput::GetCode() const {
|
||||
std::u16string code = code_field_->GetText();
|
||||
std::u16string_view code = code_field_->GetText();
|
||||
if (!code.length()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -601,7 +602,7 @@ AccessibleInputField* FixedLengthCodeInput::ActiveField() const {
|
||||
return input_fields_[active_input_index_];
|
||||
}
|
||||
|
||||
const std::u16string& FixedLengthCodeInput::ActiveInput() const {
|
||||
std::u16string_view FixedLengthCodeInput::ActiveInput() const {
|
||||
return ActiveField()->GetText();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/style/system_textfield.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -283,7 +284,7 @@ class FixedLengthCodeInput : public AccessCodeInput {
|
||||
AccessibleInputField* ActiveField() const;
|
||||
|
||||
// Returns text in the active input field.
|
||||
const std::u16string& ActiveInput() const;
|
||||
std::u16string_view ActiveInput() const;
|
||||
|
||||
// To be called when access input code changes (digit is inserted, deleted or
|
||||
// updated). Passes true when code is complete (all digits have input value)
|
||||
|
@ -107,7 +107,7 @@ void AnimatedAuthFactorsLabelWrapper::SetLabelTextAndAccessibleName(
|
||||
|
||||
previous_label_id_ = label_id;
|
||||
previous_accessible_name_id_ = accessible_name_id;
|
||||
std::u16string previous_text = current_label_->GetText();
|
||||
std::u16string previous_text(current_label_->GetText());
|
||||
|
||||
current_label_->SetText(l10n_util::GetStringUTF16(label_id));
|
||||
current_label_->GetViewAccessibility().SetName(
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/public/cpp/login_types.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
@ -146,7 +147,7 @@ DisabledAuthMessageView::TestApi::TestApi(DisabledAuthMessageView* view)
|
||||
|
||||
DisabledAuthMessageView::TestApi::~TestApi() = default;
|
||||
|
||||
const std::u16string&
|
||||
std::u16string_view
|
||||
DisabledAuthMessageView::TestApi::GetDisabledAuthMessageContent() const {
|
||||
return view_->message_contents_->GetText();
|
||||
}
|
||||
@ -256,7 +257,7 @@ void DisabledAuthMessageView::UpdateAccessibleName() {
|
||||
GetViewAccessibility().SetName(
|
||||
std::string(), ax::mojom::NameFrom::kAttributeExplicitlyEmpty);
|
||||
} else {
|
||||
GetViewAccessibility().SetName(message_title_->GetText());
|
||||
GetViewAccessibility().SetName(std::u16string(message_title_->GetText()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -28,7 +29,7 @@ class DisabledAuthMessageView : public views::View {
|
||||
explicit TestApi(DisabledAuthMessageView* view);
|
||||
~TestApi();
|
||||
|
||||
const std::u16string& GetDisabledAuthMessageContent() const;
|
||||
std::u16string_view GetDisabledAuthMessageContent() const;
|
||||
|
||||
void SetDisabledAuthMessageTitleForTesting(std::u16string message_title);
|
||||
|
||||
|
@ -310,7 +310,7 @@ void LocalAuthenticationWithPinControllerImpl::MoveToTheCenter() {
|
||||
}
|
||||
|
||||
void LocalAuthenticationWithPinControllerImpl::OnPasswordSubmit(
|
||||
const std::u16string& password) {
|
||||
std::u16string_view password) {
|
||||
if (IsSucceedState()) {
|
||||
return;
|
||||
}
|
||||
@ -342,7 +342,7 @@ void LocalAuthenticationWithPinControllerImpl::OnPasswordSubmit(
|
||||
}
|
||||
|
||||
void LocalAuthenticationWithPinControllerImpl::OnPinSubmit(
|
||||
const std::u16string& pin) {
|
||||
std::u16string_view pin) {
|
||||
if (IsSucceedState()) {
|
||||
return;
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ class ASH_EXPORT LocalAuthenticationWithPinControllerImpl
|
||||
void OnViewPreferredSizeChanged(views::View* observed_view) override;
|
||||
|
||||
// ActiveSessionAuthView::Observer:
|
||||
void OnPasswordSubmit(const std::u16string& password) override;
|
||||
void OnPinSubmit(const std::u16string& pin) override;
|
||||
void OnPasswordSubmit(std::u16string_view password) override;
|
||||
void OnPinSubmit(std::u16string_view pin) override;
|
||||
void OnClose() override;
|
||||
|
||||
// UserDataAuthClient::AuthFactorStatusUpdateObserver:
|
||||
|
@ -382,13 +382,11 @@ class AuthSubmissionCounter : public ActiveSessionAuthView::Observer,
|
||||
}
|
||||
|
||||
// ActiveSessionAuthView::Observer:
|
||||
void OnPasswordSubmit(const std::u16string& password) override {
|
||||
void OnPasswordSubmit(std::u16string_view password) override {
|
||||
++password_submit_counter_;
|
||||
}
|
||||
|
||||
void OnPinSubmit(const std::u16string& pin) override {
|
||||
++pin_submit_counter_;
|
||||
}
|
||||
void OnPinSubmit(std::u16string_view pin) override { ++pin_submit_counter_; }
|
||||
|
||||
// views::ViewObserver:
|
||||
void OnViewRemovedFromWidget(views::View* observed_view) override {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/login/ui/local_authentication_request_view.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/accessibility/accessibility_controller.h"
|
||||
#include "ash/keyboard/ui/keyboard_ui_controller.h"
|
||||
@ -383,7 +384,7 @@ LocalAuthenticationRequestView::GetLocalAuthenticationRequestViewSize() const {
|
||||
|
||||
void LocalAuthenticationRequestView::OnAuthSubmit(
|
||||
bool authenticated_by_pin,
|
||||
const std::u16string& password) {
|
||||
std::u16string_view password) {
|
||||
CHECK(!authenticated_by_pin);
|
||||
SetInputEnabled(false);
|
||||
|
||||
@ -432,7 +433,8 @@ void LocalAuthenticationRequestView::UpdateAccessibleName() {
|
||||
GetViewAccessibility().SetName(
|
||||
std::string(), ax::mojom::NameFrom::kAttributeExplicitlyEmpty);
|
||||
} else {
|
||||
GetViewAccessibility().SetName(description_label_->GetText());
|
||||
GetViewAccessibility().SetName(
|
||||
std::u16string(description_label_->GetText()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/login/ui/access_code_input.h"
|
||||
@ -108,7 +109,7 @@ class ASH_EXPORT LocalAuthenticationRequestView
|
||||
const std::u16string& description);
|
||||
|
||||
private:
|
||||
void OnAuthSubmit(bool authenticated_by_pin, const std::u16string& password);
|
||||
void OnAuthSubmit(bool authenticated_by_pin, std::u16string_view password);
|
||||
|
||||
void OnAuthComplete(std::unique_ptr<UserContext> user_context,
|
||||
std::optional<AuthenticationError> authentication_error);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ash/auth/views/active_session_auth_view.h"
|
||||
@ -111,7 +112,7 @@ void LocalAuthenticationWithPinTestApi::SetPinStatus(
|
||||
controller_->contents_view_->SetPinStatus(std::move(pin_status));
|
||||
}
|
||||
|
||||
const std::u16string& LocalAuthenticationWithPinTestApi::GetPinStatusMessage()
|
||||
std::u16string_view LocalAuthenticationWithPinTestApi::GetPinStatusMessage()
|
||||
const {
|
||||
return controller_->contents_view_->GetPinStatusMessage();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/auth/views/active_session_auth_view.h"
|
||||
#include "ash/login/ui/local_authentication_request_controller_impl.h"
|
||||
@ -66,7 +67,7 @@ class LocalAuthenticationWithPinTestApi : public LocalAuthenticationTestApi {
|
||||
|
||||
void SetPinStatus(std::unique_ptr<cryptohome::PinStatus> pin_status);
|
||||
|
||||
const std::u16string& GetPinStatusMessage() const;
|
||||
std::u16string_view GetPinStatusMessage() const;
|
||||
|
||||
void Close() override;
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
@ -495,13 +496,13 @@ void LoginAuthUserView::TestApi::ShowDialog() {
|
||||
view_->ShowRemoveAccountDialog();
|
||||
}
|
||||
|
||||
const std::u16string&
|
||||
LoginAuthUserView::TestApi::GetDisabledAuthMessageContent() const {
|
||||
std::u16string_view LoginAuthUserView::TestApi::GetDisabledAuthMessageContent()
|
||||
const {
|
||||
return DisabledAuthMessageView::TestApi(view_->disabled_auth_message_)
|
||||
.GetDisabledAuthMessageContent();
|
||||
}
|
||||
|
||||
const std::u16string& LoginAuthUserView::TestApi::GetPinStatusMessageContent()
|
||||
std::u16string_view LoginAuthUserView::TestApi::GetPinStatusMessageContent()
|
||||
const {
|
||||
return PinStatusMessageView::TestApi(view_->pin_status_message_view_)
|
||||
.GetPinStatusMessageContent();
|
||||
@ -1116,7 +1117,7 @@ void LoginAuthUserView::OnGestureEvent(ui::GestureEvent* event) {
|
||||
RequestFocus();
|
||||
}
|
||||
|
||||
void LoginAuthUserView::OnAuthSubmit(const std::u16string& password) {
|
||||
void LoginAuthUserView::OnAuthSubmit(std::u16string_view password) {
|
||||
AuthEventsRecorder::Get()->OnAuthSubmit();
|
||||
LOG(WARNING) << "crbug.com/1339004 : AuthSubmit "
|
||||
<< password_view_->IsReadOnly() << " / "
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/login/ui/auth_factor_model.h"
|
||||
@ -144,11 +145,11 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView {
|
||||
AuthFactorModel* smart_lock_auth_factor_model() const;
|
||||
PinStatusMessageView* pin_status_message_view() const;
|
||||
bool HasAuthMethod(AuthMethods auth_method) const;
|
||||
const std::u16string& GetDisabledAuthMessageContent() const;
|
||||
std::u16string_view GetDisabledAuthMessageContent() const;
|
||||
void SetFingerprintState(FingerprintState state) const;
|
||||
void SetSmartLockState(SmartLockState state) const;
|
||||
void ShowDialog();
|
||||
const std::u16string& GetPinStatusMessageContent() const;
|
||||
std::u16string_view GetPinStatusMessageContent() const;
|
||||
|
||||
private:
|
||||
const raw_ptr<LoginAuthUserView, DanglingUntriaged> view_;
|
||||
@ -254,7 +255,7 @@ class ASH_EXPORT LoginAuthUserView : public NonAccessibleView {
|
||||
class ChallengeResponseView;
|
||||
|
||||
// Called when the user submits an auth method. Runs mojo call.
|
||||
void OnAuthSubmit(const std::u16string& password);
|
||||
void OnAuthSubmit(std::u16string_view password);
|
||||
// Called with the result of the request started in |OnAuthSubmit| or
|
||||
// |AttemptAuthenticateWithExternalBinary|.
|
||||
void OnAuthComplete(bool authenticated_by_pin,
|
||||
|
@ -466,7 +466,7 @@ void LoginPasswordView::Reset() {
|
||||
textfield_->ClearEditHistory();
|
||||
// |ContentsChanged| won't be called by |Textfield| if the text is changed
|
||||
// by |Textfield::SetText()|.
|
||||
ContentsChanged(textfield_, textfield_->GetText());
|
||||
ContentsChanged(textfield_, std::u16string(textfield_->GetText()));
|
||||
}
|
||||
|
||||
void LoginPasswordView::InsertNumber(int value) {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/ime/ime_controller_impl.h"
|
||||
@ -78,7 +79,7 @@ class ASH_EXPORT LoginPasswordView : public views::View,
|
||||
};
|
||||
|
||||
using OnPasswordSubmit =
|
||||
base::RepeatingCallback<void(const std::u16string& password)>;
|
||||
base::RepeatingCallback<void(std::u16string_view password)>;
|
||||
using OnPasswordTextChanged = base::RepeatingCallback<void(bool is_empty)>;
|
||||
|
||||
// Must call |Init| after construction.
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/login/ui/login_password_view.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/login/ui/login_arrow_navigation_delegate.h"
|
||||
#include "ash/login/ui/login_test_base.h"
|
||||
@ -58,8 +59,8 @@ class LoginPasswordViewTest : public LoginTestBase {
|
||||
SetWidget(CreateWidgetWithContent(view_));
|
||||
}
|
||||
|
||||
void OnPasswordSubmit(const std::u16string& password) {
|
||||
password_ = password;
|
||||
void OnPasswordSubmit(std::u16string_view password) {
|
||||
password_ = std::u16string_view(password);
|
||||
}
|
||||
void OnPasswordTextChanged(bool is_empty) {
|
||||
is_password_field_empty_ = is_empty;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/login/ui/login_pin_input_view.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/login/login_screen_controller.h"
|
||||
@ -211,7 +212,7 @@ void LoginPinInputView::Init(const OnPinSubmit& on_submit,
|
||||
on_changed_ = on_changed;
|
||||
}
|
||||
|
||||
void LoginPinInputView::SubmitPin(const std::u16string& pin) {
|
||||
void LoginPinInputView::SubmitPin(std::u16string_view pin) {
|
||||
DCHECK(on_submit_);
|
||||
on_submit_.Run(pin);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef ASH_LOGIN_UI_LOGIN_PIN_INPUT_VIEW_H_
|
||||
#define ASH_LOGIN_UI_LOGIN_PIN_INPUT_VIEW_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/login/ui/access_code_input.h"
|
||||
#include "ash/login/ui/non_accessible_view.h"
|
||||
@ -38,7 +40,7 @@ class ASH_EXPORT LoginPinInputView : public views::View,
|
||||
METADATA_HEADER(LoginPinInputView, views::View)
|
||||
|
||||
public:
|
||||
using OnPinSubmit = base::RepeatingCallback<void(const std::u16string& pin)>;
|
||||
using OnPinSubmit = base::RepeatingCallback<void(std::u16string_view pin)>;
|
||||
using OnPinChanged = base::RepeatingCallback<void(bool is_empty)>;
|
||||
|
||||
static const int kDefaultLength;
|
||||
@ -99,7 +101,7 @@ class ASH_EXPORT LoginPinInputView : public views::View,
|
||||
|
||||
private:
|
||||
// The code input will call this when all digits are in.
|
||||
void SubmitPin(const std::u16string& pin);
|
||||
void SubmitPin(std::u16string_view pin);
|
||||
|
||||
// Called by the inner view whenever the fields change.
|
||||
void OnChanged(bool is_empty);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/login/ui/login_test_base.h"
|
||||
#include "base/functional/bind.h"
|
||||
@ -46,8 +47,8 @@ class LoginPinInputViewTest
|
||||
SetWidget(CreateWidgetWithContent(view_));
|
||||
}
|
||||
|
||||
void OnPinSubmit(const std::u16string& pin) {
|
||||
submitted_pin_ = std::make_optional(pin);
|
||||
void OnPinSubmit(std::u16string_view pin) {
|
||||
submitted_pin_ = std::make_optional(std::u16string(pin));
|
||||
}
|
||||
|
||||
void OnPinChanged(const bool is_empty) {
|
||||
|
@ -321,7 +321,8 @@ void LoginRemoveAccountDialog::UpdateAccessibleDescription() {
|
||||
base::StrCat({email_label_->GetText(), u" ",
|
||||
management_disclosure_label_->GetText()}));
|
||||
} else {
|
||||
GetViewAccessibility().SetDescription(email_label_->GetText());
|
||||
GetViewAccessibility().SetDescription(
|
||||
std::u16string(email_label_->GetText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,9 +332,9 @@ void LoginRemoveAccountDialog::UpdateAccessibleName() {
|
||||
GetViewAccessibility().SetName(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_LOGIN_POD_REMOVE_ACCOUNT_ACCESSIBLE_NAME));
|
||||
} else {
|
||||
std::u16string accessible_name = username_label_->GetText();
|
||||
std::u16string_view accessible_name = username_label_->GetText();
|
||||
if (!accessible_name.empty()) {
|
||||
GetViewAccessibility().SetName(accessible_name);
|
||||
GetViewAccessibility().SetName(std::u16string(accessible_name));
|
||||
} else {
|
||||
GetViewAccessibility().SetName(
|
||||
std::u16string(), ax::mojom::NameFrom::kAttributeExplicitlyEmpty);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ash/login/ui/login_user_view.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_element_identifiers.h"
|
||||
#include "ash/login/ui/animated_rounded_image_view.h"
|
||||
@ -323,7 +324,7 @@ class LoginUserView::UserLabel : public NonAccessibleView {
|
||||
gfx::ElideBehavior::ELIDE_TAIL));
|
||||
}
|
||||
|
||||
const std::u16string& displayed_name() const { return user_name_->GetText(); }
|
||||
std::u16string_view displayed_name() const { return user_name_->GetText(); }
|
||||
|
||||
private:
|
||||
raw_ptr<views::Label> user_name_ = nullptr;
|
||||
@ -381,7 +382,7 @@ LoginDisplayStyle LoginUserView::TestApi::display_style() const {
|
||||
return view_->display_style_;
|
||||
}
|
||||
|
||||
const std::u16string& LoginUserView::TestApi::displayed_name() const {
|
||||
std::u16string_view LoginUserView::TestApi::displayed_name() const {
|
||||
return view_->user_label_->displayed_name();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef ASH_LOGIN_UI_LOGIN_USER_VIEW_H_
|
||||
#define ASH_LOGIN_UI_LOGIN_USER_VIEW_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ash/login/ui/login_base_bubble_view.h"
|
||||
#include "ash/login/ui/login_display_style.h"
|
||||
@ -36,7 +38,7 @@ class ASH_EXPORT LoginUserView : public views::View,
|
||||
|
||||
LoginDisplayStyle display_style() const;
|
||||
|
||||
const std::u16string& displayed_name() const;
|
||||
std::u16string_view displayed_name() const;
|
||||
|
||||
views::View* user_label() const;
|
||||
views::View* tap_button() const;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/style/ash_color_id.h"
|
||||
@ -50,8 +51,8 @@ PinStatusMessageView::TestApi::TestApi(PinStatusMessageView* view)
|
||||
|
||||
PinStatusMessageView::TestApi::~TestApi() = default;
|
||||
|
||||
const std::u16string&
|
||||
PinStatusMessageView::TestApi::GetPinStatusMessageContent() const {
|
||||
std::u16string_view PinStatusMessageView::TestApi::GetPinStatusMessageContent()
|
||||
const {
|
||||
return view_->message_->GetText();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef ASH_LOGIN_UI_PIN_STATUS_MESSAGE_VIEW_H_
|
||||
#define ASH_LOGIN_UI_PIN_STATUS_MESSAGE_VIEW_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/time/time.h"
|
||||
@ -23,7 +25,7 @@ class PinStatusMessageView : public views::View {
|
||||
explicit TestApi(PinStatusMessageView* view);
|
||||
~TestApi();
|
||||
|
||||
const std::u16string& GetPinStatusMessageContent() const;
|
||||
std::u16string_view GetPinStatusMessageContent() const;
|
||||
|
||||
private:
|
||||
const raw_ptr<PinStatusMessageView> view_;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_PUBLIC_CPP_LOGIN_SCREEN_TEST_API_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/public/cpp/ash_public_export.h"
|
||||
#include "ash/public/cpp/login_types.h"
|
||||
@ -54,7 +55,8 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
|
||||
const std::string& password,
|
||||
bool check_if_submittable);
|
||||
static void SubmitPin(const AccountId& account_id, const std::string& pin);
|
||||
static std::u16string GetChallengeResponseLabel(const AccountId& account_id);
|
||||
static std::u16string_view GetChallengeResponseLabel(
|
||||
const AccountId& account_id);
|
||||
static bool IsChallengeResponseButtonClickable(const AccountId& account_id);
|
||||
static void ClickChallengeResponseButton(const AccountId& account_id);
|
||||
static int64_t GetUiUpdateCount();
|
||||
@ -75,8 +77,9 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
|
||||
static bool RemoveUser(const AccountId& account_id);
|
||||
|
||||
static std::string GetDisplayedName(const AccountId& account_id);
|
||||
static std::u16string GetDisabledAuthMessage(const AccountId& account_id);
|
||||
static std::u16string GetManagementDisclosureText(
|
||||
static std::u16string_view GetDisabledAuthMessage(
|
||||
const AccountId& account_id);
|
||||
static std::u16string_view GetManagementDisclosureText(
|
||||
const AccountId& account_id);
|
||||
|
||||
static bool ExpandPublicSessionPod(const AccountId& account_id);
|
||||
@ -95,14 +98,14 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
|
||||
static std::string GetExpandedPublicSessionSelectedKeyboard();
|
||||
|
||||
static bool IsOobeDialogVisible();
|
||||
static std::u16string GetShutDownButtonLabel();
|
||||
static std::u16string_view GetShutDownButtonLabel();
|
||||
static gfx::Rect GetShutDownButtonTargetBounds();
|
||||
static gfx::Rect GetShutDownButtonMirroredBounds();
|
||||
static std::string GetAppsButtonClassName();
|
||||
|
||||
static void SetPinRequestWidgetShownCallback(
|
||||
base::RepeatingClosure on_pin_request_widget_shown);
|
||||
static std::u16string GetPinRequestWidgetTitle();
|
||||
static std::u16string_view GetPinRequestWidgetTitle();
|
||||
static void SubmitPinRequestWidget(const std::string& pin);
|
||||
static void CancelPinRequestWidget();
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
|
||||
@ -89,7 +90,7 @@ class ASH_EXPORT SystemTrayTestApi {
|
||||
// Returns the text for a sub-view `view_id` of `GetMainBubbleView()`, or the
|
||||
// empty string if the view does not exist. This method only works if the
|
||||
// bubble view is a label.
|
||||
std::u16string GetBubbleViewText(int view_id);
|
||||
std::u16string_view GetBubbleViewText(int view_id);
|
||||
|
||||
// Get the notification pop up view based on the notification id.
|
||||
message_center::MessagePopupView* GetPopupViewForNotificationID(
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_PUBLIC_CPP_TEST_APP_LIST_TEST_API_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
@ -67,7 +68,7 @@ class ASH_EXPORT AppListTestApi {
|
||||
bool HasApp(const std::string& app_id);
|
||||
|
||||
// Returns the name displayed in the launcher for the provided app list item.
|
||||
std::u16string GetAppListItemViewName(const std::string& item_id);
|
||||
std::u16string_view GetAppListItemViewName(const std::string& item_id);
|
||||
|
||||
// Returns the top level item view specified by `item_id`.
|
||||
AppListItemView* GetTopLevelItemViewFromId(const std::string& item_id);
|
||||
|
@ -61,7 +61,7 @@ QuickInsertBadgeView::QuickInsertBadgeView() {
|
||||
|
||||
QuickInsertBadgeView::~QuickInsertBadgeView() = default;
|
||||
|
||||
const std::u16string& QuickInsertBadgeView::GetText() const {
|
||||
std::u16string_view QuickInsertBadgeView::GetText() const {
|
||||
return label_->GetText();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_QUICK_INSERT_VIEWS_QUICK_INSERT_BADGE_VIEW_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
@ -30,7 +31,7 @@ class ASH_EXPORT QuickInsertBadgeView : public views::BoxLayoutView {
|
||||
QuickInsertBadgeView& operator=(const QuickInsertBadgeView&) = delete;
|
||||
~QuickInsertBadgeView() override;
|
||||
|
||||
const std::u16string& GetText() const;
|
||||
std::u16string_view GetText() const;
|
||||
void SetText(const std::u16string& text);
|
||||
|
||||
// views::BoxLayoutView:
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ash/bubble/bubble_utils.h"
|
||||
@ -145,8 +146,7 @@ void QuickInsertItemWithSubmenuView::OnMouseEntered(
|
||||
ShowSubmenu();
|
||||
}
|
||||
|
||||
const std::u16string& QuickInsertItemWithSubmenuView::GetTextForTesting()
|
||||
const {
|
||||
std::u16string_view QuickInsertItemWithSubmenuView::GetTextForTesting() const {
|
||||
return label_->GetText();
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user