chromium/chrome/browser/ui/views/passwords/password_bubble_interactive_uitest.cc

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

#include <memory>
#include <string>
#include <utility>

#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_samples.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/with_feature_override.h"
#include "build/build_config.h"
#include "chrome/browser/signin/chrome_signin_pref_names.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/passwords/manage_passwords_test.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/controls/rich_hover_button.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_details_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_list_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view_ids.h"
#include "chrome/browser/ui/views/passwords/password_auto_sign_in_view.h"
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
#include "chrome/browser/ui/views/passwords/password_save_update_view.h"
#include "chrome/browser/ui/views/passwords/shared_passwords_notification_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/password_manager/core/browser/features/password_features.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/signin/public/base/signin_prefs.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/focus_changed_observer.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/editable_combobox/editable_combobox.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/textarea/textarea.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/test/widget_test.h"

Bucket;
BasicHttpResponse;
HttpRequest;
HttpResponse;
PasswordForm;
_;
ElementsAre;
Eq;
Field;

namespace {

const char kDisplayDispositionMetric[] =;

bool IsBubbleShowing() {}

views::EditableCombobox* GetUsernameDropdown(
    const PasswordBubbleViewBase* bubble) {}

void ClickOnView(views::View* view) {}

PasswordForm CreateSharedCredentials(
    const GURL& url,
    const std::u16string& username = u"username",
    const std::u16string& sender_name = u"Elisa Becket") {}

}  // namespace

metrics_util;

class PasswordBubbleInteractiveUiTest : public ManagePasswordsTest {};

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, BasicOpenAndClose) {}

// Same as 'BasicOpenAndClose', but use the command rather than the static
// method directly.
IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, CommandControlsBubble) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       CommandExecutionInManagingState) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       CommandExecutionInAutomaticState) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       CommandExecutionInPendingState) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       CommandExecutionInAutomaticSaveState) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, DontCloseOnClick) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       DontCloseOnEscWithoutFocus) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, DontCloseOnKey) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, DontCloseOnNavigation) {}

// crbug.com/1194950.
// Test that the automatic save bubble ignores the browser activation and
// deactivation events.
IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       DontCloseOnDeactivation) {}

// crbug.com/1194950.
// Test that the automatic save bubble ignores the focus lost event.
IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, DontCloseOnLostFocus) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       TwoTabsWithBubbleSwitch) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       TwoTabsWithBubbleClose) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, AutoSignin) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, AutoSigninNoFocus) {}

// Test that triggering the leak detection dialog successfully hides a showing
// bubble.
IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest, LeakPromptHidesBubble) {}

class PasswordBubbleInteractiveUiTestWithExplicitBrowserSigninParam
    : public PasswordBubbleInteractiveUiTest,
      public base::test::WithFeatureOverride {};

// This is a regression test for crbug.com/1335418
IN_PROC_BROWSER_TEST_P(
    PasswordBubbleInteractiveUiTestWithExplicitBrowserSigninParam,
    SaveUiDismissalReason) {}

#if BUILDFLAG(ENABLE_DICE_SUPPORT)
IN_PROC_BROWSER_TEST_P(
    PasswordBubbleInteractiveUiTestWithExplicitBrowserSigninParam,
    DismissBubbleBeforeSignInPromoDoesNotIncrementPref) {}
#endif  // BUILDFLAG(ENABLE_DICE_SUPPORT)

INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE();

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       ClosesBubbleOnNavigationToFullPasswordManager) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       ClosesBubbleOnClickingGooglePasswordManagerLink) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       CopiesPasswordDetailsToClipboardOnCopyButtonClicks) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       RevealPasswordOnEyeIconClicks) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       DisplaysNewUsernameAfterEditing) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       DisplaysCorrectTextAfterAddingNote) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       DisplaysCorrectTextAfterEditingNote) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       DisplaysCorrectTextAfterDeletingNote) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       RecordsMetricsForCopyingFullNoteWithKeyboardShortcuts) {}

IN_PROC_BROWSER_TEST_F(
    PasswordBubbleInteractiveUiTest,
    RecordsMetricsForCopyingFullNoteWithSelectAllAndCopyCommands) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       RecordsMetricsForCopyingFullNoteAfterMouseSelection) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       RecordsMetricsForCopyingPartOfNoteAfterMouseSelection) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleInteractiveUiTest,
                       NavigateToManagementDetailsViewAndTakeScreenshot) {}

IN_PROC_BROWSER_TEST_F(
    PasswordBubbleInteractiveUiTest,
    NavigateToManagementDetailsViewWithMoveFooterVisibleAndTakeScreenshot) {}

class PasswordBubbleWithManagePasswordButtonInteractiveUiTest
    : public PasswordBubbleInteractiveUiTest {};

IN_PROC_BROWSER_TEST_F(PasswordBubbleWithManagePasswordButtonInteractiveUiTest,
                       ClosesBubbleOnNavigationToPasswordDetailsSubpage) {}

IN_PROC_BROWSER_TEST_F(PasswordBubbleWithManagePasswordButtonInteractiveUiTest,
                       NavigateToManagementDetailsViewAndTakeScreenshot) {}

class SharedPasswordsNotificationBubbleInteractiveUiTest
    : public PasswordBubbleInteractiveUiTest {};

auto SharedPasswordsNotificationBubbleInteractiveUiTest::
    ScreenshotSharedPasswordsNotificationRootView(const char* baseline) {}

IN_PROC_BROWSER_TEST_F(SharedPasswordsNotificationBubbleInteractiveUiTest,
                       SharedPasswordNotificationUIShowsUpAndTakeScreenshot) {}

IN_PROC_BROWSER_TEST_F(
    SharedPasswordsNotificationBubbleInteractiveUiTest,
    MultipleSharedPasswordsNotificationUIShowsUpAndTakeScreenshot) {}

// Tests the case when there are multiple shared passwords, but only one is not
// notified yet.
IN_PROC_BROWSER_TEST_F(
    SharedPasswordsNotificationBubbleInteractiveUiTest,
    OnlyUnnotifiedPasswordsNotificationUIShowsUpAndTakeScreenshot) {}

IN_PROC_BROWSER_TEST_F(
    SharedPasswordsNotificationBubbleInteractiveUiTest,
    SharedPasswordNotificationUIShouldNotShowIfNotifiedAlready) {}