mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b9a9e8aed6
Summary: Add unit tests for ShadowNode::State Changelog: [Internal] Reviewed By: JoshuaGross, mdvacca Differential Revision: D19345738 fbshipit-source-id: efb8b797e1a69b9d19631bf5cc4552283c05c107
66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
/*
|
|
* 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 <memory>
|
|
|
|
#include <folly/dynamic.h>
|
|
#include <react/components/view/ConcreteViewShadowNode.h>
|
|
#include <react/components/view/ViewEventEmitter.h>
|
|
#include <react/components/view/ViewProps.h>
|
|
#include <react/core/ConcreteComponentDescriptor.h>
|
|
#include <react/core/RawProps.h>
|
|
#include <react/core/ShadowNode.h>
|
|
|
|
using namespace facebook::react;
|
|
|
|
/**
|
|
* This defines a set of TestComponent classes: Props, ShadowNode,
|
|
* ComponentDescriptor. To be used for testing purpose.
|
|
*/
|
|
|
|
class TestState {
|
|
public:
|
|
int number;
|
|
};
|
|
|
|
static const char TestComponentName[] = "Test";
|
|
|
|
class TestProps : public ViewProps {
|
|
public:
|
|
using ViewProps::ViewProps;
|
|
|
|
TestProps(const TestProps &sourceProps, const RawProps &rawProps)
|
|
: ViewProps(sourceProps, rawProps) {}
|
|
};
|
|
|
|
using SharedTestProps = std::shared_ptr<const TestProps>;
|
|
|
|
class TestShadowNode;
|
|
|
|
using SharedTestShadowNode = std::shared_ptr<const TestShadowNode>;
|
|
|
|
class TestShadowNode : public ConcreteViewShadowNode<
|
|
TestComponentName,
|
|
TestProps,
|
|
ViewEventEmitter,
|
|
TestState> {
|
|
public:
|
|
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
|
|
bool setLayoutMetrics(LayoutMetrics layoutMetrics) {
|
|
return YogaLayoutableShadowNode::setLayoutMetrics(layoutMetrics);
|
|
}
|
|
};
|
|
|
|
class TestComponentDescriptor
|
|
: public ConcreteComponentDescriptor<TestShadowNode> {
|
|
public:
|
|
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
|
|
};
|