chromium/content/browser/shared_storage/shared_storage_header_observer_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 "content/browser/shared_storage/shared_storage_header_observer.h"

#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>

#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "content/browser/navigation_or_document_handle.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/common/content_client.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/shared_storage_test_utils.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_shared_storage_header_observer.h"
#include "content/test/test_web_contents.h"
#include "services/network/public/mojom/optional_bool.mojom.h"
#include "services/network/public/mojom/url_loader_network_service_observer.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-param-test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace content {

namespace {

const char kMainOrigin[] =;
const char kMainOrigin1[] =;
const char kMainOrigin2[] =;
const char kChildOrigin1[] =;
const char kChildOrigin2[] =;
const char kTestOrigin1[] =;
const char kTestOrigin2[] =;
const char kTestOrigin3[] =;

OperationPtr;
OperationType;
OperationResult;
GetResult;
ContextType;

enum class TestCaseType {};

[[nodiscard]] blink::ParsedPermissionsPolicy MakeSharedStoragePermissionsPolicy(
    const url::Origin& request_origin,
    bool shared_storage_enabled_for_request,
    bool shared_storage_enabled_for_all) {}

[[nodiscard]] OperationPtr MakeSharedStorageOperationPtr(
    OperationType operation_type,
    std::optional<std::string> key,
    std::optional<std::string> value,
    std::optional<bool> ignore_if_present) {}

[[nodiscard]] std::vector<OperationPtr> MakeOperationVector(
    std::vector<std::tuple<OperationType,
                           std::optional<std::string>,
                           std::optional<std::string>,
                           std::optional<bool>>> operation_tuples) {}

[[nodiscard]] SharedStorageWriteOperationAndResult SetOperation(
    const url::Origin& request_origin,
    std::string key,
    std::string value,
    std::optional<bool> ignore_if_present,
    OperationResult result) {}

[[nodiscard]] SharedStorageWriteOperationAndResult AppendOperation(
    const url::Origin& request_origin,
    std::string key,
    std::string value,
    OperationResult result) {}

[[nodiscard]] SharedStorageWriteOperationAndResult DeleteOperation(
    const url::Origin& request_origin,
    std::string key,
    OperationResult result) {}

[[nodiscard]] SharedStorageWriteOperationAndResult ClearOperation(
    const url::Origin& request_origin,
    OperationResult result) {}

class MockContentBrowserClient : public ContentBrowserClient {};

class SharedStorageHeaderObserverTest
    : public RenderViewHostTestHarness,
      public testing::WithParamInterface<TestCaseType> {};

auto describe_test_case_type =;

}  // namespace

INSTANTIATE_TEST_SUITE_P();

TEST_P(SharedStorageHeaderObserverTest, SharedStorageNotAllowed) {}

TEST_P(SharedStorageHeaderObserverTest, Basic_SingleOrigin_AllSuccessful) {}

TEST_P(SharedStorageHeaderObserverTest, Basic_MultiOrigin_AllSuccessful) {}

TEST_P(SharedStorageHeaderObserverTest, SkipMissingParams) {}

TEST_P(SharedStorageHeaderObserverTest, SkipInvalidParams) {}

TEST_P(SharedStorageHeaderObserverTest, IgnoreExtraParams) {}

}  // namespace content