Change GetClassName() to return a std::string_view and clean up callers.
Bug: 364987728 Change-Id: I4e0a43b49c93f0ad9f73dc3ca0ade26988cfff25 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6230223 Reviewed-by: Mitsuru Oshima <oshima@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Reviewed-by: Allen Bauer <kylixrd@chromium.org> Commit-Queue: Peter Kasting <pkasting@chromium.org> Owners-Override: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/main@{#1416424}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
eb5f5ee80d
commit
0600f5d827
ash
accessibility
app_list
hud_display
login
shelf
system
accessibility
audio
bluetooth
bluetooth_device_list_controller_unittest.ccbluetooth_device_list_item_view.ccbluetooth_feature_pod_controller_unittest.cc
brightness
cast
focus_mode
network
network_feature_pod_controller_unittest.ccnetwork_list_view_controller_unittest.ccvpn_detailed_view_unittest.cc
phonehub
time
calendar_event_list_view.cccalendar_up_next_view_unittest.cccalendar_view.cccalendar_view_unittest.cc
tray
unified
chrome
browser
ash
notifications
ui
ash
views
autofill
desktop_capture
download
extensions
find_bar_views_interactive_uitest.ccframe
task_manager_search_bar_view_unittest.cctoolbar
webid
test
interaction
components
ui
base
views
@ -56,8 +56,7 @@ void NativeFocusWatcher::UpdateFocusedView() {
|
||||
gfx::Rect view_bounds = view->GetContentsBounds();
|
||||
|
||||
// Workarounds that attempts to pick a better bounds.
|
||||
if (std::string_view(view->GetClassName()) ==
|
||||
std::string_view(views::LabelButton::kViewClassName)) {
|
||||
if (view->GetClassName() == views::LabelButton::kViewClassName) {
|
||||
view_bounds = view->GetLocalBounds();
|
||||
view_bounds.Inset(2);
|
||||
}
|
||||
|
@ -1183,8 +1183,7 @@ void AppListControllerImpl::SetKeyboardTraversalMode(bool engaged) {
|
||||
// TODO(https://crbug.com/1262236): class name comparision and static cast
|
||||
// should be avoided in the production code. Find a better way to guarantee
|
||||
// the item's selection status.
|
||||
if (std::string_view(focused_view->GetClassName()) ==
|
||||
std::string_view(AppListItemView::kViewClassName)) {
|
||||
if (focused_view->GetClassName() == AppListItemView::kViewClassName) {
|
||||
static_cast<AppListItemView*>(focused_view)->EnsureSelected();
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ class AppListBubbleViewTest : public AshTestBase {
|
||||
->IsBubbleShown();
|
||||
}
|
||||
|
||||
const char* GetFocusedViewName() {
|
||||
std::string_view GetFocusedViewName() {
|
||||
auto* view = GetFocusedView();
|
||||
return view ? view->GetClassName() : "none";
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "ui/views/border.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/layout/box_layout.h"
|
||||
#include "ui/views/view_utils.h"
|
||||
|
||||
namespace ash {
|
||||
namespace hud_display {
|
||||
@ -183,23 +184,17 @@ void Legend::Layout(PassKey) {
|
||||
gfx::Size max_size;
|
||||
bool updated = false;
|
||||
for (views::View* view : children()) {
|
||||
if (std::string_view(view->GetClassName()) !=
|
||||
std::string_view(LegendEntry::kViewClassName)) {
|
||||
continue;
|
||||
if (auto* entry = views::AsViewClass<LegendEntry>(view)) {
|
||||
views::View* value = entry->value();
|
||||
max_size.SetToMax(value->GetPreferredSize());
|
||||
updated |= max_size != value->GetPreferredSize();
|
||||
}
|
||||
|
||||
views::View* value = static_cast<LegendEntry*>(view)->value();
|
||||
max_size.SetToMax(value->GetPreferredSize());
|
||||
updated |= max_size != value->GetPreferredSize();
|
||||
}
|
||||
if (updated) {
|
||||
for (views::View* view : children()) {
|
||||
if (std::string_view(view->GetClassName()) !=
|
||||
std::string_view(LegendEntry::kViewClassName)) {
|
||||
continue;
|
||||
if (auto* entry = views::AsViewClass<LegendEntry>(view)) {
|
||||
entry->value()->SetPreferredSize(max_size);
|
||||
}
|
||||
|
||||
static_cast<LegendEntry*>(view)->value()->SetPreferredSize(max_size);
|
||||
}
|
||||
LayoutSuperclass<views::View>(this);
|
||||
}
|
||||
@ -207,23 +202,17 @@ void Legend::Layout(PassKey) {
|
||||
|
||||
void Legend::SetValuesIndex(size_t index) {
|
||||
for (views::View* view : children()) {
|
||||
if (std::string_view(view->GetClassName()) !=
|
||||
std::string_view(LegendEntry::kViewClassName)) {
|
||||
continue;
|
||||
if (auto* entry = views::AsViewClass<LegendEntry>(view)) {
|
||||
entry->SetValueIndex(index);
|
||||
}
|
||||
|
||||
static_cast<LegendEntry*>(view)->SetValueIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void Legend::RefreshValues() {
|
||||
for (views::View* view : children()) {
|
||||
if (std::string_view(view->GetClassName()) !=
|
||||
std::string_view(LegendEntry::kViewClassName)) {
|
||||
continue;
|
||||
if (auto* entry = views::AsViewClass<LegendEntry>(view)) {
|
||||
entry->RefreshValue();
|
||||
}
|
||||
|
||||
static_cast<LegendEntry*>(view)->RefreshValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -881,12 +881,10 @@ gfx::Rect LoginScreenTestApi::GetShutDownButtonMirroredBounds() {
|
||||
|
||||
// static
|
||||
std::string LoginScreenTestApi::GetAppsButtonClassName() {
|
||||
views::View* button = GetAppsButton();
|
||||
if (!button) {
|
||||
return "";
|
||||
if (views::View* button = GetAppsButton()) {
|
||||
return std::string(button->GetClassName());
|
||||
}
|
||||
|
||||
return button->GetClassName();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -103,7 +103,7 @@ class AssistantOverlayTest : public AshTestBase,
|
||||
protected:
|
||||
const views::View* GetAssistantOverlay() {
|
||||
for (const views::View* child : home_button()->children()) {
|
||||
if (std::string(child->GetClassName()) == kAssistantOverlayClassName) {
|
||||
if (child->GetClassName() == kAssistantOverlayClassName) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
@ -491,10 +491,6 @@ class AccessibilityDetailedViewTest : public AshTestBase,
|
||||
detailed_menu_->color_correction_view_);
|
||||
}
|
||||
|
||||
const char* GetDetailedViewClassName() {
|
||||
return detailed_menu_->GetClassName();
|
||||
}
|
||||
|
||||
void SetUpKioskSession() {
|
||||
auto* session_controller = Shell::Get()->session_controller();
|
||||
SessionInfo info;
|
||||
|
@ -238,7 +238,7 @@ TEST_F(DictationBubbleControllerTest, DictationHintViewClassHasTheRightName) {
|
||||
Show(DictationBubbleIconType::kStandby, std::optional<std::u16string>(),
|
||||
std::optional<std::vector<DictationBubbleHintType>>());
|
||||
EXPECT_TRUE(GetView());
|
||||
EXPECT_STREQ(GetHintView()->GetClassName(), "DictationHintView");
|
||||
EXPECT_EQ(GetHintView()->GetClassName(), "DictationHintView");
|
||||
|
||||
HideAndCheckExpectations();
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ class UnifiedAudioDetailedViewControllerTest : public AshTestBase {
|
||||
slider_button->GetViewAccessibility().IsAccessibilityFocusable());
|
||||
|
||||
slider->RequestFocus();
|
||||
EXPECT_STREQ(slider->GetFocusManager()->GetFocusedView()->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
EXPECT_EQ(slider->GetFocusManager()->GetFocusedView()->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
// Check the accessibility role of QuickSettingsSlider.
|
||||
ui::AXNodeData node_data;
|
||||
slider->GetFocusManager()
|
||||
|
@ -80,13 +80,13 @@ class UnifiedVolumeViewTest : public AshTestBase {
|
||||
// `LiveCaption` button, and a drill-in button that leads to
|
||||
// `AudioDetailedView`.
|
||||
TEST_F(UnifiedVolumeViewTest, SliderButtonComponents) {
|
||||
EXPECT_STREQ(unified_volume_view()->children()[0]->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
EXPECT_EQ(unified_volume_view()->children()[0]->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
|
||||
// TODO(b/257151067): Updates the a11y name id and tooltip text.
|
||||
auto* live_caption_button =
|
||||
static_cast<IconButton*>(unified_volume_view()->children()[1]);
|
||||
EXPECT_STREQ(live_caption_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(live_caption_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(live_caption_button->GetViewAccessibility().GetCachedName(),
|
||||
l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_STATUS_TRAY_LIVE_CAPTION_TOGGLE_TOOLTIP,
|
||||
@ -97,7 +97,7 @@ TEST_F(UnifiedVolumeViewTest, SliderButtonComponents) {
|
||||
|
||||
auto* audio_subpage_drill_in_button =
|
||||
static_cast<IconButton*>(unified_volume_view()->children()[2]);
|
||||
EXPECT_STREQ(audio_subpage_drill_in_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(audio_subpage_drill_in_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(
|
||||
audio_subpage_drill_in_button->GetViewAccessibility().GetCachedName(),
|
||||
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_AUDIO));
|
||||
@ -234,11 +234,11 @@ TEST_F(UnifiedVolumeViewTest, SliderFocusToggleMute) {
|
||||
// Presses the tab key to activate the focus on the bubble.
|
||||
generator->PressAndReleaseKey(ui::KeyboardCode::VKEY_TAB);
|
||||
slider()->RequestFocus();
|
||||
EXPECT_STREQ(unified_volume_view()
|
||||
->GetFocusManager()
|
||||
->GetFocusedView()
|
||||
->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
EXPECT_EQ(unified_volume_view()
|
||||
->GetFocusManager()
|
||||
->GetFocusedView()
|
||||
->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
|
||||
const bool is_muted = CrasAudioHandler::Get()->IsOutputMuted();
|
||||
// Presses the enter key when focused on the slider will toggle mute state.
|
||||
|
@ -2,14 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/system/bluetooth/bluetooth_device_list_controller_impl.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "ash/system/bluetooth/bluetooth_detailed_view.h"
|
||||
#include "ash/system/bluetooth/bluetooth_device_list_controller_impl.h"
|
||||
#include "ash/system/bluetooth/bluetooth_device_list_item_view.h"
|
||||
#include "ash/system/bluetooth/fake_bluetooth_detailed_view.h"
|
||||
#include "ash/system/tray/tri_view.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/view_utils.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
@ -154,11 +154,10 @@ class BluetoothDeviceListControllerTest : public AshTestBase {
|
||||
private:
|
||||
const TriView* FindSubHeaderWithText(const std::u16string& text) {
|
||||
for (const views::View* view : device_list()->children()) {
|
||||
if (std::strcmp("TriView", view->GetClassName()))
|
||||
continue;
|
||||
const TriView* sub_header = static_cast<const TriView*>(view);
|
||||
if (GetSubHeaderText(sub_header) == text)
|
||||
if (const auto* sub_header = views::AsViewClass<TriView>(view);
|
||||
sub_header && GetSubHeaderText(sub_header) == text) {
|
||||
return sub_header;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -284,9 +284,8 @@ void BluetoothDeviceListItemView::UpdateMultipleBatteryView(
|
||||
// Remove battery view if it is not a multiple battery view.
|
||||
if (!sub_row()->children().empty()) {
|
||||
DCHECK(sub_row()->children().size() == 1);
|
||||
if (std::string_view(sub_row()->children().at(0)->GetClassName()) !=
|
||||
std::string_view(
|
||||
BluetoothDeviceListItemMultipleBatteryView::kViewClassName)) {
|
||||
if (sub_row()->children().at(0)->GetClassName() !=
|
||||
BluetoothDeviceListItemMultipleBatteryView::kViewClassName) {
|
||||
sub_row()->RemoveAllChildViews();
|
||||
}
|
||||
}
|
||||
@ -312,8 +311,8 @@ void BluetoothDeviceListItemView::UpdateSingleBatteryView(
|
||||
// Remove battery view if it is not a single battery view.
|
||||
if (!sub_row()->children().empty()) {
|
||||
DCHECK(sub_row()->children().size() == 1);
|
||||
if (std::string_view(sub_row()->children().at(0)->GetClassName()) !=
|
||||
std::string_view(BluetoothDeviceListItemBatteryView::kViewClassName)) {
|
||||
if (sub_row()->children().at(0)->GetClassName() !=
|
||||
BluetoothDeviceListItemBatteryView::kViewClassName) {
|
||||
sub_row()->RemoveAllChildViews();
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class BluetoothFeaturePodControllerTest
|
||||
const views::View::Views& children = container->children();
|
||||
if (is_showing) {
|
||||
EXPECT_EQ(1u, children.size());
|
||||
EXPECT_STREQ("BluetoothDetailedViewImpl", children.at(0)->GetClassName());
|
||||
EXPECT_EQ("BluetoothDetailedViewImpl", children.at(0)->GetClassName());
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(0u, children.size());
|
||||
|
@ -60,14 +60,13 @@ TEST_F(DisplayDetailedViewTest, ScrollContentChildren) {
|
||||
views::View* tile_container = GetTileContainer(&detailed_view);
|
||||
ASSERT_TRUE(tile_container);
|
||||
ASSERT_EQ(tile_container->children().size(), 2u);
|
||||
EXPECT_STREQ(tile_container->children()[0]->GetClassName(), "FeatureTile");
|
||||
EXPECT_STREQ(tile_container->children()[1]->GetClassName(), "FeatureTile");
|
||||
EXPECT_EQ(tile_container->children()[0]->GetClassName(), "FeatureTile");
|
||||
EXPECT_EQ(tile_container->children()[1]->GetClassName(), "FeatureTile");
|
||||
|
||||
// The second children of scroll content is the `UnifiedBrightnessView`.
|
||||
views::View* unified_brightness_view =
|
||||
scroll_content->GetViewByID(VIEW_ID_QS_DISPLAY_BRIGHTNESS_SLIDER);
|
||||
EXPECT_STREQ(unified_brightness_view->GetClassName(),
|
||||
"UnifiedBrightnessView");
|
||||
EXPECT_EQ(unified_brightness_view->GetClassName(), "UnifiedBrightnessView");
|
||||
}
|
||||
|
||||
TEST_F(DisplayDetailedViewTest, FeatureTileVisibility) {
|
||||
|
@ -127,13 +127,13 @@ TEST_F(UnifiedBrightnessViewTest, SliderButtonClickThrough) {
|
||||
// `NightLight` button, and a drill-in button that leads to the display subpage.
|
||||
TEST_F(UnifiedBrightnessViewTest, SliderButtonComponents) {
|
||||
EXPECT_EQ(unified_brightness_view()->children().size(), 3u);
|
||||
EXPECT_STREQ(unified_brightness_view()->children()[0]->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
EXPECT_EQ(unified_brightness_view()->children()[0]->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
|
||||
// TODO(b/257151067): Updates the a11y name id and tooltip text.
|
||||
auto* night_light_button =
|
||||
static_cast<IconButton*>(unified_brightness_view()->children()[1]);
|
||||
EXPECT_STREQ(night_light_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(night_light_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(night_light_button->GetViewAccessibility().GetCachedName(),
|
||||
l10n_util::GetStringFUTF16(
|
||||
IDS_ASH_STATUS_TRAY_NIGHT_LIGHT_TOGGLE_TOOLTIP,
|
||||
@ -144,7 +144,7 @@ TEST_F(UnifiedBrightnessViewTest, SliderButtonComponents) {
|
||||
|
||||
auto* display_subpage_drill_in_button =
|
||||
static_cast<IconButton*>(unified_brightness_view()->children()[2]);
|
||||
EXPECT_STREQ(display_subpage_drill_in_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(display_subpage_drill_in_button->GetClassName(), "IconButton");
|
||||
EXPECT_EQ(
|
||||
display_subpage_drill_in_button->GetViewAccessibility().GetCachedName(),
|
||||
l10n_util::GetStringUTF16(
|
||||
@ -162,8 +162,8 @@ TEST_F(UnifiedBrightnessViewTest, SliderButtonComponents) {
|
||||
// `QuickSettingsSlider`.
|
||||
TEST_F(UnifiedBrightnessViewTest, SliderComponent) {
|
||||
EXPECT_EQ(brightness_slider()->children().size(), 1u);
|
||||
EXPECT_STREQ(brightness_slider()->children()[0]->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
EXPECT_EQ(brightness_slider()->children()[0]->GetClassName(),
|
||||
"QuickSettingsSlider");
|
||||
}
|
||||
|
||||
// Tests the slider icon matches the slider level.
|
||||
|
@ -101,7 +101,7 @@ TEST_F(CastDetailedViewTest, ViewsCreatedForCastDevices) {
|
||||
|
||||
for (views::View* view : GetDeviceViews()) {
|
||||
// Device views are children of the rounded container.
|
||||
EXPECT_STREQ(view->parent()->GetClassName(), "RoundedContainer");
|
||||
EXPECT_EQ(view->parent()->GetClassName(), "RoundedContainer");
|
||||
|
||||
// Device views don't have a "stop casting" button by default.
|
||||
ASSERT_TRUE(views::IsViewClass<HoverHighlightView>(view));
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "ash/system/unified/unified_system_tray.h"
|
||||
#include "ash/system/unified/unified_system_tray_bubble.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/i18n/time_formatting.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
@ -936,8 +937,7 @@ TEST_F(FocusModeDetailedViewTest,
|
||||
|
||||
ASSERT_TRUE(hover_highlight_view);
|
||||
ASSERT_TRUE(right_view);
|
||||
ASSERT_TRUE(std::string(right_view->GetClassName()).find("Button") !=
|
||||
std::string::npos);
|
||||
ASSERT_TRUE(base::Contains(right_view->GetClassName(), "Button"));
|
||||
|
||||
hover_highlight_view->GetViewAccessibility().GetAccessibleNodeData(&data);
|
||||
EXPECT_EQ(data.GetDefaultActionVerb(), ax::mojom::DefaultActionVerb::kClick);
|
||||
|
@ -241,8 +241,7 @@ class NetworkFeaturePodControllerTest : public AshTestBase {
|
||||
children = quick_settings_view()->detailed_view_container()->children();
|
||||
|
||||
ASSERT_EQ(1u, children.size());
|
||||
EXPECT_STREQ("NetworkDetailedNetworkViewImpl",
|
||||
children.at(0)->GetClassName());
|
||||
EXPECT_EQ("NetworkDetailedNetworkViewImpl", children.at(0)->GetClassName());
|
||||
}
|
||||
|
||||
void CheckSignalStrengthSubLabel(
|
||||
|
@ -380,8 +380,8 @@ class NetworkListViewControllerTest : public AshTestBase,
|
||||
size_t index,
|
||||
const std::optional<std::string>& guid) {
|
||||
ASSERT_GT(network_list(type)->children().size(), index);
|
||||
EXPECT_STREQ(network_list(type)->children().at(index)->GetClassName(),
|
||||
kNetworkListNetworkItemView);
|
||||
EXPECT_EQ(network_list(type)->children().at(index)->GetClassName(),
|
||||
kNetworkListNetworkItemView);
|
||||
|
||||
const NetworkStatePropertiesPtr& network =
|
||||
static_cast<NetworkListNetworkItemView*>(
|
||||
@ -395,8 +395,8 @@ class NetworkListViewControllerTest : public AshTestBase,
|
||||
}
|
||||
|
||||
bool GetNetworkListItemIsEnabled(NetworkType type, size_t index) {
|
||||
EXPECT_STREQ(network_list(type)->children().at(index)->GetClassName(),
|
||||
kNetworkListNetworkItemView);
|
||||
EXPECT_EQ(network_list(type)->children().at(index)->GetClassName(),
|
||||
kNetworkListNetworkItemView);
|
||||
|
||||
NetworkListNetworkItemView* network =
|
||||
static_cast<NetworkListNetworkItemView*>(
|
||||
|
@ -165,11 +165,11 @@ TEST_F(VpnDetailedViewTest, ParentContainerConfiguration) {
|
||||
AddVpnProvidersAndNetwork();
|
||||
for (const views::View* view : GetProviderViews()) {
|
||||
const views::View* parent = view->parent();
|
||||
EXPECT_STREQ(parent->GetClassName(), "RoundedContainer");
|
||||
EXPECT_EQ(parent->GetClassName(), "RoundedContainer");
|
||||
}
|
||||
for (const views::View* view : GetNetworkViews()) {
|
||||
const views::View* parent = view->parent();
|
||||
EXPECT_STREQ(parent->GetClassName(), "RoundedContainer");
|
||||
EXPECT_EQ(parent->GetClassName(), "RoundedContainer");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ TEST_F(CameraRollThumbnailTest, ViewLayout) {
|
||||
|
||||
EXPECT_EQ(camera_roll_thumbnail()->GetFocusBehavior(),
|
||||
CameraRollThumbnail::FocusBehavior::ALWAYS);
|
||||
EXPECT_STREQ("CameraRollThumbnail", camera_roll_thumbnail()->GetClassName());
|
||||
EXPECT_EQ("CameraRollThumbnail", camera_roll_thumbnail()->GetClassName());
|
||||
}
|
||||
|
||||
TEST_F(CameraRollThumbnailTest, ImageThumbnail) {
|
||||
|
@ -195,12 +195,10 @@ void CalendarEventListView::Layout(PassKey) {
|
||||
// to the current or next event. Otherwise `scroll_view_` won't scroll with
|
||||
// the focus change.
|
||||
if (GetFocusManager() && GetFocusManager()->GetFocusedView()) {
|
||||
const auto focused_view_class_name =
|
||||
std::string_view(GetFocusManager()->GetFocusedView()->GetClassName());
|
||||
if (focused_view_class_name ==
|
||||
std::string_view(CalendarEventListItemView::kViewClassName) ||
|
||||
focused_view_class_name ==
|
||||
std::string_view(PillButton::kViewClassName)) {
|
||||
if (const auto focused_view_class_name =
|
||||
GetFocusManager()->GetFocusedView()->GetClassName();
|
||||
focused_view_class_name == CalendarEventListItemView::kViewClassName ||
|
||||
focused_view_class_name == PillButton::kViewClassName) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -559,8 +559,8 @@ TEST_F(CalendarUpNextViewTest, ShouldFocusViewsInCorrectOrder_WhenPressingTab) {
|
||||
auto* first_item = GetContentsView()->children()[0].get();
|
||||
ASSERT_TRUE(first_item);
|
||||
EXPECT_EQ(first_item, focus_manager->GetFocusedView());
|
||||
EXPECT_STREQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
|
||||
// Next, the "Join" button should be focused.
|
||||
PressTab();
|
||||
@ -572,8 +572,8 @@ TEST_F(CalendarUpNextViewTest, ShouldFocusViewsInCorrectOrder_WhenPressingTab) {
|
||||
auto* second_item = GetContentsView()->children()[1].get();
|
||||
ASSERT_TRUE(second_item);
|
||||
EXPECT_EQ(second_item, focus_manager->GetFocusedView());
|
||||
EXPECT_STREQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
|
||||
// Next, the second event list item view "Join" button should be focused.
|
||||
PressTab();
|
||||
@ -593,8 +593,8 @@ TEST_F(CalendarUpNextViewTest, ShouldFocusViewsInCorrectOrder_WhenPressingTab) {
|
||||
// Going back again, the second event list item view should be focused.
|
||||
PressShiftTab();
|
||||
EXPECT_EQ(second_item, focus_manager->GetFocusedView());
|
||||
EXPECT_STREQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
}
|
||||
|
||||
// Add unittest for the fix of this bug: b/286596205.
|
||||
@ -615,16 +615,16 @@ TEST_F(CalendarUpNextViewTest, ShouldPreserveFocusAfterRefreshEvent) {
|
||||
auto* first_item = GetContentsView()->children()[0].get();
|
||||
ASSERT_TRUE(first_item);
|
||||
EXPECT_EQ(first_item, focus_manager->GetFocusedView());
|
||||
EXPECT_STREQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
|
||||
up_next_view()->RefreshEvents();
|
||||
|
||||
// After refresh the events, the first event list item view should still be
|
||||
// focused.
|
||||
EXPECT_EQ(first_item, focus_manager->GetFocusedView());
|
||||
EXPECT_STREQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ("CalendarEventListItemView",
|
||||
focus_manager->GetFocusedView()->GetClassName());
|
||||
}
|
||||
|
||||
class CalendarUpNextViewAnimationTest : public CalendarUpNextViewTest {
|
||||
|
@ -510,7 +510,7 @@ CalendarView::CalendarView(bool use_glanceables_container_style)
|
||||
// Focusable nodes must have an accessible name and valid role.
|
||||
// TODO(crbug.com/1348930): Review the accessible name and role.
|
||||
GetViewAccessibility().SetRole(ax::mojom::Role::kPane);
|
||||
GetViewAccessibility().SetName(GetClassName(),
|
||||
GetViewAccessibility().SetName(std::string(GetClassName()),
|
||||
ax::mojom::NameFrom::kAttribute);
|
||||
|
||||
views::View* calendar_header_view = nullptr;
|
||||
@ -572,7 +572,7 @@ CalendarView::CalendarView(bool use_glanceables_container_style)
|
||||
// TODO(crbug.com/1348930): Review the accessible name and role.
|
||||
content_view_->GetViewAccessibility().SetRole(ax::mojom::Role::kPane);
|
||||
content_view_->GetViewAccessibility().SetName(
|
||||
GetClassName(), ax::mojom::NameFrom::kAttribute);
|
||||
std::string(GetClassName()), ax::mojom::NameFrom::kAttribute);
|
||||
content_view_->SetFocusBehavior(FocusBehavior::ALWAYS);
|
||||
|
||||
// Set up layer for animations.
|
||||
|
@ -603,8 +603,8 @@ TEST_F(CalendarViewTest, HeaderFocusing) {
|
||||
|
||||
auto* focus_manager = calendar_view()->GetFocusManager();
|
||||
// Todays DateCellView should be focused on open.
|
||||
EXPECT_STREQ(focus_manager->GetFocusedView()->GetClassName(),
|
||||
"CalendarDateCellView");
|
||||
EXPECT_EQ(focus_manager->GetFocusedView()->GetClassName(),
|
||||
"CalendarDateCellView");
|
||||
EXPECT_EQ(
|
||||
static_cast<const views::LabelButton*>(focus_manager->GetFocusedView())
|
||||
->GetText(),
|
||||
@ -884,7 +884,7 @@ TEST_F(CalendarViewTest, FocusAfterClosingEventListView) {
|
||||
close_button());
|
||||
|
||||
PressEnter();
|
||||
EXPECT_STREQ(
|
||||
EXPECT_EQ(
|
||||
calendar_view()->GetFocusManager()->GetFocusedView()->GetClassName(),
|
||||
"CalendarDateCellView");
|
||||
}
|
||||
@ -1378,7 +1378,6 @@ TEST_F(CalendarViewTest, AdminDisabledTest) {
|
||||
|
||||
auto* focus_manager = calendar_view()->GetFocusManager();
|
||||
// Todays `DateCellView` should be focused on open.
|
||||
ASSERT_TRUE(focus_manager->GetFocusedView()->GetClassName());
|
||||
ASSERT_TRUE(focus_manager->GetFocusedView());
|
||||
|
||||
// Moves to the next focusable view - managed icon button.
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "ash/system/tray/tri_view.h"
|
||||
#include "ash/system/tray/unfocusable_label.h"
|
||||
#include "ash/system/tray/view_click_listener.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "ui/accessibility/ax_enums.mojom.h"
|
||||
#include "ui/accessibility/ax_node_data.h"
|
||||
@ -320,12 +321,10 @@ void HoverHighlightView::OnEnabledChanged() {
|
||||
}
|
||||
|
||||
void HoverHighlightView::SetAndUpdateAccessibleDefaultAction() {
|
||||
SetDefaultActionVerb(
|
||||
(right_view_ && right_view_->GetVisible() &&
|
||||
std::string(right_view_->GetClassName()).find("Button") !=
|
||||
std::string::npos)
|
||||
? ax::mojom::DefaultActionVerb::kClick
|
||||
: ax::mojom::DefaultActionVerb::kPress);
|
||||
SetDefaultActionVerb((right_view_ && right_view_->GetVisible() &&
|
||||
base::Contains(right_view_->GetClassName(), "Button"))
|
||||
? ax::mojom::DefaultActionVerb::kClick
|
||||
: ax::mojom::DefaultActionVerb::kPress);
|
||||
UpdateAccessibleDefaultActionVerb();
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ TEST_P(DateTrayTest, DontActivateBubbleIfShownByTap) {
|
||||
EXPECT_TRUE(
|
||||
GetGlanceableTrayBubble()->GetCalendarView()->Contains(focused_view));
|
||||
}
|
||||
EXPECT_STREQ("CalendarDateCellView", focused_view->GetClassName());
|
||||
EXPECT_EQ("CalendarDateCellView", focused_view->GetClassName());
|
||||
}
|
||||
|
||||
TEST_P(DateTrayTest, ActivateBubbleIfShownByKeyboard) {
|
||||
@ -477,7 +477,7 @@ TEST_P(DateTrayTest, ActivateBubbleIfShownByKeyboard) {
|
||||
EXPECT_TRUE(
|
||||
GetGlanceableTrayBubble()->GetCalendarView()->Contains(focused_view));
|
||||
}
|
||||
EXPECT_STREQ("CalendarDateCellView", focused_view->GetClassName());
|
||||
EXPECT_EQ("CalendarDateCellView", focused_view->GetClassName());
|
||||
}
|
||||
|
||||
// Tests the behavior when clicking on different areas.
|
||||
@ -632,11 +632,11 @@ TEST_P(DateTrayTest, RendersClassroomBubblesForActiveRoles) {
|
||||
// Both calendar and the `TimeManagementContainer` should be rendered in
|
||||
// `GlanceableTrayBubbleView`.
|
||||
EXPECT_EQ(GetGlanceableTrayBubble()->GetBubbleView()->children().size(), 2u);
|
||||
EXPECT_STREQ("TimeManagementContainer", GetGlanceableTrayBubble()
|
||||
->GetBubbleView()
|
||||
->children()
|
||||
.at(0)
|
||||
->GetClassName());
|
||||
EXPECT_EQ("TimeManagementContainer", GetGlanceableTrayBubble()
|
||||
->GetBubbleView()
|
||||
->children()
|
||||
.at(0)
|
||||
->GetClassName());
|
||||
}
|
||||
|
||||
TEST_P(DateTrayTest, AccessibleName) {
|
||||
|
@ -507,8 +507,8 @@ TEST_P(UnifiedSystemTrayTest, CalendarAcceleratorFocusesDateCell) {
|
||||
auto* focus_manager =
|
||||
GetUnifiedSystemTrayBubble()->GetBubbleWidget()->GetFocusManager();
|
||||
EXPECT_TRUE(focus_manager->GetFocusedView());
|
||||
EXPECT_STREQ(focus_manager->GetFocusedView()->GetClassName(),
|
||||
"CalendarDateCellView");
|
||||
EXPECT_EQ(focus_manager->GetFocusedView()->GetClassName(),
|
||||
"CalendarDateCellView");
|
||||
}
|
||||
|
||||
// Tests that using functional keys to change brightness/volume when the
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "chrome/browser/ash/notifications/echo_dialog_view.h"
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/browser/ash/notifications/echo_dialog_listener.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
@ -12,6 +13,7 @@
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/controls/styled_label.h"
|
||||
#include "ui/views/test/views_test_base.h"
|
||||
#include "ui/views/view_utils.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
@ -34,14 +36,11 @@ class TestEchoDialogListener : public EchoDialogListener {
|
||||
};
|
||||
|
||||
bool IsLabelWithText(const views::View* view, const std::u16string& text) {
|
||||
const char* class_name = view->GetClassName();
|
||||
if (!strcmp(class_name, "Label")) {
|
||||
auto* label = static_cast<const views::Label*>(view);
|
||||
return label->GetText().find(text) != label->GetText().npos;
|
||||
if (const auto* label = views::AsViewClass<views::Label>(view)) {
|
||||
return base::Contains(label->GetText(), text);
|
||||
}
|
||||
if (!strcmp(class_name, "StyledLabel")) {
|
||||
auto* styled_label = static_cast<const views::StyledLabel*>(view);
|
||||
return styled_label->GetText().find(text) != styled_label->GetText().npos;
|
||||
if (const auto* styled_label = views::AsViewClass<views::StyledLabel>(view)) {
|
||||
return base::Contains(styled_label->GetText(), text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1731,8 +1731,7 @@ IN_PROC_BROWSER_TEST_F(DesksClientTest, SystemUICaptureIncognitoBrowserTest) {
|
||||
ash::GetSavedDeskDialogAcceptButton();
|
||||
ASSERT_TRUE(dialog_accept_button);
|
||||
// MaterialNext uses PillButton instead of dialog buttons.
|
||||
if (std::string_view(dialog_accept_button->GetClassName()) ==
|
||||
std::string_view(ash::PillButton::kViewClassName)) {
|
||||
if (dialog_accept_button->GetClassName() == ash::PillButton::kViewClassName) {
|
||||
ClickView(dialog_accept_button);
|
||||
} else {
|
||||
// Use a key press to accept the dialog instead of a click as
|
||||
|
@ -180,9 +180,7 @@ TEST_F(AddressEditorViewTest, WholeFormValidationState) {
|
||||
|
||||
TEST_F(AddressEditorViewTest, InitialFocusViewPointsToCountryCombobox) {
|
||||
EXPECT_NE(view_->initial_focus_view(), nullptr);
|
||||
EXPECT_EQ(
|
||||
std::string(view_->initial_focus_view()->GetClassMetaData()->type_name()),
|
||||
"Combobox");
|
||||
EXPECT_EQ(view_->initial_focus_view()->GetClassName(), "Combobox");
|
||||
}
|
||||
|
||||
TEST_F(AddressEditorViewTest, FocusIsNotLostAfterEditorContentChange) {
|
||||
|
@ -251,10 +251,7 @@ TEST_F(EditAddressProfileViewTest, GetInitiallyFocusedView) {
|
||||
dialog->ShowForWebContents(test_web_contents());
|
||||
|
||||
EXPECT_NE(dialog->GetInitiallyFocusedView(), nullptr);
|
||||
EXPECT_EQ(
|
||||
std::string(
|
||||
dialog->GetInitiallyFocusedView()->GetClassMetaData()->type_name()),
|
||||
"Combobox");
|
||||
EXPECT_EQ(dialog->GetInitiallyFocusedView()->GetClassName(), "Combobox");
|
||||
}
|
||||
|
||||
} // namespace autofill
|
||||
|
@ -77,8 +77,7 @@ TEST_F(PopupSearchBarViewTest, SetsFocusOnTextfield) {
|
||||
|
||||
views::View* focused_field = widget().GetFocusManager()->GetFocusedView();
|
||||
ASSERT_NE(focused_field, nullptr);
|
||||
EXPECT_EQ(focused_field->GetClassMetaData()->type_name(),
|
||||
std::string("Textfield"));
|
||||
EXPECT_EQ(focused_field->GetClassName(), "Textfield");
|
||||
}
|
||||
|
||||
TEST_F(PopupSearchBarViewTest, OnFocusLostCalled) {
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace {
|
||||
|
||||
bool IsDesktopMediaTabList(views::View* view) {
|
||||
return !strcmp(view->GetClassName(), "DesktopMediaTabList");
|
||||
return view->GetClassName() == "DesktopMediaTabList";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -141,8 +141,7 @@ class SuppressBubbleSettingRow : public views::View,
|
||||
views::ViewTargeterDelegate::TargetForRect(root, rect);
|
||||
// Links should operate as expected, but all other gestures on this view
|
||||
// should be forwarded to the checkbox.
|
||||
if (std::string_view(target->GetClassName()) ==
|
||||
std::string_view(views::LinkFragment::kViewClassName)) {
|
||||
if (target->GetClassName() == views::LinkFragment::kViewClassName) {
|
||||
return target;
|
||||
}
|
||||
|
||||
|
@ -762,7 +762,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallDialogWithWithholdPermissionsUI,
|
||||
|
||||
const views::View* const extra_view = delegate_view->GetExtraView();
|
||||
EXPECT_TRUE(extra_view);
|
||||
EXPECT_EQ("Checkbox", std::string(extra_view->GetClassName()));
|
||||
EXPECT_EQ("Checkbox", extra_view->GetClassName());
|
||||
|
||||
CloseAndWait(delegate_view->GetWidget());
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class FindBarViewsUiTest : public InteractiveBrowserTest {
|
||||
focused->GetProperty(views::kElementIdentifierKey)) {
|
||||
return id.GetName();
|
||||
}
|
||||
return focused->GetClassName();
|
||||
return std::string(focused->GetClassName());
|
||||
}
|
||||
return "(none)";
|
||||
}),
|
||||
|
@ -102,8 +102,7 @@ void BrowserFrameViewLinuxNative::MaybeUpdateCachedFrameButtonImages() {
|
||||
views::Button::ButtonState button_state =
|
||||
static_cast<views::Button::ButtonState>(state);
|
||||
views::Button* button = GetButtonFromDisplayType(type);
|
||||
DCHECK_EQ(std::string(views::ImageButton::kViewClassName),
|
||||
button->GetClassName());
|
||||
DCHECK_EQ(views::ImageButton::kViewClassName, button->GetClassName());
|
||||
static_cast<views::ImageButton*>(button)->SetImageModel(
|
||||
button_state,
|
||||
ui::ImageModel::FromImageSkia(nav_button_provider_->GetImage(
|
||||
|
@ -630,7 +630,7 @@ void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
|
||||
if (GetFrameButtonStyle() == FrameButtonStyle::kMdButton) {
|
||||
for (views::Button* button :
|
||||
{minimize_button_, maximize_button_, restore_button_, close_button_}) {
|
||||
DCHECK_EQ(std::string(views::FrameCaptionButton::kViewClassName),
|
||||
DCHECK_EQ(views::FrameCaptionButton::kViewClassName,
|
||||
button->GetClassName());
|
||||
views::FrameCaptionButton* frame_caption_button =
|
||||
static_cast<views::FrameCaptionButton*>(button);
|
||||
|
@ -485,7 +485,7 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton(
|
||||
gfx::Size button_size = button->GetPreferredSize();
|
||||
if (delegate_->GetFrameButtonStyle() ==
|
||||
OpaqueBrowserFrameViewLayoutDelegate::FrameButtonStyle::kMdButton) {
|
||||
DCHECK_EQ(std::string(views::FrameCaptionButton::kViewClassName),
|
||||
DCHECK_EQ(views::FrameCaptionButton::kViewClassName,
|
||||
button->GetClassName());
|
||||
const int caption_button_center_size =
|
||||
button_width - 2 * views::kCaptionButtonInkDropDefaultCornerRadius;
|
||||
@ -501,8 +501,7 @@ void OpaqueBrowserFrameViewLayout::SetBoundsForButton(
|
||||
} else if (delegate_->GetFrameButtonStyle() ==
|
||||
OpaqueBrowserFrameViewLayoutDelegate::FrameButtonStyle::
|
||||
kImageButton) {
|
||||
DCHECK_EQ(std::string(views::ImageButton::kViewClassName),
|
||||
button->GetClassName());
|
||||
DCHECK_EQ(views::ImageButton::kViewClassName, button->GetClassName());
|
||||
auto* const image_button = static_cast<views::ImageButton*>(button);
|
||||
image_button->SetImageHorizontalAlignment(
|
||||
(alignment == ALIGN_LEADING) ? views::ImageButton::ALIGN_RIGHT
|
||||
@ -591,11 +590,7 @@ void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) {
|
||||
window_icon_ = view;
|
||||
break;
|
||||
case VIEW_ID_WINDOW_TITLE:
|
||||
if (view) {
|
||||
DCHECK_EQ(std::string(views::Label::kViewClassName),
|
||||
view->GetClassName());
|
||||
}
|
||||
window_title_ = static_cast<views::Label*>(view);
|
||||
window_title_ = views::AsViewClass<views::Label>(view);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,7 @@ TEST_F(TaskManagerSearchBarViewTest, SetsFocusOnTextfield) {
|
||||
|
||||
views::View* focused_field = widget().GetFocusManager()->GetFocusedView();
|
||||
ASSERT_NE(focused_field, nullptr);
|
||||
EXPECT_EQ(focused_field->GetClassMetaData()->type_name(),
|
||||
std::string("Textfield"));
|
||||
EXPECT_EQ(focused_field->GetClassName(), "Textfield");
|
||||
}
|
||||
|
||||
TEST_F(TaskManagerSearchBarViewTest, KeyPressedFromTextfield) {
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "ui/views/controls/button/label_button.h"
|
||||
#include "ui/views/controls/link.h"
|
||||
#include "ui/views/test/test_widget_observer.h"
|
||||
#include "ui/views/view_utils.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
namespace {
|
||||
@ -309,7 +310,7 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewIconOnly) {
|
||||
ShowBubble(&delegate);
|
||||
const views::View* const extra_view = bubble()->GetExtraView();
|
||||
ASSERT_TRUE(extra_view);
|
||||
ASSERT_EQ(std::string(extra_view->GetClassName()), "ImageView");
|
||||
ASSERT_EQ(extra_view->GetClassName(), "ImageView");
|
||||
EXPECT_TRUE(gfx::test::AreImagesEqual(
|
||||
gfx::Image(static_cast<const views::ImageView*>(extra_view)->GetImage()),
|
||||
gfx::Image(gfx::CreateVectorIcon(
|
||||
@ -331,7 +332,7 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewLinkedTextOnly) {
|
||||
|
||||
const views::View* const extra_view = bubble()->GetExtraView();
|
||||
ASSERT_TRUE(extra_view);
|
||||
ASSERT_EQ(std::string(extra_view->GetClassName()), "ImageButton");
|
||||
ASSERT_EQ(extra_view->GetClassName(), "ImageButton");
|
||||
EXPECT_EQ(extra_view->GetRenderedTooltipText(gfx::Point(0, 0)),
|
||||
kExtraViewText);
|
||||
CloseBubble();
|
||||
@ -350,7 +351,7 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewLabelTextOnly) {
|
||||
|
||||
const views::View* const extra_view = bubble()->GetExtraView();
|
||||
ASSERT_TRUE(extra_view);
|
||||
EXPECT_EQ(std::string(extra_view->GetClassName()), "Label");
|
||||
EXPECT_EQ(extra_view->GetClassName(), "Label");
|
||||
EXPECT_EQ(static_cast<const views::Label*>(extra_view)->GetText(),
|
||||
kExtraViewText);
|
||||
CloseBubble();
|
||||
@ -370,17 +371,17 @@ TEST_F(ToolbarActionsBarBubbleViewsTest, TestCreateExtraViewImageAndText) {
|
||||
|
||||
const views::View* const extra_view = bubble()->GetExtraView();
|
||||
ASSERT_TRUE(extra_view);
|
||||
EXPECT_STREQ(extra_view->GetClassName(), "View");
|
||||
EXPECT_EQ(extra_view->GetClassName(), "View");
|
||||
EXPECT_EQ(extra_view->children().size(), 2u);
|
||||
|
||||
for (const views::View* v : extra_view->children()) {
|
||||
std::string class_name = v->GetClassName();
|
||||
if (class_name == "Label") {
|
||||
EXPECT_EQ(static_cast<const views::Label*>(v)->GetText(), kExtraViewText);
|
||||
if (const auto* label = views::AsViewClass<views::Label>(v)) {
|
||||
EXPECT_EQ(label->GetText(), kExtraViewText);
|
||||
} else {
|
||||
ASSERT_EQ(class_name, "ImageView");
|
||||
const auto* image = views::AsViewClass<views::ImageView>(v);
|
||||
ASSERT_TRUE(image);
|
||||
EXPECT_TRUE(gfx::test::AreImagesEqual(
|
||||
gfx::Image(static_cast<const views::ImageView*>(v)->GetImage()),
|
||||
gfx::Image(image->GetImage()),
|
||||
gfx::Image(gfx::CreateVectorIcon(
|
||||
vector_icons::kBusinessIcon, kIconSize,
|
||||
v->GetColorProvider()->GetColor(ui::kColorIcon)))));
|
||||
|
@ -445,7 +445,7 @@ class AccountSelectionBubbleViewTest : public ChromeViewsTestBase,
|
||||
|
||||
void CheckMismatchIdp(views::View* idp_row,
|
||||
const std::u16string& expected_idp) {
|
||||
ASSERT_STREQ("HoverButton", idp_row->GetClassName());
|
||||
ASSERT_EQ("HoverButton", idp_row->GetClassName());
|
||||
HoverButton* idp_button = static_cast<HoverButton*>(idp_row);
|
||||
ASSERT_TRUE(idp_button);
|
||||
EXPECT_EQ(GetHoverButtonTitle(idp_button), u"Sign in to " + expected_idp);
|
||||
@ -1218,10 +1218,10 @@ TEST_F(MultipleIdpAccountSelectionBubbleViewTest, HoverChangesIdpCircle) {
|
||||
std::vector<raw_ptr<views::View, VectorExperimental>> icon_children =
|
||||
icon_view->children();
|
||||
ASSERT_EQ(icon_children.size(), 2u);
|
||||
EXPECT_STREQ(icon_children[1]->GetClassName(), "BoxLayoutView");
|
||||
EXPECT_EQ(icon_children[1]->GetClassName(), "BoxLayoutView");
|
||||
ASSERT_EQ(icon_children[1]->children().size(), 1u);
|
||||
EXPECT_STREQ(icon_children[1]->children()[0]->GetClassName(),
|
||||
"BrandIconImageView");
|
||||
EXPECT_EQ(icon_children[1]->children()[0]->GetClassName(),
|
||||
"BrandIconImageView");
|
||||
auto* brand_icon_image_view =
|
||||
static_cast<BrandIconImageView*>(icon_children[1]->children()[0]);
|
||||
auto* color_provider = account_row->GetColorProvider();
|
||||
|
@ -456,7 +456,7 @@ void AccountSelectionModalView::ShowVerifyingSheet(
|
||||
for (const auto& child : account_chooser_->children()) {
|
||||
// If one of the immediate children is HoverButton, this is a single account
|
||||
// chooser.
|
||||
if (std::string(child->GetClassName()) == "HoverButton") {
|
||||
if (child->GetClassName() == "HoverButton") {
|
||||
is_single_account_chooser = true;
|
||||
AccountHoverButton* button = static_cast<AccountHoverButton*>(child);
|
||||
if (button->HasBeenClicked()) {
|
||||
@ -477,7 +477,7 @@ void AccountSelectionModalView::ShowVerifyingSheet(
|
||||
views::View* wrapper = account_chooser_->children()[0];
|
||||
views::View* contents = wrapper->children()[0];
|
||||
for (const auto& child : contents->children()) {
|
||||
if (std::string(child->GetClassName()) == "HoverButton") {
|
||||
if (child->GetClassName() == "HoverButton") {
|
||||
AccountHoverButton* button = static_cast<AccountHoverButton*>(child);
|
||||
if (button->HasBeenClicked()) {
|
||||
has_spinner_ = true;
|
||||
|
@ -322,7 +322,7 @@ class AccountSelectionModalViewTest : public DialogBrowserTest,
|
||||
bool has_spinner = false;
|
||||
for (const auto& child : button->children()) {
|
||||
// Spinner is placed in a BoxLayoutView.
|
||||
if (std::string(child->GetClassName()) == "BoxLayoutView") {
|
||||
if (child->GetClassName() == "BoxLayoutView") {
|
||||
views::Throbber* spinner =
|
||||
static_cast<views::Throbber*>(child->children()[0]);
|
||||
EXPECT_TRUE(spinner);
|
||||
@ -335,9 +335,8 @@ class AccountSelectionModalViewTest : public DialogBrowserTest,
|
||||
void CheckDisabledButtonRow(views::View* button_row) {
|
||||
for (const auto& button : button_row->children()) {
|
||||
auto* text_button = static_cast<views::MdTextButton*>(
|
||||
std::string(button->GetClassName()) == "FlexLayoutView"
|
||||
? button->children()[0]
|
||||
: button);
|
||||
(button->GetClassName() == "FlexLayoutView") ? button->children()[0]
|
||||
: button);
|
||||
|
||||
if (text_button->GetText() == l10n_util::GetStringUTF16(IDS_CANCEL)) {
|
||||
ASSERT_TRUE(text_button->GetEnabled());
|
||||
@ -495,7 +494,7 @@ class AccountSelectionModalViewTest : public DialogBrowserTest,
|
||||
// account_chooser section. e.g. accounts, disclosure text, scroll view etc.
|
||||
// and all of them should be disabled.
|
||||
for (const auto& item : account_chooser) {
|
||||
if (std::string(item->GetClassName()) == "HoverButton") {
|
||||
if (item->GetClassName() == "HoverButton") {
|
||||
AccountHoverButton* button = static_cast<AccountHoverButton*>(item);
|
||||
ASSERT_FALSE(item->GetEnabled());
|
||||
ASSERT_TRUE(button->HasDisabledOpacity());
|
||||
@ -604,8 +603,7 @@ class AccountSelectionModalViewTest : public DialogBrowserTest,
|
||||
|
||||
size_t accounts_index = 0;
|
||||
for (const auto& account_suffix : account_suffixes) {
|
||||
if (std::string(accounts[accounts_index]->GetClassName()) ==
|
||||
"Separator") {
|
||||
if (accounts[accounts_index]->GetClassName() == "Separator") {
|
||||
++accounts_index;
|
||||
}
|
||||
CheckHoverableAccountRow(accounts[accounts_index++], account_suffix,
|
||||
@ -639,11 +637,11 @@ class AccountSelectionModalViewTest : public DialogBrowserTest,
|
||||
std::vector<raw_ptr<views::View, VectorExperimental>> accounts =
|
||||
TestStructureAndGetAccounts(children[1]);
|
||||
|
||||
ASSERT_EQ(std::string(accounts[0]->GetClassName()), "Separator");
|
||||
ASSERT_EQ(accounts[0]->GetClassName(), "Separator");
|
||||
CheckHoverableAccountRow(accounts[1], "enabled",
|
||||
/*expect_idp=*/false, /*is_modal_dialog=*/true,
|
||||
/*is_disabled=*/false);
|
||||
ASSERT_EQ(std::string(accounts[2]->GetClassName()), "Separator");
|
||||
ASSERT_EQ(accounts[2]->GetClassName(), "Separator");
|
||||
CheckHoverableAccountRow(accounts[3], "disabled",
|
||||
/*expect_idp=*/false, /*is_modal_dialog=*/true,
|
||||
/*is_disabled=*/true);
|
||||
|
@ -114,7 +114,7 @@ std::vector<std::string> AccountSelectionViewTestBase::GetChildClassNames(
|
||||
views::View* parent) {
|
||||
std::vector<std::string> child_class_names;
|
||||
for (views::View* child_view : parent->children()) {
|
||||
child_class_names.push_back(child_view->GetClassName());
|
||||
child_class_names.emplace_back(child_view->GetClassName());
|
||||
}
|
||||
return child_class_names;
|
||||
}
|
||||
@ -176,7 +176,7 @@ void AccountSelectionViewTestBase::CheckHoverableAccountRows(
|
||||
// `accounts_index` to the first unused index in `accounts`, or to
|
||||
// `accounts.size()` if done.
|
||||
for (const auto& account_suffix : account_suffixes) {
|
||||
if (std::string(accounts[accounts_index]->GetClassName()) == "Separator") {
|
||||
if (accounts[accounts_index]->GetClassName() == "Separator") {
|
||||
++accounts_index;
|
||||
}
|
||||
CheckHoverableAccountRow(accounts[accounts_index++], account_suffix,
|
||||
@ -190,7 +190,7 @@ void AccountSelectionViewTestBase::CheckHoverableAccountRow(
|
||||
bool expect_idp,
|
||||
bool is_modal_dialog,
|
||||
bool is_disabled) {
|
||||
ASSERT_STREQ("HoverButton", account->GetClassName());
|
||||
ASSERT_EQ("HoverButton", account->GetClassName());
|
||||
HoverButton* account_row = static_cast<HoverButton*>(account);
|
||||
ASSERT_TRUE(account_row);
|
||||
|
||||
@ -254,16 +254,16 @@ void AccountSelectionViewTestBase::CheckHoverableAccountRow(
|
||||
std::vector<raw_ptr<views::View, VectorExperimental>> icon_children =
|
||||
icon_view->children();
|
||||
ASSERT_EQ(icon_children.size(), 2u);
|
||||
EXPECT_STREQ(icon_children[0]->GetClassName(), "AccountImageView");
|
||||
EXPECT_EQ(icon_children[0]->GetClassName(), "AccountImageView");
|
||||
EXPECT_EQ(icon_children[0]->size(),
|
||||
gfx::Size(kDesiredAvatarSize + kIdpBadgeOffset,
|
||||
kDesiredAvatarSize + kIdpBadgeOffset));
|
||||
EXPECT_STREQ(icon_children[1]->GetClassName(), "BoxLayoutView");
|
||||
EXPECT_EQ(icon_children[1]->GetClassName(), "BoxLayoutView");
|
||||
ASSERT_EQ(icon_children[1]->children().size(), 1u);
|
||||
views::View* brand_icon_image_view = icon_children[1]->children()[0];
|
||||
EXPECT_STREQ(brand_icon_image_view->GetClassName(), "BrandIconImageView");
|
||||
EXPECT_EQ(brand_icon_image_view->GetClassName(), "BrandIconImageView");
|
||||
} else {
|
||||
EXPECT_STREQ(icon_view->GetClassName(), "AccountImageView");
|
||||
EXPECT_EQ(icon_view->GetClassName(), "AccountImageView");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,7 @@ IN_PROC_BROWSER_TEST_F(InteractionSequenceUiTest, OpenMainMenuAndViewHelpItem) {
|
||||
kToolbarAppMenuButtonElementId, context);
|
||||
BrowserAppMenuButton* const app_menu_button =
|
||||
static_cast<BrowserAppMenuButton*>(button_view);
|
||||
DCHECK_EQ(std::string("BrowserAppMenuButton"),
|
||||
std::string(app_menu_button->GetClassName()));
|
||||
DCHECK_EQ("BrowserAppMenuButton", app_menu_button->GetClassName());
|
||||
|
||||
// Define a simple sequence of:
|
||||
// - spotting the app menu button
|
||||
|
@ -928,15 +928,15 @@ TEST_F(KeyboardTest, FocusWithArcOverlay) {
|
||||
EXPECT_EQ(keyboard.focused_surface_for_testing(), surface.get());
|
||||
|
||||
constexpr char kFocusedViewClassName[] = "OverlayNativeViewHost";
|
||||
EXPECT_STREQ(kFocusedViewClassName,
|
||||
widget1->GetFocusManager()->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ(kFocusedViewClassName,
|
||||
widget1->GetFocusManager()->GetFocusedView()->GetClassName());
|
||||
|
||||
// Tabbing should not move the focus away from the overlay.
|
||||
ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
|
||||
generator.PressKey(ui::VKEY_TAB, 0);
|
||||
|
||||
EXPECT_STREQ(kFocusedViewClassName,
|
||||
widget1->GetFocusManager()->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ(kFocusedViewClassName,
|
||||
widget1->GetFocusManager()->GetFocusedView()->GetClassName());
|
||||
EXPECT_EQ(keyboard.focused_surface_for_testing(), surface.get());
|
||||
|
||||
hold.RunAndReset();
|
||||
|
@ -144,7 +144,8 @@ void ViewElement::SetBounds(const gfx::Rect& bounds) {
|
||||
|
||||
std::vector<std::string> ViewElement::GetAttributes() const {
|
||||
// TODO(lgrey): Change name to class after updating tests.
|
||||
return {"class", view_->GetClassName(), "name", view_->GetObjectName()};
|
||||
return {"class", std::string(view_->GetClassName()), "name",
|
||||
view_->GetObjectName()};
|
||||
}
|
||||
|
||||
std::pair<gfx::NativeWindow, gfx::Rect>
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define UI_BASE_METADATA_METADATA_MACROS_INTERNAL_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "ui/base/metadata/metadata_types.h"
|
||||
@ -60,7 +61,7 @@
|
||||
#define METADATA_ACCESSORS_INTERNAL_BASE(class_name) \
|
||||
using kMetadataTag = class_name; \
|
||||
[[maybe_unused]] static const char kViewClassName[]; \
|
||||
const char* GetClassName() const; \
|
||||
std::string_view GetClassName() const; \
|
||||
static ui::metadata::ClassMetaData* MetaData(); \
|
||||
class_name* ReinterpretToBaseClass(void* obj); \
|
||||
/* Don't hide non-const base class version. */ \
|
||||
@ -169,7 +170,7 @@
|
||||
|
||||
#define BEGIN_METADATA_INTERNAL_BASE(qualified_class_name, \
|
||||
metadata_class_name, parent_class_name) \
|
||||
const char* qualified_class_name::GetClassName() const { \
|
||||
std::string_view qualified_class_name::GetClassName() const { \
|
||||
return GetClassMetaData()->type_name(); \
|
||||
} \
|
||||
\
|
||||
|
@ -99,17 +99,7 @@ class COMPONENT_EXPORT(UI_BASE_METADATA) ClassMetaData {
|
||||
ClassMetaData& operator=(const ClassMetaData&) = delete;
|
||||
virtual ~ClassMetaData();
|
||||
|
||||
const char* type_name() const {
|
||||
static_assert(
|
||||
std::is_same<decltype(type_name_), std::string_view>::value,
|
||||
"This string is logged in plaintext via UMA trace events uploads, so "
|
||||
"must be static as a privacy requirement.");
|
||||
// This is safe because the underlying string is a C string and null
|
||||
// terminated.
|
||||
// TODO(325589481): See if directly returning the string_view would be
|
||||
// desirable.
|
||||
return type_name_.data();
|
||||
}
|
||||
std::string_view type_name() const { return type_name_; }
|
||||
const std::vector<raw_ptr<MemberMetaDataBase, VectorExperimental>>& members()
|
||||
const {
|
||||
return members_;
|
||||
@ -152,9 +142,6 @@ class COMPONENT_EXPORT(UI_BASE_METADATA) ClassMetaData {
|
||||
ClassMemberIterator operator++(int);
|
||||
|
||||
bool operator==(const ClassMemberIterator& rhs) const;
|
||||
bool operator!=(const ClassMemberIterator& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
MemberMetaDataBase* operator*() {
|
||||
if (current_collection_ == nullptr ||
|
||||
@ -201,9 +188,10 @@ class COMPONENT_EXPORT(UI_BASE_METADATA) ClassMetaData {
|
||||
class COMPONENT_EXPORT(UI_BASE_METADATA) MemberMetaDataBase {
|
||||
public:
|
||||
using ValueStrings = std::vector<std::u16string>;
|
||||
MemberMetaDataBase(const std::string& member_name,
|
||||
const std::string& member_type)
|
||||
: member_name_(member_name), member_type_(member_type) {}
|
||||
|
||||
MemberMetaDataBase(std::string member_name, std::string member_type)
|
||||
: member_name_(std::move(member_name)),
|
||||
member_type_(std::move(member_type)) {}
|
||||
MemberMetaDataBase(const MemberMetaDataBase&) = delete;
|
||||
MemberMetaDataBase& operator=(const MemberMetaDataBase&) = delete;
|
||||
virtual ~MemberMetaDataBase() = default;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "ui/views/accessibility/ax_view_obj_wrapper.h"
|
||||
#include "ui/views/accessibility/ax_virtual_view.h"
|
||||
#include "ui/views/accessibility/view_accessibility.h"
|
||||
@ -61,8 +62,8 @@ bool AXVirtualViewWrapper::HandleAccessibleAction(
|
||||
}
|
||||
|
||||
std::string AXVirtualViewWrapper::ToString() const {
|
||||
std::string description = "Virtual view child of ";
|
||||
return description + virtual_view_->GetOwnerView()->GetClassName();
|
||||
return base::StrCat({"Virtual view child of ",
|
||||
virtual_view_->GetOwnerView()->GetClassName()});
|
||||
}
|
||||
|
||||
} // namespace views
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ui/views/accessibility/view_accessibility.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
@ -848,7 +849,7 @@ void ViewAccessibility::OnViewAddedToWidget() {
|
||||
// this would be done in the ctor, but due to inheritance and the
|
||||
// implementation of `GetClassName`, it would not work. As such, we set it
|
||||
// here, since at this point the view object is fully initialized.
|
||||
SetClassName(view_->GetClassName());
|
||||
SetClassName(std::string(view_->GetClassName()));
|
||||
}
|
||||
|
||||
void ViewAccessibility::SetPlaceholder(const std::string& placeholder) {
|
||||
|
@ -907,17 +907,17 @@ BubbleDialogDelegate::BubbleUmaLogger::GetBubbleName() const {
|
||||
// Some dialogs might only use BDD and not BDDV. In those cases, the class
|
||||
// name should be based on BDDs' content view.
|
||||
if (delegate_.has_value()) {
|
||||
std::string class_name =
|
||||
delegate_.value()->GetContentsView()->GetClassName();
|
||||
std::string class_name(
|
||||
delegate_.value()->GetContentsView()->GetClassName());
|
||||
if (class_name != "View") {
|
||||
return class_name;
|
||||
}
|
||||
}
|
||||
|
||||
if (bubble_view_.has_value()) {
|
||||
return bubble_view_.value()->GetClassName();
|
||||
return std::string(bubble_view_.value()->GetClassName());
|
||||
}
|
||||
return std::optional<std::string>();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
|
@ -47,7 +47,7 @@ void PrintFocusHierarchyImp(const View* view,
|
||||
std::string PrintViewGraphImpl(const View* view) {
|
||||
std::string result;
|
||||
|
||||
const std::string class_name(view->GetClassName());
|
||||
const std::string_view class_name = view->GetClassName();
|
||||
size_t base_name_index = class_name.find_last_of('/');
|
||||
if (base_name_index == std::string::npos) {
|
||||
base_name_index = 0;
|
||||
@ -60,7 +60,7 @@ std::string PrintViewGraphImpl(const View* view) {
|
||||
result.append(base::StringPrintf("%p", view));
|
||||
result.append(" [label=\"");
|
||||
|
||||
result.append(class_name.substr(base_name_index).c_str());
|
||||
result.append(class_name.substr(base_name_index));
|
||||
|
||||
result.append(base::StringPrintf(
|
||||
"\\n bounds: (%d, %d), (%dx%d)", view->bounds().x(), view->bounds().y(),
|
||||
|
@ -146,7 +146,7 @@ class ClassRegistration : public BaseClassRegistration {
|
||||
~ClassRegistration() override = default;
|
||||
std::unique_ptr<View> CreateView() override { return std::make_unique<C>(); }
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(C::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(C::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -164,7 +164,7 @@ class ClassRegistration<Combobox> : public BaseClassRegistration,
|
||||
.Build();
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(Combobox::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(Combobox::kViewClassName);
|
||||
}
|
||||
|
||||
// ui::ComboboxModel
|
||||
@ -182,7 +182,7 @@ class ClassRegistration<MdTextButton> : public BaseClassRegistration {
|
||||
return Builder<MdTextButton>().SetText(u"Button").Build();
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(MdTextButton::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(MdTextButton::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -201,7 +201,7 @@ class ClassRegistration<Textfield> : public BaseClassRegistration {
|
||||
.Build();
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(Textfield::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(Textfield::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -214,7 +214,7 @@ class ClassRegistration<Checkbox> : public BaseClassRegistration {
|
||||
return std::make_unique<Checkbox>(u"<Checkbox>");
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(Checkbox::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(Checkbox::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -227,7 +227,7 @@ class ClassRegistration<RadioButton> : public BaseClassRegistration {
|
||||
return std::make_unique<RadioButton>(u"<RadioButton>", 0);
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(RadioButton::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(RadioButton::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -243,7 +243,7 @@ class ClassRegistration<ToggleButton> : public BaseClassRegistration {
|
||||
.Build();
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(ToggleButton::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(ToggleButton::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -261,7 +261,7 @@ class ClassRegistration<ImageButton> : public BaseClassRegistration {
|
||||
.Build();
|
||||
}
|
||||
std::u16string GetViewClassName() override {
|
||||
return base::ASCIIToUTF16(ImageButton::MetaData()->type_name());
|
||||
return base::ASCIIToUTF16(ImageButton::kViewClassName);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -549,7 +549,7 @@ ui::InteractionSequence::StepBuilder InteractiveViewsTestApi::NameViewRelative(
|
||||
if (!IsViewClass<V>(view)) {
|
||||
LOG(ERROR) << "NameView(): Target View is of type "
|
||||
<< view->GetClassName() << " but expected "
|
||||
<< V::MetaData()->type_name();
|
||||
<< V::kViewClassName;
|
||||
seq->FailForTesting();
|
||||
return;
|
||||
}
|
||||
@ -690,7 +690,7 @@ InteractiveViewsTestApi::NameChildViewByType(ElementSpecifier parent,
|
||||
base::OwnedRef(index)))
|
||||
.SetDescription(base::StringPrintf(
|
||||
"NameChildViewByType<%s>( \"%s\" %zu )",
|
||||
V::MetaData()->type_name(), name.data(), index)));
|
||||
V::kViewClassName, name.data(), index)));
|
||||
}
|
||||
|
||||
// static
|
||||
@ -714,7 +714,7 @@ InteractiveViewsTestApi::NameDescendantViewByType(ElementSpecifier ancestor,
|
||||
base::OwnedRef(index)))
|
||||
.SetDescription(base::StringPrintf(
|
||||
"NameDescendantViewByType<%s>( \"%s\" %zu )",
|
||||
V::MetaData()->type_name(), name.data(), index)));
|
||||
V::kViewClassName, name.data(), index)));
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "base/containers/map_util.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "build/build_config.h"
|
||||
#include "ui/base/interaction/element_identifier.h"
|
||||
#include "ui/base/interaction/element_tracker.h"
|
||||
@ -351,19 +351,18 @@ gfx::NativeWindow InteractiveViewsTestPrivate::GetNativeWindowFromContext(
|
||||
std::string InteractiveViewsTestPrivate::DebugDumpWidget(
|
||||
const Widget& widget) const {
|
||||
std::string description = widget.GetName();
|
||||
return base::StringPrintf(
|
||||
"%s \"%s\" at %s", widget.GetClassName(), widget.GetName().c_str(),
|
||||
DebugDumpBounds(widget.GetWindowBoundsInScreen()).c_str());
|
||||
return base::StrCat({widget.GetClassName(), " \"", widget.GetName(), "\" at ",
|
||||
DebugDumpBounds(widget.GetWindowBoundsInScreen())});
|
||||
}
|
||||
|
||||
InteractiveViewsTestPrivate::DebugTreeNode
|
||||
InteractiveViewsTestPrivate::DebugDumpElement(
|
||||
const ui::TrackedElement* el) const {
|
||||
if (const auto* view = el->AsA<TrackedElementViews>()) {
|
||||
return DebugTreeNode(base::StringPrintf(
|
||||
"%s%s - %s at %s", (view->view()->HasFocus() ? "[FOCUSED] " : ""),
|
||||
view->view()->GetClassName(), el->identifier().GetName().c_str(),
|
||||
DebugDumpBounds(el->GetScreenBounds())));
|
||||
return DebugTreeNode(base::StrCat(
|
||||
{(view->view()->HasFocus() ? "[FOCUSED] " : ""),
|
||||
view->view()->GetClassName(), " - ", el->identifier().GetName(),
|
||||
" at ", DebugDumpBounds(el->GetScreenBounds())}));
|
||||
}
|
||||
return InteractiveTestPrivate::DebugDumpElement(el);
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ View* View::GetSelectedViewForGroup(int group) {
|
||||
}
|
||||
|
||||
std::string View::GetObjectName() const {
|
||||
return GetClassName();
|
||||
return std::string(GetClassName());
|
||||
}
|
||||
|
||||
// Coordinate conversion -------------------------------------------------------
|
||||
@ -3403,7 +3403,7 @@ void View::CreateLayer(ui::LayerType layer_type) {
|
||||
|
||||
SetLayer(std::make_unique<ui::Layer>(layer_type));
|
||||
layer()->set_delegate(this);
|
||||
layer()->SetName(GetClassName());
|
||||
layer()->SetName(std::string(GetClassName()));
|
||||
|
||||
UpdateParentLayers();
|
||||
UpdateLayerVisibility();
|
||||
@ -3521,7 +3521,7 @@ void View::LayoutImmediately() {
|
||||
TRACE_EVENT("ui", "View::LayoutImmediately", [&](perfetto::EventContext ctx) {
|
||||
auto* event = ctx.event<perfetto::protos::pbzero::ChromeTrackEvent>();
|
||||
auto* data = event->set_view_class_name();
|
||||
data->set_name(GetClassName());
|
||||
data->set_name(std::string(GetClassName()));
|
||||
});
|
||||
invalidates_during_layout_ = 0;
|
||||
++layouts_since_last_paint_;
|
||||
@ -3845,7 +3845,7 @@ void BaseActionViewInterface::ActionItemChangedImpl(
|
||||
BEGIN_METADATA_BASE(View)
|
||||
ADD_PROPERTY_METADATA(std::unique_ptr<Background>, Background)
|
||||
ADD_PROPERTY_METADATA(std::unique_ptr<Border>, Border)
|
||||
ADD_READONLY_PROPERTY_METADATA(const char*, ClassName)
|
||||
ADD_READONLY_PROPERTY_METADATA(std::string_view, ClassName)
|
||||
ADD_PROPERTY_METADATA(bool, Enabled)
|
||||
ADD_PROPERTY_METADATA(View::FocusBehavior, FocusBehavior)
|
||||
ADD_PROPERTY_METADATA(bool, FlipCanvasOnPaintForRTLUI)
|
||||
|
@ -4,11 +4,15 @@
|
||||
|
||||
#include "ui/views/view_utils.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/debug/stack_trace.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "ui/views/view.h"
|
||||
#include "ui/views/views_switches.h"
|
||||
|
||||
@ -22,9 +26,10 @@ namespace {
|
||||
|
||||
std::string GetViewTreeAsString(View* view) {
|
||||
if (!view->parent()) {
|
||||
return view->GetClassName();
|
||||
return std::string(view->GetClassName());
|
||||
}
|
||||
return GetViewTreeAsString(view->parent()) + " -> " + view->GetClassName();
|
||||
return base::StrCat(
|
||||
{GetViewTreeAsString(view->parent()), " -> ", view->GetClassName()});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -34,7 +39,7 @@ ViewDebugWrapperImpl::ViewDebugWrapperImpl(View* view) : view_(view) {}
|
||||
ViewDebugWrapperImpl::~ViewDebugWrapperImpl() = default;
|
||||
|
||||
std::string ViewDebugWrapperImpl::GetViewClassName() {
|
||||
return view_->GetClassName();
|
||||
return std::string(view_->GetClassName());
|
||||
}
|
||||
|
||||
int ViewDebugWrapperImpl::GetID() {
|
||||
@ -89,23 +94,21 @@ std::string PrintViewHierarchy(View* view, bool verbose) {
|
||||
|
||||
std::string GetViewDebugInfo(View* view) {
|
||||
std::string debug_string =
|
||||
std::string("View: ") + view->GetClassName() + "\n";
|
||||
debug_string += std::string("Hierarchy:\n ") + GetViewTreeAsString(view);
|
||||
|
||||
debug_string += "\nView created here:\n";
|
||||
base::StrCat({"\nView: ", view->GetClassName(), "\nHierarchy:\n ",
|
||||
GetViewTreeAsString(view), "\nView created here:\n"});
|
||||
|
||||
static bool has_stack_trace =
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kViewStackTraces);
|
||||
|
||||
if (has_stack_trace) {
|
||||
debug_string += view->GetProperty(kViewStackTraceKey)->ToString();
|
||||
} else {
|
||||
debug_string += std::string(" Run with --") + switches::kViewStackTraces +
|
||||
" to get a stack trace for when this View was created.";
|
||||
debug_string +=
|
||||
base::StrCat({" Run with --", switches::kViewStackTraces,
|
||||
" to get a stack trace for when this View was created."});
|
||||
}
|
||||
|
||||
return "\n" + debug_string;
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
} // namespace views
|
||||
|
@ -120,7 +120,7 @@ class NativeWidgetMac::ZoomFocusMonitor : public FocusChangeListener {
|
||||
return;
|
||||
}
|
||||
// Web content handles its own zooming.
|
||||
if (strcmp("WebView", focused_now->GetClassName()) == 0) {
|
||||
if (focused_now->GetClassName() == "WebView") {
|
||||
return;
|
||||
}
|
||||
NSRect rect = NSRectFromCGRect(focused_now->GetBoundsInScreen().ToCGRect());
|
||||
|
@ -2708,7 +2708,7 @@ void Widget::OnChildRemoved(Widget* child_widget) {
|
||||
}
|
||||
|
||||
BEGIN_METADATA_BASE(Widget)
|
||||
ADD_READONLY_PROPERTY_METADATA(const char*, ClassName)
|
||||
ADD_READONLY_PROPERTY_METADATA(std::string_view, ClassName)
|
||||
ADD_READONLY_PROPERTY_METADATA(gfx::Rect, ClientAreaBoundsInScreen)
|
||||
ADD_READONLY_PROPERTY_METADATA(std::string, Name)
|
||||
ADD_READONLY_PROPERTY_METADATA(gfx::Rect, RestoredBounds)
|
||||
|
Reference in New Issue
Block a user