chromium/content/browser/browsing_data/clear_site_data_handler_unittest.cc

// Copyright 2018 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/browsing_data/clear_site_data_handler.h"

#include <memory>
#include <optional>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "content/public/browser/storage_partition_config.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "net/base/load_flags.h"
#include "net/cookies/cookie_partition_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features_generated.h"

_;

namespace content {

ConsoleMessagesDelegate;
Message;

namespace {

const char kClearCookiesHeader[] =;

const StoragePartitionConfig kTestStoragePartitionConfig;

// A slightly modified ClearSiteDataHandler for testing with dummy clearing
// functionality.
class TestHandler : public ClearSiteDataHandler {};

// A ConsoleDelegate that copies message to a vector |message_buffer| owned by
// the caller instead of outputs to the console.
// We need this override because otherwise messages are outputted as soon as
// request finished, and we don't have a chance to check them.
class VectorConsoleMessagesDelegate : public ConsoleMessagesDelegate {};

// A ConsoleDelegate that outputs messages to a string |output_buffer| owned
// by the caller instead of to the console (losing the level information).
class StringConsoleMessagesDelegate : public ConsoleMessagesDelegate {};

}  // namespace

class ClearSiteDataHandlerTest : public testing::Test,
                                 public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(ClearSiteDataHandlerTest, ParseHeaderAndExecuteClearingTask) {}

TEST_F(ClearSiteDataHandlerTest, InvalidHeader) {}

TEST_F(ClearSiteDataHandlerTest, ClearCookieSuccess) {}

TEST_F(ClearSiteDataHandlerTest, LoadDoNotSaveCookies) {}

TEST_F(ClearSiteDataHandlerTest, InvalidOrigin) {}

// Verifies that console outputs from various actions on different URLs
// are correctly pretty-printed to the console.
TEST_F(ClearSiteDataHandlerTest, FormattedConsoleOutput) {}

TEST_F(ClearSiteDataHandlerTest, CookiePartitionKey) {}

TEST_F(ClearSiteDataHandlerTest, StorageKey) {}

TEST_F(ClearSiteDataHandlerTest, ThirdPartyCookieBlockingEnabled) {}

TEST_F(ClearSiteDataHandlerTest, CorrectStoragePartition) {}

}  // namespace content