Resolve ReactCommon unit test issues (#37463)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37463

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D45946544

fbshipit-source-id: ecae31b0d67f1fbf92a47aebbfd111e961f2a971
This commit is contained in:
Pieter De Baets
2023-05-18 04:45:30 -07:00
committed by Facebook GitHub Bot
parent eba1b206af
commit 0f8b1d2ba3
6 changed files with 28 additions and 11 deletions
@@ -12,9 +12,9 @@
#include <gtest/gtest.h>
#include <ReactCommon/RuntimeExecutor.h>
#include <ReactNative/venice/ReactInstance.h>
#include <hermes/API/hermes/hermes.h>
#include <jsi/jsi.h>
#include <react/bridgeless/ReactInstance.h>
#include <react/renderer/mapbuffer/MapBuffer.h>
using ::testing::_;
@@ -219,7 +219,7 @@ static void sliceChildShadowNodeViewPairsRecursivelyV2(
auto &childShadowNode = *sharedChildShadowNode;
#ifndef ANDROID
// Temporary disabled on Android because the mounting infrastructure
// T153547836: Disabled on Android because the mounting infrastructure
// is not fully ready yet.
if (childShadowNode.getTraits().check(ShadowNodeTraits::Trait::Hidden)) {
continue;
@@ -768,10 +768,25 @@ TEST_F(StackingContextTest, zIndexAndFlattenedNodes) {
});
testViewTree_([](StubViewTree const &viewTree) {
// 5 views in total.
#ifdef ANDROID
// T153547836: Android still mounts views with
// ShadowNodeTraits::Trait::Hidden
EXPECT_EQ(viewTree.size(), 8);
// nodeBB_ forms a stacking context
EXPECT_EQ(viewTree.getRootStubView().children.size(), 5);
// The root view subviews are [6, 10, 9, 5].
EXPECT_EQ(viewTree.getRootStubView().children.at(0)->tag, 6);
EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 10);
EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 9);
EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 5);
EXPECT_EQ(viewTree.getRootStubView().children.at(4)->tag, 3);
#else
EXPECT_EQ(viewTree.size(), 5);
// The root view has all 5 subviews.
// The root view has all 4 subviews.
EXPECT_EQ(viewTree.getRootStubView().children.size(), 4);
// The root view subviews are [6, 10, 9, 5].
@@ -779,6 +794,7 @@ TEST_F(StackingContextTest, zIndexAndFlattenedNodes) {
EXPECT_EQ(viewTree.getRootStubView().children.at(1)->tag, 9);
EXPECT_EQ(viewTree.getRootStubView().children.at(2)->tag, 5);
EXPECT_EQ(viewTree.getRootStubView().children.at(3)->tag, 3);
#endif
});
}
@@ -110,7 +110,8 @@ void Timeline::rewind(TimelineSnapshot const &snapshot) const noexcept {
-> RootShadowNode::Unshared {
return std::static_pointer_cast<RootShadowNode>(
rootShadowNode->ShadowNode::clone({}));
});
},
{});
assert(rewinding_ && "");
rewinding_ = false;
@@ -15,8 +15,7 @@ namespace facebook::react {
TimelineHandler TimelineController::enable(SurfaceId surfaceId) const {
assert(uiManager_);
auto shadowTreePtr = (ShadowTree const *){};
ShadowTree const *shadowTreePtr = nullptr;
uiManager_->getShadowTreeRegistry().visit(
surfaceId,
[&](ShadowTree const &shadowTree) { shadowTreePtr = &shadowTree; });
@@ -24,7 +23,7 @@ TimelineHandler TimelineController::enable(SurfaceId surfaceId) const {
assert(shadowTreePtr);
{
std::unique_lock<butter::shared_mutex> lock(timelinesMutex_);
std::unique_lock<std::shared_mutex> lock(timelinesMutex_);
auto timeline = std::make_unique<Timeline>(*shadowTreePtr);
auto handler = TimelineHandler{*timeline};
@@ -34,7 +33,7 @@ TimelineHandler TimelineController::enable(SurfaceId surfaceId) const {
}
void TimelineController::disable(TimelineHandler &&handler) const {
std::unique_lock<butter::shared_mutex> lock(timelinesMutex_);
std::unique_lock<std::shared_mutex> lock(timelinesMutex_);
auto iterator = timelines_.find(handler.getSurfaceId());
assert(iterator != timelines_.end());
@@ -56,7 +55,7 @@ RootShadowNode::Unshared TimelineController::shadowTreeWillCommit(
ShadowTree const &shadowTree,
RootShadowNode::Shared const &oldRootShadowNode,
RootShadowNode::Unshared const &newRootShadowNode) const noexcept {
std::shared_lock<butter::shared_mutex> lock(timelinesMutex_);
std::shared_lock<std::shared_mutex> lock(timelinesMutex_);
assert(uiManager_ && "`uiManager_` must not be `nullptr`.");
@@ -8,6 +8,7 @@
#pragma once
#include <memory>
#include <shared_mutex>
#include <butter/map.h>
@@ -64,7 +65,7 @@ class TimelineController final : public UIManagerCommitHook {
/*
* Protects all the data members.
*/
mutable butter::shared_mutex timelinesMutex_;
mutable std::shared_mutex timelinesMutex_;
/*
* Owning collection of all running `Timeline` instances.