chromium/chrome/browser/ui/views/intent_picker_bubble_view_unittest.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/intent_picker_bubble_view.h"

#include <optional>
#include <string>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/apps/link_capturing/intent_picker_info.h"
#include "chrome/browser/apps/link_capturing/link_capturing_feature_test_support.h"
#include "chrome/browser/apps/link_capturing/link_capturing_features.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/views/chrome_views_test_base.h"
#include "components/services/app_service/public/cpp/intent_util.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/event_generator.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/image/image.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_state.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/resources/grit/views_resources.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget_utils.h"
#include "url/gurl.h"
#include "url/origin.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "components/arc/common/intent_helper/arc_intent_helper_package.h"
#endif

AppInfo;
BubbleType;
WebContents;
OpenURLParams;
Referrer;

class IntentPickerBubbleViewTest : public TestWithBrowserView {};

// Verifies that we didn't set up an image for any LabelButton.
TEST_F(IntentPickerBubbleViewTest, NullIcons) {}

// Verifies that all the icons contain a non-null icon.
TEST_F(IntentPickerBubbleViewTest, NonNullIcons) {}

// Verifies that the bubble contains as many rows as |app_info_| with one
// exception, if the Chrome package is present on the input list it won't be
// shown to the user on the picker UI, so there could be a difference
// represented by |chrome_package_repetitions|.
TEST_F(IntentPickerBubbleViewTest, LabelsPtrVectorSize) {}

// Verifies that the first item is activated by default when creating a new
// bubble.
TEST_F(IntentPickerBubbleViewTest, VerifyStartingInkDrop) {}

// Press each button at a time and make sure it goes to ACTIVATED state,
// followed by HIDDEN state after selecting other button.
TEST_F(IntentPickerBubbleViewTest, InkDropStateTransition) {}

// Arbitrary press a button twice, check that the InkDropState remains the same.
TEST_F(IntentPickerBubbleViewTest, PressButtonTwice) {}

// Check that a non nullptr WebContents() has been created and observed.
TEST_F(IntentPickerBubbleViewTest, WebContentsTiedToBubble) {}

// Check that that the correct window title is shown.
TEST_F(IntentPickerBubbleViewTest, WindowTitle) {}

// Check that that the correct button labels are used.
TEST_F(IntentPickerBubbleViewTest, ButtonLabels) {}

TEST_F(IntentPickerBubbleViewTest, InitiatingOriginView) {}

enum class BubbleInterfaceType {};

class IntentPickerBubbleViewLayoutTest
    : public IntentPickerBubbleViewTest,
      public ::testing::WithParamInterface<BubbleInterfaceType> {};

TEST_P(IntentPickerBubbleViewLayoutTest, RememberCheckbox) {}

TEST_P(IntentPickerBubbleViewLayoutTest, AcceptDialog) {}

TEST_P(IntentPickerBubbleViewLayoutTest, AcceptDialogWithRememberSelection) {}

TEST_P(IntentPickerBubbleViewLayoutTest, CancelDialog) {}

TEST_P(IntentPickerBubbleViewLayoutTest, CloseDialog) {}

// TODO(crbug.com/40843230): Fix flakiness on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_KeyboardNavigation
#else
#define MAYBE_KeyboardNavigation
#endif
TEST_P(IntentPickerBubbleViewLayoutTest, MAYBE_KeyboardNavigation) {}

TEST_P(IntentPickerBubbleViewLayoutTest, DoubleClickToAccept) {}

INSTANTIATE_TEST_SUITE_P();

class IntentPickerBubbleViewGridLayoutTest : public IntentPickerBubbleViewTest {};

TEST_F(IntentPickerBubbleViewGridLayoutTest, DefaultSelectionOneApp) {}

TEST_F(IntentPickerBubbleViewGridLayoutTest, AccessibilityCheckedStateChange) {}

TEST_F(IntentPickerBubbleViewGridLayoutTest, DefaultSelectionTwoApps) {}

// TODO(crbug.com/40843230): Fix flakiness on Windows.
#if BUILDFLAG(IS_WIN)
#define MAYBE_OpenWithReturnKey
#else
#define MAYBE_OpenWithReturnKey
#endif
TEST_F(IntentPickerBubbleViewGridLayoutTest, MAYBE_OpenWithReturnKey) {}