gd: Fix the crash related to Tab focus
This CL fixes the issue with the tab focus within GD UIs on ARC windows. Bug: b/335330357 Test: manual test Change-Id: I1363e7e33942146c6314869b8326d74170374112 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5460896 Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Reviewed-by: Prameet Shah <phshah@chromium.org> Commit-Queue: Cici Ruan <cuicuiruan@google.com> Cr-Commit-Position: refs/heads/main@{#1288774}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
f2fb819b85
commit
bb99bbbf05
ash/game_dashboard
@ -459,10 +459,13 @@ void GameDashboardContext::OnEvent(ui::Event* event) {
|
||||
const bool reverse = event->IsShiftDown();
|
||||
|
||||
// Manually move focus from the currently focused widget to the next in
|
||||
// the widget list.
|
||||
MoveFocus(game_dashboard_utils::GetNextWidgetToFocus(
|
||||
GetTraversableWidgets(), currently_focused, reverse),
|
||||
event, reverse);
|
||||
// the widget list. It is possible that `currently_focused` is not in the
|
||||
// `GetTraversableWidgets()`. For example, `currently_focused` is the app
|
||||
// window itself.
|
||||
if (auto* next_focus = game_dashboard_utils::GetNextWidgetToFocus(
|
||||
GetTraversableWidgets(), currently_focused, reverse)) {
|
||||
MoveFocus(next_focus, event, reverse);
|
||||
}
|
||||
}
|
||||
} else if (main_menu_widget_) {
|
||||
switch (event_type) {
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "components/ukm/test_ukm_recorder.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "services/metrics/public/cpp/ukm_builders.h"
|
||||
#include "ui/aura/client/focus_client.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
|
||||
@ -2448,6 +2449,22 @@ TEST_P(GameTypeGameDashboardContextTest, TabletMode) {
|
||||
ToastManager::Get()->IsToastShown(game_dashboard::kTabletToastId));
|
||||
}
|
||||
|
||||
// Test tab navigation when the game window is focused.
|
||||
TEST_P(GameTypeGameDashboardContextTest, TabNavigationGameWindow) {
|
||||
test_api_->OpenTheMainMenu();
|
||||
test_api_->OpenTheToolbar();
|
||||
test_api_->CloseTheMainMenu();
|
||||
|
||||
aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow())
|
||||
->FocusWindow(game_window_.get());
|
||||
TabNavigateForward();
|
||||
|
||||
// Once the focus is on the game window, it's hard to know if it reaches to
|
||||
// the last focusable view inside. Keep the focus inside of the game window.
|
||||
EXPECT_FALSE(test_api_->GetGameDashboardButton()->HasFocus());
|
||||
EXPECT_FALSE(test_api_->GetToolbarGamepadButton()->HasFocus());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// OnOverviewModeEndedWaiter:
|
||||
class OnOverviewModeEndedWaiter : public OverviewObserver {
|
||||
|
Reference in New Issue
Block a user