mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
Added sample iOS unit test setup for fabric/debug target
Summary: basic setup for unit testing Fabric impl Reviewed By: hramos Differential Revision: D7359239 fbshipit-source-id: ccaf36e775036f2fad4d8c882bce86bbbe06dd28
This commit is contained in:
parent
f015900d30
commit
6ae38feb65
@ -5,18 +5,18 @@ APPLE_COMPILER_FLAGS = []
|
||||
|
||||
if not IS_OSS_BUILD:
|
||||
load("@xplat//configurations/buck/apple:flag_defs.bzl", "get_static_library_ios_flags", "flags")
|
||||
APPLE_COMPILER_FLAGS = flags.get_flag_value(get_static_library_ios_flags(), 'compiler_flags')
|
||||
APPLE_COMPILER_FLAGS = flags.get_flag_value(get_static_library_ios_flags(), "compiler_flags")
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "debug",
|
||||
srcs = glob(
|
||||
[
|
||||
"**/*.cpp",
|
||||
"*.cpp",
|
||||
],
|
||||
),
|
||||
headers = glob(
|
||||
[
|
||||
"**/*.h",
|
||||
"*.h",
|
||||
],
|
||||
),
|
||||
header_namespace = "",
|
||||
@ -27,10 +27,10 @@ rn_xplat_cxx_library(
|
||||
prefix = "fabric/debug",
|
||||
),
|
||||
compiler_flags = [
|
||||
"-std=c++14",
|
||||
"-Wall",
|
||||
"-fexceptions",
|
||||
"-frtti",
|
||||
"-std=c++14",
|
||||
"-Wall",
|
||||
],
|
||||
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
|
||||
fbobjc_preprocessor_flags = get_debug_preprocessor_flags() + APPLE_INSPECTOR_FLAGS,
|
||||
@ -39,8 +39,31 @@ rn_xplat_cxx_library(
|
||||
"-DLOG_TAG=\"ReactNative\"",
|
||||
"-DWITH_FBSYSTRACE=1",
|
||||
],
|
||||
tests = [
|
||||
":tests",
|
||||
],
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
"xplat//folly:headers_only",
|
||||
],
|
||||
)
|
||||
|
||||
if not IS_OSS_BUILD:
|
||||
load("@xplat//configurations/buck:default_platform_defs.bzl", "APPLE")
|
||||
|
||||
cxx_test(
|
||||
name = "tests",
|
||||
srcs = glob(["tests/**/*.cpp"]),
|
||||
compiler_flags = [
|
||||
"-fexceptions",
|
||||
"-frtti",
|
||||
"-std=c++14",
|
||||
"-Wall",
|
||||
],
|
||||
platforms = APPLE,
|
||||
deps = [
|
||||
"xplat//folly:molly",
|
||||
"xplat//third-party/gmock:gtest",
|
||||
":debug",
|
||||
],
|
||||
)
|
||||
|
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <fabric/debug/DebugStringConvertibleItem.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
TEST(DebugStringConvertibleTest, handleSimpleNode) {
|
||||
SharedDebugStringConvertibleList empty;
|
||||
auto item = std::make_shared<DebugStringConvertibleItem>("View", "hello", empty, empty);
|
||||
|
||||
ASSERT_STREQ(item->getDebugName().c_str(), "View");
|
||||
ASSERT_STREQ(item->getDebugValue().c_str(), "hello");
|
||||
ASSERT_STREQ(item->getDebugDescription().c_str(), "<View=hello/>\n");
|
||||
}
|
||||
|
||||
TEST(DebugStringConvertibleTest, handleSimpleNodeWithProps) {
|
||||
SharedDebugStringConvertibleList empty;
|
||||
SharedDebugStringConvertibleList props = {
|
||||
std::make_shared<DebugStringConvertibleItem>("x", "1", empty, empty)
|
||||
};
|
||||
auto item = std::make_shared<DebugStringConvertibleItem>("View", "hello", props, empty);
|
||||
|
||||
ASSERT_STREQ(item->getDebugName().c_str(), "View");
|
||||
ASSERT_STREQ(item->getDebugValue().c_str(), "hello");
|
||||
ASSERT_STREQ(item->getDebugDescription().c_str(), "<View=hello x=1/>\n");
|
||||
}
|
||||
|
||||
TEST(DebugStringConvertibleTest, handleSimpleNodeWithChildren) {
|
||||
SharedDebugStringConvertibleList empty;
|
||||
SharedDebugStringConvertibleList children = {
|
||||
std::make_shared<DebugStringConvertibleItem>("Child", "a", empty, empty)
|
||||
};
|
||||
auto item = std::make_shared<DebugStringConvertibleItem>("View", "hello", empty, children);
|
||||
|
||||
ASSERT_STREQ(item->getDebugName().c_str(), "View");
|
||||
ASSERT_STREQ(item->getDebugValue().c_str(), "hello");
|
||||
ASSERT_STREQ(item->getDebugDescription().c_str(), "<View=hello>\n <Child=a/>\n</View>\n");
|
||||
}
|
||||
|
||||
TEST(DebugStringConvertibleTest, handleNestedNode) {
|
||||
SharedDebugStringConvertibleList empty;
|
||||
SharedDebugStringConvertibleList props = {
|
||||
std::make_shared<DebugStringConvertibleItem>("x", "1", empty, empty)
|
||||
};
|
||||
SharedDebugStringConvertibleList children = {
|
||||
std::make_shared<DebugStringConvertibleItem>("Child", "a", props, empty)
|
||||
};
|
||||
auto item = std::make_shared<DebugStringConvertibleItem>("View", "hello", props, children);
|
||||
|
||||
ASSERT_STREQ(item->getDebugName().c_str(), "View");
|
||||
ASSERT_STREQ(item->getDebugValue().c_str(), "hello");
|
||||
ASSERT_STREQ(item->getDebugDescription().c_str(), "<View=hello x=1>\n <Child=a x=1/>\n</View>\n");
|
||||
}
|
||||
|
||||
TEST(DebugStringConvertibleTest, handleNodeWithComplexProps) {
|
||||
SharedDebugStringConvertibleList empty;
|
||||
SharedDebugStringConvertibleList subProps = {
|
||||
std::make_shared<DebugStringConvertibleItem>("height", "100", empty, empty),
|
||||
std::make_shared<DebugStringConvertibleItem>("width", "200", empty, empty)
|
||||
};
|
||||
SharedDebugStringConvertibleList props = {
|
||||
std::make_shared<DebugStringConvertibleItem>("x", "1", subProps, empty)
|
||||
};
|
||||
auto item = std::make_shared<DebugStringConvertibleItem>("View", "hello", props, empty);
|
||||
|
||||
ASSERT_STREQ(item->getDebugName().c_str(), "View");
|
||||
ASSERT_STREQ(item->getDebugValue().c_str(), "hello");
|
||||
ASSERT_STREQ(item->getDebugDescription().c_str(), "<View=hello x=1(height=100 width=200)/>\n");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user