#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/common/manifest_test.h"
#include <optional>
#include <string_view>
#include <utility>
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/json_file_value_serializer.h"
#include "base/path_service.h"
#include "base/strings/pattern.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/values.h"
#include "extensions/common/extension_l10n_util.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/l10n/l10n_util.h"
ManifestLocation;
namespace extensions {
namespace {
std::string GetNameFromManifest(const base::Value::Dict& manifest) { … }
std::optional<base::Value::Dict> LoadManifestFile(
const base::FilePath& manifest_path,
std::string* error) { … }
}
ManifestTest::ManifestTest()
: … { … }
ManifestTest::~ManifestTest() = default;
ManifestTest::ManifestData::ManifestData(std::string_view name) : … { … }
ManifestTest::ManifestData::ManifestData(base::Value::Dict manifest,
std::string_view name)
: … { … }
ManifestTest::ManifestData::ManifestData(base::Value::Dict manifest)
: … { … }
ManifestTest::ManifestData::ManifestData(ManifestData&& other) = default;
ManifestTest::ManifestData::~ManifestData() = default;
const std::optional<base::Value::Dict>& ManifestTest::ManifestData::GetManifest(
const base::FilePath& test_data_dir,
std::string* error) const { … }
ManifestTest::ManifestData ManifestTest::ManifestData::FromJSON(
std::string_view json) { … }
std::string ManifestTest::GetTestExtensionID() const { … }
base::FilePath ManifestTest::GetTestDataDir() { … }
std::optional<base::Value::Dict> ManifestTest::LoadManifest(
char const* manifest_name,
std::string* error) { … }
scoped_refptr<Extension> ManifestTest::LoadExtension(
const ManifestData& manifest,
std::string* error,
ManifestLocation location,
int flags) { … }
scoped_refptr<Extension> ManifestTest::LoadAndExpectSuccess(
const ManifestData& manifest,
ManifestLocation location,
int flags) { … }
scoped_refptr<Extension> ManifestTest::LoadAndExpectSuccess(
char const* manifest_name,
ManifestLocation location,
int flags) { … }
scoped_refptr<Extension> ManifestTest::LoadAndExpectWarning(
const ManifestData& manifest,
const std::string& expected_warning,
ManifestLocation location,
int flags) { … }
scoped_refptr<Extension> ManifestTest::LoadAndExpectWarning(
char const* manifest_name,
const std::string& expected_warning,
ManifestLocation location,
int flags) { … }
scoped_refptr<Extension> ManifestTest::LoadAndExpectWarnings(
const ManifestData& manifest,
const std::vector<std::string>& expected_warnings,
ManifestLocation location,
int flags) { … }
scoped_refptr<Extension> ManifestTest::LoadAndExpectWarnings(
char const* manifest_name,
const std::vector<std::string>& expected_warnings,
ManifestLocation location,
int flags) { … }
void ManifestTest::VerifyExpectedError(
Extension* extension,
const std::string& name,
const std::string& error,
const std::string& expected_error) { … }
void ManifestTest::LoadAndExpectError(const ManifestData& manifest,
const std::string& expected_error,
ManifestLocation location,
int flags) { … }
void ManifestTest::LoadAndExpectError(const ManifestData& manifest,
const std::u16string& expected_error,
ManifestLocation location,
int flags) { … }
void ManifestTest::LoadAndExpectError(char const* manifest_name,
const std::string& expected_error,
ManifestLocation location,
int flags) { … }
void ManifestTest::LoadAndExpectError(char const* manifest_name,
const std::u16string& expected_error,
ManifestLocation location,
int flags) { … }
void ManifestTest::AddPattern(extensions::URLPatternSet* extent,
const std::string& pattern) { … }
ManifestTest::Testcase::Testcase(const std::string& manifest_filename,
const std::string& expected_error,
ManifestLocation location,
int flags)
: … { … }
ManifestTest::Testcase::Testcase(const std::string& manifest_filename,
const std::u16string& expected_error,
ManifestLocation location,
int flags)
: … { … }
ManifestTest::Testcase::Testcase(const std::string& manifest_filename,
const std::string& expected_error)
: … { … }
ManifestTest::Testcase::Testcase(const std::string& manifest_filename,
const std::u16string& expected_error)
: … { … }
ManifestTest::Testcase::Testcase(const std::string& manifest_filename)
: … { … }
ManifestTest::Testcase::Testcase(const std::string& manifest_filename,
ManifestLocation location,
int flags)
: … { … }
void ManifestTest::RunTestcases(const Testcase* testcases,
size_t num_testcases,
ExpectType type) { … }
void ManifestTest::RunTestcase(const Testcase& testcase, ExpectType type) { … }
}