chromium/extensions/browser/sandboxed_unpacker_unittest.cc

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

#include "extensions/browser/sandboxed_unpacker.h"
#include "build/build_config.h"

#include <memory>
#include <tuple>

#include "base/base64.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "components/crx_file/id_util.h"
#include "components/services/unzip/content/unzip_service.h"
#include "components/services/unzip/in_process_unzipper.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/browser/install/crx_install_error.h"
#include "extensions/browser/install/sandboxed_unpacker_failure_reason.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/file_util.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/switches.h"
#include "extensions/common/verifier_formats.h"
#include "extensions/strings/grit/extensions_strings.h"
#include "extensions/test/test_extensions_client.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/zlib/google/zip.h"
#include "ui/base/l10n/l10n_util.h"

namespace extensions {

namespace {

// Inserts an illegal path into the browser images returned by
// TestExtensionsClient for any extension.
class IllegalImagePathInserter
    : public TestExtensionsClient::BrowserImagePathsFilter {};

}  // namespace

class MockSandboxedUnpackerClient : public SandboxedUnpackerClient {};

class SandboxedUnpackerTest : public ExtensionsTest {};

TEST_F(SandboxedUnpackerTest, EmptyDefaultLocale) {}

TEST_F(SandboxedUnpackerTest, HasDefaultLocaleMissingLocalesFolder) {}

TEST_F(SandboxedUnpackerTest, InvalidDefaultLocale) {}

TEST_F(SandboxedUnpackerTest, MissingDefaultData) {}

TEST_F(SandboxedUnpackerTest, MissingDefaultLocaleHasLocalesFolder) {}

TEST_F(SandboxedUnpackerTest, MissingMessagesFile) {}

TEST_F(SandboxedUnpackerTest, NoLocaleData) {}

TEST_F(SandboxedUnpackerTest, ImageDecodingError) {}

TEST_F(SandboxedUnpackerTest, BadPathError) {}

TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) {}

TEST_F(SandboxedUnpackerTest, FromDirNoCatalogsSuccess) {}

TEST_F(SandboxedUnpackerTest, WithCatalogsSuccess) {}

TEST_F(SandboxedUnpackerTest, FromDirWithCatalogsSuccess) {}

TEST_F(SandboxedUnpackerTest, FailHashCheck) {}

TEST_F(SandboxedUnpackerTest, TestRewriteManifestInjections) {}

TEST_F(SandboxedUnpackerTest, InvalidMessagesFile) {}

TEST_F(SandboxedUnpackerTest, PassHashCheck) {}

TEST_F(SandboxedUnpackerTest, SkipHashCheck) {}

// The following tests simulate the utility services failling.
TEST_F(SandboxedUnpackerTest, UnzipperServiceFails) {}

TEST_F(SandboxedUnpackerTest, JsonParserFails) {}

TEST_F(SandboxedUnpackerTest, ImageDecoderFails) {}

TEST_F(SandboxedUnpackerTest, NoComputeHashes) {}

TEST_F(SandboxedUnpackerTest, ComputeHashes) {}

// SandboxedUnpacker is ref counted and is reference by callbacks and
// InterfacePtrs. This tests that it gets deleted as expected (so that no extra
// refs are left).
TEST_F(SandboxedUnpackerTest, DeletedOnSuccess) {}

TEST_F(SandboxedUnpackerTest, DeletedOnFailure) {}

}  // namespace extensions