chromium/content/browser/fenced_frame/fenced_frame_url_mapping_unittest.cc

// Copyright 2021 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/fenced_frame/fenced_frame_url_mapping.h"

#include <optional>

#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "content/browser/fenced_frame/fenced_frame_reporter.h"
#include "content/public/test/test_renderer_host.h"
#include "content/test/fenced_frame_test_utils.h"
#include "net/base/schemeful_site.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/fenced_frame/fenced_frame_utils.h"
#include "third_party/blink/public/common/interest_group/ad_auction_constants.h"
#include "third_party/blink/public/common/interest_group/ad_display_size.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"

namespace content {

namespace {

// Validates the mapping contained in `pending_ad_components`.
//
// If `add_to_new_map` is false, `pending_ad_components` will be added to
// `fenced_frame_url_mapping` to mimic ShadowDOM behavior. Otherwise, they'll
// be added to a new FencedFrameURLMapping to mimic MPArch behavior, and
// `fenced_frame_url_mapping` is ignored.
//
// `expected_mapped_ad_descriptors` contains the URLs the first URNs are
// expected to map to, and will be padded with "about:blank" URLs until it's
// blink::MaxAdAuctionAdComponents() in length.
// TODO(crbug.com/40202462): the ShadowDOM implementation is deprecated, and
// these tests should be cleaned up to only reflect MPArch behavior.
void ValidatePendingAdComponentsMap(
    FencedFrameURLMapping* fenced_frame_url_mapping,
    bool add_to_new_map,
    const std::vector<std::pair<GURL, FencedFrameConfig>>&
        nested_urn_config_pairs,
    std::vector<blink::AdDescriptor> expected_mapped_ad_descriptors) {}

GURL GenerateAndVerifyPendingMappedURN(
    FencedFrameURLMapping* fenced_frame_url_mapping) {}

class FencedFrameURLMappingTest : public RenderViewHostTestHarness {};

}  // namespace

TEST_F(FencedFrameURLMappingTest, AddAndConvert) {}

TEST_F(FencedFrameURLMappingTest, NonExistentUUID) {}

TEST_F(FencedFrameURLMappingTest, PendingMappedUUID) {}

TEST_F(FencedFrameURLMappingTest, RemoveObserverOnPendingMappedUUID) {}

TEST_F(FencedFrameURLMappingTest, RegisterTwoObservers) {}

// Test the case `ad_component_descriptors` is empty. In this case, it should
// be filled with URNs that are mapped to about:blank.
TEST_F(FencedFrameURLMappingTest,
       AssignFencedFrameURLAndInterestGroupInfoNoAdComponentsUrls) {}

// Test the case `ad_component_descriptors` has a single URL.
TEST_F(FencedFrameURLMappingTest,
       AssignFencedFrameURLAndInterestGroupInfoOneAdComponentUrl) {}

// Test the case `ad_component_descriptors` has the maximum number of allowed
// ad component URLs.
TEST_F(FencedFrameURLMappingTest,
       AssignFencedFrameURLAndInterestGroupInfoMaxAdComponentUrl) {}

// Test the case `ad_component_descriptors` has the maximum number of allowed
// ad component URLs, and they're all identical. The main purpose of this test
// is to make sure they receive unique URNs, despite being identical URLs.
TEST_F(FencedFrameURLMappingTest,
       AssignFencedFrameURLAndInterestGroupInfoMaxIdenticalAdComponentUrl) {}

// Test the case `ad_component_descriptors` has a single URL.
TEST_F(FencedFrameURLMappingTest, SubstituteFencedFrameURLs) {}

// Test the correctness of the URN format. The URN is expected to be in the
// format "urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" as per RFC-4122.
TEST_F(FencedFrameURLMappingTest, HasCorrectFormat) {}

// Test that reporting metadata gets saved successfully.
TEST_F(FencedFrameURLMappingTest, ReportingMetadataSuccess) {}

// Test that reporting metadata gets saved successfully.
TEST_F(FencedFrameURLMappingTest, ReporterSuccessWithInterestGroupInfo) {}

// Test that number of urn mappings limit is enforced for pending mapped urn
// generation.
TEST_F(FencedFrameURLMappingTest, ExceedNumOfUrnMappingsLimitFailsAddURL) {}

}  // namespace content