#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/common/file_util.h"
#include <stddef.h>
#include <optional>
#include <string_view>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/values_test_util.h"
#include "base/types/optional_ref.h"
#include "base/values.h"
#include "build/build_config.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/strings/grit/extensions_strings.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
ManifestLocation;
namespace extensions {
namespace {
constexpr char kManifestContent[] = …;
constexpr char kExtensionId[] = …;
const char kCustomManifest[] = …;
const base::FilePath::CharType kCustomManifestFilename[] = …);
scoped_refptr<Extension> LoadExtensionManifest(
const base::Value::Dict& manifest,
const base::FilePath& manifest_dir,
ManifestLocation location,
int extra_flags,
std::string* error) { … }
scoped_refptr<Extension> LoadExtensionManifest(
const std::string& manifest_value,
const base::FilePath& manifest_dir,
ManifestLocation location,
int extra_flags,
std::string* error) { … }
void RunUnderscoreDirectoriesTest(
const std::vector<std::string>& underscore_directories) { … }
struct UninstallTestData { … };
const std::vector<UninstallTestData>& GetTestData() { … }
}
FileUtilTest;
TEST_F(FileUtilTest, UninstallRemovesAllPackedExtensionVersions) { … }
TEST_F(FileUtilTest, LoadExtensionWithMetadataFolder) { … }
TEST_F(FileUtilTest, LoadExtensionWithUnderscoreFolder) { … }
TEST_F(FileUtilTest, LoadExtensionWithUnderscoreAndMetadataFolder) { … }
TEST_F(FileUtilTest, LoadExtensionWithValidLocales) { … }
TEST_F(FileUtilTest, LoadExtensionWithGzippedLocalesAllowed) { … }
TEST_F(FileUtilTest, LoadExtensionWithGzippedLocalesNotAllowed) { … }
TEST_F(FileUtilTest, LoadExtensionWithoutLocalesFolder) { … }
TEST_F(FileUtilTest, CheckIllegalFilenamesNoUnderscores) { … }
TEST_F(FileUtilTest, CheckIllegalFilenamesOnlyReserved) { … }
TEST_F(FileUtilTest, CheckIllegalFilenamesReservedAndIllegal) { … }
#if !BUILDFLAG(IS_WIN)
TEST_F(FileUtilTest, CheckIllegalFilenamesDirectoryWindowsReserved) { … }
TEST_F(FileUtilTest,
CheckIllegalFilenamesWindowsReservedFilenameWithExtension) { … }
#endif
TEST_F(FileUtilTest, LoadExtensionGivesHelpfullErrorOnMissingManifest) { … }
TEST_F(FileUtilTest, LoadExtensionGivesHelpfullErrorOnBadManifest) { … }
TEST_F(FileUtilTest, ValidateThemeUTF8) { … }
TEST_F(FileUtilTest, BackgroundScriptsMustExist) { … }
constexpr std::string_view private_key = …;
TEST_F(FileUtilTest, FindPrivateKeyFiles) { … }
TEST_F(FileUtilTest, WarnOnPrivateKey) { … }
TEST_F(FileUtilTest, SpecifyManifestFile) { … }
TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFile) { … }
TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFileUnpacked) { … }
TEST_F(FileUtilTest, CheckInvisibleIconFileUnpacked) { … }
TEST_F(FileUtilTest, CheckInvisibleIconFilePacked) { … }
TEST_F(FileUtilTest, ExtensionURLToRelativeFilePath) { … }
class UninstallTest : public testing::Test { … };
bool UninstallTest::SetupExtensionsDirForUninstall() { … }
bool UninstallTest::ExtensionDirectoryDeleted() { … }
bool UninstallTest::ExtensionDirectoryNotDeleted() { … }
class UninstallTestParameterized
: public UninstallTest,
public testing::WithParamInterface<UninstallTestData> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(UninstallTestParameterized, UninstallDirectory) { … }
TEST_F(UninstallTest,
UninstallDirectory_ExtensionsInstallDirNotSubdirOfProfileDir) { … }
TEST_F(
UninstallTest,
UninstallDirectory_ExtensionsDirToDeleteNotSubdirOfExtensionsInstallDir) { … }
}