native C++ test cases update

Signed-off-by: HaoXinyu <haoxinyu1@huawei.com>
This commit is contained in:
HaoXinyu 2024-10-18 14:54:40 +08:00
parent d32da98722
commit e5b81a79f3
38 changed files with 435 additions and 295 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/adapter/android /adapter/android
/adapter/ios /adapter/ios
/.vscode

View File

@ -25,8 +25,8 @@ namespace OHOS::Rosen {
class ContentEffectNodeTest : public RSGraphicTest { class ContentEffectNodeTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -76,7 +76,7 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Alpha_Test_1)
// set background image alpha // set background image alpha
const std::string imgPath = "/data/local/tmp/appearance_test.jpg"; const std::string imgPath = "/data/local/tmp/appearance_test.jpg";
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < rowCount; i++) {
int x = (i % rowCount) * (nodeWidth + nodeGap); int x = (i % rowCount) * (nodeWidth + nodeGap);
int y = (columnCount + columnCount) * (nodeHeight + nodeGap); int y = (columnCount + columnCount) * (nodeHeight + nodeGap);
auto testNodeBgImg = SetUpNodeBgImage(imgPath, { x, y, nodeWidth, nodeHeight }); auto testNodeBgImg = SetUpNodeBgImage(imgPath, { x, y, nodeWidth, nodeHeight });
@ -157,7 +157,7 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Alpha_Offscreen_Te
RegisterNode(testNodeParent); RegisterNode(testNodeParent);
auto testNodeChild = RSCanvasNode::Create(); auto testNodeChild = RSCanvasNode::Create();
testNodeChild->SetBounds({ x, y, nodeSize, nodeSize }); testNodeChild->SetBounds({ 0, 0, nodeSize, nodeSize });
testNodeChild->SetTranslate(0, 50, 0); // Set Y-Position to 50 testNodeChild->SetTranslate(0, 50, 0); // Set Y-Position to 50
testNodeChild->SetAlpha(0.2); // Set alpha to 0.2 testNodeChild->SetAlpha(0.2); // Set alpha to 0.2
testNodeChild->SetBackgroundColor(colorList[i]); testNodeChild->SetBackgroundColor(colorList[i]);
@ -180,7 +180,7 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Alpha_Offscreen_Te
RegisterNode(testNodeParent); RegisterNode(testNodeParent);
auto testNodeChild = RSCanvasNode::Create(); auto testNodeChild = RSCanvasNode::Create();
testNodeChild->SetBounds({ x, y, nodeSize, nodeSize }); testNodeChild->SetBounds({ 0, 0, nodeSize, nodeSize });
testNodeChild->SetTranslate(0, 50, 0); // Set Y-Position to 50 testNodeChild->SetTranslate(0, 50, 0); // Set Y-Position to 50
testNodeChild->SetAlpha(0.2); // Set alpha = 0.2 testNodeChild->SetAlpha(0.2); // Set alpha = 0.2
testNodeChild->SetBackgroundColor(colorList[i]); testNodeChild->SetBackgroundColor(colorList[i]);

View File

@ -93,7 +93,7 @@ GRAPHIC_TEST(AppearanceTest01, CONTENT_DISPLAY_TEST, Appearance_Border_Radius_Co
// four different color // four different color
auto testNodeFourColor = RSCanvasNode::Create(); auto testNodeFourColor = RSCanvasNode::Create();
setNode(testNodeFourColor, { 0, nodeSize * 3, nodeSize, nodeSize }, setNode(testNodeFourColor, { 0, nodePos * 3, nodeSize, nodeSize },
Vector4<Color>(colorList[0], colorList[1], colorList[2], colorList[3])); Vector4<Color>(colorList[0], colorList[1], colorList[2], colorList[3]));
GetRootNode()->AddChild(testNodeFourColor); GetRootNode()->AddChild(testNodeFourColor);
RegisterNode(testNodeFourColor); RegisterNode(testNodeFourColor);

View File

@ -297,8 +297,8 @@ GRAPHIC_TEST(AppearanceTest02, CONTENT_DISPLAY_TEST, Appearance_Border_Touch_Tes
testNode2->SetTranslate(xList[i], yList[i], 0); testNode2->SetTranslate(xList[i], yList[i], 0);
testNode2->SetBackgroundColor(0xff000000); testNode2->SetBackgroundColor(0xff000000);
testNode2->SetBorderStyle(styleList[i], styleList[i], styleList[i], styleList[i]); testNode2->SetBorderStyle(styleList[i], styleList[i], styleList[i], styleList[i]);
testNode1->SetBorderDashGap({ dashGap, dashGap, dashGap, dashGap }); testNode2->SetBorderDashGap({ dashGap, dashGap, dashGap, dashGap });
testNode1->SetBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth); testNode2->SetBorderWidth(borderWidth, borderWidth, borderWidth, borderWidth);
testNode2->SetBorderColor(0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff); testNode2->SetBorderColor(0xff0000ff, 0xff0000ff, 0xff0000ff, 0xff0000ff);
GetRootNode()->AddChild(testNode2); GetRootNode()->AddChild(testNode2);
RegisterNode(testNode2); RegisterNode(testNode2);

View File

@ -24,8 +24,8 @@ namespace OHOS::Rosen {
class AppearanceTest : public RSGraphicTest { class AppearanceTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -37,33 +37,38 @@ public:
GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, ClipRRect_Test_1) GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, ClipRRect_Test_1)
{ {
Vector4f rect[] = { const Vector4f rect[] = {
{ 0.0, 0.0, 250.0, 250.0 }, { 0.0, 0.0, 250.0, 250.0 },
{ 100.0, 100.0, 450.0, 450.0 }, { 100.0, 100.0, 450.0, 450.0 },
{ 100.0, 100.0, 200.0, 200.0 }, { 100.0, 100.0, 200.0, 200.0 },
}; };
Vector4f radius[] = { const Vector4f radius[] = {
{ 100.0, 100.0, 100.0, 100.0 }, { 100.0, 100.0, 100.0, 100.0 },
{ 250.0, 250.0, 250.0, 250.0 }, { 250.0, 250.0, 250.0, 250.0 },
{ 500.0, 500.0, 500.0, 500.0 }, { 500.0, 500.0, 500.0, 500.0 },
}; };
for (int i = 0; i < 3; i++) { const int counts = 3;
for (int j = 0; j < 3; j++) { for (int i = 0; i < counts; i++) {
for (int j = 0; j < counts; j++) {
Vector4f bounds = { i * 410.0, j * 500.0, 400.0, 400.0 };
const int nodeSize = 400;
const int fontSize = 50;
auto testFaNode = RSCanvasNode::Create(); auto testFaNode = RSCanvasNode::Create();
testFaNode->SetBounds({ i * 410.0, j * 500.0, 400.0, 400.0 }); testFaNode->SetBounds(bounds);
testFaNode->SetFrame({ i * 410.0, j * 500.0, 400.0, 400.0 }); testFaNode->SetFrame(bounds);
auto imageModifier = std::make_shared<ImageCustomModifier>(); auto imageModifier = std::make_shared<ImageCustomModifier>();
imageModifier->SetWidth(400); imageModifier->SetWidth(nodeSize);
imageModifier->SetHeight(400); imageModifier->SetHeight(nodeSize);
imageModifier->SetPixelMapPath("/data/local/tmp/fg_test.jpg"); imageModifier->SetPixelMapPath("/data/local/tmp/fg_test.jpg");
testFaNode->AddModifier(imageModifier); testFaNode->AddModifier(imageModifier);
auto textModifier = std::make_shared<TextCustomModifier>(); auto textModifier = std::make_shared<TextCustomModifier>();
textModifier->SetText("TestText"); textModifier->SetText("TestText");
textModifier->SetFontSize(50.0); textModifier->SetFontSize(fontSize);
testFaNode->AddModifier(textModifier); testFaNode->AddModifier(textModifier);
testFaNode->SetClipToBounds(true); testFaNode->SetClipToBounds(true);
auto testNode = RSCanvasNode::Create(); auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0.0, 50.0, 400.0, 400.0 }); testNode->SetBounds({ 0.0, fontSize, nodeSize, nodeSize });
testNode->SetBackgroundColor(0xff00ff00); testNode->SetBackgroundColor(0xff00ff00);
testFaNode->AddChild(testNode); testFaNode->AddChild(testNode);
testFaNode->SetClipRRect(rect[i], radius[j]); testFaNode->SetClipRRect(rect[i], radius[j]);
@ -76,28 +81,33 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, ClipRRect_Test_1)
GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, ClipRRect_Test_2) GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, ClipRRect_Test_2)
{ {
Vector4f rect[] = { const Vector4f rect[] = {
{ 0.0, 0.0, 250.0, 250.0 }, { 0.0, 0.0, 250.0, 250.0 },
{ 100.0, 100.0, 450.0, 450.0 }, { 100.0, 100.0, 450.0, 450.0 },
{ 100.0, 100.0, 200.0, 200.0 }, { 100.0, 100.0, 200.0, 200.0 },
}; };
Vector4f radius[] = { const Vector4f radius[] = {
{ 100.0, 100.0, 100.0, 100.0 }, { 100.0, 100.0, 100.0, 100.0 },
{ 250.0, 250.0, 250.0, 250.0 }, { 250.0, 250.0, 250.0, 250.0 },
{ 500.0, 500.0, 500.0, 500.0 }, { 500.0, 500.0, 500.0, 500.0 },
}; };
for (int i = 0; i < 3; i++) { const int counts = 3;
for (int j = 0; j < 3; j++) { for (int i = 0; i < counts; i++) {
for (int j = 0; j < counts; j++) {
Vector4f bounds = { i * 410.0, j * 500.0, 400.0, 400.0 };
const int nodeSize = 400;
const int nodePosY = 50;
auto testFaNode = RSCanvasNode::Create(); auto testFaNode = RSCanvasNode::Create();
testFaNode->SetBounds({ i * 410.0, j * 500.0, 400.0, 400.0 }); testFaNode->SetBounds(bounds);
auto imageModifier = std::make_shared<ImageCustomModifier>(); auto imageModifier = std::make_shared<ImageCustomModifier>();
imageModifier->SetWidth(400); imageModifier->SetWidth(nodeSize);
imageModifier->SetHeight(400); imageModifier->SetHeight(nodeSize);
imageModifier->SetPixelMapPath("/data/local/tmp/fg_test.jpg"); imageModifier->SetPixelMapPath("/data/local/tmp/fg_test.jpg");
testFaNode->AddModifier(imageModifier); testFaNode->AddModifier(imageModifier);
testFaNode->SetClipToBounds(false); testFaNode->SetClipToBounds(false);
auto testNode = RSCanvasNode::Create(); auto testNode = RSCanvasNode::Create();
testNode->SetBounds({ 0.0, 50.0, 400.0, 400.0 }); testNode->SetBounds({ 0.0, nodePosY, nodeSize, nodeSize });
testNode->SetBackgroundColor(0xff00ff00); testNode->SetBackgroundColor(0xff00ff00);
testFaNode->AddChild(testNode); testFaNode->AddChild(testNode);
testFaNode->SetClipRRect(rect[i], radius[j]); testFaNode->SetClipRRect(rect[i], radius[j]);

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class AppearanceTest03 : public RSGraphicTest { class AppearanceTest03 : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -54,37 +54,44 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra
{ {
Color colorList[] = { Color(0, 0, 0), Color(255, 0, 0), Color(0, 255, 0), Color(0, 0, 255) }; Color colorList[] = { Color(0, 0, 0), Color(255, 0, 0), Color(0, 255, 0), Color(0, 0, 255) };
for (int i = 0; i < 4; i++) { const int nodeCount = 4;
int x = (i % 2) * 520; const int columnCount = 2;
int y = (i / 2) * 520; const int nodeSize = 500;
const int nodeHalfSize = 250;
const int nodePos = 520;
for (int i = 0; i < nodeCount; i++) {
int x = (i % columnCount) * nodePos;
int y = (i / columnCount) * nodePos;
auto testNodeColor = RSCanvasNode::Create(); auto testNodeColor = RSCanvasNode::Create();
setNode(testNodeColor, { x, y, 500, 500 }, Vector4<Color>(colorList[i])); setNode(testNodeColor, { x, y, nodeSize, nodeSize }, Vector4<Color>(colorList[i]));
GetRootNode()->AddChild(testNodeColor); GetRootNode()->AddChild(testNodeColor);
RegisterNode(testNodeColor); RegisterNode(testNodeColor);
} }
// parent black, child red color, white border // parent black, child red color, white border
auto testNodeParent = RSCanvasNode::Create(); auto testNodeParent = RSCanvasNode::Create();
setNode(testNodeParent, { 0, 520 * 2, 500, 500 }, Vector4<Color>(colorList[0])); setNode(testNodeParent, { 0, nodePos * 2, nodeSize, nodeSize }, Vector4<Color>(colorList[0]));
testNodeParent->SetBackgroundColor(0xff000000); testNodeParent->SetBackgroundColor(0xff000000);
GetRootNode()->AddChild(testNodeParent); GetRootNode()->AddChild(testNodeParent);
RegisterNode(testNodeParent); RegisterNode(testNodeParent);
const int testPos = 50;
auto testNodeChild = RSCanvasNode::Create(); auto testNodeChild = RSCanvasNode::Create();
setNode(testNodeChild, { 50, 50, 250, 250 }, Vector4<Color>(Color(0xffffffff))); setNode(testNodeChild, { testPos, testPos, nodeHalfSize, nodeHalfSize }, Vector4<Color>(Color(0xffffffff)));
testNodeChild->SetForegroundColor(0xffff0000); testNodeChild->SetForegroundColor(0xffff0000);
testNodeParent->AddChild(testNodeChild); testNodeParent->AddChild(testNodeChild);
RegisterNode(testNodeChild); RegisterNode(testNodeChild);
// alpha border // alpha border
auto testNodeAlphaColor = RSCanvasNode::Create(); auto testNodeAlphaColor = RSCanvasNode::Create();
setNode(testNodeAlphaColor, { 520, 520 * 2, 500, 500 }, Vector4<Color>(Color(0x7dffffff))); setNode(testNodeAlphaColor, { nodePos, nodePos * 2, nodeSize, nodeSize }, Vector4<Color>(Color(0x7dffffff)));
GetRootNode()->AddChild(testNodeAlphaColor); GetRootNode()->AddChild(testNodeAlphaColor);
RegisterNode(testNodeAlphaColor); RegisterNode(testNodeAlphaColor);
// four different color // four different color
auto testNodeFourColor = RSCanvasNode::Create(); auto testNodeFourColor = RSCanvasNode::Create();
setNode(testNodeFourColor, { 0, 520 * 3, 500, 500 }, setNode(testNodeFourColor, { 0, nodePos * 3, nodeSize, nodeSize },
Vector4<Color>(colorList[0], colorList[1], colorList[2], colorList[3])); Vector4<Color>(colorList[0], colorList[1], colorList[2], colorList[3]));
GetRootNode()->AddChild(testNodeFourColor); GetRootNode()->AddChild(testNodeFourColor);
RegisterNode(testNodeFourColor); RegisterNode(testNodeFourColor);
@ -98,15 +105,23 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra
Color color(0, 0, 0); Color color(0, 0, 0);
Vector4<Color> outLineColor = { color, color, color, color }; Vector4<Color> outLineColor = { color, color, color, color };
for (int i = 0; i < 3; i++) { const int nodeCount = 3;
int x = (i % 2) * 520; const int columnCount = 2;
int y = (i / 2) * 520; const int nodeSize = 500;
const int nodePos = 520;
const float radiusVal = 50.0f;
const int offsetVal = 20;
const int offsetVal2 = 600;
for (int i = 0; i < nodeCount; i++) {
int x = (i % columnCount) * nodePos;
int y = (i / columnCount) * nodePos;
auto testNodeWidth = RSCanvasNode::Create(); auto testNodeWidth = RSCanvasNode::Create();
testNodeWidth->SetBounds({ x, y, 500, 500 }); testNodeWidth->SetBounds({ x, y, nodeSize, nodeSize });
testNodeWidth->SetTranslate(widthList[i] + 20, widthList[i] + 50, 0); testNodeWidth->SetTranslate(widthList[i] + offsetVal, widthList[i] + radiusVal, 0);
testNodeWidth->SetOutlineStyle(style); testNodeWidth->SetOutlineStyle(style);
testNodeWidth->SetOutlineWidth({ widthList[i], widthList[i], widthList[i], widthList[i] }); testNodeWidth->SetOutlineWidth({ widthList[i], widthList[i], widthList[i], widthList[i] });
testNodeWidth->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); testNodeWidth->SetOutlineRadius({ radiusVal, radiusVal, radiusVal, radiusVal });
testNodeWidth->SetOutlineColor(outLineColor); testNodeWidth->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeWidth); GetRootNode()->AddChild(testNodeWidth);
RegisterNode(testNodeWidth); RegisterNode(testNodeWidth);
@ -114,11 +129,11 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra
// four different width // four different width
auto testNodeFourWidth = RSCanvasNode::Create(); auto testNodeFourWidth = RSCanvasNode::Create();
testNodeFourWidth->SetBounds({ 0, 520 * 2, 500, 500 }); testNodeFourWidth->SetBounds({ 0, nodePos * 2, nodeSize, nodeSize });
testNodeFourWidth->SetTranslate(20, 600, 0); testNodeFourWidth->SetTranslate(offsetVal, offsetVal2, 0);
testNodeFourWidth->SetOutlineStyle(style); testNodeFourWidth->SetOutlineStyle(style);
testNodeFourWidth->SetOutlineWidth({ widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 }); testNodeFourWidth->SetOutlineWidth({ widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 });
testNodeFourWidth->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); testNodeFourWidth->SetOutlineRadius({ radiusVal, radiusVal, radiusVal, radiusVal });
testNodeFourWidth->SetOutlineColor(outLineColor); testNodeFourWidth->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeFourWidth); GetRootNode()->AddChild(testNodeFourWidth);
RegisterNode(testNodeFourWidth); RegisterNode(testNodeFourWidth);
@ -134,16 +149,24 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra
Color color(0, 0, 0); Color color(0, 0, 0);
Vector4<Color> outLineColor = { color, color, color, color }; Vector4<Color> outLineColor = { color, color, color, color };
for (int i = 0; i < 4; i++) { const int nodeCount = 4;
int x = (i % 2) * 520; const int columnCount = 2;
int y = (i / 2) * 520; const int nodeSize = 500;
const int nodePos = 520;
const float radiusVal = 50.0f;
const int borderWidth = 5;
const int tranlateVal = 20;
for (int i = 0; i < nodeCount; i++) {
int x = (i % columnCount) * nodePos;
int y = (i / columnCount) * nodePos;
auto testNodeStyle = RSCanvasNode::Create(); auto testNodeStyle = RSCanvasNode::Create();
testNodeStyle->SetBounds({ x, y, 500, 500 }); testNodeStyle->SetBounds({ x, y, nodeSize, nodeSize });
testNodeStyle->SetTranslate(20, 20, 0); testNodeStyle->SetTranslate(tranlateVal, tranlateVal, 0);
Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)i); Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)i);
testNodeStyle->SetOutlineStyle(style); testNodeStyle->SetOutlineStyle(style);
testNodeStyle->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeStyle->SetOutlineWidth({ borderWidth, borderWidth, borderWidth, borderWidth });
testNodeStyle->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); testNodeStyle->SetOutlineRadius({ radiusVal, radiusVal, radiusVal, radiusVal });
testNodeStyle->SetOutlineColor(outLineColor); testNodeStyle->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeStyle); GetRootNode()->AddChild(testNodeStyle);
RegisterNode(testNodeStyle); RegisterNode(testNodeStyle);
@ -151,12 +174,12 @@ GRAPHIC_TEST(AppearanceTest03, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Ra
// four different style // four different style
auto testNodeFourStyle = RSCanvasNode::Create(); auto testNodeFourStyle = RSCanvasNode::Create();
testNodeFourStyle->SetBounds({ 0, 520 * 2, 500, 500 }); testNodeFourStyle->SetBounds({ 0, nodePos * 2, nodeSize, nodeSize });
testNodeFourStyle->SetTranslate(20, 20, 0); testNodeFourStyle->SetTranslate(tranlateVal, tranlateVal, 0);
Vector4<BorderStyle> style2 = Vector4<BorderStyle>((BorderStyle)0, (BorderStyle)1, (BorderStyle)2, (BorderStyle)3); Vector4<BorderStyle> style2 = Vector4<BorderStyle>((BorderStyle)0, (BorderStyle)1, (BorderStyle)2, (BorderStyle)3);
testNodeFourStyle->SetOutlineStyle(style2); testNodeFourStyle->SetOutlineStyle(style2);
testNodeFourStyle->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeFourStyle->SetOutlineWidth({ borderWidth, borderWidth, borderWidth, borderWidth });
testNodeFourStyle->SetOutlineRadius({ 50.0, 50.0, 50.0, 50.0 }); testNodeFourStyle->SetOutlineRadius({ radiusVal, radiusVal, radiusVal, radiusVal });
testNodeFourStyle->SetOutlineColor(outLineColor); testNodeFourStyle->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeFourStyle); GetRootNode()->AddChild(testNodeFourStyle);
RegisterNode(testNodeFourStyle); RegisterNode(testNodeFourStyle);

View File

@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "parameters_defination.h"
#include "rs_graphic_test.h" #include "rs_graphic_test.h"
using namespace testing; using namespace testing;
@ -22,8 +23,8 @@ namespace OHOS::Rosen {
class AppearanceTest04 : public RSGraphicTest { class AppearanceTest04 : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -51,37 +52,40 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Co
{ {
Color colorList[] = { Color(0, 0, 0), Color(255, 0, 0), Color(0, 255, 0), Color(0, 0, 255) }; Color colorList[] = { Color(0, 0, 0), Color(255, 0, 0), Color(0, 255, 0), Color(0, 0, 255) };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 520; int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_;
int y = (i / 2) * 520; int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_;
auto testNodeColor = RSCanvasNode::Create(); auto testNodeColor = RSCanvasNode::Create();
setNode(testNodeColor, { x, y, 500, 500 }, Vector4<Color>(colorList[i])); setNode(testNodeColor, { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ }, Vector4<Color>(colorList[i]));
GetRootNode()->AddChild(testNodeColor); GetRootNode()->AddChild(testNodeColor);
RegisterNode(testNodeColor); RegisterNode(testNodeColor);
} }
// parent black, child red color, white border // parent black, child red color, white border
auto testNodeParent = RSCanvasNode::Create(); auto testNodeParent = RSCanvasNode::Create();
setNode(testNodeParent, { 0, 520 * 2, 500, 500 }, Vector4<Color>(colorList[0])); setNode(
testNodeParent, { 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ }, Vector4<Color>(colorList[0]));
testNodeParent->SetBackgroundColor(0xff000000); testNodeParent->SetBackgroundColor(0xff000000);
GetRootNode()->AddChild(testNodeParent); GetRootNode()->AddChild(testNodeParent);
RegisterNode(testNodeParent); RegisterNode(testNodeParent);
auto testNodeChild = RSCanvasNode::Create(); auto testNodeChild = RSCanvasNode::Create();
setNode(testNodeChild, { 50, 50, 250, 250 }, Vector4<Color>(Color(0xffffffff))); setNode(
testNodeChild, { FIFTY_, FIFTY_, TWO_HUNDRED_FIFTY_, TWO_HUNDRED_FIFTY_ }, Vector4<Color>(Color(0xffffffff)));
testNodeChild->SetForegroundColor(0xffff0000); testNodeChild->SetForegroundColor(0xffff0000);
testNodeParent->AddChild(testNodeChild); testNodeParent->AddChild(testNodeChild);
RegisterNode(testNodeChild); RegisterNode(testNodeChild);
// alpha border // alpha border
auto testNodeAlphaColor = RSCanvasNode::Create(); auto testNodeAlphaColor = RSCanvasNode::Create();
setNode(testNodeAlphaColor, { 520, 520 * 2, 500, 500 }, Vector4<Color>(Color(0x7dffffff))); setNode(testNodeAlphaColor, { FIVE_HUNDRED_TWENTY_, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ },
Vector4<Color>(Color(0x7dffffff)));
GetRootNode()->AddChild(testNodeAlphaColor); GetRootNode()->AddChild(testNodeAlphaColor);
RegisterNode(testNodeAlphaColor); RegisterNode(testNodeAlphaColor);
// four different color // four different color
auto testNodeFourColor = RSCanvasNode::Create(); auto testNodeFourColor = RSCanvasNode::Create();
setNode(testNodeFourColor, { 0, 520 * 3, 500, 500 }, setNode(testNodeFourColor, { 0, FIVE_HUNDRED_TWENTY_ * 3, FIVE_HUNDRED_, FIVE_HUNDRED_ },
Vector4<Color>(colorList[0], colorList[1], colorList[2], colorList[3])); Vector4<Color>(colorList[0], colorList[1], colorList[2], colorList[3]));
GetRootNode()->AddChild(testNodeFourColor); GetRootNode()->AddChild(testNodeFourColor);
RegisterNode(testNodeFourColor); RegisterNode(testNodeFourColor);
@ -95,12 +99,12 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Wi
Color color(0, 0, 0); Color color(0, 0, 0);
Vector4<Color> outLineColor = { color, color, color, color }; Vector4<Color> outLineColor = { color, color, color, color };
for (int i = 0; i < 3; i++) { for (int i = 0; i < THREE_; i++) {
int x = (i % 2) * 520; int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_;
int y = (i / 2) * 520; int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_;
auto testNodeWidth = RSCanvasNode::Create(); auto testNodeWidth = RSCanvasNode::Create();
testNodeWidth->SetBounds({ x, y, 500, 500 }); testNodeWidth->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeWidth->SetTranslate(widthList[i] + 20, widthList[i] + 50, 0); testNodeWidth->SetTranslate(widthList[i] + TWENTY_, widthList[i] + FIFTY_, 0);
testNodeWidth->SetOutlineStyle(style); testNodeWidth->SetOutlineStyle(style);
testNodeWidth->SetOutlineWidth({ widthList[i], widthList[i], widthList[i], widthList[i] }); testNodeWidth->SetOutlineWidth({ widthList[i], widthList[i], widthList[i], widthList[i] });
testNodeWidth->SetOutlineColor(outLineColor); testNodeWidth->SetOutlineColor(outLineColor);
@ -110,8 +114,8 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Wi
// four different width // four different width
auto testNodeFourWidth = RSCanvasNode::Create(); auto testNodeFourWidth = RSCanvasNode::Create();
testNodeFourWidth->SetBounds({ 0, 520 * 2, 500, 500 }); testNodeFourWidth->SetBounds({ 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeFourWidth->SetTranslate(20, 600, 0); testNodeFourWidth->SetTranslate(TWENTY_, SIX_HUNDRED_, 0);
testNodeFourWidth->SetOutlineStyle(style); testNodeFourWidth->SetOutlineStyle(style);
testNodeFourWidth->SetOutlineWidth({ widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 }); testNodeFourWidth->SetOutlineWidth({ widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 });
testNodeFourWidth->SetOutlineColor(outLineColor); testNodeFourWidth->SetOutlineColor(outLineColor);
@ -129,15 +133,15 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_St
Color color(0, 0, 0); Color color(0, 0, 0);
Vector4<Color> outLineColor = { color, color, color, color }; Vector4<Color> outLineColor = { color, color, color, color };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 520; int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_;
int y = (i / 2) * 520; int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_;
auto testNodeStyle = RSCanvasNode::Create(); auto testNodeStyle = RSCanvasNode::Create();
testNodeStyle->SetBounds({ x, y, 500, 500 }); testNodeStyle->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeStyle->SetTranslate(20, 20, 0); testNodeStyle->SetTranslate(TWENTY_, TWENTY_, 0);
Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)i); Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)i);
testNodeStyle->SetOutlineStyle(style); testNodeStyle->SetOutlineStyle(style);
testNodeStyle->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeStyle->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeStyle->SetOutlineColor(outLineColor); testNodeStyle->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeStyle); GetRootNode()->AddChild(testNodeStyle);
RegisterNode(testNodeStyle); RegisterNode(testNodeStyle);
@ -145,11 +149,11 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_St
// four different style // four different style
auto testNodeFourStyle = RSCanvasNode::Create(); auto testNodeFourStyle = RSCanvasNode::Create();
testNodeFourStyle->SetBounds({ 0, 520 * 2, 500, 500 }); testNodeFourStyle->SetBounds({ 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeFourStyle->SetTranslate(20, 20, 0); testNodeFourStyle->SetTranslate(TWENTY_, TWENTY_, 0);
Vector4<BorderStyle> style2 = Vector4<BorderStyle>((BorderStyle)0, (BorderStyle)1, (BorderStyle)2, (BorderStyle)3); Vector4<BorderStyle> style2 = Vector4<BorderStyle>((BorderStyle)0, (BorderStyle)1, (BorderStyle)2, (BorderStyle)3);
testNodeFourStyle->SetOutlineStyle(style2); testNodeFourStyle->SetOutlineStyle(style2);
testNodeFourStyle->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeFourStyle->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeFourStyle->SetOutlineColor(outLineColor); testNodeFourStyle->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeFourStyle); GetRootNode()->AddChild(testNodeFourStyle);
RegisterNode(testNodeFourStyle); RegisterNode(testNodeFourStyle);
@ -158,21 +162,21 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_St
// Dash Width // Dash Width
GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_DashWidth_Test_1) GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_DashWidth_Test_1)
{ {
uint32_t widthList[] = { 0, 20, 120, 250 }; uint32_t widthList[] = { 0, 20, 120, TWO_HUNDRED_FIFTY_ };
Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)1); Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)1);
Color color(0, 0, 0); Color color(0, 0, 0);
Vector4<Color> outLineColor = { color, color, color, color }; Vector4<Color> outLineColor = { color, color, color, color };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 520; int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_;
int y = (i / 2) * 520; int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_;
auto testNodeDashWidth = RSCanvasNode::Create(); auto testNodeDashWidth = RSCanvasNode::Create();
testNodeDashWidth->SetBounds({ x, y, 500, 500 }); testNodeDashWidth->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeDashWidth->SetTranslate(20, 20, 0); testNodeDashWidth->SetTranslate(TWENTY_, TWENTY_, 0);
// dash style // dash style
testNodeDashWidth->SetOutlineStyle(style); testNodeDashWidth->SetOutlineStyle(style);
testNodeDashWidth->SetBorderDashWidth({ widthList[i], widthList[i], widthList[i], widthList[i] }); testNodeDashWidth->SetBorderDashWidth({ widthList[i], widthList[i], widthList[i], widthList[i] });
testNodeDashWidth->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeDashWidth->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeDashWidth->SetOutlineColor(outLineColor); testNodeDashWidth->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeDashWidth); GetRootNode()->AddChild(testNodeDashWidth);
RegisterNode(testNodeDashWidth); RegisterNode(testNodeDashWidth);
@ -180,24 +184,24 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Da
// four different dash width // four different dash width
auto testNodeFourDashWidth = RSCanvasNode::Create(); auto testNodeFourDashWidth = RSCanvasNode::Create();
testNodeFourDashWidth->SetBounds({ 0, 520 * 2, 500, 500 }); testNodeFourDashWidth->SetBounds({ 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeFourDashWidth->SetTranslate(20, 20, 0); testNodeFourDashWidth->SetTranslate(TWENTY_, TWENTY_, 0);
testNodeFourDashWidth->SetOutlineStyle(style); testNodeFourDashWidth->SetOutlineStyle(style);
testNodeFourDashWidth->SetBorderDashWidth( testNodeFourDashWidth->SetBorderDashWidth(
{ widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 }); { widthList[1] * 0, widthList[1] * 2, widthList[1] * 4, widthList[1] * 8 });
testNodeFourDashWidth->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeFourDashWidth->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeFourDashWidth->SetOutlineColor(outLineColor); testNodeFourDashWidth->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeFourDashWidth); GetRootNode()->AddChild(testNodeFourDashWidth);
RegisterNode(testNodeFourDashWidth); RegisterNode(testNodeFourDashWidth);
// not dash style, set dash width // not dash style, set dash width
auto testNodeSolid = RSCanvasNode::Create(); auto testNodeSolid = RSCanvasNode::Create();
testNodeSolid->SetBounds({ 520, 520 * 2, 500, 500 }); testNodeSolid->SetBounds({ FIVE_HUNDRED_TWENTY_, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeSolid->SetTranslate(20, 20, 0); testNodeSolid->SetTranslate(TWENTY_, TWENTY_, 0);
// solid style // solid style
testNodeSolid->SetOutlineStyle(style); testNodeSolid->SetOutlineStyle(style);
testNodeSolid->SetBorderDashWidth({ widthList[1], widthList[1], widthList[1], widthList[1] }); testNodeSolid->SetBorderDashWidth({ widthList[1], widthList[1], widthList[1], widthList[1] });
testNodeSolid->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeSolid->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeSolid->SetOutlineColor(outLineColor); testNodeSolid->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeSolid); GetRootNode()->AddChild(testNodeSolid);
RegisterNode(testNodeSolid); RegisterNode(testNodeSolid);
@ -206,21 +210,21 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Da
// Dash Gap // Dash Gap
GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_DashGap_Test_1) GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_DashGap_Test_1)
{ {
uint32_t gapList[] = { 0, 20, 120, 250 }; uint32_t gapList[] = { 0, 20, 120, TWO_HUNDRED_FIFTY_ };
Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)1); Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)1);
Color color(0, 0, 0); Color color(0, 0, 0);
Vector4<Color> outLineColor = { color, color, color, color }; Vector4<Color> outLineColor = { color, color, color, color };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 520; int x = (i % TWO_) * FIVE_HUNDRED_TWENTY_;
int y = (i / 2) * 520; int y = (i / TWO_) * FIVE_HUNDRED_TWENTY_;
auto testNodeDashGap = RSCanvasNode::Create(); auto testNodeDashGap = RSCanvasNode::Create();
testNodeDashGap->SetBounds({ x, y, 500, 500 }); testNodeDashGap->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeDashGap->SetTranslate(20, 20, 0); testNodeDashGap->SetTranslate(TWENTY_, TWENTY_, 0);
// dash style // dash style
testNodeDashGap->SetOutlineStyle(style); testNodeDashGap->SetOutlineStyle(style);
testNodeDashGap->SetBorderDashGap({ gapList[i], gapList[i], gapList[i], gapList[i] }); testNodeDashGap->SetBorderDashGap({ gapList[i], gapList[i], gapList[i], gapList[i] });
testNodeDashGap->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeDashGap->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeDashGap->SetOutlineColor(outLineColor); testNodeDashGap->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeDashGap); GetRootNode()->AddChild(testNodeDashGap);
RegisterNode(testNodeDashGap); RegisterNode(testNodeDashGap);
@ -228,23 +232,23 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_Da
// four different dash width // four different dash width
auto testNodeFourDashGap = RSCanvasNode::Create(); auto testNodeFourDashGap = RSCanvasNode::Create();
testNodeFourDashGap->SetBounds({ 0, 520 * 2, 500, 500 }); testNodeFourDashGap->SetBounds({ 0, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeFourDashGap->SetTranslate(20, 20, 0); testNodeFourDashGap->SetTranslate(TWENTY_, TWENTY_, 0);
testNodeFourDashGap->SetOutlineStyle(style); testNodeFourDashGap->SetOutlineStyle(style);
testNodeFourDashGap->SetBorderDashGap({ gapList[1] * 0, gapList[1] * 2, gapList[1] * 4, gapList[1] * 8 }); testNodeFourDashGap->SetBorderDashGap({ gapList[1] * 0, gapList[1] * 2, gapList[1] * 4, gapList[1] * 8 });
testNodeFourDashGap->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeFourDashGap->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeFourDashGap->SetOutlineColor(outLineColor); testNodeFourDashGap->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeFourDashGap); GetRootNode()->AddChild(testNodeFourDashGap);
RegisterNode(testNodeFourDashGap); RegisterNode(testNodeFourDashGap);
// not dash style, set dash width // not dash style, set dash width
auto testNodeSolid = RSCanvasNode::Create(); auto testNodeSolid = RSCanvasNode::Create();
testNodeSolid->SetBounds({ 520, 520 * 2, 500, 500 }); testNodeSolid->SetBounds({ FIVE_HUNDRED_TWENTY_, FIVE_HUNDRED_TWENTY_ * 2, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeSolid->SetTranslate(20, 20, 0); testNodeSolid->SetTranslate(TWENTY_, TWENTY_, 0);
// solid style // solid style
testNodeSolid->SetOutlineStyle(style); testNodeSolid->SetOutlineStyle(style);
testNodeSolid->SetBorderDashGap({ gapList[1], gapList[1], gapList[1], gapList[1] }); testNodeSolid->SetBorderDashGap({ gapList[1], gapList[1], gapList[1], gapList[1] });
testNodeSolid->SetOutlineWidth({ 5, 5, 5, 5 }); testNodeSolid->SetOutlineWidth({ FIVE_, FIVE_, FIVE_, FIVE_ });
testNodeSolid->SetOutlineColor(outLineColor); testNodeSolid->SetOutlineColor(outLineColor);
GetRootNode()->AddChild(testNodeSolid); GetRootNode()->AddChild(testNodeSolid);
RegisterNode(testNodeSolid); RegisterNode(testNodeSolid);
@ -262,32 +266,32 @@ GRAPHIC_TEST(AppearanceTest04, CONTENT_DISPLAY_TEST, Appearance_OutlineBorder_To
float xList[] = { 50, 50, 525, 525 }; float xList[] = { 50, 50, 525, 525 };
float yList[] = { 50, 50, 20, 20 }; float yList[] = { 50, 50, 20, 20 };
// overlay // overlay
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 560; int x = (i % TWO_) * FIVE_HUNDRED_SIXTY_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
if (i == 3) { if (i == THREE_) {
x -= 560; x -= FIVE_HUNDRED_SIXTY_;
y += 510; y += FIVE_HUNDRED_TEN_;
} }
auto testNode1 = RSCanvasNode::Create(); auto testNode1 = RSCanvasNode::Create();
testNode1->SetBounds({ x, y, 500, 500 }); testNode1->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode1->SetTranslate(20, 20, 0); testNode1->SetTranslate(TWENTY_, TWENTY_, 0);
testNode1->SetBackgroundColor(0xff000000); testNode1->SetBackgroundColor(0xff000000);
Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)styleList[i]); Vector4<BorderStyle> style = Vector4<BorderStyle>((BorderStyle)styleList[i]);
testNode1->SetOutlineStyle(style); testNode1->SetOutlineStyle(style);
testNode1->SetBorderDashGap({ 25, 25, 25, 25 }); testNode1->SetBorderDashGap({ TWENTY_FIVE_, TWENTY_FIVE_, TWENTY_FIVE_, TWENTY_FIVE_ });
testNode1->SetOutlineWidth({ 10, 10, 10, 10 }); testNode1->SetOutlineWidth({ TEN_, TEN_, TEN_, TEN_ });
testNode1->SetOutlineColor(outLineColor1); testNode1->SetOutlineColor(outLineColor1);
GetRootNode()->AddChild(testNode1); GetRootNode()->AddChild(testNode1);
RegisterNode(testNode1); RegisterNode(testNode1);
auto testNode2 = RSCanvasNode::Create(); auto testNode2 = RSCanvasNode::Create();
testNode2->SetBounds({ x, y, 500, 500 }); testNode2->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode2->SetTranslate(xList[i], yList[i], 0); testNode2->SetTranslate(xList[i], yList[i], 0);
testNode2->SetBackgroundColor(0xff000000); testNode2->SetBackgroundColor(0xff000000);
testNode2->SetOutlineStyle(style); testNode2->SetOutlineStyle(style);
testNode2->SetBorderDashGap({ 25, 25, 25, 25 }); testNode2->SetBorderDashGap({ TWENTY_FIVE_, TWENTY_FIVE_, TWENTY_FIVE_, TWENTY_FIVE_ });
testNode2->SetOutlineWidth({ 10, 10, 10, 10 }); testNode2->SetOutlineWidth({ TEN_, TEN_, TEN_, TEN_ });
testNode2->SetOutlineColor(outLineColor2); testNode2->SetOutlineColor(outLineColor2);
GetRootNode()->AddChild(testNode2); GetRootNode()->AddChild(testNode2);
RegisterNode(testNode2); RegisterNode(testNode2);

View File

@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "parameters_defination.h"
#include "rs_graphic_test.h" #include "rs_graphic_test.h"
#include "rs_graphic_test_img.h" #include "rs_graphic_test_img.h"
@ -23,8 +24,8 @@ namespace OHOS::Rosen {
class AppearanceTest : public RSGraphicTest { class AppearanceTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -39,14 +40,14 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Color_Test_
{ {
uint32_t colorList[] = { 0xff000000, 0xffff0000, 0xff00ff00, 0xff0000ff }; uint32_t colorList[] = { 0xff000000, 0xffff0000, 0xff00ff00, 0xff0000ff };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeColor = RSCanvasNode::Create(); auto testNodeColor = RSCanvasNode::Create();
testNodeColor->SetBounds({ x, y, 500, 500 }); testNodeColor->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeColor->SetTranslate(100, 100, 0); testNodeColor->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeColor->SetShadowColor(colorList[i]); testNodeColor->SetShadowColor(colorList[i]);
testNodeColor->SetShadowRadius(50); testNodeColor->SetShadowRadius(FIFTY_);
GetRootNode()->AddChild(testNodeColor); GetRootNode()->AddChild(testNodeColor);
RegisterNode(testNodeColor); RegisterNode(testNodeColor);
} }
@ -55,12 +56,12 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Color_Test_
// shadow offset // shadow offset
GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test_1) GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test_1)
{ {
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeOffset = RSCanvasNode::Create(); auto testNodeOffset = RSCanvasNode::Create();
testNodeOffset->SetBounds({ x, y, 500, 500 }); testNodeOffset->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeOffset->SetTranslate(100, 100, 0); testNodeOffset->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeOffset->SetShadowColor(0xff000000); testNodeOffset->SetShadowColor(0xff000000);
switch (i) { switch (i) {
case 0: { case 0: {
@ -82,7 +83,7 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test
default: default:
break; break;
} }
testNodeOffset->SetShadowRadius(50); testNodeOffset->SetShadowRadius(FIFTY_);
GetRootNode()->AddChild(testNodeOffset); GetRootNode()->AddChild(testNodeOffset);
RegisterNode(testNodeOffset); RegisterNode(testNodeOffset);
} }
@ -90,12 +91,12 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test
GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test_2) GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test_2)
{ {
for (int i = 0; i < 5; i++) { for (int i = 0; i < FIVE_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeOffset = RSCanvasNode::Create(); auto testNodeOffset = RSCanvasNode::Create();
testNodeOffset->SetBounds({ x, y, 500, 500 }); testNodeOffset->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeOffset->SetTranslate(100, 100, 0); testNodeOffset->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeOffset->SetBackgroundColor(0xffc0c0c0); testNodeOffset->SetBackgroundColor(0xffc0c0c0);
testNodeOffset->SetShadowColor(0xff000000); testNodeOffset->SetShadowColor(0xff000000);
testNodeOffset->SetShadowRadius(50); testNodeOffset->SetShadowRadius(50);
@ -118,8 +119,8 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Offset_Test
break; break;
} }
case 4: { case 4: {
testNodeOffset->SetTranslate(0, 200, 0); testNodeOffset->SetTranslate(0, TWO_HUNDRED_, 0);
testNodeOffset->SetShadowOffset(500, 500); testNodeOffset->SetShadowOffset(FIVE_HUNDRED_, FIVE_HUNDRED_);
break; break;
} }
default: default:
@ -135,16 +136,16 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Alpha_Test_
{ {
float alphaList[] = { 0, 0.2, 0.8, 1 }; float alphaList[] = { 0, 0.2, 0.8, 1 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeAlpha = RSCanvasNode::Create(); auto testNodeAlpha = RSCanvasNode::Create();
testNodeAlpha->SetBounds({ x, y, 500, 500 }); testNodeAlpha->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeAlpha->SetTranslate(100, 100, 0); testNodeAlpha->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeAlpha->SetBackgroundColor(0xffc0c0c0); testNodeAlpha->SetBackgroundColor(0xffc0c0c0);
testNodeAlpha->SetShadowColor(0xff000000); testNodeAlpha->SetShadowColor(0xff000000);
testNodeAlpha->SetShadowAlpha(alphaList[i]); testNodeAlpha->SetShadowAlpha(alphaList[i]);
testNodeAlpha->SetShadowRadius(50); testNodeAlpha->SetShadowRadius(FIFTY_);
GetRootNode()->AddChild(testNodeAlpha); GetRootNode()->AddChild(testNodeAlpha);
RegisterNode(testNodeAlpha); RegisterNode(testNodeAlpha);
} }
@ -155,12 +156,12 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Radius_Test
{ {
float radiusList[] = { 0, 50, 250 }; float radiusList[] = { 0, 50, 250 };
for (int i = 0; i < 3; i++) { for (int i = 0; i < THREE_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeRadius = RSCanvasNode::Create(); auto testNodeRadius = RSCanvasNode::Create();
testNodeRadius->SetBounds({ x, y, 500, 500 }); testNodeRadius->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeRadius->SetTranslate(100, 100, 0); testNodeRadius->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeRadius->SetBackgroundColor(0xffc0c0c0); testNodeRadius->SetBackgroundColor(0xffc0c0c0);
testNodeRadius->SetShadowColor(0xff000000); testNodeRadius->SetShadowColor(0xff000000);
testNodeRadius->SetShadowRadius(radiusList[i]); testNodeRadius->SetShadowRadius(radiusList[i]);
@ -169,20 +170,21 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Radius_Test
} }
// ClipToBounds // ClipToBounds
const int yPos = 1250;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
auto testNodeParent = RSCanvasNode::Create(); auto testNodeParent = RSCanvasNode::Create();
testNodeParent->SetBounds({ i * 600, 1250, 500, 500 }); testNodeParent->SetBounds({ i * SIX_HUNDRED_, yPos, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeParent->SetTranslate(100, 100, 0); testNodeParent->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeParent->SetClipToBounds(i); testNodeParent->SetClipToBounds(i);
GetRootNode()->AddChild(testNodeParent); GetRootNode()->AddChild(testNodeParent);
RegisterNode(testNodeParent); RegisterNode(testNodeParent);
auto testNodeChild = RSCanvasNode::Create(); auto testNodeChild = RSCanvasNode::Create();
testNodeChild->SetBounds({ 0, 0, 400, 400 }); testNodeChild->SetBounds({ 0, 0, FOUR_HUNDRED_, FOUR_HUNDRED_ });
testNodeChild->SetTranslate(100, 100, 0); testNodeChild->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeChild->SetBackgroundColor(0xffc0c0c0); testNodeChild->SetBackgroundColor(0xffc0c0c0);
testNodeChild->SetShadowColor(0xff000000); testNodeChild->SetShadowColor(0xff000000);
testNodeChild->SetShadowRadius(50); testNodeChild->SetShadowRadius(FIFTY_);
testNodeParent->AddChild(testNodeChild); testNodeParent->AddChild(testNodeChild);
RegisterNode(testNodeChild); RegisterNode(testNodeChild);
} }
@ -198,34 +200,34 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Strategy_Te
float radiusList[] = { 50, 100 }; float radiusList[] = { 50, 100 };
float offsetList[] = { 0, 50 }; float offsetList[] = { 0, 50 };
for (int i = 0; i < 6; i++) { for (int i = 0; i < SIX_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNodeParent = RSCanvasNode::Create(); auto testNodeParent = RSCanvasNode::Create();
testNodeParent->SetBounds({ x, y, 500, 500 }); testNodeParent->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
auto imageModifier = std::make_shared<ImageCustomModifier>(); auto imageModifier = std::make_shared<ImageCustomModifier>();
imageModifier->SetWidth(500); imageModifier->SetWidth(FIVE_HUNDRED_);
imageModifier->SetHeight(500); imageModifier->SetHeight(FIVE_HUNDRED_);
imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg"); imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg");
testNodeParent->AddModifier(imageModifier); testNodeParent->AddModifier(imageModifier);
GetRootNode()->AddChild(testNodeParent); GetRootNode()->AddChild(testNodeParent);
RegisterNode(testNodeParent); RegisterNode(testNodeParent);
auto testNodeChild = RSCanvasNode::Create(); auto testNodeChild = RSCanvasNode::Create();
testNodeChild->SetBounds({ 0, 0, 250, 250 }); testNodeChild->SetBounds({ 0, 0, TWO_HUNDRED_FIFTY_, TWO_HUNDRED_FIFTY_ });
testNodeChild->SetTranslate(100, 100, 0); testNodeChild->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
testNodeChild->SetBackgroundColor(0xffffffff); testNodeChild->SetBackgroundColor(0xffffffff);
testNodeChild->SetShadowAlpha(alphaList[i % 2]); testNodeChild->SetShadowAlpha(alphaList[i % TWO_]);
testNodeChild->SetShadowOffset(offsetList[i % 2], offsetList[i % 2]); testNodeChild->SetShadowOffset(offsetList[i % TWO_], offsetList[i % TWO_]);
// 1st, 2nd row, Average and Primary, radius // 1st, 2nd row, Average and Primary, radius
if (i < 4) { if (i < 4) {
testNodeChild->SetShadowColorStrategy((i / 2) + 1); testNodeChild->SetShadowColorStrategy((i / TWO_) + 1);
testNodeChild->SetShadowRadius(radiusList[i % 2]); testNodeChild->SetShadowRadius(radiusList[i % TWO_]);
} }
// third row, Shadow Elevation, normal shadow // third row, Shadow Elevation, normal shadow
else { else {
testNodeChild->SetShadowColorStrategy(i / 2); testNodeChild->SetShadowColorStrategy(i / TWO_);
testNodeChild->SetShadowElevation(radiusList[i % 2]); testNodeChild->SetShadowElevation(radiusList[i % TWO_]);
} }
testNodeParent->AddChild(testNodeChild); testNodeParent->AddChild(testNodeChild);
RegisterNode(testNodeChild); RegisterNode(testNodeChild);
@ -237,23 +239,23 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Filled_Test
{ {
float alphaList[] = { 1, 0.5 }; float alphaList[] = { 1, 0.5 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeFilled = RSCanvasNode::Create(); auto testNodeFilled = RSCanvasNode::Create();
testNodeFilled->SetBounds({ x, y, 500, 500 }); testNodeFilled->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeFilled->SetTranslate(100, 100, 0); testNodeFilled->SetTranslate(ONE_HUNDRED_, ONE_HUNDRED_, 0);
auto imageModifier = std::make_shared<ImageCustomModifier>(); auto imageModifier = std::make_shared<ImageCustomModifier>();
imageModifier->SetWidth(500); imageModifier->SetWidth(FIVE_HUNDRED_);
imageModifier->SetHeight(500); imageModifier->SetHeight(FIVE_HUNDRED_);
imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg"); imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg");
testNodeFilled->AddModifier(imageModifier); testNodeFilled->AddModifier(imageModifier);
testNodeFilled->SetAlpha(0.5); testNodeFilled->SetAlpha(0.5);
testNodeFilled->SetShadowColor(0xff00ff00); testNodeFilled->SetShadowColor(0xff00ff00);
testNodeFilled->SetShadowOffset(50, 50); testNodeFilled->SetShadowOffset(FIFTY_, FIFTY_);
testNodeFilled->SetShadowRadius(50); testNodeFilled->SetShadowRadius(FIFTY_);
testNodeFilled->SetShadowIsFilled(i / 2); testNodeFilled->SetShadowIsFilled(i / TWO_);
testNodeFilled->SetShadowAlpha(alphaList[i % 2]); testNodeFilled->SetShadowAlpha(alphaList[i % TWO_]);
GetRootNode()->AddChild(testNodeFilled); GetRootNode()->AddChild(testNodeFilled);
RegisterNode(testNodeFilled); RegisterNode(testNodeFilled);
} }
@ -262,18 +264,18 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Filled_Test
// shadow mask // shadow mask
GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_mask_Test_1) GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_mask_Test_1)
{ {
for (int i = 0; i < 2; i++) { for (int i = 0; i < TWO_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeMask = RSCanvasNode::Create(); auto testNodeMask = RSCanvasNode::Create();
testNodeMask->SetBounds({ x, y, 500, 500 }); testNodeMask->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
auto imageModifier = std::make_shared<ImageCustomModifier>(); auto imageModifier = std::make_shared<ImageCustomModifier>();
imageModifier->SetWidth(500); imageModifier->SetWidth(FIVE_HUNDRED_);
imageModifier->SetHeight(500); imageModifier->SetHeight(FIVE_HUNDRED_);
imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg"); imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg");
testNodeMask->AddModifier(imageModifier); testNodeMask->AddModifier(imageModifier);
testNodeMask->SetShadowMask(i); testNodeMask->SetShadowMask(i);
testNodeMask->SetShadowRadius(100); testNodeMask->SetShadowRadius(ONE_HUNDRED_);
testNodeMask->SetShadowAlpha(0.5); testNodeMask->SetShadowAlpha(0.5);
GetRootNode()->AddChild(testNodeMask); GetRootNode()->AddChild(testNodeMask);
RegisterNode(testNodeMask); RegisterNode(testNodeMask);
@ -286,14 +288,14 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Shadow_Touch_Test_
float alphaList[] = { 1, 0.5 }; float alphaList[] = { 1, 0.5 };
uint32_t colorList[] = { 0xff000000, 0xffff0000 }; uint32_t colorList[] = { 0xff000000, 0xffff0000 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 600; int x = (i % TWO_) * SIX_HUNDRED_;
int y = (i / 2) * 600; int y = (i / TWO_) * SIX_HUNDRED_;
auto testNodeTouch = RSCanvasNode::Create(); auto testNodeTouch = RSCanvasNode::Create();
testNodeTouch->SetBounds({ x, y, 500, 500 }); testNodeTouch->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNodeTouch->SetShadowColor(colorList[i]); testNodeTouch->SetShadowColor(colorList[i]);
testNodeTouch->SetShadowRadius(100); testNodeTouch->SetShadowRadius(ONE_HUNDRED_);
testNodeTouch->SetShadowAlpha(alphaList[i / 2]); testNodeTouch->SetShadowAlpha(alphaList[i / TWO_]);
GetRootNode()->AddChild(testNodeTouch); GetRootNode()->AddChild(testNodeTouch);
RegisterNode(testNodeTouch); RegisterNode(testNodeTouch);
} }

View File

@ -15,6 +15,7 @@
#include "rs_graphic_test.h" #include "rs_graphic_test.h"
#include "rs_graphic_test_img.h" #include "rs_graphic_test_img.h"
#include "parameters_defination.h"
using namespace testing; using namespace testing;
using namespace testing::ext; using namespace testing::ext;
@ -23,8 +24,8 @@ namespace OHOS::Rosen {
class AppearanceTest : public RSGraphicTest { class AppearanceTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -39,14 +40,14 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Spherize_Test_1)
{ {
float spherizeList[] = { 0, 0.001, 0.5, 1 }; float spherizeList[] = { 0, 0.001, 0.5, 1 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNodeSpherize = RSCanvasNode::Create(); auto testNodeSpherize = RSCanvasNode::Create();
testNodeSpherize->SetBounds({ x, y, 500, 500 }); testNodeSpherize->SetBounds({ x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
auto imageModifier = std::make_shared<ImageCustomModifier>(); auto imageModifier = std::make_shared<ImageCustomModifier>();
imageModifier->SetWidth(500); imageModifier->SetWidth(FIVE_HUNDRED_);
imageModifier->SetHeight(500); imageModifier->SetHeight(FIVE_HUNDRED_);
imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg"); imageModifier->SetPixelMapPath("/data/local/tmp/appearance_test.jpg");
testNodeSpherize->AddModifier(imageModifier); testNodeSpherize->AddModifier(imageModifier);
testNodeSpherize->SetSpherizeDegree(spherizeList[i]); testNodeSpherize->SetSpherizeDegree(spherizeList[i]);
@ -59,13 +60,13 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Spherize_Test_1)
GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Spherize_Test_2) GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_Spherize_Test_2)
{ {
auto testNodeSpherizeBlur = RSCanvasNode::Create(); auto testNodeSpherizeBlur = RSCanvasNode::Create();
testNodeSpherizeBlur->SetBounds({ 0, 0, 500, 500 }); testNodeSpherizeBlur->SetBounds({ 0, 0, FIVE_HUNDRED_, FIVE_HUNDRED_ });
auto imageModifier2 = std::make_shared<ImageCustomModifier>(); auto imageModifier2 = std::make_shared<ImageCustomModifier>();
imageModifier2->SetWidth(500); imageModifier2->SetWidth(FIVE_HUNDRED_);
imageModifier2->SetHeight(500); imageModifier2->SetHeight(FIVE_HUNDRED_);
imageModifier2->SetPixelMapPath("/data/local/tmp/appearance_test.jpg"); imageModifier2->SetPixelMapPath("/data/local/tmp/appearance_test.jpg");
testNodeSpherizeBlur->AddModifier(imageModifier2); testNodeSpherizeBlur->AddModifier(imageModifier2);
testNodeSpherizeBlur->SetForegroundEffectRadius(10); testNodeSpherizeBlur->SetForegroundEffectRadius(TEN_);
testNodeSpherizeBlur->SetSpherizeDegree(1); testNodeSpherizeBlur->SetSpherizeDegree(1);
GetRootNode()->AddChild(testNodeSpherizeBlur); GetRootNode()->AddChild(testNodeSpherizeBlur);
RegisterNode(testNodeSpherizeBlur); RegisterNode(testNodeSpherizeBlur);

View File

@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "parameters_defination.h"
#include "rs_graphic_test.h" #include "rs_graphic_test.h"
#include "rs_graphic_test_img.h" #include "rs_graphic_test_img.h"
@ -26,8 +27,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -40,10 +41,10 @@ public:
GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_ForegroundEffectRadius_Test_1) GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_ForegroundEffectRadius_Test_1)
{ {
float radiusList[] = { 0, 10.0, 100.0 }; float radiusList[] = { 0, 10.0, 100.0 };
for (int i = 0; i < 3; i++) { for (int i = 0; i < THREE_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetForegroundEffectRadius(radiusList[i]); testNode->SetForegroundEffectRadius(radiusList[i]);
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
RegisterNode(testNode); RegisterNode(testNode);
@ -54,10 +55,10 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_Saturation_Test_1)
{ {
float radiusList[] = { 10.0, 0.0, 10.0, 10.0 }; float radiusList[] = { 10.0, 0.0, 10.0, 10.0 };
float degreeList[] = { 0.0, 0.5, 0.5, 5.0 }; float degreeList[] = { 0.0, 0.5, 0.5, 5.0 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetForegroundBlurRadius(radiusList[i]); testNode->SetForegroundBlurRadius(radiusList[i]);
testNode->SetForegroundBlurSaturation(degreeList[i]); testNode->SetForegroundBlurSaturation(degreeList[i]);
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
@ -69,10 +70,10 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_Brightness_Test_1)
{ {
float radiusList[] = { 10.0, 0.0, 10.0, 10.0 }; float radiusList[] = { 10.0, 0.0, 10.0, 10.0 };
float degreeList[] = { 0.0, 0.5, 0.5, 1.5 }; float degreeList[] = { 0.0, 0.5, 0.5, 1.5 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetForegroundBlurRadius(radiusList[i]); testNode->SetForegroundBlurRadius(radiusList[i]);
testNode->SetForegroundBlurBrightness(degreeList[i]); testNode->SetForegroundBlurBrightness(degreeList[i]);
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
@ -84,10 +85,10 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_Color_Test_1)
{ {
float radiusList[] = { 10.0, 0.0, 10.0 }; float radiusList[] = { 10.0, 0.0, 10.0 };
uint32_t colorList[] = { 0x00ffffff, 0x0000ff00, 0x7d00ff00 }; uint32_t colorList[] = { 0x00ffffff, 0x0000ff00, 0x7d00ff00 };
for (int i = 0; i < 3; i++) { for (int i = 0; i < THREE_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetForegroundBlurRadius(radiusList[i]); testNode->SetForegroundBlurRadius(radiusList[i]);
testNode->SetForegroundBlurMaskColor(RSColor::FromArgbInt(colorList[i])); testNode->SetForegroundBlurMaskColor(RSColor::FromArgbInt(colorList[i]));
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
@ -97,11 +98,11 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_Color_Test_1)
GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_ColorMode_Test_1) GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_ColorMode_Test_1)
{ {
for (int i = 0; i < 3; i++) { for (int i = 0; i < THREE_; i++) {
int x = (i % 2) * 510; int x = (i % TWO_) * FIVE_HUNDRED_TEN_;
int y = (i / 2) * 510; int y = (i / TWO_) * FIVE_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 500, 500 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, FIVE_HUNDRED_, FIVE_HUNDRED_ });
testNode->SetForegroundBlurRadius(10.f); testNode->SetForegroundBlurRadius(TEN_);
testNode->SetForegroundBlurMaskColor(RSColor::FromArgbInt(0x7dff0000)); testNode->SetForegroundBlurMaskColor(RSColor::FromArgbInt(0x7dff0000));
testNode->SetForegroundBlurColorMode(i); testNode->SetForegroundBlurColorMode(i);
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
@ -113,10 +114,10 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_RadiusXY_Test_1)
{ {
float radiusX[] = { 0.0, 1.1, 10.0, 10.0 }; float radiusX[] = { 0.0, 1.1, 10.0, 10.0 };
float radiusY[] = { 0.0, 10.0, 1.1, 10.0 }; float radiusY[] = { 0.0, 10.0, 1.1, 10.0 };
for (int i = 0; i < 4; i++) { for (int i = 0; i < FOUR_; i++) {
int x = (i % 2) * 610; int x = (i % TWO_) * SIX_HUNDRED_TEN_;
int y = (i / 2) * 610; int y = (i / TWO_) * SIX_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 600, 600 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, SIX_HUNDRED_, SIX_HUNDRED_ });
testNode->SetForegroundBlurRadiusX(radiusX[i]); testNode->SetForegroundBlurRadiusX(radiusX[i]);
testNode->SetForegroundBlurRadiusY(radiusY[i]); testNode->SetForegroundBlurRadiusY(radiusY[i]);
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
@ -140,13 +141,13 @@ GRAPHIC_TEST(ForegroundTest, CONTENT_DISPLAY_TEST, Blur_LinearGradientBlur_Test_
{ std::make_pair(0.0, 0.0), std::make_pair(1.0, 1.0) }, { std::make_pair(0.0, 0.0), std::make_pair(1.0, 1.0) },
{ std::make_pair(0.0, 0.0), std::make_pair(1.0, 0.5), std::make_pair(0.0, 1.0) }, { std::make_pair(0.0, 0.0), std::make_pair(1.0, 0.5), std::make_pair(0.0, 1.0) },
}; };
for (int i = 0; i < 5; i++) { for (int i = 0; i < FIVE_; i++) {
int x = (i % 2) * 610; int x = (i % TWO_) * SIX_HUNDRED_TEN_;
int y = (i / 2) * 610; int y = (i / TWO_) * SIX_HUNDRED_TEN_;
auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, 600, 600 }); auto testNode = SetUpNodeBgImage("/data/local/tmp/fg_test.jpg", { x, y, SIX_HUNDRED_, SIX_HUNDRED_ });
testNode->SetFrame({ x, y, 600, 600 }); testNode->SetFrame({ x, y, SIX_HUNDRED_, SIX_HUNDRED_ });
std::shared_ptr<RSLinearGradientBlurPara> param( std::shared_ptr<RSLinearGradientBlurPara> param(
std::make_shared<Rosen::RSLinearGradientBlurPara>(100.f, fractionStops[i], direction[i])); std::make_shared<Rosen::RSLinearGradientBlurPara>(ONE_HUNDRED_, fractionStops[i], direction[i]));
testNode->SetLinearGradientBlurPara(param); testNode->SetLinearGradientBlurPara(param);
GetRootNode()->AddChild(testNode); GetRootNode()->AddChild(testNode);
RegisterNode(testNode); RegisterNode(testNode);

View File

@ -25,8 +25,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class ForegroundTest01 : public RSGraphicTest { class ForegroundTest01 : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class ForegroundTest02 : public RSGraphicTest { class ForegroundTest02 : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -27,8 +27,8 @@ namespace OHOS::Rosen {
class ForegroundTest : public RSGraphicTest { class ForegroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -24,8 +24,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -24,8 +24,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -22,8 +22,8 @@ namespace OHOS::Rosen {
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 Huawei Device 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.
*/
#ifndef PARAMETERS_DEFINATION_H
#define PARAMETERS_DEFINATION_H
#define ZERO_ 0
#define ONE_ 1
#define TWO_ 2
#define THREE_ 3
#define FOUR_ 4
#define FIVE_ 5
#define SIX_ 6
#define SEVEN_ 7
#define EIGHT_ 8
#define NINE_ 9
#define TEN_ 10
#define TWENTY_ 20
#define TWENTY_FIVE_ 25
#define THIRTY_ 30
#define FORTY_ 40
#define FIFTY_ 50
#define ONE_HUNDRED_ 100
#define ONE_HUNDRED_TWENTY_ 120
#define TWO_HUNDRED_ 200
#define TWO_HUNDRED_FIFTY_ 250
#define THREE_HUNDRED_ 300
#define FOUR_HUNDRED_ 400
#define FIVE_HUNDRED_ 500
#define FIVE_HUNDRED_TEN_ 510
#define FIVE_HUNDRED_TWENTY_ 520
#define FIVE_HUNDRED_SIXTY_ 560
#define SIX_HUNDRED_ 600
#define SIX_HUNDRED_TEN_ 610
#endif // PARAMETERS_DEFINATION_H

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class AppearanceTest : public RSGraphicTest { class AppearanceTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -92,6 +92,7 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_PixelStretchPercen
std::vector<Vector4f> pixelStretchList = { { 0, 0, 0, 0 }, { 0, 0.10, 0, 0 }, { 0, 0, 0.5, 0 }, { 0, 0, 0, 1.0 }, std::vector<Vector4f> pixelStretchList = { { 0, 0, 0, 0 }, { 0, 0.10, 0, 0 }, { 0, 0, 0.5, 0 }, { 0, 0, 0, 1.0 },
{ 0.1, 0.2, 0.3, 0.4 } }; { 0.1, 0.2, 0.3, 0.4 } };
Vector4f midVal = { 0.5, 0.5, 0.5, 0.5 };
std::vector<Drawing::TileMode> modeList = { Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, std::vector<Drawing::TileMode> modeList = { Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP,
Drawing::TileMode::REPEAT, Drawing::TileMode::MIRROR, Drawing::TileMode::DECAL }; Drawing::TileMode::REPEAT, Drawing::TileMode::MIRROR, Drawing::TileMode::DECAL };
@ -103,6 +104,8 @@ GRAPHIC_TEST(AppearanceTest, CONTENT_DISPLAY_TEST, Appearance_PixelStretchPercen
testNodeBackGround->SetBorderStyle(0, 0, 0, 0); testNodeBackGround->SetBorderStyle(0, 0, 0, 0);
testNodeBackGround->SetBorderWidth(5, 5, 5, 5); testNodeBackGround->SetBorderWidth(5, 5, 5, 5);
testNodeBackGround->SetBorderColor(Vector4<Color>(RgbPalette::Green())); testNodeBackGround->SetBorderColor(Vector4<Color>(RgbPalette::Green()));
// Set PixelStretch to a middle value, DTS2024092542149
testNodeBackGround->SetPixelStretchPercent(midVal, modeList[i]);
testNodeBackGround->SetPixelStretchPercent(pixelStretchList[i], modeList[i]); testNodeBackGround->SetPixelStretchPercent(pixelStretchList[i], modeList[i]);
GetRootNode()->AddChild(testNodeBackGround); GetRootNode()->AddChild(testNodeBackGround);
RegisterNode(testNodeBackGround); RegisterNode(testNodeBackGround);

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class AppearanceTest : public RSGraphicTest { class AppearanceTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -36,8 +36,8 @@ public:
class GeometryTest : public RSGraphicTest { class GeometryTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class BackgroundTest : public RSGraphicTest { class BackgroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -25,8 +25,8 @@ namespace OHOS::Rosen {
class BackgroundTest : public RSGraphicTest { class BackgroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class BackgroundTest : public RSGraphicTest { class BackgroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests
@ -181,6 +181,51 @@ GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Background_Blur_Mask_Color_Te
} }
} }
GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Background_Blur_Mask_Color_Alpha_Test)
{
int columnCount = 3;
int rowCount = 4;
auto sizeX = screenWidth / columnCount;
auto sizeY = screenHeight / rowCount;
std::vector<Color> colorList = {
Color(0xff000000), // RgbPalette::Black()
Color(0xffffffff), // RgbPalette::White()
Color(0x2dff0000), // RgbPalette::Red()
Color(0x4d00ff00), // RgbPalette::Green()
Color(0x6d0000ff), // RgbPalette::Blue()
Color(0x8d00ffff), // RgbPalette::Cyan()
Color(0xad444444), // RgbPalette::Gray()
Color(0xcdff00ff), // RgbPalette::Magenta()
Color(0x00000000), // RgbPalette::Transparent()
Color(0x10000000), // RgbPalette::Transparent()
Color(0x20000000), // RgbPalette::Transparent()
Color(0x30000000), // RgbPalette::Transparent()
};
std::vector<int> radiusList = { 10, 20, 30, 40, 50, 60, 70, 80, 90, -100, -10, 0 };
std::vector<float> saturationList = { 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 0.6, 1.0, 1.4 };
std::vector<float> brightnessList = { 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 0.6, 1.0, 1.4 };
std::vector<float> alphaList = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2 };
for (int i = 0; i < colorList.size(); i++) {
int x = (i % columnCount) * sizeX;
int y = (i / columnCount) * sizeY;
auto testNodeBackGround =
SetUpNodeBgImage("/data/local/tmp/Images/backGroundImage.jpg", { x, y, sizeX - 10, sizeY - 10 });
testNodeBackGround->SetBorderStyle(0, 0, 0, 0);
testNodeBackGround->SetBorderWidth(5, 5, 5, 5);
testNodeBackGround->SetBorderColor(Vector4<Color>(RgbPalette::Red()));
testNodeBackGround->SetBackgroundBlurRadius(radiusList[i]);
testNodeBackGround->SetBackgroundBlurSaturation(saturationList[i]);
testNodeBackGround->SetBackgroundBlurBrightness(brightnessList[i]);
testNodeBackGround->SetBackgroundBlurMaskColor(colorList[i]);
testNodeBackGround->SetAlpha(alphaList[i]);
GetRootNode()->AddChild(testNodeBackGround);
RegisterNode(testNodeBackGround);
}
}
GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Background_Blur_Color_Mode_Test) GRAPHIC_TEST(BackgroundTest, CONTENT_DISPLAY_TEST, Background_Blur_Color_Mode_Test)
{ {
int columnCount = 3; int columnCount = 3;

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class BackgroundTest : public RSGraphicTest { class BackgroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class BackgroundTest : public RSGraphicTest { class BackgroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class BackgroundTest01 : public RSGraphicTest { class BackgroundTest01 : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests

View File

@ -23,8 +23,8 @@ namespace OHOS::Rosen {
class BackgroundTest : public RSGraphicTest { class BackgroundTest : public RSGraphicTest {
private: private:
int screenWidth = 1260; const int screenWidth = 1260;
int screenHeight = 2720; const int screenHeight = 2720;
public: public:
// called before each tests // called before each tests