#include "chrome/browser/ui/views/extensions/extensions_menu_main_page_view.h"
#include "base/containers/to_vector.h"
#include "base/feature_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/user_action_tester.h"
#include "chrome/app/vector_icons/vector_icons.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/permissions/active_tab_permission_granter.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_button.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_coordinator.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_item_view.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_site_permissions_page_view.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_view_controller.h"
#include "chrome/browser/ui/views/extensions/extensions_request_access_button.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_button.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_unittest.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension_features.h"
#include "extensions/test/permissions_manager_waiter.h"
#include "extensions/test/test_extension_dir.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/vector_icons.h"
#include "ui/views/view_utils.h"
namespace {
PermissionsManager;
SitePermissionsHelper;
std::vector<std::string> GetNamesFromMenuItems(
std::vector<ExtensionMenuItemView*> menu_items) { … }
}
class ExtensionsMenuMainPageViewUnitTest : public ExtensionsToolbarUnitTest { … };
ExtensionsMenuMainPageViewUnitTest::ExtensionsMenuMainPageViewUnitTest() { … }
void ExtensionsMenuMainPageViewUnitTest::ShowMenu() { … }
ExtensionMenuItemView* ExtensionsMenuMainPageViewUnitTest::GetOnlyMenuItem() { … }
std::vector<extensions::ExtensionId>
ExtensionsMenuMainPageViewUnitTest::GetExtensionsInRequestAccessSection() { … }
std::vector<extensions::ExtensionId>
ExtensionsMenuMainPageViewUnitTest::GetExtensionsInRequestAccessButton() { … }
void ExtensionsMenuMainPageViewUnitTest::LayoutMenuIfNecessary() { … }
void ExtensionsMenuMainPageViewUnitTest::ClickSitePermissionsButton(
ExtensionMenuItemView* menu_item) { … }
void ExtensionsMenuMainPageViewUnitTest::ClickSiteAccessToggle(
ExtensionMenuItemView* menu_item,
bool active_tab_only) { … }
ExtensionsMenuMainPageView* ExtensionsMenuMainPageViewUnitTest::main_page() { … }
ExtensionsMenuSitePermissionsPageView*
ExtensionsMenuMainPageViewUnitTest::site_permissions_page() { … }
std::vector<ExtensionMenuItemView*>
ExtensionsMenuMainPageViewUnitTest::menu_items() { … }
void ExtensionsMenuMainPageViewUnitTest::SetUp() { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, ExtensionsAreSorted) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, NoSiteAccessRequested) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
NoSiteAccessRequested_EnterpriseExtension) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
HostPermissionsRequested_ToggleSiteAccess_OnSite) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
HostPermissionsRequested_ToggleSiteAccess_OnAllSites) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
HostPermissionsRequested_DynamicUpdates) { … }
TEST_F(
ExtensionsMenuMainPageViewUnitTest,
HostPermissionsRequested_DynamicUpdates_TogglePersistsPreviousSiteAccess) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
HostPermissionsRequested_EnterpriseExtension) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
DISABLED_ActiveTabRequested_ToggleSiteAccess) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
ActiveTabRequested_ToggleSiteAccess_UngrantTabPermissions) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, ActiveTabRequested_DynamicUpdates) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
SitePermissionsButton_OpenSitePermissionsPage) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
AddAndRemoveExtensionWhenMainPageIsOpen) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, NavigationWhenMainPageIsOpen) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, PinnedExtensions) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, DisableAndEnableExtension) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, ReloadExtension) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, ReloadExtensionFailed) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, RestrictedSite) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, PolicyBlockedSite) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, MessageSection_RestrictedAccess) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, MessageSection_PolicyBlockedAccess) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest, MessageSection_UserBlockedAccess) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserBlockedAccess_Enterprise) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_Extensions) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_RequestsWithPattern) { … }
TEST_F(
ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_RequestsWithPattern_NavigationBetweenPages) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_ExtensionGrantedSiteAccess) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_AllowExtension) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_DismissExtension) { … }
TEST_F(ExtensionsMenuMainPageViewUnitTest,
MessageSection_UserCustomizedAccess_RequestNotAllowedOnToolbar) { … }