Commit 6be0833e authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros:Modify shelf focus order

Focus should be NavWidget->HotseatWidget->StatusAreaWidget. This was
missed when we split the shelf into multiple widgets.

Bug: 1060338
Change-Id: Ic1d4e259e94338c7110a712bdd70ade147b6986c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153320Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760157}
parent 059d2fc6
...@@ -397,14 +397,14 @@ TEST_F(FocusCyclerTest, RemoveWidgetOnDisplayRemoved) { ...@@ -397,14 +397,14 @@ TEST_F(FocusCyclerTest, RemoveWidgetOnDisplayRemoved) {
Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(GetPrimaryShelf()->navigation_widget()->IsActive()); EXPECT_TRUE(GetPrimaryShelf()->navigation_widget()->IsActive());
// Cycle focus to the status area.
Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(GetPrimaryStatusAreaWidget()->IsActive());
// Cycle focus to the hotseat widget. // Cycle focus to the hotseat widget.
Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(GetPrimaryShelf()->hotseat_widget()->IsActive()); EXPECT_TRUE(GetPrimaryShelf()->hotseat_widget()->IsActive());
// Cycle focus to the status area.
Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(GetPrimaryStatusAreaWidget()->IsActive());
// Cycle focus should go back to the browser. // Cycle focus should go back to the browser.
Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD); Shell::Get()->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_TRUE(wm::IsActiveWindow(window.get())); EXPECT_TRUE(wm::IsActiveWindow(window.get()));
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/animation/animation_change_type.h" #include "ash/animation/animation_change_type.h"
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/focus_cycler.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h" #include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
...@@ -346,7 +345,6 @@ void Shelf::CreateNavigationWidget(aura::Window* container) { ...@@ -346,7 +345,6 @@ void Shelf::CreateNavigationWidget(aura::Window* container) {
navigation_widget_->Initialize(container); navigation_widget_->Initialize(container);
navigation_widget_metrics_reporter_ = navigation_widget_metrics_reporter_ =
std::make_unique<NavigationWidgetAnimationMetricsReporter>(this); std::make_unique<NavigationWidgetAnimationMetricsReporter>(this);
Shell::Get()->focus_cycler()->AddWidget(navigation_widget_.get());
} }
void Shelf::CreateHotseatWidget(aura::Window* container) { void Shelf::CreateHotseatWidget(aura::Window* container) {
...@@ -370,7 +368,6 @@ void Shelf::CreateStatusAreaWidget(aura::Window* status_container) { ...@@ -370,7 +368,6 @@ void Shelf::CreateStatusAreaWidget(aura::Window* status_container) {
status_area_widget_ = status_area_widget_ =
std::make_unique<StatusAreaWidget>(status_container, this); std::make_unique<StatusAreaWidget>(status_container, this);
status_area_widget_->Initialize(); status_area_widget_->Initialize();
Shell::Get()->focus_cycler()->AddWidget(status_area_widget_.get());
} }
void Shelf::CreateShelfWidget(aura::Window* root) { void Shelf::CreateShelfWidget(aura::Window* root) {
......
...@@ -686,8 +686,13 @@ void ShelfWidget::OnTabletModeChanged() { ...@@ -686,8 +686,13 @@ void ShelfWidget::OnTabletModeChanged() {
} }
void ShelfWidget::PostCreateShelf() { void ShelfWidget::PostCreateShelf() {
SetFocusCycler(Shell::Get()->focus_cycler()); ash::FocusCycler* focus_cycler = Shell::Get()->focus_cycler();
hotseat_widget()->SetFocusCycler(Shell::Get()->focus_cycler()); SetFocusCycler(focus_cycler);
// Add widgets to |focus_cycler| in the desired focus order in LTR.
focus_cycler->AddWidget(navigation_widget());
hotseat_widget()->SetFocusCycler(focus_cycler);
focus_cycler->AddWidget(status_area_widget());
shelf_layout_manager_->LayoutShelf(); shelf_layout_manager_->LayoutShelf();
shelf_layout_manager_->UpdateAutoHideState(); shelf_layout_manager_->UpdateAutoHideState();
......
...@@ -110,10 +110,10 @@ TEST_F(PipTest, ShortcutNavigation) { ...@@ -110,10 +110,10 @@ TEST_F(PipTest, ShortcutNavigation) {
// Cycle Backward. // Cycle Backward.
generator->PressKey(ui::VKEY_BROWSER_BACK, ui::EF_CONTROL_DOWN); generator->PressKey(ui::VKEY_BROWSER_BACK, ui::EF_CONTROL_DOWN);
EXPECT_TRUE(hotseat_widget->IsActive()); EXPECT_TRUE(status_area->IsActive());
generator->PressKey(ui::VKEY_BROWSER_BACK, ui::EF_CONTROL_DOWN); generator->PressKey(ui::VKEY_BROWSER_BACK, ui::EF_CONTROL_DOWN);
EXPECT_TRUE(status_area->IsActive()); EXPECT_TRUE(hotseat_widget->IsActive());
generator->PressKey(ui::VKEY_BROWSER_BACK, ui::EF_CONTROL_DOWN); generator->PressKey(ui::VKEY_BROWSER_BACK, ui::EF_CONTROL_DOWN);
EXPECT_TRUE(navigation_widget->IsActive()); EXPECT_TRUE(navigation_widget->IsActive());
...@@ -132,10 +132,10 @@ TEST_F(PipTest, ShortcutNavigation) { ...@@ -132,10 +132,10 @@ TEST_F(PipTest, ShortcutNavigation) {
EXPECT_TRUE(navigation_widget->IsActive()); EXPECT_TRUE(navigation_widget->IsActive());
generator->PressKey(ui::VKEY_BROWSER_FORWARD, ui::EF_CONTROL_DOWN); generator->PressKey(ui::VKEY_BROWSER_FORWARD, ui::EF_CONTROL_DOWN);
EXPECT_TRUE(status_area->IsActive()); EXPECT_TRUE(hotseat_widget->IsActive());
generator->PressKey(ui::VKEY_BROWSER_FORWARD, ui::EF_CONTROL_DOWN); generator->PressKey(ui::VKEY_BROWSER_FORWARD, ui::EF_CONTROL_DOWN);
EXPECT_TRUE(hotseat_widget->IsActive()); EXPECT_TRUE(status_area->IsActive());
generator->PressKey(ui::VKEY_BROWSER_FORWARD, ui::EF_CONTROL_DOWN); generator->PressKey(ui::VKEY_BROWSER_FORWARD, ui::EF_CONTROL_DOWN);
EXPECT_TRUE(pip_widget->IsActive()); EXPECT_TRUE(pip_widget->IsActive());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment