0

Add Utility Cluster Row to Menu

Creates the utility cluster row, which contains a feedback, settings,
and help button. The functionality for these buttons will be implemented
in a future CL.

Bug: b:275424971
Test: Ran GameDashboard* ash_unittests
Change-Id: I0f0ed997e04b57e42d84b378920b42e49e871236
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4569652
Commit-Queue: Gina Domergue <gdomergue@google.com>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1158921}
This commit is contained in:
Gina Domergue
2023-06-16 17:11:34 +00:00
committed by Chromium LUCI CQ
parent dca83def85
commit 66f9dc4417
8 changed files with 133 additions and 3 deletions

@ -6759,6 +6759,9 @@ To shut down the device, press and hold the power button on the device again.
<message name="IDS_ASH_GAME_DASHBOARD_CONTROLS_TILE_BUTTON_TITLE" translateable="false" desc="The display name for the Game Dashboard game controls tile.">
Controls
</message>
<message name="IDS_ASH_GAME_DASHBOARD_HELP_TOOLTIP" translateable="false" desc="Tooltip for the Game Dashboard help icon button.">
Help center
</message>
<message name="IDS_ASH_GAME_DASHBOARD_MAIN_MENU_BUTTON_TITLE" desc="The title of the Game Dashboard main menu button.">
Game Dashboard
</message>
@ -6771,6 +6774,12 @@ To shut down the device, press and hold the power button on the device again.
<message name="IDS_ASH_GAME_DASHBOARD_SCREEN_SIZE_SETTINGS_TITLE" translateable="false" desc="The display name for the Game Dashboard screen size settings.">
Screen size
</message>
<message name="IDS_ASH_GAME_DASHBOARD_SEND_FEEDBACK_TITLE" translateable="false" desc="The display name for the Game Dashboard send feedback button.">
Send feedback
</message>
<message name="IDS_ASH_GAME_DASHBOARD_SETTINGS_TOOLTIP" translateable="false" desc="Tooltip for the Game Dashboard settings icon button.">
Dashboard settings
</message>
<message name="IDS_ASH_GAME_DASHBOARD_TOOLBAR_TILE_BUTTON_TITLE" translateable="false" desc="The display name for the Game Dashboard toolbar tile.">
Toolbar
</message>

@ -0,0 +1 @@
6bd821d57e43cddd54301863dbe2e9861ba809a6

@ -0,0 +1 @@
c2544472af9221944d377fd4242add495cc6f05a

@ -0,0 +1 @@
dea3a882021afadd69a56b689084f67d059659ec

@ -11,11 +11,14 @@
#include "ash/game_dashboard/game_dashboard_test_base.h"
#include "ash/game_dashboard/test_game_dashboard_delegate.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/system/unified/feature_tile.h"
#include "base/check.h"
#include "chromeos/ui/base/window_properties.h"
#include "chromeos/ui/frame/frame_header.h"
#include "chromeos/ui/wm/window_util.h"
#include "extensions/common/constants.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/vector2d.h"
@ -33,12 +36,19 @@ class GameDashboardContextTest : public GameDashboardTestBase {
void SetUp() override {
GameDashboardTestBase::SetUp();
game_window_ = CreateAppWindow(TestGameDashboardDelegate::kGameAppId,
AppType::ARC_APP, game_window_bounds_);
AppType::ARC_APP, gfx::Rect(0, 0, 400, 200));
game_context_ = GameDashboardController::Get()->GetGameDashboardContext(
game_window_.get());
DCHECK(game_context_);
}
void SetUpGeForceNowApp() {
game_window_->SetProperty(
kAppIDKey, static_cast<std::string>(extension_misc::kGeForceNowAppId));
game_window_->SetProperty(aura::client::kAppType,
static_cast<int>(AppType::NON_APP));
}
void TearDown() override {
game_window_.reset();
GameDashboardTestBase::TearDown();
@ -63,7 +73,6 @@ class GameDashboardContextTest : public GameDashboardTestBase {
protected:
std::unique_ptr<aura::Window> game_window_;
const GameDashboardContext* game_context_;
const gfx::Rect game_window_bounds_ = gfx::Rect(0, 0, 400, 200);
};
// Tests
@ -121,6 +130,46 @@ TEST_F(GameDashboardContextTest, CloseMainMenuButtonWidget) {
EXPECT_FALSE(GetMainMenuDialogWidget());
}
// Verifies the main menu shows all items allowed for ARC games.
TEST_F(GameDashboardContextTest, MainMenuDialogWidget_ARCGame) {
// Open the main menu.
LeftClickOn(GetMainMenuButtonWidget()->GetContentsView());
ASSERT_TRUE(GetMainMenuDialogWidget());
// Verify whether each element available in the main menu is available as
// expected.
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_TOOLBAR_TILE));
// TODO(b/273641402): Update Game Controls visibility once implemented.
EXPECT_FALSE(GetMainMenuViewById(VIEW_ID_GD_CONTROLS_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_RECORD_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_SCREENSHOT_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_SCREEN_SIZE_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_FEEDBACK_BUTTON));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_HELP_BUTTON));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_GENERAL_SETTINGS_BUTTON));
}
// Verifies the main menu doesn't show items only allowed for ARC games on
// non-ARC apps.
TEST_F(GameDashboardContextTest, MainMenuDialogWidget_NonARCGame) {
// Override the default `game_window_` to reflect GeForce Now and open the
// main menu.
SetUpGeForceNowApp();
LeftClickOn(GetMainMenuButtonWidget()->GetContentsView());
ASSERT_TRUE(GetMainMenuDialogWidget());
// Verify whether each element available in the main menu is available as
// expected.
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_TOOLBAR_TILE));
EXPECT_FALSE(GetMainMenuViewById(VIEW_ID_GD_CONTROLS_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_RECORD_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_SCREENSHOT_TILE));
EXPECT_FALSE(GetMainMenuViewById(VIEW_ID_GD_SCREEN_SIZE_TILE));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_FEEDBACK_BUTTON));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_HELP_BUTTON));
EXPECT_TRUE(GetMainMenuViewById(VIEW_ID_GD_GENERAL_SETTINGS_BUTTON));
}
TEST_F(GameDashboardContextTest, TakeScreenshot) {
// Retrieve the screenshot button and verify the initial state.
LeftClickOn(GetMainMenuButtonWidget()->GetContentsView());
@ -133,7 +182,7 @@ TEST_F(GameDashboardContextTest, TakeScreenshot) {
// Verify that a screenshot is taken of the game window.
const auto file_path = WaitForCaptureFileToBeSaved();
const gfx::Image image = ReadAndDecodeImageFile(file_path);
EXPECT_EQ(image.Size(), game_window_bounds_.size());
EXPECT_EQ(image.Size(), game_window_->bounds().size());
}
} // namespace ash

@ -10,6 +10,7 @@
#include "ash/public/cpp/app_types_util.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/feature_tile.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
@ -47,6 +48,19 @@ std::unique_ptr<FeatureTile> CreateTile(base::RepeatingClosure callback,
return tile;
}
std::unique_ptr<ash::FeaturePodIconButton> CreateIconButton(
base::RepeatingClosure callback,
int id,
const gfx::VectorIcon& icon,
const std::u16string& text) {
auto icon_button = std::make_unique<FeaturePodIconButton>(
std::move(callback), /*is_togglable=*/false);
icon_button->SetID(id);
icon_button->SetVectorIcon(icon);
icon_button->SetTooltipText(text);
return icon_button;
}
} // namespace
GameDashboardMainMenuView::GameDashboardMainMenuView(
@ -74,6 +88,8 @@ GameDashboardMainMenuView::GameDashboardMainMenuView(
MaybeAddScreenSizeSettingsRow();
AddUtilityClusterRow();
SizeToPreferredSize();
}
@ -96,6 +112,18 @@ void GameDashboardMainMenuView::OnScreenSizeSettingsButtonPressed() {
// TODO(b/283988495): Add support when screen size setting is pressed.
}
void GameDashboardMainMenuView::OnFeedbackButtonPressed() {
// TODO(b/273641035): Add support when feedback button is pressed.
}
void GameDashboardMainMenuView::OnHelpButtonPressed() {
// TODO(b/273640773): Add support when help button is pressed.
}
void GameDashboardMainMenuView::OnSettingsButtonPressed() {
// TODO(b/281773221): Add support when settings button is pressed.
}
void GameDashboardMainMenuView::AddShortcutTilesRow() {
views::BoxLayoutView* container =
AddChildView(std::make_unique<views::BoxLayoutView>());
@ -139,6 +167,34 @@ void GameDashboardMainMenuView::MaybeAddScreenSizeSettingsRow() {
}
}
void GameDashboardMainMenuView::AddUtilityClusterRow() {
views::BoxLayoutView* container =
AddChildView(std::make_unique<views::BoxLayoutView>());
container->SetOrientation(views::BoxLayout::Orientation::kHorizontal);
container->SetBetweenChildSpacing(kCenterPadding);
auto* feedback_button =
container->AddChildView(std::make_unique<views::LabelButton>(
base::BindRepeating(
&GameDashboardMainMenuView::OnFeedbackButtonPressed,
base::Unretained(this)),
l10n_util::GetStringUTF16(
IDS_ASH_GAME_DASHBOARD_SEND_FEEDBACK_TITLE)));
feedback_button->SetID(VIEW_ID_GD_FEEDBACK_BUTTON);
feedback_button->SetImageLabelSpacing(kCenterPadding);
feedback_button->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
container->AddChildView(CreateIconButton(
base::BindRepeating(&GameDashboardMainMenuView::OnHelpButtonPressed,
base::Unretained(this)),
VIEW_ID_GD_HELP_BUTTON, vector_icons::kHelpIcon,
l10n_util::GetStringUTF16(IDS_ASH_GAME_DASHBOARD_HELP_TOOLTIP)));
container->AddChildView(CreateIconButton(
base::BindRepeating(&GameDashboardMainMenuView::OnSettingsButtonPressed,
base::Unretained(this)),
VIEW_ID_GD_GENERAL_SETTINGS_BUTTON, vector_icons::kSettingsIcon,
l10n_util::GetStringUTF16(IDS_ASH_GAME_DASHBOARD_SETTINGS_TOOLTIP)));
}
BEGIN_METADATA(GameDashboardMainMenuView, views::BubbleDialogDelegateView)
END_METADATA

@ -33,6 +33,12 @@ class GameDashboardMainMenuView : public views::BubbleDialogDelegateView {
void OnScreenshotTilePressed();
// Handles when the Screen Size Settings is pressed.
void OnScreenSizeSettingsButtonPressed();
// Opens the feedback form with preset information.
void OnFeedbackButtonPressed();
// Opens the help center for more info about Game Dashboard.
void OnHelpButtonPressed();
// Opens up the Game Dashboard Settings.
void OnSettingsButtonPressed();
// Adds a row of shortcut tiles to the main menu view for users to quickly
// access common functionality.
@ -42,6 +48,10 @@ class GameDashboardMainMenuView : public views::BubbleDialogDelegateView {
// given game window is an ARC app.
void MaybeAddScreenSizeSettingsRow();
// Adds the dashboard cluster (containing feedback, settings, and help
// buttons) to the Game Controls tile view.
void AddUtilityClusterRow();
const raw_ptr<aura::Window, ExperimentalAsh> game_window_;
};

@ -37,6 +37,9 @@ enum ViewID {
// Game Dashboard elements
VIEW_ID_GD_CONTROLS_TILE,
VIEW_ID_GD_FEEDBACK_BUTTON,
VIEW_ID_GD_GENERAL_SETTINGS_BUTTON,
VIEW_ID_GD_HELP_BUTTON,
VIEW_ID_GD_RECORD_TILE,
VIEW_ID_GD_SCREEN_SIZE_TILE,
VIEW_ID_GD_SCREENSHOT_TILE,