diff --git a/graphic/graphicnapidrawingtest/BUILD.gn b/graphic/graphicnapidrawingtest/BUILD.gn index 8e914f779f41e93b1f819597b9d9fdbc234d6119..5101466e5eed8b1ee4c5f36d135786a7c9309147 100644 --- a/graphic/graphicnapidrawingtest/BUILD.gn +++ b/graphic/graphicnapidrawingtest/BUILD.gn @@ -41,6 +41,7 @@ ohos_moduletest_suite("ActsGraphicNapiDrawingTest") { include_dirs = [ "$comPath/rosen/modules/2d_engine", + "$comPath/rosen/modules/2d_engine/rosen_text/export", "//third_party/googletest/googletest/include", ] diff --git a/graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp b/graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp index 1a156e2cb6fb2e0f50cef42a50b1d0aa5ddfebcf..6762b392387da70f3265bcf59e34c134e37bf6a3 100644 --- a/graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp +++ b/graphic/graphicnapidrawingtest/OH_Drawing_TypographyTest.cpp @@ -20,10 +20,10 @@ #include "c/drawing_font_collection.h" #include "c/drawing_text_declaration.h" #include "c/drawing_text_typography.h" -#include "rosen_text/ui/typography.h" -#include "rosen_text/ui/typography_create.h" +#include "rosen_text/typography.h" +#include "rosen_text/typography_create.h" -using namespace rosen; +using namespace OHOS::Rosen; using namespace testing; using namespace testing::ext; @@ -62,11 +62,11 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest002, TestSize.Level { OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle(); OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_LTR); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection_, TextDirection::LTR); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::LTR); OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_RTL); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection_, TextDirection::RTL); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::RTL); OH_Drawing_SetTypographyTextDirection(typoStyle, -1); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection_, TextDirection::LTR); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textDirection, TextDirection::LTR); } /* @@ -78,19 +78,19 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest003, TestSize.Level { OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle(); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_LEFT); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::LEFT); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::LEFT); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_RIGHT); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::RIGHT); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::RIGHT); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_CENTER); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::CENTER); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::CENTER); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_JUSTIFY); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::JUSTIFY); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::JUSTIFY); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_START); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::START); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::START); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_END); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::END); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::END); OH_Drawing_SetTypographyTextAlign(typoStyle, -1); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign_, TextAlign::LEFT); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->textAlign, TextAlign::LEFT); } /* @@ -102,9 +102,9 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest004, TestSize.Level { OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle(); OH_Drawing_SetTypographyTextMaxLines(typoStyle, 100); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines_, 100); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 100); OH_Drawing_SetTypographyTextMaxLines(typoStyle, 200); - EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines_, 200); + EXPECT_EQ(ConvertToOriginalText(typoStyle)->maxLines, 200); } /* @@ -129,13 +129,13 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest006, TestSize.Level OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); // black OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00)); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->color_, 0xFF000000); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFF000000); // red OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00)); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->color_, 0xFFFF0000); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFFFF0000); // blue OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0xFF)); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->color_, 0xFF0000FF); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->color, 0xFF0000FF); } /* @@ -147,9 +147,9 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest007, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleFontSize(txtStyle, 80); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize_, 80); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, 80); OH_Drawing_SetTextStyleFontSize(txtStyle, 40); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize_, 40); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontSize, 40); } /* @@ -161,25 +161,25 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest008, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_100); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W100); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W100); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_200); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W200); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W200); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_300); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W300); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W300); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W400); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W400); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_500); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W500); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W500); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_600); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W600); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W600); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_700); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W700); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W700); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_800); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W800); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W800); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_900); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W900); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W900); OH_Drawing_SetTextStyleFontWeight(txtStyle, -1); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight_, FontWeight::W400); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontWeight, FontWeight::W400); } /* @@ -191,11 +191,11 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest009, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->textBaseline_, TextBaseline::ALPHABETIC); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::ALPHABETIC); OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_IDEOGRAPHIC); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->textBaseline_, TextBaseline::IDEOGRAPHIC); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::IDEOGRAPHIC); OH_Drawing_SetTextStyleBaseLine(txtStyle, -1); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->textBaseline_, TextBaseline::ALPHABETIC); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->baseline, TextBaseline::ALPHABETIC); } /* @@ -207,15 +207,15 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest010, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_NONE); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::NONE); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE); OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_UNDERLINE); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::UNDERLINE); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::UNDERLINE); OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_OVERLINE); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::OVERLINE); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::OVERLINE); OH_Drawing_SetTextStyleDecoration(txtStyle, TEXT_DECORATION_LINE_THROUGH); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::LINETHROUGH); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::LINE_THROUGH); OH_Drawing_SetTextStyleDecoration(txtStyle, -1); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration_, TextDecoration::NONE); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decoration, TextDecoration::NONE); } /* @@ -227,9 +227,9 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest011, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleDecorationColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00)); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor_, 0xFF000000); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor, 0xFF000000); OH_Drawing_SetTextStyleDecorationColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00)); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor_, 0xFFFF0000); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->decorationColor, 0xFFFF0000); } /* @@ -241,7 +241,7 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest012, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleFontHeight(txtStyle, 0.0); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->height_, 0.0); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->heightScale, 0.0); } /* @@ -255,7 +255,7 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest013, TestSize.Level const char* fontFamilies[] = {"Roboto"}; OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, fontFamilies); std::vector fontFamiliesResult = {"Roboto"}; - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontFamilies_, fontFamiliesResult); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontFamilies, fontFamiliesResult); } /* @@ -267,11 +267,11 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest014, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle_, FontStyle::NORMAL); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::NORMAL); OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_ITALIC); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle_, FontStyle::ITALIC); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::ITALIC); OH_Drawing_SetTextStyleFontStyle(txtStyle, -1); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle_, FontStyle::NORMAL); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->fontStyle, FontStyle::NORMAL); } /* @@ -283,7 +283,7 @@ HWTEST_F(OH_Drawing_TypographyTest, OH_Drawing_TypographyTest015, TestSize.Level { OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleLocale(txtStyle, "en"); - EXPECT_EQ(ConvertToOriginalText(txtStyle)->locale_, "en"); + EXPECT_EQ(ConvertToOriginalText(txtStyle)->locale, "en"); } /*