chromium/chrome/browser/ui/views/webid/account_selection_bubble_view_unittest.cc

// Copyright 2022 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/webid/account_selection_bubble_view.h"

#include <string>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/webid/account_selection_view_base.h"
#include "chrome/browser/ui/views/webid/account_selection_view_test_base.h"
#include "chrome/browser/ui/views/webid/fake_delegate.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/views/chrome_views_test_base.h"
#include "content/public/browser/identity_request_dialog_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/color_parser.h"
#include "content/public/common/content_features.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/view.h"
#include "ui/views/view_utils.h"

LoginState;

class AccountSelectionBubbleViewTest : public ChromeViewsTestBase,
                                       public AccountSelectionViewTestBase {};

TEST_F(AccountSelectionBubbleViewTest, SingleAccount) {}

TEST_F(AccountSelectionBubbleViewTest, SingleAccountNoTermsOfService) {}

TEST_F(AccountSelectionBubbleViewTest, MultipleAccounts) {}

TEST_F(AccountSelectionBubbleViewTest, UseDifferentAccount) {}

TEST_F(AccountSelectionBubbleViewTest, ReturningAccount) {}

TEST_F(AccountSelectionBubbleViewTest, NewAccountWithoutRequestPermission) {}

TEST_F(AccountSelectionBubbleViewTest,
       ContinueButtonWithProperBackgroundColor) {}

TEST_F(AccountSelectionBubbleViewTest,
       ContinueButtonWithImproperBackgroundColor) {}

TEST_F(AccountSelectionBubbleViewTest, Verifying) {}

TEST_F(AccountSelectionBubbleViewTest, VerifyingForAutoReauthn) {}

TEST_F(AccountSelectionBubbleViewTest, Failure) {}

class MultipleIdpAccountSelectionBubbleViewTest
    : public AccountSelectionBubbleViewTest {};

// Tests that the single account case is the same with
// features::kFedCmMultipleIdentityProviders enabled. See
// AccountSelectionBubbleViewTest's SingleAccount test.
TEST_F(MultipleIdpAccountSelectionBubbleViewTest, SingleAccount) {}

// Tests that when there is multiple accounts but only one IDP, the UI is
// exactly the same with features::kFedCmMultipleIdentityProviders enabled (see
// AccountSelectionBubbleViewTest's MultipleAccounts test).
TEST_F(MultipleIdpAccountSelectionBubbleViewTest, MultipleAccountsSingleIdp) {}

// Tests that the logo is visible with features::kFedCmMultipleIdentityProviders
// enabled and multiple IDPs.
TEST_F(MultipleIdpAccountSelectionBubbleViewTest,
       MultipleAccountsMultipleIdps) {}

TEST_F(MultipleIdpAccountSelectionBubbleViewTest, OneIdpWithMismatch) {}

TEST_F(MultipleIdpAccountSelectionBubbleViewTest, MultiIdpUseOtherAccount) {}

TEST_F(MultipleIdpAccountSelectionBubbleViewTest,
       ShowSingleReturningAccountDialog) {}

TEST_F(MultipleIdpAccountSelectionBubbleViewTest, MultiIdpWithAllIdpsMismatch) {}

TEST_F(MultipleIdpAccountSelectionBubbleViewTest, MultipleReturningAccounts) {}

TEST_F(MultipleIdpAccountSelectionBubbleViewTest,
       MultipleReturningAccountsWithTimestamps) {}

// Tests that in the multi IDP account button, hovering over the button modifies
// the background circle containing the IDP icon.
TEST_F(MultipleIdpAccountSelectionBubbleViewTest, HoverChangesIdpCircle) {}

TEST_F(AccountSelectionBubbleViewTest, GenericError) {}

TEST_F(AccountSelectionBubbleViewTest, GenericErrorWithErrorUrl) {}

TEST_F(AccountSelectionBubbleViewTest, ErrorWithDifferentErrorCodes) {}

// Tests that CanFitInWebContents returns true when the web contents is large
// enough to fit the bubble and bubble bounds computed are contained within the
// web contents' bounds.
TEST_F(AccountSelectionBubbleViewTest, WebContentsLargeEnoughToFitDialog) {}

// Tests that CanFitInWebContents returns false when the web contents is too
// small to fit the bubble. We do not test GetBubbleBounds here because the
// bubble would be hidden so GetBubbleBounds is not relevant.
TEST_F(AccountSelectionBubbleViewTest, WebContentsTooSmallToFitDialog) {}

// Tests crash scenario from crbug.com/341240034.
TEST_F(AccountSelectionBubbleViewTest, BoundsChangedAfterWebContentsDestroyed) {}

// Tests that the brand icon view is hidden if the brand icon URL is invalid.
TEST_F(AccountSelectionBubbleViewTest, InvalidBrandIconUrlHidesBrandIcon) {}