chromium/chrome/browser/ui/views/extensions/extensions_toolbar_container_unittest.cc

// Copyright 2021 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/extensions/extensions_toolbar_container.h"

#include "base/json/json_reader.h"
#include "base/ranges/algorithm.h"
#include "base/test/metrics/user_action_tester.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/extension_action_runner.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_button.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_unittest.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/test/permissions_manager_waiter.h"
#include "extensions/test/test_extension_dir.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"

namespace {

SitePermissionsHelper;
PermissionsManager;

// TODO(crbug.com/40916158): Same as permission's ChipController. Pull out to a
// shared location.
base::TimeDelta kConfirmationDisplayDuration =;

// A scoper that manages a Browser instance created by BrowserWithTestWindowTest
// beyond the default instance it creates in SetUp.
class AdditionalBrowser {};

}  // namespace

class ExtensionsToolbarContainerUnitTest : public ExtensionsToolbarUnitTest {};

ExtensionsToolbarContainerUnitTest::ExtensionsToolbarContainerUnitTest()
    :{}

void ExtensionsToolbarContainerUnitTest::NavigateAndCommit(const GURL& url) {}

ToolbarActionView* ExtensionsToolbarContainerUnitTest::GetPinnedExtensionView(
    const extensions::ExtensionId& extension_id) {}

bool ExtensionsToolbarContainerUnitTest::IsRequestAccessButtonVisible() {}

void ExtensionsToolbarContainerUnitTest::SetUp() {}

TEST_F(ExtensionsToolbarContainerUnitTest, ReorderPinnedExtensions) {}

TEST_F(ExtensionsToolbarContainerUnitTest, ForcePinnedExtensionsCannotReorder) {}

// Tests that when an extension is reloaded it remains visible in the toolbar.
TEST_F(ExtensionsToolbarContainerUnitTest, ReloadExtensionKeepsPinnedState) {}

// Tests that a when an extension is reloaded with manifest errors, and
// therefore fails to be loaded into Chrome, it's removed from the toolbar.
TEST_F(ExtensionsToolbarContainerUnitTest, ReloadExtensionFailed) {}

TEST_F(ExtensionsToolbarContainerUnitTest,
       PinnedExtensionAppearsInAnotherWindow) {}

TEST_F(ExtensionsToolbarContainerUnitTest,
       PinnedExtensionsReorderOnPrefChange) {}

TEST_F(ExtensionsToolbarContainerUnitTest, RunDropCallback) {}

TEST_F(ExtensionsToolbarContainerUnitTest, ResetDropCallback) {}

TEST_F(ExtensionsToolbarContainerUnitTest,
       InvalidateDropCallbackOnActionAdded) {}

// ToolbarActionsModel::MovePinnedAction crashes if pinned extensions changes
// while the drop callback isn't invalidated. This test makes sure this doesn't
// happen anymore. https://crbug.com/1268239.
TEST_F(ExtensionsToolbarContainerUnitTest, InvalidateDropCallbackOnPrefChange) {}

// Test that the extension button state changes after site permissions updates.
TEST_F(ExtensionsToolbarContainerUnitTest,
       ExtensionsButton_SitePermissionsUpdates) {}

// Test that the extension button state takes into account chrome restricted
// sites.
TEST_F(ExtensionsToolbarContainerUnitTest,
       ExtensionsButton_ChromeRestrictedSite) {}

// Tests that extensions appear in the request access button iff they have a
// site access request.
TEST_F(ExtensionsToolbarContainerUnitTest, RequestAccessButton_Extensions) {}

// Tests that an extension appears in the request access button iff it has a
// site access request that matches the given pattern filter.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_RequestWithPattern) {}

// Tests that an extension's site access request is removed when the extension
// is granted site access.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_ExtensionGrantedSiteAccess) {}

// Tests that requests are reset on cross-origin navigations.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButtonVisibility_NavigationBetweenPages) {}

// Tests that the request access button is visible for matched patterns on
// same-origin navigations.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_NavigationBetweenPages_RequestWithPattern) {}

// Test that request access button is visible based on the user site setting
// selected.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_UserSiteSetting) {}

// Tests that an extension with a site access request but not allowed to show
// requests in the toolbar is not shown in the request access button.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_ExtensionsNotAllowedInButton) {}

// Test that an extension's request which is dismissed is not visible in the
// request access button.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_RequestDismissed) {}

TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_OnPressedExecuteAction) {}

// Tests that if an update comes in between the request access button is clicked
// and the confirmation is collapsed, the button is updated afterwards with the
// correct information.
TEST_F(ExtensionsToolbarContainerUnitTest,
       RequestAccessButton_UpdateInBetweenClickAndConfirmationCollapse) {}

class ExtensionsToolbarContainerWithPermittedSitesUnitTest
    : public ExtensionsToolbarContainerUnitTest {};

// Test that request access button is visible based on the user site setting
// selected.
TEST_F(ExtensionsToolbarContainerWithPermittedSitesUnitTest,
       RequestAccessButtonVisibilityOnPermittedSites) {}