/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCommon/jsinspector-modern/tracing/tests/ProfileTreeNodeTest.cpp
58 строк
2 KB
generatedunixname89002005287564
Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages [A] (#53969)
29 сен 2025, 20:34
29 сен 2025, 20:34
3774f75
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "ProfileTreeNode.h" #include <gmock/gmock.h> #include <gtest/gtest.h> namespace facebook::react::jsinspector_modern::tracing { TEST(ProfileTreeNodeTest, OnlyAddsUniqueChildren) { auto fooCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, .scriptId = 0, .functionName = "foo"}; auto barCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, .scriptId = 0, .functionName = "bar"}; ProfileTreeNode parent( 1, ProfileTreeNode::CodeType::JavaScript, fooCallFrame); ProfileTreeNode* child = parent.addChild(2, ProfileTreeNode::CodeType::JavaScript, barCallFrame); auto maybeAlreadyExistingChild = parent.getIfAlreadyExists( ProfileTreeNode::CodeType::JavaScript, barCallFrame); EXPECT_NE(maybeAlreadyExistingChild, nullptr); auto maybeExistingChildOfChild = child->getIfAlreadyExists( ProfileTreeNode::CodeType::JavaScript, barCallFrame); EXPECT_EQ(maybeExistingChildOfChild, nullptr); } TEST(ProfileTreeNodeTest, ConsidersCodeTypeOfChild) { auto parentCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, .scriptId = 0, .functionName = "foo"}; auto childCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, .scriptId = 0, .functionName = "bar"}; ProfileTreeNode parent( 1, ProfileTreeNode::CodeType::JavaScript, parentCallFrame); parent.addChild(2, ProfileTreeNode::CodeType::JavaScript, childCallFrame); auto maybeExistingChild = parent.getIfAlreadyExists( ProfileTreeNode::CodeType::Other, childCallFrame); EXPECT_EQ(maybeExistingChild, nullptr); } } // namespace facebook::react::jsinspector_modern::tracing