Skip to content

Commit

Permalink
cros_next: Replace WindowCycleTabSlider with ash/style/TabSlider
Browse files Browse the repository at this point in the history
In Alt-tab, replace the WindowCycleTabSlider with ash/style/TabSlider,
replace the WindowCycleTabSliderButton with ash/style/TabSliderButton.
Delete ash/style/TabSlider and ash/style/TabSliderButton.

Bug: b/273571138
Change-Id: I214588bdea50f5a612171f2749568de4951f5ccc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4342969
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: Xiaodan Zhu <zxdan@chromium.org>
Commit-Queue: Connie Xu <conniekxu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1118729}
  • Loading branch information
conniekxu authored and Chromium LUCI CQ committed Mar 17, 2023
1 parent d3a378a commit f1e979c
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 420 deletions.
4 changes: 0 additions & 4 deletions ash/BUILD.gn
Expand Up @@ -2418,10 +2418,6 @@ component("ash") {
"wm/window_cycle/window_cycle_item_view.h",
"wm/window_cycle/window_cycle_list.cc",
"wm/window_cycle/window_cycle_list.h",
"wm/window_cycle/window_cycle_tab_slider.cc",
"wm/window_cycle/window_cycle_tab_slider.h",
"wm/window_cycle/window_cycle_tab_slider_button.cc",
"wm/window_cycle/window_cycle_tab_slider_button.h",
"wm/window_cycle/window_cycle_view.cc",
"wm/window_cycle/window_cycle_view.h",
"wm/window_dimmer.cc",
Expand Down
4 changes: 4 additions & 0 deletions ash/style/tab_slider.cc
Expand Up @@ -111,6 +111,10 @@ TabSlider::TabSlider(bool has_background,

TabSlider::~TabSlider() = default;

views::View* TabSlider::GetSelectorView() {
return selector_view_;
}

void TabSlider::SetCustomLayout(const LayoutParams& layout_params) {
use_button_recommended_layout_ = false;

Expand Down
2 changes: 2 additions & 0 deletions ash/style/tab_slider.h
Expand Up @@ -43,6 +43,8 @@ class ASH_EXPORT TabSlider : public views::View {
TabSlider& operator=(const TabSlider&) = delete;
~TabSlider() override;

views::View* GetSelectorView();

// Add a button with the button's unique pointer. For example
// AddButton(std::make_unique<SliderButtonType>(...)).
template <typename T>
Expand Down
57 changes: 18 additions & 39 deletions ash/wm/window_cycle/window_cycle_controller_unittest.cc
Expand Up @@ -30,6 +30,7 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/tab_slider_button.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ash/test_shell_delegate.h"
Expand Down Expand Up @@ -180,19 +181,16 @@ class WindowCycleListTestApi {
return cycle_view()->mirror_container_->children();
}

const views::View* GetTabSliderActiveButtonSelector() const {
if (auto* tab_slider_container = cycle_view()->tab_slider_container_)
return tab_slider_container->active_button_selector_;
return nullptr;
}

const views::View::Views& GetTabSliderButtons() const {
auto* tab_slider_container = cycle_view()->tab_slider_container_;
if (!tab_slider_container) {
static const views::View::Views empty;
const std::vector<TabSliderButton*> GetTabSliderButtons() const {
auto* tab_slider = cycle_view()->tab_slider_;
if (!tab_slider) {
static const std::vector<TabSliderButton*> empty;
return empty;
}
return tab_slider_container->buttons_container_->children();
std::vector<TabSliderButton*> buttons;
buttons.push_back(cycle_view()->all_desks_tab_slider_button_);
buttons.push_back(cycle_view()->current_desk_tab_slider_button_);
return buttons;
}

bool IsCycleViewAnimating() const {
Expand Down Expand Up @@ -239,15 +237,10 @@ class WindowCycleControllerTest : public AshTestBase {
return WindowCycleListTestApi(GetCycleList()).GetWindowCycleItemViews();
}

const views::View::Views& GetWindowCycleTabSliderButtons() const {
const std::vector<TabSliderButton*> GetWindowCycleTabSliderButtons() const {
return WindowCycleListTestApi(GetCycleList()).GetTabSliderButtons();
}

const views::View* GetWindowCycleTabSliderActiveButtonSelector() const {
return WindowCycleListTestApi(GetCycleList())
.GetTabSliderActiveButtonSelector();
}

const views::Label* GetWindowCycleNoRecentItemsLabel() const {
return WindowCycleListTestApi(GetCycleList()).no_recent_items_label();
}
Expand Down Expand Up @@ -2627,7 +2620,8 @@ TEST_F(ModeSelectionWindowCycleControllerTest, KeyboardNavigation) {
cycle_controller->HandleCycleWindow(
WindowCycleController::WindowCyclingDirection::kForward);
EXPECT_EQ(win1.get(), GetTargetWindow());
views::View::Views tab_slider_buttons = GetWindowCycleTabSliderButtons();
std::vector<TabSliderButton*> tab_slider_buttons =
GetWindowCycleTabSliderButtons();
EXPECT_FALSE(cycle_controller->IsTabSliderFocused());
EXPECT_FALSE(cycle_controller->IsAltTabPerActiveDesk());

Expand Down Expand Up @@ -2733,7 +2727,8 @@ TEST_F(ModeSelectionWindowCycleControllerTest, KeyboardNavigationAfterClick) {
cycle_controller->HandleCycleWindow(
WindowCycleController::WindowCyclingDirection::kForward);
EXPECT_EQ(win1.get(), GetTargetWindow());
views::View::Views tab_slider_buttons = GetWindowCycleTabSliderButtons();
std::vector<TabSliderButton*> tab_slider_buttons =
GetWindowCycleTabSliderButtons();
EXPECT_FALSE(cycle_controller->IsTabSliderFocused());
EXPECT_FALSE(cycle_controller->IsAltTabPerActiveDesk());

Expand Down Expand Up @@ -3143,16 +3138,9 @@ TEST_F(ModeSelectionWindowCycleControllerTest,
auto tab_slider_buttons = GetWindowCycleTabSliderButtons();
EXPECT_EQ(2u, tab_slider_buttons.size());

// Run the accessibility paint checks on the active button selector.
// There should be no DCHECK failures. Failures in the past occurred due to
// the active button selector having `FocusBehavior::ALWAYS`. That change,
// done to improve ChromeVox's presentation, appears to no longer be needed.
// Therefore the default focus behavior (`FocusBehavior::NEVER`) is once again
// in place.
auto* active_button_selector = GetWindowCycleTabSliderActiveButtonSelector();
EXPECT_EQ(active_button_selector->GetFocusBehavior(),
views::View::FocusBehavior::NEVER);
RunAccessibilityPaintChecks(const_cast<views::View*>(active_button_selector));
EXPECT_FALSE(cycle_controller->window_cycle_list()
->cycle_view()
->IsTabSliderFocused());

CompleteCycling(cycle_controller);
}
Expand Down Expand Up @@ -3291,19 +3279,10 @@ class MultiUserWindowCycleControllerTest
return WindowCycleListTestApi(GetCycleList()).GetWindowCycleItemViews();
}

const views::View* GetWindowCycleTabSliderActiveButtonSelector() const {
return WindowCycleListTestApi(GetCycleList())
.GetTabSliderActiveButtonSelector();
}

const views::View::Views& GetWindowCycleTabSliderButtons() const {
const std::vector<TabSliderButton*> GetWindowCycleTabSliderButtons() const {
return WindowCycleListTestApi(GetCycleList()).GetTabSliderButtons();
}

const aura::Window* GetTargetWindow() const {
return WindowCycleListTestApi(GetCycleList()).target_window();
}

void CompleteCycling(WindowCycleController* controller) {
controller->CompleteCycling();
base::RunLoop().RunUntilIdle();
Expand Down
1 change: 0 additions & 1 deletion ash/wm/window_cycle/window_cycle_list.h
Expand Up @@ -10,7 +10,6 @@

#include "ash/ash_export.h"
#include "ash/wm/window_cycle/window_cycle_controller.h"
#include "ash/wm/window_cycle/window_cycle_tab_slider.h"
#include "ash/wm/window_cycle/window_cycle_view.h"
#include "base/timer/timer.h"
#include "ui/aura/window_observer.h"
Expand Down
174 changes: 0 additions & 174 deletions ash/wm/window_cycle/window_cycle_tab_slider.cc

This file was deleted.

0 comments on commit f1e979c

Please sign in to comment.