chromium/chrome/browser/extensions/api/webstore_private/webstore_private_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <optional>
#include <vector>

#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/json/values_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "base/version_info/version_info.h"
#include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h"
#include "chrome/browser/extensions/extension_api_unittest.h"
#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/mv2_experiment_stage.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_test_util.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/supervised_user/core/common/features.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/web_contents_tester.h"
#include "extensions/browser/api/management/management_api.h"
#include "extensions/browser/api_test_utils.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/event_router_factory.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_features.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace extensions {
namespace {
constexpr char kInvalidId[] =;
constexpr char kExtensionId[] =;
constexpr char kFakeJustification[] =;
constexpr char kExtensionManifest[] =;

constexpr char kBlockAllExtensionSettings[] =;
constexpr char kBlockOneExtensionSettings[] =;

constexpr char kBlockedManifestTypeExtensionSettings[] =;

constexpr char kBlockedDownloadsPermissionsExtensionSettings[] =;

constexpr char kBlockedAudioPermissionsExtensionSettings[] =;

constexpr char kWebstoreUserCancelledError[] =;
constexpr char kWebstoreBlockByPolicy[] =;

// Helper test struct used for holding data related to extension requests.
struct ExtensionRequestData {};

// Verifies that the extension request pending list in |profile| matches the
// |expected_pending_requests|.
void VerifyPendingList(const std::map<ExtensionId, ExtensionRequestData>&
                           expected_pending_requests,
                       Profile* profile) {}

void SetExtensionSettings(const std::string& settings_string,
                          TestingProfile* profile) {}

std::unique_ptr<KeyedService> BuildManagementApi(
    content::BrowserContext* context) {}

std::unique_ptr<KeyedService> BuildEventRouter(
    content::BrowserContext* profile) {}

}  // namespace

WebstorePrivateApiUnittest;

TEST_F(WebstorePrivateApiUnittest, GetFullChromeVersion) {}

class WebstorePrivateExtensionInstallRequestBase : public ExtensionApiUnittest {};

class WebstorePrivateGetExtensionStatusTest
    : public WebstorePrivateExtensionInstallRequestBase {};

TEST_F(WebstorePrivateGetExtensionStatusTest, InvalidExtensionId) {}

TEST_F(WebstorePrivateGetExtensionStatusTest, ExtensionEnabled) {}

TEST_F(WebstorePrivateGetExtensionStatusTest, InvalidManifest) {}

TEST_F(WebstorePrivateGetExtensionStatusTest, ExtensionBlockedByManifestType) {}

TEST_F(WebstorePrivateGetExtensionStatusTest, ExtensionBlockedByPermission) {}

TEST_F(WebstorePrivateGetExtensionStatusTest,
       ExtensionNotBlockedByOptionalPermission) {}

TEST_F(WebstorePrivateGetExtensionStatusTest, ExtensionCorrupted) {}

class SupervisedUserWebstorePrivateGetExtensionStatusTest
    : public WebstorePrivateGetExtensionStatusTest {};

TEST_F(SupervisedUserWebstorePrivateGetExtensionStatusTest,
       ExtensionCustodianApprovalRequired) {}

TEST_F(SupervisedUserWebstorePrivateGetExtensionStatusTest,
       ExtensionCustodianApprovalRequiredForInstallation) {}

class WebstorePrivateBeginInstallWithManifest3Test
    : public ExtensionApiUnittest {};

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       RequestExtensionWithConfirmThenShowPendingDialog) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       RequestExtensionWithCancel) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       RequestExtensionWithJustification) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       RequestExtensionWithJustificationAndCancel) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       NormalInstallIfRequestExtensionIsDisabled) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test, BlockedByPolicy) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       BlockedByPolicyWithExtensionRequest) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       ExtensionBlockedByManifestType) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       ExtensionBlockedByPermission) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       ExtensionNotBlockedByOptionalPermission) {}

TEST_F(WebstorePrivateBeginInstallWithManifest3Test,
       ProfileDeletedBeforeCompleteInstall) {}

struct FrictionDialogTestCase {};

std::ostream& operator<<(std::ostream& out,
                         const FrictionDialogTestCase& test_case) {}

const FrictionDialogTestCase kFrictionDialogTestCases[] =;

class WebstorePrivateBeginInstallWithManifest3FrictionDialogTest
    : public WebstorePrivateBeginInstallWithManifest3Test,
      public testing::WithParamInterface<FrictionDialogTestCase> {};

TEST_P(WebstorePrivateBeginInstallWithManifest3FrictionDialogTest,
       FrictionDialogTests) {}

INSTANTIATE_TEST_SUITE_P();

// A test suite to be used with the MV2 deprecation experiments.
class WebstorePrivateManifestV2DeprecationUnitTest
    : public ExtensionApiUnittest,
      public testing::WithParamInterface<MV2ExperimentStage> {};

WebstorePrivateManifestV2DeprecationUnitTest::
    WebstorePrivateManifestV2DeprecationUnitTest() {}

INSTANTIATE_TEST_SUITE_P();

// Tests the behavior of the webstorePrivate.getMV2DeprecationStatus() function.
TEST_P(WebstorePrivateManifestV2DeprecationUnitTest,
       TestGetMV2DeprecationStatus) {}

}  // namespace extensions