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

// Copyright 2023 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_menu_main_page_view.h"

#include "base/feature_list.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/ui/views/extensions/extensions_menu_coordinator.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 "content/public/browser/web_contents.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/views/controls/button/toggle_button.h"

namespace {

PermissionsManager;
SitePermissionsHelper;

}  // namespace

class ExtensionsSitePermissionsPageViewUnitTest
    : public ExtensionsToolbarUnitTest {};

ExtensionsSitePermissionsPageViewUnitTest::
    ExtensionsSitePermissionsPageViewUnitTest() {}

void ExtensionsSitePermissionsPageViewUnitTest::ShowSitePermissionsPage(
    extensions::ExtensionId extension_id) {}

bool ExtensionsSitePermissionsPageViewUnitTest::IsMainPageOpened() {}

bool ExtensionsSitePermissionsPageViewUnitTest::IsSitePermissionsPageOpened(
    extensions::ExtensionId extension_id) {}

std::vector<extensions::ExtensionId>
ExtensionsSitePermissionsPageViewUnitTest::GetExtensionsShowingRequests() {}

void ExtensionsSitePermissionsPageViewUnitTest::NavigateAndCommit(
    const std::string& string_url) {}

void ExtensionsSitePermissionsPageViewUnitTest::LayoutMenuIfNecessary() {}

ExtensionsMenuMainPageView*
ExtensionsSitePermissionsPageViewUnitTest::main_page() {}

ExtensionsMenuSitePermissionsPageView*
ExtensionsSitePermissionsPageViewUnitTest::site_permissions_page() {}

void ExtensionsSitePermissionsPageViewUnitTest::SetUp() {}

TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       AddAndRemoveExtensionWhenSitePermissionsPageIsOpen) {}

// Tests that menu navigates back to the main page when an extension, whose site
// permissions page is open, is disabled.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest, DisableAndEnableExtension) {}

// Tests that menu navigates back to the main page when an extension, whose site
// permissions page is open, is reloaded.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest, ReloadExtension) {}

// Tests that toggling the show requests button changes whether an extension can
// show site access requests in the toolbar, and the UI is properly updated.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest, ShowRequestsTogglePressed) {}

// Tests that the UI is properly updated when an extension pref for showing site
// access requests in the toolbar changes while the menu is open.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       ShowRequestsPrefChangedWithMenuOpen) {}

// Tests that selecting a site acces option in the menu updates the extension
// site access.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest, SiteAccessUpdated) {}

// Tests that the menu UI is properly updated when the extension's site access
// is changed to "on click" while the menu is open.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       SiteAccessUpdatedWithMenuOpen_OnClick) {}

// Tests that the menu UI is properly updated when the extension's site access
// is changed to "on site" while the menu is open.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       SiteAccessUpdatedWithMenuOpen_OnSite) {}

// Tests that the menu UI is properly updated when the extension's site access
// is changed to "on all sites" while the menu is open.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       SiteAccessUpdatedWithMenuOpen_OnAllSites) {}

// Test that navigating to a new site where the user doesn't have runtime host
// permissions controls (e.g restricted site) closes the site permissions page.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       PageNavigationWithMenuOpen_UserLosesRuntimeHostPermissionsControls) {}

// Test that navigating to a new site where the user still has runtime host
// permissions controls updates the page contents.
TEST_F(ExtensionsSitePermissionsPageViewUnitTest,
       PageNavigationWithMenuOpen_UserMaintainsRuntimeHostPermissionsControls) {}