Commit d1a68b1c authored by David Black's avatar David Black Committed by Commit Bot

Add context menu to holding space tray.

The context menu will only show when the content forward entry point is
enabled and will eventually be used to allow the user to enable/disable
holding space item previews in the tray.

This CL adds and shows the context menu but does not wire it up to
perform its intended action. That will be done in the next CL.

Bug: 1142572
Change-Id: Ic81bf57b84467d28757b311e73aeacf0eef401b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523905Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#825426}
parent fd9ee0f5
......@@ -986,12 +986,18 @@ This file contains the strings for ash.
<message name="IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_COPY_IMAGE_TO_CLIPBOARD" desc="Title of the option to copy an image to the clipboard in the holding space item context menu.">
Copy image
</message>
<message name="IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_HIDE_PREVIEWS" desc="Title of the option to hide previews in the holding space tray context menu.">
Hide previews
</message>
<message name="IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_PIN" desc="Title of the pin option in the holding space item context menu.">
Pin
</message>
<message name="IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_SHOW_IN_FOLDER" desc="Title of the option to show item in its folder in the holding space item context menu.">
Show in folder
</message>
<message name="IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_SHOW_PREVIEWS" desc="Title of the option to show previews in the holding space tray context menu.">
Show previews
</message>
<message name="IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_UNPIN" desc="Title of the unpin option in the holding space item context menu.">
Unpin
</message>
......
b9bcb1c92b7252ccbdb6d56e913b49ca86adf868
\ No newline at end of file
6c452cd23b239225ead66df5450ece9e95a4e1a6
\ No newline at end of file
......@@ -42,9 +42,11 @@ constexpr int kHoldingSpaceTrayIconSize = 20;
// Context menu commands.
enum HoldingSpaceCommandId {
kPinItem,
kCopyImageToClipboard,
kHidePreviews,
kPinItem,
kShowInFolder,
kShowPreviews,
kUnpinItem,
kMaxValue = kUnpinItem
};
......
......@@ -58,6 +58,9 @@ class ASH_EXPORT HoldingSpaceTestApi {
// If holding space UI is not visible, an empty collection is returned.
std::vector<views::View*> GetScreenCaptureViews();
// Returns the holding space tray in the shelf.
views::View* GetTray();
// Returns whether the pinned files container is shown.
bool PinnedFilesContainerShown() const;
......
......@@ -328,6 +328,8 @@ aggregate_vector_icons("ash_vector_icons") {
"unified_network_badge_vpn.icon",
"unpinned.icon",
"unrendered_html_placeholder.icon",
"visibility.icon",
"visibility_off.icon",
"wallpaper.icon",
]
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 24,
MOVE_TO, 12, 7,
R_CUBIC_TO, -2.48f, 0, -4.5f, 2.02f, -4.5f, 4.5f,
CUBIC_TO_SHORTHAND, 9.52f, 16, 12, 16,
R_CUBIC_TO, 2.48f, 0, 4.5f, -2.02f, 4.5f, -4.5f,
CUBIC_TO_SHORTHAND, 14.48f, 7, 12, 7,
CLOSE,
R_MOVE_TO, 0, 7.2f,
R_CUBIC_TO, -1.49f, 0, -2.7f, -1.21f, -2.7f, -2.7f,
R_CUBIC_TO, 0, -1.49f, 1.21f, -2.7f, 2.7f, -2.7f,
R_CUBIC_TO, 1.49f, 0, 2.7f, 1.21f, 2.7f, 2.7f,
R_CUBIC_TO, 0, 1.49f, -1.21f, 2.7f, -2.7f, 2.7f,
CLOSE,
MOVE_TO, 12, 4,
CUBIC_TO, 7, 4, 2.73f, 7.11f, 1, 11.5f,
CUBIC_TO, 2.73f, 15.89f, 7, 19, 12, 19,
R_CUBIC_TO, 5, 0, 9.27f, -3.11f, 11, -7.5f,
CUBIC_TO, 21.27f, 7.11f, 17, 4, 12, 4,
CLOSE,
R_MOVE_TO, 0, 13,
R_CUBIC_TO, -3.79f, 0, -7.17f, -2.13f, -8.82f, -5.5f,
CUBIC_TO, 4.83f, 8.13f, 8.21f, 6, 12, 6,
R_CUBIC_TO, 3.79f, 0, 7.17f, 2.13f, 8.82f, 5.5f,
CUBIC_TO, 19.17f, 14.87f, 15.79f, 17, 12, 17,
CLOSE
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 24,
MOVE_TO, 10.58f, 7.25f,
R_LINE_TO, 1.56f, 1.56f,
R_CUBIC_TO, 1.38f, 0.07f, 2.47f, 1.17f, 2.54f, 2.54f,
R_LINE_TO, 1.56f, 1.56f,
R_CUBIC_TO, 0.16f, -0.44f, 0.26f, -0.91f, 0.26f, -1.41f,
CUBIC_TO, 16.5f, 9.02f, 14.48f, 7, 12, 7,
R_CUBIC_TO, -0.5f, 0, -0.97f, 0.1f, -1.42f, 0.25f,
CLOSE,
MOVE_TO, 12, 6,
R_CUBIC_TO, 3.79f, 0, 7.17f, 2.13f, 8.82f, 5.5f,
R_CUBIC_TO, -0.64f, 1.32f, -1.56f, 2.44f, -2.66f, 3.33f,
R_LINE_TO, 1.42f, 1.42f,
R_CUBIC_TO, 1.51f, -1.26f, 2.7f, -2.89f, 3.43f, -4.74f,
CUBIC_TO, 21.27f, 7.11f, 17, 4, 12, 4,
R_CUBIC_TO, -1.4f, 0, -2.73f, 0.25f, -3.98f, 0.7f,
R_LINE_TO, 1.61f, 1.6f,
CUBIC_TO, 10.4f, 6.12f, 11.19f, 6, 12, 6,
CLOSE,
R_MOVE_TO, 4.43f, 9.93f,
R_LINE_TO, -1.25f, -1.25f,
R_LINE_TO, -1.27f, -1.27f,
R_LINE_TO, -3.82f, -3.82f,
R_LINE_TO, -1.27f, -1.27f,
R_LINE_TO, -1.25f, -1.25f,
R_LINE_TO, -1.48f, -1.48f,
R_LINE_TO, -2.78f, -2.78f,
R_LINE_TO, -1.42f, 1.41f,
R_LINE_TO, 2.53f, 2.53f,
CUBIC_TO, 2.92f, 8.02f, 1.73f, 9.64f, 1, 11.5f,
CUBIC_TO, 2.73f, 15.89f, 7, 19, 12, 19,
R_CUBIC_TO, 1.4f, 0, 2.73f, -0.25f, 3.98f, -0.7f,
R_LINE_TO, 4.3f, 4.3f,
R_LINE_TO, 1.41f, -1.41f,
R_LINE_TO, -3.78f, -3.78f,
R_LINE_TO, -1.48f, -1.48f,
CLOSE,
R_MOVE_TO, -4.57f, -1.74f,
R_CUBIC_TO, -1.38f, -0.07f, -2.47f, -1.17f, -2.54f, -2.54f,
R_LINE_TO, 2.54f, 2.54f,
CLOSE,
MOVE_TO, 12, 17,
R_CUBIC_TO, -3.79f, 0, -7.17f, -2.13f, -8.82f, -5.5f,
R_CUBIC_TO, 0.64f, -1.32f, 1.56f, -2.44f, 2.66f, -3.33f,
R_LINE_TO, 1.91f, 1.91f,
R_CUBIC_TO, -0.15f, 0.45f, -0.25f, 0.92f, -0.25f, 1.42f,
R_CUBIC_TO, 0, 2.48f, 2.02f, 4.5f, 4.5f, 4.5f,
R_CUBIC_TO, 0.5f, 0, 0.97f, -0.1f, 1.42f, -0.25f,
R_LINE_TO, 0.95f, 0.95f,
R_CUBIC_TO, -0.77f, 0.18f, -1.56f, 0.3f, -2.37f, 0.3f,
CLOSE
......@@ -126,6 +126,10 @@ std::vector<views::View*> HoldingSpaceTestApi::GetScreenCaptureViews() {
return screen_capture_views;
}
views::View* HoldingSpaceTestApi::GetTray() {
return holding_space_tray_;
}
bool HoldingSpaceTestApi::PinnedFilesContainerShown() const {
if (!holding_space_tray_->GetBubbleView())
return false;
......
......@@ -7,11 +7,13 @@
#include <memory>
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/holding_space/holding_space_constants.h"
#include "ash/public/cpp/holding_space/holding_space_item.h"
#include "ash/public/cpp/holding_space/holding_space_metrics.h"
#include "ash/public/cpp/holding_space/holding_space_prefs.h"
#include "ash/public/cpp/system_tray_client.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
......@@ -20,11 +22,19 @@
#include "ash/system/holding_space/holding_space_tray_icon.h"
#include "ash/system/tray/tray_container.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/menu/menu_runner.h"
namespace ash {
namespace {
// Helpers ---------------------------------------------------------------------
// TODO(crbug.com/1142572): Read state from prefs.
bool IsShowingPreviews() {
return features::IsTemporaryHoldingSpaceContentForwardEntryPointEnabled();
}
// Returns whether the holding space model contains any finalized items.
bool ModelContainsFinalizedItems(HoldingSpaceModel* model) {
for (const auto& item : model->items()) {
......@@ -36,10 +46,16 @@ bool ModelContainsFinalizedItems(HoldingSpaceModel* model) {
} // namespace
// HoldingSpaceTray ------------------------------------------------------------
HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
controller_observer_.Add(HoldingSpaceController::Get());
SetVisible(false);
// Context menu.
if (features::IsTemporaryHoldingSpaceContentForwardEntryPointEnabled())
set_context_menu_controller(this);
// Icon.
icon_ = tray_container()->AddChildView(
std::make_unique<HoldingSpaceTrayIcon>(shelf));
......@@ -190,6 +206,49 @@ void HoldingSpaceTray::OnHoldingSpaceItemFinalized(
UpdateVisibility();
}
// TODO(crbug.com/1142572): Implement.
void HoldingSpaceTray::ExecuteCommand(int command_id, int event_flags) {
DCHECK(features::IsTemporaryHoldingSpaceContentForwardEntryPointEnabled());
NOTIMPLEMENTED();
}
void HoldingSpaceTray::ShowContextMenuForViewImpl(
views::View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) {
DCHECK(features::IsTemporaryHoldingSpaceContentForwardEntryPointEnabled());
context_menu_model_ = std::make_unique<ui::SimpleMenuModel>(this);
if (IsShowingPreviews()) {
context_menu_model_->AddItemWithIcon(
HoldingSpaceCommandId::kHidePreviews,
l10n_util::GetStringUTF16(
IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_HIDE_PREVIEWS),
ui::ImageModel::FromVectorIcon(kVisibilityOffIcon));
} else {
context_menu_model_->AddItemWithIcon(
HoldingSpaceCommandId::kShowPreviews,
l10n_util::GetStringUTF16(
IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_SHOW_PREVIEWS),
ui::ImageModel::FromVectorIcon(kVisibilityIcon));
}
const int run_types = views::MenuRunner::USE_TOUCHABLE_LAYOUT |
views::MenuRunner::CONTEXT_MENU |
views::MenuRunner::FIXED_ANCHOR;
context_menu_runner_ =
std::make_unique<views::MenuRunner>(context_menu_model_.get(), run_types);
gfx::Rect anchor = source->GetBoundsInScreen();
anchor.Inset(gfx::Insets(-kHoldingSpaceContextMenuMargin, 0));
context_menu_runner_->RunMenuAt(
source->GetWidget(), /*button_controller=*/nullptr, anchor,
views::MenuAnchorPosition::kTopLeft, source_type);
}
void HoldingSpaceTray::OnWidgetDragWillStart(views::Widget* widget) {
// The holding space bubble should be closed while dragging holding space
// items so as not to obstruct drop targets. Post the task to close the bubble
......
......@@ -16,6 +16,8 @@
#include "ash/system/tray/tray_background_view.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
......@@ -29,6 +31,8 @@ class HoldingSpaceTrayIcon;
class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView,
public HoldingSpaceControllerObserver,
public HoldingSpaceModelObserver,
public ui::SimpleMenuModel::Delegate,
public views::ContextMenuController,
public views::WidgetObserver {
public:
explicit HoldingSpaceTray(Shelf* shelf);
......@@ -66,12 +70,22 @@ class ASH_EXPORT HoldingSpaceTray : public TrayBackgroundView,
void OnHoldingSpaceItemRemoved(const HoldingSpaceItem* item) override;
void OnHoldingSpaceItemFinalized(const HoldingSpaceItem* item) override;
// ui::SimpleMenuModel::Delegate:
void ExecuteCommand(int command_id, int event_flags) override;
// views::ContextMenuController:
void ShowContextMenuForViewImpl(views::View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) override;
// views::WidgetObserver:
void OnWidgetDragWillStart(views::Widget* widget) override;
void OnWidgetDestroying(views::Widget* widget) override;
HoldingSpaceTrayIcon* icon_ = nullptr; // Owned by `TrayContainer`.
std::unique_ptr<HoldingSpaceTrayBubble> bubble_;
std::unique_ptr<ui::SimpleMenuModel> context_menu_model_;
std::unique_ptr<views::MenuRunner> context_menu_runner_;
ScopedObserver<HoldingSpaceController, HoldingSpaceControllerObserver>
controller_observer_{this};
......
......@@ -113,6 +113,9 @@ void HoldingSpaceTrayIcon::OnHoldingSpaceItemRemoved(
const HoldingSpaceItem* item) {
DCHECK(features::IsTemporaryHoldingSpaceContentForwardEntryPointEnabled());
if (!item->IsFinalized())
return;
size_t index = previews_.size();
for (size_t i = 0u; i < previews_.size(); ++i) {
if (previews_[i]->item() == item) {
......
......@@ -22,6 +22,7 @@
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "url/gurl.h"
namespace ash {
......@@ -37,10 +38,16 @@ std::unique_ptr<HoldingSpaceImage> CreateStubHoldingSpaceImage() {
} // namespace
class HoldingSpaceTrayTest : public AshTestBase {
// Parameterized by whether the content forward entry point is enabled.
class HoldingSpaceTrayTest : public AshTestBase,
public testing::WithParamInterface<bool> {
public:
HoldingSpaceTrayTest() {
scoped_feature_list_.InitAndEnableFeature(features::kTemporaryHoldingSpace);
scoped_feature_list_.InitAndEnableFeatureWithParameters(
features::kTemporaryHoldingSpace,
/*field_trial_params=*/{
{"content-forward-entry-point-enabled",
IsContentForwardEntryPointEnabled() ? "true" : "false"}});
}
// AshTestBase:
......@@ -108,6 +115,8 @@ class HoldingSpaceTrayTest : public AshTestBase {
GetSessionControllerClient()->GetUserPrefService(user_account));
}
bool IsContentForwardEntryPointEnabled() const { return GetParam(); }
HoldingSpaceTestApi* test_api() { return test_api_.get(); }
HoldingSpaceModel* model() { return &holding_space_model_; }
......@@ -118,7 +127,7 @@ class HoldingSpaceTrayTest : public AshTestBase {
base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(HoldingSpaceTrayTest, ShowTrayButtonOnFirstUse) {
TEST_P(HoldingSpaceTrayTest, ShowTrayButtonOnFirstUse) {
StartSession();
// Tray item should be shown for users that have never added anything to the
......@@ -157,7 +166,7 @@ TEST_F(HoldingSpaceTrayTest, ShowTrayButtonOnFirstUse) {
EXPECT_FALSE(test_api()->IsShowingInShelf());
}
TEST_F(HoldingSpaceTrayTest, AddingItemShowsTrayBubble) {
TEST_P(HoldingSpaceTrayTest, AddingItemShowsTrayBubble) {
MarkTimeOfFirstPin();
StartSession();
......@@ -190,7 +199,7 @@ TEST_F(HoldingSpaceTrayTest, AddingItemShowsTrayBubble) {
EXPECT_FALSE(test_api()->IsShowingInShelf());
}
TEST_F(HoldingSpaceTrayTest, TrayButtonNotShownForPartialItemsOnly) {
TEST_P(HoldingSpaceTrayTest, TrayButtonNotShownForPartialItemsOnly) {
MarkTimeOfFirstPin();
StartSession();
......@@ -224,7 +233,7 @@ TEST_F(HoldingSpaceTrayTest, TrayButtonNotShownForPartialItemsOnly) {
// Tests how download chips are updated during item addition, removal and
// finalization
TEST_F(HoldingSpaceTrayTest, DownloadsContainer) {
TEST_P(HoldingSpaceTrayTest, DownloadsContainer) {
StartSession();
test_api()->Show();
......@@ -314,7 +323,7 @@ TEST_F(HoldingSpaceTrayTest, DownloadsContainer) {
// Verifies the downloads container is shown and orders items as expected when
// the model contains a number of finalized items prior to showing UI.
TEST_F(HoldingSpaceTrayTest, DownloadsContainerWithFinalizedItemsOnly) {
TEST_P(HoldingSpaceTrayTest, DownloadsContainerWithFinalizedItemsOnly) {
MarkTimeOfFirstPin();
StartSession();
......@@ -344,7 +353,7 @@ TEST_F(HoldingSpaceTrayTest, DownloadsContainerWithFinalizedItemsOnly) {
test_api()->Close();
}
TEST_F(HoldingSpaceTrayTest, FinalizingDownloadItemThatShouldBeInvisible) {
TEST_P(HoldingSpaceTrayTest, FinalizingDownloadItemThatShouldBeInvisible) {
StartSession();
test_api()->Show();
......@@ -397,7 +406,7 @@ TEST_F(HoldingSpaceTrayTest, FinalizingDownloadItemThatShouldBeInvisible) {
// Tests that a partially initialized download item does not get shown if a full
// download item gets removed from the holding space.
TEST_F(HoldingSpaceTrayTest, PartialItemNowShownOnRemovingADownloadItem) {
TEST_P(HoldingSpaceTrayTest, PartialItemNowShownOnRemovingADownloadItem) {
StartSession();
test_api()->Show();
......@@ -436,7 +445,7 @@ TEST_F(HoldingSpaceTrayTest, PartialItemNowShownOnRemovingADownloadItem) {
// Tests how screen capture list is updated during item addition, removal and
// finalization
TEST_F(HoldingSpaceTrayTest, ScreenCaptureContainer) {
TEST_P(HoldingSpaceTrayTest, ScreenCaptureContainer) {
StartSession();
test_api()->Show();
EXPECT_TRUE(test_api()->PinnedFilesContainerShown());
......@@ -536,7 +545,7 @@ TEST_F(HoldingSpaceTrayTest, ScreenCaptureContainer) {
// Verifies the screen captures container is shown and orders items as expected
// when the model contains a number of finalized items prior to showing UI.
TEST_F(HoldingSpaceTrayTest, ScreenCapturesContainerWithFinalizedItemsOnly) {
TEST_P(HoldingSpaceTrayTest, ScreenCapturesContainerWithFinalizedItemsOnly) {
MarkTimeOfFirstPin();
StartSession();
......@@ -566,7 +575,7 @@ TEST_F(HoldingSpaceTrayTest, ScreenCapturesContainerWithFinalizedItemsOnly) {
test_api()->Close();
}
TEST_F(HoldingSpaceTrayTest, FinalizingScreenCaptureItemThatShouldBeInvisible) {
TEST_P(HoldingSpaceTrayTest, FinalizingScreenCaptureItemThatShouldBeInvisible) {
StartSession();
test_api()->Show();
......@@ -637,7 +646,7 @@ TEST_F(HoldingSpaceTrayTest, FinalizingScreenCaptureItemThatShouldBeInvisible) {
// Tests that a partially initialized screenshot item does not get shown if a
// fully initialized screenshot item gets removed from the holding space.
TEST_F(HoldingSpaceTrayTest, PartialItemNowShownOnRemovingAScreenCapture) {
TEST_P(HoldingSpaceTrayTest, PartialItemNowShownOnRemovingAScreenCapture) {
StartSession();
test_api()->Show();
......@@ -683,7 +692,7 @@ TEST_F(HoldingSpaceTrayTest, PartialItemNowShownOnRemovingAScreenCapture) {
// Tests how the pinned item list is updated during item addition, removal and
// finalization.
TEST_F(HoldingSpaceTrayTest, PinnedFilesContainer) {
TEST_P(HoldingSpaceTrayTest, PinnedFilesContainer) {
MarkTimeOfFirstPin();
StartSession();
......@@ -788,7 +797,7 @@ TEST_F(HoldingSpaceTrayTest, PinnedFilesContainer) {
// Verifies the pinned items container is not shown if it only contains
// partially initialized items.
TEST_F(HoldingSpaceTrayTest,
TEST_P(HoldingSpaceTrayTest,
PinnedFilesContainerWithPartiallyInitializedItemsOnly) {
MarkTimeOfFirstPin();
StartSession();
......@@ -830,7 +839,7 @@ TEST_F(HoldingSpaceTrayTest,
// Verifies the pinned items container is shown and orders items as expected
// when the model contains a number of finalized items prior to showing UI.
TEST_F(HoldingSpaceTrayTest, PinnedFilesContainerWithFinalizedItemsOnly) {
TEST_P(HoldingSpaceTrayTest, PinnedFilesContainerWithFinalizedItemsOnly) {
MarkTimeOfFirstPin();
StartSession();
......@@ -861,7 +870,7 @@ TEST_F(HoldingSpaceTrayTest, PinnedFilesContainerWithFinalizedItemsOnly) {
// Tests that as nearby shared files are added to the model, they show on the
// downloads container.
TEST_F(HoldingSpaceTrayTest, DownloadsContainerWithNearbySharedFiles) {
TEST_P(HoldingSpaceTrayTest, DownloadsContainerWithNearbySharedFiles) {
StartSession();
test_api()->Show();
......@@ -912,7 +921,7 @@ TEST_F(HoldingSpaceTrayTest, DownloadsContainerWithNearbySharedFiles) {
// Tests that a partially initialized nearby share item does not get shown if a
// full download item gets removed from the holding space.
TEST_F(HoldingSpaceTrayTest, PartialNearbyShareItemWithExistingDownloadItems) {
TEST_P(HoldingSpaceTrayTest, PartialNearbyShareItemWithExistingDownloadItems) {
StartSession();
test_api()->Show();
......@@ -992,7 +1001,7 @@ TEST_F(HoldingSpaceTrayTest, PartialNearbyShareItemWithExistingDownloadItems) {
// Tests that a partially initialized download item does not get shown if a
// full download item gets removed from the holding space.
TEST_F(HoldingSpaceTrayTest, PartialDownloadItemWithExistingNearbyShareItems) {
TEST_P(HoldingSpaceTrayTest, PartialDownloadItemWithExistingNearbyShareItems) {
StartSession();
test_api()->Show();
......@@ -1047,4 +1056,26 @@ TEST_F(HoldingSpaceTrayTest, PartialDownloadItemWithExistingNearbyShareItems) {
test_api()->Close();
}
// Right clicking the holding space tray should show a context menu if the
// content forward entry point is enabled. Otherwise it should do nothing.
TEST_P(HoldingSpaceTrayTest, ShouldMaybeShowContextMenuOnRightClick) {
StartSession();
views::View* tray = test_api()->GetTray();
ASSERT_TRUE(tray);
EXPECT_FALSE(views::MenuController::GetActiveInstance());
// Move the mouse to and perform a right click on `tray`.
auto* root_window = tray->GetWidget()->GetNativeWindow()->GetRootWindow();
ui::test::EventGenerator event_generator(root_window);
event_generator.MoveMouseTo(tray->GetBoundsInScreen().CenterPoint());
event_generator.ClickRightButton();
EXPECT_EQ(!!views::MenuController::GetActiveInstance(),
IsContentForwardEntryPointEnabled());
}
INSTANTIATE_TEST_SUITE_P(All, HoldingSpaceTrayTest, testing::Bool());
} // namespace ash
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