diff --git a/ReactCommon/fabric/element/ComponentBuilder.h b/ReactCommon/fabric/element/ComponentBuilder.h index aa9b9d13b5a..d33a3934c2a 100644 --- a/ReactCommon/fabric/element/ComponentBuilder.h +++ b/ReactCommon/fabric/element/ComponentBuilder.h @@ -29,6 +29,14 @@ class ComponentBuilder final { ComponentBuilder( ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry); + /* + * Copyable and movable. + */ + ComponentBuilder(ComponentBuilder const &componentBuilder) = default; + ComponentBuilder(ComponentBuilder &&componentBuilder) noexcept = default; + ComponentBuilder &operator=(ComponentBuilder const &other) = default; + ComponentBuilder &operator=(ComponentBuilder &&other) = default; + /* * Builds a `ShadowNode` tree with given `Element` tree using stored * `ComponentDescriptorRegistry`. diff --git a/ReactCommon/fabric/element/testUtils.h b/ReactCommon/fabric/element/testUtils.h new file mode 100644 index 00000000000..cb29e91afb9 --- /dev/null +++ b/ReactCommon/fabric/element/testUtils.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include +#include +#include + +namespace facebook { +namespace react { + +extern ComponentBuilder simpleComponentBuilder() { + ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{}; + auto eventDispatcher = EventDispatcher::Shared{}; + auto componentDescriptorRegistry = + componentDescriptorProviderRegistry.createComponentDescriptorRegistry( + ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + + componentDescriptorProviderRegistry.add( + concreteComponentDescriptorProvider()); + componentDescriptorProviderRegistry.add( + concreteComponentDescriptorProvider()); + + return ComponentBuilder{componentDescriptorRegistry}; +} + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/element/tests/ElementTest.cpp b/ReactCommon/fabric/element/tests/ElementTest.cpp index 8c838eb5c74..790759f3876 100644 --- a/ReactCommon/fabric/element/tests/ElementTest.cpp +++ b/ReactCommon/fabric/element/tests/ElementTest.cpp @@ -12,21 +12,13 @@ #include #include #include +#include #include using namespace facebook::react; TEST(ElementTest, testNormalCases) { - ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{}; - auto eventDispatcher = EventDispatcher::Shared{}; - auto componentDescriptorRegistry = - componentDescriptorProviderRegistry.createComponentDescriptorRegistry( - ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); - - componentDescriptorProviderRegistry.add( - concreteComponentDescriptorProvider()); - - auto builder = ComponentBuilder{componentDescriptorRegistry}; + auto builder = simpleComponentBuilder(); auto shadowNodeA = std::shared_ptr{}; auto shadowNodeAA = std::shared_ptr{};