chromium/third_party/blink/renderer/core/dom/flat_tree_traversal_test.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/dom/flat_tree_traversal.h"

#include <memory>
#include <string_view>

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {

namespace {

// Gathers all the nodes in `traversal_range` and returns them as a
// `HeapVector`.
HeapVector<Member<Node>> GatherFromTraversalRange(auto traversal_range) {
  HeapVector<Member<Node>> result;
  for (Node& node : traversal_range) {
    result.push_back(&node);
  }
  return result;
}

class FlatTreeTraversalTest : public PageTestBase {};

void FlatTreeTraversalTest::SetupSampleHTML(std::string_view main_html,
                                            std::string_view shadow_html,
                                            unsigned index) {}

void FlatTreeTraversalTest::SetupDocumentTree(std::string_view main_html) {}

void FlatTreeTraversalTest::AttachOpenShadowRoot(
    Element& shadow_host,
    std::string_view shadow_inner_html) {}

namespace {

void TestCommonAncestor(Node* expected_result,
                        const Node& node_a,
                        const Node& node_b) {}

}  // namespace

// Test case for
//  - childAt
//  - countChildren
//  - hasChildren
//  - index
//  - isDescendantOf
TEST_F(FlatTreeTraversalTest, childAt) {}

TEST_F(FlatTreeTraversalTest, DescendantsOf) {}

TEST_F(FlatTreeTraversalTest, StartsAtOrAfter) {}

TEST_F(FlatTreeTraversalTest, ChildrenOf) {}

// Test case for
//  - commonAncestor
//  - isDescendantOf
TEST_F(FlatTreeTraversalTest, commonAncestor) {}

// Test case for
//  - NextSkippingChildren
//  - PreviousAbsoluteSibling
TEST_F(FlatTreeTraversalTest, SkippingChildrenFunctions) {}

TEST_F(FlatTreeTraversalTest, AncestorsOf) {}

TEST_F(FlatTreeTraversalTest, InclusiveAncestorsOf) {}

// Test case for
//  - lastWithin
//  - lastWithinOrSelf
TEST_F(FlatTreeTraversalTest, lastWithin) {}

TEST_F(FlatTreeTraversalTest, previousPostOrder) {}

TEST_F(FlatTreeTraversalTest, nextSiblingNotInDocumentFlatTree) {}


TEST_F(FlatTreeTraversalTest, v1Simple) {}

TEST_F(FlatTreeTraversalTest, v1Redistribution) {}

TEST_F(FlatTreeTraversalTest, v1SlotInDocumentTree) {}

TEST_F(FlatTreeTraversalTest, v1FallbackContent) {}

TEST_F(FlatTreeTraversalTest, v1FallbackContentSkippedInTraversal) {}

TEST_F(FlatTreeTraversalTest, v1AllFallbackContent) {}

}  // namespace
}  // namespace blink