mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-10-07 16:33:54 +00:00
!12854 新增render_context和polygon_painter的测试用例
Merge pull request !12854 from 陈桥/master
This commit is contained in:
commit
b353634b36
@ -29,6 +29,7 @@ accessibility_test_output_path = "ace_engine/accessibility"
|
||||
property_test_output_path = "ace_engine/property"
|
||||
layout_test_output_path = "ace_engine/layout"
|
||||
svg_test_output_path = "ace_engine/svg"
|
||||
render_test_output_path = "ace_engine/render"
|
||||
|
||||
template("ace_unittest") {
|
||||
forward_variables_from(invoker, "*")
|
||||
|
@ -21,5 +21,6 @@ group("core_unittest") {
|
||||
"gestures:gestures_test_ng",
|
||||
"pattern:core_pattern_unittest",
|
||||
"pipeline:pipeline_context_test_ng",
|
||||
"render:render_unittest",
|
||||
]
|
||||
}
|
||||
|
20
test/unittest/core/render/BUILD.gn
Executable file
20
test/unittest/core/render/BUILD.gn
Executable file
@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
group("render_unittest") {
|
||||
testonly = true
|
||||
deps = [
|
||||
"polygon_painter:polygon_painter_test_ng",
|
||||
"render_context:render_context_test_ng",
|
||||
]
|
||||
}
|
45
test/unittest/core/render/polygon_painter/BUILD.gn
Executable file
45
test/unittest/core/render/polygon_painter/BUILD.gn
Executable file
@ -0,0 +1,45 @@
|
||||
# Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni")
|
||||
|
||||
ohos_unittest("polygon_painter_test_ng") {
|
||||
module_out_path = render_test_output_path
|
||||
|
||||
sources = [
|
||||
#self
|
||||
"$ace_root/frameworks/core/components_ng/render/polygon_painter.cpp",
|
||||
"$ace_root/test/unittest/core/render/polygon_painter/polygon_painter_test_ng.cpp",
|
||||
|
||||
#main
|
||||
"$ace_root/frameworks/base/geometry/dimension.cpp",
|
||||
"$ace_root/frameworks/base/json/json_util.cpp",
|
||||
"$ace_root/frameworks/core/components/common/properties/color.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/render/shape_painter.cpp",
|
||||
|
||||
#mock
|
||||
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_drawing_convertor.cpp",
|
||||
"$ace_root/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_container.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$ace_root/frameworks/base:ace_memory_monitor_ohos",
|
||||
"$ace_root/test/unittest:ace_unittest_log",
|
||||
"$ace_root/test/unittest:ace_unittest_trace",
|
||||
"$cjson_root:cjson",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
configs = [ "$ace_root/test/unittest:ace_unittest_config" ]
|
||||
}
|
105
test/unittest/core/render/polygon_painter/polygon_painter_test_ng.cpp
Executable file
105
test/unittest/core/render/polygon_painter/polygon_painter_test_ng.cpp
Executable file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "base/utils/utils.h"
|
||||
#define protected public
|
||||
#define private public
|
||||
#include "core/components_ng/render/polygon_painter.h"
|
||||
|
||||
#include "core/components_ng/pattern/shape/polygon_paint_property.h"
|
||||
#include "core/components_ng/pattern/shape/shape_paint_property.h"
|
||||
#include "core/components_ng/render/drawing.h"
|
||||
#include "core/components_ng/render/drawing_prop_convertor.h"
|
||||
#include "core/components_ng/render/shape_painter.h"
|
||||
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS::Ace {
|
||||
namespace {
|
||||
const Dimension TEST {0.0, DimensionUnit::PX};
|
||||
const std::pair<Dimension, Dimension> START_POINT = {10.0_vp, 10.0_vp};
|
||||
const std::pair<Dimension, Dimension> END_POINT = {30.0_vp, 30.0_vp};
|
||||
|
||||
std::vector<ShapePoint> shape_Point;
|
||||
}
|
||||
|
||||
class PolygonPainterTestNg : public testing::Test {};
|
||||
|
||||
/**
|
||||
* @tc.name: PolygonPainterTestNg001
|
||||
* @tc.desc: Test cast to PolygonPainterTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PolygonPainterTestNg, PolygonPainterTestNg001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps1: create canvas and polygonPaintProperty object.
|
||||
*/
|
||||
RSCanvas canvas;
|
||||
NG::PolygonPaintProperty polygonPaintProperty;
|
||||
|
||||
/**
|
||||
* @tc.steps2: call DrawPolygon.
|
||||
* @tc.expected: expect HasPoints return false.
|
||||
*/
|
||||
NG::PolygonPainter::DrawPolygon(canvas, polygonPaintProperty, true);
|
||||
EXPECT_FALSE(polygonPaintProperty.HasPoints());
|
||||
|
||||
/**
|
||||
* @tc.steps3: call DrawPolygon and UpdatePoints with shape_Point.
|
||||
* @tc.expected: expect HasPoints return true.
|
||||
*/
|
||||
polygonPaintProperty.UpdatePoints(shape_Point);
|
||||
NG::PolygonPainter::DrawPolygon(canvas, polygonPaintProperty, true);
|
||||
EXPECT_TRUE(polygonPaintProperty.HasPoints());
|
||||
EXPECT_TRUE(polygonPaintProperty.GetPointsValue().empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PolygonPainterTestNg002
|
||||
* @tc.desc: Test cast to PolygonPainterTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PolygonPainterTestNg, PolygonPainterTestNg002, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps1: create canvas and polygonPaintProperty object.
|
||||
*/
|
||||
RSCanvas canvas;
|
||||
NG::PolygonPaintProperty polygonPaintProperty;
|
||||
|
||||
/**
|
||||
* @tc.steps2: Add START_POINT and END_POINT element to the shape_Point.
|
||||
* @tc.steps2: UpdatePoints with shape_Point and UpdateStrokeWidth with TEST.
|
||||
*/
|
||||
shape_Point.push_back(START_POINT);
|
||||
shape_Point.push_back(END_POINT);
|
||||
polygonPaintProperty.UpdatePoints(shape_Point);
|
||||
polygonPaintProperty.UpdateStrokeWidth(TEST);
|
||||
|
||||
/**
|
||||
* @tc.steps3: call DrawPolygon.
|
||||
* @tc.expected: expect HasStrokeWidth return true.
|
||||
*/
|
||||
NG::PolygonPainter::DrawPolygon(canvas, polygonPaintProperty, true);
|
||||
EXPECT_TRUE(polygonPaintProperty.HasStrokeWidth());
|
||||
EXPECT_FALSE(polygonPaintProperty.GetPointsValue().empty());
|
||||
}
|
||||
} // namespace OHOS::Ace
|
92
test/unittest/core/render/render_context/BUILD.gn
Executable file
92
test/unittest/core/render/render_context/BUILD.gn
Executable file
@ -0,0 +1,92 @@
|
||||
# Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni")
|
||||
|
||||
ohos_unittest("render_context_test_ng") {
|
||||
module_out_path = render_test_output_path
|
||||
|
||||
sources = [
|
||||
"$ace_root/frameworks/base/geometry/dimension.cpp",
|
||||
"$ace_root/frameworks/base/json/json_util.cpp",
|
||||
"$ace_root/frameworks/base/utils/string_expression.cpp",
|
||||
"$ace_root/frameworks/base/utils/string_utils.cpp",
|
||||
"$ace_root/frameworks/core/components/common/layout/grid_column_info.cpp",
|
||||
|
||||
# components_ng
|
||||
"$ace_root/frameworks/base/geometry/matrix4.cpp",
|
||||
"$ace_root/frameworks/base/utils/time_util.cpp",
|
||||
"$ace_root/frameworks/core/components/common/layout/grid_container_info.cpp",
|
||||
"$ace_root/frameworks/core/components/common/layout/grid_system_manager.cpp",
|
||||
"$ace_root/frameworks/core/components/common/layout/screen_system_manager.cpp",
|
||||
"$ace_root/frameworks/core/components/common/properties/alignment.cpp",
|
||||
"$ace_root/frameworks/core/components/common/properties/border_image.cpp",
|
||||
"$ace_root/frameworks/core/components/common/properties/color.cpp",
|
||||
"$ace_root/frameworks/core/components/common/properties/decoration.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/base/frame_node.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/base/geometry_node.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/base/ui_node.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/base/view_stack_processor.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/event_hub.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/focus_hub.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/gesture_event_hub.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/input_event.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/input_event_hub.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/state_style_manager.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/event/touch_event.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/gestures/gesture_referee.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/gestures/recognizers/exclusive_recognizer.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/gestures/recognizers/gesture_recognizer.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/gestures/recognizers/parallel_recognizer.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/layout/box_layout_algorithm.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/layout/layout_property.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/layout/layout_wrapper.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/flex/flex_layout_algorithm.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_layout_property.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/property/calc_length.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/property/gradient_property.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/property/grid_property.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/property/measure_utils.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/property/property.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/render/render_property.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/syntax/for_each_node.cpp",
|
||||
"$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp",
|
||||
"$ace_root/frameworks/core/image/image_source_info.cpp",
|
||||
"$ace_root/frameworks/core/pipeline/base/constants.cpp",
|
||||
|
||||
# mock
|
||||
"$ace_root/frameworks/base/test/mock/mock_system_properties.cpp",
|
||||
"$ace_root/frameworks/core/common/test/mock/mock_ace_application_info.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/test/mock/animation/mock_geometry_transition.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_drawing_convertor.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_context_creator.cpp",
|
||||
"$ace_root/frameworks/core/pipeline_ng/test/mock/mock_element_register.cpp",
|
||||
"$ace_root/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp",
|
||||
|
||||
#test main
|
||||
"$ace_root/frameworks/core/components_ng/render/render_context.cpp",
|
||||
"$ace_root/test/unittest/core/render/render_context/render_context_test_ng.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$ace_root/frameworks/base:ace_memory_monitor_ohos",
|
||||
"$ace_root/test/unittest:ace_unittest_log",
|
||||
"$ace_root/test/unittest:ace_unittest_trace",
|
||||
"$cjson_root:cjson",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
configs = [ "$ace_root/test/unittest:ace_unittest_config" ]
|
||||
}
|
321
test/unittest/core/render/render_context/render_context_test_ng.cpp
Executable file
321
test/unittest/core/render/render_context/render_context_test_ng.cpp
Executable file
@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "base/utils/utils.h"
|
||||
#define protected public
|
||||
#define private public
|
||||
#include "core/components_ng/render/render_context.h"
|
||||
#include "core/components_ng/base/frame_node.h"
|
||||
#include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
|
||||
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS::Ace {
|
||||
namespace {
|
||||
std::string srcimages = "test";
|
||||
constexpr char TAG_ROOT[] = "root";
|
||||
const std::string MATRIX_STRING1 = "1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,";
|
||||
const std::string MATRIX_STRING2 = "0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,";
|
||||
const float VALUE = 1.0f;
|
||||
const float MAXVALUE = 200.0f;
|
||||
const Color RED = Color(0xffff0000);
|
||||
const Color BLACK = Color(0xff000000);
|
||||
const Color WHITE = Color(0xffffffff);
|
||||
|
||||
constexpr Dimension ZERO_TEST {0.0f, DimensionUnit::PX};
|
||||
constexpr Dimension LEFT_TEST {10.0f, DimensionUnit::PX};
|
||||
constexpr Dimension TOP_TEST {20.0f, DimensionUnit::PX};
|
||||
constexpr Dimension RIGHT_TEST {30.0f, DimensionUnit::PX};
|
||||
constexpr Dimension BOTTOM_TEST {40.0f, DimensionUnit::PX};
|
||||
|
||||
RefPtr<NG::ProgressMaskProperty> CreateProgressMaskProperty()
|
||||
{
|
||||
RefPtr<NG::ProgressMaskProperty> progressMaskProperty = AceType::MakeRefPtr<NG::ProgressMaskProperty>();
|
||||
progressMaskProperty->SetMaxValue(MAXVALUE);
|
||||
progressMaskProperty->SetColor(RED);
|
||||
progressMaskProperty->SetValue(VALUE);
|
||||
return progressMaskProperty;
|
||||
};
|
||||
|
||||
void MakeProperty(NG::RenderContext& renderContext)
|
||||
{
|
||||
renderContext.propBorder_ = std::make_unique<NG::BorderProperty>();
|
||||
renderContext.propBdImage_ = std::make_unique<NG::BorderImageProperty>();
|
||||
renderContext.propOverlay_ = std::make_unique<NG::OverlayProperty>();
|
||||
renderContext.propPositionProperty_ = std::make_unique<NG::RenderPositionProperty>();
|
||||
renderContext.propBackground_ = std::make_unique<NG::BackgroundProperty>();
|
||||
renderContext.propGraphics_ = std::make_unique<NG::GraphicsProperty>();
|
||||
renderContext.propGradient_ = std::make_unique<NG::GradientProperty>();
|
||||
renderContext.propTransform_ = std::make_unique<NG::TransformProperty>();
|
||||
renderContext.propClip_ = std::make_unique<NG::ClipProperty>();
|
||||
};
|
||||
}
|
||||
|
||||
class RenderContextTestNg : public testing::Test {};
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest001
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto requestFrame = []() {
|
||||
srcimages = "common/images/mmm.jpg";
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback SetRequestFrame.
|
||||
* @tc.expected: step2. The renderContext.requestFrame_ is not null.
|
||||
*/
|
||||
renderContext.SetRequestFrame(requestFrame);
|
||||
EXPECT_EQ(srcimages, "test");
|
||||
ASSERT_NE(renderContext.requestFrame_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest002
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest002, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto requestFrame = []() {
|
||||
srcimages = "common/images/mmm.jpg";
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback RequestNextFrame.
|
||||
* @tc.expected: step2. The renderContext.requestFrame_ is null.
|
||||
*/
|
||||
renderContext.RequestNextFrame();
|
||||
EXPECT_EQ(srcimages, "test");
|
||||
EXPECT_EQ(renderContext.requestFrame_, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. callback RequestNextFrame.
|
||||
* @tc.expected: step3. The renderContext.requestFrame_ is not null.
|
||||
*/
|
||||
renderContext.SetRequestFrame(requestFrame);
|
||||
renderContext.RequestNextFrame();
|
||||
EXPECT_EQ(srcimages, "common/images/mmm.jpg");
|
||||
ASSERT_NE(renderContext.requestFrame_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest003
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest003, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto rowFrameNode =
|
||||
NG::FrameNode::CreateFrameNode(TAG_ROOT, 0, AceType::MakeRefPtr<NG::LinearLayoutPattern>(false));
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback GetHost.
|
||||
* @tc.expected: step2. expected result is null.
|
||||
*/
|
||||
RefPtr<NG::FrameNode> result = renderContext.GetHost();
|
||||
EXPECT_EQ(result, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback SetHostNode.
|
||||
* @tc.expected: step2. The renderContext.host_ = rowFrameNode.
|
||||
* @tc.expected: step2. The renderContext.host_.Upgrade() is not null.
|
||||
*/
|
||||
renderContext.SetHostNode(rowFrameNode);
|
||||
EXPECT_EQ(renderContext.host_, rowFrameNode);
|
||||
ASSERT_NE(renderContext.host_.Upgrade(), nullptr);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. callback GetHost.
|
||||
* @tc.expected: step3. expected results is not null.
|
||||
*/
|
||||
RefPtr<NG::FrameNode> results = renderContext.GetHost();
|
||||
ASSERT_NE(results, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest004
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest004, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback ToJsonValue.push propTransformMatrix_ is null.
|
||||
* @tc.steps: step2. push propProgressMask_ is null.push propPixelStretchEffect_ is null.
|
||||
*/
|
||||
auto json = JsonUtil::Create(true);
|
||||
renderContext.ToJsonValue(json);
|
||||
|
||||
/**
|
||||
* @tc.expected: Return expected results..
|
||||
*/
|
||||
EXPECT_EQ(json->GetString("total"), "");
|
||||
EXPECT_EQ(json->GetString("updateProgress"), "");
|
||||
EXPECT_EQ(json->GetString("updateColor"), "");
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("left"), ZERO_TEST.ToString());
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("right"), ZERO_TEST.ToString());
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("top"), ZERO_TEST.ToString());
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("bottom"), ZERO_TEST.ToString());
|
||||
EXPECT_EQ(json->GetString("backgroundColor"), "#00000000");
|
||||
EXPECT_EQ(json->GetString("foregroundColor"), "#00000001");
|
||||
EXPECT_EQ(json->GetString("transform"), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest005
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest005, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto json = JsonUtil::Create(true);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback ToJsonValue.push propProgressMask_ is not null.
|
||||
*/
|
||||
MakeProperty(renderContext);
|
||||
renderContext.propProgressMask_ = CreateProgressMaskProperty();
|
||||
renderContext.ToJsonValue(json);
|
||||
|
||||
/**
|
||||
* @tc.expected: Return expected results.
|
||||
*/
|
||||
EXPECT_EQ(json->GetString("total"), "");
|
||||
EXPECT_EQ(json->GetString("updateProgress"), "");
|
||||
EXPECT_EQ(json->GetString("updateColor"), "#FFFF0000");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest006
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest006, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto json = JsonUtil::Create(true);
|
||||
|
||||
PixStretchEffectOption pixStretchEffectOption;
|
||||
pixStretchEffectOption.bottom = BOTTOM_TEST;
|
||||
pixStretchEffectOption.left = LEFT_TEST;
|
||||
pixStretchEffectOption.right= RIGHT_TEST;
|
||||
pixStretchEffectOption.top = TOP_TEST;
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback ToJsonValue.push propPixelStretchEffect_ is not null.
|
||||
*/
|
||||
MakeProperty(renderContext);
|
||||
renderContext.propPixelStretchEffect_ = std::move(pixStretchEffectOption);
|
||||
renderContext.ToJsonValue(json);
|
||||
|
||||
/**
|
||||
* @tc.expected: Return expected results.
|
||||
*/
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("left"), LEFT_TEST.ToString());
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("right"), RIGHT_TEST.ToString());
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("top"), TOP_TEST.ToString());
|
||||
EXPECT_EQ(json->GetValue("pixelStretchEffect")->GetString("bottom"), BOTTOM_TEST.ToString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest007
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest007, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto json = JsonUtil::Create(true);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback ToJsonValue.push propBackgroundColor_ is BLACK.
|
||||
* @tc.steps: step2. push propForegroundColor_ is WHITE.
|
||||
*/
|
||||
MakeProperty(renderContext);
|
||||
renderContext.propBackgroundColor_ = BLACK;
|
||||
renderContext.propForegroundColor_ = WHITE;
|
||||
renderContext.ToJsonValue(json);
|
||||
|
||||
/**
|
||||
* @tc.expected: Return expected results.
|
||||
*/
|
||||
EXPECT_EQ(json->GetString("backgroundColor"), "#FF000000");
|
||||
EXPECT_EQ(json->GetString("foregroundColor"), "#FFFFFFFF");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RenderContextTest008
|
||||
* @tc.desc: Test cast to RenderContextTestNg
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(RenderContextTestNg, RenderContextTest008, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Build a object renderContext.
|
||||
*/
|
||||
NG::RenderContext renderContext;
|
||||
auto json = JsonUtil::Create(true);
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. callback ToJsonValue.push propTransformMatrix_ is CreateIdentity.
|
||||
*/
|
||||
MakeProperty(renderContext);
|
||||
renderContext.propTransformMatrix_ = Matrix4::CreateIdentity();;
|
||||
renderContext.ToJsonValue(json);
|
||||
|
||||
/**
|
||||
* @tc.expected: Return expected results.
|
||||
*/
|
||||
EXPECT_EQ(json->GetValue("transform")->GetString("type"), "matrix");
|
||||
EXPECT_EQ(json->GetValue("transform")->GetString("matrix"), MATRIX_STRING1 + MATRIX_STRING2);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
Loading…
Reference in New Issue
Block a user