0

[gtm] Unify the glanceables view ids for Tasks and Classroom

As the first step of refactoring, this cl unifies the child view ids
in GlanceablesTimeManagementBubbleView that were different between
Tasks and Classrooms. This can be done because we can call GetViewByID
on either Tasks view or Classroom view, so that there won't be
ambiguity finding target view.

Bug: 333770880
Change-Id: I7cc30c549a18d2b2773db89bb3e9cb1a0f4d335c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5652180
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Commit-Queue: Wen-Chien Wang <wcwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1319386}
This commit is contained in:
Wen-Chien Wang
2024-06-25 20:28:54 +00:00
committed by Chromium LUCI CQ
parent 764bc7991a
commit 7eff5cead6
8 changed files with 74 additions and 68 deletions

@ -182,12 +182,12 @@ GlanceablesClassroomStudentView::GlanceablesClassroomStudentView()
header_icon->SetBackgroundColor(SK_ColorTRANSPARENT);
header_icon->SetProperty(views::kMarginsKey, kHeaderIconButtonMargins);
header_icon->SetID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleHeaderIcon));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleHeaderIcon));
combo_box_view_ = header_view_->AddChildView(std::make_unique<Combobox>(
std::make_unique<ClassroomStudentComboboxModel>()));
combo_box_view_->SetID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleComboBox));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleComboBox));
combo_box_view_->SetTooltipText(l10n_util::GetStringUTF16(
IDS_GLANCEABLES_CLASSROOM_DROPDOWN_ACCESSIBLE_NAME));
combo_box_view_->GetViewAccessibility().SetDescription(u"");
@ -219,8 +219,8 @@ GlanceablesClassroomStudentView::GlanceablesClassroomStudentView()
header_container->AddChildView(std::make_unique<GlanceablesExpandButton>(
IDS_GLANCEABLES_CLASSROOM_EXPAND_BUTTON_EXPAND_TOOLTIP,
IDS_GLANCEABLES_CLASSROOM_EXPAND_BUTTON_COLLAPSE_TOOLTIP));
expand_button_->SetID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleExpandButton));
expand_button_->SetID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton));
// This is only set visible when both Tasks and Classroom exist, where the
// elevated background is created in that case.
expand_button_->SetVisible(false);
@ -240,8 +240,8 @@ GlanceablesClassroomStudentView::GlanceablesClassroomStudentView()
list_container_view_ =
body_container->AddChildView(std::make_unique<views::BoxLayoutView>());
list_container_view_->SetID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleListContainer));
list_container_view_->SetID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListContainer));
list_container_view_->SetOrientation(
views::BoxLayout::Orientation::kVertical);
list_container_view_->SetBetweenChildSpacing(4);
@ -269,7 +269,7 @@ GlanceablesClassroomStudentView::GlanceablesClassroomStudentView()
base::BindRepeating(&GlanceablesClassroomStudentView::OnSeeAllPressed,
base::Unretained(this))));
list_footer_view_->SetID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleListFooter));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleListFooter));
list_footer_view_->SetVisible(false);
SelectedAssignmentListChanged(/*initial_update=*/true);

@ -120,23 +120,26 @@ class GlanceablesClassroomStudentViewTest : public AshTestBase {
}
const views::View* GetHeaderIcon() const {
return views::AsViewClass<views::View>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleHeaderIcon)));
return views::AsViewClass<views::View>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleHeaderIcon)));
}
Combobox* GetComboBoxView() {
return views::AsViewClass<Combobox>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleComboBox)));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleComboBox)));
}
const CounterExpandButton* GetCounterExpandButton() const {
return views::AsViewClass<CounterExpandButton>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleExpandButton)));
return views::AsViewClass<CounterExpandButton>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton)));
}
const views::View* GetListContainerView() const {
return views::AsViewClass<views::View>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleListContainer)));
return views::AsViewClass<views::View>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListContainer)));
}
const views::View* GetEmptyListLabel() const {
@ -146,8 +149,9 @@ class GlanceablesClassroomStudentViewTest : public AshTestBase {
}
views::View* GetListFooter() const {
return views::AsViewClass<views::View>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleListFooter)));
return views::AsViewClass<views::View>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListFooter)));
}
const views::Label* GetListFooterLabel() const {
@ -202,8 +206,8 @@ TEST_F(GlanceablesClassroomStudentViewTest, Basics) {
// Check that the expand button is not visible when
// `GlanceablesClassroomStudentView` is created alone.
auto* expand_button = view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleExpandButton));
auto* expand_button = view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton));
EXPECT_TRUE(expand_button);
EXPECT_FALSE(expand_button->GetVisible());
}

@ -18,13 +18,19 @@ enum class GlanceablesViewId {
// `GlanceablesProgressBarView`.
kProgressBar,
// `ClassroomBubbleBaseView`.
kClassroomBubbleHeaderIcon,
kClassroomBubbleComboBox,
kClassroomBubbleExpandButton,
kClassroomBubbleListContainer,
// `GlanceablesTimeManagementBubbleView`.
kTimeManagementBubbleHeaderView,
kTimeManagementBubbleHeaderIcon,
kTimeManagementBubbleComboBox,
kTimeManagementBubbleExpandButton,
kTimeManagementBubbleListContainer,
kTimeManagementBubbleListFooter,
// `GlanceablesClassroomStudentView`.
kClassroomBubbleEmptyListLabel,
kClassroomBubbleListFooter,
// `GlanceablesTasksView`.
kTasksBubbleAddNewButton,
// `GlanceablesClassroomItemView`.
kClassroomItemIcon,
@ -33,15 +39,6 @@ enum class GlanceablesViewId {
kClassroomItemDueDateLabel,
kClassroomItemDueTimeLabel,
// `GlanceablesTasksView`.
kTasksBubbleComboBox,
kTasksBubbleExpandButton,
kTasksBubbleListContainer,
kTasksBubbleAddNewButton,
kTasksBubbleListFooter,
kTasksBubbleHeaderView,
kTasksBubbleHeaderIcon,
// `GlanceablesTaskView`.
kTaskItemTitleLabel,
kTaskItemTitleTextField,

@ -246,8 +246,9 @@ class GlanceablesTasksAndClassroomTest : public GlanceablesBaseTest {
}
CounterExpandButton* GetTasksExpandButtonView() const {
return views::AsViewClass<CounterExpandButton>(GetTasksView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleExpandButton)));
return views::AsViewClass<CounterExpandButton>(
GetTasksView()->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton)));
}
views::ScrollView* GetTasksScrollView() const {
@ -263,7 +264,7 @@ class GlanceablesTasksAndClassroomTest : public GlanceablesBaseTest {
CounterExpandButton* GetClassroomExpandButtonView() const {
return views::AsViewClass<CounterExpandButton>(
GetClassroomView()->GetViewByID(base::to_underlying(
GlanceablesViewId::kClassroomBubbleExpandButton)));
GlanceablesViewId::kTimeManagementBubbleExpandButton)));
}
views::ScrollView* GetClassroomScrollView() const {

@ -177,7 +177,7 @@ GlanceablesTasksView::GlanceablesTasksView(
tasks_header_view_->SetMainAxisAlignment(views::LayoutAlignment::kStart);
tasks_header_view_->SetOrientation(views::LayoutOrientation::kHorizontal);
tasks_header_view_->SetID(
base::to_underlying(GlanceablesViewId::kTasksBubbleHeaderView));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleHeaderView));
tasks_header_view_->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::LayoutOrientation::kHorizontal,
@ -189,8 +189,8 @@ GlanceablesTasksView::GlanceablesTasksView(
std::make_unique<GlanceablesExpandButton>(
IDS_GLANCEABLES_TASKS_EXPAND_BUTTON_EXPAND_TOOLTIP,
IDS_GLANCEABLES_TASKS_EXPAND_BUTTON_COLLAPSE_TOOLTIP));
expand_button_->SetID(
base::to_underlying(GlanceablesViewId::kTasksBubbleExpandButton));
expand_button_->SetID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton));
// This is only set visible when both Tasks and Classroom exist, where the
// elevated background is created in that case.
expand_button_->SetVisible(false);
@ -223,8 +223,8 @@ GlanceablesTasksView::GlanceablesTasksView(
list_view->AddChildView(std::make_unique<views::View>());
task_items_container_view_->GetViewAccessibility().SetRole(
ax::mojom::Role::kList);
task_items_container_view_->SetID(
base::to_underlying(GlanceablesViewId::kTasksBubbleListContainer));
task_items_container_view_->SetID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListContainer));
task_items_container_view_->SetLayoutManager(
std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical,
@ -242,7 +242,7 @@ GlanceablesTasksView::GlanceablesTasksView(
header_icon->SetBackgroundColor(SK_ColorTRANSPARENT);
header_icon->SetProperty(views::kMarginsKey, kHeaderIconButtonMargins);
header_icon->SetID(
base::to_underlying(GlanceablesViewId::kTasksBubbleHeaderIcon));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleHeaderIcon));
tasks_combobox_model_ =
std::make_unique<GlanceablesTasksComboboxModel>(task_lists);
@ -278,7 +278,7 @@ GlanceablesTasksView::GlanceablesTasksView(
TasksLaunchSource::kFooterButton,
GURL(kTasksManagementPage))));
list_footer_view_->SetID(
base::to_underlying(GlanceablesViewId::kTasksBubbleListFooter));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleListFooter));
list_footer_view_->SetBorder(views::CreateEmptyBorder(kFooterBorderInsets));
list_footer_view_->SetVisible(false);
@ -1005,7 +1005,7 @@ void GlanceablesTasksView::CreateComboBoxView() {
task_list_combo_box_view_ = tasks_header_view_->AddChildView(
std::make_unique<Combobox>(tasks_combobox_model_.get()));
task_list_combo_box_view_->SetID(
base::to_underlying(GlanceablesViewId::kTasksBubbleComboBox));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleComboBox));
task_list_combo_box_view_->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToZero,

@ -103,26 +103,25 @@ class GlanceablesTasksViewTest : public AshTestBase {
Combobox* GetComboBoxView() const {
return views::AsViewClass<Combobox>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleComboBox)));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleComboBox)));
}
const IconButton* GetHeaderIconView() const {
return views::AsViewClass<IconButton>(
view_
->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleHeaderView))
->GetViewByID(base::to_underlying(
GlanceablesViewId::kTasksBubbleHeaderIcon)));
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleHeaderIcon)));
}
const CounterExpandButton* GetCounterExpandButton() const {
return views::AsViewClass<CounterExpandButton>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleExpandButton)));
return views::AsViewClass<CounterExpandButton>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton)));
}
const views::View* GetTaskItemsContainerView() const {
return views::AsViewClass<views::View>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleListContainer)));
return views::AsViewClass<views::View>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListContainer)));
}
const views::View* GetEditInBrowserButton() const {
@ -136,8 +135,9 @@ class GlanceablesTasksViewTest : public AshTestBase {
}
const GlanceablesListFooterView* GetListFooterView() const {
return views::AsViewClass<GlanceablesListFooterView>(view_->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleListFooter)));
return views::AsViewClass<GlanceablesListFooterView>(
view_->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListFooter)));
}
const views::ProgressBar* GetProgressBar() const {
@ -180,8 +180,8 @@ TEST_F(GlanceablesTasksViewTest, Basics) {
// Check that the expand button does not exist when `GlanceablesTasksView` is
// created alone.
auto* expand_button = view()->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleExpandButton));
auto* expand_button = view()->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton));
EXPECT_TRUE(expand_button);
EXPECT_FALSE(expand_button->GetVisible());
}

@ -692,7 +692,8 @@ TEST_P(GlanceablesDateTrayTest, ClickOutsideComboboxMenu) {
// Click on the combo box to show the assignment types list.
const auto* combobox = views::AsViewClass<Combobox>(
GetGlanceableTrayBubble()->GetClassroomStudentView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleComboBox)));
base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleComboBox)));
LeftClickOn(combobox);
EXPECT_TRUE(combobox->IsMenuRunning());
EXPECT_TRUE(GetGlanceableTrayBubble());

@ -157,7 +157,7 @@ class GlanceablesBrowserTest : public InProcessBrowserTest {
Combobox* GetTasksComboBoxView() const {
return views::AsViewClass<Combobox>(GetTasksView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleComboBox)));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleComboBox)));
}
views::ScrollView* GetTasksScrollView() const {
@ -166,13 +166,15 @@ class GlanceablesBrowserTest : public InProcessBrowserTest {
}
views::View* GetTasksItemContainerView() const {
return views::AsViewClass<views::View>(GetTasksView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleListContainer)));
return views::AsViewClass<views::View>(
GetTasksView()->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListContainer)));
}
CounterExpandButton* GetTasksExpandButtonView() const {
return views::AsViewClass<CounterExpandButton>(GetTasksView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kTasksBubbleExpandButton)));
return views::AsViewClass<CounterExpandButton>(
GetTasksView()->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleExpandButton)));
}
views::LabelButton* GetAddNewTaskButton() const {
@ -204,18 +206,19 @@ class GlanceablesBrowserTest : public InProcessBrowserTest {
views::View* GetStudentComboBoxView() const {
return views::AsViewClass<views::View>(GetStudentView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleComboBox)));
base::to_underlying(GlanceablesViewId::kTimeManagementBubbleComboBox)));
}
CounterExpandButton* GetStudentExpandButtonView() const {
return views::AsViewClass<CounterExpandButton>(
GetStudentView()->GetViewByID(base::to_underlying(
GlanceablesViewId::kClassroomBubbleExpandButton)));
GlanceablesViewId::kTimeManagementBubbleExpandButton)));
}
views::View* GetStudentItemContainerView() const {
return views::AsViewClass<views::View>(GetStudentView()->GetViewByID(
base::to_underlying(GlanceablesViewId::kClassroomBubbleListContainer)));
return views::AsViewClass<views::View>(
GetStudentView()->GetViewByID(base::to_underlying(
GlanceablesViewId::kTimeManagementBubbleListContainer)));
}
std::vector<std::string> GetCurrentStudentAssignmentCourseWorkTitles() const {