chromium/chrome/browser/ui/autofill/autofill_popup_controller_impl_unittest.cc

// Copyright 2012 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/autofill/autofill_popup_controller_impl.h"

#include <optional>

#include "base/test/metrics/user_action_tester.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller_impl_test_api.h"
#include "chrome/browser/ui/autofill/autofill_suggestion_controller_test_base.h"
#include "chrome/browser/ui/autofill/test_autofill_popup_controller_autofill_client.h"
#include "components/autofill/core/browser/ui/popup_interaction.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_button_action.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/common/aliases.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_active_popup.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_tree_id.h"
#include "ui/accessibility/ax_tree_manager.h"
#include "ui/accessibility/ax_tree_manager_map.h"
#include "ui/accessibility/platform/ax_platform_node_base.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
#include "ui/gfx/range/range.h"

#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "content/public/test/scoped_accessibility_mode_override.h"
#endif  // !BUILDFLAG(IS_CHROMEOS_ASH)

namespace autofill {

namespace {

_;
AllOf;
ElementsAre;
Eq;
Field;
InSequence;
Matcher;
Mock;
MockFunction;
NiceMock;
Return;

SingleEntryRemovalMethod;

Matcher<const AutofillSuggestionDelegate::SuggestionPosition&>
EqualsSuggestionPosition(
    AutofillSuggestionDelegate::SuggestionPosition position) {}

}  // namespace

AutofillPopupControllerImplTest;

TEST_F(AutofillPopupControllerImplTest, AcceptSuggestionRespectsTimeout) {}

// Tests that the time threshold for accepting suggestions only starts counting
// once the view is painted.
TEST_F(AutofillPopupControllerImplTest, AcceptSuggestionRespectsWaitsForPaint) {}

// Tests that reshowing the suggestions resets the accept threshold.
TEST_F(AutofillPopupControllerImplTest,
       AcceptSuggestionTimeoutIsUpdatedOnPopupUpdate) {}

TEST_F(AutofillPopupControllerImplTest, SubPopupIsCreatedWithViewFromParent) {}

TEST_F(AutofillPopupControllerImplTest,
       PopupInteraction_SubPopupMetricsAreLogged) {}

TEST_F(AutofillPopupControllerImplTest,
       PopupInteraction_NonAddressSuggestion_LogOnlyHistogramMetrics) {}

TEST_F(
    AutofillPopupControllerImplTest,
    PopupInteraction_TriggerSourcesThatOpensThePopupIndirectly_SubPopupMetricsAreNotLogged) {}

TEST_F(AutofillPopupControllerImplTest,
       PopupInteraction_RootPopupMetricsAreLogged) {}

TEST_F(AutofillPopupControllerImplTest,
       DelegateMethodsAreCalledOnlyByRootPopup) {}

TEST_F(AutofillPopupControllerImplTest, EventsAreDelegatedToChildrenAndView) {}

// Tests that the controller forwards calls to perform a button action (such as
// clicking a close button on a suggestion) to its delegate.
TEST_F(AutofillPopupControllerImplTest, ButtonActionsAreSentToDelegate) {}

// The second popup is also the second "sub_popup_level". This test asserts that
// the information regarding the popup level is passed on to the delegate.
TEST_F(AutofillPopupControllerImplTest, PopupForwardsSuggestionPosition) {}

TEST_F(AutofillPopupControllerImplTest, DoesNotAcceptUnacceptableSuggestions) {}

TEST_F(AutofillPopupControllerImplTest, DoesNotSelectUnacceptableSuggestions) {}

TEST_F(AutofillPopupControllerImplTest,
       ManualFallBackTriggerSource_IgnoresClickOutsideCheck) {}

// Tests that the popup controller queries the view for its screen location.
TEST_F(AutofillPopupControllerImplTest, GetPopupScreenLocationCallsView) {}

// Tests that Compose saved state notification popup gets hidden after 2
// seconds, but not after 1 second.
TEST_F(AutofillPopupControllerImplTest,
       TimedHideComposeSavedStateNotification) {}

TEST_F(AutofillPopupControllerImplTest,
       PopupHidesOnWebContentsFocusLossIfViewIsNotFocused) {}

TEST_F(AutofillPopupControllerImplTest,
       PopupDoesntHideOnWebContentsFocusLossIfViewIsFocused) {}

TEST_F(AutofillPopupControllerImplTest,
       PopupDoesntHideOnEndEditingFromRendererIfViewIsFocused) {}

TEST_F(AutofillPopupControllerImplTest, EmitsVisibleDurationMetricsOnHide) {}

TEST_F(AutofillPopupControllerImplTest,
       DoesntEmitsVisibleDurationMetricsOnHideForSubPopups) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveAutocompleteSuggestion_IgnoresClickOutsideCheck) {}

// Tests that if the popup is shown in the *main frame*, changing the zoom hides
// the popup.
TEST_F(AutofillPopupControllerImplTest, HideInMainFrameOnZoomChange) {}

TEST_F(AutofillPopupControllerImplTest,
       SuggestionFiltration_NoFilteringByDefault) {}

TEST_F(AutofillPopupControllerImplTest,
       SuggestionFiltration_SuggestionChangeNotifications) {}

TEST_F(AutofillPopupControllerImplTest, SuggestionFiltration_MatchingMainText) {}

TEST_F(AutofillPopupControllerImplTest,
       SuggestionFiltration_SuggestionIsDeletedFromFilteredList) {}

TEST_F(AutofillPopupControllerImplTest,
       SuggestionFiltration_StaticSuggestionsAreNotFilteredOut) {}

TEST_F(AutofillPopupControllerImplTest,
       SuggestionFiltration_HasFilteredOutSuggestions) {}

TEST_F(
    AutofillPopupControllerImplTest,
    SuggestionFiltration_PresentOnlyWithoutFilterSuggestionsAlwaysFilteredOut) {}

TEST_F(AutofillPopupControllerImplTest, RemoveSuggestion) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveAutocompleteSuggestion_AnnounceText) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveAutocompleteSuggestion_NoMetricsEmittedOnFail) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveAutocompleteSuggestion_MetricsEmittedOnSuccess) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveAddressSuggestion_NoMetricsEmittedOnFail) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveAddressSuggestion_MetricsEmittedOnSuccess) {}

TEST_F(AutofillPopupControllerImplTest,
       RemoveCreditCardSuggestion_NoMetricsEmitted) {}

TEST_F(AutofillPopupControllerImplTest, UnselectingClearsPreview) {}

#if !BUILDFLAG(IS_CHROMEOS_ASH)
namespace {

class MockAutofillDriver : public ContentAutofillDriver {};

class AutofillPopupControllerForPopupAxTest
    : public AutofillSuggestionControllerForTest {};

class MockAxTreeManager : public ui::AXTreeManager {};

class MockAxPlatformNodeDelegate : public ui::AXPlatformNodeDelegate {};

class MockAxPlatformNode : public ui::AXPlatformNodeBase {};

}  // namespace

AutofillPopupControllerImplTestAccessibilityBase;
class AutofillPopupControllerImplTestAccessibility
    : public AutofillPopupControllerImplTestAccessibilityBase {};

// Test for successfully firing controls changed event for popup show/hide.
TEST_F(AutofillPopupControllerImplTestAccessibility,
       FireControlsChangedEventDuringShowAndHide) {}

// Test for attempting to fire controls changed event when ax tree manager
// fails to retrieve the ax platform node associated with the popup.
// No event is fired and global active popup ax unique id is not set.
TEST_F(AutofillPopupControllerImplTestAccessibility,
       FireControlsChangedEventNoAxPlatformNode) {}

// Test for attempting to fire controls changed event when failing to retrieve
// the autofill popup's ax unique id. No event is fired and the global active
// popup ax unique id is not set.
TEST_F(AutofillPopupControllerImplTestAccessibility,
       FireControlsChangedEventNoPopupAxUniqueId) {}
#endif

}  // namespace autofill