From 184fda639142bcdf4c6e66d500095a05b33eb4ff Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Tue, 9 May 2023 16:49:28 +0800 Subject: [PATCH 01/99] [components/search] use Drawing interface Change-Id: I323a4d5a7050c89395b9c6ee66b220f484c60cbf Signed-off-by: huangzejia1 --- .../components/search/rosen_render_search.cpp | 70 ++++++++++++++++++- .../components/search/rosen_render_search.h | 9 ++- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components/search/rosen_render_search.cpp b/frameworks/core/components/search/rosen_render_search.cpp index b5a3e3b4026..85a541777fa 100644 --- a/frameworks/core/components/search/rosen_render_search.cpp +++ b/frameworks/core/components/search/rosen_render_search.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,7 +15,9 @@ #include "core/components/search/rosen_render_search.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkRRect.h" +#endif #include "core/pipeline/base/rosen_render_context.h" @@ -41,6 +43,7 @@ void RosenRenderSearch::Paint(RenderContext& context, const Offset& offset) // Paint divider. if (renderSearchBox_) { +#ifndef USE_ROSEN_DRAWING SkCanvas* canvas = GetSkCanvas(context); SkPaint paint; if (canvas != nullptr) { @@ -56,6 +59,25 @@ void RosenRenderSearch::Paint(RenderContext& context, const Offset& offset) paint.setColor(SEARCH_DIVIDER_COLOR.GetValue()); canvas->drawRect(SkRect::MakeXYWH(rect.Left(), rect.Top(), rect.Width(), rect.Height()), paint); canvas->restore(); +#else + RSCanvas* canvas = GetDrawingCanvas(context); + RSPen pen; + if (canvas != nullptr) { + double dividerVerticalOffset = (GetLayoutSize().Height() - NormalizeToPx(ICON_HEIGHT)) / 2.0; + Offset dividerOffset = Offset(searchTextRect_.GetOffset().GetX(), dividerVerticalOffset); + if (needReverse_) { + dividerOffset = searchTextRect_.GetOffset() + + Offset(searchTextRect_.Width() - SEARCH_DIVIDER_WIDTH, dividerVerticalOffset); + } + dividerOffset += offset; + Rect rect(dividerOffset, Size(SEARCH_DIVIDER_WIDTH, NormalizeToPx(ICON_HEIGHT))); + canvas->Save(); + pen.SetColor(SEARCH_DIVIDER_COLOR.GetValue()); + canvas->AttachPen(pen); + canvas->DrawRect(RSRect(rect.Left(), rect.Top(), rect.Width() + rect.Left(), rect.Height() + rect.Top())); + canvas->DetachPen(); + canvas->Restore(); +#endif } // Paint search text. @@ -118,6 +140,7 @@ void RosenRenderSearch::PaintOverlayForHoverAndPress(RenderContext& context, con return; } +#ifndef USE_ROSEN_DRAWING SkCanvas* canvas = GetSkCanvas(context); if (canvas == nullptr) { LOGE("canvas is null!"); @@ -127,6 +150,17 @@ void RosenRenderSearch::PaintOverlayForHoverAndPress(RenderContext& context, con SkPaint paint; // Background overlay 10% opacity black when hover. paint.setColor(overlayColor_.GetValue()); +#else + RSCanvas* canvas = GetDrawingCanvas(context); + if (canvas == nullptr) { + LOGE("canvas is null!"); + return; + } + canvas->Save(); + RSPen pen; + // Background overlay 10% opacity black when hover. + pen.SetColor(overlayColor_.GetValue()); +#endif Offset rectOffset; Size rectSize; @@ -141,10 +175,18 @@ void RosenRenderSearch::PaintOverlayForHoverAndPress(RenderContext& context, con Border border; border.SetBorderRadius(Radius(rectSize.Height() / 2.0)); +#ifndef USE_ROSEN_DRAWING canvas->drawRRect(MakeRRect(rectOffset + offset, rectSize, border), paint); canvas->restore(); +#else + canvas->AttachPen(pen); + canvas->DrawRoundRect(MakeRRect(rectOffset + offset, rectSize, border)); + canvas->DetachPen(); + canvas->Restore(); +#endif } +#ifndef USE_ROSEN_DRAWING SkRRect RosenRenderSearch::MakeRRect(const Offset& offset, const Size& size, const Border& border) { SkRect rect = SkRect::MakeXYWH(offset.GetX(), offset.GetY(), size.Width(), size.Height()); @@ -161,8 +203,32 @@ SkRRect RosenRenderSearch::MakeRRect(const Offset& offset, const Size& size, con rrect.setRectRadii(rect, rectRadii); return rrect; } +#else +RSRoundRect RosenRenderSearch::MakeRRect(const Offset& offset, const Size& size, const Border& border) +{ + RSRect rect( + offset.GetX(), offset.GetY(), offset.GetX() + size.Width(), offset.GetY() + size.Height()); + std::vector rectRadii(4); + rectRadii.at(RSRoundRect::CornerPos::TOP_LEFT_POS) = RSPoint( + NormalizeToPx(border.TopLeftRadius().GetX()), NormalizeToPx(border.TopLeftRadius().GetY())); + rectRadii.at(RSRoundRect::CornerPos::TOP_RIGHT_POS) = RSPoint( + NormalizeToPx(border.TopRightRadius().GetX()), NormalizeToPx(border.TopRightRadius().GetY())); + rectRadii.at(RSRoundRect::CornerPos::BOTTOM_RIGHT_POS) = RSPoint( + NormalizeToPx(border.BottomRightRadius().GetX()), NormalizeToPx(border.BottomRightRadius().GetY())); + rectRadii.at(RSRoundRect::CornerPos::BOTTOM_LEFT_POS) = RSPoint( + NormalizeToPx(border.BottomLeftRadius().GetX()), NormalizeToPx(border.BottomLeftRadius().GetY())); + + RSRoundRect rrect(rect, rectRadii); + return rrect; +} +#endif + +#ifndef USE_ROSEN_DRAWING SkCanvas* RosenRenderSearch::GetSkCanvas(RenderContext& context) +#else +RSCanvas* RosenRenderSearch::GetDrawingCanvas(RenderContext& context) +#endif { auto renderContext = AceType::DynamicCast(&context); if (!renderContext) { @@ -176,4 +242,4 @@ SkCanvas* RosenRenderSearch::GetSkCanvas(RenderContext& context) return canvas; } -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace diff --git a/frameworks/core/components/search/rosen_render_search.h b/frameworks/core/components/search/rosen_render_search.h index 02821f410c5..aaafb541ffc 100644 --- a/frameworks/core/components/search/rosen_render_search.h +++ b/frameworks/core/components/search/rosen_render_search.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -16,7 +16,9 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SEARCH_ROSEN_RENDER_SEARCH_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SEARCH_ROSEN_RENDER_SEARCH_H +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" +#endif #include "core/components/search/render_search.h" #include "core/pipeline/base/rosen_render_context.h" @@ -32,8 +34,13 @@ public: private: void PaintFocus(); void PaintOverlayForHoverAndPress(RenderContext& context, const Offset& offset); +#ifndef USE_ROSEN_DRAWING SkRRect MakeRRect(const Offset& offset, const Size& size, const Border& border); SkCanvas* GetSkCanvas(RenderContext& context); +#else + RSRoundRect MakeRRect(const Offset& offset, const Size& size, const Border& border); + RSCanvas* GetDrawingCanvas(RenderContext& context); +#endif }; } // namespace OHOS::Ace From b0332a775942d6d89922507a312f00013b89bff3 Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Tue, 9 May 2023 17:02:43 +0800 Subject: [PATCH 02/99] [components/shape][1/2] use Drawing interface Change-Id: Icbe88bdc6b889b3046ee54c97355596061f3cd89 Signed-off-by: huangzejia1 --- .../components/shape/rosen_render_shape.cpp | 125 +++++++++++++++++- .../components/shape/rosen_render_shape.h | 16 ++- 2 files changed, 138 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components/shape/rosen_render_shape.cpp b/frameworks/core/components/shape/rosen_render_shape.cpp index 59116f3dc27..d932c21248c 100644 --- a/frameworks/core/components/shape/rosen_render_shape.cpp +++ b/frameworks/core/components/shape/rosen_render_shape.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,9 +15,11 @@ #include "core/components/shape/rosen_render_shape.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkPaint.h" #include "include/effects/SkDashPathEffect.h" #include "include/utils/SkParsePath.h" +#endif #include "core/pipeline/base/rosen_render_context.h" #include "frameworks/core/components/common/painter/rosen_svg_painter.h" @@ -34,9 +36,15 @@ Size RosenRenderShape::CalcSize() case ShapeType::ELLIPSE: return CreateEllipse(); case ShapeType::LINE: +#ifndef USE_ROSEN_DRAWING path_.reset(); path_.moveTo(NormalizePercentToPx(start_.first, false), NormalizePercentToPx(start_.second, true)); path_.lineTo(NormalizePercentToPx(end_.first, false), NormalizePercentToPx(end_.second, true)); +#else + path_.Reset(); + path_.MoveTo(NormalizePercentToPx(start_.first, false), NormalizePercentToPx(start_.second, true)); + path_.LineTo(NormalizePercentToPx(end_.first, false), NormalizePercentToPx(end_.second, true)); +#endif break; case ShapeType::POLYLINE: return CreatePolygon(false); @@ -48,11 +56,19 @@ Size RosenRenderShape::CalcSize() LOGE("invalid shapeType"); return Size(); } +#ifndef USE_ROSEN_DRAWING auto skRect = path_.getBounds(); if (width_.IsValid() && height_.IsValid()) { return Size(NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); } return Size(skRect.right(), skRect.bottom()); +#else + auto rect = path_.GetBounds(); + if (width_.IsValid() && height_.IsValid()) { + return Size(NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); + } + return Size(rect.GetRight(), rect.GetBottom()); +#endif } Size RosenRenderShape::CreateRect() @@ -60,8 +76,13 @@ Size RosenRenderShape::CreateRect() if (!GetLayoutParam().GetMaxSize().IsValid()) { return Size(); } +#ifndef USE_ROSEN_DRAWING SkRect rect = SkRect::MakeLTRB(0.0f, 0.0f, NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); +#else + RSRect rect = + RSRect(0.0f, 0.0f, NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); +#endif float topLeftRadiusX = GetFloatRadiusValue(topLeftRadius_.GetX(), topLeftRadius_.GetY(), false); float topLeftRadiusY = GetFloatRadiusValue(topLeftRadius_.GetY(), topLeftRadius_.GetX(), true); float topRightRadiusX = GetFloatRadiusValue(topRightRadius_.GetX(), topRightRadius_.GetY(), false); @@ -70,6 +91,7 @@ Size RosenRenderShape::CreateRect() float bottomRightRadiusY = GetFloatRadiusValue(bottomRightRadius_.GetY(), bottomRightRadius_.GetX(), true); float bottomLeftRadiusX = GetFloatRadiusValue(bottomLeftRadius_.GetX(), bottomLeftRadius_.GetY(), false); float bottomLeftRadiusY = GetFloatRadiusValue(bottomLeftRadius_.GetY(), bottomLeftRadius_.GetX(), true); +#ifndef USE_ROSEN_DRAWING const SkVector fRadii[4] = { { topLeftRadiusX, topLeftRadiusY }, { topRightRadiusX, topRightRadiusY }, { bottomRightRadiusX, bottomRightRadiusY }, { bottomLeftRadiusX, bottomLeftRadiusY } }; path_.reset(); @@ -78,6 +100,16 @@ Size RosenRenderShape::CreateRect() path_.addRRect(roundRect); auto skRect = path_.getBounds(); return Size(skRect.right(), skRect.bottom()); +#else + std::vector fRadii = { { topLeftRadiusX, topLeftRadiusY }, { topRightRadiusX, topRightRadiusY }, + { bottomRightRadiusX, bottomRightRadiusY }, { bottomLeftRadiusX, bottomLeftRadiusY } }; + path_.Reset(); + RSRoundRect roundRect; + roundRect.SetRectRadii(rect, fRadii); + path_.AddRoundRect(roundRect); + auto drRect = path_.GetBounds(); + return Size(drRect.GetRight(), drRect.GetBottom()); +#endif } float RosenRenderShape::GetFloatRadiusValue(const Dimension& src, const Dimension& dest, bool isVertical) @@ -93,10 +125,18 @@ Size RosenRenderShape::CreateCircle() if (!GetLayoutParam().GetMaxSize().IsValid()) { return Size(); } +#ifndef USE_ROSEN_DRAWING path_.reset(); +#else + path_.Reset(); +#endif double width = NormalizePercentToPx(width_, false); double height = NormalizePercentToPx(height_, true); +#ifndef USE_ROSEN_DRAWING path_.addCircle(width * 0.5, height * 0.5, std::min(width, height) * 0.5); +#else + path_.AddCircle(width * 0.5, height * 0.5, std::min(width, height) * 0.5); +#endif return Size(width, height); } @@ -105,16 +145,25 @@ Size RosenRenderShape::CreateEllipse() if (!GetLayoutParam().GetMaxSize().IsValid()) { return Size(); } +#ifndef USE_ROSEN_DRAWING path_.reset(); auto width = NormalizePercentToPx(width_, false); auto height = NormalizePercentToPx(height_, true); SkRect rect = SkRect::MakeXYWH(0.0f, 0.0f, width, height); path_.addOval(rect); +#else + path_.Reset(); + auto width = NormalizePercentToPx(width_, false); + auto height = NormalizePercentToPx(height_, true); + auto rect = RSRect(0.0f, 0.0f, width, height); + path_.AddOval(rect); +#endif return Size(width, height); } Size RosenRenderShape::CreatePolygon(bool needClose) { +#ifndef USE_ROSEN_DRAWING path_.reset(); std::vector skPoints; for (auto point : points_) { @@ -130,6 +179,23 @@ Size RosenRenderShape::CreatePolygon(bool needClose) return Size(NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); } return Size(skRect.right(), skRect.bottom()); +#else + path_.Reset(); + std::vector points; + for (auto point : points_) { + points.emplace_back( + RSPoint(NormalizePercentToPx(point.first, false), NormalizePercentToPx(point.second, true))); + } + if (points.empty()) { + return Size(); + } + path_.AddPoly(points, points.size(), needClose); + auto rect = path_.GetBounds(); + if (width_.IsValid() && height_.IsValid()) { + return Size(NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); + } + return Size(rect.GetRight(), rect.GetBottom()); +#endif } Size RosenRenderShape::CreatePath() @@ -137,8 +203,13 @@ Size RosenRenderShape::CreatePath() if (pathCmd_.GetValue().empty()) { return Size(); } +#ifndef USE_ROSEN_DRAWING path_.reset(); bool ret = SkParsePath::FromSVGString(pathCmd_.GetValue().c_str(), &path_); +#else + path_.Reset(); + bool ret = path_.BuildFromSVGString(pathCmd_.GetValue()); +#endif if (width_.IsValid() && height_.IsValid()) { return Size(NormalizePercentToPx(width_, false), NormalizePercentToPx(height_, true)); } @@ -146,6 +217,7 @@ Size RosenRenderShape::CreatePath() LOGW("path value is invalid"); return Size(); } +#ifndef USE_ROSEN_DRAWING auto skRect = path_.getBounds(); auto right = skRect.right(); auto bottom = skRect.bottom(); @@ -160,6 +232,22 @@ Size RosenRenderShape::CreatePath() bottom = lineWidth.ConvertToPx(); } return Size(right, bottom); +#else + auto rect = path_.GetBounds(); + auto right = rect.GetRight(); + auto bottom = rect.GetBottom(); + if (NearZero(right) && NearZero(bottom)) { + return Size(); + } + auto lineWidth = strokeState_.GetLineWidth(); + if (NearZero(right)) { + right = lineWidth.ConvertToPx(); + } + if (NearZero(bottom)) { + bottom = lineWidth.ConvertToPx(); + } + return Size(right, bottom); +#endif } void RosenRenderShape::Paint(RenderContext& context, const Offset& offset) @@ -173,6 +261,7 @@ void RosenRenderShape::Paint(RenderContext& context, const Offset& offset) PaintOnCanvas(canvas, offset); } +#ifndef USE_ROSEN_DRAWING void RosenRenderShape::PaintOnCanvas(SkCanvas* skCanvas, const Offset& offset) { SkPath path = path_; @@ -180,7 +269,17 @@ void RosenRenderShape::PaintOnCanvas(SkCanvas* skCanvas, const Offset& offset) RosenSvgPainter::SetFillStyle(skCanvas, path, fillState_, UINT8_MAX, antiAlias_.second); DrawStroke(skCanvas, path); } +#else +void RosenRenderShape::PaintOnCanvas(RSCanvas* canvas, const Offset& offset) +{ + RSPath path = path_; + path_.Offset(offset.GetX(), offset.GetY()); + RosenSvgPainter::SetFillStyle(canvas, path, fillState_, UINT8_MAX, antiAlias_.second); + DrawStroke(canvas, path); +} +#endif +#ifndef USE_ROSEN_DRAWING void RosenRenderShape::DrawStroke(SkCanvas* skCanvas, const SkPath& path) { if (strokeState_.GetColor() != Color::TRANSPARENT && GreatNotEqual(strokeState_.GetLineWidth().Value(), 0.0)) { @@ -199,5 +298,27 @@ void RosenRenderShape::DrawStroke(SkCanvas* skCanvas, const SkPath& path) skCanvas->drawPath(path, strokePaint); } } +#else +void RosenRenderShape::DrawStroke(RSCanvas* canvas, const RSPath& path) +{ + if (strokeState_.GetColor() != Color::TRANSPARENT && GreatNotEqual(strokeState_.GetLineWidth().Value(), 0.0)) { + RSPen strokePen; + RosenSvgPainter::SetStrokeStyle(strokePen, strokeState_, UINT8_MAX, antiAlias_.second); + strokePen.SetWidth(NormalizePercentToPx(strokeState_.GetLineWidth(), false)); + if (!strokeState_.GetStrokeDashArray().empty()) { + auto lineDashState = strokeState_.GetStrokeDashArray(); + RSscalar intervals[lineDashState.size()]; + for (size_t i = 0; i < lineDashState.size(); ++i) { + intervals[i] = DoubleToScalar(NormalizePercentToPx(lineDashState[i], false)); + } + RSscalar phase = DoubleToScalar(NormalizePercentToPx(strokeState_.GetStrokeDashOffset(), false)); + strokePen.SetPathEffect(RSPathEffect::CreateDashPathEffect(intervals, lineDashState.size(), phase)); + } + canvas->AttachPen(strokePen); + canvas->DrawPath(path); + canvas->DetachPen(); + } +} +#endif -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace diff --git a/frameworks/core/components/shape/rosen_render_shape.h b/frameworks/core/components/shape/rosen_render_shape.h index 87adacae858..5d62850c1a0 100644 --- a/frameworks/core/components/shape/rosen_render_shape.h +++ b/frameworks/core/components/shape/rosen_render_shape.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -16,8 +16,10 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHAPE_ROSEN_RENDER_SHAPE_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SHAPE_ROSEN_RENDER_SHAPE_H +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkPath.h" +#endif #include "core/components/shape/render_shape.h" @@ -29,7 +31,11 @@ class RosenRenderShape : public RenderShape { public: void Paint(RenderContext& context, const Offset& offset) override; Size CalcSize() override; +#ifndef USE_ROSEN_DRAWING void PaintOnCanvas(SkCanvas* skCanvas, const Offset& offset); +#else + void PaintOnCanvas(Rosen::RSCanvas* canvas, const Offset& offset); +#endif private: Size CreateRect(); @@ -37,10 +43,18 @@ private: Size CreateEllipse(); Size CreatePolygon(bool needClose); Size CreatePath(); +#ifndef USE_ROSEN_DRAWING void DrawStroke(SkCanvas* skCanvas, const SkPath& path); +#else + void DrawStroke(Rosen::RSCanvas* canvas, const Rosen::RSPath& path); +#endif float GetFloatRadiusValue(const Dimension& src, const Dimension& dest, bool isVertical); +#ifndef USE_ROSEN_DRAWING SkPath path_; +#else + Rosen::RSRecordingPath path_; +#endif }; } // namespace OHOS::Ace From bdcdbfd4cb258579476563b33ebc7a49fefb6cfc Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Tue, 9 May 2023 19:12:06 +0800 Subject: [PATCH 03/99] [components/shadow] use Drawing interface Change-Id: Ic49c742856580338096e4bd6c75c9315b3e62f4f Signed-off-by: huangzejia1 --- .../components/shadow/rosen_render_shadow.cpp | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/frameworks/core/components/shadow/rosen_render_shadow.cpp b/frameworks/core/components/shadow/rosen_render_shadow.cpp index 578328ab669..68617e09bb8 100644 --- a/frameworks/core/components/shadow/rosen_render_shadow.cpp +++ b/frameworks/core/components/shadow/rosen_render_shadow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,10 +15,12 @@ #include "core/components/shadow/rosen_render_shadow.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkMaskFilter.h" #include "include/core/SkRRect.h" +#endif #include "core/pipeline/base/rosen_render_context.h" @@ -44,15 +46,25 @@ void RosenRenderShadow::Paint(RenderContext& context, const Offset& offset) } if (isNeedClip_) { +#ifndef USE_ROSEN_DRAWING canvas->clipRect(SkRect::MakeXYWH(clipRect_.GetOffset().GetX() - NormalizeToPx(SHADOW_OFFSET) / 2, clipRect_.GetOffset().GetY(), clipRect_.Width() + NormalizeToPx(SHADOW_OFFSET), clipRect_.Height() + NormalizeToPx(SHADOW_OFFSET)), true); +#else + canvas->ClipRect( + RSRect(clipRect_.GetOffset().GetX() - NormalizeToPx(SHADOW_OFFSET) / 2, + clipRect_.GetOffset().GetY(), + clipRect_.Width() - NormalizeToPx(SHADOW_OFFSET) / 2 + clipRect_.GetOffset().GetX(), + clipRect_.Height() + NormalizeToPx(SHADOW_OFFSET) + clipRect_.GetOffset().GetY(),), + true); +#endif } double radiusX = NormalizeToPx(rrect_.GetCorner().bottomLeftRadius.GetX()); double radiusY = NormalizeToPx(rrect_.GetCorner().bottomLeftRadius.GetY()); +#ifndef USE_ROSEN_DRAWING SkPaint paint; paint.setColor(SkColorSetARGB(SHADOW_COLOR_ALPHA, 0, 0, 0)); paint.setStyle(SkPaint::Style::kStrokeAndFill_Style); @@ -62,6 +74,27 @@ void RosenRenderShadow::Paint(RenderContext& context, const Offset& offset) rect = SkRect::MakeXYWH( offset_.GetX(), offset_.GetY() + NormalizeToPx(SHADOW_OFFSET), rrect_.Width(), rrect_.Height()); canvas->drawRRect(SkRRect::MakeRectXY(rect, radiusX, radiusY), paint); +#else + RSPen pen; + RSBrush brush; + pen.SetColor(RSColor::ColorQuadSetARGB(SHADOW_COLOR_ALPHA, 0, 0, 0)); + brush.SetColor(RSColor::ColorQuadSetARGB(SHADOW_COLOR_ALPHA, 0, 0, 0)); + RSFilter filter; + filter.SetMaskFilter( + RSMaskFilter::CreateBlurMaskFilter(RSBlurType::NORMAL, SHADOW_BLUR_RADIUS)); + pen.SetFilter(filter); + brush.SetFilter(filter); + RSRect rect( + offset_.GetX(), offset_.GetY(), offset_.GetX() + rrect_.Width(), offset_.GetY() + rrect_.Height()); + canvas->ClipRoundRect(RSRoundRect(rect, radiusX, radiusY), RSClipOp::DIFFERENCE, true); + rect = RSRect(offset_.GetX(), offset_.GetY() + NormalizeToPx(SHADOW_OFFSET), + rrect_.Width() + offset_.GetX(), rrect_.Height() + offset_.GetY() + NormalizeToPx(SHADOW_OFFSET)); + canvas->AttachPen(pen); + canvas->AttachBrush(brush); + canvas->DrawRoundRect(RSRoundRect(rect, radiusX, radiusY)); + canvas->DetachPen(); + canvas->DetachBrush(); +#endif } } // namespace OHOS::Ace From 7dd489326b596817c51548c455aff293198d8b81 Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Tue, 9 May 2023 19:13:00 +0800 Subject: [PATCH 04/99] [components/side_bar] use Drawing interface Change-Id: I61f55bebea7c7972b200a584691df0ee352906e2 Signed-off-by: huangzejia1 --- .../components/side_bar/render_side_bar_container.cpp | 6 +++++- .../side_bar/rosen_render_side_bar_container.cpp | 11 ++++++++++- .../side_bar/side_bar_container_component.cpp | 6 +++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components/side_bar/render_side_bar_container.cpp b/frameworks/core/components/side_bar/render_side_bar_container.cpp index 49f54f3e586..5f6439497fa 100644 --- a/frameworks/core/components/side_bar/render_side_bar_container.cpp +++ b/frameworks/core/components/side_bar/render_side_bar_container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -497,7 +497,11 @@ void RenderSideBarContainer::UpdateRenderImage() imageComponent->SetSrc(sideBar_->GetSwitchIcon()); } } +#ifndef USE_ROSEN_DRAWING imageComponent->SetUseSkiaSvg(false); +#else + imageComponent->SetUseDrawingSvg(false); +#endif imageComponent->SetImageFit(ImageFit::FILL); renderImage->Update(imageComponent); } diff --git a/frameworks/core/components/side_bar/rosen_render_side_bar_container.cpp b/frameworks/core/components/side_bar/rosen_render_side_bar_container.cpp index 3209335d8c0..f05871a2d70 100644 --- a/frameworks/core/components/side_bar/rosen_render_side_bar_container.cpp +++ b/frameworks/core/components/side_bar/rosen_render_side_bar_container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -15,7 +15,9 @@ #include "core/components/side_bar/rosen_render_side_bar_container.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkPath.h" +#endif #include "render_service_client/core/ui/rs_node.h" #include "core/pipeline/base/rosen_render_context.h" @@ -31,9 +33,16 @@ void RosenRenderSideBarContainer::Paint(RenderContext& context, const Offset& of rsNode->SetClipToBounds(true); auto paintRect = GetPaintRect(); +#ifndef USE_ROSEN_DRAWING SkPath skPath; skPath.addRect(SkRect::MakeXYWH(paintRect.Left(), paintRect.Top(), paintRect.Width(), paintRect.Height())); rsNode->SetClipBounds(Rosen::RSPath::CreateRSPath(skPath)); +#else + RSRecordingPath dPath; + dPath.AddRect(RSRect(paintRect.GetLeft(), paintRect.GetTop(), + paintRect.GetWidth() + paintRect.GetLeft(), paintRect.GetHeight())); + rsNode->SetClipBounds(Rosen::RSPath::CreateRSPath(dPath)); +#endif RenderNode::Paint(context, offset); } diff --git a/frameworks/core/components/side_bar/side_bar_container_component.cpp b/frameworks/core/components/side_bar/side_bar_container_component.cpp index c3d762419d9..1647af076e5 100644 --- a/frameworks/core/components/side_bar/side_bar_container_component.cpp +++ b/frameworks/core/components/side_bar/side_bar_container_component.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -61,7 +61,11 @@ RefPtr SideBarContainerComponent::BuildButton() imageComponent->SetSrc(GetHiddenIcon()); } } +#ifndef USE_ROSEN_DRAWING imageComponent->SetUseSkiaSvg(false); +#else + imageComponent->SetUseDrawingSvg(false); +#endif imageComponent->SetImageFit(ImageFit::FILL); return imageComponent; } From 5ad28c5caa5e30af8771d2cfc88951983ca6987a Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Tue, 9 May 2023 19:13:45 +0800 Subject: [PATCH 05/99] [components/slider] use Drawing interface Change-Id: I021bbd71be167889d5b7ea343d539404f429f882 Signed-off-by: huangzejia1 --- .../slider/rosen_render_circle_block.cpp | 119 +++++++++++++++++- .../slider/rosen_render_circle_block.h | 4 +- .../components/slider/rosen_render_slider.cpp | 23 +++- 3 files changed, 142 insertions(+), 4 deletions(-) diff --git a/frameworks/core/components/slider/rosen_render_circle_block.cpp b/frameworks/core/components/slider/rosen_render_circle_block.cpp index 468f10b598e..2521812d1c3 100644 --- a/frameworks/core/components/slider/rosen_render_circle_block.cpp +++ b/frameworks/core/components/slider/rosen_render_circle_block.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,9 +15,11 @@ #include "core/components/slider/rosen_render_circle_block.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkMaskFilter.h" #include "include/core/SkPath.h" #include "include/core/SkRRect.h" +#endif #include "base/utils/system_properties.h" #include "core/components/common/painter/rosen_decoration_painter.h" @@ -57,6 +59,7 @@ void RosenRenderCircleBlock::SyncGeometryProperties() double radius = NormalizeToPx(blockSize_) * HALF * radiusScale_; double diameter = radius * 2.0; auto frame = rsNode->GetStagingProperties().GetFrame(); +#ifndef USE_ROSEN_DRAWING SkRect rect = SkRect::MakeXYWH(frame.x_ - radius, frame.y_ - radius, diameter, diameter); float elevationOfDefaultShadowXS = 4.0f; @@ -88,6 +91,50 @@ void RosenRenderCircleBlock::SyncGeometryProperties() offsetX = shadowRect.width() * HALF; offsetY = shadowRect.height() * HALF; } +#else + RSRect rect = + RSRect(frame.x_ - radius, frame.y_ - radius, + diameter + frame.x_ - radius, diameter + frame.y_ - radius); + + float elevationOfDefaultShadowXS = 4.0f; + float transRatio = elevationOfDefaultShadowXS / (LIGHT_HEIGHT - elevationOfDefaultShadowXS); + float spotRatio = LIGHT_HEIGHT / (LIGHT_HEIGHT - elevationOfDefaultShadowXS); + + auto spotRect = RSRect(rect.GetLeft() * spotRatio, rect.GetTop() * spotRatio, + rect.GetRight() * spotRatio, rect.GetBottom() * spotRatio); + spotRect.Offset(-transRatio * LIGHT_POSITION_X, -transRatio * LIGHT_POSITION_Y); + spotRect.SetLeft(spotRect.GetLeft() - transRatio * LIGHT_RADIUS); + spotRect.SetTop(spotRect.GetTop() - transRatio * LIGHT_RADIUS); + spotRect.SetRight(spotRect.GetRight() + transRatio * LIGHT_RADIUS); + spotRect.SetBottom(shadspotRectowRect.GetBottom() + transRatio * LIGHT_RADIUS); + + RSRect shadowRect(rect); + float ambientBlur = 2.0f; + shadowRect.SetLeft(shadowRect.GetLeft() - ambientBlur); + shadowRect.SetTop(shadowRect.GetTop() - ambientBlur); + shadowRect.SetRight(shadowRect.GetRight() + ambientBlur); + shadowRect.SetBottom(shadowRect.GetBottom() + ambientBlur); + shadowRect.Join(spotRect); + shadowRect.SetLeft(shadowRect.GetLeft() - 1); + shadowRect.SetTop(shadowRect.GetTop() - 1); + shadowRect.SetRight(shadowRect.GetRight() + 1); + shadowRect.SetBottom(shadowRect.GetBottom() + 1); + + float offsetX = 0.0f; + float offsetY = 0.0f; + if (isHover_) { + double hoverRadius = NormalizeToPx(HOVER_RADIUS); + offsetX = hoverRadius > shadowRect.GetWidth() * HALF ? hoverRadius : shadowRect.GetWidth() * HALF; + offsetY = hoverRadius > shadowRect.GetHeight() * HALF ? hoverRadius : shadowRect.GetHeight() * HALF; + } else if (isPress_) { + double pressRadius = NormalizeToPx(PRESS_RADIUS); + offsetX = pressRadius > shadowRect.GetWidth() * HALF ? pressRadius : shadowRect.GetWidth() * HALF; + offsetY = pressRadius > shadowRect.GetHeight() * HALF ? pressRadius : shadowRect.GetHeight() * HALF; + } else { + offsetX = shadowRect.GetWidth() * HALF; + offsetY = shadowRect.GetHeight() * HALF; + } +#endif rsNode->SetFrame(frame.x_ - offsetX, frame.y_ - offsetY, frame.z_ + offsetX, frame.w_ + offsetY); } @@ -101,6 +148,7 @@ void RosenRenderCircleBlock::Paint(RenderContext& context, const Offset& offset) return; } +#ifndef USE_ROSEN_DRAWING if (isHover_) { SkPaint hoverPaint; hoverPaint.setColor(HOVER_BORDER_COLOR); @@ -114,11 +162,31 @@ void RosenRenderCircleBlock::Paint(RenderContext& context, const Offset& offset) double pressRadius = NormalizeToPx(PRESS_RADIUS); canvas->drawCircle(offset.GetX(), offset.GetY(), pressRadius, pressPaint); } +#else + if (isHover_) { + RSPen hoverPen; + hoverPen.SetColor(HOVER_BORDER_COLOR); + double hoverRadius = NormalizeToPx(HOVER_RADIUS); + canvas->AttachPen(hoverPen); + canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), hoverRadius); + canvas->DetachPen(); + } + + if (isPress_) { + RSPen pressPen; + pressPen.SetColor(PRESS_BORDER_COLOR); + double pressRadius = NormalizeToPx(PRESS_RADIUS); + canvas->AttachPen(pressPen); + canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), pressRadius); + canvas->DetachPen(); + } +#endif double radius = NormalizeToPx(blockSize_) * HALF * radiusScale_; PaintShadow(context, offset, radius); +#ifndef USE_ROSEN_DRAWING if (GetFocus() && GetMode() == SliderMode::OUTSET) { SkPaint focusPaint; focusPaint.setColor(FOCUS_BORDER_COLOR); @@ -148,14 +216,61 @@ void RosenRenderCircleBlock::Paint(RenderContext& context, const Offset& offset) borderPaint.setAntiAlias(true); borderPaint.setStrokeWidth(BORDER_WEIGHT); canvas->drawCircle(offset.GetX(), offset.GetY(), radius, borderPaint); +#else + if (GetFocus() && GetMode() == SliderMode::OUTSET) { + RSPen focusPen; + focusPen.SetColor(FOCUS_BORDER_COLOR); + focusPen.SetWidth(NormalizeToPx(FOCUS_BORDER_PADDING)); + focusPen.SetAntiAlias(true); + canvas->AttachPen(focusPen); + canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), radius + RADIUS_PADDING); + canvas->DetachPen(); + RSPen blockPen; + blockPen.SetColor(RSColor::ColorQuadSetARGB(GetBlockColor().GetAlpha(), + GetBlockColor().GetRed(), GetBlockColor().GetGreen(), GetBlockColor().GetBlue())); + blockPen.SetAntiAlias(true); + canvas->AttachPen(blockPen); + canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), radius); + canvas->DetachPen(); + } else { + RSPen blockPen; + blockPen.SetColor(RSColor::ColorQuadSetARGB(GetBlockColor().GetAlpha(), + GetBlockColor().GetRed(), GetBlockColor().GetGreen(), GetBlockColor().GetBlue())); + blockPen.SetAntiAlias(true); + canvas->AttachPen(blockPen); + canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), radius); + canvas->DetachPen(); + } + + // Draw block border + RSPen blockPen; + // use this color to reduce the loss at corner. + static const uint8_t alpha = 13; + blockPen.SetColor(RSColor::ColorQuadSetARGB(alpha, 0, 0, 0)); + blockPen.SetAntiAlias(true); + blockPen.SetWidth(BORDER_WEIGHT); + canvas->AttachPen(blockPen); + canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), radius); + canvas->DetachPen(); +#endif } void RosenRenderCircleBlock::PaintShadow(RenderContext& context, const Offset& offset, double radius) { double diameter = radius * 2.0; +#ifndef USE_ROSEN_DRAWING SkRect rect = SkRect::MakeXYWH(offset.GetX() - radius, offset.GetY() - radius, diameter, diameter); RosenDecorationPainter::PaintShadow(SkPath().addRRect(SkRRect::MakeRectXY(rect, radius, radius)), ShadowConfig::DefaultShadowXS, static_cast(&context)->GetCanvas()); +#else + RSRect rect = + RSRect(offset.GetX() - radius, offset.GetY() - radius, + diameter + offset.GetX() - radius, diameter + offset.GetY() - radius); + RSRecordingPath path; + path.AddRoundRect(rect, radius, radius); + RosenDecorationPainter::PaintShadow( + path, ShadowConfig::DefaultShadowXS, static_cast(&context)->GetCanvas()); +#endif } -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace diff --git a/frameworks/core/components/slider/rosen_render_circle_block.h b/frameworks/core/components/slider/rosen_render_circle_block.h index 36827d97593..ac66060594c 100644 --- a/frameworks/core/components/slider/rosen_render_circle_block.h +++ b/frameworks/core/components/slider/rosen_render_circle_block.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -16,7 +16,9 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_ROSEN_RENDER_CIRCLE_BLOCK_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_ROSEN_RENDER_CIRCLE_BLOCK_H +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" +#endif #include "core/components/slider/render_block.h" diff --git a/frameworks/core/components/slider/rosen_render_slider.cpp b/frameworks/core/components/slider/rosen_render_slider.cpp index 104e4d00227..37dba2b9145 100644 --- a/frameworks/core/components/slider/rosen_render_slider.cpp +++ b/frameworks/core/components/slider/rosen_render_slider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -356,6 +356,7 @@ void RosenRenderSlider::PaintTrackFocus(RenderContext& context, const Offset& of trackFocusHeight = track->GetTrackThickness() + NormalizeToPx(FOCUS_PADDING * 2 + FOCUS_BORDER_WIDTH); trackFocusRadius = trackFocusHeight * HALF; } +#ifndef USE_ROSEN_DRAWING SkPaint paint; paint.setColor(FOCUS_BORDER_COLOR); paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_WIDTH)); @@ -371,6 +372,26 @@ void RosenRenderSlider::PaintTrackFocus(RenderContext& context, const Offset& of track->GetTrackThickness() * HALF - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF)); } canvas->drawRRect(rRect, paint); +#else + RSPen pen; + pen.SetColor(FOCUS_BORDER_COLOR); + pen.SetWidth(NormalizeToPx(FOCUS_BORDER_WIDTH)); + pen.SetAntiAlias(true); + RSRoundRect rRect( + RSRect(0, 0, trackFocusWidth, trackFocusHeight), trackFocusRadius, trackFocusRadius); + if (direction_ == Axis::VERTICAL) { + rRect.Offset(offset.GetX() + track->GetTrackThickness() * HALF - + NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF), + offset.GetY() + NormalizeToPx(FOCUS_BORDER_WIDTH * HALF * HALF)); + } else { + rRect.Offset(offset.GetX() + NormalizeToPx(FOCUS_BORDER_WIDTH * HALF * HALF), + offset.GetY() + track->GetTrackThickness() * HALF - + NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF)); + } + canvas->AttachPen(pen); + canvas->DrawRoundRect(rRect); + canvas->DetachPen(); +#endif } } // namespace OHOS::Ace \ No newline at end of file From 3458a07aac243bce22c9fccdab56c88df06c4292 Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Tue, 9 May 2023 19:20:29 +0800 Subject: [PATCH 06/99] [components/split_container] use Drawing interface Change-Id: I839c1b441197d41db213d3a8f7815e3a67f620f5 Signed-off-by: huangzejia1 --- .../rosen_render_column_split.cpp | 18 +++++++++++++++++- .../split_container/rosen_render_row_split.cpp | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components/split_container/rosen_render_column_split.cpp b/frameworks/core/components/split_container/rosen_render_column_split.cpp index 6c22c08e764..adc6e7e0533 100644 --- a/frameworks/core/components/split_container/rosen_render_column_split.cpp +++ b/frameworks/core/components/split_container/rosen_render_column_split.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,7 +15,9 @@ #include "core/components/split_container/rosen_render_column_split.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkPaint.h" +#endif #include "core/pipeline/base/constants.h" #include "core/pipeline/base/rosen_render_context.h" @@ -57,6 +59,7 @@ void RosenRenderColumnSplit::PaintDivider(RenderContext& context, const Offset& double startPointY = offset.GetY(); double endPointX = startPointX + width; double endPointY = startPointY; +#ifndef USE_ROSEN_DRAWING SkPaint paint; auto canvas = static_cast(&context)->GetCanvas(); if (!canvas) { @@ -66,6 +69,19 @@ void RosenRenderColumnSplit::PaintDivider(RenderContext& context, const Offset& paint.setColor(COLUMN_SPLIT_COLOR); paint.setStrokeWidth(DEFAULT_SPLIT_HEIGHT); canvas->drawLine(startPointX, startPointY, endPointX, endPointY, paint); +#else + RSPen pen; + auto canvas = static_cast(&context)->GetCanvas(); + if (!canvas) { + LOGE("Paint canvas is null"); + return; + } + pen.SetColor(COLUMN_SPLIT_COLOR); + pen.SetWidth(DEFAULT_SPLIT_HEIGHT); + canvas->AttachPen(pen); + canvas->DrawLine(RSPoint(startPointX, startPointY), RSPoint(endPointX, endPointY)); + canvas->DetachPen(); +#endif } } // namespace OHOS::Ace \ No newline at end of file diff --git a/frameworks/core/components/split_container/rosen_render_row_split.cpp b/frameworks/core/components/split_container/rosen_render_row_split.cpp index aa8d0c432a2..fb1abcdf381 100644 --- a/frameworks/core/components/split_container/rosen_render_row_split.cpp +++ b/frameworks/core/components/split_container/rosen_render_row_split.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,7 +15,9 @@ #include "core/components/split_container/rosen_render_row_split.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkPaint.h" +#endif #include "core/pipeline/base/constants.h" #include "core/pipeline/base/rosen_render_context.h" @@ -57,6 +59,7 @@ void RosenRenderRowSplit::PaintDivider(RenderContext& context, const Offset& off double startPointY = offset.GetY(); double endPointX = startPointX; double endPointY = startPointY + height; +#ifndef USE_ROSEN_DRAWING SkPaint paint; auto canvas = static_cast(&context)->GetCanvas(); if (!canvas) { @@ -66,6 +69,19 @@ void RosenRenderRowSplit::PaintDivider(RenderContext& context, const Offset& off paint.setColor(ROW_SPLIT_COLOR); paint.setStrokeWidth(DEFAULT_SPLIT_HEIGHT); canvas->drawLine(startPointX, startPointY, endPointX, endPointY, paint); +#else + RSPen pen; + auto canvas = static_cast(&context)->GetCanvas(); + if (!canvas) { + LOGE("Paint canvas is null"); + return; + } + pen.SetColor(ROW_SPLIT_COLOR); + pen.SetWidth(DEFAULT_SPLIT_HEIGHT); + canvas->AttachPen(pen); + canvas->DrawLine(RSPoint(startPointX, startPointY), RSPoint(endPointX, endPointY)); + canvas->DetachPen(); +#endif } } // namespace OHOS::Ace \ No newline at end of file From 2af8aac3ae6af50a4a76d3a39b032b79e898c152 Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Wed, 10 May 2023 09:36:43 +0800 Subject: [PATCH 07/99] [components/track][1/2] use Drawing interface Change-Id: I3d2e62774f388b793345a1db07b7371f442e2ba3 Signed-off-by: huangzejia1 --- .../track/rosen_render_linear_track.cpp | 213 +++++++++++++++++- .../track/rosen_render_linear_track.h | 13 +- .../track/rosen_render_moon_track.cpp | 49 +++- .../track/rosen_render_scale_ring_track.cpp | 31 ++- 4 files changed, 300 insertions(+), 6 deletions(-) diff --git a/frameworks/core/components/track/rosen_render_linear_track.cpp b/frameworks/core/components/track/rosen_render_linear_track.cpp index cb1df86e682..681009b0426 100644 --- a/frameworks/core/components/track/rosen_render_linear_track.cpp +++ b/frameworks/core/components/track/rosen_render_linear_track.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,6 +15,7 @@ #include "core/components/track/rosen_render_linear_track.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkMaskFilter.h" #include "include/core/SkPaint.h" @@ -22,6 +23,7 @@ #include "include/core/SkRRect.h" #include "include/core/SkShader.h" #include "include/effects/SkGradientShader.h" +#endif #include "core/components/slider/render_slider.h" #include "core/components/track/render_track.h" @@ -29,6 +31,7 @@ namespace OHOS::Ace { +#ifndef USE_ROSEN_DRAWING sk_sp RosenRenderLinearTrack::BlendSkShader(const SkPoint pts, const SkColor color, bool useAnimator) { const double scanLeftOffset = NormalizeToPx(Dimension(75, DimensionUnit::VP)); @@ -60,6 +63,34 @@ sk_sp RosenRenderLinearTrack::BlendSkShader(const SkPoint pts, const S #endif return blendShader; } +#else +std::shared_ptr RosenRenderLinearTrack::BlendSkShader( + const RSPoint pts, const RSColorQuad color, bool useAnimator) +{ + const double scanLeftOffset = NormalizeToPx(Dimension(75, DimensionUnit::VP)); + const double scanRightOffset = NormalizeToPx(Dimension(5, DimensionUnit::VP)); + const Color hightLight = Color::FromString("#88ffffff"); + const Color shadow = Color::FromString("#00ffffff"); + std::vector scanColors = { shadow.GetValue(), hightLight.GetValue(), shadow.GetValue() }; + std::vector scanPos = { 0, 0.94, 1 }; + std::shared_ptr scanShader; + std::shared_ptr backgroundShader; + std::shared_ptr blendShader; + const RSPoint gradientPoints[2] = { { pts.GetX() - scanLeftOffset, pts.GetY() }, + { pts.GetX() + scanRightOffset, pts.GetY() } }; + + backgroundShader = RSShaderEffect::CreateColorShader(color); + scanShader = RSShaderEffect::CreateLinearGradient( + gradientPoints[0], gradientPoints[1], scanColors, scanPos, RSTileMode::DECAL); + if (useAnimator) { + blendShader = RSShaderEffect::CreateBlendShader( + *backgroundShader, *scanShader, RSBlendMode::SRC_OVER); + } else { + blendShader = backgroundShader; + } + return blendShader; +} +#endif void RosenRenderLinearTrack::Paint(RenderContext& context, const Offset& offset) { @@ -90,6 +121,7 @@ void RosenRenderLinearTrack::Paint(RenderContext& context, const Offset& offset) trackLength = GetLayoutSize().Width(); } trackLength = trackLength - trackHeight; +#ifndef USE_ROSEN_DRAWING if (!NearEqual(GetCachedRatio(), 0.0)) { SkPaint cachedPaint; cachedPaint.setAntiAlias(true); @@ -133,6 +165,60 @@ void RosenRenderLinearTrack::Paint(RenderContext& context, const Offset& offset) GetSelectColor().GetValue(), playAnimation_)); canvas->drawRRect(selectRect, selectPaint); } +#else + if (!NearEqual(GetCachedRatio(), 0.0)) { + RSPen cachedPen; + cachedPen.SetAntiAlias(true); + cachedPen.SetColor(GetCachedColor().GetValue()); + const double startRect = leftToRight_ ? offset.GetX() : offset.GetX() + GetLayoutSize().Width(); + const double endRect = leftToRight_ ? startRect + trackHeight + trackLength * GetCachedRatio() + : startRect - trackHeight - trackLength * GetCachedRatio(); + RSRoundRect cachedRect( + RSRect(startRect, offset.GetY(), endRect, offset.GetY() + trackHeight), trackHeight * HALF, + trackHeight * HALF); + RSRoundRect cachedRectRosen(cachedRect); + canvas->AttachPen(cachedPen); + canvas->DrawRoundRect(cachedRectRosen); + canvas->DetachPen(); + } + // Draw selected region + if (!NearEqual(GetTotalRatio(), 0.0)) { + RSPen selectPen; + selectPen.SetAntiAlias(true); + double startRect = 0.0; + double endRect = 0.0; + if (direction_ == Axis::VERTICAL) { + startRect = isReverse_ ? offset.GetY() + GetLayoutSize().Height() : offset.GetY(); + endRect = isReverse_ ? startRect - trackHeight - trackLength * GetTotalRatio() + : startRect + trackHeight + trackLength * GetTotalRatio(); + RSRoundRect selectRect( + RSRect(offset.GetX(), startRect, offset.GetX() + trackHeight, endRect), + trackHeight * HALF, trackHeight * HALF); + selectPen.SetShaderEffect(BlendSkShader( + RSPoint(offset.GetX(), startRect), GetSelectColor().GetValue(), playAnimation_)); + canvas->AttachPen(selectPen); + canvas->DrawRoundRect(selectRect); + canvas->DetachPen(); + return; + } + if ((leftToRight_ && !isReverse_) || (!leftToRight_ && isReverse_)) { + startRect = offset.GetX(); + endRect = startRect + trackHeight + trackLength * GetTotalRatio(); + } else { + startRect = offset.GetX() + GetLayoutSize().Width(); + endRect = startRect - trackHeight - trackLength * GetTotalRatio(); + } + RSRoundRect selectRect( + RSRect(startRect, offset.GetY(), endRect, offset.GetY() + trackHeight), trackHeight * HALF, + trackHeight * HALF); + selectPen.SetShaderEffect( + BlendSkShader(RSPoint(startRect + scanHighLightValue_ * trackLength, offset.GetY()), + GetSelectColor().GetValue(), playAnimation_)); + canvas->AttachPen(selectPen); + canvas->DrawRoundRect(selectRect); + canvas->DetachPen(); + } +#endif } void RosenRenderLinearTrack::PaintSliderSteps(RenderContext& context, const Offset& offset) @@ -159,6 +245,7 @@ void RosenRenderLinearTrack::PaintSliderSteps(RenderContext& context, const Offs if (!NearEqual(GetTrackThickness(), 0.0)) { trackHeight = GetTrackThickness(); } +#ifndef USE_ROSEN_DRAWING if (direction_ == Axis::VERTICAL) { const double trackLength = GetLayoutSize().Height(); const double dxOffset = offset.GetX() + trackHeight * HALF; @@ -204,6 +291,55 @@ void RosenRenderLinearTrack::PaintSliderSteps(RenderContext& context, const Offs } canvas->drawPath(path, skPaint); } +#else + if (direction_ == Axis::VERTICAL) { + const double trackLength = GetLayoutSize().Height(); + const double dxOffset = offset.GetX() + trackHeight * HALF; + double current = offset.GetY(); + RSPen pen; + pen.SetColor(color.GetValue()); + pen.SetWidth(size); + pen.SetCapStyle(RSPen::CapStyle::ROUND_CAP); + RSPath path; + while (LessOrEqual(current, offset.GetY() + trackLength)) { + double dyOffset; + if (GetSliderMode() == SliderMode::OUTSET) { + dyOffset = std::clamp(current, offset.GetY() + size * HALF, offset.GetY() + trackLength - size * HALF); + } else { + dyOffset = std::clamp(current, offset.GetY(), offset.GetY() + trackLength); + } + path.MoveTo(static_cast(dxOffset), static_cast(dyOffset)); + path.LineTo(static_cast(dxOffset), static_cast(dyOffset)); + current += GetSliderSteps(); + } + canvas->AttachPen(pen); + canvas->DrawPath(path); + canvas->DetachPen(); + } else { + const double trackLength = GetLayoutSize().Width(); + const double dyOffset = offset.GetY() + trackHeight * HALF; + double current = offset.GetX(); + RSPen pen; + pen.SetColor(color.GetValue()); + pen.SetWidth(size); + pen.SetCapStyle(RSPen::CapStyle::ROUND_CAP); + RSPath path; + while (LessOrEqual(current, offset.GetY() + trackLength)) { + double dxOffset; + if (GetSliderMode() == SliderMode::OUTSET) { + dxOffset = std::clamp(current, offset.GetX() + size * HALF, offset.GetX() + trackLength - size * HALF); + } else { + dxOffset = std::clamp(current, offset.GetX(), offset.GetX() + trackLength); + } + path.MoveTo(static_cast(dxOffset), static_cast(dyOffset)); + path.LineTo(static_cast(dxOffset), static_cast(dyOffset)); + current += GetSliderSteps(); + } + canvas->AttachPen(pen); + canvas->DrawPath(path); + canvas->DetachPen(); + } +#endif } void RosenRenderLinearTrack::PaintSliderTrack(RenderContext& context, const Offset& offset) @@ -229,6 +365,7 @@ void RosenRenderLinearTrack::PaintSliderTrack(RenderContext& context, const Offs } // Draw background +#ifndef USE_ROSEN_DRAWING SkPaint railPaint; railPaint.setAntiAlias(true); railPaint.setColor(GetBackgroundColor().GetValue()); @@ -240,11 +377,28 @@ void RosenRenderLinearTrack::PaintSliderTrack(RenderContext& context, const Offs } else { canvas->drawLine(offset.GetX(), dyOffset, offset.GetX() + trackLength, dyOffset, railPaint); } +#else + RSPen railPen; + railPen.SetAntiAlias(true); + railPen.SetColor(GetBackgroundColor().GetValue()); + railPen.SetWidth(trackHeight); + railPen.SetCapStyle(RSPen::CapStyle::ROUND_CAP); + canvas->AttachPen(railPen); + if (direction_ == Axis::VERTICAL) { + canvas->DrawLine(RSPoint(dxOffset, offset.GetY()), + RSPoint(dxOffset, offset.GetY() + trackLength)); + } else { + canvas->DrawLine(RSPoint(offset.GetX(), dyOffset), + RSPoint(offset.GetX() + trackLength, dyOffset)); + } + canvas->DetachBrush(); +#endif // draw steps PaintSliderSteps(context, offset); // Draw selected region +#ifndef USE_ROSEN_DRAWING if (!NearEqual(GetTotalRatio(), 0.0)) { SkPaint selectPaint; selectPaint.setAntiAlias(true); @@ -270,8 +424,40 @@ void RosenRenderLinearTrack::PaintSliderTrack(RenderContext& context, const Offs } canvas->drawLine(fromOffset, dyOffset, toOffset, dyOffset, selectPaint); } +#else + if (!NearEqual(GetTotalRatio(), 0.0)) { + RSPen selectPen; + selectPen.SetAntiAlias(true); + selectPen.SetColor(GetSelectColor().GetValue()); + selectPen.SetWidth(trackHeight); + selectPen.SetCapStyle(RSPen::CapStyle::ROUND_CAP); + canvas->AttachPen(selectPen); + double fromOffset = 0.0; + double toOffset = 0.0; + if (direction_ == Axis::VERTICAL) { + fromOffset = isReverse_ ? offset.GetY() + trackLength : offset.GetY(); + toOffset = isReverse_ ? + fromOffset - trackLength * GetTotalRatio() : fromOffset + trackLength * GetTotalRatio(); + canvas->AttachPen(selectPen); + canvas->DrawLine(RSPoint(dxOffset, fromOffset), RSPoint(dxOffset, toOffset)); + canvas->DetachPen(); + return; + } + if (((leftToRight_ && !isReverse_)) || ((!leftToRight_ && isReverse_))) { + fromOffset = offset.GetX(); + toOffset = fromOffset + trackLength * GetTotalRatio(); + } else { + fromOffset = offset.GetX() + trackLength; + toOffset = fromOffset - trackLength * GetTotalRatio(); + } + canvas->AttachPen(selectPen); + canvas->DrawLine(RSPoint(fromOffset, dyOffset), RSPoint(toOffset, dyOffset)); + canvas->DetachPen(); + } +#endif } +#ifndef USE_ROSEN_DRAWING void RosenRenderLinearTrack::PaintBackgroundTrack(SkCanvas* canvas, const Offset& offset, double trackHeight) const { SkPaint railPaint; @@ -290,5 +476,28 @@ void RosenRenderLinearTrack::PaintBackgroundTrack(SkCanvas* canvas, const Offset canvas->drawRRect(rrect, railPaint); } +#else +void RosenRenderLinearTrack::PaintBackgroundTrack( + RSCanvas* canvas, const Offset& offset, double trackHeight) const +{ + RSPen railPen; + railPen.SetAntiAlias(true); + railPen.SetColor(GetBackgroundColor().GetValue()); + RSRoundRect rrect; + if (direction_ == Axis::VERTICAL) { + rrect = RSRoundRect(RSRect(offset.GetX(), offset.GetY(), + offset.GetX() + trackHeight, offset.GetY() + GetLayoutSize().Height()), + trackHeight * HALF, trackHeight * HALF); + } else { + rrect = RSRoundRect(RSRect(offset.GetX(), offset.GetY(), + offset.GetX() + GetLayoutSize().Width(), offset.GetY() + trackHeight), + trackHeight * HALF, trackHeight * HALF); + } -} // namespace OHOS::Ace \ No newline at end of file + canvas->AttachPen(railPen); + canvas->DrawRoundRect(rrect); + canvas->DetachPen(); +} +#endif + +} // namespace OHOS::Ace diff --git a/frameworks/core/components/track/rosen_render_linear_track.h b/frameworks/core/components/track/rosen_render_linear_track.h index 59022a73c66..e1c78b1a427 100644 --- a/frameworks/core/components/track/rosen_render_linear_track.h +++ b/frameworks/core/components/track/rosen_render_linear_track.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -16,10 +16,12 @@ #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TRACK_ROSEN_RENDER_LINEAR_TRACK_H #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TRACK_ROSEN_RENDER_LINEAR_TRACK_H +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkPoint.h" #include "include/core/SkShader.h" +#endif #include "base/geometry/offset.h" #include "core/components/track/render_track.h" @@ -36,10 +38,19 @@ public: void Paint(RenderContext& context, const Offset& offset) override; void PaintSliderTrack(RenderContext& context, const Offset& offset); void PaintSliderSteps(RenderContext& context, const Offset& offset); +#ifndef USE_ROSEN_DRAWING void PaintBackgroundTrack(SkCanvas* canvas, const Offset& offset, double trackHeight) const; +#else + void PaintBackgroundTrack(RSCanvas* canvas, const Offset& offset, double trackHeight) const; +#endif private: +#ifndef USE_ROSEN_DRAWING sk_sp BlendSkShader(const SkPoint pts, const SkColor color, bool useAnimator = false); +#else + std::shared_ptr BlendSkShader(const RSPoint pts, + const RSColorQuad color, bool useAnimator = false); +#endif }; } // namespace OHOS::Ace diff --git a/frameworks/core/components/track/rosen_render_moon_track.cpp b/frameworks/core/components/track/rosen_render_moon_track.cpp index 203c3d5eb27..980ad05d132 100644 --- a/frameworks/core/components/track/rosen_render_moon_track.cpp +++ b/frameworks/core/components/track/rosen_render_moon_track.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,9 +15,11 @@ #include "rosen_render_moon_track.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkPaint.h" #include "include/core/SkPath.h" +#endif #include "core/pipeline/base/rosen_render_context.h" @@ -28,15 +30,22 @@ void RosenRenderMoonTrack::Paint(RenderContext& context, const Offset& offset) Size canvasSize = GetLayoutSize(); Offset center = offset + Offset(canvasSize.Width() / 2, canvasSize.Height() / 2); double radius = std::min(canvasSize.Width(), canvasSize.Height()) / 2; +#ifndef USE_ROSEN_DRAWING SkPaint paint; paint.setAntiAlias(true); paint.setColor(GetSelectColor().GetValue()); paint.setStyle(SkPaint::kFill_Style); +#else + RSBrush brush; + brush.SetAntiAlias(true); + brush.SetColor(GetSelectColor().GetValue()); +#endif auto canvas = static_cast(&context)->GetCanvas(); if (canvas == nullptr) { LOGE("Paint canvas is null"); return; } +#ifndef USE_ROSEN_DRAWING SkPath path; SkPaint backgroundPaint; @@ -65,6 +74,42 @@ void RosenRenderMoonTrack::Paint(RenderContext& context, const Offset& offset) 270, 180); canvas->drawPath(path, paint); } +#else + RSRecordingPath path; + + RSBrush backgroundBrush; + backgroundBrush.SetAntiAlias(true); + backgroundBrush.SetColor(GetBackgroundColor().GetValue()); + canvas->AttachBrush(backgroundBrush); + canvas->DrawCircle(RSPoint(center.GetX(), center.GetY()), radius); + canvas->DetachBrush(); + + if (GetTotalRatio() <= 0.5) { + path.MoveTo(center.GetX(), center.GetY() - radius); + path.AddArc(RSRect( + center.GetX() - radius, center.GetY() - radius, center.GetX() + radius, center.GetY() + radius), + 90, 180); + double progressOffset = radius - radius * GetTotalRatio() / 0.5; + path.AddArc(RSRect(center.GetX() - progressOffset, + center.GetY() - radius, center.GetX() + progressOffset, center.GetY() + radius), + 270, -180); + canvas->AttachBrush(brush); + canvas->DrawPath(path); + canvas->DetachBrush(); + } else { + double progressOffset = radius * (GetTotalRatio() - 0.5) / 0.5; + path.MoveTo(center.GetX(), center.GetY() - radius); + path.AddArc(RSRect( + center.GetX() - radius, center.GetY() - radius, center.GetX() + radius, center.GetY() + radius), + 90, 180); + path.AddArc(RSRect(center.GetX() - progressOffset, + center.GetY() - radius, center.GetX() + progressOffset, center.GetY() + radius), + 270, 180); + canvas->AttachBrush(brush); + canvas->DrawPath(path); + canvas->DetachBrush(); + } +#endif } -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace diff --git a/frameworks/core/components/track/rosen_render_scale_ring_track.cpp b/frameworks/core/components/track/rosen_render_scale_ring_track.cpp index 309019242db..dbbe92fe458 100644 --- a/frameworks/core/components/track/rosen_render_scale_ring_track.cpp +++ b/frameworks/core/components/track/rosen_render_scale_ring_track.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,9 +15,11 @@ #include "core/components/track/rosen_render_scale_ring_track.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkPaint.h" #include "include/effects/Sk1DPathEffect.h" +#endif #include "core/components/theme/theme_constants.h" #include "core/components/theme/theme_constants_defines.h" @@ -33,6 +35,7 @@ void DrawScaleArc(RenderContext& context, const RenderRingInfo& trackInfo) LOGE("Paint canvas is null"); return; } +#ifndef USE_ROSEN_DRAWING SkPaint paint; SkPath path; path.addRRect(SkRRect::MakeRectXY(SkRect::MakeWH(trackInfo.scaleStrokeWidth, trackInfo.thickness), @@ -46,18 +49,44 @@ void DrawScaleArc(RenderContext& context, const RenderRingInfo& trackInfo) paint.setStrokeWidth(trackInfo.thickness); paint.setAntiAlias(true); paint.setColor(trackInfo.color.GetValue()); +#else + RSPen pen; + RSRecordingPath path; + path.AddRoundRect(RSRect(0, 0, trackInfo.scaleStrokeWidth, trackInfo.thickness), + trackInfo.thickness / 2.0, trackInfo.thickness / 2.0); + double pathDistance = 2.0 * M_PI * + (trackInfo.radius + (NearEqual(trackInfo.clockwise, 1.0) ? trackInfo.thickness : 0.0)) / + trackInfo.totalScaleNumber; + pen.SetPathEffect(RSPathEffect::CreatePathDashEffect( + path, static_cast(pathDistance), 0.0f, RSPathDashStyle::ROTATE)); + pen.SetWidth(trackInfo.thickness); + pen.SetAntiAlias(true); + pen.SetColor(trackInfo.color.GetValue()); +#endif static int32_t totalDegree = 360; double radiusPrecision = trackInfo.thickness; if (trackInfo.clockwise != 1) { radiusPrecision = 0.0; } +#ifndef USE_ROSEN_DRAWING canvas->drawArc({ trackInfo.center.GetX() - trackInfo.radius - radiusPrecision, trackInfo.center.GetY() - trackInfo.radius - radiusPrecision, trackInfo.center.GetX() + trackInfo.radius + radiusPrecision, trackInfo.center.GetY() + trackInfo.radius + radiusPrecision }, 180 * (trackInfo.clockwise * (trackInfo.startDegree / (totalDegree / 2.0)) - 0.5), 360 * (trackInfo.clockwise * trackInfo.sweepDegree / totalDegree), false, paint); +#else + canvas->AttachPen(pen); + canvas->DrawArc( + RSRect(trackInfo.center.GetX() - trackInfo.radius - radiusPrecision, + trackInfo.center.GetY() - trackInfo.radius - radiusPrecision, + trackInfo.center.GetX() + trackInfo.radius + radiusPrecision, + trackInfo.center.GetY() + trackInfo.radius + radiusPrecision), + 180 * (trackInfo.clockwise * (trackInfo.startDegree / (totalDegree / 2.0)) - 0.5), + 360 * (trackInfo.clockwise * trackInfo.sweepDegree / totalDegree)); + canvas->DetachPen(); +#endif } } // namespace From bf3b9da7786f397dd0b52f313611baa3196e57a4 Mon Sep 17 00:00:00 2001 From: huangzejia1 Date: Wed, 10 May 2023 09:40:14 +0800 Subject: [PATCH 08/99] [components/track][2/2] use Drawing interface Change-Id: Iab978f2319f58c0671a388c78219bbe370813f33 Signed-off-by: huangzejia1 --- .../track/rosen_render_arc_track.cpp | 64 +++++++++++++++- .../track/rosen_render_capsule_track.cpp | 75 ++++++++++++++++++- .../track/rosen_render_circular_track.cpp | 49 +++++++++++- 3 files changed, 183 insertions(+), 5 deletions(-) diff --git a/frameworks/core/components/track/rosen_render_arc_track.cpp b/frameworks/core/components/track/rosen_render_arc_track.cpp index 5ce88785366..db997c0723d 100644 --- a/frameworks/core/components/track/rosen_render_arc_track.cpp +++ b/frameworks/core/components/track/rosen_render_arc_track.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,10 +15,12 @@ #include "core/components/track/rosen_render_arc_track.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkClipOp.h" #include "include/core/SkPaint.h" #include "include/core/SkPath.h" +#endif #include "txt/paragraph_builder.h" #include "txt/paragraph_txt.h" @@ -41,6 +43,7 @@ void DrawGauge(RenderContext& context, const RenderRingInfo& trackInfo) return; } double thickness = trackInfo.thickness; +#ifndef USE_ROSEN_DRAWING SkPaint paint; paint.setAntiAlias(true); paint.setColor(trackInfo.color.GetValue()); @@ -53,6 +56,22 @@ void DrawGauge(RenderContext& context, const RenderRingInfo& trackInfo) trackInfo.center.GetX() + trackInfo.radius - (thickness / 2), trackInfo.center.GetY() + trackInfo.radius - (thickness / 2) }, trackInfo.startDegree - 90, trackInfo.sweepDegree, false, paint); +#else + RSPen pen; + pen.SetAntiAlias(true); + pen.SetColor(trackInfo.color.GetValue()); + pen.SetWidth(thickness); + pen.SetCapStyle(RSPen::CapStyle::ROUND_CAP); + + canvas->AttachPen(pen); + canvas->DrawArc( + RSRect(trackInfo.center.GetX() + (thickness / 2) - trackInfo.radius, + trackInfo.center.GetY() + (thickness / 2) - trackInfo.radius, + trackInfo.center.GetX() + trackInfo.radius - (thickness / 2), + trackInfo.center.GetY() + trackInfo.radius - (thickness / 2)), + trackInfo.startDegree - 90, trackInfo.sweepDegree); + canvas->DetachPen(); +#endif } bool ShouldHighLight(const double start, const double interval, const double percent) @@ -63,8 +82,13 @@ bool ShouldHighLight(const double start, const double interval, const double per return false; } +#ifndef USE_ROSEN_DRAWING void SetTextStyle(SkCanvas* canvas, const RenderRingInfo& trackInfo, const std::string& markedText, const Color markedColor, const Rect dataRegion) +#else +void SetTextStyle(RSCanvas* canvas, const RenderRingInfo& trackInfo, const std::string& markedText, + const Color markedColor, const Rect dataRegion) +#endif { if (!canvas) { LOGE("Paint canvas is null"); @@ -89,7 +113,12 @@ void SetTextStyle(SkCanvas* canvas, const RenderRingInfo& trackInfo, const std:: builder->AddText(StringUtils::Str8ToStr16(markedText)); auto paragraph = builder->Build(); paragraph->Layout(dataRegion.Width()); +#ifndef USE_ROSEN_DRAWING paragraph->Paint(canvas, pathStartVertexX - txtStyle.font_size, pathStartVertexY + EDGE + HEIGHT_OFFSET * 2); +#else + paragraph->Paint(canvas->GetCanvasData()->ExportSkCanvas(), pathStartVertexX - txtStyle.font_size, + pathStartVertexY + EDGE + HEIGHT_OFFSET * 2); +#endif } void DrawIndicator(RenderContext& context, const RenderRingInfo& trackInfo, const std::string& markedText, @@ -100,6 +129,7 @@ void DrawIndicator(RenderContext& context, const RenderRingInfo& trackInfo, cons LOGE("Paint canvas is null"); return; } +#ifndef USE_ROSEN_DRAWING canvas->save(); SkPath path; @@ -125,6 +155,38 @@ void DrawIndicator(RenderContext& context, const RenderRingInfo& trackInfo, cons paint.setColor(Color::BLACK.GetValue()); canvas->drawPath(path, paint); canvas->restore(); +#else + canvas->Save(); + + RSRecordingPath path; + double pathStartVertexX = trackInfo.center.GetX(); + double pathStartVertexY = trackInfo.center.GetY() - trackInfo.radius + (trackInfo.thickness / 2); + path.MoveTo(pathStartVertexX, pathStartVertexY); + path.LineTo(pathStartVertexX - EDGE, pathStartVertexY + EDGE); + path.LineTo(pathStartVertexX - EDGE, pathStartVertexY + EDGE + HEIGHT_OFFSET); + path.LineTo(pathStartVertexX + EDGE, pathStartVertexY + EDGE + HEIGHT_OFFSET); + path.LineTo(pathStartVertexX + EDGE, pathStartVertexY + EDGE); + path.LineTo(pathStartVertexX, pathStartVertexY); + + canvas->Rotate(trackInfo.startDegree + trackInfo.sweepDegree, trackInfo.center.GetX(), trackInfo.center.GetY()); + RSBrush brush; + RSPen pen; + + brush.SetColor(Color::WHITE.GetValue()); + canvas->AttachBrush(brush); + canvas->DrawPath(path); + canvas->DetachBrush(); + SetTextStyle(canvas, trackInfo, markedText, markedColor, dataRegion); + + pen.SetCapStyle(RSPen::CapStyle::SQUARE_CAP); + pen.SetWidth(INDICATOR_STROKE_WIDTH); + pen.SetColor(Color::BLACK.GetValue()); + canvas->AttachPen(pen); + canvas->DrawPath(path); + canvas->DetachPen(); + + canvas->Restore(); +#endif } } // namespace diff --git a/frameworks/core/components/track/rosen_render_capsule_track.cpp b/frameworks/core/components/track/rosen_render_capsule_track.cpp index 624986d9c06..7337a42ec31 100644 --- a/frameworks/core/components/track/rosen_render_capsule_track.cpp +++ b/frameworks/core/components/track/rosen_render_capsule_track.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,9 +15,11 @@ #include "rosen_render_capsule_track.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkPaint.h" #include "include/core/SkPath.h" +#endif #include "core/pipeline/base/rosen_render_context.h" @@ -36,6 +38,7 @@ void RosenRenderCapsuleTrack::DrawShape(RenderContext& context, const Offset& of Size progressSize = Size(progressWidth, progressHeight); double rrectRadius = progressSize.Height() / 2.0; +#ifndef USE_ROSEN_DRAWING SkPaint paint; paint.setColor(GetBackgroundColor().GetValue()); paint.setStyle(SkPaint::Style::kFill_Style); @@ -46,6 +49,20 @@ void RosenRenderCapsuleTrack::DrawShape(RenderContext& context, const Offset& of rRect.offset(offset.GetX(), offset.GetY()); canvas->drawRRect(rRect, paint); +#else + RSBrush brush; + brush.SetColor(GetBackgroundColor().GetValue()); + brush.SetAntiAlias(true); + RSRoundRect rRect( + RSRect(0, 0, static_cast(progressSize.Width()), + static_cast(progressSize.Height())), + rrectRadius, rrectRadius); + + rRect.Offset(offset.GetX(), offset.GetY()); + canvas->AttachBrush(brush); + canvas->DrawRoundRect(rRect); + canvas->DetachBrush(); +#endif } void RosenRenderCapsuleTrack::DrawCapsuleProgressAnimation(RenderContext& context, @@ -69,6 +86,7 @@ void RosenRenderCapsuleTrack::DrawCapsuleProgressAnimation(RenderContext& contex double progressWidth = progressSize.Width()*GetTotalRatio(); +#ifndef USE_ROSEN_DRAWING SkPath path; path.addArc({ offsetX, offsetY, progressSize.Height() + offsetX, progressSize.Height() + offsetY }, 90, 180); if (LessNotEqual(progressWidth, radius)) { @@ -90,6 +108,31 @@ void RosenRenderCapsuleTrack::DrawCapsuleProgressAnimation(RenderContext& contex paint.setStyle(SkPaint::Style::kFill_Style); paint.setAntiAlias(true); canvas->drawPath(path, paint); +#else + RSRecordingPath path; + path.AddArc(RSRect( + offsetX, offsetY, progressSize.Height() + offsetX, progressSize.Height() + offsetY), 90, 180); + if (LessNotEqual(progressWidth, radius)) { + path.AddArc(RSRect( + progressWidth + offsetX, offsetY, progressSize.Height() - progressWidth + offsetX, + progressSize.Height() + offsetY), 270, -180); + } else if (GreatNotEqual(progressWidth, progressSize.Width() - radius)) { + path.AddRect(radius + offsetX, offsetY, progressSize.Width() - radius + offsetX, + progressSize.Height() + offsetY, RSPathDirection::CW_DIRECTION); + path.AddArc(RSRect( + (progressSize.Width() - radius) * 2.0 - progressWidth + offsetX, offsetY, + progressWidth + offsetX, progressSize.Height() + offsetY), 270, 180); + } else { + path.AddRect(radius + offsetX, offsetY, progressWidth + offsetX, progressSize.Height() + offsetY); + } + + RSBrush brush; + brush.SetColor(GetSelectColor().GetValue()); + brush.SetAntiAlias(true); + canvas->AttachBrush(brush); + canvas->DrawPath(path); + canvas->DetachBrush(); +#endif } void RosenRenderCapsuleTrack::DrawCapsuleProgressVerticalAnimation(RenderContext& context, const Offset& offset) @@ -111,6 +154,7 @@ void RosenRenderCapsuleTrack::DrawCapsuleProgressVerticalAnimation(RenderContext double radius = progressSize.Width() / 2.0; double progressWidth = progressSize.Height()*GetTotalRatio(); +#ifndef USE_ROSEN_DRAWING SkPath path; path.addArc({ offsetX, offsetY, progressSize.Width() + offsetX, progressSize.Width() + offsetY }, 0, -180); if (LessNotEqual(progressWidth, radius)) { @@ -132,6 +176,33 @@ void RosenRenderCapsuleTrack::DrawCapsuleProgressVerticalAnimation(RenderContext paint.setStyle(SkPaint::Style::kFill_Style); paint.setAntiAlias(true); canvas->drawPath(path, paint); +#else + RSRecordingPath path; + path.AddArc(RSRect( + offsetX, offsetY, progressSize.Width() + offsetX, + progressSize.Width() + offsetY), 0, -180); + if (LessNotEqual(progressWidth, radius)) { + path.AddArc(RSRect( + offsetX, offsetY + progressWidth, progressSize.Width() + offsetX, + progressSize.Width() - progressWidth + offsetY), 180, 180); + } else if (GreatNotEqual(progressWidth, progressSize.Height() - radius)) { + path.AddRect( + offsetX, offsetY + radius, progressSize.Width() + offsetX, progressSize.Height() - radius + offsetY); + path.AddArc(RSRect( + offsetX, offsetY + (progressSize.Height() - radius) * 2.0 - progressWidth, + progressSize.Width() + offsetX, progressWidth + offsetY), 180, -180); + } else { + path.AddRect(RSRect( + offsetX, radius + offsetY, offsetX + progressSize.Width(), progressWidth + offsetY)); + } + + RSBrush brush; + brush.SetColor(GetSelectColor().GetValue()); + brush.SetAntiAlias(true); + canvas->AttachBrush(brush); + canvas->DrawPath(path); + canvas->DetachBrush(); +#endif } void RosenRenderCapsuleTrack::Paint(RenderContext& context, const Offset& offset) @@ -146,4 +217,4 @@ void RosenRenderCapsuleTrack::Paint(RenderContext& context, const Offset& offset DrawCapsuleProgressVerticalAnimation(context, offset); } } -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace diff --git a/frameworks/core/components/track/rosen_render_circular_track.cpp b/frameworks/core/components/track/rosen_render_circular_track.cpp index a0142d5c16a..254e540ce32 100644 --- a/frameworks/core/components/track/rosen_render_circular_track.cpp +++ b/frameworks/core/components/track/rosen_render_circular_track.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 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 @@ -15,10 +15,12 @@ #include "core/components/track/rosen_render_circular_track.h" +#ifndef USE_ROSEN_DRAWING #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkPaint.h" #include "include/effects/SkGradientShader.h" +#endif #include "core/pipeline/base/rosen_render_context.h" @@ -36,6 +38,7 @@ void DrawArc(RenderContext& context, const RenderRingInfo& trackInfo) return; } double thickness = trackInfo.thickness; +#ifndef USE_ROSEN_DRAWING SkPaint paint; paint.setAntiAlias(true); if (trackInfo.gradient.IsValid()) { @@ -67,6 +70,40 @@ void DrawArc(RenderContext& context, const RenderRingInfo& trackInfo) trackInfo.center.GetY() + trackInfo.radius - (thickness / 2) }, trackInfo.clockwise * trackInfo.startDegree + degreeOffset, trackInfo.clockwise * trackInfo.sweepDegree, false, paint); +#else + RSPen pen; + pen.SetAntiAlias(true); + + if (trackInfo.gradient.IsValid()) { + RSColorQuad colors[trackInfo.gradient.GetColors().size() + 1]; + // size cannot be larger than uint32_t. + for (uint32_t index = 0; index < trackInfo.gradient.GetColors().size(); index++) { + colors[index] = trackInfo.gradient.GetColors()[index].GetColor().GetValue(); + } + colors[trackInfo.gradient.GetColors().size()] = trackInfo.gradient.GetColors()[0].GetColor().GetValue(); + float position[] = { COLOR_STOP, 2.0 * COLOR_STOP, 1.0 }; + + std::vector vecColor(colors, colors + sizeof(colors)); + std::vector vecPos(position, position + sizeof(position)); + + pen.SetShaderEffect(RSShaderEffect::CreateSweepGradientByMatrix( + RSPoint(trackInfo.center.GetX(), trackInfo.center.GetY()), vecColor, vecPos, + RSTileMode::CLAMP, trackInfo.startDegree, trackInfo.startDegree + 360, true, nullptr)); + } else { + pen.SetColor(trackInfo.color.GetValue()); + } + pen.SetWidth(thickness); + pen.SetCapStyle(RSPen::CapStyle::ROUND_CAP); + + canvas->AttachPen(pen); + canvas->DrawArc( + RSRect(trackInfo.center.GetX() + (thickness / 2) - trackInfo.radius, + trackInfo.center.GetY() + (thickness / 2) - trackInfo.radius, + trackInfo.center.GetX() + trackInfo.radius - (thickness / 2), + trackInfo.center.GetY() + trackInfo.radius - (thickness / 2)), + trackInfo.clockwise * trackInfo.startDegree, trackInfo.clockwise * trackInfo.sweepDegree); + canvas->DetachPen(); +#endif } } // namespace @@ -81,7 +118,11 @@ void RosenRenderCircularTrack::Paint(RenderContext& context, const Offset& offse LOGE("Paint canvas is null"); return; } +#ifndef USE_ROSEN_DRAWING canvas->save(); +#else + canvas->Save(); +#endif // draw background data.color = GetBackgroundColor(); @@ -98,7 +139,11 @@ void RosenRenderCircularTrack::Paint(RenderContext& context, const Offset& offse data.sweepDegree = paintData_.sweepDegree * GetTotalRatio(); DrawArc(context, data); +#ifndef USE_ROSEN_DRAWING canvas->restore(); +#else + canvas->Restore(); +#endif } -} // namespace OHOS::Ace \ No newline at end of file +} // namespace OHOS::Ace From b6cf96a8f419d5b6356cfe93a2b708cd08109754 Mon Sep 17 00:00:00 2001 From: huang-xl Date: Mon, 15 May 2023 16:27:35 +0800 Subject: [PATCH 09/99] player_framework SPLE Signed-off-by: huang-xl Signed-off-by: huang-xl Change-Id: I7df7b79ac93fc8d58cebf8015664c000dd582aeb --- frameworks/core/components/camera/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/core/components/camera/BUILD.gn b/frameworks/core/components/camera/BUILD.gn index fcf7836b617..eb8dda10d84 100644 --- a/frameworks/core/components/camera/BUILD.gn +++ b/frameworks/core/components/camera/BUILD.gn @@ -50,7 +50,7 @@ build_component("camera") { "c_utils:utils", "ipc:ipc_core", "multimedia_camera_framework:camera_framework", - "multimedia_player_framework:media_client", + "player_framework:media_client", ] } else { sources += [ "large_system/camera.cpp" ] From 0d10df5fa3749aad833851caabe771897b5b0c19 Mon Sep 17 00:00:00 2001 From: chengjinsong2 Date: Tue, 16 May 2023 18:25:06 +0800 Subject: [PATCH 10/99] add innertag on arkui_ace_engine Signed-off-by: chengjinsong2 --- build/BUILD.gn | 1 + interfaces/inner_api/ace/BUILD.gn | 1 + interfaces/inner_api/drawable_descriptor/BUILD.gn | 1 + interfaces/inner_api/form_render/BUILD.gn | 1 + interfaces/inner_api/ui_service_manager/BUILD.gn | 1 + 5 files changed, 5 insertions(+) diff --git a/build/BUILD.gn b/build/BUILD.gn index a903b0aab53..8ec627b5b10 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -87,6 +87,7 @@ foreach(item, ace_platforms) { ohos_shared_library("libace") { deps = [ "$ace_root/build:libace_static_ohos" ] version_script = "libace.map" + innerapi_tags = [ "platformsdk" ] part_name = ace_engine_part subsystem_name = ace_engine_subsystem } diff --git a/interfaces/inner_api/ace/BUILD.gn b/interfaces/inner_api/ace/BUILD.gn index f88ea67710b..47e03a2ced0 100644 --- a/interfaces/inner_api/ace/BUILD.gn +++ b/interfaces/inner_api/ace/BUILD.gn @@ -37,5 +37,6 @@ ohos_shared_library("ace_uicontent") { external_deps = [ "multimedia_image_framework:image" ] subsystem_name = ace_engine_subsystem + innerapi_tags = [ "platformsdk_indirect" ] part_name = ace_engine_part } diff --git a/interfaces/inner_api/drawable_descriptor/BUILD.gn b/interfaces/inner_api/drawable_descriptor/BUILD.gn index 50462415f3e..3145618b7d8 100644 --- a/interfaces/inner_api/drawable_descriptor/BUILD.gn +++ b/interfaces/inner_api/drawable_descriptor/BUILD.gn @@ -60,5 +60,6 @@ ohos_shared_library("drawable_descriptor") { ] subsystem_name = ace_engine_subsystem + innerapi_tags = [ "platformsdk" ] part_name = ace_engine_part } diff --git a/interfaces/inner_api/form_render/BUILD.gn b/interfaces/inner_api/form_render/BUILD.gn index e4c13e3626f..38122637404 100644 --- a/interfaces/inner_api/form_render/BUILD.gn +++ b/interfaces/inner_api/form_render/BUILD.gn @@ -64,5 +64,6 @@ ohos_shared_library("ace_form_render") { ] subsystem_name = ace_engine_subsystem + innerapi_tags = [ "platformsdk_indirect" ] part_name = ace_engine_part } diff --git a/interfaces/inner_api/ui_service_manager/BUILD.gn b/interfaces/inner_api/ui_service_manager/BUILD.gn index 88a7266af41..b712e79ece6 100755 --- a/interfaces/inner_api/ui_service_manager/BUILD.gn +++ b/interfaces/inner_api/ui_service_manager/BUILD.gn @@ -67,5 +67,6 @@ ohos_shared_library("ui_service_mgr") { ] subsystem_name = ace_engine_subsystem + innerapi_tags = [ "platformsdk_indirect" ] part_name = ace_engine_part } From b01e1519eb00ee21415977e633fd6a669bb0ca25 Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 17 May 2023 14:38:56 +0800 Subject: [PATCH 11/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E8=AE=BE=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E5=86=85=E5=AE=B9=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng --- .../declarative_frontend/jsview/js_search.cpp | 13 +++++---- .../jsview/js_textfield.cpp | 28 +++++++++++-------- .../jsview/js_textpicker.cpp | 8 ++++-- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_search.cpp b/frameworks/bridge/declarative_frontend/jsview/js_search.cpp index 1f1d8704fbb..47dd7450a89 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_search.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_search.cpp @@ -125,15 +125,18 @@ void JSSearch::Create(const JSCallbackInfo& info) } std::string text; key = ""; - if (param->GetProperty("value")->IsObject()) { - JSRef valueObj = JSRef::Cast(param->GetProperty("value")); + JSRef textValue = param->GetProperty("value"); + if (textValue->IsObject()) { + JSRef valueObj = JSRef::Cast(textValue); changeEventVal = valueObj->GetProperty("changeEvent"); - auto valueProperty = valueObj->GetProperty("value"); - if (ParseJsString(valueProperty, text)) { + if (changeEventVal->IsFunction()) { + textValue = valueObj->GetProperty("value"); + } + if (ParseJsString(textValue, text)) { key = text; } } else { - if (ParseJsString(param->GetProperty("value"), text)) { + if (ParseJsString(textValue, text)) { key = text; } } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp b/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp index 013aec83413..87148708f4e 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_textfield.cpp @@ -163,15 +163,18 @@ void JSTextField::CreateTextInput(const JSCallbackInfo& info) placeholderSrc = placeholder; } std::string text; - if (paramObject->GetProperty("text")->IsObject()) { - JSRef valueObj = JSRef::Cast(paramObject->GetProperty("text")); + JSRef textValue = paramObject->GetProperty("text"); + if (textValue->IsObject()) { + JSRef valueObj = JSRef::Cast(textValue); changeEventVal = valueObj->GetProperty("changeEvent"); - auto valueProperty = valueObj->GetProperty("value"); - if (ParseJsString(valueProperty, text)) { + if (changeEventVal->IsFunction()) { + textValue = valueObj->GetProperty("value"); + } + if (ParseJsString(textValue, text)) { value = text; } } else { - if (ParseJsString(paramObject->GetProperty("text"), text)) { + if (ParseJsString(textValue, text)) { value = text; } } @@ -200,7 +203,7 @@ void JSTextField::CreateTextArea(const JSCallbackInfo& info) std::optional placeholderSrc; std::optional value; JSTextAreaController* jsController = nullptr; - JSRef changeEventVal; + JSRef changeEventVal = JSRef::Make(); if (info[0]->IsObject()) { auto paramObject = JSRef::Cast(info[0]); std::string placeholder; @@ -208,15 +211,18 @@ void JSTextField::CreateTextArea(const JSCallbackInfo& info) placeholderSrc = placeholder; } std::string text; - if (paramObject->GetProperty("text")->IsObject()) { - JSRef valueObj = JSRef::Cast(paramObject->GetProperty("text")); + JSRef textValue = paramObject->GetProperty("text"); + if (textValue->IsObject()) { + JSRef valueObj = JSRef::Cast(textValue); changeEventVal = valueObj->GetProperty("changeEvent"); - auto valueProperty = valueObj->GetProperty("value"); - if (ParseJsString(valueProperty, text)) { + if (changeEventVal->IsFunction()) { + textValue = valueObj->GetProperty("value"); + } + if (ParseJsString(textValue, text)) { value = text; } } else { - if (ParseJsString(paramObject->GetProperty("text"), text)) { + if (ParseJsString(textValue, text)) { value = text; } } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp b/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp index caeae869d47..6845b0725b4 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp @@ -628,7 +628,9 @@ bool JSTextPickerParser::ParseTextArray(const JSRef& paramObject, Pars if (getValue->IsObject()) { JSRef valueObj = JSRef::Cast(getValue); param.valueChangeEventVal = valueObj->GetProperty("changeEvent"); - getValue = valueObj->GetProperty("value"); + if (param.valueChangeEventVal->IsFunction()) { + getValue = valueObj->GetProperty("value"); + } } if (!ParseJsString(getValue, param.value)) { param.value = getRangeVector.front(); @@ -636,7 +638,9 @@ bool JSTextPickerParser::ParseTextArray(const JSRef& paramObject, Pars if (getSelected->IsObject()) { JSRef selectedObj = JSRef::Cast(getSelected); param.selectedChangeEventVal = selectedObj->GetProperty("changeEvent"); - getSelected = selectedObj->GetProperty("value"); + if (param.selectedChangeEventVal->IsFunction()) { + getSelected = selectedObj->GetProperty("value"); + } } if (!ParseJsInteger(getSelected, param.selected) && !param.value.empty()) { auto valueIterator = std::find(getRangeVector.begin(), getRangeVector.end(), param.value); From fad42495b6c045b346f612b4291615a18f0de520 Mon Sep 17 00:00:00 2001 From: Guido Grassel Date: Wed, 17 May 2023 10:00:19 +0300 Subject: [PATCH 12/99] D API 9/10 code branching C++ Signed-off-by: Guido Grassel Change-Id: I46699ca11c14585f43091a2365b7b3605db01b32 --- .../jsview/js_view_stack_processor.cpp | 11 +++++++++++ .../jsview/js_view_stack_processor.h | 8 ++++++++ .../pu_synced_property_object_one_way.ts | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.cpp index 0d5478724c7..b2533f01b56 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.cpp @@ -24,6 +24,7 @@ #include "core/components_ng/base/view_stack_model_ng.h" #include "core/components_ng/base/view_stack_processor.h" #include "frameworks/core/pipeline/base/element_register.h" +#include "foundation/arkui/ace_engine/frameworks/core/common/ace_application_info.h" namespace OHOS::Ace { @@ -88,6 +89,7 @@ void JSViewStackProcessor::JSBind(BindingTarget globalObj) JSClass::StaticMethod("visualState", JSVisualState, opt); JSClass::StaticMethod("MakeUniqueId", &JSViewStackProcessor::JSMakeUniqueId, opt); JSClass::StaticMethod("UsesNewPipeline", &JSViewStackProcessor::JsUsesNewPipeline, opt); + JSClass::StaticMethod("getApiVersion", &JSViewStackProcessor::JsGetApiVersion, opt); JSClass::Bind<>(globalObj); } @@ -142,6 +144,7 @@ void JSViewStackProcessor::JSMakeUniqueId(const JSCallbackInfo& info) const auto result = ElementRegister::GetInstance()->MakeUniqueId(); info.SetReturnValue(JSRef::Make(ToJSValue(result))); } + /** * return true of current Container uses new Pipeline */ @@ -150,4 +153,12 @@ bool JSViewStackProcessor::JsUsesNewPipeline() return Container::IsCurrentUseNewPipeline(); } +/** + * return the API version specified in the manifest.json + */ +int32_t JSViewStackProcessor::JsGetApiVersion() +{ + return AceApplicationInfo::GetInstance().GetApiTargetVersion(); +} + } // namespace OHOS::Ace::Framework diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h b/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h index 7e5ddfa8848..98d52266a06 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h @@ -76,8 +76,16 @@ public: return it->second; } + /** + * return true of current Container uses new Pipeline + */ static bool JsUsesNewPipeline(); + /** + * return the API version specified in the manifest.json + */ + static int32_t JsGetApiVersion(); + private: static void JSVisualState(const JSCallbackInfo& info); static std::map> viewMap_; diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_one_way.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_one_way.ts index d6b0ad2a545..dc7913ca459 100644 --- a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_one_way.ts +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/partial_update/pu_synced_property_object_one_way.ts @@ -242,6 +242,10 @@ class SynchedPropertyObjectOneWayPU // ViewStackProcessor.getApiVersion function is not present in API9 // therefore shallowCopyObject will always be used in API version 9 and before // but the code in this file is the same regardless of API version + stateMgmtConsole.debug(`targetApiVersion: \ + ${(typeof ViewStackProcessor["getApiVersion"] == "function") ? ViewStackProcessor["getApiVersion"]() : 'unknown'}, \ + will use ${((typeof ViewStackProcessor["getApiVersion"] == "function") && (ViewStackProcessor["getApiVersion"]() >= 10)) ? 'deep copy' : 'shallow copy'} .`); + return ((typeof ViewStackProcessor["getApiVersion"] == "function") && (ViewStackProcessor["getApiVersion"]() >= 10)) ? this.deepCopyObject(value, propName) From cf7202d4993d6cc5d866f19d752b7bddcd677647 Mon Sep 17 00:00:00 2001 From: lijiamin Date: Wed, 17 May 2023 17:00:12 +0800 Subject: [PATCH 13/99] Previewer support debug : part 2 Signed-off-by: lijiamin Change-Id: I4e2c9ed16b82b93a1d70afcea02b554de591a242 --- .../engine/jsi/jsi_declarative_engine.cpp | 3 ++- .../bridge/js_frontend/engine/jsi/ark_js_runtime.cpp | 8 +++++--- frameworks/bridge/js_frontend/engine/jsi/jsi_engine.cpp | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp index bc9c95da49a..333c5052e84 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/jsi_declarative_engine.cpp @@ -960,7 +960,8 @@ void JsiDeclarativeEngine::RegisterInitWorkerFunc() auto workerPostTask = [nativeEngine](std::function&& callback) { nativeEngine->CallDebuggerPostTaskFunc(std::move(callback)); }; - panda::JSNApi::StartDebugger(libraryPath.c_str(), vm, debugMode, gettid(), workerPostTask); + panda::JSNApi::DebugOption debugOption = {libraryPath.c_str(), debugMode}; + panda::JSNApi::StartDebugger(vm, debugOption, gettid(), workerPostTask); #endif instance->InitConsoleModule(arkNativeEngine); diff --git a/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp b/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp index 4260c661731..da502e58781 100644 --- a/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp +++ b/frameworks/bridge/js_frontend/engine/jsi/ark_js_runtime.cpp @@ -108,15 +108,17 @@ bool ArkJSRuntime::StartDebugger() bool ret = false; #if !defined(PREVIEW) if (!libPath_.empty()) { + JSNApi::DebugOption debugOption = {libPath_.c_str(), isDebugMode_}; #if !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM) ConnectServerManager::Get().AddInstance(instanceId_, language_); - ret = JSNApi::StartDebugger(libPath_.c_str(), vm_, isDebugMode_, instanceId_, debuggerPostTask_); + ret = JSNApi::StartDebugger(vm_, debugOption, instanceId_, debuggerPostTask_); #elif defined(ANDROID_PLATFORM) - ret = JSNApi::StartDebugger(libPath_.c_str(), vm_, isDebugMode_, instanceId_, debuggerPostTask_); + ret = JSNApi::StartDebugger(vm_, debugOption, instanceId_, debuggerPostTask_); #endif } #if defined(IOS_PLATFORM) - ret = JSNApi::StartDebugger(nullptr, vm_, isDebugMode_, instanceId_, debuggerPostTask_); + JSNApi::DebugOption debugOption = {nullptr, isDebugMode_}; + ret = JSNApi::StartDebugger(vm_, debugOption, instanceId_, debuggerPostTask_); #endif #endif return ret; diff --git a/frameworks/bridge/js_frontend/engine/jsi/jsi_engine.cpp b/frameworks/bridge/js_frontend/engine/jsi/jsi_engine.cpp index 38a88bc2d8e..2bcaadebe7c 100644 --- a/frameworks/bridge/js_frontend/engine/jsi/jsi_engine.cpp +++ b/frameworks/bridge/js_frontend/engine/jsi/jsi_engine.cpp @@ -3237,7 +3237,8 @@ void JsiEngine::RegisterInitWorkerFunc() auto workerPostTask = [nativeEngine](std::function&& callback) { nativeEngine->CallDebuggerPostTaskFunc(std::move(callback)); }; - panda::JSNApi::StartDebugger(libraryPath.c_str(), vm, debugMode, gettid(), workerPostTask); + panda::JSNApi::DebugOption debugOption = {libraryPath.c_str(), debugMode}; + panda::JSNApi::StartDebugger(vm, debugOption, gettid(), workerPostTask); #endif instance->RegisterConsoleModule(arkNativeEngine); // load jsfwk From 91550d53ea1c54b3ce5a7529e6da4f04f16d6fab Mon Sep 17 00:00:00 2001 From: limeng Date: Sat, 20 May 2023 18:07:27 +0800 Subject: [PATCH 14/99] fix the bug of selection start equal to selection end Signed-off-by: limeng --- .../pattern/text_field/text_field_pattern.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp index 791b692cc07..479d8f12d95 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp @@ -954,6 +954,9 @@ void TextFieldPattern::HandleSetSelection(int32_t start, int32_t end) void TextFieldPattern::AdjustTextSelectionRectOffsetX() { + if (textBoxes_.empty()) { + return; + } auto contentLeftBoundary = contentRect_.GetX(); auto contentRightBoundary = contentRect_.GetX() + contentRect_.GetSize().Width() - unitWidth_; auto selectionStart = textBoxes_.begin()->rect_.GetLeft() + textRect_.GetX(); @@ -3565,9 +3568,8 @@ void TextFieldPattern::SetTextSelection(int32_t selectionStart, int32_t selectio { selectionStart = selectionStart < 0 ? 0 : selectionStart; selectionEnd = std::clamp(selectionEnd, 0, static_cast(textEditingValue_.GetWideText().length())); - if (selectionStart >= selectionEnd) { - LOGE("The start position is greater than or equal to the end position"); - return; + if (selectionStart > selectionEnd) { + selectionStart = selectionEnd; } auto host = GetHost(); CHECK_NULL_VOID(host); @@ -3585,7 +3587,14 @@ void TextFieldPattern::SetTextSelection(int32_t selectionStart, int32_t selectio } ContainerScope scope(client->GetInstanceId()); client->HandleSetSelection(selectionStart, selectionEnd); - client->SetInSelectMode(SelectionMode::SELECT); + if (selectionStart == selectionEnd) { + client->SetInSelectMode(SelectionMode::NONE); + client->StartTwinkling(); + } else { + client->SetInSelectMode(SelectionMode::SELECT); + client->StopTwinkling(); + } + client->isUsingMouse_ = false; client->SetCaretUpdateType(CaretUpdateType::EVENT); client->CloseSelectOverlay(); client->isSelectedAreaRedraw_ = !client->isSelectedAreaRedraw_; @@ -3596,7 +3605,6 @@ void TextFieldPattern::SetTextSelection(int32_t selectionStart, int32_t selectio CHECK_NULL_VOID(eventHub); eventHub->FireOnEditChanged(true); } - client->StopTwinkling(); }; taskExecutor->PostTask(task, TaskExecutor::TaskType::UI); } From ad03c95b62235c4cc66bd17a8c6d0c242abe759f Mon Sep 17 00:00:00 2001 From: zhouyan Date: Mon, 22 May 2023 02:14:26 +0000 Subject: [PATCH 15/99] =?UTF-8?q?text=E8=A1=A5=E5=85=85TDD=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyan Change-Id: If6877acc9f24f845311502e16a12379ed433a397 --- .../components_ng/test/pattern/text/BUILD.gn | 4 +- .../test/pattern/text/text_test_ng.cpp | 839 +++++++++++++++++- 2 files changed, 793 insertions(+), 50 deletions(-) diff --git a/frameworks/core/components_ng/test/pattern/text/BUILD.gn b/frameworks/core/components_ng/test/pattern/text/BUILD.gn index a46887c36e8..c1ffb359666 100644 --- a/frameworks/core/components_ng/test/pattern/text/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text/BUILD.gn @@ -35,7 +35,7 @@ ohos_unittest("text_test_ng") { "$ace_root/frameworks/core/animation/anticipate_curve.cpp", "$ace_root/frameworks/core/animation/cubic_curve.cpp", "$ace_root/frameworks/core/animation/curves.cpp", - "$ace_root/frameworks/core/common/clipboard/clipboard_proxy.cpp", + "$ace_root/frameworks/core/common/test/mock/mock_clipboard.cpp", "$ace_root/frameworks/core/components/common/layout/grid_column_info.cpp", "$ace_root/frameworks/core/components/common/layout/grid_container_info.cpp", "$ace_root/frameworks/core/components/common/layout/grid_system_manager.cpp", @@ -79,7 +79,6 @@ ohos_unittest("text_test_ng") { "$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/manager/select_overlay/select_overlay_manager.cpp", - "$ace_root/frameworks/core/components_ng/manager/select_overlay/select_overlay_proxy.cpp", "$ace_root/frameworks/core/components_ng/pattern/button/button_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/button/button_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/flex/flex_layout_algorithm.cpp", @@ -112,6 +111,7 @@ ohos_unittest("text_test_ng") { "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/adapter/svg_canvas_image.cpp", "$ace_root/frameworks/core/components_ng/render/paint_wrapper.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/manager/select_overlay/mock_select_overlay_proxy.cpp", "$ace_root/frameworks/core/components_ng/test/pattern/text/mock/mock_text_layout_adapter.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", "$ace_root/frameworks/core/gestures/velocity_tracker.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp b/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp index 7aece9da3c1..12ba621a7a0 100644 --- a/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp @@ -44,6 +44,9 @@ #include "core/components_ng/test/pattern/text/mock/mock_txt_paragraph.h" #include "core/components_v2/inspector/inspector_constants.h" #include "core/pipeline_ng/test/mock/mock_pipeline_base.h" +#include "core/event/mouse_event.h" +#include "frameworks/base/window/drag_window.h" +#include "frameworks/core/components_ng/pattern/root/root_pattern.h" #undef private #undef protected #include "core/components_ng/pattern/text/span_model_ng.h" @@ -113,6 +116,8 @@ const Dimension ADAPT_UPDATE_FONTSIZE_VALUE = Dimension(50, DimensionUnit::PX); const std::string ROOT_TAG("root"); constexpr int32_t NODE_ID = 143; const Color FOREGROUND_COLOR_VALUE = Color::FOREGROUND; +const RectF CONTENT_RECT(3.0, 3.0, TEXT_WIDTH, TEXT_HEIGHT); +constexpr int32_t ROOT_NODE_ID = 113; using OnClickCallback = std::function; using DragDropBaseCallback = std::function&, const std::string&)>; @@ -316,6 +321,18 @@ void TextTestNg::UpdateTextLayoutProperty(RefPtr textLayoutP textLayoutProperty->UpdateTextDecoration(TextDecoration::OVERLINE); textLayoutProperty->UpdateBaselineOffset(ADAPT_BASE_LINE_OFFSET_VALUE); } + +std::pair, RefPtr> Init() +{ + TextModelNG textModelNG; + textModelNG.Create(CREATE_VALUE); + auto pattern = AceType::MakeRefPtr(); + auto frameNode = FrameNode::CreateFrameNode("Test", 1, pattern); + frameNode->geometryNode_ = AceType::MakeRefPtr(); + pattern->AttachToFrameNode(frameNode); + return { frameNode, pattern }; +} + /** * @tc.name: TextFrameNodeCreator001 * @tc.desc: Test all the properties of text. @@ -510,7 +527,7 @@ HWTEST_F(TextTestNg, OnDetachFromFrameNode002, TestSize.Level1) /** * @tc.steps: step2. call CreateAndShowSelectOverlay - * @tc.expected: step2. return the proxy which has the right SelectOverlayId + * @tc.expected: return the proxy which has the right SelectOverlayId */ auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); pattern->selectOverlayProxy_ = proxy; @@ -518,6 +535,36 @@ HWTEST_F(TextTestNg, OnDetachFromFrameNode002, TestSize.Level1) EXPECT_NE(pattern->selectOverlayProxy_, nullptr); } +/** + * @tc.name: OnDetachFromFrameNode003 + * @tc.desc: Test TextPattern OnDetachFromFrameNode when SelectOverlayProxy is not nullptr with wrong selectOverlayId. + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, OnDetachFromFrameNode003, TestSize.Level1) +{ + TextModelNG textModelNG; + textModelNG.Create(CREATE_VALUE); + + auto pattern = AceType::MakeRefPtr(); + /** + * @tc.steps: step1. construct a SelectOverlayManager + */ + SelectOverlayInfo selectOverlayInfo; + selectOverlayInfo.singleLineHeight = NODE_ID; + auto root = AceType::MakeRefPtr(ROOT_TAG, -1, AceType::MakeRefPtr(), true); + auto selectOverlayManager = AceType::MakeRefPtr(root); + + /** + * @tc.steps: step2. call CreateAndShowSelectOverlay + * @tc.expected: return the proxy which has the right SelectOverlayId + */ + auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); + pattern->selectOverlayProxy_ = proxy; + proxy->selectOverlayId_ = 1; + pattern->OnDetachFromFrameNode(nullptr); + EXPECT_NE(pattern->selectOverlayProxy_, nullptr); +} + /** * @tc.name: OnHandleMoveDone001 * @tc.desc: Test TextPattern OnHandleMoveDone when SelectOverlayProxy is not nullptr. @@ -525,14 +572,14 @@ HWTEST_F(TextTestNg, OnDetachFromFrameNode002, TestSize.Level1) */ HWTEST_F(TextTestNg, OnHandleMoveDone001, TestSize.Level1) { - TextModelNG textModelNG; - textModelNG.Create(CREATE_VALUE); - - auto pattern = AceType::MakeRefPtr(); - auto frameNode = FrameNode::CreateFrameNode("Test", 1, pattern); - pattern->AttachToFrameNode(frameNode); /** - * @tc.steps: step1. construct a SelectOverlayManager + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->textSelector_.Update(0, TEXT_SIZE_INT); + + /** + * @tc.steps: step2. construct a SelectOverlayManager */ SelectOverlayInfo selectOverlayInfo; selectOverlayInfo.singleLineHeight = NODE_ID; @@ -540,12 +587,68 @@ HWTEST_F(TextTestNg, OnHandleMoveDone001, TestSize.Level1) auto selectOverlayManager = AceType::MakeRefPtr(root); /** - * @tc.steps: step2. call CreateAndShowSelectOverlay - * @tc.expected: step2. return the proxy which has the right SelectOverlayId + * @tc.steps: step3. call CreateAndShowSelectOverlay + * @tc.expected: return the proxy which has the right SelectOverlayId */ auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); pattern->selectOverlayProxy_ = proxy; EXPECT_NE(pattern->selectOverlayProxy_, nullptr); + + /** + * @tc.steps: step4. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr());; + + /** + * @tc.steps: step5. call OnHandleMoveDone + * @tc.expected: return the proxy which has the right SelectOverlayId + */ + RectF handleRect = CONTENT_RECT; + pattern->OnHandleMoveDone(handleRect, true); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); + pattern->OnHandleMoveDone(handleRect, false); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: OnHandleMoveDone002 + * @tc.desc: Test TextPattern OnHandleMoveDone when SelectOverlayProxy is nullptr. + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, OnHandleMoveDone002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->selectOverlayProxy_ = nullptr; + pattern->textSelector_.Update(0, TEXT_SIZE_INT); + + /** + * @tc.steps: step2. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr());; + + /** + * @tc.steps: step3. call OnHandleMoveDone + * @tc.expected: the function exits normally + */ + RectF handleRect = CONTENT_RECT; + pattern->OnHandleMoveDone(handleRect, true); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); } /** @@ -555,10 +658,7 @@ HWTEST_F(TextTestNg, OnHandleMoveDone001, TestSize.Level1) */ HWTEST_F(TextTestNg, ShowSelectOverlay001, TestSize.Level1) { - TextModelNG textModelNG; - textModelNG.Create(CREATE_VALUE); - - auto pattern = AceType::MakeRefPtr(); + auto [frameNode, pattern] = Init(); /** * @tc.steps: step1. construct a SelectOverlayManager */ @@ -569,11 +669,18 @@ HWTEST_F(TextTestNg, ShowSelectOverlay001, TestSize.Level1) /** * @tc.steps: step2. call CreateAndShowSelectOverlay - * @tc.expected: step2. return the proxy which has the right SelectOverlayId + * @tc.expected: return the proxy which has the right SelectOverlayId */ auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); + auto current = selectOverlayManager->selectOverlayItem_.Upgrade(); + ASSERT_NE(current, nullptr); + proxy->selectOverlayId_ = current->GetId(); pattern->selectOverlayProxy_ = proxy; - EXPECT_NE(pattern->selectOverlayProxy_, nullptr); + ASSERT_NE(pattern->selectOverlayProxy_, nullptr); + RectF firstHandle = CONTENT_RECT; + RectF secondHandle = CONTENT_RECT; + pattern->ShowSelectOverlay(firstHandle, secondHandle); + EXPECT_EQ(pattern->selectOverlayProxy_, nullptr); } /** @@ -594,23 +701,6 @@ HWTEST_F(TextTestNg, ShowSelectOverlay002, TestSize.Level1) EXPECT_EQ(pattern->selectOverlayProxy_, nullptr); } -/** - * @tc.name: HandleOnSelectAll001 - * @tc.desc: Test TextPattern HandleOnSelectAll when frameNode is not nullptr. - * @tc.type: FUNC - */ -HWTEST_F(TextTestNg, HandleOnSelectAll001, TestSize.Level1) -{ - TextModelNG textModelNG; - textModelNG.Create(CREATE_VALUE); - - auto pattern = AceType::MakeRefPtr(); - auto frameNode = FrameNode::CreateFrameNode("Test", 1, pattern); - pattern->AttachToFrameNode(frameNode); - pattern->selectOverlayProxy_ = nullptr; - EXPECT_EQ(pattern->selectOverlayProxy_, nullptr); -} - /** * @tc.name: OnModifyDone001 * @tc.desc: Test TextPattern OnModifyDone when frameNode is not nullptr. @@ -657,12 +747,15 @@ HWTEST_F(TextTestNg, OnModifyDone002, TestSize.Level1) * copyOption: CopyOptions::InApp */ textLayoutProperty->UpdateCopyOption(CopyOptions::InApp); + textLayoutProperty->UpdateContent(TEXT_CONTENT); /** * @tc.steps: step3. check the longPressEvent. + * @tc.expected: longPressEvent is triggered */ textPattern->OnModifyDone(); EXPECT_NE(textPattern->longPressEvent_, nullptr); + EXPECT_EQ(textPattern->textForDisplay_, TEXT_CONTENT); } /** @@ -910,12 +1003,12 @@ HWTEST_F(TextTestNg, OnHandleMove001, TestSize.Level1) /** * @tc.steps: step2. call CreateAndShowSelectOverlay - * @tc.expected: step2. return the proxy which has the right SelectOverlayId + * @tc.expected: return the proxy which has the right SelectOverlayId */ auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); pattern->selectOverlayProxy_ = proxy; EXPECT_NE(pattern->selectOverlayProxy_, nullptr); -} + } /** * @tc.name: TextCreatParagraphTest001 @@ -2704,17 +2797,6 @@ HWTEST_F(TextTestNg, AddChildSpanItem001, TestSize.Level1) EXPECT_TRUE(ret); } -std::pair, RefPtr> Init() -{ - TextModelNG textModelNG; - textModelNG.Create(CREATE_VALUE); - auto pattern = AceType::MakeRefPtr(); - auto frameNode = FrameNode::CreateFrameNode("Test", 1, pattern); - frameNode->geometryNode_ = AceType::MakeRefPtr(); - pattern->AttachToFrameNode(frameNode); - return { frameNode, pattern }; -} - /** * @tc.name: ShowSelectOverlay003 * @tc.desc: test text_pattern.h ShowSelectOverlay function @@ -2739,6 +2821,41 @@ HWTEST_F(TextTestNg, ShowSelectOverlay003, TestSize.Level1) EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); } +/** + * @tc.name: ShowSelectOverlay004 + * @tc.desc: test text_pattern.h ShowSelectOverlay function when menuOptionItems_ is not nullptr + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, ShowSelectOverlay004, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + GestureEvent info; + info.localLocation_ = Offset(1, 1); + pattern->HandleLongPress(info); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + + pattern->copyOption_ = CopyOptions::InApp; + pattern->paragraph_ = AceType::MakeRefPtr(ParagraphStyle {}, nullptr); + pattern->textForDisplay_ = "test"; + pattern->textSelector_.Update(0, 20); + std::vector menuOptionItems; + MenuOptionsParam menuOptionItem1; + menuOptionItem1.content = "test1"; + menuOptionItem1.action = [](const std::string&) {}; + menuOptionItems.emplace_back(menuOptionItem1); + pattern->menuOptionItems_ = menuOptionItems; + + /** + * @tc.steps: step2. call ShowSelectOverlay function + */ + pattern->ShowSelectOverlay(pattern->textSelector_.firstHandle, pattern->textSelector_.secondHandle); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + /** * @tc.name: IsDraggable001 * @tc.desc: test text_pattern.h Draggable function @@ -2751,12 +2868,23 @@ HWTEST_F(TextTestNg, IsDraggable001, TestSize.Level1) pattern->copyOption_ = CopyOptions::Distributed; pattern->paragraph_ = AceType::MakeRefPtr(ParagraphStyle {}, nullptr); host->draggable_ = true; - // set selected rect to [0, 0] - [20, 20] + + /** + * @tc.steps: step1. set selected rect to [0, 0] - [20, 20] + * @tc.expected: return true if the location is in region + */ pattern->textSelector_.Update(0, 20); EXPECT_TRUE(pattern->IsDraggable(Offset(1, 1))); + + /** + * @tc.expected: return false if the location is not in region + */ EXPECT_FALSE(pattern->IsDraggable(Offset(21, 21))); - // text not selected + /** + * @tc.steps: step2. text not selected + * @tc.expected: return false + */ pattern->textSelector_.Update(-1); EXPECT_FALSE(pattern->IsDraggable(Offset(1, 1))); } @@ -2909,4 +3037,619 @@ HWTEST_F(TextTestNg, UpdateChildProperty002, TestSize.Level1) */ TestUpdateScenario(pattern); } + +/** + * @tc.name: HandleClickEvent001 + * @tc.desc: test test_pattern.h HandleClickEvent function with valid textSelector + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleClickEvent001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->textSelector_.Update(0, 20); + + /** + * @tc.steps: step2. create GestureEvent and call HandleClickEvent function + * @tc.expected: selectOverlay is closed + */ + GestureEvent info; + info.localLocation_ = Offset(0, 0); + pattern->HandleClickEvent(info); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleClickEvent002 + * @tc.desc: test test_pattern.h HandleClickEvent function when spanItemChildren is not nullptr. + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleClickEvent002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + /** + * @tc.steps: step2. construct spanItemChildren + */ + std::list> spanItemChildren; + auto spanItemChild1 = AceType::MakeRefPtr(); + spanItemChildren.emplace_back(spanItemChild1); + pattern->spanItemChildren_ = spanItemChildren; + + /** + * @tc.steps: step3. create paragraph + */ + ParagraphStyle paragraphStyle; + RefPtr paragraph = Paragraph::Create(paragraphStyle, FontCollection::Current()); + ASSERT_NE(paragraph, nullptr); + pattern->paragraph_ = paragraph; + + /** + * @tc.steps: step4. create GestureEvent and call HandleClickEvent function with invalid textSelector + * @tc.expected: function run rightly + */ + pattern->textSelector_.Update(-2, -2); + GestureEvent info; + info.localLocation_ = Offset(0, 0); + pattern->HandleClickEvent(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: OnVisibleChange001 + * @tc.desc: test test_pattern.h OnVisibleChange function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, OnVisibleChange001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + /** + * @tc.steps: step2.call function + * @tc.expected: selectOverlay is closed + */ + pattern->CreateHandles(); + pattern->textSelector_.Update(0, 20); + pattern->OnVisibleChange(false); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleMouseEvent001 + * @tc.desc: test test_pattern.h HandleMouseEvent function when copyOption is none + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleMouseEvent001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + /** + * @tc.steps: step2. create MouseEvent and call HandleMouseEvent function when copyOption is none + * @tc.expected: selectOverlay is closed + */ + MouseInfo info; + info.localLocation_ = Offset(1, 1); + pattern->copyOption_ = copyOption; + pattern->HandleMouseEvent(info); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleMouseEvent002 + * @tc.desc: test test_pattern.h HandleMouseEvent function when copyOption is not none + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleMouseEvent002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->textForDisplay_ = "test"; + pattern->textSelector_.Update(0, 3); + pattern->copyOption_ = CopyOptions::InApp; + + /** + * @tc.steps: step2. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr());; + pattern->contentRect_ = CONTENT_RECT; + + /** + * @tc.steps: step3. create paragraph + */ + ParagraphStyle paragraphStyle; + RefPtr paragraph = Paragraph::Create(paragraphStyle, FontCollection::Current()); + ASSERT_NE(paragraph, nullptr); + pattern->paragraph_ = paragraph; + + /** + * @tc.steps: step4. create MouseInfo and call HandleMouseEvent function + * @tc.expected: selectOverlay is not closed + */ + MouseInfo info; + info.localLocation_ = Offset(2, 2); + info.button_ = MouseButton::RIGHT_BUTTON; + info.action_ = MouseAction::PRESS; + pattern->HandleMouseEvent(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleOnCopy001 + * @tc.desc: test test_pattern.h HandleOnCopy function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleOnCopy001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + /** + * @tc.steps: step2. construct clipboard + */ + pattern->BeforeCreateLayoutWrapper(); + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto context = host->GetContext(); + ASSERT_NE(context, nullptr); + auto clipboard = ClipboardProxy::GetInstance()->GetClipboard(context->GetTaskExecutor()); + ASSERT_NE(clipboard, nullptr); + pattern->clipboard_ = clipboard; + + /** + * @tc.steps: step3. call HandleOnCopy function when textSelector is valid and textStart is equal to textEnd + * @tc.expected: selectOverlay is closed + */ + pattern->textSelector_.Update(2, 2); + pattern->HandleOnCopy(); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleOnCopy002 + * @tc.desc: test test_pattern.h HandleOnCopy function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleOnCopy002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + /** + * @tc.steps: step2. construct clipboard + */ + pattern->BeforeCreateLayoutWrapper(); + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto context = host->GetContext(); + ASSERT_NE(context, nullptr); + auto clipboard = ClipboardProxy::GetInstance()->GetClipboard(context->GetTaskExecutor()); + ASSERT_NE(clipboard, nullptr); + pattern->clipboard_ = clipboard; + + /** + * @tc.steps: step3. call HandleOnCopy function when textSelector is not valid and textStart < 0 + * @tc.expected: selectOverlay is closed + */ + pattern->textSelector_.Update(-1,20); + pattern->HandleOnCopy(); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleOnCopy003 + * @tc.desc: test test_pattern.h HandleOnCopy function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleOnCopy003, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + /** + * @tc.steps: step2. construct clipboard + */ + pattern->BeforeCreateLayoutWrapper(); + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto context = host->GetContext(); + ASSERT_NE(context, nullptr); + auto clipboard = ClipboardProxy::GetInstance()->GetClipboard(context->GetTaskExecutor()); + ASSERT_NE(clipboard, nullptr); + pattern->clipboard_ = clipboard; + + /** + * @tc.steps: step3. call HandleOnCopy function with valid textSelector and copyOption + * @tc.expected: selectOverlay is closed + */ + pattern->textSelector_.Update(0,6); + pattern->textForDisplay_ = "TestHandleOnCopy"; + pattern->copyOption_ = CopyOptions::InApp; + pattern->HandleOnCopy(); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandlePanStart001 + * @tc.desc: test text_pattern.h HandlePanStart function when IsDraggable is false + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandlePanStart001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->copyOption_ = copyOption; + pattern->textSelector_.Update(0, 20); + GestureEvent info; + info.localLocation_ = Offset(1, 1); + /** + * @tc.steps: step2. call HandlePanStart function + * @tc.expected: The function exits normally + */ + pattern->HandlePanStart(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandlePanStart002 + * @tc.desc: test text_pattern.h HandlePanStart function when IsDraggable is true + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandlePanStart002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + frameNode->draggable_ = true; + pattern->copyOption_ = CopyOptions::InApp; + pattern->textSelector_.Update(0, 3); + pattern->textForDisplay_ = TEXT_CONTENT; + pattern->selectOverlayProxy_ = nullptr; + GestureEvent info; + info.localLocation_ = Offset(1.0, 1.0); + + /** + * @tc.steps: step2. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr()); + + /** + * @tc.steps: step3. create paragraph + */ + ParagraphStyle paragraphStyle; + RefPtr paragraph = Paragraph::Create(paragraphStyle, FontCollection::Current()); + ASSERT_NE(paragraph, nullptr); + pattern->paragraph_ = paragraph; + + /** + * @tc.steps: step4. call HandlePanStart function + * @tc.expected: The function exits normally + */ + pattern->HandlePanStart(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleLongPress001 + * @tc.desc: test text_pattern.h HandleLongPress function when IsDraggable is false + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleLongPress001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + frameNode->draggable_ = false; + pattern->paragraph_ = AceType::MakeRefPtr(ParagraphStyle {}, nullptr); + pattern->copyOption_ = CopyOptions::InApp; + pattern->textSelector_.Update(0, 3); + pattern->textForDisplay_ = TEXT_CONTENT; + GestureEvent info; + info.localLocation_ = Offset(1, 1); + EXPECT_FALSE(pattern->IsDraggable(info.GetLocalLocation())); + + /** + * @tc.steps: step2. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr()); + + /** + * @tc.steps: step2. call HandleLongPress function + * @tc.expected: The function exits normally + */ + pattern->HandleLongPress(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleLongPress002 + * @tc.desc: test text_pattern.h HandleLongPress function when IsDraggable is true + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleLongPress002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + + frameNode->draggable_ = true; + pattern->paragraph_ = AceType::MakeRefPtr(ParagraphStyle {}, nullptr); + pattern->copyOption_ = CopyOptions::InApp; + pattern->textSelector_.Update(0, 3); + pattern->textForDisplay_ = TEXT_CONTENT; + GestureEvent info; + info.localLocation_ = Offset(1, 1); + /** + * @tc.steps: step2. call HandleLongPress function + * @tc.expected: The function exits normally + */ + pattern->HandleLongPress(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandlePanUpdate001 + * @tc.desc: test text_pattern.h HandlePanUpdate function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandlePanUpdate001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->copyOption_ = CopyOptions::InApp; + pattern->textSelector_.Update(0, 20); + GestureEvent info; + info.localLocation_ = Offset(1, 1); + + /** + * @tc.steps: step2. construct dragWindow_ + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipelineContext = host->GetContext(); + ASSERT_NE(pipelineContext, nullptr); + auto rect = pipelineContext->GetCurrentWindowRect(); + auto contentRect_ = CONTENT_RECT; + // create textdrag window + auto dragWindow = DragWindow::CreateTextDragWindow("APP_DRAG_WINDOW", + static_cast(host->GetPaintRectOffset().GetX() + rect.Left()), + static_cast(host->GetPaintRectOffset().GetY() + rect.Top()), + static_cast(contentRect_.Width() + contentRect_.GetX()), + contentRect_.Height() + contentRect_.GetY()); + + pattern->dragWindow_ = dragWindow; + /** + * @tc.steps: step3. call HandlePanUpdate function + * @tc.expected: The function exits normally + */ + pattern->HandlePanUpdate(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandlePanEnd001 + * @tc.desc: test text_pattern.h HandlePanUpdate function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandlePanEnd001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->copyOption_ = CopyOptions::InApp; + pattern->textSelector_.Update(0, 20); + pattern->paragraph_ = AceType::MakeRefPtr(ParagraphStyle {}, nullptr); + GestureEvent info; + info.localLocation_ = Offset(1, 1); + + /** + * @tc.steps: step2. construct dragWindow_ + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipelineContext = host->GetContext(); + ASSERT_NE(pipelineContext, nullptr); + auto rect = pipelineContext->GetCurrentWindowRect(); + auto contentRect_ = CONTENT_RECT; + // create textdrag window + auto dragWindow = DragWindow::CreateTextDragWindow("APP_DRAG_WINDOW", + static_cast(host->GetPaintRectOffset().GetX() + rect.Left()), + static_cast(host->GetPaintRectOffset().GetY() + rect.Top()), + static_cast(contentRect_.Width() + contentRect_.GetX()), + contentRect_.Height() + contentRect_.GetY()); + + pattern->dragWindow_ = dragWindow; + + /** + * @tc.steps: step3. construct dragProxy_ + */ + // draw select text on drag window + pattern->dragWindow_->DrawTextNG(pattern->paragraph_, pattern); + // add select data to clipboard + auto manager = pipelineContext->GetDragDropManager(); + ASSERT_NE(manager, nullptr); + auto dragDropProxy = manager->CreateTextDragDropProxy(); + ASSERT_NE(dragDropProxy, nullptr); + pattern->dragDropProxy_ = dragDropProxy; + + /** + * @tc.steps: step4. call HandlePanEnd function + * @tc.expected: The function exits normally + */ + pattern->HandlePanEnd(info); + EXPECT_NE(pattern->textSelector_.GetTextStart(), -1); + EXPECT_NE(pattern->textSelector_.GetTextEnd(), -1); +} + +/** + * @tc.name: HandleOnSelectAll001 + * @tc.desc: Test TextPattern HandleOnSelectAll when frameNode is not nullptr. + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleOnSelectAll001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + pattern->textForDisplay_ = "TestHandleOnSelectAll"; + pattern->selectOverlayProxy_ = nullptr; + + /** + * @tc.steps: step2. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr()); + + /** + * @tc.steps: step3. create paragraph + */ + ParagraphStyle paragraphStyle; + RefPtr paragraph = Paragraph::Create(paragraphStyle, FontCollection::Current()); + ASSERT_NE(paragraph, nullptr); + pattern->paragraph_ = paragraph; + + /** + * @tc.steps: step4. call HandleOnSelectAll + * @tc.expected:The function exits normally + */ + pattern->HandleOnSelectAll(); + EXPECT_EQ(pattern->selectOverlayProxy_, nullptr); +} + +/** + * @tc.name: HandleOnSelectAll002 + * @tc.desc: Test TextPattern HandleOnSelectAll when frameNode is not nullptr. + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, HandleOnSelectAll002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create frameNode and pattern + */ + auto [frameNode, pattern] = Init(); + /** + * @tc.steps: step2. construct a SelectOverlayManager and rootNode + */ + SelectOverlayInfo selectOverlayInfo; + selectOverlayInfo.singleLineHeight = NODE_ID; + auto root = AceType::MakeRefPtr(ROOT_TAG, -1, AceType::MakeRefPtr(), true); + auto selectOverlayManager = AceType::MakeRefPtr(root); + + /** + * @tc.steps: step3. call CreateAndShowSelectOverlay + * @tc.expected: return the proxy which has the right SelectOverlayId + */ + auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); + pattern->selectOverlayProxy_ = proxy; + pattern->textForDisplay_ = "TestHandleOnSelectAll"; + + /** + * @tc.steps: step4. construct rootNode + */ + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + auto pipeline = host->GetContext(); + ASSERT_NE(pipeline, nullptr); + pipeline->rootNode_ = FrameNode::CreateFrameNodeWithTree( + V2::ROOT_ETS_TAG, ROOT_NODE_ID, Referenced::MakeRefPtr()); + + /** + * @tc.steps: step5. call HandleOnSelectAll when selectOverlayProxy is not nullptr. + * @tc.expected:The function exits normally + */ + pattern->HandleOnSelectAll(); + EXPECT_NE(pattern->selectOverlayProxy_, nullptr); +} + +/** + * @tc.name: CloseSelectOverlay001 + * @tc.desc: Test TextPattern CloseSelectOverlay when SelectOverlayProxy is not nullptr. + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, CloseSelectOverlay001, TestSize.Level1) +{ + auto [frameNode, pattern] = Init(); + /** + * @tc.steps: step1. construct a SelectOverlayManager + */ + SelectOverlayInfo selectOverlayInfo; + selectOverlayInfo.singleLineHeight = NODE_ID; + auto root = AceType::MakeRefPtr(ROOT_TAG, -1, AceType::MakeRefPtr(), true); + auto selectOverlayManager = AceType::MakeRefPtr(root); + + /** + * @tc.steps: step2. call CreateAndShowSelectOverlay + * @tc.expected: return the proxy which has the right SelectOverlayId + */ + auto proxy = selectOverlayManager->CreateAndShowSelectOverlay(selectOverlayInfo); + pattern->selectOverlayProxy_ = proxy; + ASSERT_NE(pattern->selectOverlayProxy_, nullptr); + + /** + * @tc.steps: step3. call CloseSelectOverlay + * @tc.expected: textSelector updates successfully + */ + pattern->CloseSelectOverlay(); + EXPECT_EQ(pattern->textSelector_.GetTextStart(), -1); + EXPECT_EQ(pattern->textSelector_.GetTextEnd(), -1); +} } // namespace OHOS::Ace::NG From 19b9cf958995a89a95b6c512148e3aca89669b8c Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Mon, 22 May 2023 13:32:34 +0800 Subject: [PATCH 16/99] Fix counter paragraph Signed-off-by: sunjiakun --- .../pattern/text_field/text_field_content_modifier.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_content_modifier.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_content_modifier.cpp index 29b895d27c1..15d48a3f5f9 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_content_modifier.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_content_modifier.cpp @@ -102,14 +102,8 @@ void TextFieldContentModifier::onDraw(DrawingContext& context) } canvas.Restore(); if (showCounter_->Get() && counterParagraph) { - canvas.Save(); - RSRect clipInnerCounterRect = RSRect(offset.GetX(), textFrameRect.Bottom() - textFrameRect.Top() - - COUNTER_TEXT_AREA_MARGIN.ConvertToPx() - textFieldPattern->GetCountHeight(), - contentSize.Width() + contentOffset.GetX(), textFrameRect.Bottom() - textFrameRect.Top()); - canvas.ClipRect(clipInnerCounterRect, RSClipOp::UNION); counterParagraph->Paint(&canvas, textRectX_->Get(), textFrameRect.Bottom() - textFrameRect.Top() - COUNTER_TEXT_AREA_MARGIN.ConvertToPx() - textFieldPattern->GetCountHeight()); - canvas.Restore(); } canvas.Save(); if (showErrorState_->Get() && errorParagraph) { From 837c435eb2a1dce3aee139ab3308fa0133cc7fe3 Mon Sep 17 00:00:00 2001 From: makangcheng Date: Mon, 22 May 2023 03:48:03 +0000 Subject: [PATCH 17/99] Fix ActionSheet cancel_error Signed-off-by: makangcheng Change-Id: I819b9f770ff39e715d2f771b343423a43e6cff36 --- .../core/components_ng/pattern/dialog/dialog_pattern.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp index bf0629b40a3..cbb0251c7e2 100644 --- a/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp +++ b/frameworks/core/components_ng/pattern/dialog/dialog_pattern.cpp @@ -57,6 +57,7 @@ namespace OHOS::Ace::NG { namespace { +constexpr int32_t SHEET_INFO_IDX = -2; constexpr Dimension SHEET_IMAGE_MARGIN = 16.0_vp; constexpr Dimension SHEET_DIVIDER_WIDTH = 1.0_px; constexpr Dimension SHEET_LIST_PADDING = 24.0_vp; @@ -531,7 +532,7 @@ RefPtr DialogPattern::BuildSheetItem(const ActionSheetInfo& item) hub->AddClickEvent(item.action); } // close dialog when clicked - BindCloseCallBack(hub, -1); + BindCloseCallBack(hub, SHEET_INFO_IDX); itemRow->MountToParent(itemNode); return itemNode; From be1e9784bec8d4f75aed3ce97c33d0bf1c711ab6 Mon Sep 17 00:00:00 2001 From: zhoutianer Date: Sat, 20 May 2023 17:27:22 +0800 Subject: [PATCH 18/99] fix svg viewBox offset Signed-off-by: zhoutianer Change-Id: I8df41cc68ac7950ad6dbeac19f8b5100584baa14 --- frameworks/core/components_ng/svg/svg_dom.cpp | 29 ++++++--- .../test/mock/rosen/mock_canvas.h | 9 ++- .../test/mock/rosen/testing_canvas.h | 4 +- .../pattern/bubble/bubble_pattern_test_ng.cpp | 2 +- .../rating/rating_paint_method_test_ng.cpp | 2 +- .../core/components_ng/test/svg/BUILD.gn | 5 +- .../core/components_ng/test/svg/dom/BUILD.gn | 40 ++++++++++++ .../test/svg/dom/svg_dom_test_ng.cpp | 65 +++++++++++++++++++ .../components_ng/test/svg/parse/BUILD.gn | 7 +- 9 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 frameworks/core/components_ng/test/svg/dom/BUILD.gn create mode 100644 frameworks/core/components_ng/test/svg/dom/svg_dom_test_ng.cpp diff --git a/frameworks/core/components_ng/svg/svg_dom.cpp b/frameworks/core/components_ng/svg/svg_dom.cpp index a1e77d41bcb..76612378f62 100644 --- a/frameworks/core/components_ng/svg/svg_dom.cpp +++ b/frameworks/core/components_ng/svg/svg_dom.cpp @@ -281,13 +281,14 @@ void SvgDom::DrawImage( void SvgDom::FitImage(RSCanvas& canvas, const ImageFit& imageFit, const Size& layout) { - // abandon this function, if image component support function fitImage + // scale svg to layout_ with ImageFit applied double scaleX = 1.0; double scaleY = 1.0; - double scaleViewBox = 1.0; - double tx = 0.0; - double ty = 0.0; - double half = 0.5; + + float scaleViewBox = 1.0; + float tx = 0.0; + float ty = 0.0; + constexpr float half = 0.5f; if (!layout.IsEmpty()) { layout_ = layout; @@ -295,17 +296,27 @@ void SvgDom::FitImage(RSCanvas& canvas, const ImageFit& imageFit, const Size& la if (!layout_.IsEmpty() && (svgSize_.IsValid() && !svgSize_.IsInfinite())) { ApplyImageFit(imageFit, scaleX, scaleY); } + /* + * 1. viewBox_, svgSize_, and layout_ are on 3 different scales. + * 2. Elements are painted in viewBox_ scale but displayed in layout_ scale. + * 3. To center align svg content, we first align viewBox_ to svgSize_, then we align svgSize_ to layout_. + * 4. Canvas is initially in layout_ scale, so transformation (tx, ty) needs to be in that scale, too. + */ if (viewBox_.IsValid()) { if (svgSize_.IsValid() && !svgSize_.IsInfinite()) { - // center align viewBox to svg + // center align viewBox_ to svg, need to map viewBox_ to the scale of svgSize_ scaleViewBox = std::min(svgSize_.Width() / viewBox_.Width(), svgSize_.Height() / viewBox_.Height()); tx = svgSize_.Width() * half - (viewBox_.Width() * half + viewBox_.Left()) * scaleViewBox; ty = svgSize_.Height() * half - (viewBox_.Height() * half + viewBox_.Top()) * scaleViewBox; + // map transformation to layout_ scale + tx *= scaleX; + ty *= scaleY; + // center align svg to layout container - tx += layout_.Width() * half - svgSize_.Width() * half * scaleX; - ty += layout_.Height() * half - svgSize_.Height() * half * scaleY; + tx += (layout_.Width() - svgSize_.Width() * scaleX) * half; + ty += (layout_.Height() - svgSize_.Height() * scaleY) * half; } else if (!layout_.IsEmpty()) { - // no svg size, center align viewBox to layout container + // no svgSize_, center align viewBox to layout container scaleViewBox = std::min(layout_.Width() / viewBox_.Width(), layout_.Height() / viewBox_.Height()); tx = layout_.Width() * half - (viewBox_.Width() * half + viewBox_.Left()) * scaleViewBox; ty = layout_.Height() * half - (viewBox_.Height() * half + viewBox_.Top()) * scaleViewBox; diff --git a/frameworks/core/components_ng/test/mock/rosen/mock_canvas.h b/frameworks/core/components_ng/test/mock/rosen/mock_canvas.h index e107942fd10..e8ff2c4c450 100644 --- a/frameworks/core/components_ng/test/mock/rosen/mock_canvas.h +++ b/frameworks/core/components_ng/test/mock/rosen/mock_canvas.h @@ -35,8 +35,13 @@ public: MOCK_METHOD1(DrawRect, void(const TestingRect& rect)); MOCK_METHOD3(Rotate, void(float deg, float sx, float sy)); MOCK_METHOD1(Rotate, void(float deg)); - MOCK_METHOD2(Translate, void(float sx, float sy)); - MOCK_METHOD2(ClipRoundRect, void(const TestingRoundRect& roundRect, ClipOp op)); + MOCK_METHOD2(Translate, void(float tx, float ty)); + MOCK_METHOD2(Scale, void(float sx, float sy)); + MOCK_METHOD3(ClipRoundRectImpl, void(const TestingRoundRect& roundRect, ClipOp op, bool antiAlias)); + virtual void ClipRoundRect(const TestingRoundRect& roundRect, ClipOp op, bool antiAlias = false) + { + ClipRoundRectImpl(roundRect, op, antiAlias); + } MOCK_METHOD1(AttachPen, TestingCanvas&(const TestingPen& pen)); MOCK_METHOD1(AttachBrush, TestingCanvas&(const TestingBrush& brush)); MOCK_METHOD0(DetachPen, TestingCanvas&()); diff --git a/frameworks/core/components_ng/test/mock/rosen/testing_canvas.h b/frameworks/core/components_ng/test/mock/rosen/testing_canvas.h index 66ba9525bb3..b4b2da1981c 100644 --- a/frameworks/core/components_ng/test/mock/rosen/testing_canvas.h +++ b/frameworks/core/components_ng/test/mock/rosen/testing_canvas.h @@ -54,10 +54,10 @@ public: virtual void DrawPath(const TestingPath& path) {} virtual void DrawArc(const TestingRect& oval, float startAngle, float sweepAngle) {} virtual void DrawRect(const TestingRect& rect) {} - virtual void ClipRoundRect(const TestingRoundRect& roundRect, ClipOp op) {} + virtual void ClipRoundRect(const TestingRoundRect& roundRect, ClipOp op, bool antiAlias = false) {} virtual void Rotate(float deg, float sx, float sy) {} virtual void Rotate(float deg) {} - virtual void Translate(float dx, float dy) {} + virtual void Translate(float tx, float ty) {} virtual void DrawBitmap(const TestingBitmap& bitmap, const float px, const float py) {} virtual void DrawShadow(const TestingPath& path, const TestingPoint3& planeParams, const TestingPoint3& devLightPos, float lightRadius, TestingColor /* ambientColor */, TestingColor /* spotColor */, TestingShadowFlags flag) diff --git a/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp index 708393de96f..7623e6bb965 100644 --- a/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp @@ -799,7 +799,7 @@ HWTEST_F(BubblePatternTestNg, BubblePaintMethod001, TestSize.Level1) EXPECT_CALL(canvas, Translate(_, _)).Times(AtLeast(1)); EXPECT_CALL(canvas, DrawRoundRect(_)).Times(AtLeast(1)); EXPECT_CALL(canvas, ClipPath(_, _, _)).Times(AtLeast(1)); - EXPECT_CALL(canvas, ClipRoundRect(_, _)).Times(AtLeast(1)); + EXPECT_CALL(canvas, ClipRoundRectImpl(_, _, _)).Times(AtLeast(1)); /** * @tc.steps: step2. Create the GeometryNode and PaintWrapper.Set the progressPaintProperty. diff --git a/frameworks/core/components_ng/test/pattern/rating/rating_paint_method_test_ng.cpp b/frameworks/core/components_ng/test/pattern/rating/rating_paint_method_test_ng.cpp index 11f9d0a2617..0bf621bd4e9 100644 --- a/frameworks/core/components_ng/test/pattern/rating/rating_paint_method_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/rating/rating_paint_method_test_ng.cpp @@ -126,7 +126,7 @@ HWTEST_F(RatingPaintMethodTestNg, RatingPaintPropertyTest001, TestSize.Level1) DrawingContext context = { mockCanvas, 10.0f, 10.0f }; EXPECT_CALL(mockCanvas, DrawBackground(_)).Times(RATING_DRAW_BACKGROUND_TIMES); EXPECT_CALL(mockCanvas, Save()).Times(RATING_SAVE_TIMES); - EXPECT_CALL(mockCanvas, ClipRoundRect(_, _)).Times(RATING_CLIP_ROUND_RECT_TIMES); + EXPECT_CALL(mockCanvas, ClipRoundRectImpl(_, _, _)).Times(RATING_CLIP_ROUND_RECT_TIMES); EXPECT_CALL(mockCanvas, Restore()).Times(RATING_RESTORE_TIMES); EXPECT_CALL(mockCanvas, ClipRect(_, _)).Times(RATING_CLIP_CLIP_RECT_TIMES); ratingPaintMethod->ratingModifier_->onDraw(context); diff --git a/frameworks/core/components_ng/test/svg/BUILD.gn b/frameworks/core/components_ng/test/svg/BUILD.gn index 63cc4cac9ac..91e7c07b297 100644 --- a/frameworks/core/components_ng/test/svg/BUILD.gn +++ b/frameworks/core/components_ng/test/svg/BUILD.gn @@ -13,5 +13,8 @@ group("svg_unittest") { testonly = true - deps = [ "parse:svg_parse_unit_test" ] + deps = [ + "dom:svg_dom_test_ng", + "parse:svg_parse_unit_test", + ] } diff --git a/frameworks/core/components_ng/test/svg/dom/BUILD.gn b/frameworks/core/components_ng/test/svg/dom/BUILD.gn new file mode 100644 index 00000000000..3971ea163c3 --- /dev/null +++ b/frameworks/core/components_ng/test/svg/dom/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2023 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. + +import("//build/test.gni") +import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") + +ohos_unittest("svg_dom_test_ng") { + module_out_path = svg_test_output_path + + sources = [ + "$ace_root/frameworks/core/animation/test/mock/mock_animator.cpp", + "$ace_root/frameworks/core/components_ng/render/adapter/image_painter_utils.cpp", + "$ace_root/frameworks/core/components_ng/svg/svg_context.cpp", + "$ace_root/frameworks/core/components_ng/svg/svg_dom.cpp", + "svg_dom_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_static", + "//third_party/googletest:gmock_main", + ] + + configs = [ + "$ace_root/test/unittest:ace_unittest_config", + "../parse:config_svg_parse_test", + ] +} diff --git a/frameworks/core/components_ng/test/svg/dom/svg_dom_test_ng.cpp b/frameworks/core/components_ng/test/svg/dom/svg_dom_test_ng.cpp new file mode 100644 index 00000000000..0cecd2cc803 --- /dev/null +++ b/frameworks/core/components_ng/test/svg/dom/svg_dom_test_ng.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 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. + */ + +#include + +#include "gtest/gtest.h" + +#include "core/components_ng/test/mock/rosen/mock_canvas.h" +#include "core/components_ng/test/mock/rosen/testing_rect.h" + +#define private public +#define protected public + +#include "core/components_ng/svg/svg_dom.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Ace::NG { +namespace { +const Size LAYOUT = { 400, 500 }; +const Size SVG_SIZE = { 50, 50 }; +const Rect VIEW_BOX = { -4.0, -10.0, 300.0, 300.0 }; +constexpr float EPSILON = 0.001; +} // namespace +class SvgDomTestNg : public testing::Test {}; + +/** + * @tc.name: SvgDom001 + * @tc.desc: test fit image + * @tc.type: FUNC + */ +HWTEST_F(SvgDomTestNg, SvgDom001, TestSize.Level1) +{ + auto svgDom = AceType::MakeRefPtr(); + + svgDom->svgSize_ = SVG_SIZE; + svgDom->viewBox_ = VIEW_BOX; + Testing::MockCanvas canvas; + float layoutScale = LAYOUT.Width() / SVG_SIZE.Width(); + float viewBoxScale = SVG_SIZE.Width() / VIEW_BOX.Width(); + float tx = 4.0f * viewBoxScale * layoutScale ; + float ty = 10.0f * viewBoxScale * layoutScale; + + ty += (LAYOUT.Height() - SVG_SIZE.Height() * layoutScale) / 2; + // check translate and scale parameters + EXPECT_CALL(canvas, Translate(FloatNear(tx, EPSILON), FloatNear(ty, EPSILON))); + EXPECT_CALL(canvas, Scale(layoutScale * viewBoxScale, layoutScale * viewBoxScale)); + auto clipRect = Testing::TestingRect(0, 0, LAYOUT.Width(), LAYOUT.Height()); + EXPECT_CALL(canvas, ClipRect(_, _)); + svgDom->FitImage(canvas, ImageFit::CONTAIN, LAYOUT); +} +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/svg/parse/BUILD.gn b/frameworks/core/components_ng/test/svg/parse/BUILD.gn index f95b1b38ffb..ae58534c953 100644 --- a/frameworks/core/components_ng/test/svg/parse/BUILD.gn +++ b/frameworks/core/components_ng/test/svg/parse/BUILD.gn @@ -18,7 +18,10 @@ import( import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") config("config_svg_parse_test") { - visibility = [ ":*" ] + visibility = [ + ":*", + "../dom:*", + ] include_dirs = [ "//commonlibrary/c_utils/base/include", "//foundation/graphic/graphic_2d/rosen/modules/2d_engine", @@ -26,7 +29,7 @@ config("config_svg_parse_test") { "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include", "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src", "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/src/drawing/engine_adapter", - "//third_party/flutter/skia", + "//third_party/skia", "$ace_root", "$ace_root/frameworks", ] From d09dc8941c2dac9d7819373fc0fc9e175dc872e0 Mon Sep 17 00:00:00 2001 From: huzeqi Date: Mon, 22 May 2023 17:10:43 +0800 Subject: [PATCH 19/99] replace uid to userId Signed-off-by: huzeqi Change-Id: Id0a9c5397222c0ab0669c3e9be1732fe74992075 --- adapter/ohos/osal/page_url_checker_ohos.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapter/ohos/osal/page_url_checker_ohos.cpp b/adapter/ohos/osal/page_url_checker_ohos.cpp index 34e9136ed41..df88e51240f 100644 --- a/adapter/ohos/osal/page_url_checker_ohos.cpp +++ b/adapter/ohos/osal/page_url_checker_ohos.cpp @@ -14,6 +14,7 @@ */ #include "page_url_checker_ohos.h" + #include #include "ability_runtime/context/context.h" @@ -219,7 +220,7 @@ void PageUrlCheckerOhos::LoadPageUrl(const std::string& url, const std::function sptr routerCallback = new AtomicServiceStatusCallback(); routerCallback->SetActionEventHandler(callback); routerCallback->SetErrorEventHandler(silentInstallErrorCallBack); - if (bms->SilentInstall(want, appInfo->uid, routerCallback)) { + if (bms->SilentInstall(want, appInfo->uid / AppExecFwk::Constants::BASE_USER_RANGE, routerCallback)) { LOGI("Begin to silent install"); } } else { From 677236d5d89f05a7d6b4bf573b869f8fc0c2a712 Mon Sep 17 00:00:00 2001 From: qpzeng Date: Mon, 22 May 2023 16:13:23 +0800 Subject: [PATCH 20/99] remove UIWindow Signed-off-by: qpzeng Change-Id: Idab6b0cb33cdaf237427300be58a886285dac328 --- .../pattern/window_scene/BUILD.gn | 3 - .../scene/container/window_extension.cpp | 35 -- .../scene/container/window_extension.h | 35 -- .../scene/container/window_pattern.cpp | 364 ------------------ .../scene/container/window_pattern.h | 132 ------- .../scene/host/host_window_extension.cpp | 3 +- interfaces/inner_api/ace/BUILD.gn | 1 - interfaces/inner_api/ace/ui_window.cpp | 60 --- interfaces/inner_api/ace/ui_window.h | 51 --- 9 files changed, 1 insertion(+), 683 deletions(-) delete mode 100644 frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.cpp delete mode 100644 frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.h delete mode 100644 frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.cpp delete mode 100644 frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.h delete mode 100644 interfaces/inner_api/ace/ui_window.cpp delete mode 100644 interfaces/inner_api/ace/ui_window.h diff --git a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn index 4e63db58324..52b55ee3b5e 100644 --- a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn +++ b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn @@ -29,8 +29,6 @@ if (is_ohos_standard_system) { build_component_ng("window_scene") { sources = [ "root/root_scene_model.cpp", - "scene/container/window_extension.cpp", - "scene/container/window_pattern.cpp", "scene/host/host_window_extension.cpp", "scene/host/host_window_node.cpp", "scene/host/host_window_pattern.cpp", @@ -47,7 +45,6 @@ build_component_ng("window_scene") { external_deps = [ "ability_runtime:abilitykit_native", - "ace_engine:ace_uicontent", "input:libmmi-client", "ipc:ipc_single", "window_manager:libdm", diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.cpp deleted file mode 100644 index 3f02e83a111..00000000000 --- a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#include "core/components_ng/pattern/window_scene/scene/container/window_extension.h" - -#include "session/container/include/extension_session_stage.h" - -namespace OHOS::Ace::NG { -extern "C" ACE_EXPORT void* OHOS_ACE_CreateWindowExtension(const std::shared_ptr& context, - const sptr& iSession) -{ - LOGI("Ace lib loaded, CreateWindowExtension."); - auto windowExtension = std::make_shared(context, iSession); - return new std::shared_ptr(windowExtension); -} - -WindowExtension::WindowExtension(const std::shared_ptr& context, - const sptr& iSession) - : WindowPattern(context) -{ - sessionStage_ = new Rosen::ExtensionSessionStage(iSession); -} -} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.h b/frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.h deleted file mode 100644 index ea825c31410..00000000000 --- a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_extension.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_EXTENSION_H -#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_EXTENSION_H - -#include "core/components_ng/pattern/window_scene/scene/container/window_pattern.h" - -namespace OHOS::Ace::NG { -class WindowExtension : public WindowPattern { - DECLARE_ACE_TYPE(WindowExtension, WindowPattern); - -public: - WindowExtension(const std::shared_ptr& context, - const sptr& iSession); - ~WindowExtension() override = default; - -private: - ACE_DISALLOW_COPY_AND_MOVE(WindowExtension); -}; -} // namespace OHOS::Ace::NG - -#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_EXTENSION_H diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.cpp deleted file mode 100644 index b9c3a44737d..00000000000 --- a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#include "core/components_ng/pattern/window_scene/scene/container/window_pattern.h" - -#include "ability_context.h" - -#include "base/utils/time_util.h" -#include "core/common/container.h" -#include "core/common/container_scope.h" -#include "core/common/thread_checker.h" -#include "core/components_ng/render/adapter/rosen_render_context.h" - -namespace { -constexpr int32_t IDLE_TASK_DELAY_MILLISECOND = 51; -constexpr float ONE_SECOND_IN_NANO = 1000000000.0f; - -float GetDisplayRefreshRate() -{ -#ifdef PREVIEW - return 30.0f; -#else - return 60.0f; -#endif -} -} // namespace - -namespace OHOS::Ace::NG { -namespace { -class SizeChangeListener : public Rosen::ISizeChangeListener { -public: - explicit SizeChangeListener(const std::weak_ptr& weakWindow) : weakWindow_(weakWindow) {} - virtual ~SizeChangeListener() = default; - - void OnSizeChange(const Rosen::WSRect& rect, Rosen::SizeChangeReason reason) override - { - LOGI("OnSizeChange window rect: [%{public}d, %{public}d, %{public}u, %{public}u]", - rect.posX_, rect.posY_, rect.width_, rect.height_); - auto window = weakWindow_.lock(); - CHECK_NULL_VOID(window); - auto windowRect = Rect(rect.posX_, rect.posY_, rect.width_, rect.height_); - window->SetWindowRect(windowRect); - window->UpdateViewportConfig(windowRect, SESSION_TO_WINDOW_MAP.at(reason)); - } - -private: - const std::map SESSION_TO_WINDOW_MAP { - { Rosen::SizeChangeReason::UNDEFINED, Rosen::WindowSizeChangeReason::UNDEFINED }, - { Rosen::SizeChangeReason::HIDE, Rosen::WindowSizeChangeReason::HIDE }, - { Rosen::SizeChangeReason::MAXIMIZE, Rosen::WindowSizeChangeReason::MAXIMIZE }, - { Rosen::SizeChangeReason::RECOVER, Rosen::WindowSizeChangeReason::RECOVER }, - { Rosen::SizeChangeReason::ROTATION, Rosen::WindowSizeChangeReason::ROTATION }, - }; - std::weak_ptr weakWindow_; -}; - -class InputEventListener : public Rosen::IInputEventListener { -public: - explicit InputEventListener(int32_t instanceId) : instanceId_(instanceId) {} - virtual ~InputEventListener() = default; - - void OnPointerEvent(const std::shared_ptr& pointerEvent) override - { - ContainerScope scope(instanceId_); - auto container = Container::Current(); - CHECK_NULL_VOID(container); - auto window = static_cast(container->GetWindow()); - CHECK_NULL_VOID(window); - window->ProcessPointerEvent(pointerEvent); - } - - void OnKeyEvent(const std::shared_ptr& keyEvent) override - { - ContainerScope scope(instanceId_); - auto container = Container::Current(); - CHECK_NULL_VOID(container); - auto window = static_cast(container->GetWindow()); - CHECK_NULL_VOID(window); - window->ProcessKeyEvent(keyEvent); - } - - void OnAxisEvent(const std::shared_ptr& axisEvent) override - { - ContainerScope scope(instanceId_); - auto container = Container::Current(); - CHECK_NULL_VOID(container); - auto window = static_cast(container->GetWindow()); - CHECK_NULL_VOID(window); - window->ProcessAxisEvent(axisEvent); - } - -private: - int32_t instanceId_ = -1; -}; -} // namespace - -WindowPattern::WindowPattern(const std::shared_ptr& context) - : context_(context) -{ - ACE_DCHECK(context_); - - auto name = context_->GetBundleName(); - auto pos = name.find_last_of('.'); - name = (pos == std::string::npos) ? name : name.substr(pos + 1); // skip '.' - windowName_ = name + std::to_string(windowId_); - surfaceNode_ = CreateSurfaceNode(windowName_); -} - -void WindowPattern::Init() -{ - int64_t refreshPeriod = static_cast(ONE_SECOND_IN_NANO / GetDisplayRefreshRate()); - vsyncCallback_ = std::make_shared(); - vsyncCallback_->onCallback = [weakTask = taskExecutor_, instanceId = instanceId_, refreshPeriod]( - int64_t nanoTimestamp) { - auto onVsync = [instanceId, nanoTimestamp, refreshPeriod] { - ContainerScope scope(instanceId); - // use container to get window can make sure the window is valid - auto container = Container::Current(); - CHECK_NULL_VOID(container); - auto window = container->GetWindow(); - CHECK_NULL_VOID(window); - window->OnVsync(static_cast(nanoTimestamp), 0); - auto pipeline = container->GetPipelineContext(); - if (pipeline) { - pipeline->OnIdle(nanoTimestamp + refreshPeriod); - } - }; - auto taskExecutor = weakTask.Upgrade(); - CHECK_NULL_VOID(taskExecutor); - auto uiTaskRunner = SingleTaskExecutor::Make(taskExecutor, TaskExecutor::TaskType::UI); - if (uiTaskRunner.IsRunOnCurrentThread()) { - onVsync(); - return; - } - uiTaskRunner.PostTask([callback = std::move(onVsync)]() { callback(); }); - }; - rsUIDirector_ = Rosen::RSUIDirector::Create(); - rsUIDirector_->SetRSSurfaceNode(GetSurfaceNode()); - rsUIDirector_->SetCacheDir(AceApplicationInfo::GetInstance().GetDataFileDirPath()); - rsUIDirector_->Init(); - rsUIDirector_->SetUITaskRunner( - [taskExecutor = taskExecutor_.Upgrade(), instanceId = instanceId_](const std::function& task) { - ContainerScope scope(instanceId); - if (taskExecutor) { - taskExecutor->PostTask(task, TaskExecutor::TaskType::UI); - } - }); -} - -void WindowPattern::Destroy() -{ - vsyncCallback_.reset(); - rsUIDirector_->Destroy(); - rsUIDirector_.reset(); - callbacks_.clear(); -} - -std::shared_ptr WindowPattern::CreateSurfaceNode(const std::string& name) -{ - struct Rosen::RSSurfaceNodeConfig rsSurfaceNodeConfig; - rsSurfaceNodeConfig.SurfaceNodeName = name; - return Rosen::RSSurfaceNode::Create(rsSurfaceNodeConfig); -} - -void WindowPattern::LoadContent( - const std::string& contentUrl, NativeEngine* engine, NativeValue* storage, AbilityRuntime::Context* context) -{ - uiContent_ = UIContent::Create(context_.get(), engine); - CHECK_NULL_VOID(uiContent_); - uiContent_->Initialize(shared_from_this(), contentUrl, storage); - - uiContent_->Foreground(); - UpdateViewportConfig(GetWindowRect(), Rosen::WindowSizeChangeReason::UNDEFINED); - - auto inputListener = std::make_shared(instanceId_); - RegisterInputEventListener(inputListener); -} - -void WindowPattern::UpdateViewportConfig(const Rect& rect, Rosen::WindowSizeChangeReason reason) -{ - ViewportConfig config; - config.SetPosition(rect.Left(), rect.Top()); - config.SetSize(rect.Width(), rect.Height()); - config.SetDensity(displayDensity_); - CHECK_NULL_VOID(uiContent_); - uiContent_->UpdateViewportConfig(config, reason); -} - -void WindowPattern::SetRootFrameNode(const RefPtr& root) -{ - LOGI("WindowPattern set root frame node"); - CHECK_NULL_VOID(root); - auto rosenRenderContext = AceType::DynamicCast(root->GetRenderContext()); - CHECK_NULL_VOID(rosenRenderContext); - if (rosenRenderContext->GetRSNode()) { - rsUIDirector_->SetRoot(rosenRenderContext->GetRSNode()->GetId()); - } -} - -void WindowPattern::RequestFrame() -{ - CHECK_NULL_VOID_NOLOG(onShow_); - CHECK_RUN_ON(UI); - CHECK_NULL_VOID_NOLOG(!isRequestVsync_); - - LOGD("request next vsync"); - RequestVsync(vsyncCallback_); - lastRequestVsyncTime_ = GetSysTimestamp(); - isRequestVsync_ = true; - - auto taskExecutor = taskExecutor_.Upgrade(); - CHECK_NULL_VOID(taskExecutor); - taskExecutor->PostDelayedTask( - [id = instanceId_]() { - ContainerScope scope(id); - auto container = Container::Current(); - CHECK_NULL_VOID(container); - auto pipeline = container->GetPipelineContext(); - CHECK_NULL_VOID(pipeline); - pipeline->OnIdle(0); - }, - TaskExecutor::TaskType::UI, IDLE_TASK_DELAY_MILLISECOND); -} - -void WindowPattern::RecordFrameTime(uint64_t timeStamp, const std::string& name) -{ - LOGD("WindowPattern RecordFrameTime"); - rsUIDirector_->SetTimeStamp(timeStamp, name); -} - -bool WindowPattern::FlushCustomAnimation(uint64_t timeStamp) -{ - return rsUIDirector_->RunningCustomAnimation(timeStamp); -} - -void WindowPattern::FlushTasks() -{ - CHECK_RUN_ON(UI); - LOGD("WindowPattern flush tasks"); - rsUIDirector_->SendMessages(); -} - -void WindowPattern::RequestVsync(const std::shared_ptr& vsyncCallback) -{ - std::lock_guard lock(mutex_); - Rosen::VsyncStation::GetInstance().RequestVsync(vsyncCallback); -} - -void WindowPattern::OnShow() -{ - onShow_ = true; - rsUIDirector_->GoForeground(); - rsUIDirector_->SendMessages(); -} - -void WindowPattern::OnHide() -{ - onShow_ = false; - rsUIDirector_->GoBackground(); - rsUIDirector_->SendMessages(); -} - -void WindowPattern::SetDrawTextAsBitmap(bool useBitmap) -{ - Rosen::RSSystemProperties::SetDrawTextAsBitmap(useBitmap); -} - -float WindowPattern::GetRefreshRate() const -{ - return GetDisplayRefreshRate(); -} - -void WindowPattern::RegisterSessionStageStateListener( - const std::shared_ptr& listener) -{ - CHECK_NULL_VOID(sessionStage_); - sessionStage_->RegisterSessionStageStateListener(listener); -} - -void WindowPattern::RegisterSizeChangeListener(const std::shared_ptr& listener) -{ - CHECK_NULL_VOID(sessionStage_); - sessionStage_->RegisterSizeChangeListener(listener); -} - -void WindowPattern::RegisterInputEventListener(const std::shared_ptr& listener) -{ - CHECK_NULL_VOID(sessionStage_); - sessionStage_->RegisterInputEventListener(listener); -} - -void WindowPattern::ProcessPointerEvent(const std::shared_ptr& pointerEvent) -{ - CHECK_NULL_VOID(uiContent_); - uiContent_->ProcessPointerEvent(pointerEvent); -} - -void WindowPattern::ProcessKeyEvent(const std::shared_ptr& keyEvent) -{ - CHECK_NULL_VOID(uiContent_); - uiContent_->ProcessKeyEvent(keyEvent); -} - -void WindowPattern::ProcessAxisEvent(const std::shared_ptr& axisEvent) -{ - CHECK_NULL_VOID(uiContent_); - uiContent_->ProcessAxisEvent(axisEvent); -} - -void WindowPattern::Connect() -{ - auto sizeChangeListener = std::make_shared(weak_from_this()); - RegisterSizeChangeListener(sizeChangeListener); - - CHECK_NULL_VOID(sessionStage_); - sessionStage_->Connect(surfaceNode_); -} - -void WindowPattern::Foreground() -{ - if (uiContent_) { - uiContent_->Foreground(); - } - CHECK_NULL_VOID(sessionStage_); - sessionStage_->Foreground(); -} - -void WindowPattern::Background() -{ - if (uiContent_) { - uiContent_->Background(); - } - CHECK_NULL_VOID(sessionStage_); - sessionStage_->Background(); -} - -void WindowPattern::Disconnect() -{ - if (uiContent_) { - uiContent_->Destroy(); - } - CHECK_NULL_VOID(sessionStage_); - sessionStage_->Disconnect(); -} - -void WindowPattern::OnNewWant(const AAFwk::Want& want) -{ - if (uiContent_) { - uiContent_->OnNewWant(want); - } -} -} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.h b/frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.h deleted file mode 100644 index cdd2e19c5ae..00000000000 --- a/frameworks/core/components_ng/pattern/window_scene/scene/container/window_pattern.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_PATTERN_H -#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_PATTERN_H - -#include "session/container/include/session_stage.h" -#include "ui/rs_surface_node.h" -#include "ui/rs_ui_director.h" -#include "ui_window.h" -#include "vsync_station.h" - -#include "core/common/window.h" -#include "core/components_ng/pattern/pattern.h" - -namespace OHOS::Ace::NG { -class WindowPattern : public UIWindow, - public Pattern, - public Window, - public std::enable_shared_from_this { - DECLARE_ACE_TYPE(WindowPattern, Pattern); - -public: - WindowPattern() = default; - WindowPattern(const std::shared_ptr& context); - virtual ~WindowPattern() = default; - - void Init() override; - void Destroy() override; - - void LoadContent(const std::string& contentUrl, NativeEngine* engine, NativeValue* storage, - AbilityRuntime::Context* context = nullptr) override; - - void UpdateViewportConfig(const Rect& rect, Rosen::WindowSizeChangeReason reason); - - std::shared_ptr GetSurfaceNode() - { - return surfaceNode_; - } - - Rect GetCurrentWindowRect() const override - { - return GetWindowRect(); - } - - void SetTaskExecutor(const RefPtr& taskExecutor) override - { - taskExecutor_ = taskExecutor; - } - - void SetInstanceId(int32_t instanceId) override - { - instanceId_ = instanceId; - } - - void SetRootRenderNode(const RefPtr& root) override {} - - void SetRootFrameNode(const RefPtr& root) override; - - std::shared_ptr GetRSUIDirector() const override - { - return rsUIDirector_; - } - - void RecordFrameTime(uint64_t timeStamp, const std::string& name) override; - - void FlushTasks() override; - - bool FlushCustomAnimation(uint64_t timeStamp) override; - - void OnShow() override; - void OnHide() override; - - void SetDrawTextAsBitmap(bool useBitmap) override; - - float GetRefreshRate() const override; - - void RequestFrame() override; - - void RequestVsync(const std::shared_ptr& vsyncCallback); - - void RegisterSessionStageStateListener(const std::shared_ptr& listener) override; - void RegisterSizeChangeListener(const std::shared_ptr& listener); - void RegisterInputEventListener(const std::shared_ptr& listener); - - void ProcessPointerEvent(const std::shared_ptr& pointerEvent); - void ProcessKeyEvent(const std::shared_ptr& keyEvent); - void ProcessAxisEvent(const std::shared_ptr& axisEvent); - - void Connect() override; - void Foreground() override; - void Background() override; - void Disconnect() override; - void OnNewWant(const AAFwk::Want& want) override; - -protected: - std::shared_ptr surfaceNode_; - - std::unique_ptr uiContent_; - std::shared_ptr context_; - - sptr sessionStage_; - -private: - std::shared_ptr CreateSurfaceNode(const std::string& name); - - std::recursive_mutex mutex_; - - WeakPtr taskExecutor_; - int32_t instanceId_ = -1; - std::shared_ptr rsUIDirector_; - std::shared_ptr vsyncCallback_; - - float displayDensity_ = 1.5f; - - ACE_DISALLOW_COPY_AND_MOVE(WindowPattern); -}; -} // namespace OHOS::Ace::NG - -#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_WINDOW_PATTERN_H diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/host/host_window_extension.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/host/host_window_extension.cpp index 0e5adf20fac..882b30ec393 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/host/host_window_extension.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/host/host_window_extension.cpp @@ -17,10 +17,9 @@ #include "session/host/include/extension_session.h" #include "session_manager/include/extension_session_manager.h" +#include "ui/rs_surface_node.h" #include "adapter/ohos/entrance/ace_container.h" -#include "core/common/container.h" -#include "core/components_ng/pattern/window_scene/scene/container/window_pattern.h" #include "core/pipeline_ng/pipeline_context.h" namespace OHOS::Ace::NG { diff --git a/interfaces/inner_api/ace/BUILD.gn b/interfaces/inner_api/ace/BUILD.gn index 8e1f869cb60..6ecb0cc850c 100644 --- a/interfaces/inner_api/ace/BUILD.gn +++ b/interfaces/inner_api/ace/BUILD.gn @@ -53,7 +53,6 @@ ohos_shared_library("ace_uicontent") { "${ace_root}/interfaces/inner_api/ace/hot_reloader.cpp", "${ace_root}/interfaces/inner_api/ace/serializeable_object.cpp", "${ace_root}/interfaces/inner_api/ace/ui_content.cpp", - "${ace_root}/interfaces/inner_api/ace/ui_window.cpp", ] if (!use_mingw_win && !use_mac && !use_linux && diff --git a/interfaces/inner_api/ace/ui_window.cpp b/interfaces/inner_api/ace/ui_window.cpp deleted file mode 100644 index 94901f90f74..00000000000 --- a/interfaces/inner_api/ace/ui_window.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#include "interfaces/inner_api/ace/ui_window.h" - -#include "utils.h" - -namespace OHOS::Ace::NG { - -#if defined(WINDOWS_PLATFORM) -constexpr char ACE_LIB_NAME[] = "libace.dll"; -#elif defined(MAC_PLATFORM) -constexpr char ACE_LIB_NAME[] = "libace.dylib"; -#elif defined(LINUX_PLATFORM) -constexpr char ACE_LIB_NAME[] = "libace.so"; -#else -constexpr char ACE_LIB_NAME[] = "libace.z.so"; -#endif - -using CreateWindowExtensionFunc = std::shared_ptr* (*)(const std::shared_ptr&, - const sptr&); -constexpr char CREATE_WINDOW_EXTENSION_FUNC[] = "OHOS_ACE_CreateWindowExtension"; - -std::shared_ptr UIWindow::CreateWindowExtension( - const std::shared_ptr& context, const sptr& iSession) -{ - LIBHANDLE handle = LOADLIB(ACE_LIB_NAME); - if (handle == nullptr) { - return nullptr; - } - - auto entry = reinterpret_cast(LOADSYM(handle, CREATE_WINDOW_EXTENSION_FUNC)); - if (entry == nullptr) { - FREELIB(handle); - return nullptr; - } - - auto uiWindowPtr = entry(context, iSession); - FREELIB(handle); - if (uiWindowPtr == nullptr) { - return nullptr; - } - std::shared_ptr uiWindow = *uiWindowPtr; - delete uiWindowPtr; - - return uiWindow; -} -} // namespace OHOS::Ace::NG diff --git a/interfaces/inner_api/ace/ui_window.h b/interfaces/inner_api/ace/ui_window.h deleted file mode 100644 index 508ce99c3da..00000000000 --- a/interfaces/inner_api/ace/ui_window.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 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 FOUNDATION_ACE_INTERFACE_INNER_API_UI_WINDOW_H -#define FOUNDATION_ACE_INTERFACE_INNER_API_UI_WINDOW_H - -#include - -#include "macros.h" -#include "ui_content.h" - -namespace OHOS::Rosen { -class ISession; -class ISessionStageStateListener; -} // namespace OHOS::Rosen - -namespace OHOS::Ace::NG { -class ACE_EXPORT_WITH_PREVIEW UIWindow { -public: - static std::shared_ptr CreateWindowExtension( - const std::shared_ptr& context, const sptr& iSession); - - virtual ~UIWindow() = default; - - virtual void LoadContent(const std::string& contentUrl, NativeEngine* engine, NativeValue* storage, - AbilityRuntime::Context* context = nullptr) = 0; - - virtual void RegisterSessionStageStateListener( - const std::shared_ptr& listener) = 0; - - virtual void Connect() = 0; - virtual void Foreground() = 0; - virtual void Background() = 0; - virtual void Disconnect() = 0; - virtual void OnNewWant(const AAFwk::Want& want) = 0; -}; -} // namespace OHOS::Ace::NG - -#endif // FOUNDATION_ACE_INTERFACE_INNER_API_UI_WINDOW_H From 09dd51009ad4e8fb3fb6294060f6014bc3893dff Mon Sep 17 00:00:00 2001 From: zoulinken Date: Mon, 22 May 2023 20:43:01 +0800 Subject: [PATCH 21/99] add checkNull for cppcrash Signed-off-by: zoulinken Change-Id: I2134c57629ffd5a7f2db920ce94c978d3c2976fc --- .../components_ng/pattern/video/video_pattern.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frameworks/core/components_ng/pattern/video/video_pattern.cpp b/frameworks/core/components_ng/pattern/video/video_pattern.cpp index 40b812bc31b..0b2597c6a29 100644 --- a/frameworks/core/components_ng/pattern/video/video_pattern.cpp +++ b/frameworks/core/components_ng/pattern/video/video_pattern.cpp @@ -192,6 +192,7 @@ void VideoPattern::UpdateMediaPlayer() void VideoPattern::PrepareMediaPlayer() { auto videoLayoutProperty = GetLayoutProperty(); + CHECK_NULL_VOID(videoLayoutProperty); // src has not set/changed if (!videoLayoutProperty->HasVideoSource() || videoLayoutProperty->GetVideoSource() == src_) { LOGW("Video source is null or the source has not changed."); @@ -226,6 +227,7 @@ void VideoPattern::PrepareMediaPlayer() bool VideoPattern::SetSourceForMediaPlayer() { auto videoLayoutProperty = GetLayoutProperty(); + CHECK_NULL_VOID(videoLayoutProperty); auto videoSrc = videoLayoutProperty->GetVideoSource().value(); src_ = videoSrc; LOGI("Video Set src for media, it is : %{public}s", videoSrc.c_str()); @@ -295,6 +297,7 @@ void VideoPattern::OnCurrentTimeChange(uint32_t currentPos) OnUpdateTime(currentPos, CURRENT_POS); currentPos_ = currentPos; auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); auto json = JsonUtil::Create(true); json->Put("time", static_cast(currentPos)); auto param = json->ToString(); @@ -318,12 +321,14 @@ void VideoPattern::OnPlayerStatus(PlaybackStatus status) json->Put("start", ""); auto param = json->ToString(); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); eventHub->FireStartEvent(param); } else { auto json = JsonUtil::Create(true); json->Put("pause", ""); auto param = json->ToString(); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); eventHub->FirePauseEvent(param); } @@ -357,6 +362,7 @@ void VideoPattern::OnError(const std::string& errorId) json->Put("error", ""); auto param = json->ToString(); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); eventHub->FireErrorEvent(param); } @@ -370,6 +376,7 @@ void VideoPattern::OnResolutionChange() const SizeF videoSize = SizeF(static_cast(mediaPlayer_->GetVideoWidth()), static_cast(mediaPlayer_->GetVideoHeight())); auto videoLayoutProperty = host->GetLayoutProperty(); + CHECK_NULL_VOID(videoLayoutProperty); videoLayoutProperty->UpdateVideoSize(videoSize); LOGI("OnResolutionChange video size: %{public}s", videoSize.ToString().c_str()); host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); @@ -380,6 +387,7 @@ void VideoPattern::OnPrepared(double width, double height, uint32_t duration, ui auto host = GetHost(); CHECK_NULL_VOID(host); auto videoLayoutProperty = host->GetLayoutProperty(); + CHECK_NULL_VOID(videoLayoutProperty); videoLayoutProperty->UpdateVideoSize(SizeF(static_cast(width), static_cast(height))); host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); @@ -417,6 +425,7 @@ void VideoPattern::OnPrepared(double width, double height, uint32_t duration, ui json->Put("duration", static_cast(duration_)); auto param = json->ToString(); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); eventHub->FirePreparedEvent(param); } UpdateLooping(); @@ -441,6 +450,7 @@ void VideoPattern::OnCompletion() json->Put("finish", ""); auto param = json->ToString(); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); eventHub->FireFinishEvent(param); } @@ -1149,6 +1159,7 @@ void VideoPattern::OnSliderChange(float posTime, int32_t mode) LOGD("posTime: %{public}lf, mode: %{public}d", posTime, mode); SetCurrentTime(posTime); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); auto json = JsonUtil::Create(true); json->Put("time", static_cast(posTime)); auto param = json->ToString(); @@ -1166,6 +1177,7 @@ void VideoPattern::OnFullScreenChange(bool isFullScreen) json->Put("fullscreen", isFullScreen); auto param = json->ToString(); auto eventHub = GetEventHub(); + CHECK_NULL_VOID(eventHub); eventHub->FireFullScreenChangeEvent(param); auto host = GetHost(); CHECK_NULL_VOID(host); @@ -1241,6 +1253,7 @@ void VideoPattern::EnableDrag() auto dragEnd = [this, videoSrcBefore]( const RefPtr& event, const std::string& extraParams) { auto videoLayoutProperty = this->GetLayoutProperty(); + CHECK_NULL_VOID(videoLayoutProperty); std::shared_ptr unifiedData = event->GetData(); std::string videoSrc = ""; if (unifiedData != nullptr) { @@ -1277,6 +1290,7 @@ void VideoPattern::EnableDrag() return; } auto videoLayoutProperty = this->GetLayoutProperty(); + CHECK_NULL_VOID(videoLayoutProperty); auto json = JsonUtil::ParseJsonString(extraParams); std::string key = "extraInfo"; std::string extraInfo = json->GetString(key); From 6ab228916bb1b5aa39282cbd2273ae4c44a8c41c Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Mon, 22 May 2023 21:44:11 +0800 Subject: [PATCH 22/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtextpicker=20xtsUI?= =?UTF-8?q?=E6=B5=8B=E8=AF=95cppCrash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunjiakun --- .../declarative_frontend/jsview/js_textpicker.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp b/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp index e04cb208201..1bbbff44966 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp @@ -544,9 +544,13 @@ bool JSTextPickerParser::ParseInternalArray(const JSRef& jsRangeValue, values.emplace_back(""); } } else { - auto valueIterator = std::find(resultStr.begin(), resultStr.end(), values[index]); - if (valueIterator == resultStr.end()) { - values[index] = resultStr.front(); + if (resultStr.size() > 0) { + auto valueIterator = std::find(resultStr.begin(), resultStr.end(), values[index]); + if (valueIterator == resultStr.end()) { + values[index] = resultStr.front(); + } + } else { + values[index] = ""; } } From ae7238a685ac017b02324d206a3b9a428065113c Mon Sep 17 00:00:00 2001 From: wangchensu Date: Fri, 19 May 2023 21:22:32 +0800 Subject: [PATCH 23/99] form pattern TDD Signed-off-by: wangchensu Change-Id: Ia835900be0a97982f75066b2282eb916f010128a --- .../test/mock/render/mock_render_context.h | 4 +- .../components_ng/test/pattern/form/BUILD.gn | 2 +- .../pattern/form/form_pattern_test_ng.cpp | 524 +++++++++++++++++- .../form/mock/mock_form_manager_delegate.cpp | 7 +- .../test/pattern/form/mock/mock_form_utils.h | 42 ++ .../form/mock/mock_rs_surface_mode.cpp | 44 ++ .../pattern/form/mock/mock_sub_container.h | 39 ++ 7 files changed, 636 insertions(+), 26 deletions(-) create mode 100644 frameworks/core/components_ng/test/pattern/form/mock/mock_form_utils.h create mode 100644 frameworks/core/components_ng/test/pattern/form/mock/mock_rs_surface_mode.cpp create mode 100644 frameworks/core/components_ng/test/pattern/form/mock/mock_sub_container.h diff --git a/frameworks/core/components_ng/test/mock/render/mock_render_context.h b/frameworks/core/components_ng/test/mock/render/mock_render_context.h index b4b3eac28f2..dce256dc3de 100644 --- a/frameworks/core/components_ng/test/mock/render/mock_render_context.h +++ b/frameworks/core/components_ng/test/mock/render/mock_render_context.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -25,9 +25,11 @@ class MockRenderContext : public RenderContext { DECLARE_ACE_TYPE(MockRenderContext, RenderContext) public: ~MockRenderContext() override = default; + MOCK_METHOD4(SetBounds, void(float, float, float, float)); MOCK_METHOD0(GetPaintRectWithTransform, RectF()); MOCK_METHOD1(GetPointWithTransform, void(PointF&)); + MOCK_METHOD2(AddChild, void(const RefPtr& renderContext, int index)); }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_RENDER_CONTEXT_H diff --git a/frameworks/core/components_ng/test/pattern/form/BUILD.gn b/frameworks/core/components_ng/test/pattern/form/BUILD.gn index 714a02a1219..68c036bd506 100644 --- a/frameworks/core/components_ng/test/pattern/form/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/form/BUILD.gn @@ -111,6 +111,7 @@ ohos_unittest("form_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_context_creator.cpp", "$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_surface_creator.cpp", "$ace_root/frameworks/core/components_ng/test/mock/syntax/mock_for_each_node.cpp", + "$ace_root/frameworks/core/components_ng/test/pattern/form/mock/mock_rs_surface_mode.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", ] @@ -140,7 +141,6 @@ ohos_unittest("form_pattern_test_ng") { "form_fwk:fmskit_native", "form_fwk:form_manager", "input:libmmi-client", - "ipc:ipc_core", ] } configs = [ diff --git a/frameworks/core/components_ng/test/pattern/form/form_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/form/form_pattern_test_ng.cpp index 3100a88e0f2..68f06282997 100644 --- a/frameworks/core/components_ng/test/pattern/form/form_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/form/form_pattern_test_ng.cpp @@ -18,20 +18,35 @@ #include "gtest/gtest.h" +#include "core/components/form/resource/form_utils.h" +#include "core/pipeline/pipeline_base.h" + #define private public +#define protected public +#include "test/mock/core/common/mock_container.h" + +#include "core/common/ace_engine.h" +#include "core/common/form_manager.h" #include "core/components/common/layout/constants.h" +#include "core/components/form/resource/form_manager_delegate.h" +#include "core/components/form/sub_container.h" #include "core/components_ng/base/view_stack_processor.h" #include "core/components_ng/pattern/form/form_event_hub.h" #include "core/components_ng/pattern/form/form_layout_property.h" #include "core/components_ng/pattern/form/form_model_ng.h" #include "core/components_ng/pattern/form/form_node.h" #include "core/components_ng/pattern/form/form_pattern.h" +#include "core/components_ng/test/mock/render/mock_render_context.h" +#include "core/components_ng/test/pattern/form/mock/mock_form_utils.h" +#include "core/components_ng/test/pattern/form/mock/mock_sub_container.h" #include "core/pipeline_ng/test/mock/mock_pipeline_base.h" using namespace testing; using namespace testing::ext; namespace OHOS::Ace::NG { namespace { +constexpr float NORMAL_LENGTH = 100.0f; +constexpr int64_t FORM_ID_OF_TDD = 123456; RequestFormInfo formInfo; DirtySwapConfig config; FormModelNG formModelNG; @@ -47,7 +62,7 @@ public: void TearDown() override; protected: - static RefPtr CreateFromParagraph(); + static RefPtr CreateFromNode(); }; void FormPatternTestNg::SetUp() @@ -58,13 +73,14 @@ void FormPatternTestNg::SetUp() formInfo.bundleName = "bundle"; formInfo.abilityName = "ability"; formInfo.moduleName = "module"; + formInfo.allowUpdate = true; } void FormPatternTestNg::TearDown() { MockPipelineBase::TearDown(); } -RefPtr FormPatternTestNg::CreateFromParagraph() +RefPtr FormPatternTestNg::CreateFromNode() { formModelNG.Create(formInfo); auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); @@ -81,39 +97,79 @@ HWTEST_F(FormPatternTestNg, FormNodeTest001, TestSize.Level1) auto* stack = ViewStackProcessor::GetInstance(); auto frameNode = FormNode::GetOrCreateFormNode( "FormComponent", stack->ClaimNodeId(), []() { return AceType::MakeRefPtr(); }); - EXPECT_NE(frameNode, nullptr); + ASSERT_NE(frameNode, nullptr); } /** * @tc.name: FormPatternTestNg001 - * @tc.desc: Test OnDirtyLayoutWrapperSwap in Plugin Pattern. + * @tc.desc: Test OnDirtyLayoutWrapperSwap in Form Pattern. * @tc.type: FUNC */ HWTEST_F(FormPatternTestNg, OnDirtyLayoutWrapperSwap, TestSize.Level1) { - RefPtr frameNode = CreateFromParagraph(); + RefPtr frameNode = CreateFromNode(); auto pattern = frameNode->GetPattern(); - EXPECT_NE(pattern, nullptr); + ASSERT_NE(pattern, nullptr); RefPtr geometryNode = AceType::MakeRefPtr(); - geometryNode->SetContentSize(SizeF(100.0f, 100.0f)); - geometryNode->SetContentOffset(OffsetF(0, 0)); + geometryNode->SetFrameSize(SizeF(100.0f, 100.0f)); + geometryNode->SetFrameOffset(OffsetF(0, 0)); RefPtr layoutAlgorithm = AceType::MakeRefPtr(); auto layoutWrapper = AceType::MakeRefPtr(frameNode, geometryNode, nullptr); - EXPECT_NE(layoutWrapper, nullptr); + ASSERT_NE(layoutWrapper, nullptr); auto host = pattern->GetHost(); - EXPECT_NE(host, nullptr); + ASSERT_NE(host, nullptr); pattern->OnAttachToFrameNode(); + + /** + * @tc.steps: step2. Set call methods OnDirtyLayoutWrapperSwap when the config.skipMeasure and config.skipLayout + * dose not same everty times + * @tc.expected: Check the return value of OnDirtyLayoutWrapperSwap + */ bool skipMeasures[2] = { false, true }; for (int32_t i = 0; i < 2; ++i) { for (int32_t j = 0; j < 2; ++j) { config.skipMeasure = skipMeasures[i]; + config.skipLayout = skipMeasures[j]; auto layoutAlgorithmWrapper = AceType::MakeRefPtr(layoutAlgorithm, skipMeasures[i]); layoutWrapper->SetLayoutAlgorithm(layoutAlgorithmWrapper); - layoutWrapper->skipMeasureContent_ = skipMeasures[j]; auto isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); - EXPECT_EQ(isSwap, false); + ASSERT_EQ(isSwap, false); } } + + /** + * @tc.steps: step3. Set call methods OnDirtyLayoutWrapperSwap when card info dose not change, but the value of + * allowUpdate dose not equals. + * @tc.expected: Check the cardInfo_.allowUpdate equals formInfo.allowUpdate. + */ + config.skipMeasure = false; + ASSERT_NE(pattern->formManagerBridge_, nullptr); + pattern->cardInfo_.allowUpdate = !formInfo.allowUpdate; + auto isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); + ASSERT_EQ(pattern->cardInfo_.allowUpdate, formInfo.allowUpdate); + ASSERT_EQ(isSwap, false); + + /** + * @tc.steps: ste4. Set call methods OnDirtyLayoutWrapperSwap when card info dose not change , but the value of + * allowUpdate dose not equals, and the formManagerBridge_ is nullptr. + * @tc.expected: Check the cardInfo_.allowUpdate equals formInfo.allowUpdate. + */ + config.skipMeasure = false; + pattern->formManagerBridge_ = nullptr; + pattern->cardInfo_.allowUpdate = !formInfo.allowUpdate; + isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); + ASSERT_EQ(pattern->cardInfo_.allowUpdate, formInfo.allowUpdate); + ASSERT_EQ(isSwap, false); + + /** + * @tc.steps: step5. Set call methods OnDirtyLayoutWrapperSwap when card info dose not change , and the value of + * allowUpdate is equals, and the formManagerBridge_ is nullptr. + * @tc.expected: Check the cardInfo_.allowUpdate equals formInfo.allowUpdate. + */ + pattern->formManagerBridge_ = nullptr; + isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); + ASSERT_EQ(pattern->cardInfo_.allowUpdate, formInfo.allowUpdate); + ASSERT_EQ(isSwap, false); } /** @@ -131,7 +187,7 @@ HWTEST_F(FormPatternTestNg, FormModelNGTest001, TestSize.Level1) /** * @tc.steps: step2. Set call methods - * @tc.expected: step2. Check the FormModelNG pattern value + * @tc.expected: Check the FormModelNG pattern value */ formNG.SetDimension(1); formNG.AllowUpdate(false); @@ -139,13 +195,13 @@ HWTEST_F(FormPatternTestNg, FormModelNGTest001, TestSize.Level1) formNG.SetModuleName("test form"); auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - EXPECT_NE(frameNode, nullptr); + ASSERT_NE(frameNode, nullptr); auto property = frameNode->GetLayoutProperty(); - EXPECT_NE(property, nullptr); + ASSERT_NE(property, nullptr); auto formInfo = property->GetRequestFormInfoValue(); - EXPECT_EQ(formInfo.dimension, 1); + ASSERT_EQ(formInfo.dimension, 1); EXPECT_FALSE(formInfo.allowUpdate); - EXPECT_EQ(formInfo.moduleName, "test form"); + ASSERT_EQ(formInfo.moduleName, "test form"); } /** @@ -163,36 +219,458 @@ HWTEST_F(FormPatternTestNg, FormModelNGTest002, TestSize.Level1) /** * @tc.steps: step2. Set call methods - * @tc.expected: step2. Check the FormModelNG pattern value + * @tc.expected: Check the FormModelNG pattern value */ std::string onAcquiredValue; auto onAcquired = [&onAcquiredValue](const std::string& param) { onAcquiredValue = param; }; formNG.SetOnAcquired(std::move(onAcquired)); auto frameNodeonAcquired = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - EXPECT_NE(frameNodeonAcquired, nullptr); + ASSERT_NE(frameNodeonAcquired, nullptr); std::string onErrorValue; auto onError = [&onErrorValue](const std::string& param) { onErrorValue = param; }; formNG.SetOnError(std::move(onError)); auto frameNodeonError = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - EXPECT_NE(frameNodeonError, nullptr); + ASSERT_NE(frameNodeonError, nullptr); std::string onUninstallValue; auto onUninstall = [&onUninstallValue](const std::string& param) { onUninstallValue = param; }; formNG.SetOnUninstall(std::move(onUninstall)); auto frameNodeonUninstall = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - EXPECT_NE(frameNodeonUninstall, nullptr); + ASSERT_NE(frameNodeonUninstall, nullptr); std::string onRouterValue; auto onRouter = [&onRouterValue](const std::string& param) { onRouterValue = param; }; formNG.SetOnRouter(std::move(onRouter)); auto frameNodeonRouter = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - EXPECT_NE(frameNodeonRouter, nullptr); + ASSERT_NE(frameNodeonRouter, nullptr); std::string onLoadValue; auto onLoad = [&onLoadValue](const std::string& param) { onLoadValue = param; }; formNG.SetOnLoad(std::move(onLoad)); auto frameNodeonLoad = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - EXPECT_NE(frameNodeonLoad, nullptr); + ASSERT_NE(frameNodeonLoad, nullptr); +} + +/** + * @tc.name: OnDirtyLayoutWrapperSwap002 + * @tc.desc: Test OnDirtyLayoutWrapperSwap in Form Pattern. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, OnDirtyLayoutWrapperSwap002, TestSize.Level1) +{ + /** + * @tc.steps: step1. Init FormModelNG object + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + RefPtr geometryNode = AceType::MakeRefPtr(); + geometryNode->SetFrameOffset(OffsetF(0, 0)); + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + pattern->OnAttachToFrameNode(); + config.skipMeasure = false; + config.skipLayout = false; + frameNode->SetDraggable(true); + pattern->formManagerBridge_ = nullptr; + + /** + * @tc.steps: step2. Set different size of geometryNode and the cardInfo has changed. + * @tc.expected: Only when the width and height of geometryNode both does not equal to zero, the cardInfo_ will be + * assigned to formInfo. + */ + float length[2] = { 0, NORMAL_LENGTH }; + for (int32_t i = 0; i < 2; ++i) { + for (int32_t j = 0; j < 2; ++j) { + pattern->cardInfo_.bundleName = ""; + geometryNode->SetFrameSize(SizeF(length[i], length[j])); + RefPtr layoutAlgorithm = AceType::MakeRefPtr(); + auto layoutWrapper = AceType::MakeRefPtr(frameNode, geometryNode, nullptr); + ASSERT_NE(layoutWrapper, nullptr); + auto layoutAlgorithmWrapper = AceType::MakeRefPtr(layoutAlgorithm, false); + layoutWrapper->SetLayoutAlgorithm(layoutAlgorithmWrapper); + auto isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); + ASSERT_EQ(isSwap, false); + if (i == 1 && j == 1) { + ASSERT_EQ(pattern->cardInfo_.bundleName, formInfo.bundleName); + } else { + ASSERT_NE(pattern->cardInfo_.bundleName, formInfo.bundleName); + } + } + } + + /** + * @tc.steps: step3. Set different size of geometryNode but the cardInfo has not changed. + * @tc.expected: the cardInfo_.width and cardInfo_.height will be changed equal to the size of geometryNode. + */ + for (int32_t i = 0; i < 2; ++i) { + for (int32_t j = 0; j < 2; ++j) { + pattern->cardInfo_.width = Dimension(NORMAL_LENGTH); + pattern->cardInfo_.height = Dimension(NORMAL_LENGTH); + geometryNode->SetFrameSize(SizeF(length[i], length[j])); + RefPtr layoutAlgorithm = AceType::MakeRefPtr(); + auto layoutWrapper = AceType::MakeRefPtr(frameNode, geometryNode, nullptr); + ASSERT_NE(layoutWrapper, nullptr); + auto layoutAlgorithmWrapper = AceType::MakeRefPtr(layoutAlgorithm, false); + layoutWrapper->SetLayoutAlgorithm(layoutAlgorithmWrapper); + auto isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); + ASSERT_EQ(isSwap, false); + ASSERT_EQ(pattern->cardInfo_.width, Dimension(length[i])); + ASSERT_EQ(pattern->cardInfo_.height, Dimension(length[j])); + } + } +} + +/** + * @tc.name: OnDirtyLayoutWrapperSwap003 + * @tc.desc: Test OnDirtyLayoutWrapperSwap in Form Pattern. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, OnDirtyLayoutWrapperSwap003, TestSize.Level1) +{ + /** + * @tc.steps: step1. Init FormModelNG object + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + RefPtr geometryNode = AceType::MakeRefPtr(); + geometryNode->SetFrameOffset(OffsetF(0, 0)); + auto host = pattern->GetHost(); + ASSERT_NE(host, nullptr); + pattern->OnAttachToFrameNode(); + config.skipMeasure = false; + config.skipLayout = false; + + /** + * @tc.steps: step2. set the cardInfo_ of pattern equal to formInfo with the allowUpdate does not same.And assumed + * the card has been loaded. + */ + pattern->cardInfo_.cardName = formInfo.cardName; + pattern->cardInfo_.bundleName = formInfo.bundleName; + pattern->cardInfo_.abilityName = formInfo.abilityName; + pattern->cardInfo_.moduleName = formInfo.moduleName; + pattern->cardInfo_.allowUpdate = false; + pattern->subContainer_ = nullptr; + pattern->isLoaded_ = true; + + geometryNode->SetFrameSize(SizeF(NORMAL_LENGTH, NORMAL_LENGTH)); + RefPtr layoutAlgorithm = AceType::MakeRefPtr(); + auto layoutWrapper = AceType::MakeRefPtr(frameNode, geometryNode, nullptr); + ASSERT_NE(layoutWrapper, nullptr); + auto layoutAlgorithmWrapper = AceType::MakeRefPtr(layoutAlgorithm, false); + layoutWrapper->SetLayoutAlgorithm(layoutAlgorithmWrapper); + auto isSwap = pattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config); + ASSERT_EQ(isSwap, false); + ASSERT_EQ(pattern->cardInfo_.allowUpdate, true); + ASSERT_EQ(pattern->cardInfo_.width, Dimension(NORMAL_LENGTH)); + ASSERT_EQ(pattern->cardInfo_.height, Dimension(NORMAL_LENGTH)); +} + +/** + * @tc.name: InitFormManagerDelegate001 + * @tc.desc: Verify the InitFormManagerDelegate Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, InitFormManagerDelegate001, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and build a subContainer . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + WeakPtr context = WeakPtr(); + auto subContainer = AceType::MakeRefPtr(context); + auto formUtils = std::make_shared(); + pattern->subContainer_ = subContainer; + pattern->frameNode_ = frameNode; + + /** + * @tc.steps: step2. InitFormManagerDelegate when formUitls is nullptr. + * @tc.expected: InitFormManagerDelegate success. + */ + pattern->formManagerBridge_ = nullptr; + pattern->InitFormManagerDelegate(); + ASSERT_EQ(pattern->formManagerBridge_->formUtils_, nullptr); + + /** + * @tc.steps: step3. InitFormManagerDelegate when formManagerBridge has been created. + * @tc.expected: InitFormManagerDelegate fail. + */ + FormManager::GetInstance().SetFormUtils(formUtils); + ASSERT_EQ(FormManager::GetInstance().GetFormUtils(), formUtils); + pattern->InitFormManagerDelegate(); + ASSERT_EQ(pattern->formManagerBridge_->formUtils_, nullptr); + + /** + * @tc.steps: step4. InitFormManagerDelegate when formUitls is not nullptr. + * @tc.expected: InitFormManagerDelegate success. + */ + pattern->formManagerBridge_ = nullptr; + pattern->InitFormManagerDelegate(); + ASSERT_EQ(pattern->formManagerBridge_->formUtils_, formUtils); +} + +/** + * @tc.name: CreateCardContainer001 + * @tc.desc: Verify the CreateCardContainer Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, CreateCardContainer001, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and build a subContainer . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + WeakPtr context = WeakPtr(); + auto subContainer = AceType::MakeRefPtr(context); + auto formUtils = std::make_shared(); + pattern->subContainer_ = subContainer; + pattern->frameNode_ = frameNode; + + /** + * @tc.steps: step2. CreateCardContainer when subContainer is not nullptr. + * @tc.expected: subContainer will change. + */ + ASSERT_EQ(pattern->subContainer_, subContainer); + pattern->CreateCardContainer(); + ASSERT_NE(pattern->subContainer_, subContainer); + + /** + * @tc.steps: step3. CreateCardContainer when subContainer is nullptr. + * @tc.expected: Create subContainer success. + */ + pattern->subContainer_ = nullptr; + pattern->CreateCardContainer(); + ASSERT_NE(pattern->subContainer_, nullptr); +} + +/** + * @tc.name: CreateCardContainer002 + * @tc.desc: Verify the CreateCardContainer Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, CreateCardContainer002, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and build a subContainer . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + WeakPtr context = WeakPtr(); + auto subContainer = AceType::MakeRefPtr(context); + subContainer->instanceId_ = 0; + auto formUtils = std::make_shared(); + pattern->subContainer_ = subContainer; + pattern->frameNode_ = frameNode; + pattern->cardInfo_.id = 1; + auto mockContianer = AceType::MakeRefPtr(); + AceEngine::Get().AddContainer(ContainerScope::CurrentId(), mockContianer); + auto conainer = Container::Current(); + ASSERT_NE(conainer, nullptr); + ASSERT_EQ(conainer, mockContianer); + conainer->SetUseNewPipeline(); + ASSERT_EQ(Container::IsCurrentUseNewPipeline(), true); + + /** + * @tc.steps: step2. CreateCardContainer when subContainer is not nullptr. + * @tc.expected: subContainer will change . + */ + ASSERT_EQ(pattern->subContainer_, subContainer); + pattern->CreateCardContainer(); + ASSERT_NE(pattern->subContainer_, subContainer); + + /** + * @tc.steps: step3. CreateCardContainer when subContainer has a cache in FormManager. + * @tc.expected: subContainer in FormManager will been removed . + */ + FormManager::GetInstance().AddSubContainer(1, subContainer); + ASSERT_EQ(Container::IsCurrentUseNewPipeline(), true); + ASSERT_EQ(frameNode->GetContext()->GetInstanceId(), FormManager::GetInstance().GetSubContainer(1)->GetInstanceId()); + pattern->CreateCardContainer(); + ASSERT_EQ(FormManager::GetInstance().GetSubContainer(1), nullptr); + + /** + * @tc.steps: step4. CreateCardContainer when subContainer points to nullptr and the cache in FormManager does not + * match the cardType whith this JS_CARD. + * @tc.expected: Create subContainer success. + */ + FormManager::GetInstance().AddSubContainer(1, subContainer); + pattern->subContainer_ = nullptr; + subContainer->cardType_ = FrontendType::ETS_CARD; + pattern->CreateCardContainer(); + ASSERT_EQ(FormManager::GetInstance().GetSubContainer(1), subContainer); + ASSERT_NE(pattern->subContainer_, nullptr); + ASSERT_NE(pattern->subContainer_, subContainer); + + /** + * @tc.steps: step5. CreateCardContainer when subContainer points to nullptr and the cache in FormManager does not + * match the instanceId whith the form. + * @tc.expected: Create subContainer success. + */ + pattern->subContainer_ = nullptr; + subContainer->cardType_ = FrontendType::JS_CARD; + subContainer->instanceId_ = 2; + pattern->CreateCardContainer(); + ASSERT_EQ(FormManager::GetInstance().GetSubContainer(1), subContainer); + ASSERT_NE(pattern->subContainer_, nullptr); + ASSERT_NE(pattern->subContainer_, subContainer); +} + +/** + * @tc.name: OnRebuildFrame + * @tc.desc: Verify the OnRebuildFrame Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, OnRebuildFrame, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and build a subContainer . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + WeakPtr context = WeakPtr(); + auto renderContext = AceType::MakeRefPtr(); + frameNode->renderContext_ = renderContext; + pattern->frameNode_ = frameNode; + EXPECT_CALL(*renderContext, AddChild(_, _)).Times(1); + pattern->OnRebuildFrame(); +} + +/** + * @tc.name: RemoveSubContainer + * @tc.desc: Verify the RemoveSubContainer Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, RemoveSubContainer, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and build a subContainer . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + frameNode->eventHub_ = nullptr; + ASSERT_NE(pattern, nullptr); + WeakPtr context = WeakPtr(); + auto subContainer = AceType::MakeRefPtr(context); + subContainer->instanceId_ = 0; + pattern->subContainer_ = subContainer; + pattern->RemoveSubContainer(); + ASSERT_EQ(pattern->subContainer_, nullptr); +} + +/** + * @tc.name: ISAllowUpdate + * @tc.desc: Verify the ISAllowUpdate Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, ISAllowUpdate, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and build a subContainer . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + WeakPtr context = WeakPtr(); + auto subContainer = AceType::MakeRefPtr(context); + + /** + * @tc.steps: step2.Get allowUpate by calling ISAllowUpdate. + * @tc.expected: Check thallowUpate value. + */ + auto allowUpdate = pattern->ISAllowUpdate(); + ASSERT_EQ(allowUpdate, true); +} + +/** + * @tc.name: FireOnEvent + * @tc.desc: Verify the FireOnEvent Interface of FormPattern work correctly. + * @tc.type: FUNC + */ +HWTEST_F(FormPatternTestNg, FireOnEvent, TestSize.Level1) +{ + /** + * @tc.steps: step1. Build a FormPattern and get a FormEventHub . + */ + RefPtr frameNode = CreateFromNode(); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + auto eventHub = frameNode->GetEventHub(); + CHECK_NULL_VOID(eventHub); + + /** + * @tc.steps: step2.Call SetOnError in FormEventHub. + * @tc.expected:Call FireOnErrorEvent in FormPattern. + */ + + eventHub->SetOnError([](const std::string& string) { + auto json = JsonUtil::Create(true); + json->Put("errcode", "0"); + json->Put("msg", "msg"); + ASSERT_EQ(string, json->ToString()); + }); + pattern->FireOnErrorEvent("0", "msg"); + + /** + * @tc.steps: step3.Call SetOnUninstall in FormEventHub. + * @tc.expected: Call FireOnUninstallEvent in FormPattern. + */ + eventHub->SetOnUninstall([](const std::string& string) { + auto json = JsonUtil::Create(true); + json->Put("id", std::to_string(FORM_ID_OF_TDD).c_str()); + ASSERT_EQ(string, json->ToString()); + }); + pattern->FireOnUninstallEvent(FORM_ID_OF_TDD); + + /** + * @tc.steps: step4.Call SetOnUninstall in FormEventHub. + * @tc.expected: all FireOnUninstallEvent in FormPattern. + */ + eventHub->SetOnUninstall([](const std::string& string) { + auto json = JsonUtil::Create(true); + json->Put("id", std::to_string(FORM_ID_OF_TDD).c_str()); + ASSERT_EQ(string, json->ToString()); + }); + pattern->FireOnUninstallEvent(FORM_ID_OF_TDD); + + /** + * @tc.steps: step5.Call SetOnAcquired in FormEventHub. + * @tc.expected: Call FireOnAcquiredEvent in FormPattern. + */ + eventHub->SetOnAcquired([](const std::string& string) { + auto json = JsonUtil::Create(true); + json->Put("id", std::to_string(FORM_ID_OF_TDD).c_str()); + ASSERT_EQ(string, json->ToString()); + }); + pattern->FireOnAcquiredEvent(FORM_ID_OF_TDD); + + /** + * @tc.steps: step6.Call SetOnAcquired in FormEventHub. + * @tc.expected: Call FireOnAcquiredEvent in FormPattern. + */ + eventHub->SetOnRouter([](const std::string& string) { + auto json = JsonUtil::Create(true); + json->Put("action", "message"); + auto actionJson = JsonUtil::Create(true); + actionJson->Put("action", json); + ASSERT_EQ(string, actionJson->ToString()); + }); + auto json = JsonUtil::Create(true); + json->Put("action", "message"); + pattern->FireOnRouterEvent(json); + + /** + * @tc.steps: step7.Call SetOnLoad in FormEventHub. + * @tc.expected: Call FireOnLoadEvent in FormPattern. + */ + eventHub->SetOnLoad([](const std::string& string) { ASSERT_EQ(string, ""); }); + pattern->FireOnLoadEvent(); } } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/form/mock/mock_form_manager_delegate.cpp b/frameworks/core/components_ng/test/pattern/form/mock/mock_form_manager_delegate.cpp index 4fecab6feaa..cfe5d613e22 100644 --- a/frameworks/core/components_ng/test/pattern/form/mock/mock_form_manager_delegate.cpp +++ b/frameworks/core/components_ng/test/pattern/form/mock/mock_form_manager_delegate.cpp @@ -44,7 +44,12 @@ void FormManagerDelegate::AddFormUninstallCallback(const OnFormUninstallCallback void FormManagerDelegate::OnActionEvent(const std::string& action) {} -void FormManagerDelegate::SetFormUtils(const std::shared_ptr& formUtils) {} +void FormManagerDelegate::SetFormUtils(const std::shared_ptr& formUtils) +{ + if (formUtils) { + formUtils_ = formUtils; + } +} void FormManagerDelegate::AddRenderDelegate() {} diff --git a/frameworks/core/components_ng/test/pattern/form/mock/mock_form_utils.h b/frameworks/core/components_ng/test/pattern/form/mock/mock_form_utils.h new file mode 100644 index 00000000000..6938c407c3f --- /dev/null +++ b/frameworks/core/components_ng/test/pattern/form/mock/mock_form_utils.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 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 FOUNDATION_ACE_TEST_UNITTEST_CORE_COMMON_FORM_MOCK_FORM_TUILS_H +#define FOUNDATION_ACE_TEST_UNITTEST_CORE_COMMON_FORM_MOCK_FORM_TUILS_H + +#include + +#include "core/components/form/resource/form_utils.h" + +namespace OHOS::Ace { +class MockFormUtils final : public FormUtils { +public: + MockFormUtils() = default; + ~MockFormUtils() = default; + + int32_t RouterEvent(const int64_t formId, const std::string& action, const int32_t contianerId, + const std::string& defualtbundleName) + { + return 1; + } + + int32_t BackgroundEvent(const int64_t formId, const std::string& action, const int32_t contianerId, + const std::string& defualtbundleName) + { + return 1; + } +}; +} // namespace OHOS::Ace +#endif // FOUNDATION_ACE_TEST_UNITTEST_CORE_COMMON_FORM_MOCK_FORM_TUILS_H \ No newline at end of file diff --git a/frameworks/core/components_ng/test/pattern/form/mock/mock_rs_surface_mode.cpp b/frameworks/core/components_ng/test/pattern/form/mock/mock_rs_surface_mode.cpp new file mode 100644 index 00000000000..df202fd7a12 --- /dev/null +++ b/frameworks/core/components_ng/test/pattern/form/mock/mock_rs_surface_mode.cpp @@ -0,0 +1,44 @@ + +/* + * Copyright (c) 2023 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. + */ + +#include "render_service_client/core/ui/rs_surface_node.h" + +namespace OHOS { +namespace Rosen { +RSSurfaceNode::SharedPtr RSSurfaceNode::Create(const RSSurfaceNodeConfig& surfaceNodeConfig, bool isWindow) +{ + return nullptr; +} + +RSSurfaceNode::SharedPtr RSSurfaceNode::Create( + const RSSurfaceNodeConfig& surfaceNodeConfig, RSSurfaceNodeType type, bool isWindow) +{ + return nullptr; +} + +void RSSurfaceNode::CreateNodeInRenderThread() {} + +RSSurfaceNode::RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode) + : RSNode(isRenderServiceNode), name_(config.SurfaceNodeName) +{} + +RSSurfaceNode::RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode, NodeId id) + : RSNode(isRenderServiceNode, id), name_(config.SurfaceNodeName) +{} + +RSSurfaceNode::~RSSurfaceNode() {} +} // namespace Rosen +} // namespace OHOS diff --git a/frameworks/core/components_ng/test/pattern/form/mock/mock_sub_container.h b/frameworks/core/components_ng/test/pattern/form/mock/mock_sub_container.h new file mode 100644 index 00000000000..354cde7715b --- /dev/null +++ b/frameworks/core/components_ng/test/pattern/form/mock/mock_sub_container.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_PATTERN_FORM_MOCK_MOCK_SUB_CONTAINER_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_PATTERN_FORM_MOCK_MOCK_SUB_CONTAINER_H + +#include + +#include "gmock/gmock.h" + +#include "core/components/form/sub_container.h" + +namespace OHOS::Ace { +class MockSubContainer : public SubContainer { +public: + MockSubContainer(const WeakPtr& context) : SubContainer(context) {} + MockSubContainer(const WeakPtr& context, int32_t instanceId) : SubContainer(context, instanceId) {} + ~MockSubContainer() override = default; + + MOCK_METHOD8( + RunCard, void(int64_t formId, const std::string& path, const std::string& module, const std::string& data, + const std::map>& imageDataMap, + const std::string& formSrc, const FrontendType& cardType, const FrontendType& uiSyntax)); + MOCK_METHOD0(RunSameCard, void()); +}; +} // namespace OHOS::Ace +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_PATTERN_FORM_MOCK_MOCK_SUB_CONTAINER_H \ No newline at end of file From 5c518fd1c444f4608705f2519450fb86cec76132 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 23 May 2023 10:56:26 +0800 Subject: [PATCH 24/99] [tdd]:improve accessibility_utils tdd Change-Id: Ica096c33459227e8a4d8f530d8db32ad83cd0612 Signed-off-by: fred --- .../accessibility_utils_test_ng.cpp | 178 ++++++++++++++---- 1 file changed, 140 insertions(+), 38 deletions(-) diff --git a/frameworks/core/components_ng/test/accessibility/accessibilityutils/accessibility_utils_test_ng.cpp b/frameworks/core/components_ng/test/accessibility/accessibilityutils/accessibility_utils_test_ng.cpp index 5f2bc2e2b01..561804276e8 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilityutils/accessibility_utils_test_ng.cpp +++ b/frameworks/core/components_ng/test/accessibility/accessibilityutils/accessibility_utils_test_ng.cpp @@ -25,8 +25,7 @@ using namespace testing; using namespace testing::ext; namespace OHOS::Ace::NG { -namespace { -} // namespace +namespace {} // namespace class AccessibilityUtilsTestNg : public testing::Test { public: @@ -41,26 +40,30 @@ public: */ HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest001, TestSize.Level1) { + /** + * @tc.step1: create some Rect. + * @tc.expected: CheckBetterRect return false. + */ Rect nodeRect(5.0, 0.0, 15.0, 15.0); Rect itemRect(0.0, 0.0, 10.0, 10.0); Rect tempBest(0.0, 0.0, 10.0, 10.0); - auto result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest); - EXPECT_FALSE(result); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest); - EXPECT_FALSE(result); + /** + * @tc.step2: rect not change and test direction left right up down. + * @tc.expected: CheckBetterRect always return false. + */ + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest)); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest)); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_DOWN, itemRect, tempBest)); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest); - EXPECT_FALSE(result); - - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_DOWN, itemRect, tempBest); - EXPECT_FALSE(result); - - result = CheckBetterRect(nodeRect, 0, tempBest, itemRect); - EXPECT_FALSE(result); + /** + * @tc.step3: test CheckBetterRect with unknown direction . + * @tc.expected: CheckBetterRect return false. + */ + EXPECT_FALSE(CheckBetterRect(nodeRect, 0, tempBest, itemRect)); } - /** * @tc.name: accessibilityTest002 * @tc.desc: CheckBetterRect-OutrightBetter @@ -68,26 +71,28 @@ HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest001, TestSize.Level1) */ HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest002, TestSize.Level1) { + /** + * @tc.step1: create some Rect. + * @tc.expected: CheckBetterRect return false. + */ Rect nodeRect(5.0, 5.0, 15.0, 15.0); Rect itemRect(0.0, 0.0, 10.0, 10.0); Rect tempBest(0.0, 0.0, 10.0, 10.0); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest)); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); - auto result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest); - EXPECT_FALSE(result); - - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest); - EXPECT_FALSE(result); - + /** + * @tc.step2: change params, nodeRect now is [0.0, 0.0, 15.0, 15.0], itemRect now is [15.0, 20.0, 10.0, 10.0], + * @tc.step2: tempBest now is [15.0, 0.0 ,10.0 ,10.0]. + * @tc.expected: when direction is FOCUS_DIRECTION_RIGHT return false and FOCUS_DIRECTION_DOWN return true. + */ nodeRect.SetLeft(0.0); nodeRect.SetTop(0.0); itemRect.SetLeft(15.0); - tempBest.SetLeft(15.0); itemRect.SetTop(20.0); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest); - EXPECT_FALSE(result); - - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_DOWN, itemRect, tempBest); - EXPECT_TRUE(result); + tempBest.SetLeft(15.0); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest)); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_DOWN, itemRect, tempBest)); } /** @@ -97,26 +102,123 @@ HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest002, TestSize.Level1) */ HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest003, TestSize.Level1) { + /** + * @tc.step1: create some Rect. + * @tc.expected: CheckBetterRect return false. + */ Rect nodeRect(5.0, 0.0, 15.0, 15.0); Rect itemRect(0.0, 0.0, 10.0, 10.0); Rect tempBest(0.0, 0.0, 10.0, 10.0); - auto result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest); - EXPECT_FALSE(result); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest)); + /** + * @tc.step2: change tempBest params, tempBest now is [10.0, 0.0, 10.0, 10.0]. + * @tc.expected: CheckBetterRect return true. + */ tempBest.SetLeft(10.0); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest); - EXPECT_TRUE(result); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest)); + /** + * @tc.step2: change nodeRect params, nodeRect now is [0.0, 0.0, 15.0, 15.0]. + * @tc.expected: CheckBetterRect return false. + */ nodeRect.SetLeft(0.0); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest); - EXPECT_FALSE(result); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest)); + /** + * @tc.step2: change params, itemRect now is [15.0, 20.0, 10.0, 10.0], tempBest now is [15.0, 0.0, 10.0, 10.0]. + * @tc.expected: CheckBetterRect with direction FOCUS_DIRECTION_RIGHT meeting expectations. + */ itemRect.SetLeft(15.0); - tempBest.SetLeft(15.0); itemRect.SetTop(20.0); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest); - EXPECT_FALSE(result); - result = CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, tempBest, itemRect); - EXPECT_TRUE(result); + tempBest.SetLeft(15.0); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest)); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, tempBest, itemRect)); +} + +/** + * @tc.name: AccessibilityUtilsTest004 + * @tc.desc: Test the direction is FOCUS_DIRECTION_UP and FOCUS_DIRECTION_DOWN left remaining situation + * @tc.type: FUNC + */ +HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest004, TestSize.Level1) +{ + /** + * @tc.step1: create some Rect, itemRect and tempBest out nodeRect. + * @tc.expected: CheckBetterRect return false. + */ + Rect nodeRect(10.0, 10.0, 10.0, 10.0); + Rect itemRect(5.0, 5.0, 5.0, 5.0); + Rect tempBest(5.0, 5.0, 5.0, 5.0); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); + + /** + * @tc.step2: change itemRect params, itemRect now is [12.5, 0.0, 5.0, 5.0]. + * @tc.expected: CheckBetterRect return false. + */ + itemRect.SetLeft(12.5); + itemRect.SetTop(0.0); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); + + /** + * @tc.step3: change params, itemRect now is [15.0, 5.0, 5.0, 5.0], tempBest now is [5.0, 5.0, 4.0, 6.0]. + * @tc.expected: CheckBetterRect return true. + */ + itemRect.SetLeft(15.0); + itemRect.SetTop(5.0); + tempBest.SetWidth(4.0); + tempBest.SetHeight(6.0); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); + + /** + * @tc.step4: change tempBest params, tempBest now is [5.0, 5.0, 5.0, 5.0]. + * @tc.expected: CheckBetterRect return true. + */ + tempBest.SetHeight(5.0); + tempBest.SetWidth(5.0); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); + + /** + * @tc.step5: change tempBest params, tempBest now is [5.0, 9.5, 5.0, 0.5]. + * @tc.expected: CheckBetterRect return true. + */ + tempBest.SetHeight(0.5); + tempBest.SetTop(9.5); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_UP, itemRect, tempBest)); + + /** + * @tc.step5: change params, itemRect now is [15.0, 20.0, 5.0, 5.0], tempBest now is [20.0, 20.0, 5.0, 0.5]. + * @tc.expected: CheckBetterRect return true. + */ + itemRect.SetTop(20.0); + tempBest.SetLeft(20.0); + tempBest.SetTop(20.0); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_DOWN, itemRect, tempBest)); +} + +/** + * @tc.name: AccessibilityUtilsTest005 + * @tc.desc: Verify direction is FOCUS_DIRECTION_LEFT and FOCUS_DIRECTION_RIGHT left remaining situation. + * @tc.type: FUNC + */ +HWTEST_F(AccessibilityUtilsTestNg, AccessibilityUtilsTest005, TestSize.Level1) +{ + /** + * @tc.step1: create some Rect, intersect itemRect and nodeRect, tempBest out nodeRect. + * @tc.expected: CheckBetterRect return true. + */ + Rect nodeRect(10.0, 10.0, 10.0, 10.0); + Rect itemRect(5.0, 10.0, 5.0, 5.0); + Rect tempBest(5.0, 5.0, 5.0, 5.0); + EXPECT_TRUE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_LEFT, itemRect, tempBest)); + + /** + * @tc.step2: change params, itemRect now is [20.0, 20.0, 5.0, 5.0], tempBest now is [20.0, 5.0, 5.0, 5.0]. + * @tc.expected: CheckBetterRect return false. + */ + itemRect.SetLeft(20.0); + itemRect.SetTop(20.0); + tempBest.SetLeft(20.0); + EXPECT_FALSE(CheckBetterRect(nodeRect, FOCUS_DIRECTION_RIGHT, itemRect, tempBest)); } } // namespace OHOS::Ace::NG From 539a74f37eee364aa30d5f6a87abdc56952a31af Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Tue, 23 May 2023 11:22:20 +0800 Subject: [PATCH 25/99] If the stroke width of a ring progress which enabled shadow is close to the radius, the adjusted radius to be smaller than the stroke width. This patch fixed the issue. Signed-off-by: sunjiakun --- .../pattern/progress/progress_modifier.cpp | 10 +- .../pattern/progress/progress_test_ng.cpp | 110 ++++++++++++++++++ 2 files changed, 117 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/progress/progress_modifier.cpp b/frameworks/core/components_ng/pattern/progress/progress_modifier.cpp index 5bf8c616be9..81c0336fd53 100644 --- a/frameworks/core/components_ng/pattern/progress/progress_modifier.cpp +++ b/frameworks/core/components_ng/pattern/progress/progress_modifier.cpp @@ -50,6 +50,7 @@ constexpr Dimension SWEEP_WIDTH = 80.0_vp; constexpr float RING_SHADOW_OFFSET_X = 5.0f; constexpr float RING_SHADOW_OFFSET_Y = 5.0f; constexpr float RING_SHADOW_BLUR_RADIUS_MIN = 5.0f; +constexpr float RING_SHADOW_VALID_RADIUS_MIN = 10.0f; constexpr Dimension LINEAR_SWEEPING_LEN = 80.0_vp; constexpr float OPACITY_MAX = 1.0f; constexpr float OPACITY_MIN = 0.001f; @@ -798,14 +799,17 @@ void ProgressModifier::PaintRing(RSCanvas& canvas, const OffsetF& offset, const auto radius = std::min(contentSize.Width() / 2, contentSize.Height() / 2); auto angle = (value_->Get() / maxValue_->Get()) * ANGLE_360; auto thickness = strokeWidth_->Get(); - if (thickness >= radius) { + // No shadow is drawn if radius is less or equal to 10, because it is no enough space to draw both ring and shadow. + auto paintShadow = paintShadow_->Get() && GreatNotEqual(radius, RING_SHADOW_VALID_RADIUS_MIN); + auto shadowBlurOffset = paintShadow ? thickness / 2 + std::max(RING_SHADOW_OFFSET_X, RING_SHADOW_OFFSET_Y) : 0.0f; + if (GreatOrEqual(thickness + shadowBlurOffset, radius)) { LOGI("strokeWidth is lager than radius, auto set strokeWidth as half of radius"); thickness = radius / 2; + shadowBlurOffset = paintShadow ? thickness / 2 + std::max(RING_SHADOW_OFFSET_X, RING_SHADOW_OFFSET_Y) : 0.0f; } // The shadowBlurSigma is an empirical value. If it is greater than thickness / 5, the shadow will be cut by // the canvas boundary. auto shadowBlurSigma = std::max(thickness / 5, RING_SHADOW_BLUR_RADIUS_MIN); - auto shadowBlurOffset = thickness / 2 + std::max(RING_SHADOW_OFFSET_X, RING_SHADOW_OFFSET_Y); radius = radius - thickness / 2 - shadowBlurOffset; RingProgressData ringData; @@ -826,7 +830,7 @@ void ProgressModifier::PaintRing(RSCanvas& canvas, const OffsetF& offset, const return; } - if (paintShadow_->Get()) { + if (paintShadow) { PaintRingProgressOrShadow(canvas, ringData, true); } diff --git a/frameworks/core/components_ng/test/pattern/progress/progress_test_ng.cpp b/frameworks/core/components_ng/test/pattern/progress/progress_test_ng.cpp index 3874b063f78..9cb045930df 100644 --- a/frameworks/core/components_ng/test/pattern/progress/progress_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/progress/progress_test_ng.cpp @@ -2089,6 +2089,116 @@ HWTEST_F(ProgressTestNg, RingProgressModifier004, TestSize.Level1) EXPECT_EQ(progressModifier.progressType_->Get(), static_cast(PROGRESS_TYPE_RING)); } +/** + * @tc.name: RingProgressModifier005 + * @tc.desc: Test the modifier while drawing ring progress. + * @tc.type: FUNC + */ +HWTEST_F(ProgressTestNg, RingProgressModifier005, TestSize.Level1) +{ + /** + * @tc.steps: step1. Create ProgressModifier and set ProgressModifier property. + * @tc.expected: step1. Check the ProgressModifier property value. + */ + Gradient gradient; + GradientColor gradientColorEnd; + GradientColor gradientColorStart; + gradientColorEnd.SetLinearColor(LinearColor(Color::WHITE)); + gradientColorStart.SetLinearColor(LinearColor(Color::WHITE)); + gradientColorEnd.SetDimension(Dimension(0.0)); + gradient.AddColor(gradientColorEnd); + gradientColorStart.SetDimension(Dimension(1.0)); + gradient.AddColor(gradientColorStart); + + ProgressModifier progressModifier; + SizeF contentSize(CONTEXT_WIDTH, CONTEXT_HEIGHT); + progressModifier.SetContentSize(contentSize); + progressModifier.SetVisible(true); + progressModifier.SetProgressType(PROGRESS_TYPE_RING); + progressModifier.SetProgressStatus(ProgressStatus::PROGRESSING); + EXPECT_EQ(progressModifier.progressType_->Get(), static_cast(PROGRESS_TYPE_RING)); + LinearColor linearColor; + progressModifier.SetColor(linearColor); + EXPECT_EQ(progressModifier.color_->Get(), linearColor); + progressModifier.SetBackgroundColor(linearColor); + EXPECT_EQ(progressModifier.bgColor_->Get(), linearColor); + progressModifier.SetRingProgressColor(gradient); + progressModifier.SetMaxValue(PROGRESS_MODIFIER_VALUE); + EXPECT_EQ(progressModifier.maxValue_->Get(), PROGRESS_MODIFIER_VALUE); + progressModifier.SetValue(50.0f); + EXPECT_EQ(progressModifier.value_->Get(), 50.0f); + OffsetF offset(0, 0); + progressModifier.SetContentOffset(offset); + EXPECT_EQ(progressModifier.offset_->Get(), offset); + + Testing::MockCanvas canvas; + DrawingContext context { canvas, CONTEXT_WIDTH, CONTEXT_HEIGHT }; + EXPECT_CALL(canvas, AttachBrush(_)).WillRepeatedly(ReturnRef(canvas)); + EXPECT_CALL(canvas, AttachPen(_)).WillRepeatedly(ReturnRef(canvas)); + EXPECT_CALL(canvas, DetachPen()).WillRepeatedly(ReturnRef(canvas)); + EXPECT_CALL(canvas, DetachBrush()).WillRepeatedly(ReturnRef(canvas)); + + /** + * @tc.steps: step2. Disable shadow and make stroke width smaller than the radius, then call function onDraw. + * @tc.expected: step2. Draw ring progress without shadow. + */ + progressModifier.SetPaintShadow(false); + contentSize.SetWidth(CONTEXT_WIDTH); + contentSize.SetHeight(CONTEXT_WIDTH); + progressModifier.SetContentSize(contentSize); + progressModifier.SetStrokeWidth(50.0f); + progressModifier.onDraw(context); + EXPECT_EQ(progressModifier.contentSize_->Get(), contentSize); + + /** + * @tc.steps: step3. Disable shadow and make stroke width equal to the radius, then call function onDraw. + * @tc.expected: step3. Draw ring progress without shadow. + */ + progressModifier.SetPaintShadow(false); + contentSize.SetWidth(CONTEXT_WIDTH); + contentSize.SetHeight(CONTEXT_WIDTH); + progressModifier.SetContentSize(contentSize); + progressModifier.SetStrokeWidth(CONTEXT_WIDTH); + progressModifier.onDraw(context); + EXPECT_EQ(progressModifier.contentSize_->Get(), contentSize); + + /** + * @tc.steps: step4. Enable shadow and make stroke width smaller than the radius, then call function onDraw. + * @tc.expected: step4. Draw ring progress with shadow. + */ + progressModifier.SetPaintShadow(true); + contentSize.SetWidth(CONTEXT_WIDTH); + contentSize.SetHeight(CONTEXT_WIDTH); + progressModifier.SetContentSize(contentSize); + progressModifier.SetStrokeWidth(50.0f); + progressModifier.onDraw(context); + EXPECT_EQ(progressModifier.contentSize_->Get(), contentSize); + + /** + * @tc.steps: step5. Enable shadow and make stroke width close to the radius, then call function onDraw. + * @tc.expected: step5. Draw ring progress with shadow. + */ + progressModifier.SetPaintShadow(true); + contentSize.SetWidth(CONTEXT_WIDTH); + contentSize.SetHeight(CONTEXT_WIDTH); + progressModifier.SetContentSize(contentSize); + progressModifier.SetStrokeWidth(CONTEXT_WIDTH - 5.0f); + progressModifier.onDraw(context); + EXPECT_EQ(progressModifier.contentSize_->Get(), contentSize); + + /** + * @tc.steps: step6. Enable shadow and make radius equal to 10.0, then call function onDraw. + * @tc.expected: step6. Draw ring progress without shadow. + */ + progressModifier.SetPaintShadow(true); + contentSize.SetWidth(20.0f); + contentSize.SetHeight(20.0f); + progressModifier.SetContentSize(contentSize); + progressModifier.SetStrokeWidth(1.0f); + progressModifier.onDraw(context); + EXPECT_EQ(progressModifier.contentSize_->Get(), contentSize); +} + /** * @tc.name: LinearProgressModifier001 * @tc.desc: Test ProgressModifier. From 13bfe8abe30dcb94bc9362472ebe1d349522bae8 Mon Sep 17 00:00:00 2001 From: zhaoxinyu Date: Tue, 23 May 2023 11:52:54 +0800 Subject: [PATCH 26/99] modify menu min width Signed-off-by: zhaoxinyu Change-Id: I69d8fb98c2622028a811518f894db7fa57f9fa71 --- .../components_ng/pattern/menu/menu_layout_algorithm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp index 024e97016e6..b03e4b4c956 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp @@ -18,6 +18,7 @@ #include #include +#include "base/geometry/dimension.h" #include "base/geometry/ng/offset_t.h" #include "base/memory/referenced.h" #include "base/subwindow/subwindow_manager.h" @@ -35,11 +36,11 @@ namespace OHOS::Ace::NG { namespace { -constexpr uint32_t MIN_GRID_COUNTS = 2; constexpr uint32_t GRID_COUNTS_4 = 4; constexpr uint32_t GRID_COUNTS_6 = 6; constexpr uint32_t GRID_COUNTS_8 = 8; constexpr uint32_t GRID_COUNTS_12 = 12; +constexpr Dimension MIN_MENU_WIDTH = Dimension(64.0, DimensionUnit::VP); uint32_t GetMaxGridCounts(const RefPtr& columnInfo) { @@ -462,7 +463,7 @@ void MenuLayoutAlgorithm::UpdateConstraintWidth(LayoutWrapper* layoutWrapper, La constraint.maxSize.SetWidth(maxWidth); constraint.percentReference.SetWidth(maxWidth); // set min width - auto minWidth = static_cast(columnInfo->GetWidth(MIN_GRID_COUNTS)); + auto minWidth = static_cast(MIN_MENU_WIDTH.ConvertToPx()); auto menuPattern = layoutWrapper->GetHostNode()->GetPattern(); if (minWidth > constraint.maxSize.Width()) { minWidth = constraint.maxSize.Width(); From f6d7e18eb3355b0b93c3550386a618a3893f04da Mon Sep 17 00:00:00 2001 From: zhangxiao150 Date: Tue, 23 May 2023 06:25:22 +0000 Subject: [PATCH 27/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSelest=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=AE=BE=E7=BD=AEalign=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangxiao150 Change-Id: I5114373a2b66cf7a0296d383cfa3c11c6fe14d93 --- .../components_ng/pattern/select/select_layout_algorithm.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/select/select_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/select/select_layout_algorithm.cpp index 923814027a5..bf3afebd40b 100644 --- a/frameworks/core/components_ng/pattern/select/select_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/select/select_layout_algorithm.cpp @@ -27,7 +27,6 @@ void SelectLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) auto layoutProps = layoutWrapper->GetLayoutProperty(); CHECK_NULL_VOID(layoutProps); - layoutProps->UpdateAlignment(Alignment::CENTER); auto layoutConstraint = layoutProps->GetLayoutConstraint(); if (layoutConstraint.has_value()) { auto pipeline = PipelineBase::GetCurrentContext(); From 665a973558d44be6fe43fbb4a455082e5c9b0854 Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Tue, 23 May 2023 16:09:11 +0800 Subject: [PATCH 28/99] =?UTF-8?q?popup=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=96=87=E6=9C=ACFontStyle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sunjiakun --- .../jsview/js_view_abstract.cpp | 14 ++++++++++++++ .../components/common/properties/popup_param.h | 11 +++++++++++ .../components_ng/pattern/bubble/bubble_view.cpp | 4 ++++ .../test/pattern/bubble/bubble_pattern_test_ng.cpp | 1 + 4 files changed, 30 insertions(+) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp index dcbae47f49b..9d277225792 100755 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp @@ -111,6 +111,7 @@ constexpr int32_t PARAMETER_LENGTH_SECOND = 2; constexpr int32_t PARAMETER_LENGTH_THIRD = 3; constexpr float DEFAULT_SCALE_LIGHT = 0.9f; constexpr float DEFAULT_SCALE_MIDDLE_OR_HEAVY = 0.95f; +const std::vector FONT_STYLES = { FontStyle::NORMAL, FontStyle::ITALIC }; bool CheckJSCallbackInfo( const std::string& callerName, const JSCallbackInfo& info, std::vector& infoTypes) @@ -611,6 +612,19 @@ void SetPopupMessageOptions(const JSRef messageOptionsObj, const RefPt LOGI("Empty popup."); } } + auto fontStyleValue = fontObj->GetProperty("style"); + if (fontStyleValue->IsNumber()) { + int32_t value = fontStyleValue->ToNumber(); + if (value < 0 || value >= static_cast(FONT_STYLES.size())) { + LOGI("Text fontStyle(%d) is invalid value", value); + return; + } + if (popupParam) { + popupParam->SetFontStyle(FONT_STYLES[value]); + } else { + LOGI("Empty popup."); + } + } } } diff --git a/frameworks/core/components/common/properties/popup_param.h b/frameworks/core/components/common/properties/popup_param.h index f21dc0b47a9..f6403e32fc3 100644 --- a/frameworks/core/components/common/properties/popup_param.h +++ b/frameworks/core/components/common/properties/popup_param.h @@ -319,6 +319,16 @@ public: return fontWeight_; } + void SetFontStyle(const FontStyle& fontStyle) + { + fontStyle_ = fontStyle; + } + + const std::optional& GetFontStyle() const + { + return fontStyle_; + } + private: bool isShow_ = true; bool hasAction_ = false; @@ -345,6 +355,7 @@ private: std::optional fontWeight_; std::optional textColor_; std::optional fontSize_; + std::optional fontStyle_; // Used in NG mode StateChangeFunc onStateChange_; diff --git a/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp b/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp index 2491df1902e..979833ef485 100644 --- a/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp +++ b/frameworks/core/components_ng/pattern/bubble/bubble_view.cpp @@ -88,6 +88,10 @@ void UpdateTextProperties(const RefPtr& param, const RefPtrUpdateFontWeight(fontWeight.value()); } + auto fontStyle = param->GetFontStyle(); + if (fontStyle.has_value()) { + textLayoutProps->UpdateItalicFontStyle(fontStyle.value()); + } } } // namespace diff --git a/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp index feadbc75a1e..7645b27860d 100644 --- a/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/bubble/bubble_pattern_test_ng.cpp @@ -526,6 +526,7 @@ HWTEST_F(BubblePatternTestNg, BubblePatternTest007, TestSize.Level1) popupParam->SetTextColor(BUBBLE_PAINT_PROPERTY_TEXT_COLOR); popupParam->SetFontSize(BUBBLE_PAINT_PROPERTY_FONT_SIZE); popupParam->SetFontWeight(BUBBLE_PAINT_PROPERTY_FONT_WEIGHT); + popupParam->SetFontStyle(Ace::FontStyle::ITALIC); // create bubbleNode auto targetNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, From 4b5d0f218d1bcb1f7dc788775e1e80b424611994 Mon Sep 17 00:00:00 2001 From: zhangrongjie Date: Tue, 23 May 2023 07:33:17 +0000 Subject: [PATCH 29/99] fix minPlatformVersion value error in FA model Signed-off-by: zhangrongjie Change-Id: I4028cc960e713ba71ea1017185760c54c628c2ea --- adapter/ohos/entrance/ace_ability.cpp | 1 + .../components_ng/pattern/stage/stage_manager.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/adapter/ohos/entrance/ace_ability.cpp b/adapter/ohos/entrance/ace_ability.cpp index 150dc740481..eb7e0f017e5 100644 --- a/adapter/ohos/entrance/ace_ability.cpp +++ b/adapter/ohos/entrance/ace_ability.cpp @@ -492,6 +492,7 @@ void AceAbility::OnStart(const Want& want, sptr sessionInfo) KeyboardAnimationConfig config = { rsConfig.curveType_, rsConfig.curveParams_, rsConfig.durationIn_, rsConfig.durationOut_ }; context->SetKeyboardAnimationConfig(config); + context->SetMinPlatformVersion(apiCompatibleVersion); } // get url diff --git a/frameworks/core/components_ng/pattern/stage/stage_manager.cpp b/frameworks/core/components_ng/pattern/stage/stage_manager.cpp index f11c0069e9f..2af0bf15afe 100644 --- a/frameworks/core/components_ng/pattern/stage/stage_manager.cpp +++ b/frameworks/core/components_ng/pattern/stage/stage_manager.cpp @@ -396,11 +396,14 @@ void StageManager::FirePageShow(const RefPtr& node, PageTransitionType t auto layoutProperty = pageNode->GetLayoutProperty(); auto pipeline = PipelineBase::GetCurrentContext(); const static int32_t PLATFORM_VERSION_TEN = 10; - if (pipeline && pipeline->GetMinPlatformVersion() >= PLATFORM_VERSION_TEN && !pipeline->GetIgnoreViewSafeArea() && - layoutProperty) { - layoutProperty->SetSafeArea(pipeline->GetCurrentViewSafeArea()); + if (pipeline) { + LOGI("FirePageShow MinPlatformVersion:%{public}d, IgnoreViewSafeArea:%{public}u", + pipeline->GetMinPlatformVersion(), pipeline->GetIgnoreViewSafeArea()); + if (pipeline->GetMinPlatformVersion() >= PLATFORM_VERSION_TEN && !pipeline->GetIgnoreViewSafeArea() && + layoutProperty) { + layoutProperty->SetSafeArea(pipeline->GetCurrentViewSafeArea()); + } } - auto pageFocusHub = pageNode->GetFocusHub(); CHECK_NULL_VOID(pageFocusHub); pageFocusHub->SetParentFocusable(true); From f8692ede022a101e376e230cb52c60aa858e031d Mon Sep 17 00:00:00 2001 From: lizhan Date: Tue, 23 May 2023 15:58:18 +0800 Subject: [PATCH 30/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dime=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lizhan Change-Id: Ia6a406012105ea0d84b3e5326f3677c1c5498d6f --- test/unittest/ace_unittest.gni | 1 + test/unittest/core/common/ime/BUILD.gn | 30 ++++++++++---------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/test/unittest/ace_unittest.gni b/test/unittest/ace_unittest.gni index 5ab708ad2cd..ab63dee3035 100644 --- a/test/unittest/ace_unittest.gni +++ b/test/unittest/ace_unittest.gni @@ -160,6 +160,7 @@ template("ace_unittest") { sources += invoker.sources sources += flutter_sources deps = ace_unittest_deps + deps += [ "$ace_root/test/unittest:ace_base" ] configs = ace_unittest_config diff --git a/test/unittest/core/common/ime/BUILD.gn b/test/unittest/core/common/ime/BUILD.gn index ac3f4383f02..869264c1516 100644 --- a/test/unittest/core/common/ime/BUILD.gn +++ b/test/unittest/core/common/ime/BUILD.gn @@ -11,27 +11,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/test.gni") import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") - -ohos_unittest("ime_test") { - module_out_path = "$basic_test_output_path/common" - - include_dirs = [ - "//foundation/window/window_manager/interfaces/innerkits", - "//third_party/flutter/engine/", - ] - - sources = [ "ime_test.cpp" ] - - configs = [ "$ace_root/test/unittest:ace_unittest_config" ] - - deps = [ - "$ace_flutter_engine_root/skia:ace_skia_ohos", - "$ace_root/build:ace_ohos_unittest_base", - "//third_party/googletest:gmock_main", +ace_unittest("ime_test") { + type = "basic/common" + sources = [ + "$ace_root/frameworks/core/common/ime/text_editing_value.cpp", + "$ace_root/frameworks/core/common/ime/text_input_action.cpp", + "$ace_root/frameworks/core/common/ime/text_input_configuration.cpp", + "$ace_root/frameworks/core/common/ime/text_input_connection.cpp", + "$ace_root/frameworks/core/common/ime/text_input_formatter.cpp", + "$ace_root/frameworks/core/common/ime/text_input_proxy.cpp", + "$ace_root/frameworks/core/common/ime/text_input_type.cpp", + "ime_test.cpp", ] external_deps = [ "ability_base:base" ] - part_name = ace_engine_part } From c32531417c960424a9c0c7dcbe7140c2dc5bcbc3 Mon Sep 17 00:00:00 2001 From: xuzhouy Date: Tue, 23 May 2023 08:35:40 +0000 Subject: [PATCH 31/99] modify measure_utils_test_ng code Signed-off-by: xuzhouy --- .../test/property/measure_utils/BUILD.gn | 90 -- .../measure_utils/measure_utils_test_ng.cpp | 960 +++++++++--------- 2 files changed, 498 insertions(+), 552 deletions(-) diff --git a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn index a412b46b0d9..5bd838bb369 100755 --- a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn +++ b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn @@ -18,101 +18,14 @@ ohos_unittest("measure_utils_test_ng") { 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", - "$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/color.cpp", - "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", - "$ace_root/frameworks/core/pipeline/base/constants.cpp", # components_ng - "$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/property/calc_length.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/syntax/for_each_node.cpp", - "$ace_root/frameworks/core/components_ng/syntax/lazy_for_each_node.cpp", # mock - "$ace_root/frameworks/base/test/mock/mock_mouse_style.cpp", - "$ace_root/frameworks/base/test/mock/mock_system_properties.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", - - #test main - "$ace_root/frameworks/base/geometry/animatable_dimension.cpp", - "$ace_root/frameworks/base/geometry/matrix4.cpp", - "$ace_root/frameworks/base/subwindow/subwindow_manager.cpp", - "$ace_root/frameworks/base/test/mock/mock_drag_window.cpp", - "$ace_root/frameworks/base/test/mock/mock_ressched_report.cpp", - "$ace_root/frameworks/base/utils/base_id.cpp", - "$ace_root/frameworks/core/animation/animator.cpp", - "$ace_root/frameworks/core/animation/anticipate_curve.cpp", - - #test object - "$ace_root/frameworks/core/animation/cubic_curve.cpp", - "$ace_root/frameworks/core/animation/curves.cpp", - "$ace_root/frameworks/core/animation/scheduler.cpp", - "$ace_root/frameworks/core/common/ace_engine.cpp", - "$ace_root/frameworks/core/common/clipboard/clipboard_proxy.cpp", - "$ace_root/frameworks/core/common/container.cpp", - "$ace_root/frameworks/core/common/container_scope.cpp", - "$ace_root/frameworks/core/common/test/mock/mock_ace_application_info.cpp", - "$ace_root/frameworks/core/common/watch_dog.cpp", - "$ace_root/frameworks/core/components/common/properties/border_image.cpp", - "$ace_root/frameworks/core/components/common/properties/decoration.cpp", - "$ace_root/frameworks/core/components/common/properties/shadow_config.cpp", - "$ace_root/frameworks/core/components/test/unittest/mock/subwindow_mock.cpp", - "$ace_root/frameworks/core/components_ng/animation/geometry_transition.cpp", - "$ace_root/frameworks/core/components_ng/base/view_abstract.cpp", - "$ace_root/frameworks/core/components_ng/event/click_event.cpp", - "$ace_root/frameworks/core/components_ng/gestures/recognizers/click_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/gestures/recognizers/long_press_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/gradient_property.cpp", - "$ace_root/frameworks/core/components_ng/render/render_context.cpp", - "$ace_root/frameworks/core/components_ng/render/render_property.cpp", - "$ace_root/frameworks/core/components_ng/test/event/mock/mock_drag_event.cpp", - "$ace_root/frameworks/core/components_ng/test/event/mock/mock_long_press_event.cpp", - "$ace_root/frameworks/core/components_ng/test/event/mock/mock_pan_event.cpp", - "$ace_root/frameworks/core/components_ng/test/event/mock/mock_scrollable_event.cpp", - "$ace_root/frameworks/core/components_ng/test/event/scrollable_event/mock_scrollable.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/base/mock_localization.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/manager/drag_drop/mock_drag_drop_manager.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/manager/drag_drop/mock_drag_drop_proxy.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/manager/select_overlay/mock_select_overlay_manager.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/manager/select_overlay/mock_select_overlay_proxy.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/render/mock_animation_utils.cpp", - "$ace_root/frameworks/core/components_ng/test/mock/render/mock_modifier_adapter.cpp", - "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", - "$ace_root/frameworks/core/event/back_end_event_manager.cpp", - "$ace_root/frameworks/core/image/image_source_info.cpp", "$ace_root/frameworks/core/pipeline_ng/test/mock/mock_pipeline_base.cpp", # self @@ -121,10 +34,7 @@ ohos_unittest("measure_utils_test_ng") { deps = [ "$ace_root/frameworks/base:ace_memory_monitor_ohos", - "$ace_root/frameworks/core/components_ng/pattern:ace_core_components_pattern_ng_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" ] diff --git a/frameworks/core/components_ng/test/property/measure_utils/measure_utils_test_ng.cpp b/frameworks/core/components_ng/test/property/measure_utils/measure_utils_test_ng.cpp index f93b464a7ab..02e7459e07e 100755 --- a/frameworks/core/components_ng/test/property/measure_utils/measure_utils_test_ng.cpp +++ b/frameworks/core/components_ng/test/property/measure_utils/measure_utils_test_ng.cpp @@ -36,834 +36,870 @@ using namespace testing; using namespace testing::ext; namespace OHOS::Ace::NG { +namespace { +constexpr float PERCENT_REFERENCE = 1.0; +constexpr float TEST_VALUE = 30.0; + +constexpr bool USING_MAX_SIZE_TRUE = true; +constexpr bool USING_MAX_SIZE_FALSE = false; + +const Dimension WIDTH {50.0, DimensionUnit::PX}; +const Dimension HEIGHT {100.0, DimensionUnit::PX}; +const Dimension CALC_TEST {10.0, DimensionUnit::CALC}; +const Dimension BORDER_WIDTH_PX {10.0, DimensionUnit::PX}; +const Dimension BORDER_WIDTH_VP {10.0, DimensionUnit::VP}; + +const CalcSize TEST_CALC_SIZE {NG::CalcLength(WIDTH), NG::CalcLength(HEIGHT)}; + +const CalcLength CALC_LENGTH_WIDTH_PX {20.0, DimensionUnit::PX}; +const CalcLength CALC_LENGTH_CALC {10.0, DimensionUnit::CALC}; +const CalcLength PADDING_LENGTH_PX {10.0, DimensionUnit::PX}; +const CalcLength PADDING_LENGTH_VP {10.0, DimensionUnit::VP}; + +const SizeF TEST_SIZE {50.0, 50.0}; +const SizeF TEST_MIN_SIZE {10.0, 10.0}; +const SizeF TEST_SELF_SIZE = {1.0, 1.0}; +SizeF TEST_MAX_SIZE {100.0, 100.0}; +SizeF ADD_SIZE = {10.0, 10.0}; +SizeF AXIS_SIZE = {20.0, 10.0}; +SizeF CHILDREN_SIZE = {10, 20}; + +const OffsetF TEST_OFFSET = {10.0, 20.0}; + +OptionalSizeF TEST_OPTIONAL_SIZE = {10.0, 10.0}; + +const PaddingPropertyF TEST_PROPERTY {10.0, 10.0, 10.0, 10.0}; +PaddingPropertyF PADDING_PROPERTY = {0, 0, 0, 0}; +PaddingPropertyF TEST_PADDING_PROPERTY = {0, 0, 0, 0}; + +const BorderWidthPropertyF BORDER_WIDTH_PROPERTY {10.0, 10.0, 10.0, 10.0}; + +const Axis AXIS_HORIZONTAL = Axis::HORIZONTAL; +const Axis AXIS_VERTICAL = Axis::VERTICAL; + +const MeasureType MEASURE_TYPE_MATCH_PARENT = MeasureType::MATCH_PARENT; +const MeasureType MEASURE_TYPE_MATCH_CONTENT = MeasureType::MATCH_CONTENT; +const MeasureType MEASURE_TYPE_CROSS_AXIS = MeasureType::MATCH_PARENT_CROSS_AXIS; +const MeasureType MEASURE_TYPE_MAIN_AXIS = MeasureType::MATCH_PARENT_MAIN_AXIS; +} class MeasureUtilsTestNg : public testing::Test { public: - static void SetUpTestCase() + static void SetUpTestSuite() { MockPipelineBase::SetUp(); } - - static void TearDownTestCase() + static void TeardownTestSuite() { MockPipelineBase::TearDown(); } }; /** - * @tc.name: MeasureUtilsTestNgTest001 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg001 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest001, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg001, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToSize and set input size.width_ is 50, size.height_ is 100. - * @tc.expected: step1. the return size is the same as input size. + * @tc.steps: step1. create scaleProperty. */ - Dimension width {50.0, DimensionUnit::PX}; - Dimension height {100.0, DimensionUnit::PX}; - CalcSize testCalcSize {NG::CalcLength(width), NG::CalcLength(height)}; - ScaleProperty scaleProperty; - SizeF testSize(2.0, 2.0); + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); - SizeF retSize = ConvertToSize(testCalcSize, std::move(scaleProperty), testSize); - EXPECT_EQ(retSize.width_, 50.0); - EXPECT_EQ(retSize.height_, 100.0); + /** + * @tc.steps: step2. call ConvertToSize and set input size is TEST_SIZE. + * @tc.expected: the return size is the same as TEST_SIZE. + */ + SizeF retSize = ConvertToSize(TEST_CALC_SIZE, std::move(scaleProperty), TEST_SIZE); + EXPECT_EQ(retSize.width_, WIDTH.value_); + EXPECT_EQ(retSize.height_, HEIGHT.value_); } /** - * @tc.name: MeasureUtilsTestNgTest002 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg002 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest002, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg002, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToOptionalSize and set input size.width_ is 30, size.height_ is 80. - * @tc.expected: step1. the return size is the same as input size. + * @tc.steps: step1. create scaleProperty. */ - Dimension width {30.0, DimensionUnit::PX}; - Dimension height {80.0, DimensionUnit::PX}; - CalcSize testCalcSize {NG::CalcLength(width), NG::CalcLength(height)}; - ScaleProperty scaleProperty; - SizeF testSize(1.0, 2.0); + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); - OptionalSizeF retSize = ConvertToOptionalSize(testCalcSize, std::move(scaleProperty), testSize); - EXPECT_EQ(retSize.width_, 30.0); - EXPECT_EQ(retSize.height_, 80.0); + /** + * @tc.steps: step2. call ConvertToOptionalSize and set input size is TEST_SIZE. + * @tc.expected: the return size is the same as TEST_SIZE. + */ + OptionalSizeF retSize = ConvertToOptionalSize(TEST_CALC_SIZE, std::move(scaleProperty), TEST_SIZE); + EXPECT_EQ(retSize.width_, WIDTH.value_); + EXPECT_EQ(retSize.height_, HEIGHT.value_); } /** - * @tc.name: MeasureUtilsTestNgTest003 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg003 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest003, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg003, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToPx and set input value is 20. - * @tc.expected: step1. the return size is the same as input value. + * @tc.steps: step1. create scaleProperty. */ - CalcLength width {20.0, DimensionUnit::PX}; - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); - std::optional retSize = ConvertToPx(width, std::move(scaleProperty), 1.0); - EXPECT_EQ(retSize, 20.0); /** - * @tc.steps: step2. call ConvertToPx and set input DimensionUnit is CALC. - * @tc.expected: step2. the return value is nullopt. + * @tc.steps: step2. call ConvertToPx and set input value is CALC_LENGTH_WIDTH. + * @tc.expected: the return size is the same as input value. */ - CalcLength calc {10.0, DimensionUnit::CALC}; + std::optional retSize = ConvertToPx(CALC_LENGTH_WIDTH_PX, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retSize, CALC_LENGTH_WIDTH_PX.dimension_.value_); - retSize = ConvertToPx(calc, std::move(scaleProperty), 1.0); + /** + * @tc.steps: step3. call ConvertToPx and set input value is CALC_LENGTH_CALC. + * @tc.expected: the return value is nullopt. + */ + retSize = ConvertToPx(CALC_LENGTH_CALC, std::move(scaleProperty), PERCENT_REFERENCE); EXPECT_EQ(retSize, std::nullopt); } /** - * @tc.name: MeasureUtilsTestNgTest004 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg004 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest004, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg004, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToPx and set input value is null. - * @tc.expected: step1. the return value is nullopt. + * @tc.steps: step1. create scaleProperty and testCalcSize. */ + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); std::optional testCalcSize; - ScaleProperty scaleProperty; - std::optional retSize = ConvertToPx(testCalcSize, std::move(scaleProperty), 1.0); - EXPECT_EQ(retSize, std::nullopt); /** - * @tc.steps: step2. call ConvertToPx and set input DimensionUnit is CALC. - * @tc.expected: step2. the return value is nullopt. + * @tc.steps: step2. call ConvertToPx and set input value is null. + * @tc.expected: the return value is nullopt. */ - Dimension calcWidth {30.0, DimensionUnit::CALC}; + std::optional retSize = ConvertToPx(testCalcSize, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retSize, std::nullopt); - retSize = ConvertToPx(CalcLength(calcWidth), std::move(scaleProperty), 1.0); + /** + * @tc.steps: step3. call ConvertToPx and set input value is CALC_LENGTH_CALC. + * @tc.expected: the return value is nullopt. + */ + testCalcSize = std::make_optional(CALC_TEST); + retSize = ConvertToPx(testCalcSize, std::move(scaleProperty), PERCENT_REFERENCE); EXPECT_EQ(retSize, std::nullopt); } /** - * @tc.name: MeasureUtilsTestNgTest005 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg005 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest005, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg005, TestSize.Level1) { /** - * @tc.steps: step1. call CheckNeedRender and set input is PROPERTY_UPDATE_NORMAL. - * @tc.expected: step1. the return value is false. + * @tc.steps: step1. create scaleProperty. */ - Dimension width {30.0, DimensionUnit::PX}; - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); - std::optional retSize = ConvertToPx(width, std::move(scaleProperty), 1.0); - EXPECT_EQ(retSize, 30.0); /** - * @tc.steps: step1. call CheckNeedRender and set input is PROPERTY_UPDATE_NORMAL. - * @tc.expected: step1. the return value is false. + * @tc.steps: step2. call ConvertToPx and set input value is WIDTH. + * @tc.expected: the return value is the same as WIDTH.value_. */ - Dimension calc {30.0, DimensionUnit::CALC}; + std::optional retSize = ConvertToPx(WIDTH, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retSize, WIDTH.value_); - retSize = ConvertToPx(calc, std::move(scaleProperty), 1.0); + /** + * @tc.steps: step3. call ConvertToPx and set input value is CALC_TEST. + * @tc.expected: the return value is nullopt. + */ + retSize = ConvertToPx(CALC_TEST, std::move(scaleProperty), PERCENT_REFERENCE); EXPECT_EQ(retSize, std::nullopt); } /** - * @tc.name: MeasureUtilsTestNgTest006 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg006 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest006, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg006, TestSize.Level1) { /** - * @tc.steps: step1. call CheckNeedRender and set input is PROPERTY_UPDATE_NORMAL. - * @tc.expected: step1. the return value is false. + * @tc.steps: step1. call ConstrainSize. + * @tc.expected: the return value is the same as TEST_SIZE. */ - SizeF testSize {50, 50}; - SizeF testMinSize {10, 10}; - SizeF testMaxSize {100, 100}; + SizeF retSize = ConstrainSize(TEST_SIZE, TEST_MIN_SIZE, TEST_MAX_SIZE); + EXPECT_EQ(retSize, TEST_SIZE); - SizeF retSize = ConstrainSize(testSize, testMinSize, testMaxSize); - EXPECT_EQ(retSize, testSize); /** - * @tc.steps: step1. call CheckNeedRender and set input is PROPERTY_UPDATE_NORMAL. - * @tc.expected: step1. the return value is false. + * @tc.steps: step2. call ConstrainSize and set TEST_MIN_SIZE.width_ is 0. + * @tc.expected: the return value is the same as TEST_SIZE. */ - testSize = {50, 50}; - testMinSize = {10, 10}; - testMaxSize = {0, 0}; + TEST_MAX_SIZE = {0, 0}; - retSize = ConstrainSize(testSize, testMinSize, testMaxSize); - EXPECT_EQ(retSize, testSize); + retSize = ConstrainSize(TEST_SIZE, TEST_MIN_SIZE, TEST_MAX_SIZE); + EXPECT_EQ(retSize, TEST_SIZE); } /** - * @tc.name: MeasureUtilsTestNgTest007 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg007 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest007, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg007, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToMarginPropertyF and set input margin is null. - * @tc.expected: step1. the return value is null. + * @tc.steps: step1. create scaleProperty and testPadding. */ - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); PaddingProperty testPadding; + + /** + * @tc.steps: step2. call ConvertToMarginPropertyF and set input margin is null. + */ std::unique_ptr testMarginProperty = nullptr; + PaddingPropertyF retProperty = + ConvertToMarginPropertyF(testMarginProperty, std::move(scaleProperty), PERCENT_REFERENCE); - PaddingPropertyF retProperty = ConvertToMarginPropertyF(testMarginProperty, std::move(scaleProperty), 1.0); /** - * @tc.steps: step2. call ConvertToMarginPropertyF and set input margin is not null. - * @tc.expected: step2. return expected value. + * @tc.steps: step3. set testMarginProperty is not null. */ - CalcLength left {10.0, DimensionUnit::PX}; - CalcLength right {10.0, DimensionUnit::PX}; - CalcLength top {10.0, DimensionUnit::PX}; - CalcLength bottom {10.0, DimensionUnit::PX}; - - testPadding.left = left; - testPadding.right = right; - testPadding.top = top; - testPadding.bottom = bottom; - PaddingPropertyF testProperty = {10.0, 10.0, 10.0, 10.0}; - + testPadding.left = PADDING_LENGTH_PX; + testPadding.right = PADDING_LENGTH_PX; + testPadding.top = PADDING_LENGTH_PX; + testPadding.bottom = PADDING_LENGTH_PX; testMarginProperty = std::make_unique(std::move(testPadding)); - retProperty = ConvertToMarginPropertyF(testMarginProperty, std::move(scaleProperty), 1.0); - EXPECT_EQ(retProperty, testProperty); + + /** + * @tc.steps: step4. call ConvertToMarginPropertyF. + * @tc.expected: the return value is the same as TEST_PROPERTY. + */ + retProperty = ConvertToMarginPropertyF(testMarginProperty, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retProperty, TEST_PROPERTY); } /** - * @tc.name: MeasureUtilsTestNgTest008 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg008 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest008, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg008, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToMarginPropertyF and set input margin is PaddingProperty. - * @tc.expected: step1. return expected value. + * @tc.steps: step1. create scaleProperty and testPadding. */ - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); PaddingProperty testPadding; - CalcLength left {20.0, DimensionUnit::PX}; - CalcLength right {20.0, DimensionUnit::PX}; - CalcLength top {20.0, DimensionUnit::PX}; - CalcLength bottom {20.0, DimensionUnit::PX}; - - testPadding.left = left; - testPadding.right = right; - testPadding.top = top; - testPadding.bottom = bottom; - PaddingPropertyF testProperty = {20.0, 20.0, 20.0, 20.0}; + /** + * @tc.steps: step2. set testMarginProperty is not null. + */ + testPadding.left = PADDING_LENGTH_PX; + testPadding.right = PADDING_LENGTH_PX; + testPadding.top = PADDING_LENGTH_PX; + testPadding.bottom = PADDING_LENGTH_PX; MarginProperty testMarginProperty = testPadding; - PaddingPropertyF retProperty = ConvertToMarginPropertyF(testMarginProperty, std::move(scaleProperty), 1.0); - EXPECT_EQ(retProperty, testProperty); + + /** + * @tc.steps: step3. call ConvertToMarginPropertyF and set input margin is PaddingProperty. + * @tc.expected: the return value is the same as TEST_PROPERTY. + */ + PaddingPropertyF retProperty = + ConvertToMarginPropertyF(testMarginProperty, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retProperty, TEST_PROPERTY); } /** - * @tc.name: MeasureUtilsTestNgTest009 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg009 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest009, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg009, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToBorderWidthPropertyF and set input borderWidth is null. - * @tc.expected: step1. the return value is null. + * @tc.steps: step1. create scaleProperty and testPadding. */ - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); PaddingProperty testPadding; - std::unique_ptr testBorderWidthProperty = nullptr; - BorderWidthPropertyF retProperty = - ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), 1.0); /** - * @tc.steps: step2. call ConvertToMarginPropertyF and set input borderWidth is not null. - * @tc.expected: step2. return expected value. + * @tc.steps: step2. call ConvertToBorderWidthPropertyF and set input borderWidth is null. + */ + std::unique_ptr testBorderWidthProperty = nullptr; + BorderWidthPropertyF retProperty = + ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), PERCENT_REFERENCE); + + /** + * @tc.steps: step3. set testBorderWidthProperty is not null. */ BorderWidthPropertyT testPropertyT; - Dimension left {10.0, DimensionUnit::PX}; - Dimension right {10.0, DimensionUnit::PX}; - Dimension top {10.0, DimensionUnit::PX}; - Dimension bottom {10.0, DimensionUnit::PX}; - testPropertyT.leftDimen = left; - testPropertyT.rightDimen = right; - testPropertyT.topDimen = top; - testPropertyT.bottomDimen = bottom; - BorderWidthPropertyF testProperty = {10.0, 10.0, 10.0, 10.0}; + testPropertyT.leftDimen = BORDER_WIDTH_PX; + testPropertyT.rightDimen = BORDER_WIDTH_PX; + testPropertyT.topDimen = BORDER_WIDTH_PX; + testPropertyT.bottomDimen = BORDER_WIDTH_PX; testBorderWidthProperty = std::make_unique(std::move(testPropertyT)); - retProperty = ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), 1.0); - EXPECT_EQ(retProperty, testProperty); + + /** + * @tc.steps: step4. call ConvertToMarginPropertyF. + * @tc.expected: the return value is the same as BORDER_WIDTH_PROPERTY. + */ + retProperty = + ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retProperty, BORDER_WIDTH_PROPERTY); } /** - * @tc.name: MeasureUtilsTestNgTest010 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg010 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest010, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg010, TestSize.Level1) { /** - * @tc.steps: step1. call ConvertToBorderWidthPropertyF and set borderWidth Dimension is null. - * @tc.expected: step1. the return value is std::nullopt. + * @tc.steps: step1. create scaleProperty and testPadding. */ - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); PaddingProperty testPadding; + + /** + * @tc.steps: step2. call ConvertToBorderWidthPropertyF and set borderWidth Dimension is null. + * @tc.expected: the return value is std::nullopt. + */ BorderWidthPropertyT testPropertyT; std::unique_ptr testBorderWidthProperty = std::make_unique(std::move(testPropertyT)); BorderWidthPropertyF retProperty = - ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), 1.0); + ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), PERCENT_REFERENCE); EXPECT_EQ(retProperty.leftDimen, std::nullopt); - /** - * @tc.steps: step1. call ConvertToBorderWidthPropertyF and set borderWidth DimensionUnit is VP. - * @tc.expected: step1. the return value is std::nullopt. - */ - Dimension left {10.0, DimensionUnit::VP}; - Dimension right {10.0, DimensionUnit::VP}; - Dimension top {10.0, DimensionUnit::VP}; - Dimension bottom {10.0, DimensionUnit::VP}; - testPropertyT.leftDimen = left; - testPropertyT.rightDimen = right; - testPropertyT.topDimen = top; - testPropertyT.bottomDimen = bottom; + /** + * @tc.steps: step3. set testPropertyT DimensionUnit is VP. + */ + testPropertyT.leftDimen = BORDER_WIDTH_VP; + testPropertyT.rightDimen = BORDER_WIDTH_VP; + testPropertyT.topDimen = BORDER_WIDTH_VP; + testPropertyT.bottomDimen = BORDER_WIDTH_VP; testBorderWidthProperty = std::make_unique(std::move(testPropertyT)); - retProperty = ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), 1.0); + + /** + * @tc.steps: step4. call ConvertToBorderWidthPropertyF. + * @tc.expected: the return value is the same as BORDER_WIDTH_PROPERTY. + */ + retProperty = + ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), PERCENT_REFERENCE); + EXPECT_EQ(retProperty, BORDER_WIDTH_PROPERTY); + + /** + * @tc.steps: step5. set testPropertyT.leftDimen is CALC_TEST and call ConvertToBorderWidthPropertyF. + * @tc.expected: retProperty.leftDimen is std::nullopt. + */ + testPropertyT.leftDimen = CALC_TEST; + testBorderWidthProperty = std::make_unique(std::move(testPropertyT)); + retProperty = + ConvertToBorderWidthPropertyF(testBorderWidthProperty, std::move(scaleProperty), PERCENT_REFERENCE); EXPECT_EQ(retProperty.leftDimen, std::nullopt); } /** - * @tc.name: MeasureUtilsTestNgTest011 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg011 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest011, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg011, TestSize.Level1) { /** - * @tc.steps: step1. call UpdatePaddingPropertyF and set input Padding is null. - * @tc.expected: step1. testPaddingPropertyF is not update. + * @tc.steps: step1. create scaleProperty and testPadding. */ - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); PaddingProperty testPadding; - SizeF testSelfSize = {1.0, 1.0}; - PaddingPropertyF testPaddingPropertyF = {0, 0, 0, 0}; - PaddingPropertyF testProperty = {0, 0, 0, 0}; - UpdatePaddingPropertyF(testPadding, std::move(scaleProperty), testSelfSize, testPaddingPropertyF); - EXPECT_EQ(testPaddingPropertyF, testProperty); + /** + * @tc.steps: step2. call UpdatePaddingPropertyF and set input Padding is null. + * @tc.expected: testPaddingPropertyF is not update. + */ + UpdatePaddingPropertyF(testPadding, std::move(scaleProperty), TEST_SELF_SIZE, PADDING_PROPERTY); + EXPECT_EQ(PADDING_PROPERTY, TEST_PADDING_PROPERTY); + + /** + * @tc.steps: step3. set testPadding.left is PADDING_LENGTH_PX. + */ + testPadding.left = PADDING_LENGTH_PX; + testPadding.right = PADDING_LENGTH_PX; + testPadding.top = PADDING_LENGTH_PX; + testPadding.bottom = PADDING_LENGTH_PX; + TEST_PADDING_PROPERTY = {10.0, 10.0, 10.0, 10.0}; + /** * @tc.steps: step2. call UpdatePaddingPropertyF and set input Padding is not null. * @tc.expected: step2. testPaddingPropertyF is update and it value is the same as testPadding. */ - CalcLength left {30.0, DimensionUnit::PX}; - CalcLength right {30.0, DimensionUnit::PX}; - CalcLength top {30.0, DimensionUnit::PX}; - CalcLength bottom {30.0, DimensionUnit::PX}; - - testPadding.left = left; - testPadding.right = right; - testPadding.top = top; - testPadding.bottom = bottom; - testProperty = {30.0, 30.0, 30.0, 30.0}; - - UpdatePaddingPropertyF(testPadding, std::move(scaleProperty), testSelfSize, testPaddingPropertyF); - EXPECT_EQ(testPaddingPropertyF, testProperty); + UpdatePaddingPropertyF(testPadding, std::move(scaleProperty), TEST_SELF_SIZE, PADDING_PROPERTY); + EXPECT_EQ(PADDING_PROPERTY, TEST_PADDING_PROPERTY); } /** - * @tc.name: MeasureUtilsTestNgTest012 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg012 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest012, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg012, TestSize.Level1) { /** - * @tc.steps: step1. call UpdatePaddingPropertyF and set input Padding DimensionUnit is VP. - * @tc.expected: step1. testPaddingPropertyF is not update. + * @tc.steps: step1. create scaleProperty and testPadding. */ - ScaleProperty scaleProperty; + ScaleProperty scaleProperty = ScaleProperty::CreateScaleProperty(); PaddingProperty testPadding; - SizeF testSelfSize = {1.0, 1.0}; - PaddingPropertyF testPaddingPropertyF = {0, 0, 0, 0}; - PaddingPropertyF testProperty = {0, 0, 0, 0}; + PADDING_PROPERTY = {0, 0, 0, 0}; + TEST_PADDING_PROPERTY = {10.0, 10.0, 10.0, 10.0}; - CalcLength left {30.0, DimensionUnit::VP}; - CalcLength right {30.0, DimensionUnit::VP}; - CalcLength top {30.0, DimensionUnit::VP}; - CalcLength bottom {30.0, DimensionUnit::VP}; + /** + * @tc.steps: step2. set testPadding.left is PADDING_LENGTH_VP. + */ + testPadding.left = PADDING_LENGTH_VP; + testPadding.right = PADDING_LENGTH_VP; + testPadding.top = PADDING_LENGTH_VP; + testPadding.bottom = PADDING_LENGTH_VP; - testPadding.left = left; - testPadding.right = right; - testPadding.top = top; - testPadding.bottom = bottom; - - UpdatePaddingPropertyF(testPadding, std::move(scaleProperty), testSelfSize, testPaddingPropertyF); - EXPECT_EQ(testPaddingPropertyF, testProperty); + /** + * @tc.steps: step3. call UpdatePaddingPropertyF and set input Padding DimensionUnit is VP. + * @tc.expected: testPaddingPropertyF is not update. + */ + UpdatePaddingPropertyF(testPadding, std::move(scaleProperty), TEST_SELF_SIZE, PADDING_PROPERTY); + EXPECT_EQ(PADDING_PROPERTY, TEST_PADDING_PROPERTY); } /** - * @tc.name: MeasureUtilsTestNgTest013 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg013 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest013, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg013, TestSize.Level1) { /** * @tc.steps: step1. call AddPaddingToSize and set input Padding is zero. - * @tc.expected: step1. the testSize is not changed. + * @tc.expected: the testSize is not changed. */ - PaddingPropertyF testPaddingPropertyF = {0, 0, 0, 0}; - SizeF testSize = {10.0, 10.0}; + PADDING_PROPERTY = {0, 0, 0, 0}; - AddPaddingToSize(testPaddingPropertyF, testSize); - EXPECT_EQ(testSize.width_, 10.0); - EXPECT_EQ(testSize.height_, 10.0); + AddPaddingToSize(PADDING_PROPERTY, ADD_SIZE); + EXPECT_EQ(ADD_SIZE.width_, 10.0); + EXPECT_EQ(ADD_SIZE.height_, 10.0); /** * @tc.steps: step2. call AddPaddingToSize and set input Padding is not zero. - * @tc.expected: step2. the testSize is changed into expected values. + * @tc.expected: the testSize is changed into expected values. */ - testPaddingPropertyF = {10.0, 20.0, 30.0, 40.0}; + PADDING_PROPERTY = {10.0, 20.0, 30.0, 40.0}; - AddPaddingToSize(testPaddingPropertyF, testSize); - EXPECT_EQ(testSize.width_, 40.0); - EXPECT_EQ(testSize.height_, 80.0); + AddPaddingToSize(PADDING_PROPERTY, ADD_SIZE); + EXPECT_EQ(ADD_SIZE.width_, 40.0); + EXPECT_EQ(ADD_SIZE.height_, 80.0); } /** - * @tc.name: MeasureUtilsTestNgTest014 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg014 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest014, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg014, TestSize.Level1) { /** * @tc.steps: step1. call MinusPaddingToSize and set input Padding is zero. - * @tc.expected: step1. the testSize is not changed. + * @tc.expected: the testSize is not changed. */ - PaddingPropertyF testPaddingPropertyF = {0, 0, 0, 0}; - SizeF testSize = {100.0, 100.0}; + PADDING_PROPERTY = {0, 0, 0, 0}; + ADD_SIZE = {100.0, 100.0}; - MinusPaddingToSize(testPaddingPropertyF, testSize); - EXPECT_EQ(testSize.width_, 100.0); - EXPECT_EQ(testSize.height_, 100.0); + MinusPaddingToSize(PADDING_PROPERTY, ADD_SIZE); + EXPECT_EQ(ADD_SIZE.width_, 100.0); + EXPECT_EQ(ADD_SIZE.height_, 100.0); /** * @tc.steps: step2. call MinusPaddingToSize and set input Padding is not zero. - * @tc.expected: step2. the testSize is changed into expected values. + * @tc.expected: the testSize is changed into expected values. */ - testPaddingPropertyF = {10.0, 20.0, 30.0, 40.0}; + PADDING_PROPERTY = {10.0, 20.0, 30.0, 40.0}; - MinusPaddingToSize(testPaddingPropertyF, testSize); - EXPECT_EQ(testSize.width_, 70.0); - EXPECT_EQ(testSize.height_, 30.0); + MinusPaddingToSize(PADDING_PROPERTY, ADD_SIZE); + EXPECT_EQ(ADD_SIZE.width_, 70.0); + EXPECT_EQ(ADD_SIZE.height_, 30.0); } /** - * @tc.name: MeasureUtilsTestNgTest015 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg015 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest015, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg015, TestSize.Level1) { /** * @tc.steps: step1. call AddPaddingToSize and set input Padding is zero. - * @tc.expected: step1. the testOptionalSize is not changed. + * @tc.expected: the testOptionalSize is not changed. */ - PaddingPropertyF testPaddingPropertyF = {0, 0, 0, 0}; - OptionalSizeF testOptionalSize = {10.0, 10.0}; + PADDING_PROPERTY = {0, 0, 0, 0}; - AddPaddingToSize(testPaddingPropertyF, testOptionalSize); - EXPECT_EQ(testOptionalSize.width_, 10.0); - EXPECT_EQ(testOptionalSize.height_, 10.0); + AddPaddingToSize(PADDING_PROPERTY, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 10.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 10.0); /** * @tc.steps: step2. call AddPaddingToSize and set input Padding is not zero. - * @tc.expected: step2. the testOptionalSize is changed into expected values. + * @tc.expected: the testOptionalSize is changed into expected values. */ - testPaddingPropertyF = {40.0, 30.0, 20.0, 10.0}; + PADDING_PROPERTY = {40.0, 30.0, 20.0, 10.0}; - AddPaddingToSize(testPaddingPropertyF, testOptionalSize); - EXPECT_EQ(testOptionalSize.width_, 80.0); - EXPECT_EQ(testOptionalSize.height_, 40.0); + AddPaddingToSize(PADDING_PROPERTY, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 80.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 40.0); } /** - * @tc.name: MeasureUtilsTestNgTest016 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg016 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest016, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg016, TestSize.Level1) { /** * @tc.steps: step1. call MinusPaddingToSize and set input Padding is zero. - * @tc.expected: step1. the testOptionalSize is not changed. + * @tc.expected: the testOptionalSize is not changed. */ - PaddingPropertyF testPaddingPropertyF = {0, 0, 0, 0}; - OptionalSizeF testOptionalSize = {100.0, 100.0}; + PADDING_PROPERTY = {0, 0, 0, 0}; + TEST_OPTIONAL_SIZE = {100.0, 100.0}; - MinusPaddingToSize(testPaddingPropertyF, testOptionalSize); - EXPECT_EQ(testOptionalSize.width_, 100.0); - EXPECT_EQ(testOptionalSize.height_, 100.0); + MinusPaddingToSize(PADDING_PROPERTY, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 100.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 100.0); /** * @tc.steps: step2. call MinusPaddingToSize and set input Padding is not zero. - * @tc.expected: step2. the testOptionalSize is changed into expected values. + * @tc.expected: the testOptionalSize is changed into expected values. */ - testPaddingPropertyF = {40.0, 30.0, 20.0, 10.0}; + PADDING_PROPERTY = {40.0, 30.0, 20.0, 10.0}; - MinusPaddingToSize(testPaddingPropertyF, testOptionalSize); - EXPECT_EQ(testOptionalSize.width_, 30.0); - EXPECT_EQ(testOptionalSize.height_, 70.0); + MinusPaddingToSize(PADDING_PROPERTY, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 30.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 70.0); } /** - * @tc.name: MeasureUtilsTestNgTest017 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg017 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest017, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg017, TestSize.Level1) { /** * @tc.steps: step1. call GetMainAxisOffset and set input Axis is HORIZONTAL. - * @tc.expected: step1. return Offset.X. + * @tc.expected: the return value is equal to TEST_OFFSET.x_. */ - OffsetF testOffset = {10.0, 20.0}; - Axis testAxis = Axis::HORIZONTAL; + float retMainOffset = GetMainAxisOffset(TEST_OFFSET, AXIS_HORIZONTAL); + EXPECT_EQ(retMainOffset, TEST_OFFSET.x_); - float retMainOffset = GetMainAxisOffset(testOffset, testAxis); - EXPECT_EQ(retMainOffset, 10.0); /** * @tc.steps: step2. call GetMainAxisOffset and set input Axis is HORIZONTAL. - * @tc.expected: step2. return Offset.Y. + * @tc.expected: the return value is equal to TEST_OFFSET.y_. */ - testAxis = Axis::VERTICAL; - - retMainOffset = GetMainAxisOffset(testOffset, testAxis); - EXPECT_EQ(retMainOffset, 20.0); + retMainOffset = GetMainAxisOffset(TEST_OFFSET, AXIS_VERTICAL); + EXPECT_EQ(retMainOffset, TEST_OFFSET.y_); } /** - * @tc.name: MeasureUtilsTestNgTest018 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg018 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest018, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg018, TestSize.Level1) { /** - * @tc.steps: step1. call GetMainAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. return size.Width. + * @tc.steps: step1. call GetMainAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: the return value is equal to AXIS_SIZE.Width. */ - SizeF testSize = {20.0, 10.0}; - Axis testAxis = Axis::HORIZONTAL; + float retMainSize = GetMainAxisSize(AXIS_SIZE, AXIS_HORIZONTAL); + EXPECT_EQ(retMainSize, AXIS_SIZE.width_); - float retMainSize = GetMainAxisSize(testSize, testAxis); - EXPECT_EQ(retMainSize, 20.0); /** - * @tc.steps: step2. call GetMainAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. return size.Height. + * @tc.steps: step2. call GetMainAxisSize and set input Axis is AXIS_VERTICAL. + * @tc.expected: the return value is equal to AXIS_SIZE.Height. */ - testAxis = Axis::VERTICAL; - - retMainSize = GetMainAxisSize(testSize, testAxis); - EXPECT_EQ(retMainSize, 10.0); + retMainSize = GetMainAxisSize(AXIS_SIZE, AXIS_VERTICAL); + EXPECT_EQ(retMainSize, AXIS_SIZE.height_); } /** - * @tc.name: MeasureUtilsTestNgTest019 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg019 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest019, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg019, TestSize.Level1) { /** - * @tc.steps: step1. call GetCrossAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. return size.Height. + * @tc.steps: step1. call GetCrossAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: the return value is equal to AXIS_SIZE.Height. */ - SizeF testSize = {10.0, 20.0}; - Axis testAxis = Axis::HORIZONTAL; + float retCrossSize = GetCrossAxisSize(AXIS_SIZE, AXIS_HORIZONTAL); + EXPECT_EQ(retCrossSize, AXIS_SIZE.height_); - float retCrossSize = GetCrossAxisSize(testSize, testAxis); - EXPECT_EQ(retCrossSize, 20.0); /** - * @tc.steps: step2. call GetCrossAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. return size.Width. + * @tc.steps: step2. call GetCrossAxisSize and set input Axis is AXIS_VERTICAL. + * @tc.expected: the return value is equal to AXIS_SIZE.Width. */ - testAxis = Axis::VERTICAL; - - retCrossSize = GetCrossAxisSize(testSize, testAxis); - EXPECT_EQ(retCrossSize, 10.0); + retCrossSize = GetCrossAxisSize(AXIS_SIZE, AXIS_VERTICAL); + EXPECT_EQ(retCrossSize, AXIS_SIZE.width_); } /** - * @tc.name: MeasureUtilsTestNgTest020 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg020 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest020, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg020, TestSize.Level1) { /** - * @tc.steps: step1. call SetCrossAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. testSize.height is set to the testValue. + * @tc.steps: step1. call SetCrossAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: AXIS_SIZE.height_ is set to the TEST_VALUE. */ - SizeF testSize = {10.0, 20.0}; - Axis testAxis = Axis::HORIZONTAL; - float testValue = 30.0; + SetCrossAxisSize(TEST_VALUE, AXIS_HORIZONTAL, AXIS_SIZE); + EXPECT_EQ(AXIS_SIZE.height_, TEST_VALUE); + + /** + * @tc.steps: step2. call SetCrossAxisSize and set input Axis is AXIS_VERTICAL. + * @tc.expected: AXIS_SIZE.width_ is set to the TEST_VALUE. + */ + AXIS_SIZE = {10.0, 20.0}; + + SetCrossAxisSize(TEST_VALUE, AXIS_VERTICAL, AXIS_SIZE); + EXPECT_EQ(AXIS_SIZE.width_, TEST_VALUE); +} + +/** + * @tc.name: MeasureUtilsTestNg021 + * @tc.desc: Test cast to MeasureUtilsTestNg. + * @tc.type: FUNC + */ +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg021, TestSize.Level1) +{ + /** + * @tc.steps: step1. call SetCrossAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: TEST_OPTIONAL_SIZE.width_ is set to the TEST_VALUE. + */ + TEST_OPTIONAL_SIZE = {10.0, 20.0}; + + SetMainAxisSize(TEST_VALUE, AXIS_HORIZONTAL, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 20.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 30.0); - SetCrossAxisSize(testValue, testAxis, testSize); - EXPECT_EQ(testSize.height_, 30.0); - EXPECT_EQ(testSize.width_, 10.0); /** * @tc.steps: step2. call SetCrossAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. testSize.width is set to the testValue. + * @tc.expected: TEST_OPTIONAL_SIZE.height_ is set to the TEST_VALUE. */ - testSize = {10.0, 20.0}; - testAxis = Axis::VERTICAL; + TEST_OPTIONAL_SIZE = {10.0, 20.0}; - SetCrossAxisSize(testValue, testAxis, testSize); - EXPECT_EQ(testSize.height_, 20.0); - EXPECT_EQ(testSize.width_, 30.0); + SetMainAxisSize(TEST_VALUE, AXIS_VERTICAL, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 30.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 10.0); } /** - * @tc.name: MeasureUtilsTestNgTest021 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg022 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest021, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg022, TestSize.Level1) { /** - * @tc.steps: step1. call SetCrossAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. testOptionalSize.width is set to the testValue. + * @tc.steps: step1. call GetMainAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: the return value is equal to TEST_OPTIONAL_SIZE.width_. */ - OptionalSizeF testOptionalSize = {10.0, 20.0}; - Axis testAxis = Axis::HORIZONTAL; - float testValue = 30.0; + TEST_OPTIONAL_SIZE = {10.0, 20.0}; + + std::optional retMainSize = GetMainAxisSize(TEST_OPTIONAL_SIZE, AXIS_HORIZONTAL); + EXPECT_EQ(retMainSize, TEST_OPTIONAL_SIZE.width_); - SetMainAxisSize(testValue, testAxis, testOptionalSize); - EXPECT_EQ(testOptionalSize.height_, 20.0); - EXPECT_EQ(testOptionalSize.width_, 30.0); /** - * @tc.steps: step2. call SetCrossAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. testOptionalSize.height is set to the testValue. + * @tc.steps: step2. call GetMainAxisSize and set input Axis is AXIS_VERTICAL. + * @tc.expected: the return value is equal to TEST_OPTIONAL_SIZE.height_. */ - testOptionalSize = {10.0, 20.0}; - testAxis = Axis::VERTICAL; - - SetMainAxisSize(testValue, testAxis, testOptionalSize); - EXPECT_EQ(testOptionalSize.height_, 30.0); - EXPECT_EQ(testOptionalSize.width_, 10.0); + retMainSize = GetMainAxisSize(TEST_OPTIONAL_SIZE, AXIS_VERTICAL); + EXPECT_EQ(retMainSize, TEST_OPTIONAL_SIZE.height_); } /** - * @tc.name: MeasureUtilsTestNgTest022 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg023 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest022, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg023, TestSize.Level1) { /** - * @tc.steps: step1. call GetMainAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. return testOptionalSize.Width. + * @tc.steps: step1. call GetCrossAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: the return value is equal to TEST_OPTIONAL_SIZE.height_. */ - OptionalSizeF testOptionalSize = {20.0, 10.0}; - Axis testAxis = Axis::HORIZONTAL; + std::optional retCrossSize = GetCrossAxisSize(TEST_OPTIONAL_SIZE, AXIS_HORIZONTAL); + EXPECT_EQ(retCrossSize, TEST_OPTIONAL_SIZE.height_); - std::optional retMainSize = GetMainAxisSize(testOptionalSize, testAxis); - EXPECT_EQ(retMainSize, 20.0); /** - * @tc.steps: step2. call GetMainAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. return testOptionalSize.Height. + * @tc.steps: step2. call GetCrossAxisSize and set input Axis is AXIS_VERTICAL. + * @tc.expected: the return value is equal to TEST_OPTIONAL_SIZE.width_. */ - testAxis = Axis::VERTICAL; - - retMainSize = GetMainAxisSize(testOptionalSize, testAxis); - EXPECT_EQ(retMainSize, 10.0); + retCrossSize = GetCrossAxisSize(TEST_OPTIONAL_SIZE, AXIS_VERTICAL); + EXPECT_EQ(retCrossSize, TEST_OPTIONAL_SIZE.width_); } /** - * @tc.name: MeasureUtilsTestNgTest023 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg024 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest023, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg024, TestSize.Level1) { /** - * @tc.steps: step1. call GetCrossAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. return testOptionalSize.Height. + * @tc.steps: step1. call SetCrossAxisSize and set input Axis is AXIS_HORIZONTAL. + * @tc.expected: TEST_OPTIONAL_SIZE.height_ is set to the TEST_VALUE. */ - OptionalSizeF testOptionalSize = {10.0, 20.0}; - Axis testAxis = Axis::HORIZONTAL; + SetCrossAxisSize(TEST_VALUE, AXIS_HORIZONTAL, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 30.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 10.0); - std::optional retCrossSize = GetCrossAxisSize(testOptionalSize, testAxis); - EXPECT_EQ(retCrossSize, 20.0); /** - * @tc.steps: step2. call GetCrossAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. return testOptionalSize.Height. + * @tc.steps: step2. call SetCrossAxisSize and set input Axis is AXIS_VERTICAL. + * @tc.expected: TEST_OPTIONAL_SIZE.width_ is set to the TEST_VALUE. */ - testAxis = Axis::VERTICAL; + TEST_OPTIONAL_SIZE = {10.0, 20.0}; - retCrossSize = GetCrossAxisSize(testOptionalSize, testAxis); - EXPECT_EQ(retCrossSize, 10.0); + SetCrossAxisSize(TEST_VALUE, AXIS_VERTICAL, TEST_OPTIONAL_SIZE); + EXPECT_EQ(TEST_OPTIONAL_SIZE.height_, 20.0); + EXPECT_EQ(TEST_OPTIONAL_SIZE.width_, 30.0); } /** - * @tc.name: MeasureUtilsTestNgTest024 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg025 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest024, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg025, TestSize.Level1) { /** - * @tc.steps: step1. call SetCrossAxisSize and set input Axis is HORIZONTAL. - * @tc.expected: step1. testSize.height is set to the testValue. - */ - OptionalSizeF testOptionalSize = {10.0, 20.0}; - Axis testAxis = Axis::HORIZONTAL; - float testValue = 30.0; - - SetCrossAxisSize(testValue, testAxis, testOptionalSize); - EXPECT_EQ(testOptionalSize.height_, 30.0); - EXPECT_EQ(testOptionalSize.width_, 10.0); - /** - * @tc.steps: step2. call SetCrossAxisSize and set input Axis is VERTICAL. - * @tc.expected: step2. testSize.width is set to the testValue. - */ - testOptionalSize = {10.0, 20.0}; - testAxis = Axis::VERTICAL; - - SetCrossAxisSize(testValue, testAxis, testOptionalSize); - EXPECT_EQ(testOptionalSize.height_, 20.0); - EXPECT_EQ(testOptionalSize.width_, 30.0); -} - -/** - * @tc.name: MeasureUtilsTestNgTest025 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. - * @tc.type: FUNC - */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest025, TestSize.Level1) -{ - /** - * @tc.steps: step1. call CreateIdealSize and set input usingMaxSize is true. - * @tc.expected: step1. the return retIdealSize is the same as layoutConstraint.maxSize. + * @tc.steps: step1. call CreateIdealSize and set input usingMaxSize is USING_MAX_SIZE_TRUE. + * @tc.expected: the return retIdealSize is the same as layoutConstraint.maxSize. */ LayoutConstraintF layoutConstraint; - Axis testAxis = Axis::HORIZONTAL; - MeasureType testMeasureType = MeasureType::MATCH_PARENT; - bool usingMaxSize = true; - SizeF retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType, usingMaxSize); + SizeF retIdealSize = + CreateIdealSize(layoutConstraint, AXIS_HORIZONTAL, MEASURE_TYPE_MATCH_PARENT, USING_MAX_SIZE_TRUE); EXPECT_EQ(retIdealSize, layoutConstraint.maxSize); + /** - * @tc.steps: step2. call CreateIdealSize and set input usingMaxSize is false. - * @tc.expected: step2. the return retIdealSize.width_ and retIdealSize.height_ is not equal 0. + * @tc.steps: step2. call CreateIdealSize and set input usingMaxSize is USING_MAX_SIZE_FALSE. + * @tc.expected: the return retIdealSize.width_ and retIdealSize.height_ is not equal 0. */ - usingMaxSize = false; - retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType, usingMaxSize); + retIdealSize = + CreateIdealSize(layoutConstraint, AXIS_VERTICAL, MEASURE_TYPE_MATCH_PARENT, USING_MAX_SIZE_FALSE); EXPECT_NE(retIdealSize.width_, 0); EXPECT_NE(retIdealSize.height_, 0); } /** - * @tc.name: MeasureUtilsTestNgTest026 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg026 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest026, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg026, TestSize.Level1) { /** - * @tc.steps: step1. call CreateIdealSize and set layoutConstraint.maxSize.height_ is 100. - * @tc.expected: step1. the return retIdealSize.height_ is the same as layoutConstraint.maxSize.height_. + * @tc.steps: step1. create layoutConstraint. */ LayoutConstraintF layoutConstraint; - Axis testAxis = Axis::HORIZONTAL; - MeasureType testMeasureType = MeasureType::MATCH_PARENT_CROSS_AXIS; + /** + * @tc.steps: step1. call CreateIdealSize and set layoutConstraint.maxSize.height_ is 100. + * @tc.expected: the return retIdealSize.height_ is the same as layoutConstraint.maxSize.height_. + */ layoutConstraint.maxSize = {100.0, 100.0}; - OptionalSizeF retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType); + OptionalSizeF retIdealSize = CreateIdealSize(layoutConstraint, AXIS_HORIZONTAL, MEASURE_TYPE_CROSS_AXIS); EXPECT_EQ(retIdealSize.height_, layoutConstraint.maxSize.height_); /** - * @tc.steps: step1. call CreateIdealSize and set layoutConstraint.parentIdealSize.height_ is 20. - * @tc.expected: step1. the return retIdealSize.height_ is the same as layoutConstraint.parentIdealSize.height_. + * @tc.steps: step2. call CreateIdealSize and set layoutConstraint.parentIdealSize.height_ is 20. + * @tc.expected: the return retIdealSize.height_ is the same as layoutConstraint.parentIdealSize.height_. */ layoutConstraint.parentIdealSize = {10.0, 20.0}; - retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType); - EXPECT_EQ(retIdealSize.height_, 20.0); + retIdealSize = CreateIdealSize(layoutConstraint, AXIS_HORIZONTAL, MEASURE_TYPE_CROSS_AXIS); + EXPECT_EQ(retIdealSize.height_, layoutConstraint.parentIdealSize.height_); } /** - * @tc.name: MeasureUtilsTestNgTest027 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg027 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest027, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg027, TestSize.Level1) { /** - * @tc.steps: step1. call CreateIdealSize and set layoutConstraint.maxSize.width_ is 100. - * @tc.expected: step1. the return retIdealSize.height_ is the same as layoutConstraint.maxSize.width_. + * @tc.steps: step1. create layoutConstraint. */ LayoutConstraintF layoutConstraint; - Axis testAxis = Axis::HORIZONTAL; - MeasureType testMeasureType = MeasureType::MATCH_PARENT_MAIN_AXIS; - layoutConstraint.maxSize = {100.0, 100.0}; - OptionalSizeF retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType); - EXPECT_EQ(retIdealSize.width_, 100.0); /** - * @tc.steps: step1. call CreateIdealSize and set layoutConstraint.parentIdealSize.width_ is 20. - * @tc.expected: step1. the return retIdealSize.height_ is the same as layoutConstraint.parentIdealSize.width_. + * @tc.steps: step2. call CreateIdealSize and set layoutConstraint.maxSize.width_ is 100. + * @tc.expected: the return retIdealSize.height_ is the same as layoutConstraint.maxSize.width_. + */ + layoutConstraint.maxSize = {100.0, 100.0}; + OptionalSizeF retIdealSize = CreateIdealSize(layoutConstraint, AXIS_HORIZONTAL, MEASURE_TYPE_MAIN_AXIS); + EXPECT_EQ(retIdealSize.width_, layoutConstraint.maxSize.width_); + + /** + * @tc.steps: step3. call CreateIdealSize and set layoutConstraint.parentIdealSize.width_ is 20. + * @tc.expected: the return retIdealSize.height_ is the same as layoutConstraint.parentIdealSize.width_. */ layoutConstraint.parentIdealSize = {20.0, 10.0}; - retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType); - EXPECT_EQ(retIdealSize.width_, 20.0); + retIdealSize = CreateIdealSize(layoutConstraint, AXIS_HORIZONTAL, MEASURE_TYPE_MAIN_AXIS); + EXPECT_EQ(retIdealSize.width_, layoutConstraint.parentIdealSize.width_); + /** - * @tc.steps: step1. call CreateIdealSize and set testMeasureType is MATCH_CONTENT. - * @tc.expected: step1. the return retIdealSize is the same as testOptionalSize. + * @tc.steps: step4. call CreateIdealSize and set testMeasureType is MEASURE_TYPE_MATCH_CONTENT. + * @tc.expected: the return retIdealSize is the same as testOptionalSize. */ OptionalSizeF testOptionalSize; - testMeasureType = MeasureType::MATCH_CONTENT; - retIdealSize = CreateIdealSize(layoutConstraint, testAxis, testMeasureType); + retIdealSize = CreateIdealSize(layoutConstraint, AXIS_HORIZONTAL, MEASURE_TYPE_MATCH_CONTENT); EXPECT_EQ(retIdealSize, testOptionalSize); } /** - * @tc.name: MeasureUtilsTestNgTest028 - * @tc.desc: Set one index value into MeasureUtilsTestNg and get it. + * @tc.name: MeasureUtilsTestNg028 + * @tc.desc: Test cast to MeasureUtilsTestNg. * @tc.type: FUNC */ -HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNgTest028, TestSize.Level1) +HWTEST_F(MeasureUtilsTestNg, MeasureUtilsTestNg028, TestSize.Level1) { /** - * @tc.steps: step1. call CreateChildrenConstraint and set testPadding to have no value. - * @tc.expected: step1. the input testSize is not changed. + * @tc.steps: step1. create testPadding. */ - SizeF testSize = {10.0, 20.0}; PaddingPropertyF testPadding; - CreateChildrenConstraint(testSize, testPadding); - EXPECT_EQ(testSize.width_, 10.0); - EXPECT_EQ(testSize.height_, 20.0); /** - * @tc.steps: step1. call CreateChildrenConstraint and set testPadding to have no value. - * @tc.expected: step1. the input testSize is changed to the expected value. + * @tc.steps: step2. call CreateChildrenConstraint and set testPadding to have no value. + * @tc.expected: the input CHILDREN_SIZE is not changed. */ - testPadding = {10.0, 10.0, 10.0, 10.0}; + CreateChildrenConstraint(CHILDREN_SIZE, testPadding); + EXPECT_EQ(CHILDREN_SIZE.width_, 10.0); + EXPECT_EQ(CHILDREN_SIZE.height_, 20.0); - CreateChildrenConstraint(testSize, testPadding); - EXPECT_EQ(testSize.width_, -10.0); - EXPECT_EQ(testSize.height_, 0); + /** + * @tc.steps: step3. call CreateChildrenConstraint and set testPadding to have no value. + * @tc.expected: step1. the input CHILDREN_SIZE is changed to the expected value. + */ + testPadding = TEST_PROPERTY; + + CreateChildrenConstraint(CHILDREN_SIZE, testPadding); + EXPECT_EQ(CHILDREN_SIZE.width_, -10.0); + EXPECT_EQ(CHILDREN_SIZE.height_, 0); } } // namespace OHOS::Ace::NG From dc8a59395c9d167eaa77260e1ec7aeb382e77bfd Mon Sep 17 00:00:00 2001 From: tomkl123 Date: Tue, 23 May 2023 17:09:04 +0800 Subject: [PATCH 32/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AApadding=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E7=9A=84bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tomkl123 Change-Id: I4ac6697f900159ddc62922cba80301702aae802f --- .../pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp index 2ca3b891f76..aa7c483c8f9 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/grid/grid_scroll/grid_scroll_layout_algorithm.cpp @@ -227,6 +227,8 @@ void GridScrollLayoutAlgorithm::InitialItemsCrossSize( ConvertToPx(layoutProperty->GetColumnsGap().value_or(0.0_vp), scale, frameSize.Width()).value_or(0); mainGap_ = axis_ == Axis::HORIZONTAL ? columnsGap : rowsGap; crossGap_ = axis_ == Axis::VERTICAL ? columnsGap : rowsGap; + auto padding = layoutProperty->CreatePaddingAndBorder(); + crossPaddingOffset_ = axis_ == Axis::HORIZONTAL ? padding.top.value_or(0) : padding.left.value_or(0); auto crossSize = frameSize.CrossSize(axis_); std::vector crossLens; From 9da8a28a6890ec1616dcbd7e6b9c1a21c18e6d09 Mon Sep 17 00:00:00 2001 From: zhoutianer Date: Tue, 23 May 2023 17:24:47 +0800 Subject: [PATCH 33/99] fix drawable crash Signed-off-by: zhoutianer Change-Id: I0261393b0153dde7844522280226626eb500a31a --- .../inner_api/drawable_descriptor/drawable_descriptor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interfaces/inner_api/drawable_descriptor/drawable_descriptor.cpp b/interfaces/inner_api/drawable_descriptor/drawable_descriptor.cpp index 6f1011e2c16..2e9b0be332b 100644 --- a/interfaces/inner_api/drawable_descriptor/drawable_descriptor.cpp +++ b/interfaces/inner_api/drawable_descriptor/drawable_descriptor.cpp @@ -17,6 +17,7 @@ #include #include + #include "base/utils/string_utils.h" #ifdef NEW_SKIA @@ -72,6 +73,10 @@ std::unique_ptr LayeredDrawableDescriptor::CreateImageSource { std::string itemStr = item; std::string idStr = itemStr.substr(itemStr.find(':') + 1); + if (!StringUtils::IsNumber(idStr)) { + return nullptr; + } + size_t len = 0; std::unique_ptr data; auto state = resourceMgr_->GetMediaDataById(static_cast(std::stoul(idStr)), len, data); From 54b5b579a4d5e73e4fcd35834bb7add0058621b1 Mon Sep 17 00:00:00 2001 From: lizhan Date: Tue, 23 May 2023 18:36:38 +0800 Subject: [PATCH 34/99] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86pipeline=5Fcon?= =?UTF-8?q?text(ng)=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lizhan Change-Id: I598fea46663d25b19d7bf3c9827986d2ea2d3506 Committer: lizhan Change-Id: Ie9510f8aca2aefb343731988ecbc11d7d3371115 --- .../test/mock/pattern/mock_pattern.h | 1 + .../pipeline/pipeline_context_test_ng.cpp | 454 +++++++++++++++--- 2 files changed, 381 insertions(+), 74 deletions(-) diff --git a/frameworks/core/components_ng/test/mock/pattern/mock_pattern.h b/frameworks/core/components_ng/test/mock/pattern/mock_pattern.h index 28c2ce33fb4..061e488f987 100644 --- a/frameworks/core/components_ng/test/mock/pattern/mock_pattern.h +++ b/frameworks/core/components_ng/test/mock/pattern/mock_pattern.h @@ -65,6 +65,7 @@ public: MOCK_CONST_METHOD1(ToJsonValue, void(std::unique_ptr& json)); MOCK_METHOD0(ProvideRestoreInfo, std::string()); MOCK_METHOD0(OnAreaChangedInner, void()); + MOCK_METHOD3(OnWindowSizeChanged, void(int32_t width, int32_t height, WindowSizeChangeReason type)); }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_PATTERN_H diff --git a/test/unittest/core/pipeline/pipeline_context_test_ng.cpp b/test/unittest/core/pipeline/pipeline_context_test_ng.cpp index 450ba0cd10f..fbbb897c2ca 100644 --- a/test/unittest/core/pipeline/pipeline_context_test_ng.cpp +++ b/test/unittest/core/pipeline/pipeline_context_test_ng.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include #include #include @@ -69,11 +70,14 @@ constexpr int32_t DEFAULT_INT10 = 10; constexpr int32_t DEFAULT_RESTORE_ID0 = 100; constexpr int32_t DEFAULT_RESTORE_ID1 = 101; constexpr int32_t DEFAULT_RESTORE_ID2 = 102; +constexpr int32_t NOT_REGISTER_ID = 307; constexpr uint32_t DEFAULT_SIZE1 = 1; constexpr uint32_t DEFAULT_SIZE2 = 2; constexpr uint32_t DEFAULT_SIZE3 = 3; constexpr uint32_t FRAME_COUNT = 10; constexpr uint64_t NANO_TIME_STAMP = 10; +constexpr uint64_t DEFAULT_UINT64_1 = 39; +constexpr uint64_t DEFAULT_UINT64_2 = 41; constexpr double DEFAULT_DOUBLE0 = 0.0; constexpr double DEFAULT_DOUBLE1 = 1.0; constexpr double DEFAULT_DOUBLE2 = 2.0; @@ -193,6 +197,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg001, TestSize.Level1) auto customNode_1 = CustomNode::CreateCustomNode(customNodeId_ + 20, TEST_TAG); customNode_1->SetUpdateFunction([&flagUpdate]() { CreateCycleDirtyNode(5, flagUpdate); }); context_->AddDirtyCustomNode(customNode_1); + context_->AddDirtyCustomNode(frameNode_); context_->FlushDirtyNodeUpdate(); EXPECT_TRUE(flagUpdate); EXPECT_FALSE(context_->dirtyNodes_.empty()); @@ -226,6 +231,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg002, TestSize.Level1) * @tc.expected: The drawDelegate_ is null. */ context_->onAreaChangeNodeIds_.clear(); + context_->onAreaChangeNodeIds_.emplace(NOT_REGISTER_ID); + context_->onAreaChangeNodeIds_.emplace(customNode_->nodeId_); context_->AddVisibleAreaChangeNode(frameNode_, DEFAULT_DOUBLE1, nullptr); context_->AddVisibleAreaChangeNode(frameNode_, DEFAULT_DOUBLE1, nullptr, false); EXPECT_EQ(context_->onVisibleAreaChangeNodeIds_.size(), DEFAULT_SIZE1); @@ -359,13 +366,11 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg005, TestSize.Level1) context_->FlushFocus(); EXPECT_EQ(context_->dirtyFocusNode_.Upgrade(), nullptr); /** - * @tc.steps2: Init a frameNode and SetFocusType with Node. - * @tc.steps2: Add dirty focus and call FlushFocus + * @tc.steps2: Init a frameNode and SetFocusType with Node, Add dirty focus and call FlushFocus * @tc.expected: The dirtyFocusNode_ is changed to nullptr. */ auto eventHub = frameNode_->GetEventHub(); ASSERT_NE(eventHub, nullptr); - auto focusHub = eventHub->GetOrCreateFocusHub(); ASSERT_NE(focusHub, nullptr); focusHub->SetFocusType(FocusType::NODE); @@ -376,7 +381,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg005, TestSize.Level1) context_->FlushFocus(); EXPECT_EQ(context_->dirtyFocusNode_.Upgrade(), nullptr); /** - * @tc.steps2: Init a new frameNode and SetFocusType with Node. + * @tc.steps3: Init a new frameNode and SetFocusType with Node. Add dirty focus, free focusHub_ and call FlushFocus * @tc.expected: The dirtyFocusNode_ is changed to nullptr. */ @@ -394,6 +399,55 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg005, TestSize.Level1) frameNode_->eventHub_->focusHub_ = nullptr; context_->FlushFocus(); EXPECT_EQ(context_->dirtyFocusNode_.Upgrade(), nullptr); + /** + * @tc.steps4: free stageManager_ and call FlushFocus + * @tc.expected: The dirtyFocusNode_ is changed to nullptr. + */ + auto stageManager = context_->stageManager_; + context_->stageManager_ = nullptr; + context_->FlushFocus(); + EXPECT_EQ(context_->dirtyFocusNode_.Upgrade(), nullptr); + + /** + * @tc.steps5: Init a new frameNode and SetFocusType with Node and call RequestDefaultFocus + * @tc.expected: return true while IsFocusableWholePath return true. + return false while IsFocusableWholePath return false. + */ + + /** + * @tc.steps5: set stageManager_ and stageNode_, stageNode_'s child, + create frameNode_1's focusHub and call SetIsDefaultHasFocused with true + * @tc.expected: RequestDefaultFocus returns false. + */ + context_->stageManager_ = stageManager; + context_->stageManager_->stageNode_ = frameNode_; + frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); + auto frameNode_1 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); + frameNode_->children_.push_back(frameNode_1); + focusHub = frameNode_1->eventHub_->GetOrCreateFocusHub(); + focusHub->SetIsDefaultHasFocused(true); + EXPECT_FALSE(context_->RequestDefaultFocus()); + /** + * @tc.steps6: call SetIsDefaultHasFocused with false and create a new frameNode + init frameNode_2's focusHub + * @tc.expected: RequestDefaultFocus returns true while IsFocusableWholePath return true + RequestDefaultFocus returns false while IsFocusableWholePath return false. + */ + focusHub->SetIsDefaultHasFocused(false); + focusHub->focusCallbackEvents_ = AceType::MakeRefPtr(); + auto frameNodeId_2 = ElementRegister::GetInstance()->MakeUniqueId(); + auto frameNode_2 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_2, nullptr); + frameNode_2->parent_ = nullptr; + auto newFocusHub = frameNode_2->eventHub_->GetOrCreateFocusHub(); + focusHub->focusCallbackEvents_->SetDefaultFocusNode(newFocusHub); + newFocusHub->SetFocusType(FocusType::NODE); + frameNode_2->eventHub_->enabled_ = true; + newFocusHub->show_ = true; + newFocusHub->focusable_ = true; + newFocusHub->parentFocusable_ = true; + EXPECT_TRUE(context_->RequestDefaultFocus()); + newFocusHub->SetFocusType(FocusType::DISABLE); + EXPECT_FALSE(context_->RequestDefaultFocus()); } /** @@ -550,7 +604,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg010, TestSize.Level1) EXPECT_DOUBLE_EQ(context_->GetDipScale(), DEFAULT_DOUBLE1); /** - * @tc.steps2: Call the function OnSurfaceDensityChanged with viewScale_ = 0.0. + * @tc.steps3: Call the function OnSurfaceDensityChanged with viewScale_ = 0.0. * @tc.expected: The density_ is changed to density. */ context_->viewScale_ = DEFAULT_DOUBLE2; @@ -619,8 +673,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg012, TestSize.Level1) * @tc.steps2: Call the function WindowFocus with "true" and onShow_ = true. * @tc.expected: The onFocus_ is changed to true and the size of onWindowFocusChangedCallbacks_ is change to 1. */ - context_->WindowFocus(true); context_->onShow_ = true; + context_->WindowFocus(true); EXPECT_TRUE(context_->onFocus_); EXPECT_EQ(context_->onWindowFocusChangedCallbacks_.size(), DEFAULT_SIZE1); @@ -628,8 +682,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg012, TestSize.Level1) * @tc.steps3: Call the function WindowFocus with "true" and onShow_ = false. * @tc.expected: The onFocus_ is changed to true and the size of onWindowFocusChangedCallbacks_ is change to 1. */ - context_->WindowFocus(true); context_->onShow_ = false; + context_->WindowFocus(true); EXPECT_TRUE(context_->onFocus_); EXPECT_EQ(context_->onWindowFocusChangedCallbacks_.size(), DEFAULT_SIZE1); @@ -637,8 +691,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg012, TestSize.Level1) * @tc.steps4: Call the function WindowFocus with "false" and onShow_ = true. * @tc.expected: The onFocus_ is changed to false. */ - context_->WindowFocus(false); context_->onShow_ = true; + context_->WindowFocus(false); EXPECT_FALSE(context_->onFocus_); EXPECT_EQ(context_->onWindowFocusChangedCallbacks_.size(), DEFAULT_SIZE1); @@ -646,8 +700,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg012, TestSize.Level1) * @tc.steps5: Call the function WindowFocus with "false" and onShow_ = false. * @tc.expected: The onFocus_ is changed to false. */ - context_->WindowFocus(false); context_->onShow_ = false; + context_->WindowFocus(false); EXPECT_FALSE(context_->onFocus_); EXPECT_EQ(context_->onWindowFocusChangedCallbacks_.size(), DEFAULT_SIZE1); } @@ -675,6 +729,16 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg013, TestSize.Level1) */ context_->NotifyMemoryLevel(DEFAULT_INT1); EXPECT_EQ(context_->nodesToNotifyMemoryLevel_.size(), DEFAULT_SIZE1); + + /** + * @tc.steps3: Call the function NotifyMemoryLevel with "1". + * @tc.expected: The NOT_REGISTER_ID in nodesToNotifyMemoryLevel_ is erased. + */ + context_->AddNodesToNotifyMemoryLevel(NOT_REGISTER_ID); + context_->NotifyMemoryLevel(DEFAULT_INT1); + auto iter = + find(context_->nodesToNotifyMemoryLevel_.begin(), context_->nodesToNotifyMemoryLevel_.end(), NOT_REGISTER_ID); + EXPECT_EQ(iter, context_->nodesToNotifyMemoryLevel_.end()); } /** @@ -1025,7 +1089,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg022, TestSize.Level1) context_->SetIsFocusActive(false); event.pressedCodes = { KeyCode::KEY_DPAD_UP }; eventManager->SetInstanceId(DEFAULT_INT0); - EXPECT_TRUE(context_->OnKeyEvent(event)); + EXPECT_FALSE(context_->OnKeyEvent(event)); EXPECT_FALSE(context_->GetIsFocusActive()); /** @@ -1037,7 +1101,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg022, TestSize.Level1) context_->SetIsFocusActive(false); event.action = KeyAction::UP; event.pressedCodes = { KeyCode::KEY_CLEAR }; - EXPECT_TRUE(context_->OnKeyEvent(event)); + EXPECT_FALSE(context_->OnKeyEvent(event)); EXPECT_FALSE(context_->GetIsFocusActive()); /** @@ -1145,6 +1209,27 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg023, TestSize.Level1) ResetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG); context_->OnMouseEvent(event); EXPECT_FALSE(GetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG)); + + /** + * @tc.steps9: Call the function OnMouseEvent with action = MouseAction::MOVE + * and pressedButtons = MOUSE_PRESS_LEFT. + * @tc.expected: The function DispatchTouchEvent of eventManager_ is not called. + */ + event.button = MouseButton::RIGHT_BUTTON; + ResetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG); + context_->OnMouseEvent(event); + EXPECT_FALSE(GetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG)); + + /** + * @tc.steps9: Call the function OnMouseEvent with action = MouseAction::MOVE + * and pressedButtons = MOUSE_PRESS_LEFT. + * @tc.expected: The function DispatchTouchEvent of eventManager_ is called. + */ + event.button = MouseButton::RIGHT_BUTTON; + event.action = MouseAction::PRESS; + ResetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG); + context_->OnMouseEvent(event); + EXPECT_TRUE(GetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG)); } /** @@ -1180,6 +1265,18 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg024, TestSize.Level1) ResetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG); context_->FlushTouchEvents(); EXPECT_TRUE(GetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG)); + + /** + * @tc.steps4: Call the function FlushTouchEvents with unempty touchEvents_. + * @tc.expected: The function DispatchTouchEvent of eventManager_ is called. + */ + TouchEvent event2; + event2.id = 1; + context_->touchEvents_.push_back(event); + context_->touchEvents_.push_back(event2); + ResetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG); + context_->FlushTouchEvents(); + EXPECT_TRUE(GetEventFlag(DISPATCH_TOUCH_EVENT_TOUCH_EVENT_FLAG)); } /** @@ -1197,49 +1294,25 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg025, TestSize.Level1) context_->SetupRootElement(); /** - * @tc.steps2: Call the function OnDumpInfo and test the first branch. - * @tc.expected: The return value of function is true. + * @tc.steps2: init a vector with some string params and + call OnDumpInfo with every param array. + * @tc.expected: The return value is same as the expectation. */ - std::vector params = { "-element", "-lastpage" }; - EXPECT_TRUE(context_->OnDumpInfo(params)); - params[1] = "non-lastpage"; - EXPECT_TRUE(context_->OnDumpInfo(params)); - params.pop_back(); - EXPECT_TRUE(context_->OnDumpInfo(params)); - - /** - * @tc.steps3: Call the function OnDumpInfo and test the first branch. - * @tc.expected: The return value of function is true. - */ - params = { "-element", "-lastpage" }; - EXPECT_TRUE(context_->OnDumpInfo(params)); - params[1] = "non-lastpage"; - EXPECT_TRUE(context_->OnDumpInfo(params)); - params.pop_back(); - EXPECT_TRUE(context_->OnDumpInfo(params)); - - /** - * @tc.steps4: Call the function OnDumpInfo and test the second branch. - * @tc.expected: The return value of function is true. - */ - params = { "-focus" }; - EXPECT_TRUE(context_->OnDumpInfo(params)); - - /** - * @tc.steps5: Call the function OnDumpInfo and test the third branch. - * @tc.expected: The return value of function is true. - */ - params = { ACCESS_TAG }; - EXPECT_TRUE(context_->OnDumpInfo(params)); - params = { "-inspector" }; - EXPECT_TRUE(context_->OnDumpInfo(params)); - - /** - * @tc.steps6: Call the function OnDumpInfo and test the last branch. - * @tc.expected: The return value of function is false. - */ - params = { "test" }; - EXPECT_FALSE(context_->OnDumpInfo(params)); + std::vector> params = { { "-element", "-lastpage" }, { "-element", "non-lastpage" }, + { "-element" }, { "-focus" }, { ACCESS_TAG }, { "-inspector" }, { "-render" }, { "-layer" }, { "-frontend" }, + { "-multimodal" }, { "-rotation", "1", "2", "3" }, { "-animationscale", "1", "2", "3" }, + { "-velocityscale", "1", "2", "3" }, { "-scrollfriction", "1", "2", "3" }, { "-threadstuck", "1", "2", "3" }, + { "-rotation" }, { "-animationscale" }, { "-velocityscale" }, { "-scrollfriction" }, { "-threadstuck" }, + { "test" } }; + int turn = 0; + int falseInfoNum = 6; + for (; turn < params.size(); turn++) { + if (turn < params.size() - falseInfoNum) { + EXPECT_TRUE(context_->OnDumpInfo(params[turn])); + } else { + EXPECT_FALSE(context_->OnDumpInfo(params[turn])); + } + } } /** @@ -1314,6 +1387,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg027, TestSize.Level1) * @tc.expected: All pointer is non-null. */ ASSERT_NE(context_, nullptr); + EXPECT_CALL(*(MockWindow*)(context_->window_.get()), SetDrawTextAsBitmap(_)).Times(AnyNumber()); context_->SetupRootElement(); auto frontend = AceType::MakeRefPtr(); auto& windowConfig = frontend->GetWindowConfig(); @@ -1379,6 +1453,72 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg028, TestSize.Level1) context_->designWidthScale_ = DEFAULT_DOUBLE1; context_->OnVirtualKeyboardHeightChange(DEFAULT_DOUBLE1); EXPECT_DOUBLE_EQ(context_->designWidthScale_, DEFAULT_DOUBLE1); + EXPECT_EQ(context_->rootNode_->GetGeometryNode()->GetFrameOffset().GetY(), 0); + + /** + * @tc.steps3: init data and Call the function OnVirtualKeyboardHeightChange + when textFieldManager_ is null. + * @tc.expected: the return is same as expectation. + */ + context_->textFieldManager_ = nullptr; + // the first arg is rootHeigth_, the second arg is the parameter of founction, + // the third arg is the expectation returns + std::vector> params = { { 200, 400, -300 }, { -200, 100, -100 }, { -200, -300, -100 } }; + for (int turn = 0; turn < params.size(); turn++) { + context_->rootHeight_ = params[turn][0]; + context_->OnVirtualKeyboardHeightChange(params[turn][1]); + EXPECT_EQ(context_->rootNode_->GetGeometryNode()->GetFrameOffset().GetY(), params[turn][2]); + } + /** + * @tc.steps4: init data and Call the function OnVirtualKeyboardHeightChange + when textFieldManager_ is not null. + * @tc.expected: the return is same as expectation. + */ + auto manager = AceType::MakeRefPtr(); + context_->textFieldManager_ = manager; + ASSERT_NE(context_->rootNode_, nullptr); + // the first arg is manager->height_, the second arg is manager->position_.deltaY_ + // the third arg is rootHeight_, the forth arg is context_->rootNode_->geometryNode_->frame_.rect_.y_ + // the fifth arg is the parameter of founction, the sixth arg is the expectation returns + params = { { 10, 100, 300, 0, 50, 0 }, { 10, 100, 300, 100, 100, 100 }, { 30, 100, 300, 100, 50, 100 }, + { 50, 290, 400, 100, 200, -145 }, { -1000, 290, 400, 100, 200, 100 } }; + for (int turn = 0; turn < params.size(); turn++) { + manager->height_ = params[turn][0]; + manager->position_.deltaY_ = params[turn][1]; + context_->rootHeight_ = params[turn][2]; + context_->rootNode_->geometryNode_->frame_.rect_.y_ = params[turn][3]; + context_->OnVirtualKeyboardHeightChange(params[turn][4]); + EXPECT_EQ(context_->rootNode_->GetGeometryNode()->GetFrameOffset().GetY(), params[turn][5]); + } +} + +/** + * @tc.name: PipelineContextTestNg029 + * @tc.desc: Test ThemeManager and SharedImageManager multithread. + * @tc.type: FUNC + */ +HWTEST_F(PipelineContextTestNg, PipelineContextTestNg029, TestSize.Level1) +{ + std::vector threads; + for (int i = 0; i < 20; ++i) { + threads.emplace_back(std::thread([]() { context_->GetOrCreateSharedImageManager(); })); + } + for (auto&& thread : threads) { + thread.join(); + } + + threads.clear(); + for (int i = 0; i < 20; ++i) { + if (i == 10) { + context_->SetThemeManager(AceType::MakeRefPtr()); + } else { + threads.emplace_back(std::thread([]() { context_->GetThemeManager(); })); + } + } + for (auto&& thread : threads) { + thread.join(); + } + EXPECT_TRUE(context_->GetThemeManager()); } /** @@ -1413,6 +1553,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg030, TestSize.Level1) .WillRepeatedly(testing::Return(AceType::MakeRefPtr())); EXPECT_CALL(*mockPattern_, OnAttachToFrameNode()).Times(AnyNumber()); EXPECT_CALL(*mockPattern_, OnDetachFromFrameNode(_)).Times(AnyNumber()); + /** * @tc.steps2: init a patternCreator and Create frameNodes and call StoreNode. * @tc.expected: StoreNode success. @@ -1428,11 +1569,39 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg030, TestSize.Level1) context_->StoreNode(DEFAULT_RESTORE_ID0, frameNode_2); EXPECT_EQ(context_->storeNode_[DEFAULT_RESTORE_ID0], frameNode_2); frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); - auto frameNode_3 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, patternCreator_); + auto frameNode_3 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); context_->StoreNode(DEFAULT_RESTORE_ID1, frameNode_3); EXPECT_EQ(context_->storeNode_[DEFAULT_RESTORE_ID1], frameNode_3); context_->storeNode_[DEFAULT_RESTORE_ID2] = nullptr; - mockPattern_ = nullptr; + + /** + * @tc.steps3: call RestoreNodeInfo with nullptr. + * @tc.expected: restoreNodeInfo_ is empty. + */ + auto jsonNodeInfo = context_->GetStoredNodeInfo(); + context_->RestoreNodeInfo(jsonNodeInfo->GetChild()); + EXPECT_TRUE(context_->restoreNodeInfo_.empty()); + + /** + * @tc.steps4: call GetStoredNodeInfo and RestoreNodeInfo. + * @tc.expected: restoreNodeInfo_ is not empty. + */ + context_->RestoreNodeInfo(std::move(jsonNodeInfo)); + EXPECT_FALSE(context_->restoreNodeInfo_.empty()); + + /** + * @tc.steps5: call GetRestoreInfo. + * @tc.expected: restoreInfo is not "Default restore info". + DEFAULT_RESTORE_ID0:"Default restore info" is moved from restoreNodeInfo_. + */ + std::string restoreInfo; + auto rt = context_->GetRestoreInfo(DEFAULT_RESTORE_ID0, restoreInfo); + EXPECT_EQ(restoreInfo, "Default restore info"); + EXPECT_TRUE(rt); + rt = context_->GetRestoreInfo(DEFAULT_RESTORE_ID0, restoreInfo); + EXPECT_FALSE(rt); + auto iter1 = context_->restoreNodeInfo_.find(DEFAULT_RESTORE_ID0); + EXPECT_EQ(iter1, context_->restoreNodeInfo_.end()); } /** @@ -1472,9 +1641,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg031, TestSize.Level1) EXPECT_TRUE(context_->hasIdleTasks_); /** * @tc.steps4: init uiExtensionCallback_ and call OnTouchEvent with second arg is false. - * @tc.expected: flag is true. - * @tc.expected: hasIdleTasks_ is true. - * @tc.expected: touchEvents_ is not empty. + * @tc.expected: flag is true, hasIdleTasks_ is true and touchEvents_ is not empty. */ context_->uiExtensionCallback_ = callback; point_.type = TouchType::MOVE; @@ -1484,9 +1651,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg031, TestSize.Level1) EXPECT_FALSE(context_->touchEvents_.empty()); /** * @tc.steps5: change id and call OnTouchEvent with second arg is false. - * @tc.steps5: change touch type and call OnTouchEvent with second arg is false. - * @tc.expected: touchEvents_ is not empty. - * @tc.expected: uiExtensionCallback_ is nullptr. + change touch type and call OnTouchEvent with second arg is false. + * @tc.expected: touchEvents_ is not empty and uiExtensionCallback_ is nullptr. */ point_.id += 1; context_->OnTouchEvent(point_, false); @@ -1497,17 +1663,16 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg031, TestSize.Level1) EXPECT_EQ(context_->uiExtensionCallback_, nullptr); /** * @tc.steps5: change id and call OnTouchEvent with second arg is false. - * @tc.steps5: change touch type and call OnTouchEvent with second arg is false. - * @tc.expected: touchEvents_ is not empty. - * @tc.expected: uiExtensionCallback_ is nullptr. + change touch type and call OnTouchEvent with second arg is false. + * @tc.expected: touchEvents_ is not empty, uiExtensionCallback_ is nullptr. */ context_->uiExtensionCallback_ = callback; point_.type = TouchType::CANCEL; context_->OnTouchEvent(point_, false); EXPECT_EQ(context_->uiExtensionCallback_, nullptr); /** - * @tc.steps5: create sub pipeline. - * @tc.steps5: change touch type and call OnTouchEvent with second arg is false. + * @tc.steps5: create sub pipeline and set into touchPluginPipelineContext_. + change touch type and call OnTouchEvent with second arg is false. * @tc.expected: flag is true. */ point_.type = TouchType::DOWN; @@ -1553,7 +1718,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg032, TestSize.Level1) EXPECT_EQ(rt, 0); /** * @tc.steps2: init a callback, register it and change map memory. - * @tc.steps2: then call OnSurfacePositionChanged. + then call OnSurfacePositionChanged. * @tc.expected: flag is true. */ bool flag = false; @@ -1564,7 +1729,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg032, TestSize.Level1) EXPECT_TRUE(flag); /** * @tc.steps2: call UnregisterSurfacePositionChangedCallback. - * @tc.steps2: then call OnSurfacePositionChanged. + then call OnSurfacePositionChanged. * @tc.expected: flag is true. */ context_->UnregisterSurfacePositionChangedCallback(rt); @@ -1580,31 +1745,36 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg032, TestSize.Level1) HWTEST_F(PipelineContextTestNg, PipelineContextTestNg033, TestSize.Level1) { /** - * @tc.steps1: initialize parameters and set ui nodes + * @tc.steps1: initialize parameters and set stageNode_ + set frameNode_'s children */ ASSERT_NE(context_, nullptr); context_->stageManager_->stageNode_ = frameNode_; frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); auto frameNode_1 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); frameNode_->children_.push_back(frameNode_1); - auto navigationGroupNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); auto navigationGroupNode_1 = NavigationGroupNode::GetOrCreateGroupNode(TEST_TAG, navigationGroupNodeId_, nullptr); frameNode_->children_.push_back(navigationGroupNode_1); + /** + * @tc.steps1: set frameNode_2 as navigationGroupNode_1's contentNode_,titleBarNode_ + and set frameNode_2's children + */ frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); auto frameNode_2 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); navigationGroupNode_1->contentNode_ = frameNode_2; - auto navDestinationGroupNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); auto navDestinationGroupNode_1 = NavDestinationGroupNode::GetOrCreateGroupNode(TEST_TAG, navDestinationGroupNodeId_, nullptr); frameNode_2->children_.push_back(navDestinationGroupNode_1); - auto titleBarNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); auto titleBarNode_ = TitleBarNode::GetOrCreateTitleBarNode(TEST_TAG, titleBarNodeId_, nullptr); navDestinationGroupNode_1->titleBarNode_ = titleBarNode_; + /** + * @tc.steps1: set frameNode_3 as titleBarNode_'s backButton_ + */ frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); auto frameNode_3 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); titleBarNode_->backButton_ = frameNode_3; @@ -1655,8 +1825,7 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg034, TestSize.Level1) context_->GetCurrentViewSafeArea(); EXPECT_TRUE(flag); /** - * @tc.steps3: reset window_. - * @tc.steps3: call SetGetViewSafeAreaImpl and GetCurrentViewSafeArea. + * @tc.steps3: reset window_ and call SetGetViewSafeAreaImpl and GetCurrentViewSafeArea. * @tc.expected: flag is still true. */ context_->window_ = nullptr; @@ -1681,12 +1850,149 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg035, TestSize.Level1) * @tc.steps1: call ChangeMouseStyle. */ ASSERT_NE(context_, nullptr); + context_->onFocus_ = true; context_->mouseStyleNodeId_ = 0; auto mouseStyle_ = AceType::DynamicCast(MouseStyle::CreateMouseStyle().rawPtr_); EXPECT_CALL(*mouseStyle_, ChangePointerStyle(_, _)).Times(AnyNumber()); context_->ChangeMouseStyle(0, MouseFormat::DEFAULT); } +/** + * @tc.name: PipelineContextTestNg036 + * @tc.desc: Test RequestFocus. + * @tc.type: FUNC + */ +HWTEST_F(PipelineContextTestNg, PipelineContextTestNg036, TestSize.Level1) +{ + /** + * @tc.steps1: initialize parameters and make sure pointers are not null. + */ + ASSERT_NE(context_, nullptr); + ASSERT_NE(frameNode_, nullptr); + context_->rootNode_ = frameNode_; + auto eventHub = frameNode_->GetEventHub(); + ASSERT_NE(eventHub, nullptr); + auto focusHub = eventHub->GetOrCreateFocusHub(); + ASSERT_NE(focusHub, nullptr); + frameNodeId_ = ElementRegister::GetInstance()->MakeUniqueId(); + auto frameNode_1 = FrameNode::GetOrCreateFrameNode(TEST_TAG, frameNodeId_, nullptr); + + /** + * @tc.steps2: set host_and call UpdateInspectorId. + * @tc.expect: focusNode is not null . + */ + eventHub->host_ = frameNode_1; + frameNode_1->UpdateInspectorId("123"); + auto focusNode = focusHub->GetChildFocusNodeById("123"); + ASSERT_NE(focusNode, nullptr); + + /** + * @tc.steps3: change host_,focusType_,enabled_, + show_,focusable_,parentFocusable_,currentFocus_ + */ + auto eventHub1 = frameNode_1->GetEventHub(); + eventHub1->host_ = nullptr; + focusHub->focusType_ = FocusType::NODE; + eventHub->enabled_ = true; + focusHub->show_ = true; + focusHub->focusable_ = true; + focusHub->parentFocusable_ = true; + focusHub->currentFocus_ = true; + + /** + * @tc.steps4: change isSubPipeline_ and call RequestFocus with empty string + * @tc.expect: RequestFocus empty string return false. + */ + context_->isSubPipeline_ = true; + auto rt = context_->RequestFocus(""); + EXPECT_FALSE(rt); + + /** + * @tc.steps4: change isSubPipeline_ and call RequestFocus with 123 + * @tc.expect: RequestFocus 123 success. + */ + context_->isSubPipeline_ = true; + rt = context_->RequestFocus("123"); + EXPECT_TRUE(rt); + + /** + * @tc.steps4: change isSubPipeline_ and call RequestFocus with empty string + * @tc.expect: RequestFocus empty string return false. + */ + context_->isSubPipeline_ = false; + rt = context_->RequestFocus(""); + EXPECT_FALSE(rt); + + /** + * @tc.steps4: change isSubPipeline_ and call RequestFocus with 123 + * @tc.expect: RequestFocus 123 success. + */ + context_->isSubPipeline_ = false; + rt = context_->RequestFocus("123"); + EXPECT_TRUE(rt); +} + +/** + * @tc.name: PipelineContextTestNg037 + * @tc.desc: Test ExecuteSurfaceChangedCallbacks. + * @tc.type: FUNC + */ +HWTEST_F(PipelineContextTestNg, PipelineContextTestNg037, TestSize.Level1) +{ + /** + * @tc.steps1: initialize parameters and make sure pointers are not null. + set flag and creat callback then set into surfaceChangedCallbackMap_. + call ExecuteSurfaceChangedCallbacks. + * @tc.expect: flag turns true. + */ + ASSERT_NE(context_, nullptr); + bool flag = false; + auto callback = [&flag](int32_t input_1, int32_t input_2, int32_t input_3, int32_t input_4) { flag = !flag; }; + context_->surfaceChangedCallbackMap_[0] = callback; + context_->surfaceChangedCallbackMap_[1] = nullptr; + context_->ExecuteSurfaceChangedCallbacks(0, 0); + EXPECT_TRUE(flag); +} + +/** + * @tc.name: PipelineContextTestNg038 + * @tc.desc: Test FlushWindowSizeChangeCallback. + * @tc.type: FUNC + */ +HWTEST_F(PipelineContextTestNg, PipelineContextTestNg038, TestSize.Level1) +{ + /** + * @tc.steps1: initialize parameters and make sure pointers are not null. + set onWindowSizeChangeCallbacks_. + * @tc.expect: the value 314 has been erased. + */ + ASSERT_NE(context_, nullptr); + context_->onWindowSizeChangeCallbacks_.emplace_back(314); + ASSERT_NE(frameNode_, nullptr); + context_->onWindowSizeChangeCallbacks_.emplace_back(frameNode_->GetId()); + context_->FlushWindowSizeChangeCallback(0, 0, WindowSizeChangeReason::UNDEFINED); + EXPECT_EQ(context_->onWindowSizeChangeCallbacks_.size(), 1); +} + +/** + * @tc.name: PipelineContextTestNg039 + * @tc.desc: Test GetCurrentFrameInfo. + * @tc.type: FUNC + */ +HWTEST_F(PipelineContextTestNg, PipelineContextTestNg039, TestSize.Level1) +{ + /** + * @tc.steps1: initialize parameters and make sure pointers are not null. + set dumpFrameCount_ and dumpFrameInfos_. + * @tc.expect: the return value of GetCurrentFrameInfo is null. + */ + ASSERT_NE(context_, nullptr); + SystemProperties::dumpFrameCount_ = 1; + context_->dumpFrameInfos_.push_back({}); + auto rt = context_->GetCurrentFrameInfo(DEFAULT_UINT64_1, DEFAULT_UINT64_2); + EXPECT_NE(rt, nullptr); +} + /** * @tc.name: UITaskSchedulerTestNg001 * @tc.desc: Test FlushLayoutTask. From 8389672f4a466806bbc70e2fec0e42b4a18275d9 Mon Sep 17 00:00:00 2001 From: limeng Date: Tue, 23 May 2023 19:07:22 +0800 Subject: [PATCH 35/99] =?UTF-8?q?vw/vh=E4=B8=8D=E9=9C=80=E8=A6=81=E6=94=AF?= =?UTF-8?q?=E6=8C=81=EF=BC=8C=E9=9C=80=E8=A6=81=E5=88=A0=E9=99=A4vw/vh?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=EF=BC=8C=E4=BD=86=E6=98=AFvw/vh=E6=9C=89?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng --- frameworks/base/geometry/dimension.cpp | 35 +++------------------ frameworks/base/geometry/dimension.h | 8 ----- frameworks/base/utils/string_expression.cpp | 2 +- frameworks/base/utils/string_utils.h | 12 ------- 4 files changed, 5 insertions(+), 52 deletions(-) diff --git a/frameworks/base/geometry/dimension.cpp b/frameworks/base/geometry/dimension.cpp index 4fb4c7f123a..5a48b7bad3a 100644 --- a/frameworks/base/geometry/dimension.cpp +++ b/frameworks/base/geometry/dimension.cpp @@ -31,8 +31,6 @@ struct CalcDimensionParam { float fpScale = 0.0f; float lpxScale = 0.0f; float parentLength = 0.0f; - float rootWidth = 0.0f; - float rootHeight = 0.0f; }; using CalcDimensionFunc = std::function; @@ -84,31 +82,10 @@ bool CalcDimensionLpx(const CalcDimensionParam& param, double& result) return false; } -bool CalcDimensionVw(const CalcDimensionParam& param, double& result) -{ - if (NearZero(param.rootWidth)) { - LOGE("PipelineContext's RootWidth is 0"); - return false; - } - result = param.value * param.rootWidth; - return true; -} - -bool CalcDimensionVh(const CalcDimensionParam& param, double& result) -{ - if (NearZero(param.rootHeight)) { - LOGE("PipelineContext's RootHeight is 0"); - return false; - } - result = param.value * param.rootHeight; - return true; -} - std::unordered_map calcDimensionFuncMap_ = { { DimensionUnit::NONE, &CalcDimensionNone }, { DimensionUnit::PX, &CalcDimensionPx }, { DimensionUnit::PERCENT, &CalcDimensionPercent }, { DimensionUnit::VP, &CalcDimensionVp }, - { DimensionUnit::FP, &CalcDimensionFp }, { DimensionUnit::LPX, &CalcDimensionLpx }, - { DimensionUnit::VW, &CalcDimensionVw }, { DimensionUnit::VH, &CalcDimensionVh } + { DimensionUnit::FP, &CalcDimensionFp }, { DimensionUnit::LPX, &CalcDimensionLpx } }; } // namespace @@ -170,10 +147,10 @@ double Dimension::ConvertToPxWithSize(double size) const std::string Dimension::ToString() const { - static const int32_t unitsNum = 8; + static const int32_t unitsNum = 6; static const int32_t percentIndex = 3; static const int32_t percentUnit = 100; - static std::array units = { "px", "vp", "fp", "%", "lpx", "auto", "vw", "vh" }; + static std::array units = { "px", "vp", "fp", "%", "lpx", "auto" }; if (units[static_cast(unit_)] == units[percentIndex]) { return StringUtils::DoubleToString(value_ * percentUnit).append(units[static_cast(unit_)]); } @@ -219,11 +196,7 @@ bool Dimension::NormalizeToPx( { auto func = calcDimensionFuncMap_.find(unit_); if (func != calcDimensionFuncMap_.end()) { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_RETURN(pipeline, false); - auto rootWidth = pipeline->GetRootWidth(); - auto rootHeight = pipeline->GetRootHeight(); - CalcDimensionParam param = { value_, vpScale, fpScale, lpxScale, parentLength, rootWidth, rootHeight }; + CalcDimensionParam param = { value_, vpScale, fpScale, lpxScale, parentLength }; return func->second(param, result); } return false; diff --git a/frameworks/base/geometry/dimension.h b/frameworks/base/geometry/dimension.h index b2204263548..44974aa77c0 100644 --- a/frameworks/base/geometry/dimension.h +++ b/frameworks/base/geometry/dimension.h @@ -67,14 +67,6 @@ enum class DimensionUnit { * The value is expression. */ CALC, - /* - * The value is viewport width. - */ - VW, - /* - * The value is viewport height. - */ - VH, }; /* diff --git a/frameworks/base/utils/string_expression.cpp b/frameworks/base/utils/string_expression.cpp index 6b202d0837c..8a2c811d9fd 100644 --- a/frameworks/base/utils/string_expression.cpp +++ b/frameworks/base/utils/string_expression.cpp @@ -98,7 +98,7 @@ void ReplaceSignNumber(std::string& formula) void ReplaceSignNumberWithUnit(std::string& formula) { - std::regex pattern("(\\-|\\+)\\d+(\\.\\d+)?(px|vp|%|vw|vh|fp|lpx)"); + std::regex pattern("(\\-|\\+)\\d+(\\.\\d+)?(px|vp|%|fp|lpx)"); std::smatch result; std::string matchStr; std::string catStr; diff --git a/frameworks/base/utils/string_utils.h b/frameworks/base/utils/string_utils.h index 569eab45534..bd2f7f52c43 100644 --- a/frameworks/base/utils/string_utils.h +++ b/frameworks/base/utils/string_utils.h @@ -194,12 +194,6 @@ inline bool StringToDouble(const std::string& value, double& result) if (std::strcmp(pEnd, "%") == 0) { result = res / PERCENT_VALUE; return true; - } else if (std::strcmp(pEnd, "vw") == 0) { - result = res / PERCENT_VALUE; - return true; - } else if (std::strcmp(pEnd, "vh") == 0) { - result = res / PERCENT_VALUE; - return true; } else if (std::strcmp(pEnd, "") == 0) { result = res; return true; @@ -248,12 +242,6 @@ static Dimension StringToDimensionWithUnit(const std::string& value, DimensionUn if (std::strcmp(pEnd, "lpx") == 0) { return Dimension(result, DimensionUnit::LPX); } - if (std::strcmp(pEnd, "vw") == 0) { - return Dimension(result / PERCENT_VALUE, DimensionUnit::VW); - } - if (std::strcmp(pEnd, "vh") == 0) { - return Dimension(result / PERCENT_VALUE, DimensionUnit::VH); - } if ((std::strcmp(pEnd, "\0") == 0) && isCalc) { return Dimension(result, DimensionUnit::NONE); } From 6ee46053955bbb1fe5adf6dcc710a66b73b4390a Mon Sep 17 00:00:00 2001 From: lijuan Date: Tue, 23 May 2023 09:24:48 +0000 Subject: [PATCH 36/99] =?UTF-8?q?=E7=A1=AE=E8=AE=A4textOverflow=E8=A7=84?= =?UTF-8?q?=E6=A0=BC=E4=B8=8D=E4=B8=8Eclip=E6=B7=B7=E6=B7=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijuan --- .../core/components_ng/pattern/text/text_pattern.cpp | 9 +++++++-- .../core/components_ng/pattern/text/text_pattern.h | 1 + .../test/mock/pattern/text/mock_text_pattern.cpp | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 016ffce4f66..ce0519303a0 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -42,6 +42,13 @@ namespace OHOS::Ace::NG { +void TextPattern::OnAttachToFrameNode() +{ + auto host = GetHost(); + CHECK_NULL_VOID(host); + host->GetRenderContext()->SetClipToFrame(true); +} + void TextPattern::OnDetachFromFrameNode(FrameNode* node) { CloseSelectOverlay(); @@ -668,8 +675,6 @@ void TextPattern::OnModifyDone() paragraph_.Reset(); } - bool shouldClipToContent = textLayoutProperty->GetTextOverflow().value_or(TextOverflow::CLIP) == TextOverflow::CLIP; - host->GetRenderContext()->SetClipToFrame(shouldClipToContent); std::string textCache = textForDisplay_; textForDisplay_ = textLayoutProperty->GetContent().value_or(""); diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.h b/frameworks/core/components_ng/pattern/text/text_pattern.h index 4876082b812..3aaa9070c54 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.h +++ b/frameworks/core/components_ng/pattern/text/text_pattern.h @@ -191,6 +191,7 @@ public: private: void OnDetachFromFrameNode(FrameNode* node) override; + void OnAttachToFrameNode() override; bool OnDirtyLayoutWrapperSwap(const RefPtr& dirty, const DirtySwapConfig& config) override; void HandleLongPress(GestureEvent& info); diff --git a/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp b/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp index 930cb17590f..db0c7c751c5 100644 --- a/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp +++ b/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp @@ -67,4 +67,5 @@ bool TextPattern::BetweenSelectedPosition(const Offset& globalOffset) return {}; } +void TextPattern::OnAttachToFrameNode() {} } // namespace OHOS::Ace::NG From a1effd65f79db492ef6a3957e3084e8d2ded0c90 Mon Sep 17 00:00:00 2001 From: sunbees Date: Tue, 23 May 2023 19:31:32 +0800 Subject: [PATCH 37/99] fix shape clip Signed-off-by: sunbees Change-Id: I674a96bf1f9b6ed4fa8b4faee8a7e202a3b6bb97 --- .../declarative_frontend/jsview/js_circle.cpp | 31 +++++++------------ .../jsview/js_ellipse.cpp | 31 +++++++------------ 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_circle.cpp b/frameworks/bridge/declarative_frontend/jsview/js_circle.cpp index 85d07a7600e..b0cd99355ce 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_circle.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_circle.cpp @@ -57,27 +57,20 @@ void JSCircle::Create(const JSCallbackInfo& info) void JSCircle::ConstructorCallback(const JSCallbackInfo& info) { - if (info.Length() < 1) { - LOGE("The arg is wrong, it is supposed to have at least 1 argument"); - return; - } - if (!info[0]->IsObject()) { - LOGE("The arg is not Object"); - return; - } auto circle = AceType::MakeRefPtr(); - JSRef params = JSRef::Cast(info[0]); - JSRef width = params->GetProperty("width"); - CalcDimension dimWidth; - if (ParseJsDimensionVp(width, dimWidth)) { - circle->SetWidth(dimWidth); + if (info.Length() == 1 && info[0]->IsObject()) { + JSRef params = JSRef::Cast(info[0]); + JSRef width = params->GetProperty("width"); + CalcDimension dimWidth; + if (ParseJsDimensionVp(width, dimWidth)) { + circle->SetWidth(dimWidth); + } + JSRef height = params->GetProperty("height"); + CalcDimension dimHeight; + if (ParseJsDimensionVp(height, dimHeight)) { + circle->SetHeight(dimHeight); + } } - JSRef height = params->GetProperty("height"); - CalcDimension dimHeight; - if (ParseJsDimensionVp(height, dimHeight)) { - circle->SetHeight(dimHeight); - } - auto jsCircle = AceType::MakeRefPtr(); jsCircle->SetBasicShape(circle); jsCircle->IncRefCount(); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_ellipse.cpp b/frameworks/bridge/declarative_frontend/jsview/js_ellipse.cpp index 0c5ac8570f3..ca29150d1da 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_ellipse.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_ellipse.cpp @@ -56,27 +56,20 @@ void JSEllipse::Create(const JSCallbackInfo& info) void JSEllipse::ConstructorCallback(const JSCallbackInfo& info) { - if (info.Length() < 1) { - LOGE("The arg is wrong, it is supposed to have at least 1 argument"); - return; - } - if (!info[0]->IsObject()) { - LOGE("The arg is not Object"); - return; - } auto ellipse = AceType::MakeRefPtr(); - JSRef params = JSRef::Cast(info[0]); - JSRef width = params->GetProperty("width"); - CalcDimension dimWidth; - if (ParseJsDimensionVp(width, dimWidth)) { - ellipse->SetWidth(dimWidth); + if (info.Length() == 1 && info[0]->IsObject()) { + JSRef params = JSRef::Cast(info[0]); + JSRef width = params->GetProperty("width"); + CalcDimension dimWidth; + if (ParseJsDimensionVp(width, dimWidth)) { + ellipse->SetWidth(dimWidth); + } + JSRef height = params->GetProperty("height"); + CalcDimension dimHeight; + if (ParseJsDimensionVp(height, dimHeight)) { + ellipse->SetHeight(dimHeight); + } } - JSRef height = params->GetProperty("height"); - CalcDimension dimHeight; - if (ParseJsDimensionVp(height, dimHeight)) { - ellipse->SetHeight(dimHeight); - } - auto jsEllipse = AceType::MakeRefPtr(); jsEllipse->SetBasicShape(ellipse); jsEllipse->IncRefCount(); From e8d682d6131d38c8463d9c67d8c7f8e9089959e5 Mon Sep 17 00:00:00 2001 From: yangguangzhao Date: Tue, 23 May 2023 16:33:39 +0800 Subject: [PATCH 38/99] web add feature parameters Signed-off-by: yangguangzhao --- frameworks/core/components/web/BUILD.gn | 1 + .../core/components/web/resource/web_delegate.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/frameworks/core/components/web/BUILD.gn b/frameworks/core/components/web/BUILD.gn index eec460cce90..561e8ff233c 100644 --- a/frameworks/core/components/web/BUILD.gn +++ b/frameworks/core/components/web/BUILD.gn @@ -64,6 +64,7 @@ build_component("web") { "ability_base:configuration", "ability_runtime:app_manager", "c_utils:utils", + "init:libbegetutil", "ipc:ipc_core", "webview:libnweb", ] diff --git a/frameworks/core/components/web/resource/web_delegate.cpp b/frameworks/core/components/web/resource/web_delegate.cpp index a9f4fcf9f13..5b2032f24b0 100644 --- a/frameworks/core/components/web/resource/web_delegate.cpp +++ b/frameworks/core/components/web/resource/web_delegate.cpp @@ -45,6 +45,7 @@ #include "application_env.h" #include "nweb_adapter_helper.h" #include "nweb_handler.h" +#include "parameters.h" #include "web_configuration_observer.h" #include "web_javascript_execute_callback.h" #include "web_javascript_result_callback.h" @@ -84,6 +85,10 @@ const std::string RESOURCE_VIDEO_CAPTURE = "TYPE_VIDEO_CAPTURE"; const std::string RESOURCE_AUDIO_CAPTURE = "TYPE_AUDIO_CAPTURE"; const std::string RESOURCE_PROTECTED_MEDIA_ID = "TYPE_PROTECTED_MEDIA_ID"; const std::string RESOURCE_MIDI_SYSEX = "TYPE_MIDI_SYSEX"; + +// web parameters +const std::string MULTI_RENDER_PROCESS = "persist.web.multiple_render_processes_enable"; +const std::string BACKGROUMD_MEDIA_SUSPEND = "persist.web.background_media_should_suspend"; } // namespace #define EGLCONFIG_VERSION 3 @@ -2390,6 +2395,11 @@ void WebDelegate::InitWebViewWithSurface() } initArgs.web_engine_args_to_add.push_back( std::string("--init-background-color=").append(std::to_string(delegate->backgroundColor_))); + if (!system::GetBoolParameter(BACKGROUMD_MEDIA_SUSPEND, true)) { + initArgs.web_engine_args_to_add.emplace_back( + std::move(std::string("--disable-background-media-suspend"))); + } + initArgs.multi_renderer_process = system::GetBoolParameter(MULTI_RENDER_PROCESS, false); if (isEnhanceSurface) { LOGI("Create webview with isEnhanceSurface"); delegate->nweb_ = OHOS::NWeb::NWebAdapterHelper::Instance().CreateNWeb( From 293e62e6cae74730f7e20425715cf274ccb83433 Mon Sep 17 00:00:00 2001 From: zhangjing Date: Tue, 23 May 2023 20:00:47 +0800 Subject: [PATCH 39/99] Delete crash unittest case for grid_property Signed-off-by: zhangjing Change-Id: Idfe69d984efdb93ef6c5ee5bdf63aadb38ec168f --- .../grid_property/grid_property_test_ng.cpp | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/frameworks/core/components_ng/test/property/grid_property/grid_property_test_ng.cpp b/frameworks/core/components_ng/test/property/grid_property/grid_property_test_ng.cpp index ceb334f06ee..8e9138d34a4 100755 --- a/frameworks/core/components_ng/test/property/grid_property/grid_property_test_ng.cpp +++ b/frameworks/core/components_ng/test/property/grid_property/grid_property_test_ng.cpp @@ -312,38 +312,6 @@ HWTEST_F(GridPropertyTestNg, GridPropertyTest010, TestSize.Level1) EXPECT_EQ(json->GetString("gridOffset"), ""); } -/** - * @tc.name: GridPropertyTest011 - * @tc.desc: Test the operation of Grid_Property - * @tc.type: FUNC - */ -HWTEST_F(GridPropertyTestNg, GridPropertyTest011, TestSize.Level1) -{ - /** - * @tc.steps: step1. Build a object GridProperty. - * @tc.steps: step2. callback ToJsonValue.push json is true. - * @tc.expected: step2. Return expected results. - */ - GridProperty testGridProperty; - std::vector typedPropertySet; - GridTypedProperty testGridTypedProperty0 {GridSizeType::XS, DEFAULT_GRID_SPAN, DEFAULT_GRID_OFFSET}; - GridTypedProperty testGridTypedProperty1 {GridSizeType::SM, DEFAULT_GRID_SPAN, DEFAULT_GRID_OFFSET}; - GridTypedProperty testGridTypedProperty2 {GridSizeType::MD, DEFAULT_GRID_SPAN, DEFAULT_GRID_OFFSET}; - GridTypedProperty testGridTypedProperty3 {GridSizeType::LG, DEFAULT_GRID_SPAN, DEFAULT_GRID_OFFSET}; - GridTypedProperty testGridTypedProperty4 {GridSizeType::XL, DEFAULT_GRID_SPAN, DEFAULT_GRID_OFFSET}; - typedPropertySet.clear(); - typedPropertySet.emplace_back(testGridTypedProperty0); - typedPropertySet.emplace_back(testGridTypedProperty1); - typedPropertySet.emplace_back(testGridTypedProperty2); - typedPropertySet.emplace_back(testGridTypedProperty3); - typedPropertySet.emplace_back(testGridTypedProperty4); - testGridProperty.typedPropertySet_ = typedPropertySet; - - auto json = JsonUtil::Create(true); - testGridProperty.ToJsonValue(json); - EXPECT_EQ(json->GetString("span"), ""); -} - /** * @tc.name: GridPropertyTest012 * @tc.desc: Test the operation of Grid_Property From 86c8a8b935052126856ec88df109d54fe2aab151 Mon Sep 17 00:00:00 2001 From: sunfei Date: Tue, 23 May 2023 20:06:03 +0800 Subject: [PATCH 40/99] use skia svg for ng build Signed-off-by: sunfei Change-Id: Ia73f1821d677a57934108c3b49ac5cdbd89778b6 --- frameworks/bridge/declarative_frontend/BUILD.gn | 1 + .../engine/jsi/jsi_view_register_impl_ng.cpp | 14 +++++++------- .../declarative_frontend/jsview/js_button.cpp | 2 ++ frameworks/core/BUILD.gn | 5 ----- .../image_provider/adapter/skia_image_data.cpp | 8 ++++---- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/BUILD.gn b/frameworks/bridge/declarative_frontend/BUILD.gn index aeda99a7a3b..b8c3571d26c 100644 --- a/frameworks/bridge/declarative_frontend/BUILD.gn +++ b/frameworks/bridge/declarative_frontend/BUILD.gn @@ -579,6 +579,7 @@ template("declarative_js_engine_ng") { "sharedata/js_share_data.cpp", # jsviews + "jsview/js_button.cpp", "jsview/js_column.cpp", "jsview/js_container_base.cpp", "jsview/js_counter.cpp", diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/jsi_view_register_impl_ng.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/jsi_view_register_impl_ng.cpp index 1670dd84090..5bd39d631cf 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/jsi_view_register_impl_ng.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/jsi_view_register_impl_ng.cpp @@ -17,18 +17,15 @@ #include "base/i18n/localization.h" #include "base/log/log.h" #include "base/memory/ace_type.h" -#ifdef VIDEO_SUPPORTED -#include "bridge/declarative_frontend/jsview/js_video.h" -#endif #include "core/components_ng/base/ui_node.h" #include "core/components_ng/base/view_stack_processor.h" #include "core/components_ng/pattern/custom/custom_node.h" #include "core/components_ng/pattern/stage/page_pattern.h" -#include "frameworks/bridge/card_frontend/card_frontend_declarative.h" #include "frameworks/bridge/common/utils/engine_helper.h" #include "frameworks/bridge/declarative_frontend/engine/functions/js_drag_function.h" #include "frameworks/bridge/declarative_frontend/engine/js_object_template.h" #include "frameworks/bridge/declarative_frontend/engine/jsi/jsi_view_register.h" +#include "frameworks/bridge/declarative_frontend/jsview/js_button.h" #include "frameworks/bridge/declarative_frontend/jsview/js_column.h" #include "frameworks/bridge/declarative_frontend/jsview/js_container_base.h" #include "frameworks/bridge/declarative_frontend/jsview/js_counter.h" @@ -60,13 +57,15 @@ #include "frameworks/bridge/declarative_frontend/jsview/js_text.h" #include "frameworks/bridge/declarative_frontend/jsview/js_textinput.h" #include "frameworks/bridge/declarative_frontend/jsview/js_toggle.h" +#include "frameworks/bridge/declarative_frontend/jsview/js_view.h" +#include "frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h" #include "frameworks/bridge/declarative_frontend/jsview/scroll_bar/js_scroll_bar.h" +#include "frameworks/bridge/declarative_frontend/ng/declarative_frontend_ng.h" +#include "frameworks/bridge/declarative_frontend/ng/frontend_delegate_declarative_ng.h" + #ifdef VIDEO_SUPPORTED #include "frameworks/bridge/declarative_frontend/jsview/js_video.h" #endif -#include "frameworks/bridge/declarative_frontend/jsview/js_view.h" -#include "frameworks/bridge/declarative_frontend/jsview/js_view_stack_processor.h" -#include "frameworks/bridge/declarative_frontend/ng/frontend_delegate_declarative_ng.h" namespace OHOS::Ace::Framework { @@ -188,6 +187,7 @@ void JsBindViews(BindingTarget globalObj) JSImageSpan::JSBind(globalObj); JSScroller::JSBind(globalObj); JSScrollBar::JSBind(globalObj); + JSButton::JSBind(globalObj); } } // namespace OHOS::Ace::Framework diff --git a/frameworks/bridge/declarative_frontend/jsview/js_button.cpp b/frameworks/bridge/declarative_frontend/jsview/js_button.cpp index 8787bfab432..0d183422f51 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_button.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_button.cpp @@ -256,6 +256,7 @@ void JSButton::SetLableStyle(const JSCallbackInfo& info) void JSButton::JsRemoteMessage(const JSCallbackInfo& info) { +#ifndef NG_BUILD RemoteCallback remoteCallback; JSInteractableView::JsRemoteMessage(info, remoteCallback); EventMarker remoteMessageEventId(std::move(remoteCallback)); @@ -264,6 +265,7 @@ void JSButton::JsRemoteMessage(const JSCallbackInfo& info) if (buttonComponent) { buttonComponent->SetRemoteMessageEventId(remoteMessageEventId); } +#endif } void JSButton::JSBind(BindingTarget globalObj) diff --git a/frameworks/core/BUILD.gn b/frameworks/core/BUILD.gn index cfcef079ffd..63a932a67ac 100644 --- a/frameworks/core/BUILD.gn +++ b/frameworks/core/BUILD.gn @@ -678,15 +678,10 @@ template("ace_core_ng_source_set") { "pipeline/pipeline_base.cpp", # image - "image/animated_image_player.cpp", "image/flutter_image_cache.cpp", "image/image_cache.cpp", "image/image_compressor.cpp", "image/image_loader.cpp", - "image/image_object.cpp", - "image/image_object_animated.cpp", - "image/image_object_svg.cpp", - "image/image_provider.cpp", "image/image_source_info.cpp", # textfield diff --git a/frameworks/core/components_ng/image_provider/adapter/skia_image_data.cpp b/frameworks/core/components_ng/image_provider/adapter/skia_image_data.cpp index 0abd76a4ac2..16ff3fa4172 100644 --- a/frameworks/core/components_ng/image_provider/adapter/skia_image_data.cpp +++ b/frameworks/core/components_ng/image_provider/adapter/skia_image_data.cpp @@ -63,15 +63,15 @@ sk_sp SkiaImageData::GetSkData() const RefPtr SkiaImageData::MakeSvgDom(const std::optional& svgFillColor) { - // TODO: svg support in ng build -#ifdef NG_BUILD - return nullptr; -#else const auto svgStream = std::make_unique(skData_); CHECK_NULL_RETURN(svgStream, nullptr); if (SystemProperties::GetSvgMode() <= 0) { return SkiaSvgDom::CreateSkiaSvgDom(*svgStream, svgFillColor); } +#ifdef NG_BUILD + LOGE("NG SvgDom not support!"); + return nullptr; +#else auto svgDom_ = SvgDom::CreateSvgDom(*svgStream, svgFillColor); if (!svgDom_) { return nullptr; From 3a1683e5e20b81bd8207d0a84ae1b43162c9d09b Mon Sep 17 00:00:00 2001 From: lijuan Date: Tue, 23 May 2023 09:46:44 +0000 Subject: [PATCH 41/99] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=96=87=E6=9C=AC=E9=80=89=E6=8B=A9=E5=BC=B9?= =?UTF-8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijuan --- .../pattern/text/text_model_ng.cpp | 3 ++ .../pattern/text/text_pattern.cpp | 34 +++++++++++++++++++ .../components_ng/pattern/text/text_pattern.h | 12 +++++++ .../pattern/text_field/text_field_pattern.cpp | 7 +++- .../pattern/text_field/text_field_pattern.h | 2 +- .../mock/pattern/text/mock_text_pattern.cpp | 1 + .../test/pattern/text/text_test_ng.cpp | 24 +++++++++++++ 7 files changed, 81 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp index c18c7ebaffb..b4721217a61 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp @@ -42,6 +42,9 @@ void TextModelNG::Create(const std::string& content) auto theme = pipeline->GetTheme(); CHECK_NULL_VOID(theme); SetDraggable(theme->GetDraggable()); + CHECK_NULL_VOID(frameNode); + auto textPattern = frameNode->GetPattern(); + textPattern->InitSurfaceChangedCallback(); } void TextModelNG::SetFontSize(const Dimension& value) diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 016ffce4f66..66f8850e0dd 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -45,6 +45,12 @@ namespace OHOS::Ace::NG { void TextPattern::OnDetachFromFrameNode(FrameNode* node) { CloseSelectOverlay(); + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + if (HasSurfaceChangedCallback()) { + LOGD("Unregister surface change callback with id %{public}d", surfaceChangedCallbackId_.value_or(-1)); + pipeline->UnregisterSurfaceChangedCallback(surfaceChangedCallbackId_.value_or(-1)); + } } void TextPattern::CloseSelectOverlay() @@ -826,6 +832,34 @@ void TextPattern::OnVisibleChange(bool isVisible) } } +void TextPattern::InitSurfaceChangedCallback() +{ + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto pipeline = host->GetContext(); + CHECK_NULL_VOID(pipeline); + if (!HasSurfaceChangedCallback()) { + auto callbackId = pipeline->RegisterSurfaceChangedCallback( + [weak = WeakClaim(this)](int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight) { + auto pattern = weak.Upgrade(); + if (pattern) { + pattern->HandleSurfaceChanged(newWidth, newHeight, prevWidth, prevHeight); + } + }); + LOGD("Add surface changed callback id %{public}d", callbackId); + UpdateSurfaceChangedCallbackId(callbackId); + } +} + +void TextPattern::HandleSurfaceChanged(int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight) +{ + LOGD("TextPattern handle surface change, new width %{public}d, new height %{public}d, prev width %{public}d, prev " + "height %{public}d", + newWidth, newHeight, prevWidth, prevHeight); + CloseSelectOverlay(); + ResetSelection(); +} + void TextPattern::AddChildSpanItem(const RefPtr& child) { CHECK_NULL_VOID(child); diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.h b/frameworks/core/components_ng/pattern/text/text_pattern.h index 4876082b812..b76c900b2c7 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.h +++ b/frameworks/core/components_ng/pattern/text/text_pattern.h @@ -189,6 +189,17 @@ public: // end of TextDragBase implementations // =========================================================== + void InitSurfaceChangedCallback(); + void HandleSurfaceChanged(int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight); + bool HasSurfaceChangedCallback() + { + return surfaceChangedCallbackId_.has_value(); + } + void UpdateSurfaceChangedCallbackId(int32_t id) + { + surfaceChangedCallbackId_ = id; + } + private: void OnDetachFromFrameNode(FrameNode* node) override; bool OnDirtyLayoutWrapperSwap(const RefPtr& dirty, const DirtySwapConfig& config) override; @@ -250,6 +261,7 @@ private: bool mouseEventInitialized_ = false; bool panEventInitialized_ = false; std::optional textStyle_; + std::optional surfaceChangedCallbackId_; RefPtr textContentModifier_; RefPtr textOverlayModifier_; diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp index eadddf8a65a..54a8576a807 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp @@ -3316,11 +3316,16 @@ void TextFieldPattern::OnVisibleChange(bool isVisible) } void TextFieldPattern::HandleSurfaceChanged( - int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight) const + int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight) { LOGI("Textfield handle surface change, new width %{public}d, new height %{public}d, prev width %{public}d, prev " "height %{public}d", newWidth, newHeight, prevWidth, prevHeight); + CloseSelectOverlay(); + textSelector_.Update(-1); + auto host = GetHost(); + CHECK_NULL_VOID(host); + host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); UpdateCaretInfoToController(); } diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h index b794f04472b..4c2e631dcf6 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h @@ -548,7 +548,7 @@ public: float GetIconHotZoneSize(); float GetIconSize(); - void HandleSurfaceChanged(int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight) const; + void HandleSurfaceChanged(int32_t newWidth, int32_t newHeight, int32_t prevWidth, int32_t prevHeight); void HandleSurfacePositionChanged(int32_t posX, int32_t posY) const; void InitSurfaceChangedCallback(); diff --git a/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp b/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp index 930cb17590f..157baa16daa 100644 --- a/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp +++ b/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp @@ -67,4 +67,5 @@ bool TextPattern::BetweenSelectedPosition(const Offset& globalOffset) return {}; } +void TextPattern::InitSurfaceChangedCallback() {} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp b/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp index 7aece9da3c1..576f13a2330 100644 --- a/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/text/text_test_ng.cpp @@ -17,6 +17,7 @@ #include #include "gtest/gtest.h" + #include "core/components_ng/base/geometry_node.h" #define private public @@ -2909,4 +2910,27 @@ HWTEST_F(TextTestNg, UpdateChildProperty002, TestSize.Level1) */ TestUpdateScenario(pattern); } + +/** + * @tc.name: InitSurfaceChangedTest001 + * @tc.desc: test InitSurfaceChangedCallback function + * @tc.type: FUNC + */ +HWTEST_F(TextTestNg, InitSurfaceChangedTest001, TestSize.Level1) +{ + TestProperty testProperty; + /** + * @tc.steps: step1. create text FrameNode and SpanNode, Update child FrameNode properties + * @tc.expected: Successfully created parent Node and child Node + */ + auto host = CreateTextParagraph(CREATE_VALUE, testProperty); + ASSERT_NE(host, nullptr); + /** + * @tc.steps: step2. get text pattern called InitSurfaceChangedCallback function. + * @tc.expected: HasSurfaceChangedCallback return true. + */ + auto pattern = host->GetPattern(); + pattern->InitSurfaceChangedCallback(); + EXPECT_TRUE(pattern->HasSurfaceChangedCallback()); +} } // namespace OHOS::Ace::NG From 1c87e2ab5ae21116e5feaa8a729250ba6bdd99dd Mon Sep 17 00:00:00 2001 From: lijianing Date: Tue, 23 May 2023 11:19:12 +0800 Subject: [PATCH 42/99] =?UTF-8?q?list=E9=BC=A0=E6=A0=87=E6=A1=86=E9=80=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D+1=E5=A4=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijianing Change-Id: If256bd66aaa1ed1207b2d2ac31378910b5cc71bf --- .../pattern/list/list_item_pattern.cpp | 6 ++ .../pattern/list/list_item_pattern.h | 3 + .../pattern/list/list_pattern.cpp | 90 +++++++++++++++---- .../components_ng/pattern/list/list_pattern.h | 4 + 4 files changed, 85 insertions(+), 18 deletions(-) diff --git a/frameworks/core/components_ng/pattern/list/list_item_pattern.cpp b/frameworks/core/components_ng/pattern/list/list_item_pattern.cpp index 8c982e5bc7d..586510c0025 100644 --- a/frameworks/core/components_ng/pattern/list/list_item_pattern.cpp +++ b/frameworks/core/components_ng/pattern/list/list_item_pattern.cpp @@ -19,6 +19,7 @@ #include "base/geometry/ng/size_t.h" #include "base/memory/ace_type.h" #include "base/utils/utils.h" +#include "core/components/common/properties/color.h" #include "core/components_ng/pattern/list/list_item_layout_algorithm.h" #include "core/components_ng/pattern/list/list_item_layout_property.h" #include "core/components_ng/pattern/list/list_pattern.h" @@ -555,6 +556,11 @@ void ListItemPattern::MarkIsSelected(bool isSelected) } else { host->OnAccessibilityEvent(AccessibilityEventType::CHANGE); } + auto geometryNode = host->GetGeometryNode(); + CHECK_NULL_VOID(geometryNode); + auto context = host->GetRenderContext(); + CHECK_NULL_VOID(context); + context->OnMouseSelectUpdate(isSelected, ITEM_FILL_COLOR, ITEM_FILL_COLOR); } } diff --git a/frameworks/core/components_ng/pattern/list/list_item_pattern.h b/frameworks/core/components_ng/pattern/list/list_item_pattern.h index e460c7bad57..5857a12e012 100644 --- a/frameworks/core/components_ng/pattern/list/list_item_pattern.h +++ b/frameworks/core/components_ng/pattern/list/list_item_pattern.h @@ -129,6 +129,9 @@ public: void SetSelectable(bool selectable) { selectable_ = selectable; + if (!selectable) { + MarkIsSelected(false); + } } void SetUseStartDefaultDeleteAnimation(bool useStartDefaultDeleteAnimation) diff --git a/frameworks/core/components_ng/pattern/list/list_pattern.cpp b/frameworks/core/components_ng/pattern/list/list_pattern.cpp index c4438c61c51..647e662d710 100644 --- a/frameworks/core/components_ng/pattern/list/list_pattern.cpp +++ b/frameworks/core/components_ng/pattern/list/list_pattern.cpp @@ -40,7 +40,6 @@ constexpr double CHAIN_SPRING_DAMPING = 30.0; constexpr double CHAIN_SPRING_STIFFNESS = 228; constexpr Color SELECT_FILL_COLOR = Color(0x1A000000); constexpr Color SELECT_STROKE_COLOR = Color(0x33FFFFFF); -constexpr Color ITEM_FILL_COLOR = Color(0x1A0A59f7); constexpr float DEFAULT_MIN_SPACE_SCALE = 0.75f; constexpr float DEFAULT_MAX_SPACE_SCALE = 2.0f; } // namespace @@ -82,6 +81,9 @@ void ListPattern::OnModifyDone() if (multiSelectable_ && !isMouseEventInit_) { InitMouseEvent(); } + if (!multiSelectable_ && isMouseEventInit_) { + UninitMouseEvent(); + } auto focusHub = host->GetFocusHub(); CHECK_NULL_VOID_NOLOG(focusHub); InitOnKeyEvent(focusHub); @@ -101,15 +103,18 @@ bool ListPattern::OnDirtyLayoutWrapperSwap(const RefPtr& dirty, c itemPosition_ = listLayoutAlgorithm->GetItemPosition(); maxListItemIndex_ = listLayoutAlgorithm->GetMaxListItemIndex(); spaceWidth_ = listLayoutAlgorithm->GetSpaceWidth(); - float absoluteOffset = 0.0f; float relativeOffset = listLayoutAlgorithm->GetCurrentOffset(); if (jumpIndex_) { - absoluteOffset = listLayoutAlgorithm->GetEstimateOffset(); + float absoluteOffset = listLayoutAlgorithm->GetEstimateOffset(); relativeOffset += absoluteOffset - currentOffset_; isJump = true; jumpIndex_.reset(); } - currentOffset_ = currentOffset_ + relativeOffset; + if (listLayoutAlgorithm->GetStartIndex() == 0) { + currentOffset_ = -listLayoutAlgorithm->GetStartPosition(); + } else { + currentOffset_ = currentOffset_ + relativeOffset; + } if (isScrollEnd_) { auto host = GetHost(); CHECK_NULL_RETURN(host, false); @@ -933,6 +938,17 @@ float ListPattern::GetChainDelta(int32_t index) const return chainAnimation_->GetValue(index); } +void ListPattern::UninitMouseEvent() +{ + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto mouseEventHub = host->GetOrCreateInputEventHub(); + CHECK_NULL_VOID(mouseEventHub); + mouseEventHub->SetMouseEvent(nullptr); + ClearMultiSelect(); + isMouseEventInit_ = false; +} + void ListPattern::InitMouseEvent() { auto host = GetHost(); @@ -950,22 +966,44 @@ void ListPattern::InitMouseEvent() void ListPattern::HandleMouseEventWithoutKeyboard(const MouseInfo& info) { + if (info.GetButton() != MouseButton::LEFT_BUTTON) { + return; + } + + auto pipeline = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto manager = pipeline->GetDragDropManager(); + CHECK_NULL_VOID(manager); + if (manager->IsDragged()) { + return; + } + auto mouseOffsetX = static_cast(info.GetLocalLocation().GetX()); auto mouseOffsetY = static_cast(info.GetLocalLocation().GetY()); - if (info.GetButton() == MouseButton::LEFT_BUTTON) { - if (info.GetAction() == MouseAction::PRESS) { - mouseStartOffset_ = OffsetF(mouseOffsetX, mouseOffsetY); - mouseEndOffset_ = OffsetF(mouseOffsetX, mouseOffsetY); - // do not select when click - } else if (info.GetAction() == MouseAction::MOVE) { + if (info.GetAction() == MouseAction::PRESS) { + ClearMultiSelect(); + mouseStartOffset_ = OffsetF(mouseOffsetX, mouseOffsetY); + mouseEndOffset_ = OffsetF(mouseOffsetX, mouseOffsetY); + mousePressOffset_ = OffsetF(mouseOffsetX, mouseOffsetY); + mousePressed_ = true; + // do not select when click + } else if (info.GetAction() == MouseAction::MOVE) { + if (!mousePressed_) { + return; + } + const static double FRAME_SELECTION_DISTANCE = + pipeline->NormalizeToPx(Dimension(DEFAULT_PAN_DISTANCE, DimensionUnit::VP)); + auto delta = OffsetF(mouseOffsetX, mouseOffsetY) - mousePressOffset_; + if (Offset(delta.GetX(), delta.GetY()).GetDistance() > FRAME_SELECTION_DISTANCE) { mouseEndOffset_ = OffsetF(mouseOffsetX, mouseOffsetY); auto selectedZone = ComputeSelectedZone(mouseStartOffset_, mouseEndOffset_); MultiSelectWithoutKeyboard(selectedZone); - } else if (info.GetAction() == MouseAction::RELEASE) { - mouseStartOffset_.Reset(); - mouseEndOffset_.Reset(); - ClearSelectedZone(); } + } else if (info.GetAction() == MouseAction::RELEASE) { + mouseStartOffset_.Reset(); + mouseEndOffset_.Reset(); + mousePressed_ = false; + ClearSelectedZone(); } } @@ -984,16 +1022,12 @@ void ListPattern::MultiSelectWithoutKeyboard(const RectF& selectedZone) auto itemGeometry = item->GetGeometryNode(); CHECK_NULL_VOID(itemGeometry); - auto context = item->GetRenderContext(); - CHECK_NULL_VOID(context); auto itemRect = itemGeometry->GetFrameRect(); if (!selectedZone.IsIntersectWith(itemRect)) { itemPattern->MarkIsSelected(false); - context->OnMouseSelectUpdate(false, ITEM_FILL_COLOR, ITEM_FILL_COLOR); } else { itemPattern->MarkIsSelected(true); - context->OnMouseSelectUpdate(true, ITEM_FILL_COLOR, ITEM_FILL_COLOR); } } @@ -1002,6 +1036,26 @@ void ListPattern::MultiSelectWithoutKeyboard(const RectF& selectedZone) hostContext->UpdateMouseSelectWithRect(selectedZone, SELECT_FILL_COLOR, SELECT_STROKE_COLOR); } +void ListPattern::ClearMultiSelect() +{ + auto host = GetHost(); + CHECK_NULL_VOID(host); + std::list> children; + host->GenerateOneDepthAllFrame(children); + for (const auto& item : children) { + if (!AceType::InstanceOf(item)) { + continue; + } + + auto itemFrameNode = AceType::DynamicCast(item); + auto itemPattern = itemFrameNode->GetPattern(); + CHECK_NULL_VOID(itemPattern); + itemPattern->MarkIsSelected(false); + } + + ClearSelectedZone(); +} + void ListPattern::ClearSelectedZone() { auto host = GetHost(); diff --git a/frameworks/core/components_ng/pattern/list/list_pattern.h b/frameworks/core/components_ng/pattern/list/list_pattern.h index 711eef8f9f7..541fae076cb 100644 --- a/frameworks/core/components_ng/pattern/list/list_pattern.h +++ b/frameworks/core/components_ng/pattern/list/list_pattern.h @@ -219,8 +219,10 @@ private: void StopAnimate(); // multiSelectable + void UninitMouseEvent(); void InitMouseEvent(); void HandleMouseEventWithoutKeyboard(const MouseInfo& info); + void ClearMultiSelect(); void ClearSelectedZone(); RectF ComputeSelectedZone(const OffsetF& startOffset, const OffsetF& endOffset); void MultiSelectWithoutKeyboard(const RectF& selectedZone); @@ -270,8 +272,10 @@ private: // multiSelectable bool multiSelectable_ = false; bool isMouseEventInit_ = false; + bool mousePressed_ = false; OffsetF mouseStartOffset_; OffsetF mouseEndOffset_; + OffsetF mousePressOffset_; // ListItem swiperAction WeakPtr swiperItem_; From cf13ad50ce1d79f84ecba9ed1e5ea2bbc351493d Mon Sep 17 00:00:00 2001 From: limeng Date: Tue, 23 May 2023 22:06:10 +0800 Subject: [PATCH 43/99] fix the crash bug Signed-off-by: limeng --- .../jsview/js_offscreen_canvas.cpp | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_offscreen_canvas.cpp b/frameworks/bridge/declarative_frontend/jsview/js_offscreen_canvas.cpp index f51d7916e72..ef64618cdc8 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_offscreen_canvas.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_offscreen_canvas.cpp @@ -213,34 +213,17 @@ void JSOffscreenCanvas::JsSetHeight(const JSCallbackInfo& info) void JSOffscreenCanvas::JsTransferToImageBitmap(const JSCallbackInfo& info) { - if (Container::IsCurrentUseNewPipeline() && !offscreenCanvasPattern_) { - std::unique_ptr imageData = - offscreenCanvasPattern_->GetImageData(0.0, 0.0, GetWidth(), GetHeight()); - if (imageData.get() == nullptr) { - return; - } - double final_height = static_cast(imageData->dirtyHeight); - double final_width = static_cast(imageData->dirtyWidth); - - JSRef colorArray = JSRef::New(); - uint32_t count = 0; - for (uint32_t i = 0; i < final_height; i++) { - for (uint32_t j = 0; j < final_width; j++) { - int32_t idx = i * imageData->dirtyWidth + j; - auto pixel = imageData->data[idx]; - - colorArray->SetValueAt(count, JSRef::Make(ToJSValue(pixel.GetRed()))); - colorArray->SetValueAt(count + 1, JSRef::Make(ToJSValue(pixel.GetGreen()))); - colorArray->SetValueAt(count + 2, JSRef::Make(ToJSValue(pixel.GetBlue()))); - colorArray->SetValueAt(count + 3, JSRef::Make(ToJSValue(pixel.GetAlpha()))); - count += 4; - } - } - auto retObj = JSRef::New(); - retObj->SetProperty("width", final_width); - retObj->SetProperty("height", final_height); - retObj->SetPropertyObject("data", colorArray); - info.SetReturnValue(retObj); + if (Container::IsCurrentUseNewPipeline()) { + CHECK_NULL_VOID(offscreenCanvasContext_); + CHECK_NULL_VOID(offscreenCanvasPattern_); + auto final_height = static_cast(GetHeight()); + auto final_width = static_cast(GetWidth()); + JSRef renderImage = JSRef::New(); + renderImage->SetProperty("__type", "ImageBitmap"); + renderImage->SetProperty("__id", offscreenCanvasContext_->GetId()); + renderImage->SetProperty("height", final_height); + renderImage->SetProperty("width", final_width); + info.SetReturnValue(renderImage); } } From 492f66102ecab1e06c9ac00f42f0992b82f88eb2 Mon Sep 17 00:00:00 2001 From: Tsvetan Stefanovski twx512252 Date: Tue, 23 May 2023 17:31:17 +0200 Subject: [PATCH 44/99] Fixed checks for PersistentStorage::Set Signed-off-by: Tsvetan Stefanovski twx512252 Change-Id: I930e3336937051f33b9a96faad92aac722799086 --- .../bridge/declarative_frontend/jsview/js_persistent.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_persistent.cpp b/frameworks/bridge/declarative_frontend/jsview/js_persistent.cpp index 146f6f38bc5..0bcabe8d315 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_persistent.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_persistent.cpp @@ -60,7 +60,7 @@ void JSPersistent::Set(const JSCallbackInfo& args) "emulator or a real device instead."); return; #endif - if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsString()) { + if (args.Length() < 2 || !args[0]->IsString() || args[1]->IsUndefined() || args[1]->IsNull()) { LOGW("JSPersistent: Fail to set persistent data, args too few"); return; } @@ -73,6 +73,7 @@ void JSPersistent::Set(const JSCallbackInfo& args) } auto executor = container->GetTaskExecutor(); if(!StorageProxy::GetInstance()->GetStorage(executor)) { + LOGW("no storage available"); return; } StorageProxy::GetInstance()->GetStorage(executor)->SetString(key, value); From 526c2b6007ca5be796b5d87e5ab099fe84b6b68e Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Wed, 24 May 2023 01:23:54 +0800 Subject: [PATCH 45/99] add animate to list Signed-off-by: sunjiakun --- .../jsview/js_scroller.cpp | 19 ++- .../declarative_frontend/jsview/js_scroller.h | 2 + .../scroll/scroll_controller_base.h | 2 +- .../scroll/scroll_position_controller.cpp | 3 +- .../scroll/scroll_position_controller.h | 2 +- .../pattern/grid/grid_position_controller.cpp | 3 +- .../pattern/grid/grid_position_controller.h | 2 +- .../pattern/list/list_pattern.cpp | 49 ++++++- .../components_ng/pattern/list/list_pattern.h | 5 +- .../pattern/list/list_position_controller.cpp | 5 +- .../pattern/list/list_position_controller.h | 2 +- .../scroll/scroll_position_controller.cpp | 3 +- .../scroll/scroll_position_controller.h | 2 +- .../test/pattern/grid/grid_test_ng.cpp | 6 +- .../components_ng/test/pattern/list/BUILD.gn | 4 + .../test/pattern/list/list_test_ng.cpp | 122 +++++++++++++++++- .../test/pattern/scroll/scroll_test_ng.cpp | 4 +- .../grid/grid_position_controller.cpp | 3 +- .../grid/grid_position_controller.h | 2 +- .../list/list_position_controller.cpp | 3 +- .../list/list_position_controller.h | 2 +- 21 files changed, 214 insertions(+), 31 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_scroller.cpp b/frameworks/bridge/declarative_frontend/jsview/js_scroller.cpp index dcd5012c7d7..2994dbcc32c 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_scroller.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_scroller.cpp @@ -104,14 +104,20 @@ void JSScroller::ScrollTo(const JSCallbackInfo& args) ConvertFromJSValue(animationObj->GetProperty("duration"), duration); std::string curveName; - if (ConvertFromJSValue(animationObj->GetProperty("curve"), curveName)) { + auto curveArgs = animationObj->GetProperty("curve"); + if (ConvertFromJSValue(curveArgs, curveName)) { auto index = BinarySearchFindIndex(CURVE_MAP, ArraySize(CURVE_MAP), curveName.c_str()); if (index >= 0) { curve = CURVE_MAP[index].value; } + } else if (curveArgs->IsObject()) { + ParseCustomCurveParams(curve, curveArgs); } } + bool smooth = false; + ConvertFromJSValue(obj->GetProperty("smooth"), smooth); + if (GreatNotEqual(duration, 0.0)) { LOGD("ScrollTo(%lf, %lf, %lf)", xOffset.Value(), yOffset.Value(), duration); } else { @@ -124,7 +130,16 @@ void JSScroller::ScrollTo(const JSCallbackInfo& args) } auto direction = scrollController->GetScrollDirection(); auto position = direction == Axis::VERTICAL ? yOffset : xOffset; - scrollController->AnimateTo(position, static_cast(duration), curve); + scrollController->AnimateTo(position, static_cast(duration), curve, smooth); +} + +void JSScroller::ParseCustomCurveParams(RefPtr& curve, const JSRef& jsValue) +{ + auto icurveArgs = JsonUtil::ParseJsonString(jsValue->ToString()); + if (icurveArgs->IsObject()) { + auto curveString = icurveArgs->GetValue("__curveString"); + curve = CreateCurve(curveString->GetString()); + } } void JSScroller::ScrollEdge(const JSCallbackInfo& args) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_scroller.h b/frameworks/bridge/declarative_frontend/jsview/js_scroller.h index 2eec8286aef..52b426bb9a1 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_scroller.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_scroller.h @@ -60,6 +60,8 @@ public: } private: + void ParseCustomCurveParams(RefPtr& curve, const JSRef& jsValue); + WeakPtr controllerWeak_; WeakPtr scrollBarProxyWeak_; diff --git a/frameworks/core/components/scroll/scroll_controller_base.h b/frameworks/core/components/scroll/scroll_controller_base.h index b004aba65c0..e58bc2c6465 100644 --- a/frameworks/core/components/scroll/scroll_controller_base.h +++ b/frameworks/core/components/scroll/scroll_controller_base.h @@ -64,7 +64,7 @@ public: return Axis::NONE; } - virtual bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) + virtual bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) { return true; } diff --git a/frameworks/core/components/scroll/scroll_position_controller.cpp b/frameworks/core/components/scroll/scroll_position_controller.cpp index 4dd8175fdf9..f6e63bfb2c4 100644 --- a/frameworks/core/components/scroll/scroll_position_controller.cpp +++ b/frameworks/core/components/scroll/scroll_position_controller.cpp @@ -84,7 +84,8 @@ bool ScrollPositionController::AnimateTo(double position, float duration, const return false; } -bool ScrollPositionController::AnimateTo(const Dimension& position, float duration, const RefPtr& curve) +bool ScrollPositionController::AnimateTo( + const Dimension& position, float duration, const RefPtr& curve, bool smooth) { RefPtr node = scroll_.Upgrade(); if (node) { diff --git a/frameworks/core/components/scroll/scroll_position_controller.h b/frameworks/core/components/scroll/scroll_position_controller.h index 6af484b91e1..9d1906fd140 100644 --- a/frameworks/core/components/scroll/scroll_position_controller.h +++ b/frameworks/core/components/scroll/scroll_position_controller.h @@ -111,7 +111,7 @@ public: void JumpTo(int32_t index, int32_t source) override; void JumpTo(double position); - bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) override; + bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) override; bool AnimateTo(double position, float duration, const RefPtr& curve, bool limitDuration = true, const std::function& onFinish = nullptr); bool AnimateToTarget(const ComposeId& targetId, float duration, const RefPtr& curve, diff --git a/frameworks/core/components_ng/pattern/grid/grid_position_controller.cpp b/frameworks/core/components_ng/pattern/grid/grid_position_controller.cpp index a48434e1a42..3731667daef 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_position_controller.cpp +++ b/frameworks/core/components_ng/pattern/grid/grid_position_controller.cpp @@ -30,7 +30,8 @@ void GridPositionController::JumpTo(int32_t index, int32_t /* source */) gridPattern->UpdateStartIndex(index); } -bool GridPositionController::AnimateTo(const Dimension& position, float duration, const RefPtr& curve) +bool GridPositionController::AnimateTo( + const Dimension& position, float duration, const RefPtr& curve, bool smooth) { auto pattern = scroll_.Upgrade(); CHECK_NULL_RETURN(pattern, false); diff --git a/frameworks/core/components_ng/pattern/grid/grid_position_controller.h b/frameworks/core/components_ng/pattern/grid/grid_position_controller.h index 2b472db93e3..d6f871cae87 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_position_controller.h +++ b/frameworks/core/components_ng/pattern/grid/grid_position_controller.h @@ -33,7 +33,7 @@ public: void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) override; void ScrollPage(bool reverse, bool smooth) override; void JumpTo(int32_t index, int32_t source) override; - bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) override; + bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) override; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/list/list_pattern.cpp b/frameworks/core/components_ng/pattern/list/list_pattern.cpp index c4438c61c51..8f1ab1f6f16 100644 --- a/frameworks/core/components_ng/pattern/list/list_pattern.cpp +++ b/frameworks/core/components_ng/pattern/list/list_pattern.cpp @@ -43,6 +43,10 @@ constexpr Color SELECT_STROKE_COLOR = Color(0x33FFFFFF); constexpr Color ITEM_FILL_COLOR = Color(0x1A0A59f7); constexpr float DEFAULT_MIN_SPACE_SCALE = 0.75f; constexpr float DEFAULT_MAX_SPACE_SCALE = 2.0f; +constexpr float LIST_SCROLL_TO_MASS = 1.0f; +constexpr float LIST_SCROLL_TO_STIFFNESS = 227.0f; +constexpr float LIST_SCROLL_TO_DAMPING = 33.0f; +constexpr float LIST_SCROLL_TO_VELOCITY = 7.0f; } // namespace void ListPattern::OnAttachToFrameNode() @@ -721,14 +725,55 @@ void ListPattern::StopAnimate() } } -void ListPattern::ScrollTo(float position) +void ListPattern::ScrollTo(float position, bool smooth) { LOGI("ScrollTo:%{public}f", position); StopAnimate(); - UpdateCurrentOffset(GetTotalOffset() - position, SCROLL_FROM_JUMP); + if (smooth) { + StartDefaultSpringMotion(currentOffset_, position, LIST_SCROLL_TO_VELOCITY); + } else { + UpdateCurrentOffset(GetTotalOffset() - position, SCROLL_FROM_JUMP); + } isScrollEnd_ = true; } +void ListPattern::StartDefaultSpringMotion(float start, float end, float velocity) +{ + if (!animator_) { + animator_ = AceType::MakeRefPtr(PipelineBase::GetCurrentContext()); + } + + float mass = LIST_SCROLL_TO_MASS; + float stiffness = LIST_SCROLL_TO_STIFFNESS; + float damping = LIST_SCROLL_TO_DAMPING; + const RefPtr DEFAULT_OVER_SPRING_PROPERTY = + AceType::MakeRefPtr(mass, stiffness, damping); + if (!springMotion_) { + springMotion_ = AceType::MakeRefPtr(start, end, velocity, DEFAULT_OVER_SPRING_PROPERTY); + } else { + springMotion_->Reset(start, end, velocity, DEFAULT_OVER_SPRING_PROPERTY); + springMotion_->ClearListeners(); + } + springMotion_->AddListener([weakScroll = AceType::WeakClaim(this), start, end](double position) { + auto list = weakScroll.Upgrade(); + CHECK_NULL_VOID(list); + if (NearEqual(end, start) || NearEqual(position, end)) { + list->animator_->ClearStopListeners(); + list->animator_->Stop(); + position = end; + return; + } + list->UpdateCurrentOffset(list->GetTotalOffset() - position, SCROLL_FROM_JUMP); + }); + animator_->ClearStopListeners(); + animator_->PlayMotion(springMotion_); + animator_->AddStopListener([weak = AceType::WeakClaim(this)]() { + auto list = weak.Upgrade(); + CHECK_NULL_VOID(list); + list->MarkDirtyNodeSelf(); + }); +} + void ListPattern::ScrollToIndex(int32_t index, ScrollIndexAlignment align) { LOGI("ScrollToIndex:%{public}d", index); diff --git a/frameworks/core/components_ng/pattern/list/list_pattern.h b/frameworks/core/components_ng/pattern/list/list_pattern.h index 711eef8f9f7..a718aa9399d 100644 --- a/frameworks/core/components_ng/pattern/list/list_pattern.h +++ b/frameworks/core/components_ng/pattern/list/list_pattern.h @@ -166,7 +166,7 @@ public: // scroller void AnimateTo(float position, float duration, const RefPtr& curve); - void ScrollTo(float position); + void ScrollTo(float position, bool smooth); void ScrollToIndex(int32_t index, ScrollIndexAlignment align = ScrollIndexAlignment::ALIGN_TOP); void ScrollToIndex(int32_t index, int32_t indexInGroup, ScrollIndexAlignment align); void ScrollToEdge(ScrollEdgeType scrollEdgeType); @@ -217,6 +217,7 @@ private: void FireOnScrollStart(); void CheckRestartSpring(); void StopAnimate(); + void StartDefaultSpringMotion(float start, float end, float velocity); // multiSelectable void InitMouseEvent(); @@ -277,6 +278,8 @@ private: WeakPtr swiperItem_; bool isScrollEnd_ = false; + + RefPtr springMotion_; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/list/list_position_controller.cpp b/frameworks/core/components_ng/pattern/list/list_position_controller.cpp index b0bc1a80d1b..2ba3652113e 100644 --- a/frameworks/core/components_ng/pattern/list/list_position_controller.cpp +++ b/frameworks/core/components_ng/pattern/list/list_position_controller.cpp @@ -34,7 +34,8 @@ void ListPositionController::JumpTo(int32_t index, int32_t source) listPattern->ScrollToIndex(index); } -bool ListPositionController::AnimateTo(const Dimension& position, float duration, const RefPtr& curve) +bool ListPositionController::AnimateTo( + const Dimension& position, float duration, const RefPtr& curve, bool smooth) { auto pattern = scroll_.Upgrade(); CHECK_NULL_RETURN(pattern, false); @@ -47,7 +48,7 @@ bool ListPositionController::AnimateTo(const Dimension& position, float duration if (Positive(duration)) { listPattern->AnimateTo(position.ConvertToPx(), duration, curve); } else { - listPattern->ScrollTo(position.ConvertToPx()); + listPattern->ScrollTo(position.ConvertToPx(), smooth); } return true; } diff --git a/frameworks/core/components_ng/pattern/list/list_position_controller.h b/frameworks/core/components_ng/pattern/list/list_position_controller.h index 1409a5153fd..e36194e01b9 100644 --- a/frameworks/core/components_ng/pattern/list/list_position_controller.h +++ b/frameworks/core/components_ng/pattern/list/list_position_controller.h @@ -35,7 +35,7 @@ public: void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) override; void ScrollPage(bool reverse, bool smooth) override; void JumpTo(int32_t index, int32_t source) override; - bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) override; + bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) override; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.cpp b/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.cpp index 48eba65f8dd..0af4c36bc4a 100644 --- a/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.cpp +++ b/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.cpp @@ -33,7 +33,8 @@ void ScrollPositionController::JumpTo(int32_t index, int32_t source) LOGW("jumpTo is not supported now"); } -bool ScrollPositionController::AnimateTo(const Dimension& position, float duration, const RefPtr& curve) +bool ScrollPositionController::AnimateTo( + const Dimension& position, float duration, const RefPtr& curve, bool smooth) { auto pattern = scroll_.Upgrade(); CHECK_NULL_RETURN(pattern, false); diff --git a/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.h b/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.h index ec63e1ea6bd..c11ac73e9da 100644 --- a/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.h +++ b/frameworks/core/components_ng/pattern/scroll/scroll_position_controller.h @@ -35,7 +35,7 @@ public: void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) override; void ScrollPage(bool reverse, bool smooth) override; void JumpTo(int32_t index, int32_t source) override; - bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) override; + bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) override; double GetCurrentPosition() const; }; diff --git a/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp b/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp index c2be873d152..7734dbb59bb 100644 --- a/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp @@ -424,7 +424,7 @@ HWTEST_F(GridTestNg, KeyEvent001, TestSize.Level1) KeyEvent event; pattern_->OnKeyEvent(event); EXPECT_EQ(pattern_->GetGridLayoutInfo().currentOffset_, 0); - + /** * @tc.steps: step1. KeyCode::KEY_PAGE_DOWN. * @tc.expected: Page jump down width Grid height. @@ -433,7 +433,7 @@ HWTEST_F(GridTestNg, KeyEvent001, TestSize.Level1) event.code = KeyCode::KEY_PAGE_DOWN; pattern_->OnKeyEvent(event); EXPECT_EQ(pattern_->GetGridLayoutInfo().currentOffset_, -300.f); - + /** * @tc.steps: step1. KeyCode::KEY_PAGE_UP. * @tc.expected: Page jump up width Grid height. @@ -861,7 +861,7 @@ HWTEST_F(GridTestNg, PositionController001, TestSize.Level1) * @tc.steps: step2. Test AnimateTo func. * @tc.expected: Verify return value. */ - controller->AnimateTo(Dimension(100.f, DimensionUnit::PX), 200.f, Curves::LINEAR); + controller->AnimateTo(Dimension(100.f, DimensionUnit::PX), 200.f, Curves::LINEAR, false); ASSERT_NE(pattern_->animator_, nullptr); /** diff --git a/frameworks/core/components_ng/test/pattern/list/BUILD.gn b/frameworks/core/components_ng/test/pattern/list/BUILD.gn index 782d907b53d..ff827556ea4 100644 --- a/frameworks/core/components_ng/test/pattern/list/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/list/BUILD.gn @@ -23,10 +23,14 @@ common_sources = [ "$ace_root/frameworks/base/utils/string_expression.cpp", "$ace_root/frameworks/base/utils/string_utils.cpp", "$ace_root/frameworks/base/utils/time_util.cpp", + "$ace_root/frameworks/bridge/common/dom/dom_type.cpp", + "$ace_root/frameworks/bridge/common/utils/utils.cpp", + "$ace_root/frameworks/bridge/js_frontend/engine/common/js_constants.cpp", "$ace_root/frameworks/core/animation/anticipate_curve.cpp", "$ace_root/frameworks/core/animation/chain_animation.cpp", "$ace_root/frameworks/core/animation/cubic_curve.cpp", "$ace_root/frameworks/core/animation/curves.cpp", + "$ace_root/frameworks/core/animation/spring_curve.cpp", "$ace_root/frameworks/core/animation/spring_model.cpp", "$ace_root/frameworks/core/animation/spring_motion.cpp", "$ace_root/frameworks/core/components/common/layout/grid_column_info.cpp", diff --git a/frameworks/core/components_ng/test/pattern/list/list_test_ng.cpp b/frameworks/core/components_ng/test/pattern/list/list_test_ng.cpp index 127e2da0702..fe63043e367 100644 --- a/frameworks/core/components_ng/test/pattern/list/list_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/list/list_test_ng.cpp @@ -51,6 +51,7 @@ #include "core/components_ng/test/mock/theme/mock_theme_manager.h" #include "core/components_v2/list/list_properties.h" #include "core/pipeline_ng/test/mock/mock_pipeline_base.h" +#include "frameworks/bridge/common/utils/utils.h" using namespace testing; using namespace testing::ext; @@ -2931,9 +2932,9 @@ HWTEST_F(ListTestNg, PositionController001, TestSize.Level1) controller->JumpTo(1, 0); EXPECT_EQ(pattern_->jumpIndex_, 1); - EXPECT_FALSE(controller->AnimateTo(Dimension(1, DimensionUnit::PERCENT), 0, nullptr)); - EXPECT_TRUE(controller->AnimateTo(Dimension(1), 0, nullptr)); - EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1, nullptr)); + EXPECT_FALSE(controller->AnimateTo(Dimension(1, DimensionUnit::PERCENT), 0, nullptr, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 0, nullptr, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1, nullptr, false)); } /** @@ -2984,9 +2985,9 @@ HWTEST_F(ListTestNg, PositionController002, TestSize.Level1) controller->JumpTo(1, 0); EXPECT_EQ(pattern_->jumpIndex_, 1); - EXPECT_FALSE(controller->AnimateTo(Dimension(1, DimensionUnit::PERCENT), 0, nullptr)); - EXPECT_TRUE(controller->AnimateTo(Dimension(1), 0, nullptr)); - EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1, nullptr)); + EXPECT_FALSE(controller->AnimateTo(Dimension(1, DimensionUnit::PERCENT), 0, nullptr, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 0, nullptr, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1, nullptr, false)); } /** @@ -3028,7 +3029,7 @@ HWTEST_F(ListTestNg, PositionController003, TestSize.Level1) controller->JumpTo(1, 0); EXPECT_EQ(pattern_->jumpIndex_, 1); - EXPECT_FALSE(controller->AnimateTo(Dimension(1, DimensionUnit::PERCENT), 0, nullptr)); + EXPECT_FALSE(controller->AnimateTo(Dimension(1, DimensionUnit::PERCENT), 0, nullptr, false)); } /** @@ -3950,4 +3951,111 @@ HWTEST_F(ListTestNg, PerformActionTest002, TestSize.Level1) EXPECT_TRUE(listAccessibilityProperty->ActActionScrollForward()); EXPECT_TRUE(listAccessibilityProperty->ActActionScrollBackward()); } + +/** + * @tc.name: ListPositionControllerTest001 + * @tc.desc: Test PositionController function with smooth. + * @tc.type: FUNC + */ +HWTEST_F(ListTestNg, ListPositionControllerTest001, TestSize.Level1) +{ + ListModelNG listModelNG; + listModelNG.Create(); + RefPtr scroller = listModelNG.CreateScrollController(); + listModelNG.SetScroller(scroller, nullptr); + CreateListItem(10); + GetInstance(); + RunMeasureAndLayout(); + + /** + * @tc.steps: step1. Get positionController and set scroll_. + */ + auto controller = pattern_->positionController_; + controller->scroll_ = AceType::WeakClaim(AceType::RawPtr(pattern_)); + + /** + * @tc.steps: step2. Call func when smooth is false or true. + * @tc.expected: Return true. + */ + EXPECT_EQ(controller->GetScrollDirection(), Axis::VERTICAL); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 0, nullptr, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 0, nullptr, true)); + + /** + * @tc.steps: step3. Call func when duration is positive. + * @tc.expected: Return true. + */ + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1.0, nullptr, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1.0, nullptr, true)); +} + +/** + * @tc.name: ListPositionControllerTest002 + * @tc.desc: Test PositionController function with ICurve. + * @tc.type: FUNC + */ +HWTEST_F(ListTestNg, ListPositionControllerTest002, TestSize.Level1) +{ + ListModelNG listModelNG; + listModelNG.Create(); + RefPtr scroller = listModelNG.CreateScrollController(); + listModelNG.SetScroller(scroller, nullptr); + CreateListItem(10); + GetInstance(); + RunMeasureAndLayout(); + + /** + * @tc.steps: step1. Get positionController and set scroll_. + */ + auto controller = pattern_->positionController_; + controller->scroll_ = AceType::WeakClaim(AceType::RawPtr(pattern_)); + + /** + * @tc.steps: step2. Create ICurve. + */ + RefPtr curve; + std::string icurveString = "spring(7.000000,1.000000,227.000000,33.000000)"; + curve = Framework::CreateCurve(icurveString); + + /** + * @tc.steps: step3. Call func when the duration and curve are valid. + * @tc.expected: Return true. + */ + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1.0, curve, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1.0, curve, true)); +} + +/** + * @tc.name: ListPositionControllerTest003 + * @tc.desc: Test PositionController function with build-in curve. + * @tc.type: FUNC + */ +HWTEST_F(ListTestNg, ListPositionControllerTest003, TestSize.Level1) +{ + ListModelNG listModelNG; + listModelNG.Create(); + RefPtr scroller = listModelNG.CreateScrollController(); + listModelNG.SetScroller(scroller, nullptr); + CreateListItem(10); + GetInstance(); + RunMeasureAndLayout(); + + /** + * @tc.steps: step1. Get positionController and set scroll_. + */ + auto controller = pattern_->positionController_; + controller->scroll_ = AceType::WeakClaim(AceType::RawPtr(pattern_)); + + /** + * @tc.steps: step2. Create build-in curve. + */ + RefPtr curve = Curves::EASE_IN; + + /** + * @tc.steps: step3. Call func when the duration and curve are valid. + * @tc.expected: Return true. + */ + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1.0, curve, false)); + EXPECT_TRUE(controller->AnimateTo(Dimension(1), 1.0, curve, true)); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/scroll/scroll_test_ng.cpp b/frameworks/core/components_ng/test/pattern/scroll/scroll_test_ng.cpp index 508e893c462..fcbe2b75fef 100644 --- a/frameworks/core/components_ng/test/pattern/scroll/scroll_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/scroll/scroll_test_ng.cpp @@ -765,7 +765,7 @@ HWTEST_F(ScrollTestNg, ScrollTest007, TestSize.Level1) auto offset = positionController->GetCurrentOffset(); EXPECT_EQ(offset, Offset::Zero()); Dimension dimension(0, DimensionUnit::VP); - auto animate = positionController->AnimateTo(dimension, 0.0f, Curves::LINEAR); + auto animate = positionController->AnimateTo(dimension, 0.0f, Curves::LINEAR, false); EXPECT_EQ(animate, false); } @@ -1042,7 +1042,7 @@ HWTEST_F(ScrollTestNg, ScrollTest0010, TestSize.Level1) auto offset = positionController->GetCurrentOffset(); EXPECT_EQ(offset, Offset(0, -SCROLL_FLOAT_98)); Dimension dimension(0, DimensionUnit::VP); - auto animate = positionController->AnimateTo(dimension, 0.0f, Curves::LINEAR); + auto animate = positionController->AnimateTo(dimension, 0.0f, Curves::LINEAR, false); EXPECT_EQ(animate, true); } diff --git a/frameworks/core/components_v2/grid/grid_position_controller.cpp b/frameworks/core/components_v2/grid/grid_position_controller.cpp index 039e7be8d04..1fb546a3314 100644 --- a/frameworks/core/components_v2/grid/grid_position_controller.cpp +++ b/frameworks/core/components_v2/grid/grid_position_controller.cpp @@ -28,7 +28,8 @@ void GridPositionController::JumpTo(int32_t index, int32_t source) grid->ScrollToIndex(index, source); } -bool GridPositionController::AnimateTo(const Dimension& position, float duration, const RefPtr& curve) +bool GridPositionController::AnimateTo( + const Dimension& position, float duration, const RefPtr& curve, bool smooth) { auto grid = AceType::DynamicCast(scroll_.Upgrade()); if (!grid) { diff --git a/frameworks/core/components_v2/grid/grid_position_controller.h b/frameworks/core/components_v2/grid/grid_position_controller.h index 18600942b37..9959b19c994 100644 --- a/frameworks/core/components_v2/grid/grid_position_controller.h +++ b/frameworks/core/components_v2/grid/grid_position_controller.h @@ -29,7 +29,7 @@ public: Axis GetScrollDirection() const override; void JumpTo(int32_t index, int32_t source = 3) override; - bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) override; + bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) override; void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) override; void ScrollPage(bool reverse, bool smooth) override; Offset GetCurrentOffset() const override; diff --git a/frameworks/core/components_v2/list/list_position_controller.cpp b/frameworks/core/components_v2/list/list_position_controller.cpp index 83aa7cfd7f4..2663f5c53f7 100644 --- a/frameworks/core/components_v2/list/list_position_controller.cpp +++ b/frameworks/core/components_v2/list/list_position_controller.cpp @@ -28,7 +28,8 @@ void ListPositionController::JumpTo(int32_t index, int32_t source) list->JumpToIndex(index, source); } -bool ListPositionController::AnimateTo(const Dimension& position, float duration, const RefPtr& curve) +bool ListPositionController::AnimateTo( + const Dimension& position, float duration, const RefPtr& curve, bool smooth) { auto list = AceType::DynamicCast(scroll_.Upgrade()); if (!list) { diff --git a/frameworks/core/components_v2/list/list_position_controller.h b/frameworks/core/components_v2/list/list_position_controller.h index 10759ada089..8e0146ac03a 100644 --- a/frameworks/core/components_v2/list/list_position_controller.h +++ b/frameworks/core/components_v2/list/list_position_controller.h @@ -28,7 +28,7 @@ public: ~ListPositionController() override = default; void JumpTo(int32_t index, int32_t source = 3) override; - bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve) override; + bool AnimateTo(const Dimension& position, float duration, const RefPtr& curve, bool smooth) override; Axis GetScrollDirection() const override; Offset GetCurrentOffset() const override; void ScrollToEdge(ScrollEdgeType scrollEdgeType, bool smooth) override; From df365d1596cff2e0ba4546bc9717d6b643baba17 Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Wed, 24 May 2023 09:48:02 +0800 Subject: [PATCH 46/99] tabs Signed-off-by: sunjiakun --- .../pattern/tabs/tab_bar_pattern.cpp | 21 ++++++++++++++++--- .../pattern/tabs/tab_bar_pattern.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp index c5740476311..5076a96173e 100644 --- a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp +++ b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp @@ -527,19 +527,34 @@ void TabBarPattern::HandleClick(const GestureEvent& info) void TabBarPattern::HandleBottomTabBarChange(int32_t index) { if (indicator_ != index && (tabBarStyles_[indicator_] == TabBarStyle::BOTTOMTABBATSTYLE || - tabBarStyles_[index] == TabBarStyle::BOTTOMTABBATSTYLE)) { + tabBarStyles_[index] == TabBarStyle::BOTTOMTABBATSTYLE)) { int32_t selectedIndex = -1; int32_t unselectedIndex = -1; - if (tabBarStyles_[indicator_] == TabBarStyle::BOTTOMTABBATSTYLE) { + if (tabBarStyles_[indicator_] == TabBarStyle::BOTTOMTABBATSTYLE && CheckSvg(indicator_)) { unselectedIndex = indicator_; } - if (tabBarStyles_[index] == TabBarStyle::BOTTOMTABBATSTYLE) { + if (tabBarStyles_[index] == TabBarStyle::BOTTOMTABBATSTYLE && CheckSvg(index)) { selectedIndex = index; } HandleBottomTabBarClick(selectedIndex, unselectedIndex); } } +bool TabBarPattern::CheckSvg(int32_t index) +{ + auto host = GetHost(); + CHECK_NULL_RETURN(host, false); + auto columnNode = AceType::DynamicCast(host->GetChildAtIndex(index)); + CHECK_NULL_RETURN(columnNode, false); + auto imageNode = AceType::DynamicCast(columnNode->GetChildren().front()); + CHECK_NULL_RETURN(imageNode, false); + auto imageLayoutProperty = imageNode->GetLayoutProperty(); + CHECK_NULL_RETURN(imageLayoutProperty, false); + ImageSourceInfo info; + auto imageSourceInfo = imageLayoutProperty->GetImageSourceInfo().value_or(info); + return imageSourceInfo.IsSvg(); +} + void TabBarPattern::HandleBottomTabBarClick(int32_t selectedIndex, int32_t unselectedIndex) { auto host = GetHost(); diff --git a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h index 10d118aa7f8..af461213d14 100644 --- a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h +++ b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h @@ -299,6 +299,7 @@ private: void GetBottomTabBarImageSizeAndOffset(const std::vector& selectedIndexes, int32_t maskIndex, float& selectedImageSize, float& unselectedImageSize, OffsetF& originalSelectedMaskOffset, OffsetF& originalUnselectedMaskOffset); + bool CheckSvg(int32_t index); void HandleTouchDown(int32_t index); void HandleTouchUp(int32_t index); From 541120fbc3a908a4d20a211a22cfe7c89bec8277 Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Wed, 24 May 2023 09:48:17 +0800 Subject: [PATCH 47/99] tabs Signed-off-by: sunjiakun --- frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp | 2 +- frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp index 5076a96173e..66dfd8d09c1 100644 --- a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp +++ b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.cpp @@ -540,7 +540,7 @@ void TabBarPattern::HandleBottomTabBarChange(int32_t index) } } -bool TabBarPattern::CheckSvg(int32_t index) +bool TabBarPattern::CheckSvg(int32_t index) const { auto host = GetHost(); CHECK_NULL_RETURN(host, false); diff --git a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h index af461213d14..297c83e1e81 100644 --- a/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h +++ b/frameworks/core/components_ng/pattern/tabs/tab_bar_pattern.h @@ -299,7 +299,7 @@ private: void GetBottomTabBarImageSizeAndOffset(const std::vector& selectedIndexes, int32_t maskIndex, float& selectedImageSize, float& unselectedImageSize, OffsetF& originalSelectedMaskOffset, OffsetF& originalUnselectedMaskOffset); - bool CheckSvg(int32_t index); + bool CheckSvg(int32_t index) const; void HandleTouchDown(int32_t index); void HandleTouchUp(int32_t index); From 40ead885c756f99ea6ca9501c3209cd7a1f575d8 Mon Sep 17 00:00:00 2001 From: wanglichao Date: Wed, 17 May 2023 11:08:46 +0800 Subject: [PATCH 48/99] fix grid_row failed testsuite and change .gn Signed-off-by: wanglichao Change-Id: Ia113c18d07c1164c558ba2d33fa4441cbd6379b5 --- .../core/components_ng/test/pattern/BUILD.gn | 4 +- .../test/pattern/grid_container/BUILD.gn | 52 ++++--- ...test_ng.cpp => grid_container_test_ng.cpp} | 10 +- .../test/pattern/grid_row/BUILD.gn | 135 +++++++++++++++--- .../grid_row_layout_algorithm_test_ng.cpp | 71 ++++----- 5 files changed, 188 insertions(+), 84 deletions(-) rename frameworks/core/components_ng/test/pattern/grid_container/{grid_container_pattern_test_ng.cpp => grid_container_test_ng.cpp} (93%) diff --git a/frameworks/core/components_ng/test/pattern/BUILD.gn b/frameworks/core/components_ng/test/pattern/BUILD.gn index 7f657d3d62e..264d7ddd553 100644 --- a/frameworks/core/components_ng/test/pattern/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/BUILD.gn @@ -39,8 +39,8 @@ group("pattern_unittest") { "gauge:gauge_pattern_test_ng", "grid:grid_test_ng", "grid_col:grid_col_pattern_test_ng", - "grid_container:grid_container_pattern_test_ng", - "grid_row:grid_row_pattern_test_ng", + "grid_container:grid_container_test_ng", + "grid_row:grid_row_test_ng", "hyperlink:hyperlink_test_ng", "image:image_test_ng", "image_animator:image_animator_pattern_test", diff --git a/frameworks/core/components_ng/test/pattern/grid_container/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid_container/BUILD.gn index e601b03a090..f68127d1804 100644 --- a/frameworks/core/components_ng/test/pattern/grid_container/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid_container/BUILD.gn @@ -12,32 +12,38 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import( - "//foundation/arkui/ace_engine/frameworks/core/components_ng/components.gni") import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") -ohos_unittest("grid_container_pattern_test_ng") { - module_out_path = pattern_test_output_path +ace_unittest("grid_container_test_ng") { + ace_animation = true - sources = [ "grid_container_pattern_test_ng.cpp" ] + sources = [ + "$ace_root/frameworks/core/components_ng/base/view_abstract.cpp", + "$ace_root/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.cpp", + "$ace_root/frameworks/core/components_ng/manager/select_overlay/select_overlay_proxy.cpp", + "$ace_root/frameworks/core/components_ng/pattern/flex/flex_layout_algorithm.cpp", + "$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_layout_algorithm.cpp", + "$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_modifier.cpp", + "$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_paint_method.cpp", + "$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_pattern.cpp", + "$ace_root/frameworks/core/components_ng/pattern/select_overlay/select_overlay_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/span_node.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_content_modifier.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_layout_algorithm.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_model_ng.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_overlay_modifier.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", + "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/manager/drag_drop/mock_drag_drop_manager.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/manager/drag_drop/mock_drag_drop_proxy.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/pattern/select_overlay/mock_select_overlay_node.cpp", - deps = [ - "$ace_root/build:ace_ohos_unittest_base", - "$ace_root/frameworks/core/components_ng/base:ace_core_components_base_ng_ohos", - ] - - configs = [ - ":config_grid_container_test", - "$ace_root:ace_config", - ] -} - -config("config_grid_container_test") { - visibility = [ ":*" ] - include_dirs = [ - "//commonlibrary/c_utils/base/include", - "$ace_root", - "$ace_root/frameworks", + # self + "$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_model_ng.cpp", + "grid_container_test_ng.cpp", ] } diff --git a/frameworks/core/components_ng/test/pattern/grid_container/grid_container_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/grid_container/grid_container_test_ng.cpp similarity index 93% rename from frameworks/core/components_ng/test/pattern/grid_container/grid_container_pattern_test_ng.cpp rename to frameworks/core/components_ng/test/pattern/grid_container/grid_container_test_ng.cpp index 0f0b6088404..60ae804808d 100644 --- a/frameworks/core/components_ng/test/pattern/grid_container/grid_container_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/grid_container/grid_container_test_ng.cpp @@ -32,9 +32,7 @@ using namespace testing; using namespace testing::ext; namespace OHOS::Ace::NG { - namespace { - constexpr float DEFAULT_WIDTH = 800.0f; constexpr int32_t DEFAULT_COLUMN_NUM = 8; constexpr float DEFAULT_COLUMN_WIDTH = 100.0f; @@ -54,10 +52,9 @@ void MeasureLayout(RefPtr& container, RefPtr& text container->SwapDirtyLayoutWrapperOnMainThread(); } - } // namespace -class GridContainerPatternTestNg : public testing::Test { +class GridContainerTestNg : public testing::Test { public: RefPtr CreateGridContainerWithChild() { @@ -98,7 +95,7 @@ private: * @tc.desc: Test default properties of grid-container. * @tc.type: FUNC */ -HWTEST_F(GridContainerPatternTestNg, DefaultProperty001, TestSize.Level1) +HWTEST_F(GridContainerTestNg, DefaultProperty001, TestSize.Level1) { GridContainerInfo::Builder builder; GridContainerModelNG modelNG; @@ -122,7 +119,7 @@ HWTEST_F(GridContainerPatternTestNg, DefaultProperty001, TestSize.Level1) * @tc.desc: Test GridContainer build width. * @tc.type: FUNC */ -HWTEST_F(GridContainerPatternTestNg, BuildContainer001, TestSize.Level1) +HWTEST_F(GridContainerTestNg, BuildContainer001, TestSize.Level1) { auto layoutWrapper = CreateGridContainerWithChild(); auto textWrapper = layoutWrapper->GetOrCreateChildByIndex(0); @@ -144,5 +141,4 @@ HWTEST_F(GridContainerPatternTestNg, BuildContainer001, TestSize.Level1) EXPECT_EQ(rect.Width(), DEFAULT_COLUMN_WIDTH); EXPECT_EQ(rect.GetX(), DEFAULT_COLUMN_WIDTH); } - } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn index 427cd327f54..9090277fe0b 100644 --- a/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn @@ -12,35 +12,132 @@ # limitations under the License. import("//build/test.gni") -import("//foundation/arkui/ace_engine/ace_config.gni") -import( - "//foundation/arkui/ace_engine/frameworks/core/components_ng/components.gni") import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") -ohos_unittest("grid_row_pattern_test_ng") { +ohos_unittest("grid_row_test_ng") { module_out_path = pattern_test_output_path sources = [ + # special + "$ace_root/frameworks/base/geometry/animatable_dimension.cpp", + "$ace_root/frameworks/base/geometry/least_square_impl.cpp", + "$ace_root/frameworks/base/geometry/matrix3.cpp", + "$ace_root/frameworks/base/geometry/matrix4.cpp", + "$ace_root/frameworks/base/test/mock/mock_drag_window.cpp", + "$ace_root/frameworks/core/animation/anticipate_curve.cpp", + "$ace_root/frameworks/core/animation/cubic_curve.cpp", + "$ace_root/frameworks/core/animation/curves.cpp", + "$ace_root/frameworks/core/animation/friction_motion.cpp", + "$ace_root/frameworks/core/animation/spring_curve.cpp", + "$ace_root/frameworks/core/animation/spring_model.cpp", + "$ace_root/frameworks/core/animation/test/mock/mock_animator.cpp", + "$ace_root/frameworks/core/animation/test/mock/mock_scheduler.cpp", + "$ace_root/frameworks/core/common/test/mock/mock_clipboard.cpp", + "$ace_root/frameworks/core/common/test/mock/mock_layout_inspector.cpp", + "$ace_root/frameworks/core/components_ng/event/scrollable_event.cpp", + + # self + "$ace_root/frameworks/core/components_ng/pattern/flex/flex_layout_algorithm.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_algorithm.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_col/grid_col_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_container/grid_container_model_ng.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_row/grid_row_layout_algorithm.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_row/grid_row_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng.cpp", + "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/base/mock_view_abstract.cpp", + "$ace_root/frameworks/core/components_v2/grid_layout/grid_container_utils.cpp", + "$ace_root/frameworks/core/gestures/velocity_tracker.cpp", + "$ace_root/frameworks/core/pipeline/base/related_node.cpp", "grid_row_layout_algorithm_test_ng.cpp", "grid_row_layout_property_test_ng.cpp", ] + sources += [ + # base + "$ace_root/frameworks/base/geometry/dimension.cpp", + "$ace_root/frameworks/base/json/json_util.cpp", + "$ace_root/frameworks/base/utils/base_id.cpp", + "$ace_root/frameworks/base/utils/string_expression.cpp", + "$ace_root/frameworks/base/utils/string_utils.cpp", + "$ace_root/frameworks/base/utils/time_util.cpp", + + # components + "$ace_root/frameworks/core/components/common/layout/grid_column_info.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/color.cpp", + + # components_ng + "$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/click_event.cpp", + "$ace_root/frameworks/core/components_ng/event/drag_event.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/pan_event.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/click_recognizer.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/long_press_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/gestures/recognizers/pan_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/gestures/recognizers/sequenced_recognizer.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/property/calc_length.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/drawing_prop_convertor.cpp", + "$ace_root/frameworks/core/components_ng/render/paint_wrapper.cpp", + + # components_v2 + "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", + + # pipeline + "$ace_root/frameworks/core/pipeline/base/constants.cpp", + + # mock + "$ace_root/frameworks/base/test/mock/mock_ressched_report.cpp", + "$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/test/unittest/mock/ace_trace_mock.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/animation/mock_geometry_transition.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/base/mock_localization.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/render/mock_animation_utils.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/render/mock_modifier_adapter.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_context.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_context_creator.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/render/mock_render_surface_creator.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/syntax/mock_for_each_node.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", + ] + deps = [ - "$ace_root/build:ace_ohos_unittest_base", - "$ace_root/frameworks/core/components_ng/base:ace_core_components_base_ng_ohos", + "$ace_root/frameworks/base:ace_memory_monitor_ohos", + "$ace_root/frameworks/core/components/theme:build_theme_code", + "$ace_root/test/unittest:ace_unittest_log", + "$cjson_root:cjson_static", + "//third_party/googletest:gmock_main", ] - configs = [ - ":config_grid_row_test", - "$ace_root:ace_config", - ] -} - -config("config_grid_row_test") { - visibility = [ ":*" ] - include_dirs = [ - "//commonlibrary/c_utils/base/include", - "$ace_root", - "$ace_root/frameworks", - ] + configs = [ "$ace_root/test/unittest:ace_unittest_config" ] } diff --git a/frameworks/core/components_ng/test/pattern/grid_row/grid_row_layout_algorithm_test_ng.cpp b/frameworks/core/components_ng/test/pattern/grid_row/grid_row_layout_algorithm_test_ng.cpp index 2c60496a33a..cfbb5a1c674 100644 --- a/frameworks/core/components_ng/test/pattern/grid_row/grid_row_layout_algorithm_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/grid_row/grid_row_layout_algorithm_test_ng.cpp @@ -28,6 +28,7 @@ #include "core/components_ng/pattern/grid_col/grid_col_model_ng.h" #include "core/components_ng/pattern/grid_row/grid_row_layout_pattern.h" #include "core/components_ng/pattern/grid_row/grid_row_model_ng.h" +#include "core/pipeline_ng/test/mock/mock_pipeline_base.h" using namespace testing; using namespace testing::ext; @@ -51,7 +52,9 @@ public: static RefPtr CreateLayoutWrapperAndLayout(bool needLayout); static void TestGridColWidth(uint8_t span, uint8_t expectWidth); - static void TestGridColGeometry(uint8_t span, uint8_t offset, uint8_t expectLines, uint8_t expectOffset); + static testing::AssertionResult TestGridColGeometry( + uint8_t offset, uint8_t span, uint8_t expectOffsetX, uint8_t expectLines); + static OffsetF GetColOffset(RefPtr& layoutWrapper, int32_t index); static RefPtr rowNode_; static std::vector> colNodes_; @@ -72,12 +75,14 @@ void GridRowColPatternTestNg::SetUpTestSuite() } rowNode_ = AceType::DynamicCast(ViewStackProcessor::GetInstance()->GetMainElementNode()); ViewStackProcessor::GetInstance()->PopContainer(); + MockPipelineBase::SetUp(); } void GridRowColPatternTestNg::TearDownTestSuite() { rowNode_->Clean(); colNodes_.clear(); + MockPipelineBase::TearDown(); } void GridRowColPatternTestNg::SetUp() @@ -145,28 +150,28 @@ void GridRowColPatternTestNg::TestGridColWidth(uint8_t span, uint8_t expectWidth } /* Examine the last grid-col position according to span/offset */ -void GridRowColPatternTestNg::TestGridColGeometry( - uint8_t span, uint8_t offset, uint8_t expectLines, uint8_t expectOffset) +testing::AssertionResult GridRowColPatternTestNg::TestGridColGeometry( + uint8_t offset, uint8_t span, uint8_t expectOffsetX, uint8_t expectLines) { - // first grid-col occupies the first line to constrain the line-height of that line - auto colNode = colNodes_.back(); - auto layoutProperty = colNode->GetLayoutProperty(); - layoutProperty->UpdateSpan(V2::GridContainerSize(span)); - layoutProperty->UpdateOffset(V2::GridContainerSize(offset)); + auto firstColNode = colNodes_.front(); + auto firstColLayoutProperty = firstColNode->GetLayoutProperty(); + firstColLayoutProperty->UpdateSpan(V2::GridContainerSize(span)); + firstColLayoutProperty->UpdateOffset(V2::GridContainerSize(offset)); auto layoutWrapper = CreateLayoutWrapperAndLayout(true); + auto secondColOffset = GetColOffset(layoutWrapper, 1); + const OffsetF expectOffset = OffsetF(DEFAULT_SPAN_WIDTH * expectOffsetX, DEFAULT_HEIGHT * expectLines); + if (secondColOffset == expectOffset) { + return testing::AssertionSuccess(); + } + return testing::AssertionFailure() << + "secondColOffset: " << secondColOffset.ToString() << + " But expect offset: " << expectOffset.ToString(); +} - // Check geometry Size - auto firstGridColFrameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect(); - auto frameRect = layoutWrapper->GetOrCreateChildByIndex(1)->GetGeometryNode()->GetFrameRect(); - float columnWidth = firstGridColFrameRect.Width(); - float lineHeight = firstGridColFrameRect.Height(); - - EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH); - EXPECT_EQ(frameRect.GetX(), - firstGridColFrameRect.GetX() + columnWidth * (expectOffset - DEFAULT_OFFSET)); // examine offset - EXPECT_EQ(frameRect.GetY() - firstGridColFrameRect.GetY(), - lineHeight * expectLines); // examine lines +OffsetF GridRowColPatternTestNg::GetColOffset(RefPtr& layoutWrapper, int32_t index) +{ + return layoutWrapper->GetOrCreateChildByIndex(index)->GetGeometryNode()->GetFrameOffset(); } /** @@ -188,18 +193,18 @@ HWTEST_F(GridRowColPatternTestNg, Algorithm001, TestSize.Level1) */ HWTEST_F(GridRowColPatternTestNg, Algorithm002, TestSize.Level1) { - // span + offset <= columns - constexpr uint8_t span = 6; - TestGridColGeometry(span, DEFAULT_COLUMNS - span, 1, DEFAULT_COLUMNS - span); + // Set the first col: span + offset == columns + // Test second col position + EXPECT_TRUE(TestGridColGeometry(2, 6, 0, 1)); - // offset <= columns, span + offset > columns - TestGridColGeometry(DEFAULT_COLUMNS - 1, 2, 2, 0); + // span + offset > columns, offset <= columns + EXPECT_TRUE(TestGridColGeometry(2, 7, 7, 0)); - // offset > columns, span <= columns - TestGridColGeometry(2, DEFAULT_COLUMNS + 1, 2, 1); + // span < columns, offset > columns + EXPECT_TRUE(TestGridColGeometry(9, 2, 3, 0)); // span > columns - TestGridColGeometry(DEFAULT_COLUMNS + 1, 1, 2, 0); + EXPECT_TRUE(TestGridColGeometry(1, 9, 0, 1)); } /** @@ -221,8 +226,8 @@ HWTEST_F(GridRowColPatternTestNg, Algorithm003, TestSize.Level1) float columnWidth = frameRect.Width(); // the first grid-col's offset occupies a whole line - EXPECT_EQ(columnWidth, DEFAULT_GRID_ROW_WIDTH / testColumns); - EXPECT_EQ(frameRect.GetX(), 0); + EXPECT_EQ(columnWidth, DEFAULT_SPAN_WIDTH); + EXPECT_EQ(frameRect.GetX(), testColumns * DEFAULT_SPAN_WIDTH); } /** @@ -240,9 +245,9 @@ HWTEST_F(GridRowColPatternTestNg, Algorithm004, TestSize.Level1) float columnWidth = frameRect.Width(); // the first grid-col's offset occupies a whole line - float expectcolumnWidth = (DEFAULT_GRID_ROW_WIDTH + gutterVal) / DEFAULT_COLUMNS - gutterVal; - EXPECT_EQ(columnWidth, expectcolumnWidth); - EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - expectcolumnWidth); + const float expectColWidth = (DEFAULT_GRID_ROW_WIDTH - (DEFAULT_COLUMNS - 1) * gutterVal) / DEFAULT_COLUMNS; + EXPECT_EQ(columnWidth, expectColWidth); + EXPECT_EQ(frameRect.GetX(), DEFAULT_GRID_ROW_WIDTH - expectColWidth); } /** @@ -277,7 +282,7 @@ HWTEST_F(GridRowColPatternTestNg, Algorithm006, TestSize.Level1) auto frameRect = layoutWrapper->GetOrCreateChildByIndex(0)->GetGeometryNode()->GetFrameRect(); EXPECT_EQ(frameRect.GetX(), 0); - EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT); + EXPECT_EQ(frameRect.GetY(), DEFAULT_HEIGHT); // because of DEFAULT_OFFSET, the col is at second row } /** From 401afd12ccb3d453be1dab985501cbb38e6d9251 Mon Sep 17 00:00:00 2001 From: yzj688 Date: Wed, 24 May 2023 10:50:51 +0800 Subject: [PATCH 49/99] =?UTF-8?q?skia=E5=BA=93=E6=94=B9=E5=90=8D=20Signed-?= =?UTF-8?q?off-by:=20yzj688=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/preview/sdk/sharedlib_config.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/preview/sdk/sharedlib_config.gni b/adapter/preview/sdk/sharedlib_config.gni index 52bf2b54725..28513901796 100644 --- a/adapter/preview/sdk/sharedlib_config.gni +++ b/adapter/preview/sdk/sharedlib_config.gni @@ -160,7 +160,7 @@ common_bin = [ if (defined(use_new_skia) && use_new_skia) { common_bin += [ { - label = "//third_party/skia:new_skia" + label = "//third_party/skia:skia_canvaskit_0310" subsystem_name = "thirdparty" part_name = "third_party_skia" }, From 4dbeee6424e520b3b59c6cbbdb8651a2e1f6763d Mon Sep 17 00:00:00 2001 From: wanyanglan Date: Fri, 19 May 2023 09:53:47 +0000 Subject: [PATCH 50/99] Add modal transition unittest. Signed-off-by: wanyanglan Change-Id: Ie588daf61f2594781f0693468f79874f36796938 --- .../pattern/overlay/overlay_manager.cpp | 18 +- .../overlay/sheet_presentation_pattern.cpp | 9 +- .../test/pattern/overlay/BUILD.gn | 12 + .../overlay/overlay_manager_test_ng.cpp | 364 ++++++++++++++++++ 4 files changed, 397 insertions(+), 6 deletions(-) diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp index e3debc06477..afe07421ca4 100644 --- a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp +++ b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp @@ -1264,8 +1264,13 @@ void OverlayManager::PlaySheetTransition(RefPtr sheetNode, bool isTra CHECK_NULL_VOID(context); auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); - auto pageNode = pipeline->GetStageManager()->GetLastPage(); - auto pageHeight = pageNode->GetGeometryNode()->GetFrameSize().Height(); + auto stageManager = pipeline->GetStageManager(); + CHECK_NULL_VOID(stageManager); + auto pageNode = stageManager->GetLastPage(); + CHECK_NULL_VOID(pageNode); + auto geometryNode = pageNode->GetGeometryNode(); + CHECK_NULL_VOID(geometryNode); + auto pageHeight = geometryNode->GetFrameSize().Height(); if (isTransitionIn) { auto offset = pageHeight - sheetHeight_; if (isFirstTransition) { @@ -1310,8 +1315,13 @@ void OverlayManager::ComputeSheetOffset(NG::SheetStyle& sheetStyle) { auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); - auto pageNode = pipeline->GetStageManager()->GetLastPage(); - auto pageHeight = pageNode->GetGeometryNode()->GetFrameSize().Height(); + auto stageManager = pipeline->GetStageManager(); + CHECK_NULL_VOID(stageManager); + auto pageNode = stageManager->GetLastPage(); + CHECK_NULL_VOID(pageNode); + auto geometryNode = pageNode->GetGeometryNode(); + CHECK_NULL_VOID(geometryNode); + auto pageHeight = geometryNode->GetFrameSize().Height(); auto largeHeight = pageHeight - SHEET_BLANK_MINI_HEIGHT.ConvertToPx(); if (sheetStyle.sheetMode.has_value()) { if (sheetStyle.sheetMode == SheetMode::MEDIUM) { diff --git a/frameworks/core/components_ng/pattern/overlay/sheet_presentation_pattern.cpp b/frameworks/core/components_ng/pattern/overlay/sheet_presentation_pattern.cpp index 8c9eff175bf..d08ee332e85 100644 --- a/frameworks/core/components_ng/pattern/overlay/sheet_presentation_pattern.cpp +++ b/frameworks/core/components_ng/pattern/overlay/sheet_presentation_pattern.cpp @@ -48,6 +48,7 @@ void SheetPresentationPattern::OnModifyDone() auto sheetStyle = layoutProperty->GetSheetStyleValue(); if (sheetStyle.showDragBar.value()) { auto dragBar = AceType::DynamicCast(host->GetFirstChild()); + CHECK_NULL_VOID(dragBar); auto dragBarPattern = dragBar->GetPattern(); CHECK_NULL_VOID(dragBarPattern); if (!dragBarPattern->HasClickArrowCallback()) { @@ -65,9 +66,13 @@ void SheetPresentationPattern::InitPageHeight() { auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); - auto pageNode = pipeline->GetStageManager()->GetLastPage(); + auto stageManager = pipeline->GetStageManager(); + CHECK_NULL_VOID(stageManager); + auto pageNode = stageManager->GetLastPage(); CHECK_NULL_VOID(pageNode); - pageHeight_ = pageNode->GetGeometryNode()->GetFrameSize().Height(); + auto geometryNode = pageNode->GetGeometryNode(); + CHECK_NULL_VOID(geometryNode); + pageHeight_ = geometryNode->GetFrameSize().Height(); } bool SheetPresentationPattern::OnDirtyLayoutWrapperSwap(const RefPtr& dirty, diff --git a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn index ddd9184b0f5..063892619bf 100644 --- a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("overlay_manager_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/picker/datepicker_dialog_view.cpp", + "$ace_root/frameworks/core/components_ng/pattern/stage/stage_manager.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_picker/textpicker_dialog_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/time_picker/timepicker_dialog_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/toast/toast_view.cpp", @@ -68,13 +69,23 @@ ohos_unittest("overlay_manager_test_ng") { "$ace_root/frameworks/core/components_ng/test/mock/pattern/text/mock_text_pattern.cpp", # self + "$ace_root/frameworks/core/components_ng/pattern/overlay/modal_presentation_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp", + "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_drag_bar_paint_method.cpp", + "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_drag_bar_pattern.cpp", + "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_presentation_pattern.cpp", + "$ace_root/frameworks/core/components_ng/pattern/overlay/sheet_view.cpp", "overlay_manager_test_ng.cpp", ] sources += [ # base "$ace_root/frameworks/base/geometry/dimension.cpp", + "$ace_root/frameworks/base/geometry/least_square_impl.cpp", + "$ace_root/frameworks/base/geometry/matrix3.cpp", + "$ace_root/frameworks/base/geometry/matrix4.cpp", + "$ace_root/frameworks/base/geometry/quaternion.cpp", + "$ace_root/frameworks/base/geometry/transform_util.cpp", "$ace_root/frameworks/base/json/json_util.cpp", "$ace_root/frameworks/base/utils/base_id.cpp", "$ace_root/frameworks/base/utils/string_expression.cpp", @@ -124,6 +135,7 @@ ohos_unittest("overlay_manager_test_ng") { "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/drawing_prop_convertor.cpp", "$ace_root/frameworks/core/components_ng/render/paint_wrapper.cpp", + "$ace_root/frameworks/core/gestures/velocity_tracker.cpp", # components_v2 "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/overlay/overlay_manager_test_ng.cpp b/frameworks/core/components_ng/test/pattern/overlay/overlay_manager_test_ng.cpp index 6ea19be4f7e..fae747329b1 100644 --- a/frameworks/core/components_ng/test/pattern/overlay/overlay_manager_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/overlay/overlay_manager_test_ng.cpp @@ -26,16 +26,25 @@ #include "base/geometry/ng/offset_t.h" #include "core/components/select/select_theme.h" #include "core/components/toast/toast_theme.h" +#include "core/components/drag_bar/drag_bar_theme.h" #include "core/components_ng/base/view_abstract.h" #include "core/components_ng/base/view_stack_processor.h" #include "core/components_ng/pattern/bubble/bubble_event_hub.h" #include "core/components_ng/pattern/bubble/bubble_pattern.h" #include "core/components_ng/pattern/button/button_pattern.h" #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" +#include "core/components_ng/pattern/overlay/modal_presentation_pattern.h" #include "core/components_ng/pattern/overlay/overlay_manager.h" +#include "core/components_ng/pattern/overlay/sheet_drag_bar_paint_method.h" +#include "core/components_ng/pattern/overlay/sheet_drag_bar_pattern.h" +#include "core/components_ng/pattern/overlay/sheet_presentation_pattern.h" +#include "core/components_ng/pattern/overlay/sheet_style.h" #include "core/components_ng/pattern/root/root_pattern.h" +#include "core/components_ng/pattern/stage/stage_pattern.h" +#include "core/components_ng/test/mock/theme/mock_theme_manager.h" #include "core/components_v2/inspector/inspector_constants.h" #include "core/pipeline_ng/test/mock/mock_pipeline_base.h" +#include "core/pipeline_ng/pipeline_context.h" using namespace testing; using namespace testing::ext; @@ -48,6 +57,7 @@ public: protected: static RefPtr CreateBubbleNode(const TestProperty& testProperty); static RefPtr CreateTargetNode(); + static void CreateSheetStyle(SheetStyle& sheetStyle); }; void OverlayManagerTestNg::SetUpTestCase() @@ -66,6 +76,15 @@ RefPtr OverlayManagerTestNg::CreateTargetNode() return frameNode; } +void OverlayManagerTestNg::CreateSheetStyle(SheetStyle& sheetStyle) +{ + if (!sheetStyle.sheetMode.has_value()) { + sheetStyle.sheetMode = SheetMode::MEDIUM; + } + if (!sheetStyle.showDragBar.has_value()) { + sheetStyle.showDragBar = true; + } +} /** * @tc.name: PopupTest001 * @tc.desc: Test OverlayManager::UpdatePopupNode. @@ -91,4 +110,349 @@ HWTEST_F(OverlayManagerTestNg, PopupTest001, TestSize.Level1) auto overlayManager = AceType::MakeRefPtr(rootNode); overlayManager->UpdatePopupNode(targetId, popupInfo); } + +/** + * @tc.name: BindContentCover001 + * @tc.desc: Test OverlayManager::BindContentCover create modal node. + * @tc.type: FUNC + */ +HWTEST_F(OverlayManagerTestNg, BindContentCover001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create target node. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + stageNode->MountToParent(rootNode); + targetNode->MountToParent(stageNode); + rootNode->MarkDirtyNode(); + + /** + * @tc.steps: step2. create target node. + */ + auto builderFunc = []() -> RefPtr { + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), + []() { return AceType::MakeRefPtr(true); }); + auto childFrameNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + frameNode->AddChild(childFrameNode); + return frameNode; + }; + + /** + * @tc.steps: step3. create modal node and get modal node, get pattern. + * @tc.expected: step3. related function is called. + */ + int32_t modalTransition = 1; + bool isShow = true; + auto overlayManager = AceType::MakeRefPtr(rootNode); + overlayManager->BindContentCover(isShow, nullptr, std::move(builderFunc), modalTransition, targetId); + EXPECT_FALSE(overlayManager->modalStack_.empty()); + auto topModalNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_NE(topModalNode, nullptr); + auto topModalPattern = topModalNode->GetPattern(); + EXPECT_NE(topModalPattern, nullptr); + auto type = topModalPattern->GetType(); + EXPECT_EQ(type, ModalTransition::NONE); +} + +/** + * @tc.name: BindContentCover002 + * @tc.desc: Test OverlayManager::BindContentCover change ModalTransition dynamically. + * @tc.type: FUNC + */ +HWTEST_F(OverlayManagerTestNg, BindContentCover002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create target node. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + stageNode->MountToParent(rootNode); + targetNode->MountToParent(stageNode); + rootNode->MarkDirtyNode(); + + /** + * @tc.steps: step2. create target node. + */ + auto builderFunc = []() -> RefPtr { + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), + []() { return AceType::MakeRefPtr(true); }); + auto childFrameNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + frameNode->AddChild(childFrameNode); + return frameNode; + }; + + /** + * @tc.steps: step3. create modal node and get modal node, get pattern. + * @tc.expected: step3. related function is called. + */ + int32_t modalTransition = 1; + bool isShow = true; + auto overlayManager = AceType::MakeRefPtr(rootNode); + overlayManager->BindContentCover(isShow, nullptr, std::move(builderFunc), modalTransition, targetId); + EXPECT_FALSE(overlayManager->modalStack_.empty()); + auto topModalNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_NE(topModalNode, nullptr); + auto topModalPattern = topModalNode->GetPattern(); + EXPECT_NE(topModalPattern, nullptr); + auto type = topModalPattern->GetType(); + EXPECT_EQ(type, ModalTransition::NONE); + + /** + * @tc.steps: step4. Change the ModalTransion. + */ + modalTransition = 0; + overlayManager->BindContentCover(isShow, nullptr, std::move(builderFunc), modalTransition, targetId); + topModalNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_NE(topModalNode, nullptr); + topModalPattern = topModalNode->GetPattern(); + EXPECT_NE(topModalPattern, nullptr); + type = topModalPattern->GetType(); + EXPECT_EQ(type, ModalTransition::DEFAULT); +} + + +/** + * @tc.name: BindContentCover003 + * @tc.desc: Test OverlayManager::BindContentCover destroy modal node. + * @tc.type: FUNC + */ +HWTEST_F(OverlayManagerTestNg, BindContentCover003, TestSize.Level1) +{ + /** + * @tc.steps: step1. create target node. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + stageNode->MountToParent(rootNode); + targetNode->MountToParent(stageNode); + rootNode->MarkDirtyNode(); + + /** + * @tc.steps: step2. create modal page node. + */ + auto builderFunc = []() -> RefPtr { + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), + []() { return AceType::MakeRefPtr(true); }); + auto childFrameNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + frameNode->AddChild(childFrameNode); + return frameNode; + }; + + /** + * @tc.steps: step3. create modal node. + */ + int32_t modalTransition = 1; + bool isShow = true; + auto overlayManager = AceType::MakeRefPtr(rootNode); + overlayManager->BindContentCover(isShow, nullptr, std::move(builderFunc), modalTransition, targetId); + EXPECT_FALSE(overlayManager->modalStack_.empty()); + + /** + * @tc.steps: step4. destroy modal page. + */ + overlayManager->BindContentCover(!isShow, nullptr, nullptr, modalTransition, targetId); + EXPECT_TRUE(overlayManager->modalStack_.empty()); +} + +/** + * @tc.name: BindSheet001 + * @tc.desc: Test OverlayManager::BindSheet create sheet page. + * @tc.type: FUNC + */ +HWTEST_F(OverlayManagerTestNg, BindSheet001, TestSize.Level1) +{ + /** + * @tc.steps: step1. create target node. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + stageNode->MountToParent(rootNode); + targetNode->MountToParent(stageNode); + rootNode->MarkDirtyNode(); + + /** + * @tc.steps: step2. create builder func. + */ + auto builderFunc = []() -> RefPtr { + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), + []() { return AceType::MakeRefPtr(true); }); + auto childFrameNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + frameNode->AddChild(childFrameNode); + return frameNode; + }; + + /** + * @tc.steps: step3. create sheet node and get sheet node, get pattern. + * @tc.expected: step3. related function is called. + */ + SheetStyle sheetStyle; + CreateSheetStyle(sheetStyle); + bool isShow = true; + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + auto dragBarTheme = AceType::MakeRefPtr(); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(dragBarTheme)); + auto overlayManager = AceType::MakeRefPtr(rootNode); + overlayManager->BindSheet(isShow, nullptr, std::move(builderFunc), sheetStyle, targetId); + EXPECT_FALSE(overlayManager->modalStack_.empty()); + auto topSheetNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_FALSE(topSheetNode == nullptr); + auto topSheetPattern = topSheetNode->GetPattern(); + EXPECT_FALSE(topSheetPattern == nullptr); + auto sheetLayoutProperty = topSheetNode->GetLayoutProperty(); + EXPECT_FALSE(sheetLayoutProperty == nullptr); + auto sheetDragBarNode = AceType::DynamicCast(topSheetNode->GetFirstChild()); + EXPECT_FALSE(sheetDragBarNode == nullptr); + auto sheetDragBarPattern = sheetDragBarNode->GetPattern(); + EXPECT_FALSE(sheetDragBarPattern == nullptr); + auto sheetDragBarPaintProperty = sheetDragBarNode->GetPaintProperty(); + EXPECT_FALSE(sheetDragBarPaintProperty == nullptr); +} + +/** + * @tc.name: BindSheet002 + * @tc.desc: Test OverlayManager::BindSheet change sheetStyle dynamically. + * @tc.type: FUNC + */ +HWTEST_F(OverlayManagerTestNg, BindSheet002, TestSize.Level1) +{ + /** + * @tc.steps: step1. create target node. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + stageNode->MountToParent(rootNode); + targetNode->MountToParent(stageNode); + rootNode->MarkDirtyNode(); + + /** + * @tc.steps: step2. create builder. + */ + auto builderFunc = []() -> RefPtr { + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), + []() { return AceType::MakeRefPtr(true); }); + auto childFrameNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + frameNode->AddChild(childFrameNode); + return frameNode; + }; + + /** + * @tc.steps: step3. create sheet node and get sheet node, get pattern. + * @tc.expected: step3. related function is called. + */ + SheetStyle sheetStyle; + CreateSheetStyle(sheetStyle); + bool isShow = true; + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + auto dragBarTheme = AceType::MakeRefPtr(); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(dragBarTheme)); + auto overlayManager = AceType::MakeRefPtr(rootNode); + overlayManager->BindSheet(isShow, nullptr, std::move(builderFunc), sheetStyle, targetId); + EXPECT_FALSE(overlayManager->modalStack_.empty()); + auto topSheetNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_FALSE(topSheetNode == nullptr); + auto sheetNodeLayoutProperty = topSheetNode->GetLayoutProperty(); + auto style = sheetNodeLayoutProperty->GetSheetStyle(); + EXPECT_EQ(style->sheetMode.value(), SheetMode::MEDIUM); + EXPECT_EQ(style->showDragBar.value(), true); + + /** + * @tc.steps: step4. Change the sheetStyle. + */ + sheetStyle.sheetMode = SheetMode::LARGE; + sheetStyle.showDragBar = false; + overlayManager->BindSheet(isShow, nullptr, std::move(builderFunc), sheetStyle, targetId); + auto sheetNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_FALSE(topSheetNode == nullptr); + auto sheetPattern = sheetNode->GetPattern(); + EXPECT_EQ(sheetPattern->GetTargetId(), topSheetNode->GetPattern()->GetTargetId()); + sheetNodeLayoutProperty = sheetNode->GetLayoutProperty(); + style = sheetNodeLayoutProperty->GetSheetStyle(); + EXPECT_EQ(style->sheetMode.value(), SheetMode::LARGE); + EXPECT_EQ(style->showDragBar.value(), false); +} + +/** + * @tc.name: BindSheet003 + * @tc.desc: Test OverlayManager::BindSheet destroy sheet node. + * @tc.type: FUNC + */ +HWTEST_F(OverlayManagerTestNg, BindSheet003, TestSize.Level1) +{ + /** + * @tc.steps: step1. create target node. + */ + auto targetNode = CreateTargetNode(); + auto targetId = targetNode->GetId(); + auto stageNode = FrameNode::CreateFrameNode( + V2::STAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto rootNode = FrameNode::CreateFrameNode(V2::ROOT_ETS_TAG, 1, AceType::MakeRefPtr()); + stageNode->MountToParent(rootNode); + targetNode->MountToParent(stageNode); + rootNode->MarkDirtyNode(); + + /** + * @tc.steps: step2. create builder. + */ + auto builderFunc = []() -> RefPtr { + auto frameNode = FrameNode::GetOrCreateFrameNode(V2::COLUMN_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), + []() { return AceType::MakeRefPtr(true); }); + auto childFrameNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG, + ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr(); }); + frameNode->AddChild(childFrameNode); + return frameNode; + }; + + /** + * @tc.steps: step3. create sheet node. + * @tc.expected: Make sure the modalStack holds the sheetNode. + */ + SheetStyle sheetStyle; + CreateSheetStyle(sheetStyle); + bool isShow = true; + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + auto dragBarTheme = AceType::MakeRefPtr(); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(dragBarTheme)); + auto overlayManager = AceType::MakeRefPtr(rootNode); + overlayManager->BindSheet(isShow, nullptr, std::move(builderFunc), sheetStyle, targetId); + EXPECT_FALSE(overlayManager->modalStack_.empty()); + auto sheetNode = overlayManager->modalStack_.top().Upgrade(); + EXPECT_EQ(sheetNode->GetTag(), "SheetPage"); + + /** + * @tc.steps: step4. destroy modal page. + */ + overlayManager->BindSheet(!isShow, nullptr, nullptr, sheetStyle, targetId); + EXPECT_TRUE(overlayManager->modalStack_.empty()); +} + } // namespace OHOS::Ace::NG \ No newline at end of file From e5ddc4bbea8ac39de6b01f37fcadae13173f9760 Mon Sep 17 00:00:00 2001 From: zhouchaobo Date: Mon, 22 May 2023 10:17:03 +0800 Subject: [PATCH 51/99] Navigation menu location error bug fix Signed-off-by: zhouchaobo Change-Id: I4e0098bbdbd2817f6ef31ddac17ea300a62330f8 --- .../core/components_ng/pattern/BUILD.gn | 1 - .../pattern/menu/menu_pattern.cpp | 2 +- .../components_ng/pattern/menu/menu_pattern.h | 1 - .../menu/navigation_menu_layout_algorithm.cpp | 57 ------------------- .../menu/navigation_menu_layout_algorithm.h | 37 ------------ .../navigation/navigation_declaration.h | 1 - .../navigation/navigation_model_ng.cpp | 10 +++- .../components_ng/test/pattern/menu/BUILD.gn | 1 - .../test/pattern/option/BUILD.gn | 1 - .../test/pattern/select/BUILD.gn | 1 - .../test/pattern/select_overlay/BUILD.gn | 1 - .../test/pattern/textfield/BUILD.gn | 1 - test/unittest/core/pipeline/BUILD.gn | 1 - 13 files changed, 9 insertions(+), 106 deletions(-) delete mode 100644 frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp delete mode 100644 frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.h diff --git a/frameworks/core/components_ng/pattern/BUILD.gn b/frameworks/core/components_ng/pattern/BUILD.gn index 17459f3d67d..82a3f907160 100644 --- a/frameworks/core/components_ng/pattern/BUILD.gn +++ b/frameworks/core/components_ng/pattern/BUILD.gn @@ -190,7 +190,6 @@ build_component_ng("pattern_ng") { "menu/menu_pattern.cpp", "menu/menu_view.cpp", "menu/multi_menu_layout_algorithm.cpp", - "menu/navigation_menu_layout_algorithm.cpp", "menu/sub_menu_layout_algorithm.cpp", "menu/wrapper/menu_wrapper_layout_algorithm.cpp", "menu/wrapper/menu_wrapper_paint_method.cpp", diff --git a/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp b/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp index b0479a1c723..556557d5768 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp @@ -413,7 +413,7 @@ RefPtr MenuPattern::CreateLayoutAlgorithm() { switch (type_) { case MenuType::NAVIGATION_MENU: - return MakeRefPtr(); + return MakeRefPtr(); case MenuType::MULTI_MENU: return MakeRefPtr(); case MenuType::SUB_MENU: diff --git a/frameworks/core/components_ng/pattern/menu/menu_pattern.h b/frameworks/core/components_ng/pattern/menu/menu_pattern.h index a69de2cd661..c1ea37eccf2 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_pattern.h +++ b/frameworks/core/components_ng/pattern/menu/menu_pattern.h @@ -24,7 +24,6 @@ #include "core/components_ng/pattern/menu/menu_layout_algorithm.h" #include "core/components_ng/pattern/menu/menu_layout_property.h" #include "core/components_ng/pattern/menu/menu_paint_method.h" -#include "core/components_ng/pattern/menu/navigation_menu_layout_algorithm.h" #include "core/components_ng/pattern/pattern.h" #include "core/components_ng/pattern/select/select_model.h" diff --git a/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp deleted file mode 100644 index b8e3813c65c..00000000000 --- a/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 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. - */ - -#include "core/components_ng/pattern/menu/navigation_menu_layout_algorithm.h" - -#include "base/geometry/ng/offset_t.h" -#include "base/utils/utils.h" -#include "core/components_ng/pattern/menu/menu_layout_property.h" -#include "core/pipeline_ng/pipeline_context.h" - -namespace OHOS::Ace::NG { - -void NavigationMenuLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) -{ - CHECK_NULL_VOID(layoutWrapper); - auto size = layoutWrapper->GetGeometryNode()->GetFrameSize(); - auto props = AceType::DynamicCast(layoutWrapper->GetLayoutProperty()); - LOGD("MenuLayout: clickPosition = %{public}f, %{public}f", position_.GetX(), position_.GetY()); - CHECK_NULL_VOID(props); - - float x = HorizontalLayout(size, position_.GetX()); - float y = VerticalLayout(size, position_.GetY()); - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - auto outPadding = static_cast(theme->GetOutPadding().ConvertToPx()); - auto child = layoutWrapper->GetOrCreateChildByIndex(0, false); - float offsetX = 0.0; - if (child) { - offsetX = child->GetGeometryNode()->GetFrameSize().Width() + outPadding * 2; - } - layoutWrapper->GetGeometryNode()->SetMarginFrameOffset(NG::OffsetF(x - offsetX, y)); - - // translate each option by the height of previous options - OffsetF translate(outPadding, outPadding); - for (const auto& child : layoutWrapper->GetAllChildrenWithBuild()) { - LOGD("layout child at offset: %{public}f, %{public}f", translate.GetX(), translate.GetY()); - child->GetGeometryNode()->SetMarginFrameOffset(translate); - child->Layout(); - translate += OffsetF(0, child->GetGeometryNode()->GetFrameSize().Height()); - } -} - -} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.h b/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.h deleted file mode 100644 index dc31c3e676e..00000000000 --- a/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MENU_NAVIGATION_MENU_LAYOUT_ALGORITHM_H -#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MENU_NAVIGATION_MENU_LAYOUT_ALGORITHM_H - -#include "base/geometry/ng/offset_t.h" -#include "core/components_ng/pattern/menu/menu_layout_algorithm.h" - -namespace OHOS::Ace::NG { -class ACE_EXPORT NavigationMenuLayoutAlgorithm : public MenuLayoutAlgorithm { - DECLARE_ACE_TYPE(NavigationMenuLayoutAlgorithm, MenuLayoutAlgorithm) -public: - NavigationMenuLayoutAlgorithm() = default; - ~NavigationMenuLayoutAlgorithm() override = default; - - void Layout(LayoutWrapper* layoutWrapper) override; - -private: - - ACE_DISALLOW_COPY_AND_MOVE(NavigationMenuLayoutAlgorithm); -}; -} // namespace OHOS::Ace::NG - -#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MENU_NAVIGATION_MENU_LAYOUT_ALGORITHM_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/navigation/navigation_declaration.h b/frameworks/core/components_ng/pattern/navigation/navigation_declaration.h index 2fc57ea363b..7420abd2b89 100644 --- a/frameworks/core/components_ng/pattern/navigation/navigation_declaration.h +++ b/frameworks/core/components_ng/pattern/navigation/navigation_declaration.h @@ -89,7 +89,6 @@ constexpr Dimension BUTTON_RADIUS = 5.0_vp; // more button constexpr Dimension MORE_BUTTON_CORNER_RADIUS = 8.0_vp; -constexpr Dimension MENU_AND_BUTTON_SPACE = 8.0_vp; struct BarItem { std::optional text; diff --git a/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp b/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp index db94f2aaf4d..dedbb2c3e94 100644 --- a/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp @@ -182,8 +182,14 @@ void BuildMoreItemNodeAction(const RefPtr& barItemNode, const RefPt auto imgOffset = imageFrameNode->GetOffsetRelativeToWindow(); auto imageSize = imageFrameNode->GetGeometryNode()->GetFrameSize(); - imgOffset.SetX(imgOffset.GetX() + imageSize.Width()); - imgOffset.SetY(imgOffset.GetY() + imageSize.Height() + static_cast(MENU_AND_BUTTON_SPACE.ConvertToPx())); + auto menuNode = AceType::DynamicCast(menu->GetChildAtIndex(0)); + CHECK_NULL_VOID(menuNode); + auto menuLayoutProperty = menuNode->GetLayoutProperty(); + CHECK_NULL_VOID(menuLayoutProperty); + menuLayoutProperty->UpdateTargetSize(imageSize); + + imgOffset.SetX(imgOffset.GetX()); + imgOffset.SetY(imgOffset.GetY() + imageSize.Height()); overlayManager->ShowMenu(id, imgOffset, menu); }; eventHub->SetItemAction(clickCallback); diff --git a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn index 2658bace7af..bbea2e95341 100644 --- a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn @@ -98,7 +98,6 @@ ohos_unittest("menu_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", diff --git a/frameworks/core/components_ng/test/pattern/option/BUILD.gn b/frameworks/core/components_ng/test/pattern/option/BUILD.gn index a86d7e1b228..fd91d5be3a4 100644 --- a/frameworks/core/components_ng/test/pattern/option/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/option/BUILD.gn @@ -52,7 +52,6 @@ ace_unittest("option_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select/BUILD.gn b/frameworks/core/components_ng/test/pattern/select/BUILD.gn index 7a1184b52ea..2d41be645f7 100644 --- a/frameworks/core/components_ng/test/pattern/select/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select/BUILD.gn @@ -88,7 +88,6 @@ ohos_unittest("select_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn index 968f46ebe6d..317cfee4e5c 100644 --- a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn @@ -68,7 +68,6 @@ ohos_unittest("select_overlay_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", diff --git a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn index 9c08a2f7362..5d0b68a90d5 100644 --- a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn @@ -50,7 +50,6 @@ ohos_unittest("textfield_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", diff --git a/test/unittest/core/pipeline/BUILD.gn b/test/unittest/core/pipeline/BUILD.gn index 7bbae7ff9d7..1bf80da74fd 100644 --- a/test/unittest/core/pipeline/BUILD.gn +++ b/test/unittest/core/pipeline/BUILD.gn @@ -150,7 +150,6 @@ ohos_unittest("pipeline_context_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/menu/menu_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/menu_view.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/multi_menu_layout_algorithm.cpp", - "$ace_root/frameworks/core/components_ng/pattern/menu/navigation_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/sub_menu_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/menu/wrapper/menu_wrapper_paint_method.cpp", From 7c508c9571a83cc91df8e47469e0b2eb53b48a1a Mon Sep 17 00:00:00 2001 From: jiangkuaixue Date: Wed, 24 May 2023 10:59:45 +0800 Subject: [PATCH 52/99] fix web screen on Signed-off-by: jiangkuaixue --- .../core/components/web/resource/web_delegate.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/frameworks/core/components/web/resource/web_delegate.cpp b/frameworks/core/components/web/resource/web_delegate.cpp index a9f4fcf9f13..a70641f70e5 100644 --- a/frameworks/core/components/web/resource/web_delegate.cpp +++ b/frameworks/core/components/web/resource/web_delegate.cpp @@ -2362,7 +2362,7 @@ void WebDelegate::InitWebViewWithSurface() rosenWindowId_ = window->GetWindowId(); LOGI("Init WebView With Surface"); context->GetTaskExecutor()->PostTask( - [weak = WeakClaim(this)]() { + [weak = WeakClaim(this), context = context_]() { auto delegate = weak.Upgrade(); CHECK_NULL_VOID(delegate); OHOS::NWeb::NWebInitArgs initArgs; @@ -2418,10 +2418,13 @@ void WebDelegate::InitWebViewWithSurface() delegate->nweb_->SetNWebHandler(nweb_handler); delegate->nweb_->PutDownloadCallback(downloadListenerImpl); #ifdef OHOS_STANDARD_SYSTEM - delegate->nweb_->RegisterScreenLockFunction(delegate->GetRosenWindowId(), [weak](bool key) { - auto delegate = weak.Upgrade(); - CHECK_NULL_VOID(delegate); - delegate->SetKeepScreenOn(key); + delegate->nweb_->RegisterScreenLockFunction(delegate->GetRosenWindowId(), [context](bool key) { + LOGD("SetKeepScreenOn %{public}d", key); + auto weakContext = context.Upgrade(); + CHECK_NULL_VOID(weakContext); + auto window = weakContext->GetWindow(); + CHECK_NULL_VOID(window); + window->SetKeepScreenOn(key); }); #endif auto findListenerImpl = std::make_shared(Container::CurrentId()); @@ -4833,4 +4836,4 @@ void WebDelegate::OnResizeNotWork() CHECK_NULL_VOID(webPattern); webPattern->OnResizeNotWork(); } -} // namespace OHOS::Ace +} // namespace OHOS::Ace \ No newline at end of file From 6ab8ff9944f166bfe48be22b340f4cbabfb0dd09 Mon Sep 17 00:00:00 2001 From: aryawang Date: Wed, 24 May 2023 03:33:31 +0000 Subject: [PATCH 53/99] =?UTF-8?q?marquee=20=E7=9B=B8=E5=AF=B9=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E5=8F=B3=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aryawang Change-Id: I8400b6df0a228d4a101d2db477a4b595f3f63004 --- .../pattern/marquee/marquee_layout_algorithm.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/marquee/marquee_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/marquee/marquee_layout_algorithm.cpp index 8c1f78373fa..ed95cf98b54 100644 --- a/frameworks/core/components_ng/pattern/marquee/marquee_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/marquee/marquee_layout_algorithm.cpp @@ -39,7 +39,6 @@ void MarqueeLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) // measure child. LayoutConstraintF textLayoutConstraint; textLayoutConstraint.UpdateMaxSizeWithCheck(SizeF(Infinity(), maxSize.Height())); - textLayoutConstraint.UpdateMinSizeWithCheck(minSize); child->Measure(textLayoutConstraint); // measure self. OptionalSizeF frameSize; @@ -49,8 +48,9 @@ void MarqueeLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) if (frameSize.IsValid()) { break; } + frameSize.UpdateIllegalSizeWithCheck(layoutConstraint->parentIdealSize); + frameSize.UpdateIllegalSizeWithCheck(layoutConstraint->percentReference); if (measureType == MeasureType::MATCH_PARENT) { - frameSize.UpdateIllegalSizeWithCheck(layoutConstraint->parentIdealSize); if (frameSize.IsValid()) { frameSize.Constrain(minSize, maxSize); break; @@ -60,7 +60,7 @@ void MarqueeLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) auto childFrame = child->GetGeometryNode()->GetMarginFrameSize(); childFrame.Constrain(SizeF(Infinity(), minSize.Height()), maxSize); AddPaddingToSize(padding, childFrame); - frameSize.UpdateIllegalSizeWithCheck(childFrame); + frameSize.Constrain(SizeF { 0.0f, 0.0f }, SizeF { Infinity(), childFrame.Height() }); break; } frameSize.UpdateIllegalSizeWithCheck(SizeF { 0.0f, 0.0f }); From 97154ec4a466739352efd823cf6129c8cdded978 Mon Sep 17 00:00:00 2001 From: zhengqiyi Date: Wed, 24 May 2023 03:40:19 +0000 Subject: [PATCH 54/99] change draggable Signed-off-by: zhengqiyi --- frameworks/core/components_ng/event/drag_event.cpp | 5 ++++- frameworks/core/components_ng/event/gesture_event_hub.cpp | 7 +++++-- .../components_ng/pattern/hyperlink/hyperlink_pattern.h | 5 +++++ .../core/components_ng/pattern/image/image_model_ng.cpp | 6 ------ .../core/components_ng/pattern/image/image_pattern.h | 5 +++++ frameworks/core/components_ng/pattern/pattern.h | 5 +++++ .../core/components_ng/pattern/text/text_model_ng.cpp | 6 ------ frameworks/core/components_ng/pattern/text/text_pattern.h | 5 +++++ .../core/components_ng/pattern/video/video_pattern.h | 5 +++++ 9 files changed, 34 insertions(+), 15 deletions(-) diff --git a/frameworks/core/components_ng/event/drag_event.cpp b/frameworks/core/components_ng/event/drag_event.cpp index fd770a1ff3e..6ea840f9445 100644 --- a/frameworks/core/components_ng/event/drag_event.cpp +++ b/frameworks/core/components_ng/event/drag_event.cpp @@ -198,7 +198,10 @@ void DragEventActuator::OnCollectTouchTarget(const OffsetF& coordinateOffset, co CHECK_NULL_VOID(gestureHub); auto frameNode = gestureHub->GetFrameNode(); CHECK_NULL_VOID(frameNode); - if (!longPressRecognizer_->HasThumbnailCallback()) { + auto eventHub = frameNode->GetEventHub(); + CHECK_NULL_VOID(eventHub); + bool isAllowedDrag = gestureHub->IsAllowedDrag(eventHub); + if (!longPressRecognizer_->HasThumbnailCallback() && isAllowedDrag) { auto callback = [weakPtr = gestureEventHub_](Offset point) { auto gestureHub = weakPtr.Upgrade(); CHECK_NULL_VOID(gestureHub); diff --git a/frameworks/core/components_ng/event/gesture_event_hub.cpp b/frameworks/core/components_ng/event/gesture_event_hub.cpp index 218faa834a1..7f9bef83fb0 100644 --- a/frameworks/core/components_ng/event/gesture_event_hub.cpp +++ b/frameworks/core/components_ng/event/gesture_event_hub.cpp @@ -354,8 +354,11 @@ bool GestureEventHub::IsAllowedDrag(RefPtr eventHub) { auto frameNode = GetFrameNode(); CHECK_NULL_RETURN(frameNode, false); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_RETURN(pattern, false); + if (frameNode->IsDraggable()) { - if (!eventHub->HasOnDragStart()) { + if (!eventHub->HasOnDragStart() && !pattern->DefaultSupportDrag()) { LOGE("Default support for drag and drop, but there is no onDragStart function."); return false; } @@ -364,7 +367,7 @@ bool GestureEventHub::IsAllowedDrag(RefPtr eventHub) LOGE("User settings cannot be dragged"); return false; } - if (!eventHub->HasOnDragStart()) { + if (!eventHub->HasOnDragStart() && !pattern->DefaultSupportDrag()) { LOGE("The default does not support drag and drop, and there is no onDragStart function."); return false; } diff --git a/frameworks/core/components_ng/pattern/hyperlink/hyperlink_pattern.h b/frameworks/core/components_ng/pattern/hyperlink/hyperlink_pattern.h index f703b018df1..8f0f5dce726 100644 --- a/frameworks/core/components_ng/pattern/hyperlink/hyperlink_pattern.h +++ b/frameworks/core/components_ng/pattern/hyperlink/hyperlink_pattern.h @@ -47,6 +47,11 @@ public: return draggable_; } + bool DefaultSupportDrag() override + { + return true; + } + private: void LinkToAddress(); void OnAttachToFrameNode() override; diff --git a/frameworks/core/components_ng/pattern/image/image_model_ng.cpp b/frameworks/core/components_ng/pattern/image/image_model_ng.cpp index efaecd24de8..750d1196bcd 100644 --- a/frameworks/core/components_ng/pattern/image/image_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/image/image_model_ng.cpp @@ -50,12 +50,6 @@ void ImageModelNG::Create(const std::string& src, bool noPixMap, RefPtr(); }); stack->Push(frameNode); ACE_UPDATE_LAYOUT_PROPERTY(ImageLayoutProperty, ImageSourceInfo, createSourceInfoFunc()); - - auto pipeline = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - SetDraggable(theme->GetDraggable()); } void ImageModelNG::SetAlt(const std::string& src) diff --git a/frameworks/core/components_ng/pattern/image/image_pattern.h b/frameworks/core/components_ng/pattern/image/image_pattern.h index 171a72c3dfe..c8af0ffb7e3 100644 --- a/frameworks/core/components_ng/pattern/image/image_pattern.h +++ b/frameworks/core/components_ng/pattern/image/image_pattern.h @@ -80,6 +80,11 @@ public: void EnableDrag(); + bool DefaultSupportDrag() override + { + return true; + } + void SetCopyOption(CopyOptions value) { copyOption_ = value; diff --git a/frameworks/core/components_ng/pattern/pattern.h b/frameworks/core/components_ng/pattern/pattern.h index 74315b1293f..2772f0b232c 100644 --- a/frameworks/core/components_ng/pattern/pattern.h +++ b/frameworks/core/components_ng/pattern/pattern.h @@ -54,6 +54,11 @@ public: return true; } + virtual bool DefaultSupportDrag() + { + return false; + } + virtual std::optional GetSurfaceNodeName() const { return std::nullopt; diff --git a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp index c18c7ebaffb..f5a74202237 100644 --- a/frameworks/core/components_ng/pattern/text/text_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text/text_model_ng.cpp @@ -36,12 +36,6 @@ void TextModelNG::Create(const std::string& content) ACE_UPDATE_LAYOUT_PROPERTY(TextLayoutProperty, Content, content); ACE_UPDATE_LAYOUT_PROPERTY(TextLayoutProperty, TextAlign, TextAlign::START); ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Alignment, Alignment::CENTER_LEFT); - - auto pipeline = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - SetDraggable(theme->GetDraggable()); } void TextModelNG::SetFontSize(const Dimension& value) diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.h b/frameworks/core/components_ng/pattern/text/text_pattern.h index df331a5ee08..260d7431ee6 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.h +++ b/frameworks/core/components_ng/pattern/text/text_pattern.h @@ -79,6 +79,11 @@ public: return false; } + bool DefaultSupportDrag() override + { + return true; + } + void OnModifyDone() override; void BeforeCreateLayoutWrapper() override; diff --git a/frameworks/core/components_ng/pattern/video/video_pattern.h b/frameworks/core/components_ng/pattern/video/video_pattern.h index 593ba7d53b6..f5fff9c118e 100644 --- a/frameworks/core/components_ng/pattern/video/video_pattern.h +++ b/frameworks/core/components_ng/pattern/video/video_pattern.h @@ -64,6 +64,11 @@ public: return MakeRefPtr(); } + bool DefaultSupportDrag() override + { + return true; + } + void UpdateMuted(bool muted) { muted_ = muted; From 2a4e090d35296462ea8ed2d05223df93db10bdb4 Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 24 May 2023 11:42:34 +0800 Subject: [PATCH 55/99] fix the bug of stroke style Signed-off-by: limeng --- .../declarative_frontend/jsview/js_canvas_renderer.cpp | 9 ++++++--- .../pattern/custom_paint/custom_paint_paint_method.cpp | 8 +++++++- .../pattern/custom_paint/custom_paint_pattern.cpp | 6 ------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp index 80791b9e35f..9b7ca2af819 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp @@ -769,9 +769,12 @@ void JSCanvasRenderer::JsSetStrokeStyle(const JSCallbackInfo& info) return; } if (info[0]->IsString()) { - std::string colorStr; - JSViewAbstract::ParseJsString(info[0], colorStr); - auto color = Color::FromString(colorStr); + static const char componentCanvasRenderer[] = "CanvasRenderer"; + static const char propCanvasRendererStrokeStyle[] = "strokeStyle"; + Color color; + if (!JSViewAbstract::CheckColor(info[0], color, componentCanvasRenderer, propCanvasRendererStrokeStyle)) { + return; + } if (Container::IsCurrentUseNewPipeline()) { if (isOffscreen_ && offscreenCanvasPattern_) { offscreenCanvasPattern_->SetStrokeColor(color); diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp index f7e0b98a4d4..37911ea7dcf 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp @@ -379,7 +379,9 @@ void CustomPaintPaintMethod::GetStrokePaint(SkPaint& paint, SkSamplingOptions& o { LineCapStyle::SQUARE, SkPaint::Cap::kSquare_Cap }, }; InitImagePaint(paint, options); - paint.setColor(strokeState_.GetColor().GetValue()); + if (strokeState_.GetPaintStyle() == PaintStyle::Color) { + paint.setColor(strokeState_.GetColor().GetValue()); + } paint.setStyle(SkPaint::Style::kStroke_Style); paint.setStrokeJoin(ConvertEnumToSkEnum( strokeState_.GetLineJoin(), skLineJoinTable, ArraySize(skLineJoinTable), SkPaint::Join::kMiter_Join)); @@ -571,6 +573,10 @@ void CustomPaintPaintMethod::StrokeRect(PaintWrapper* paintWrapper, const Rect& GetStrokePaint(paint, options); #endif paint.setAntiAlias(antiAlias_); + if (strokeState_.GetPaintStyle() == PaintStyle::Color) { + paint.setColor(strokeState_.GetColor().GetValue()); + } + paint.setStyle(SkPaint::Style::kStroke_Style); SkRect skRect = SkRect::MakeLTRB(rect.Left() + offset.GetX(), rect.Top() + offset.GetY(), rect.Right() + offset.GetX(), offset.GetY() + rect.Bottom()); if (HasShadow()) { diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp index 46db2a74a21..12fb09751aa 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp @@ -550,8 +550,6 @@ void CustomPaintPattern::UpdateStrokePattern(const std::weak_ptr& { auto task = [pattern](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { paintMethod.SetStrokePatternNG(pattern); - paintMethod.SetStrokeGradient(Ace::Gradient()); - paintMethod.SetStrokeColor(Color()); }; paintMethod_->PushTask(task); auto host = GetHost(); @@ -563,8 +561,6 @@ void CustomPaintPattern::UpdateStrokeColor(const Color& color) { auto task = [color](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { paintMethod.SetStrokeColor(color); - paintMethod.SetStrokePattern(Ace::Pattern()); - paintMethod.SetStrokeGradient(Ace::Gradient()); }; paintMethod_->PushTask(task); auto host = GetHost(); @@ -576,8 +572,6 @@ void CustomPaintPattern::UpdateStrokeGradient(const Ace::Gradient& grad) { auto task = [grad](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { paintMethod.SetStrokeGradient(grad); - paintMethod.SetStrokeColor(Color()); - paintMethod.SetStrokePattern(Ace::Pattern()); }; paintMethod_->PushTask(task); auto host = GetHost(); From 83365a1ba1bf07afbfe29753b63f13e8dc9cda81 Mon Sep 17 00:00:00 2001 From: jinweiliu Date: Sun, 21 May 2023 09:25:31 +0000 Subject: [PATCH 56/99] fix video Signed-off-by: jinweiliu Change-Id: Ibb04dc5b3c94204ab50b58ac607ddfcd3b675e93 --- .../components/video/media_player_callback.h | 15 +- .../core/components_ng/pattern/BUILD.gn | 1 + .../pattern/video/video_model_ng.cpp | 29 +- .../pattern/video/video_node.cpp | 40 +++ .../components_ng/pattern/video/video_node.h | 86 ++++++ .../pattern/video/video_pattern.cpp | 270 +++++++++++------- .../pattern/video/video_pattern.h | 12 +- .../test/mock/render/mock_media_player.h | 17 +- .../components_ng/test/pattern/video/BUILD.gn | 3 +- .../video_accessibility_property_test_ng.cpp | 6 +- .../video/video_pattern_focus_test_ng.cpp | 43 +-- .../pattern/video/video_pattern_test_ng.cpp | 230 +++++---------- 12 files changed, 434 insertions(+), 318 deletions(-) create mode 100644 frameworks/core/components_ng/pattern/video/video_node.cpp create mode 100644 frameworks/core/components_ng/pattern/video/video_node.h diff --git a/frameworks/core/components/video/media_player_callback.h b/frameworks/core/components/video/media_player_callback.h index 43faa1c9f4e..c15bc4bdc5e 100644 --- a/frameworks/core/components/video/media_player_callback.h +++ b/frameworks/core/components/video/media_player_callback.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_MEDIA_PLAYER_CALLBACK_H -#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_MEDIA_PLAYER_CALLBACK_H +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_PLAYER_CALLBACK_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_PLAYER_CALLBACK_H #include "base/log/log.h" @@ -88,29 +88,30 @@ public: void OnInfo(Media::PlayerOnInfoType type, int32_t extra, const Media::Format &InfoBody = {}) override { - LOGI("OnInfo type: %{public}d, extra: %{public}d", type, extra); + LOGD("video OnInfo type: %{public}d, extra: %{public}d", type, extra); ContainerScope scope(instanceId_); switch (type) { case OHOS::Media::INFO_TYPE_SEEKDONE: - LOGI("OnSeekDone callback"); + LOGI("video OnSeekDone callback"); if (positionUpdatedEvent_) { positionUpdatedEvent_(extra / MILLISECONDS_TO_SECONDS); } break; case OHOS::Media::INFO_TYPE_EOS: - LOGI("OnEndOfStream callback"); + LOGI("video OnEndOfStream callback"); if (endOfStreamEvent_) { endOfStreamEvent_(); } break; case OHOS::Media::INFO_TYPE_STATE_CHANGE: - LOGI("OnStateChanged callback"); + LOGI("video OnStateChanged callback"); PrintState(static_cast(extra)); if (stateChangedEvent_) { stateChangedEvent_(ConvertToPlaybackStatus(extra)); } break; case OHOS::Media::INFO_TYPE_POSITION_UPDATE: + LOGI("video INFO_TYPE_POSITION_UPDATE callback"); if (positionUpdatedEvent_) { positionUpdatedEvent_(extra / MILLISECONDS_TO_SECONDS); } @@ -185,4 +186,4 @@ private: } // namespace OHOS::Ace -#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_MEDIA_PLAYER_CALLBACK_H +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_VIDEO_PLAYER_CALLBACK_H diff --git a/frameworks/core/components_ng/pattern/BUILD.gn b/frameworks/core/components_ng/pattern/BUILD.gn index f33144f1ad1..d3164f3725e 100644 --- a/frameworks/core/components_ng/pattern/BUILD.gn +++ b/frameworks/core/components_ng/pattern/BUILD.gn @@ -424,6 +424,7 @@ build_component_ng("pattern_ng") { "video/video_accessibility_property.cpp", "video/video_layout_algorithm.cpp", "video/video_model_ng.cpp", + "video/video_node.cpp", "video/video_pattern.cpp", "waterflow/water_flow_item_model_ng.cpp", "waterflow/water_flow_layout_algorithm.cpp", diff --git a/frameworks/core/components_ng/pattern/video/video_model_ng.cpp b/frameworks/core/components_ng/pattern/video/video_model_ng.cpp index ae312dbc657..f427493bdb6 100644 --- a/frameworks/core/components_ng/pattern/video/video_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/video/video_model_ng.cpp @@ -16,8 +16,10 @@ #include "core/components_ng/pattern/video/video_model_ng.h" #include "core/components/common/layout/constants.h" -#include "core/components_ng/base/frame_node.h" #include "core/components_ng/base/view_stack_processor.h" +#include "core/components_ng/pattern/image/image_pattern.h" +#include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" +#include "core/components_ng/pattern/video/video_node.h" #include "core/components_ng/pattern/video/video_pattern.h" #include "core/components_v2/inspector/inspector_constants.h" @@ -27,9 +29,30 @@ void VideoModelNG::Create(const RefPtr& videoController) { auto* stack = ViewStackProcessor::GetInstance(); auto nodeId = stack->ClaimNodeId(); - auto frameNode = FrameNode::GetOrCreateFrameNode( + auto videoNode = VideoNode::GetOrCreateVideoNode( V2::VIDEO_ETS_TAG, nodeId, [videoController]() { return AceType::MakeRefPtr(videoController); }); - stack->Push(frameNode); + CHECK_NULL_VOID(videoNode); + stack->Push(videoNode); + bool hasPreviewImageNode = videoNode->HasPreviewImageNode(); + bool hasControllerRowNode = videoNode->HasControllerRowNode(); + LOGI("Preview image is %{public}d, controller is %{public}d.", hasPreviewImageNode, hasControllerRowNode); + if (!hasPreviewImageNode) { + auto previewImageId = videoNode->GetPreviewImageId(); + auto previewImageNode = FrameNode::GetOrCreateFrameNode( + V2::IMAGE_ETS_TAG, previewImageId, []() { return AceType::MakeRefPtr(); }); + CHECK_NULL_VOID(previewImageNode); + videoNode->AddChild(previewImageNode); + } + if (!hasControllerRowNode) { + auto controllerRowId = videoNode->GetControllerRowId(); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + CHECK_NULL_VOID(frameNode); + auto videoPattern = AceType::DynamicCast(frameNode->GetPattern()); + CHECK_NULL_VOID(videoPattern); + auto controllerRowNode = videoPattern->CreateControlBar(controllerRowId); + CHECK_NULL_VOID(controllerRowNode); + videoNode->AddChild(controllerRowNode); + } AddDragFrameNodeToManager(); } diff --git a/frameworks/core/components_ng/pattern/video/video_node.cpp b/frameworks/core/components_ng/pattern/video/video_node.cpp new file mode 100644 index 00000000000..ad405c2ca09 --- /dev/null +++ b/frameworks/core/components_ng/pattern/video/video_node.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "core/components_ng/pattern/video/video_node.h" + +namespace OHOS::Ace::NG { +RefPtr VideoNode::GetOrCreateVideoNode( + const std::string& tag, int32_t nodeId, const std::function(void)>& patternCreator) +{ + auto videoNode = ElementRegister::GetInstance()->GetSpecificItemById(nodeId); + if (videoNode) { + if (videoNode->GetTag() == tag) { + return videoNode; + } + ElementRegister::GetInstance()->RemoveItemSilently(nodeId); + auto parent = videoNode->GetParent(); + if (parent) { + parent->RemoveChild(videoNode); + } + } + + auto pattern = patternCreator ? patternCreator() : AceType::MakeRefPtr(); + videoNode = AceType::MakeRefPtr(tag, nodeId, pattern, false); + videoNode->InitializePatternAndContext(); + ElementRegister::GetInstance()->AddUINode(videoNode); + return videoNode; +} +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/video/video_node.h b/frameworks/core/components_ng/pattern/video/video_node.h new file mode 100644 index 00000000000..ef575743247 --- /dev/null +++ b/frameworks/core/components_ng/pattern/video/video_node.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_VIDEO_VIDEO_NODE_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_VIDEO_VIDEO_NODE_H + +#include + +#include "core/components_ng/base/frame_node.h" +#include "core/components_ng/pattern/video/video_pattern.h" + +namespace OHOS::Ace::NG { +namespace { +constexpr int32_t PREVIEW_IMAGE_INDEX = 0; +constexpr int32_t CONTROLLER_ROW_INDEX = 1; +} // namespace + +class ACE_EXPORT VideoNode : public FrameNode { + DECLARE_ACE_TYPE(VideoNode, FrameNode); + +public: + VideoNode(const std::string& tag, int32_t nodeId, const RefPtr& pattern, bool isRoot = false) + : FrameNode(tag, nodeId, pattern, isRoot) + {} + ~VideoNode() override = default; + + bool HasControllerRowNode() const + { + return controllerRowId_.has_value(); + } + + bool HasPreviewImageNode() const + { + return previewImageId_.has_value(); + } + + int32_t GetControllerRowId() + { + if (!controllerRowId_.has_value()) { + controllerRowId_ = ElementRegister::GetInstance()->MakeUniqueId(); + } + return controllerRowId_.value(); + } + + int32_t GetPreviewImageId() + { + if (!previewImageId_.has_value()) { + previewImageId_ = ElementRegister::GetInstance()->MakeUniqueId(); + } + return previewImageId_.value(); + } + + // Get the preview image node, please check null first. + RefPtr GetPreviewImage() + { + // If the index >= size, it will return null. + return GetChildAtIndex(PREVIEW_IMAGE_INDEX); + } + + // Get the controller row node, please check null first. + RefPtr GetControllerRow() + { + // If the index >= size, it will return null. + return GetChildAtIndex(CONTROLLER_ROW_INDEX); + } + + static RefPtr GetOrCreateVideoNode( + const std::string& tag, int32_t nodeId, const std::function(void)>& patternCreator); +private: + std::optional previewImageId_; + std::optional controllerRowId_; +}; +} // namespace OHOS::Ace::NG +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_VIDEO_VIDEO_NODE_H diff --git a/frameworks/core/components_ng/pattern/video/video_pattern.cpp b/frameworks/core/components_ng/pattern/video/video_pattern.cpp index 8f789ea2694..fc285e9ae0a 100644 --- a/frameworks/core/components_ng/pattern/video/video_pattern.cpp +++ b/frameworks/core/components_ng/pattern/video/video_pattern.cpp @@ -43,14 +43,15 @@ #include "core/components_ng/pattern/text/text_pattern.h" #include "core/components_ng/pattern/video/video_event_hub.h" #include "core/components_ng/pattern/video/video_layout_property.h" +#include "core/components_ng/pattern/video/video_node.h" #include "core/components_ng/property/property.h" #include "core/components_v2/inspector/inspector_constants.h" #include "core/pipeline_ng/pipeline_context.h" #ifdef ENABLE_DRAG_FRAMEWORK -#include "video.h" #include "unified_data.h" #include "unified_record.h" +#include "video.h" #endif namespace OHOS::Ace::NG { namespace { @@ -189,6 +190,24 @@ void VideoPattern::UpdateMediaPlayer() } } +void VideoPattern::ResetMediaPlayer() +{ + mediaPlayer_->ResetMediaPlayer(); + if (!SetSourceForMediaPlayer()) { + LOGE("Video set source for mediaPlayer failed."); + + // It need post on ui thread. + FireError(); + return; + } + + RegisterMediaPlayerEvent(); + PrepareSurface(); + if (mediaPlayer_->PrepareAsync() != 0) { + LOGE("Player prepare failed"); + } +} + void VideoPattern::PrepareMediaPlayer() { auto videoLayoutProperty = GetLayoutProperty(); @@ -207,20 +226,14 @@ void VideoPattern::PrepareMediaPlayer() } ResetStatus(); - mediaPlayer_->ResetMediaPlayer(); - if (!SetSourceForMediaPlayer()) { - LOGE("Video set source for mediaPlayer failed."); - - // It need post on ui thread. - FireError(); - return; - } - - RegisterMediaPlayerEvent(); - PrepareSurface(); - if (mediaPlayer_->PrepareAsync() != 0) { - LOGE("Player prepare failed"); - } + auto context = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(context); + auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND); + platformTask.PostTask([weak = WeakClaim(this)] { + auto video = weak.Upgrade(); + CHECK_NULL_VOID(video); + video->ResetMediaPlayer(); + }); } bool VideoPattern::SetSourceForMediaPlayer() @@ -277,8 +290,42 @@ void VideoPattern::RegisterMediaPlayerEvent() mediaPlayer_->RegisterMediaPlayerEvent(positionUpdatedEvent, stateChangedEvent, errorEvent, resolutionChangeEvent); } +void VideoPattern::PrintPlayerStatus(PlaybackStatus status) +{ + switch (status) { + case PlaybackStatus::ERROR: + LOGI("Player current status is ERROR."); + break; + case PlaybackStatus::IDLE: + LOGI("Player current status is IDLE."); + break; + case PlaybackStatus::PREPARED: + LOGI("Player current status is PREPARED."); + break; + case PlaybackStatus::STARTED: + LOGI("Player current status is STARTED."); + break; + case PlaybackStatus::PAUSED: + LOGI("Player current status is PAUSED."); + break; + case PlaybackStatus::STOPPED: + LOGI("Player current status is STOPPED."); + break; + case PlaybackStatus::PLAYBACK_COMPLETE: + LOGI("Player current status is PLAYBACK_COMPLETE."); + break; + case PlaybackStatus::NONE: + LOGI("Player current status is NONE."); + break; + default: + LOGI("Invalid player status."); + break; + } +} + void VideoPattern::OnCurrentTimeChange(uint32_t currentPos) { + LOGD("Video current position is %{public}d", currentPos); isInitialState_ = isInitialState_ ? currentPos == 0 : false; if (currentPos == currentPos_ || isStop_) { return; @@ -303,6 +350,7 @@ void VideoPattern::OnCurrentTimeChange(uint32_t currentPos) void VideoPattern::OnPlayerStatus(PlaybackStatus status) { + PrintPlayerStatus(status); bool isPlaying = (status == PlaybackStatus::STARTED); if (isPlaying_ != isPlaying) { isPlaying_ = isPlaying; @@ -391,26 +439,23 @@ void VideoPattern::OnPrepared(double width, double height, uint32_t duration, ui OnUpdateTime(duration_, DURATION_POS); OnUpdateTime(currentPos_, CURRENT_POS); - auto needControlBar = videoLayoutProperty->GetControlsValue(true); - if (needControlBar) { - RefPtr controlBar = nullptr; - auto children = host->GetChildren(); - for (const auto& child : children) { - if (child->GetTag() == V2::ROW_ETS_TAG) { - controlBar = child; - break; - } + RefPtr controlBar = nullptr; + auto children = host->GetChildren(); + for (const auto& child : children) { + if (child->GetTag() == V2::ROW_ETS_TAG) { + controlBar = child; + break; } - CHECK_NULL_VOID(controlBar); - auto sliderNode = DynamicCast(controlBar->GetChildAtIndex(SLIDER_POS)); - auto sliderPaintProperty = sliderNode->GetPaintProperty(); - CHECK_NULL_VOID(sliderPaintProperty); - sliderPaintProperty->UpdateMin(0.0f); - sliderPaintProperty->UpdateMax(static_cast(duration_)); - sliderNode->MarkModifyDone(); - auto playBtn = DynamicCast(controlBar->GetChildAtIndex(0)); - ChangePlayButtonTag(playBtn); } + CHECK_NULL_VOID(controlBar); + auto sliderNode = DynamicCast(controlBar->GetChildAtIndex(SLIDER_POS)); + auto sliderPaintProperty = sliderNode->GetPaintProperty(); + CHECK_NULL_VOID(sliderPaintProperty); + sliderPaintProperty->UpdateMin(0.0f); + sliderPaintProperty->UpdateMax(static_cast(duration_)); + sliderNode->MarkModifyDone(); + auto playBtn = DynamicCast(controlBar->GetChildAtIndex(0)); + ChangePlayButtonTag(playBtn); if (needFireEvent) { auto json = JsonUtil::Create(true); @@ -421,6 +466,7 @@ void VideoPattern::OnPrepared(double width, double height, uint32_t duration, ui } UpdateLooping(); UpdateSpeed(); + UpdateMuted(); if (isStop_) { isStop_ = false; @@ -529,7 +575,7 @@ void VideoPattern::OnUpdateTime(uint32_t time, int pos) const auto layoutProperty = host->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); bool needControlBar = layoutProperty->GetControlsValue(true); - if (!needControlBar) { + if (!needControlBar && pos == CURRENT_POS) { return; } @@ -544,6 +590,7 @@ void VideoPattern::OnUpdateTime(uint32_t time, int pos) const CHECK_NULL_VOID(controlBar); auto durationNode = DynamicCast(controlBar->GetChildAtIndex(pos)); + CHECK_NULL_VOID(durationNode); auto textLayoutProperty = durationNode->GetLayoutProperty(); CHECK_NULL_VOID(textLayoutProperty); std::string timeText = IntTimeToText(time); @@ -599,18 +646,13 @@ void VideoPattern::OnModifyDone() videoPattern->HiddenChange(hidden); }); } - AddPreviewNodeIfNeeded(); - // Create the control bar - AddControlBarNodeIfNeeded(); - auto context = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(context); - auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND); - platformTask.PostTask([weak = WeakClaim(this)] { - auto video = weak.Upgrade(); - CHECK_NULL_VOID(video); - video->UpdateMediaPlayer(); - }); + // Update the control bar and preview image. + UpdatePreviewImage(); + UpdateControllerBar(); + + // Update the media player. + UpdateMediaPlayer(); if (SystemProperties::GetExtSurfaceEnabled()) { auto pipelineContext = PipelineContext::GetCurrentContext(); @@ -622,54 +664,77 @@ void VideoPattern::OnModifyDone() EnableDrag(); } -void VideoPattern::AddPreviewNodeIfNeeded() +void VideoPattern::UpdatePreviewImage() { auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + auto posterSourceInfo = layoutProperty->GetPosterImageInfo().value(); + auto imageFit = layoutProperty->GetObjectFitValue(ImageFit::COVER); + auto host = GetHost(); + CHECK_NULL_VOID(host); + + auto video = AceType::DynamicCast(host); + CHECK_NULL_VOID(video); + auto image = AceType::DynamicCast(video->GetPreviewImage()); + CHECK_NULL_VOID(image); if (!isInitialState_ || !layoutProperty->HasPosterImageInfo()) { + auto posterLayoutProperty = image->GetLayoutProperty(); + posterLayoutProperty->UpdateVisibility(VisibleType::INVISIBLE); + image->MarkModifyDone(); return; } - auto host = GetHost(); - CHECK_NULL_VOID(host); - bool isExist = false; - auto children = host->GetChildren(); - auto posterSourceInfo = layoutProperty->GetPosterImageInfo().value(); - auto imageFit = layoutProperty->GetObjectFitValue(ImageFit::COVER); - - for (const auto& child : children) { - if (child->GetTag() == V2::IMAGE_ETS_TAG) { - isExist = true; - auto image = AceType::DynamicCast(child); - auto posterLayoutProperty = image->GetLayoutProperty(); - posterLayoutProperty->UpdateImageSourceInfo(posterSourceInfo); - posterLayoutProperty->UpdateImageFit(imageFit); - image->MarkModifyDone(); - break; - } + if (!posterSourceInfo.IsValid()) { + auto posterLayoutProperty = image->GetLayoutProperty(); + posterLayoutProperty->UpdateVisibility(VisibleType::INVISIBLE); + image->MarkModifyDone(); + LOGI("Src image is not valid."); + return; } - if (!isExist) { - auto posterNode = FrameNode::CreateFrameNode(V2::IMAGE_ETS_TAG, -1, AceType::MakeRefPtr()); - CHECK_NULL_VOID(posterNode); - auto posterLayoutProperty = posterNode->GetLayoutProperty(); + if (image) { + auto posterLayoutProperty = image->GetLayoutProperty(); + posterLayoutProperty->UpdateVisibility(VisibleType::VISIBLE); posterLayoutProperty->UpdateImageSourceInfo(posterSourceInfo); posterLayoutProperty->UpdateImageFit(imageFit); - host->AddChild(posterNode); - posterNode->MarkModifyDone(); + image->MarkModifyDone(); } } -void VideoPattern::AddControlBarNodeIfNeeded() +void VideoPattern::UpdateControllerBar() { auto layoutProperty = GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); auto host = GetHost(); CHECK_NULL_VOID(host); auto children = host->GetChildren(); if (layoutProperty->GetControlsValue(true)) { - bool isExist = false; + auto video = AceType::DynamicCast(host); + CHECK_NULL_VOID(video); + auto controller = AceType::DynamicCast(video->GetControllerRow()); + + if (controller) { + auto sliderNode = DynamicCast(controller->GetChildAtIndex(SLIDER_POS)); + CHECK_NULL_VOID(sliderNode); + auto sliderPattern = sliderNode->GetPattern(); + CHECK_NULL_VOID(sliderPattern); + sliderPattern->UpdateValue(static_cast(currentPos_)); + sliderNode->MarkModifyDone(); + + auto textNode = DynamicCast(controller->GetChildAtIndex(CURRENT_POS)); + CHECK_NULL_VOID(textNode); + auto textLayoutProperty = textNode->GetLayoutProperty(); + CHECK_NULL_VOID(textLayoutProperty); + std::string label = IntTimeToText(currentPos_); + textLayoutProperty->UpdateContent(label); + textNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); + textNode->MarkModifyDone(); + auto controllerLayoutProperty = controller->GetLayoutProperty(); + controllerLayoutProperty->UpdateVisibility(VisibleType::VISIBLE); + controller->MarkModifyDone(); + } for (const auto& child : children) { if (child->GetTag() == V2::ROW_ETS_TAG) { - isExist = true; if (isDrag_) { host->RemoveChild(child); auto controlBar = CreateControlBar(); @@ -678,22 +743,15 @@ void VideoPattern::AddControlBarNodeIfNeeded() break; } } - if (!isExist) { - auto controlBar = CreateControlBar(); - host->AddChild(controlBar); - } } else { - auto iter = children.begin(); - while (iter != children.end()) { - if ((*iter)->GetTag() == V2::ROW_ETS_TAG) { - host->RemoveChild(*iter); - host->RebuildRenderContextTree(); - auto context = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(context); - context->RequestFrame(); - break; - } - ++iter; + auto video = AceType::DynamicCast(host); + CHECK_NULL_VOID(video); + auto controller = AceType::DynamicCast(video->GetControllerRow()); + CHECK_NULL_VOID(controller); + if (controller) { + auto controllerLayoutProperty = controller->GetLayoutProperty(); + controllerLayoutProperty->UpdateVisibility(VisibleType::INVISIBLE); + controller->MarkModifyDone(); } } } @@ -780,13 +838,14 @@ void VideoPattern::OnAreaChangedInner() } } -RefPtr VideoPattern::CreateControlBar() +RefPtr VideoPattern::CreateControlBar(int32_t nodeId) { auto pipelineContext = PipelineBase::GetCurrentContext(); CHECK_NULL_RETURN(pipelineContext, nullptr); auto videoTheme = pipelineContext->GetTheme(); CHECK_NULL_RETURN(videoTheme, nullptr); - auto controlBar = FrameNode::CreateFrameNode(V2::ROW_ETS_TAG, -1, AceType::MakeRefPtr(false)); + auto controlBar = FrameNode::GetOrCreateFrameNode( + V2::ROW_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(false); }); CHECK_NULL_RETURN(controlBar, nullptr); auto playButton = CreateSVG(); @@ -843,7 +902,6 @@ RefPtr VideoPattern::CreateSlider() SliderOnChangeEvent sliderOnChangeEvent = [weak = WeakClaim(this)](float value, int32_t mode) { auto videoPattern = weak.Upgrade(); CHECK_NULL_VOID(videoPattern); - videoPattern->SetCurrentTime(value); videoPattern->OnSliderChange(value, mode); }; auto sliderEventHub = sliderNode->GetEventHub(); @@ -1000,18 +1058,14 @@ void VideoPattern::Start() CHECK_NULL_VOID(context); auto host = GetHost(); CHECK_NULL_VOID(host); - const auto& children = host->GetChildren(); - auto iter = children.begin(); - while (iter != children.end()) { - if ((*iter)->GetTag() == V2::IMAGE_ETS_TAG) { - iter = host->RemoveChild(*iter); - host->RebuildRenderContextTree(); - context->RequestFrame(); - break; - } - ++iter; - } + auto video = AceType::DynamicCast(host); + CHECK_NULL_VOID(video); + auto image = AceType::DynamicCast(video->GetPreviewImage()); + CHECK_NULL_VOID(image); + auto posterLayoutProperty = image->GetLayoutProperty(); + posterLayoutProperty->UpdateVisibility(VisibleType::INVISIBLE); + image->MarkModifyDone(); auto platformTask = SingleTaskExecutor::Make(context->GetTaskExecutor(), TaskExecutor::TaskType::BACKGROUND); platformTask.PostTask([weak = WeakClaim(RawPtr(mediaPlayer_))] { @@ -1045,7 +1099,6 @@ void VideoPattern::Stop() } OnCurrentTimeChange(0); - OnPlayerStatus(PlaybackStatus::STOPPED); LOGD("Video Stop"); mediaPlayer_->Stop(); isStop_ = true; @@ -1135,7 +1188,7 @@ void VideoPattern::ChangeFullScreenButtonTag(bool isFullScreen, RefPtrIsMediaPlayerValid()) { return; } @@ -1148,7 +1201,7 @@ void VideoPattern::SetCurrentTime(float currentPos, OHOS::Ace::SeekMode seekMode void VideoPattern::OnSliderChange(float posTime, int32_t mode) { LOGD("posTime: %{public}lf, mode: %{public}d", posTime, mode); - SetCurrentTime(posTime); + SetCurrentTime(posTime, OHOS::Ace::SeekMode::SEEK_CLOSEST); auto eventHub = GetEventHub(); auto json = JsonUtil::Create(true); json->Put("time", static_cast(posTime)); @@ -1239,8 +1292,7 @@ void VideoPattern::EnableDrag() imageSrcBefore = layoutProperty->GetPosterImageInfo().value().GetSrc(); } #ifdef ENABLE_DRAG_FRAMEWORK - auto dragEnd = [this, videoSrcBefore]( - const RefPtr& event, const std::string& extraParams) { + auto dragEnd = [this, videoSrcBefore](const RefPtr& event, const std::string& extraParams) { auto videoLayoutProperty = this->GetLayoutProperty(); std::shared_ptr unifiedData = event->GetData(); std::string videoSrc = ""; @@ -1249,7 +1301,7 @@ void VideoPattern::EnableDrag() if (records.size() == 0) { LOGE("unifiedRecords is empty"); } - auto video = reinterpret_cast(records[0].get()); + auto video = reinterpret_cast(records[0].get()); videoSrc = video->GetUri(); } else { auto json = JsonUtil::ParseJsonString(extraParams); @@ -1272,7 +1324,7 @@ void VideoPattern::EnableDrag() }; #else auto dragEnd = [this, videoSrcBefore, imageSrcBefore]( - const RefPtr& event, const std::string& extraParams) { + const RefPtr& event, const std::string& extraParams) { if (extraParams.empty()) { LOGE("extraParams is empty"); return; @@ -1295,7 +1347,7 @@ void VideoPattern::EnableDrag() if (index != 0) { imageSrc = extraInfo.substr(0, index); } - + bool isInitialState = this->isInitialState_; if ((!isInitialState && videoSrc == videoSrcBefore) || (isInitialState && videoSrc == videoSrcBefore && imageSrc == imageSrcBefore)) { diff --git a/frameworks/core/components_ng/pattern/video/video_pattern.h b/frameworks/core/components_ng/pattern/video/video_pattern.h index 593ba7d53b6..732e4dac43f 100644 --- a/frameworks/core/components_ng/pattern/video/video_pattern.h +++ b/frameworks/core/components_ng/pattern/video/video_pattern.h @@ -115,6 +115,8 @@ public: return { FocusType::SCOPE, true }; } + RefPtr CreateControlBar(int32_t nodeId = -1); + void SetHiddenChangeEvent(HiddenChangeEvent&& hiddenChangeEvent) { hiddenChangeEvent_ = std::move(hiddenChangeEvent); @@ -137,7 +139,8 @@ public: void OnAreaChangedInner() override; void UpdateMediaPlayer(); - + void ResetMediaPlayer(); + void EnableDrag(); void SetIsStop(bool isStop) { @@ -185,10 +188,10 @@ private: void OnUpdateTime(uint32_t time, int pos) const; void OnFullScreenChange(bool isFullScreen); - void AddPreviewNodeIfNeeded(); - void AddControlBarNodeIfNeeded(); + void UpdatePreviewImage(); + void UpdateControllerBar(); void UpdateVideoProperty(); - RefPtr CreateControlBar(); + static RefPtr CreateSVG(); static RefPtr CreateText(uint32_t time); RefPtr CreateSlider(); @@ -198,6 +201,7 @@ private: void ChangeFullScreenButtonTag(bool isFullScreen, RefPtr& fullScreenBtn); void ResetStatus(); void HiddenChange(bool hidden); + void PrintPlayerStatus(PlaybackStatus status); // Fire error manually, eg. src is not existed. It must run on ui. void FireError(); diff --git a/frameworks/core/components_ng/test/mock/render/mock_media_player.h b/frameworks/core/components_ng/test/mock/render/mock_media_player.h index 0dfe4e3b022..bc375c48c0d 100644 --- a/frameworks/core/components_ng/test/mock/render/mock_media_player.h +++ b/frameworks/core/components_ng/test/mock/render/mock_media_player.h @@ -23,10 +23,25 @@ #include "core/components_ng/render/media_player.h" namespace OHOS::Ace::NG { +namespace { +constexpr int32_t DEFAULT_WIDTH = 100; +constexpr int32_t DEFAULT_HEIGHT = 100; +} // namespace + class MockMediaPlayer : public MediaPlayer { DECLARE_ACE_TYPE(MockMediaPlayer, MediaPlayer) public: ~MockMediaPlayer() override = default; + + int32_t GetVideoWidth() override + { + return DEFAULT_WIDTH; + } + + int32_t GetVideoHeight() override + { + return DEFAULT_HEIGHT; + } MOCK_METHOD0(IsMediaPlayerValid, bool()); MOCK_METHOD1(SetSource, bool(const std::string&)); @@ -37,8 +52,6 @@ public: MOCK_METHOD0(Prepare, int32_t()); MOCK_METHOD0(Stop, int32_t()); MOCK_METHOD2(Seek, int32_t(int32_t, SeekMode)); - MOCK_METHOD0(GetVideoWidth, int32_t()); - MOCK_METHOD0(GetVideoHeight, int32_t()); }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_MEDIA_PLAYER_H diff --git a/frameworks/core/components_ng/test/pattern/video/BUILD.gn b/frameworks/core/components_ng/test/pattern/video/BUILD.gn index 5e15fc9c82b..694f2673117 100644 --- a/frameworks/core/components_ng/test/pattern/video/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/video/BUILD.gn @@ -70,7 +70,6 @@ ohos_unittest("video_pattern_test_ng") { "$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_abstract.cpp", - "$ace_root/frameworks/core/components_ng/base/view_stack_processor.cpp", # components_ng_event "$ace_root/frameworks/core/components_ng/event/click_event.cpp", @@ -164,6 +163,7 @@ ohos_unittest("video_pattern_test_ng") { "$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/base/mock_localization.cpp", + "$ace_root/frameworks/core/components_ng/test/mock/base/mock_view_stack_processor.cpp", "$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_loading_context.cpp", "$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_painter.cpp", "$ace_root/frameworks/core/components_ng/test/mock/image_provider/mock_image_source_info.cpp", @@ -189,6 +189,7 @@ ohos_unittest("video_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/video/video_accessibility_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/video/video_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/video/video_model_ng.cpp", + "$ace_root/frameworks/core/components_ng/pattern/video/video_node.cpp", "$ace_root/frameworks/core/components_ng/pattern/video/video_pattern.cpp", "video_accessibility_property_test_ng.cpp", "video_pattern_focus_test_ng.cpp", diff --git a/frameworks/core/components_ng/test/pattern/video/video_accessibility_property_test_ng.cpp b/frameworks/core/components_ng/test/pattern/video/video_accessibility_property_test_ng.cpp index aa39f9000c6..45f6cb39563 100644 --- a/frameworks/core/components_ng/test/pattern/video/video_accessibility_property_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/video/video_accessibility_property_test_ng.cpp @@ -70,8 +70,7 @@ RefPtr VideoAccessibilityPropertyTestNg::CreateVideoNode() CHECK_NULL_RETURN(pattern, nullptr); EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) .WillRepeatedly(Return(false)); - - RefPtr element = ViewStackProcessor::GetInstance()->Finish(); + RefPtr element = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_RETURN(element, nullptr); return AceType::DynamicCast(element); } @@ -119,7 +118,6 @@ HWTEST_F(VideoAccessibilityPropertyTestNg, VideoAccessibilityPropertyTest002, Te EXPECT_EQ(accessibilityValue.min, 0); EXPECT_EQ(accessibilityValue.max, 0); EXPECT_EQ(accessibilityValue.current, 0); - auto pattern = frameNode->GetPattern(); ASSERT_NE(pattern, nullptr); EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) @@ -137,4 +135,4 @@ HWTEST_F(VideoAccessibilityPropertyTestNg, VideoAccessibilityPropertyTest002, Te accessibilityValue = videoAccessibilitProperty->GetAccessibilityValue(); EXPECT_EQ(accessibilityValue.current, 0); } -} // namespace OHOS::Ace::NG \ No newline at end of file +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/pattern/video/video_pattern_focus_test_ng.cpp b/frameworks/core/components_ng/test/pattern/video/video_pattern_focus_test_ng.cpp index 2bfda85aeb0..4d747cb6226 100644 --- a/frameworks/core/components_ng/test/pattern/video/video_pattern_focus_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/video/video_pattern_focus_test_ng.cpp @@ -92,18 +92,15 @@ void VideoPatternFocusTestNg::TearDownTestSuite() RefPtr VideoPatternFocusTestNg::CreateVideoNode(TestProperty& testProperty) { - if (testProperty.videoController.has_value()) { - VideoModelNG().Create(testProperty.videoController.value()); - } else { - auto videoController = AceType::MakeRefPtr(); - VideoModelNG().Create(videoController); - } + auto videoController = AceType::MakeRefPtr(); + VideoModelNG().Create(videoController); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_RETURN(frameNode, nullptr); auto videoPattern = AceType::DynamicCast(frameNode->GetPattern()); CHECK_NULL_RETURN(videoPattern, nullptr); EXPECT_CALL(*(AceType::DynamicCast(videoPattern->mediaPlayer_)), IsMediaPlayerValid()) - .WillRepeatedly(Return(false)); + .WillRepeatedly(Return(true)); if (testProperty.src.has_value()) { VideoModelNG().SetSrc(testProperty.src.value()); @@ -126,8 +123,7 @@ RefPtr VideoPatternFocusTestNg::CreateVideoNode(TestProperty& testPro if (testProperty.loop.has_value()) { VideoModelNG().SetLoop(testProperty.loop.value()); } - - RefPtr element = ViewStackProcessor::GetInstance()->Finish(); // pop + RefPtr element = ViewStackProcessor::GetInstance()->GetMainFrameNode(); return AceType::DynamicCast(element); } @@ -158,39 +154,29 @@ HWTEST_F(VideoPatternFocusTestNg, VideoFocusTest001, TestSize.Level1) */ HWTEST_F(VideoPatternFocusTestNg, VideoFocusTest002, TestSize.Level1) { - VideoModelNG video; - auto videoController = AceType::MakeRefPtr(); - video.Create(videoController); - /** * @tc.steps: step1. Create Video * @tc.expected: step1. Create Video successfully */ - auto frameNodeTemp = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - CHECK_NULL_VOID(frameNodeTemp); - auto videoPatternTemp = AceType::DynamicCast(frameNodeTemp->GetPattern()); - CHECK_NULL_VOID(videoPatternTemp); - EXPECT_CALL(*(AceType::DynamicCast(videoPatternTemp->mediaPlayer_)), IsMediaPlayerValid()) - .WillRepeatedly(Return(false)); + auto frameNode = CreateVideoNode(testProperty); + EXPECT_TRUE(frameNode); + EXPECT_EQ(frameNode->GetTag(), V2::VIDEO_ETS_TAG); + frameNode->GetOrCreateFocusHub()->currentFocus_ = true; + auto videoPattern = frameNode->GetPattern(); + CHECK_NULL_VOID(videoPattern); + EXPECT_CALL(*(AceType::DynamicCast(videoPattern->mediaPlayer_)), IsMediaPlayerValid()) + .WillRepeatedly(Return(true)); - // when video set preview image and control, it will contains two children which are image and row respectively. - video.SetPosterSourceInfo(VIDEO_POSTER_URL); - video.SetControls(true); - - auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); - EXPECT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::VIDEO_ETS_TAG); auto videoLayoutProperty = frameNode->GetLayoutProperty(); ASSERT_NE(videoLayoutProperty, nullptr); /** * @tc.steps: step2. Create LayoutWrapper and set videoLayoutAlgorithm. - * @tc.expected: step2. Create video pattern nad node successfully. + * @tc.expected: step2. Create video pattern and node successfully. */ RefPtr geometryNode = AceType::MakeRefPtr(); ASSERT_NE(geometryNode, nullptr); LayoutWrapper layoutWrapper = LayoutWrapper(frameNode, geometryNode, frameNode->GetLayoutProperty()); - auto videoPattern = frameNode->GetPattern(); - ASSERT_NE(videoPattern, nullptr); auto videoLayoutAlgorithm = videoPattern->CreateLayoutAlgorithm(); ASSERT_NE(videoLayoutAlgorithm, nullptr); layoutWrapper.SetLayoutAlgorithm(AceType::MakeRefPtr(videoLayoutAlgorithm)); @@ -211,7 +197,6 @@ HWTEST_F(VideoPatternFocusTestNg, VideoFocusTest002, TestSize.Level1) * @tc.steps: step4. Set the framenode tree, and test the focus. * @tc.expected: step4. Test focus on child successfully. */ - videoPattern->OnModifyDone(); frameNode->GetOrCreateFocusHub()->RequestFocusImmediately(); for (const auto& child : frameNode->GetChildren()) { diff --git a/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp index a374fd5bf45..d3b21553e9d 100644 --- a/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp @@ -130,6 +130,9 @@ void VideoPropertyTestNg::SetUpTestSuite() testProperty.loop = LOOP_VALUE; testProperty.objectFit = VIDEO_IMAGE_FIT; MockPipelineBase::SetUp(); + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr())); } void VideoPropertyTestNg::TearDownTestSuite() @@ -150,7 +153,7 @@ RefPtr VideoPropertyTestNg::CreateVideoNode(TestProperty& testPropert auto videoPattern = AceType::DynamicCast(frameNode->GetPattern()); CHECK_NULL_RETURN(videoPattern, nullptr); EXPECT_CALL(*(AceType::DynamicCast(videoPattern->mediaPlayer_)), IsMediaPlayerValid()) - .WillRepeatedly(Return(false)); + .WillRepeatedly(Return(true)); if (testProperty.src.has_value()) { VideoModelNG().SetSrc(testProperty.src.value()); @@ -177,7 +180,7 @@ RefPtr VideoPropertyTestNg::CreateVideoNode(TestProperty& testPropert VideoModelNG().SetObjectFit(testProperty.objectFit.value()); } - RefPtr element = ViewStackProcessor::GetInstance()->Finish(); // pop + RefPtr element = ViewStackProcessor::GetInstance()->GetMainFrameNode(); return AceType::DynamicCast(element); } @@ -224,7 +227,7 @@ HWTEST_F(VideoPropertyTestNg, VideoPropertyTest002, TestSize.Level1) video.SetLoop(LOOP_VALUE); video.SetObjectFit(VIDEO_IMAGE_FIT); - auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); + auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->GetMainFrameNode()); EXPECT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::VIDEO_ETS_TAG); auto videoLayoutProperty = frameNode->GetLayoutProperty(); EXPECT_FALSE(videoLayoutProperty == nullptr); @@ -272,7 +275,7 @@ HWTEST_F(VideoPropertyTestNg, VideoEventTest003, TestSize.Level1) video.SetOnUpdate(videoEvent); video.SetOnFullScreenChange(videoEvent); - auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); + auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->GetMainFrameNode()); EXPECT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::VIDEO_ETS_TAG); auto videoEventHub = frameNode->GetEventHub(); EXPECT_TRUE(videoEventHub != nullptr); @@ -315,7 +318,7 @@ HWTEST_F(VideoPropertyTestNg, VideoMeasureContentTest004, TestSize.Level1) EXPECT_CALL(*(AceType::DynamicCast(videoPatternTemp->mediaPlayer_)), IsMediaPlayerValid()) .WillRepeatedly(Return(false)); - auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); + auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->GetMainFrameNode()); EXPECT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::VIDEO_ETS_TAG); auto videoLayoutProperty = frameNode->GetLayoutProperty(); EXPECT_FALSE(videoLayoutProperty == nullptr); @@ -375,7 +378,7 @@ HWTEST_F(VideoPropertyTestNg, VideoMeasureTest005, TestSize.Level1) video.SetPosterSourceInfo(VIDEO_POSTER_URL); video.SetControls(CONTROL_VALUE); - auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); + auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->GetMainFrameNode()); EXPECT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::VIDEO_ETS_TAG); auto videoLayoutProperty = frameNode->GetLayoutProperty(); EXPECT_FALSE(videoLayoutProperty == nullptr); @@ -399,8 +402,6 @@ HWTEST_F(VideoPropertyTestNg, VideoMeasureTest005, TestSize.Level1) EXPECT_EQ(videoSize1, SizeF(VIDEO_WIDTH, VIDEO_WIDTH)); layoutWrapper.GetGeometryNode()->SetContentSize(videoSize1); - auto frameNodeRow = FrameNode::CreateFrameNode(V2::ROW_ETS_TAG, -1, AceType::MakeRefPtr()); - frameNode->AddChild(frameNodeRow); const auto& children = frameNode->GetChildren(); for (const auto& child : children) { auto frameNodeChild = AceType::DynamicCast(child); @@ -435,6 +436,10 @@ HWTEST_F(VideoPropertyTestNg, VideoMeasureTest005, TestSize.Level1) */ HWTEST_F(VideoPropertyTestNg, VideoPatternTest006, TestSize.Level1) { + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr())); + /** * @tc.steps: step1. Create Video * @tc.expected: step1. Create Video successfully @@ -446,48 +451,13 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest006, TestSize.Level1) ASSERT_TRUE(pattern); /** - * @tc.steps: step2. Add a child, in order to go to some branches + * @tc.steps: step2. check the children size. */ - auto nodeRedundant = AceType::MakeRefPtr("redundant", -1, AceType::MakeRefPtr()); - frameNode->AddChild(nodeRedundant, 0); - - /** - * @tc.steps: step3. call AddPreviewNodeIfNeeded - * case1: isInitialState_ = true, has not PosterImageInfo - * case2: isInitialState_ = false, has not PosterImageInfo - * case3: isInitialState_ = false, has PosterImageInfo - * case4: isInitialState_ = true, has PosterImageInfo(), previewNode not exist - * case5: isInitialState_ = true, has PosterImageInfo(), previewNode exists - * @tc.expected: step3. previewNode create successfully - */ - pattern->AddPreviewNodeIfNeeded(); // case1 auto children = frameNode->GetChildren(); auto childrenSize = static_cast(children.size()); - EXPECT_EQ(childrenSize, 1); - - pattern->isInitialState_ = false; - pattern->AddPreviewNodeIfNeeded(); // case2 - children = frameNode->GetChildren(); - childrenSize = static_cast(children.size()); - EXPECT_EQ(childrenSize, 1); - - auto videoLayoutProperty = frameNode->GetLayoutProperty(); - videoLayoutProperty->UpdatePosterImageInfo(ImageSourceInfo(VIDEO_POSTER_URL)); - pattern->AddPreviewNodeIfNeeded(); // case3 - children = frameNode->GetChildren(); - childrenSize = static_cast(children.size()); - EXPECT_EQ(childrenSize, 1); - - pattern->isInitialState_ = true; - pattern->AddPreviewNodeIfNeeded(); // case4 - children = frameNode->GetChildren(); - childrenSize = static_cast(children.size()); - EXPECT_EQ(childrenSize, 2); - - pattern->AddPreviewNodeIfNeeded(); // case5 - children = frameNode->GetChildren(); - childrenSize = static_cast(children.size()); EXPECT_EQ(childrenSize, 2); + auto image = frameNode->GetChildAtIndex(0); + EXPECT_EQ(image->GetTag(), V2::IMAGE_ETS_TAG); } /** @@ -507,40 +477,17 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest007, TestSize.Level1) auto pattern = frameNode->GetPattern(); ASSERT_TRUE(pattern); - /** - * @tc.steps: step2. Add a child, in order to go to some branches - */ - auto nodeRedundant = AceType::MakeRefPtr("redundant", -1, AceType::MakeRefPtr()); - frameNode->AddChild(nodeRedundant, 0); - auto themeManager = AceType::MakeRefPtr(); - MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); - EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr())); EXPECT_CALL(*(AceType::DynamicCast(pattern->renderSurface_)), IsSurfaceValid()) .WillOnce(Return(false)); /** - * @tc.steps: step3. call AddControlBarNodeIfNeeded - * case1: ControlsValue = true, controlBar not exist - * case2: ControlsValue = true, controlBar exists - * case3: ControlsValue = false, controlBar exists - * @tc.expected: step3. controlBarNode create and destroy successfully + * @tc.steps: step2. Add a child, in order to go to some branches */ - pattern->AddControlBarNodeIfNeeded(); // case1 auto children = frameNode->GetChildren(); auto childrenSize = static_cast(children.size()); EXPECT_EQ(childrenSize, 2); - - pattern->AddControlBarNodeIfNeeded(); // case2 - children = frameNode->GetChildren(); - childrenSize = static_cast(children.size()); - EXPECT_EQ(childrenSize, 2); - - auto videoLayoutProperty = frameNode->GetLayoutProperty(); - videoLayoutProperty->UpdateControls(false); - pattern->AddControlBarNodeIfNeeded(); // case3 - children = frameNode->GetChildren(); - childrenSize = static_cast(children.size()); - EXPECT_EQ(childrenSize, 1); + auto row = frameNode->GetChildAtIndex(1); + EXPECT_EQ(row->GetTag(), V2::ROW_ETS_TAG); } /** @@ -601,7 +548,7 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest008, TestSize.Level1) * @tc.expected: step5. IsMediaPlayerValid will be called 4 times. */ EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) - .Times(4) + .Times(5) .WillRepeatedly(Return(true)); pattern->UpdateMediaPlayer(); @@ -760,6 +707,9 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest009, TestSize.Level1) */ HWTEST_F(VideoPropertyTestNg, VideoPatternTest010, TestSize.Level1) { + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr())); /** * @tc.steps: step1. Create Video * @tc.expected: step1. Create Video successfully @@ -773,15 +723,9 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest010, TestSize.Level1) /** * @tc.steps: step2. Prepare the childNode & videoEvent */ - auto themeManager = AceType::MakeRefPtr(); - MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); - EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr())); - frameNode->RemoveChildAtIndex(0); // remove the controlBar created in onModifyDone - auto controlBar = pattern->CreateControlBar(); + // frameNode->RemoveChildAtIndex(0); // remove the controlBar created in onModifyDone + auto controlBar = frameNode->GetChildAtIndex(1); ASSERT_TRUE(controlBar); - auto tempFrameNode = AceType::MakeRefPtr("TEMP", -1, AceType::MakeRefPtr()); - frameNode->AddChild(controlBar); // Add ControlBar - frameNode->AddChild(tempFrameNode, 0); // Add a redundant node to go other branch auto playBtn = AceType::DynamicCast(controlBar->GetChildAtIndex(0)); ASSERT_TRUE(playBtn); @@ -817,12 +761,10 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest010, TestSize.Level1) // case1: MediaPlayer is invalid auto flag = playBtnGestureEventHub->ActClick(); EXPECT_TRUE(flag); - // case2: MediaPlayer is valid & isPlaying = true EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), Pause()).Times(1).WillOnce(Return(0)); flag = playBtnGestureEventHub->ActClick(); EXPECT_TRUE(flag); - // case3: MediaPlayer is valid & isPlaying = false pattern->isPlaying_ = false; flag = playBtnGestureEventHub->ActClick(); @@ -836,8 +778,6 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest010, TestSize.Level1) .Times(2) .WillOnce(Return(false)) .WillOnce(Return(true)); - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), GetVideoWidth()).Times(1); - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), GetVideoHeight()).Times(1); // case1: MediaPlayer is invalid pattern->OnPlayerStatus(PlaybackStatus::PREPARED); EXPECT_EQ(pauseCheck, VIDEO_PAUSE_EVENT); @@ -856,7 +796,6 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest010, TestSize.Level1) */ pattern->OnPlayerStatus(PlaybackStatus::PLAYBACK_COMPLETE); // case1: controls = true EXPECT_EQ(finishCheck, VIDEO_FINISH_EVENT); - auto videoLayoutProperty = pattern->GetLayoutProperty(); videoLayoutProperty->UpdateControls(false); pattern->OnPlayerStatus(PlaybackStatus::PLAYBACK_COMPLETE); // case2: controls = false @@ -880,9 +819,6 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest011, TestSize.Level1) auto pattern = frameNode->GetPattern(); ASSERT_TRUE(pattern); - auto tempFrameNode = AceType::MakeRefPtr("TEMP", -1, AceType::MakeRefPtr()); - frameNode->AddChild(tempFrameNode, 0); // Add a redundant node to go other branch - // set videoEvent auto videoEventHub = frameNode->GetEventHub(); ASSERT_TRUE(videoEventHub); @@ -897,8 +833,13 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest011, TestSize.Level1) * case1: needControlBar & needFireEvent = true, isStop_ & autoPlay_ = false * @tc.expected: step2. FirePreparedEvent will be called & duration_ has changed */ + EXPECT_CALL(*(AceType::DynamicCast(pattern->renderSurface_)), IsSurfaceValid()) + .WillOnce(Return(false)); + EXPECT_TRUE(videoLayoutProperty->GetControlsValue(true)); - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()).Times(2); + EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) + .Times(3) + .WillRepeatedly(Return(true)); pattern->OnPrepared(VIDEO_WIDTH, VIDEO_HEIGHT, DURATION, 0, true); EXPECT_EQ(pattern->duration_, DURATION); EXPECT_EQ(preparedCheck, VIDEO_PREPARED_EVENT); @@ -908,12 +849,13 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest011, TestSize.Level1) * case2: needControlBar & needFireEvent = false, isStop_ & autoPlay_ = true * @tc.expected: step3. FirePreparedEvent will not be called & duration_ has changed */ - videoLayoutProperty->UpdateControls(false); preparedCheck.clear(); pattern->duration_ = 0; pattern->isStop_ = true; pattern->autoPlay_ = true; - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()).Times(4); + EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) + .Times(5) + .WillRepeatedly(Return(true)); pattern->OnPrepared(VIDEO_WIDTH, VIDEO_HEIGHT, DURATION, 0, false); EXPECT_EQ(pattern->duration_, DURATION); EXPECT_TRUE(preparedCheck.empty()); @@ -936,10 +878,7 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest012, TestSize.Level1) auto pattern = frameNode->GetPattern(); ASSERT_TRUE(pattern); - auto tempFrameNode = AceType::MakeRefPtr("TEMP", -1, AceType::MakeRefPtr()); - frameNode->AddChild(tempFrameNode, 0); // Add a redundant node to go other branch - auto imageFrameNode = AceType::MakeRefPtr(V2::IMAGE_ETS_TAG, -1, AceType::MakeRefPtr()); - frameNode->AddChild(imageFrameNode); // Add a image node to go other branch + auto imageFrameNode = frameNode->GetChildAtIndex(0); auto rawChildNum = static_cast(frameNode->GetChildren().size()); // set video event @@ -974,36 +913,42 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest012, TestSize.Level1) pattern->Start(); auto childNum = static_cast(frameNode->GetChildren().size()); EXPECT_EQ(childNum, rawChildNum); - } else { - EXPECT_CALL(*(AceType::DynamicCast(pattern->renderSurface_)), IsSurfaceValid()) - .Times(1) - .WillOnce(Return(prepareReturn == 0)); - if (prepareReturn == 0) { - frameNode->AddChild(imageFrameNode); - } - pattern->isPlaying_ = false; - pattern->Start(); // will remove the imageFrameNode - auto childNum = static_cast(frameNode->GetChildren().size()); - EXPECT_EQ(childNum, rawChildNum - 1); } } } /** - * @tc.steps: step3. Call Stop + * @tc.steps: step3. Call Stop when the mediaplayer is not valid. * @tc.expected: step3. relevant functions called correctly */ + pattern->currentPos_ = 10; + pattern->isStop_ = false; EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) .WillOnce(Return(false)); - pattern->Stop(); // case1: media player is invalid + pattern->Stop(); + EXPECT_EQ(static_cast(pattern->currentPos_), 10); + EXPECT_EQ(pattern->isStop_, false); + + /** + * @tc.steps: step3. Call Stop when the mediaplayer is valid. + * @tc.expected: step3. relevant functions called correctly + */ + pattern->currentPos_ = 10; + pattern->isStop_ = false; + pattern->duration_ = 20; + EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) + .WillOnce(Return(true)); + EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), Stop()).WillOnce(Return(0)); + pattern->Stop(); + EXPECT_EQ(static_cast(pattern->currentPos_), 0); + EXPECT_EQ(pattern->isStop_, true); EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) .WillOnce(Return(true)); EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), Stop()).WillOnce(Return(0)); EXPECT_EQ(static_cast(pattern->currentPos_), 0); pattern->Stop(); // case2: media player is valid & currentPos = currentPos_ = 0 - EXPECT_EQ(pauseCheck, VIDEO_PAUSE_EVENT); - EXPECT_TRUE(updateCheck.empty()); + EXPECT_EQ(pattern->isStop_, true); EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) .Times(2) @@ -1017,17 +962,16 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest012, TestSize.Level1) pattern->Stop(); // case3: media player is valid & currentPos != currentPos_ & duration_ = 0 & // mediaPlayer_->GetDuration return ok // this will call OnUpdateTime(pos=DURATION_POS) - EXPECT_EQ(pauseCheck, VIDEO_PAUSE_EVENT); EXPECT_EQ(static_cast(pattern->currentPos_), 1); EXPECT_EQ(updateCheck, ""); - + EXPECT_EQ(pattern->isStop_, true); updateCheck.clear(); pattern->currentPos_ = 1; pattern->Stop(); // case4: media player is valid & currentPos != currentPos_ & duration_ = 0 & // mediaPlayer_->GetDuration return err - EXPECT_EQ(pauseCheck, VIDEO_PAUSE_EVENT); EXPECT_EQ(static_cast(pattern->currentPos_), 1); EXPECT_EQ(updateCheck, ""); + EXPECT_EQ(pattern->isStop_, true); } /** @@ -1179,7 +1123,7 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest013, TestSize.Level1) /** * @tc.name: VideoPatternTest014 - * @tc.desc: Test OnResolutionChange & OnHiddenChange + * @tc.desc: Test OnResolutionChange * @tc.type: FUNC */ HWTEST_F(VideoPropertyTestNg, VideoPatternTest014, TestSize.Level1) @@ -1199,50 +1143,14 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest014, TestSize.Level1) * @tc.expected: step2. related functions will be called */ EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) - .Times(2) - .WillOnce(Return(false)) + .Times(1) .WillOnce(Return(true)); - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), GetVideoWidth()).Times(1); - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), GetVideoHeight()).Times(1); - pattern->OnResolutionChange(); pattern->OnResolutionChange(); - /** - * @tc.steps: step3. Call OnVisibleChange several times - * @tc.expected: step3. related functions will be called - */ - EXPECT_CALL(*(AceType::DynamicCast(pattern->mediaPlayer_)), IsMediaPlayerValid()) - .WillRepeatedly(Return(false)); - pattern->OnModifyDone(); - - pattern->hiddenChangeEvent_ = nullptr; - pattern->OnVisibleChange(false); // case: hiddenChangeEvent_ is null - - pattern->OnModifyDone(); // after that, hiddenChangeEvent is not null - - pattern->isPlaying_ = false; - pattern->OnVisibleChange(false); // case: isPlaying_=false, hidden=true, mediaPlayer is not null - EXPECT_FALSE(pattern->pastPlayingStatus_); - - pattern->isPlaying_ = true; - pattern->OnVisibleChange(false); // case: isPlaying_=true, hidden=true, mediaPlayer is not null - EXPECT_TRUE(pattern->pastPlayingStatus_); - - pattern->isPlaying_ = false; - pattern->OnVisibleChange(false); // // case: isPlaying_=false, hidden = true, pastPlayingStatus_ = true - - pattern->isPlaying_ = true; - pattern->OnVisibleChange(true); // case: isPlaying_=true, hidden = false, pastPlayingStatus_ = true - EXPECT_FALSE(pattern->pastPlayingStatus_); - - pattern->OnVisibleChange(true); // case: isPlaying_=true, hidden = false, pastPlayingStatus_ = false - EXPECT_FALSE(pattern->pastPlayingStatus_); - - pattern->mediaPlayer_ = nullptr; - pattern->isPlaying_ = true; - pattern->OnVisibleChange(false); // case: isPlaying_=true, hidden=true, mediaPlayer is null - pattern->OnVisibleChange(true); // case: isPlaying_=true, hidden=false, mediaPlayer is null - EXPECT_FALSE(pattern->pastPlayingStatus_); + auto videoLayoutProperty = frameNode->GetLayoutProperty(); + EXPECT_TRUE(videoLayoutProperty->HasVideoSize()); + EXPECT_EQ(videoLayoutProperty->GetVideoSizeValue(SizeF(0, 0)).Width(), 100); + EXPECT_EQ(videoLayoutProperty->GetVideoSizeValue(SizeF(0, 0)).Height(), 100); } /** @@ -1268,7 +1176,7 @@ HWTEST_F(VideoPropertyTestNg, VideoFullScreenTest015, TestSize.Level1) EXPECT_CALL(*(AceType::DynamicCast(videoPatternTemp->mediaPlayer_)), IsMediaPlayerValid()) .WillRepeatedly(Return(false)); - auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->Finish()); + auto frameNode = AceType::DynamicCast(ViewStackProcessor::GetInstance()->GetMainFrameNode()); EXPECT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::VIDEO_ETS_TAG); auto videoLayoutProperty = frameNode->GetLayoutProperty(); EXPECT_FALSE(videoLayoutProperty == nullptr); @@ -1445,9 +1353,13 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest017, TestSize.Level1) std::unique_ptr tempPtr = std::make_unique(); videoLayoutProperty->propVideoStyle_ = std::move(tempPtr); videoLayoutProperty->propVideoStyle_->propVideoSize = videoSize; - geometryNode->SetContentSize(SizeF(SCREEN_WIDTH_SMALL, 0.0f)); + geometryNode->SetContentSize(SizeF(SCREEN_WIDTH_SMALL, SCREEN_HEIGHT_SMALL)); auto mockRenderContext = AceType::MakeRefPtr(); videoPattern->renderContextForMediaPlayer_ = mockRenderContext; + EXPECT_CALL(*(AceType::RawPtr(AceType::DynamicCast(videoPattern->renderContextForMediaPlayer_))), + SetBounds(0.0f, 0.0f, SCREEN_WIDTH_SMALL, SCREEN_HEIGHT_SMALL)) + .WillOnce(Return()); + EXPECT_FALSE(videoPattern->OnDirtyLayoutWrapperSwap(layoutWrapper, config)); } @@ -1623,7 +1535,7 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest020, TestSize.Level1) ASSERT_NE(videoPattern, nullptr); videoPattern->src_ = "test"; - videoPattern->OnModifyDone(); + videoPattern->EnableDrag(); auto eventHub = frameNode->GetEventHub(); ASSERT_NE(eventHub, nullptr); auto dragEnd = eventHub->onDrop_; From 639a0770f0ee8813ece68e2a7a2c2db45951b3a2 Mon Sep 17 00:00:00 2001 From: zhoutianer Date: Wed, 24 May 2023 12:20:30 +0800 Subject: [PATCH 57/99] fix drawable crash Signed-off-by: zhoutianer Change-Id: If62abb74ae8619186707696e7c9b3cc7d925c293 --- adapter/ohos/osal/resource_adapter_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/adapter/ohos/osal/resource_adapter_impl.cpp b/adapter/ohos/osal/resource_adapter_impl.cpp index 07e1448d7e3..c0747a57a1a 100644 --- a/adapter/ohos/osal/resource_adapter_impl.cpp +++ b/adapter/ohos/osal/resource_adapter_impl.cpp @@ -465,6 +465,7 @@ std::shared_ptr ResourceAdapterImpl::GetPixelMap(uint32_t resId LOGE("Failed to Create drawableDescriptor by %{public}d", resId); return nullptr; } + CHECK_NULL_RETURN(drawableDescriptor, nullptr); return drawableDescriptor->GetPixelMap(); } From 270a479420c137599f9c7f0fc80e8b1852c38462 Mon Sep 17 00:00:00 2001 From: wangyihui Date: Wed, 24 May 2023 04:24:14 +0000 Subject: [PATCH 58/99] =?UTF-8?q?=E3=80=90drawble=E3=80=91=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=B1=BB=E5=9E=8B=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyihui Change-Id: I6d4f481d135c53347eb0db19ff2a84a29f2ee999 --- .../drawable_descriptor/drawable_descriptor.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/drawable_descriptor/drawable_descriptor.h b/interfaces/inner_api/drawable_descriptor/drawable_descriptor.h index 222400f1736..e367d6f3381 100644 --- a/interfaces/inner_api/drawable_descriptor/drawable_descriptor.h +++ b/interfaces/inner_api/drawable_descriptor/drawable_descriptor.h @@ -108,14 +108,17 @@ public: if (type == "json") { HILOG_DEBUG("Create LayeredDrawableDescriptor object"); drawableType = DrawableDescriptor::DrawableType::LAYERED; + state = Global::Resource::SUCCESS; return std::make_unique(std::move(jsonBuf), len, resourceMgr); } - if (type == "png" || type == "jpg" || type == "bmp" || type == "svg" || type == "gif") { + if (type == "png" || type == "jpg" || type == "bmp" || type == "svg" || type == "gif" || type == "webp") { HILOG_DEBUG("Create DrawableDescriptor object"); drawableType = DrawableDescriptor::DrawableType::BASE; + state = Global::Resource::SUCCESS; return std::make_unique(std::move(jsonBuf), len); } HILOG_ERROR("unknow resource type: %{public}s", type.c_str()); + state = Global::Resource::INVALID_FORMAT; return nullptr; } @@ -134,14 +137,17 @@ public: if (type == "json") { HILOG_DEBUG("Create LayeredDrawableDescriptor object"); drawableType = DrawableDescriptor::DrawableType::LAYERED; + state = Global::Resource::SUCCESS; return std::make_unique(std::move(jsonBuf), len, resourceMgr); } - if (type == "png" || type == "jpg" || type == "bmp" || type == "svg" || type == "gif") { + if (type == "png" || type == "jpg" || type == "bmp" || type == "svg" || type == "gif" || type == "webp") { HILOG_DEBUG("Create DrawableDescriptor object"); drawableType = DrawableDescriptor::DrawableType::BASE; + state = Global::Resource::SUCCESS; return std::make_unique(std::move(jsonBuf), len); } HILOG_ERROR("unknow resource type: %{public}s", type.c_str()); + state = Global::Resource::INVALID_FORMAT; return nullptr; } }; From a80fe2a81e432c769a11459576717b6e999af89f Mon Sep 17 00:00:00 2001 From: caocan Date: Wed, 24 May 2023 14:46:56 +0800 Subject: [PATCH 59/99] fix ToJsonValue of Grid Signed-off-by: caocan Change-Id: Ic20c1408acc87bf5aa3b72f350f2637fc848b794 --- .../pattern/grid/grid_layout_property.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/core/components_ng/pattern/grid/grid_layout_property.cpp b/frameworks/core/components_ng/pattern/grid/grid_layout_property.cpp index df814e489a4..91d2f1d1098 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_layout_property.cpp +++ b/frameworks/core/components_ng/pattern/grid/grid_layout_property.cpp @@ -42,11 +42,11 @@ void GridLayoutProperty::ToJsonValue(std::unique_ptr& json) const json->Put("columnsGap", propColumnsGap_.value_or(0.0_vp).ToString().c_str()); json->Put("rowsGap", propRowsGap_.value_or(0.0_vp).ToString().c_str()); json->Put("cachedCount", propCachedCount_.value_or(1)); - json->Put("editMode ", propEditable_.value_or(false) ? "true" : "false"); - json->Put("layoutDirection ", GetGridDirectionStr().c_str()); - json->Put("maxCount ", propMaxCount_.value_or(Infinity())); - json->Put("minCount ", propMinCount_.value_or(1)); - json->Put("cellLength ", propCellLength_.value_or(0)); + json->Put("editMode", propEditable_.value_or(false) ? "true" : "false"); + json->Put("layoutDirection", GetGridDirectionStr().c_str()); + json->Put("maxCount", propMaxCount_.value_or(Infinity())); + json->Put("minCount", propMinCount_.value_or(1)); + json->Put("cellLength", propCellLength_.value_or(0)); auto edgeEffect = propEdgeEffect_.value_or(EdgeEffect::NONE); if (edgeEffect == EdgeEffect::SPRING) { json->Put("edgeEffect", "EdgeEffect.Spring"); From 6194aed7481f6b9df6df439264f8d1cd2edba3c6 Mon Sep 17 00:00:00 2001 From: jiangdayuan Date: Wed, 24 May 2023 14:56:31 +0800 Subject: [PATCH 60/99] card enable implicit animation in finish callback Signed-off-by: jiangdayuan Change-Id: Iabc6b7631d567c02e5bb59c7eac83a39854a140a --- .../jsview/js_view_context.cpp | 18 +++++++++++++----- frameworks/core/pipeline/pipeline_base.cpp | 12 ++++++++++-- frameworks/core/pipeline/pipeline_base.h | 11 +++++++++++ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp index 282ac6c7ac5..9714b003e75 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp @@ -216,6 +216,10 @@ void JSViewContext::JSAnimation(const JSCallbackInfo& info) CHECK_NULL_VOID(container); auto pipelineContextBase = container->GetPipelineContext(); CHECK_NULL_VOID(pipelineContextBase); + if (pipelineContextBase->GetEnableImplicitAnimation() && pipelineContextBase->IsFormRender()) { + LOGW("Form need enable implicit animation in finish callback."); + return; + } if (info[0]->IsNull() || !info[0]->IsObject()) { ViewContextModel::GetInstance()->closeAnimation(option, true); return; @@ -269,6 +273,15 @@ void JSViewContext::JSAnimateTo(const JSCallbackInfo& info) return; } + auto container = Container::Current(); + CHECK_NULL_VOID(container); + auto pipelineContext = container->GetPipelineContext(); + CHECK_NULL_VOID(pipelineContext); + if (pipelineContext->GetEnableImplicitAnimation() && pipelineContext->IsFormRender()) { + LOGW("Form need enable implicit animation in finish callback."); + return; + } + JSRef obj = JSRef::Cast(info[0]); JSRef onFinish = obj->GetProperty("onFinish"); std::function onFinishEvent; @@ -288,11 +301,6 @@ void JSViewContext::JSAnimateTo(const JSCallbackInfo& info) return; } - auto container = Container::Current(); - CHECK_NULL_VOID(container); - auto pipelineContext = container->GetPipelineContext(); - CHECK_NULL_VOID(pipelineContext); - AnimationOption option = CreateAnimation(animationArgs, pipelineContext->IsFormRender()); if (SystemProperties::GetRosenBackendEnabled()) { bool usingSharedRuntime = container->GetSettings().usingSharedRuntime; diff --git a/frameworks/core/pipeline/pipeline_base.cpp b/frameworks/core/pipeline/pipeline_base.cpp index 2740e0a394d..fcfa9c18acc 100644 --- a/frameworks/core/pipeline/pipeline_base.cpp +++ b/frameworks/core/pipeline/pipeline_base.cpp @@ -502,10 +502,18 @@ void PipelineBase::OpenImplicitAnimation( return; } context->GetTaskExecutor()->PostTask( - [finishCallback]() { - if (finishCallback) { + [finishCallback, weak]() { + auto context = weak.Upgrade(); + CHECK_NULL_VOID(context); + CHECK_NULL_VOID(finishCallback); + if (context->IsFormRender()) { + context->SetEnableImplicitAnimation(true); finishCallback(); + context->FlushBuild(); + context->SetEnableImplicitAnimation(false); + return; } + finishCallback(); }, TaskExecutor::TaskType::UI); }; diff --git a/frameworks/core/pipeline/pipeline_base.h b/frameworks/core/pipeline/pipeline_base.h index 9a8488a528f..acbc1538225 100644 --- a/frameworks/core/pipeline/pipeline_base.h +++ b/frameworks/core/pipeline/pipeline_base.h @@ -842,6 +842,16 @@ public: return ignoreViewSafeArea_; } + void SetEnableImplicitAnimation(bool enableImplicitAnimation) + { + enableImplicitAnimation_ = enableImplicitAnimation; + } + + bool GetEnableImplicitAnimation() const + { + return enableImplicitAnimation_; + } + // restore virtual void RestoreNodeInfo(std::unique_ptr nodeInfo) {} virtual std::unique_ptr GetStoredNodeInfo() @@ -968,6 +978,7 @@ private: OnRouterChangeCallback onRouterChangeCallback_ = nullptr; PostRTTaskCallback postRTTaskCallback_; std::function gsVsyncCallback_; + bool enableImplicitAnimation_ = false; ACE_DISALLOW_COPY_AND_MOVE(PipelineBase); }; From 8019accd22f39b38f4ebd2650237789bdcb3ec9e Mon Sep 17 00:00:00 2001 From: hehongyang9 Date: Wed, 24 May 2023 15:12:48 +0800 Subject: [PATCH 61/99] fix jsAnimator memory leak Signed-off-by: hehongyang9 Change-Id: Ic480a081a9f18d774e89c79163a9950232c3e44d --- interfaces/napi/kits/animator/js_animator.cpp | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/interfaces/napi/kits/animator/js_animator.cpp b/interfaces/napi/kits/animator/js_animator.cpp index a9866675caa..84a772904f8 100644 --- a/interfaces/napi/kits/animator/js_animator.cpp +++ b/interfaces/napi/kits/animator/js_animator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 @@ -220,16 +220,24 @@ static napi_value JSReset(napi_env env, napi_callback_info info) auto curve = Framework::CreateCurve(option->easing); auto animation = AceType::MakeRefPtr>(option->begin, option->end, curve); animation->AddListener([env, onframeRef](double value) { + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + if (scope == nullptr) { + LOGW("JsAnimator: open handle scope failed"); + return; + } napi_value ret = nullptr; napi_value valueNapi = nullptr; napi_value onframe = nullptr; auto result = napi_get_reference_value(env, onframeRef, &onframe); if (result != napi_ok || onframe == nullptr) { - LOGW("get onframe in callback failed"); + LOGW("JsAnimator: get onframe in callback failed"); + napi_close_handle_scope(env, scope); return; } napi_create_double(env, value, &valueNapi); napi_call_function(env, nullptr, onframe, 1, &valueNapi, &ret); + napi_close_handle_scope(env, scope); }); animator->AddInterpolator(animation); } @@ -356,16 +364,24 @@ static napi_value SetOnframe(napi_env env, napi_callback_info info) napi_create_reference(env, onframe, 1, &onframeRef); animatorResult->SetOnframeRef(onframeRef); animation->AddListener([env, onframeRef](double value) { + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + if (scope == nullptr) { + LOGW("JsAnimator: open handle scope failed"); + return; + } napi_value ret = nullptr; napi_value valueNapi = nullptr; napi_value onframe = nullptr; auto result = napi_get_reference_value(env, onframeRef, &onframe); if (result != napi_ok || onframe == nullptr) { - LOGW("get onframe in callback failed"); + LOGW("JsAnimator: get onframe in callback failed"); + napi_close_handle_scope(env, scope); return; } napi_create_double(env, value, &valueNapi); napi_call_function(env, nullptr, onframe, 1, &valueNapi, &ret); + napi_close_handle_scope(env, scope); }); animator->AddInterpolator(animation); if (!animator->HasScheduler()) { @@ -409,15 +425,23 @@ static napi_value SetOnfinish(napi_env env, napi_callback_info info) animatorResult->SetOnfinishRef(onfinishRef); animator->ClearStopListeners(); animator->AddStopListener([env, onfinishRef] { - LOGI("JsAnimator: onfinish->AddIdleListener"); + LOGI("JsAnimator: onfinish"); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + if (scope == nullptr) { + LOGW("JsAnimator: open handle scope failed"); + return; + } napi_value ret = nullptr; napi_value onfinish = nullptr; auto result = napi_get_reference_value(env, onfinishRef, &onfinish); if (result != napi_ok || onfinish == nullptr) { - LOGW("get onfinish in callback failed"); + LOGW("JsAnimator: get onfinish in callback failed"); + napi_close_handle_scope(env, scope); return; } napi_call_function(env, NULL, onfinish, 0, NULL, &ret); + napi_close_handle_scope(env, scope); }); napi_value undefined; napi_get_undefined(env, &undefined); @@ -457,15 +481,23 @@ static napi_value SetOncancel(napi_env env, napi_callback_info info) animatorResult->SetOncancelRef(oncancelRef); animator->ClearIdleListeners(); animator->AddIdleListener([env, oncancelRef] { - LOGI("JsAnimator: oncancel->AddIdleListener"); + LOGI("JsAnimator: oncancel"); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + if (scope == nullptr) { + LOGW("JsAnimator: open handle scope failed"); + return; + } napi_value ret = nullptr; napi_value oncancel = nullptr; auto result = napi_get_reference_value(env, oncancelRef, &oncancel); if (result != napi_ok || oncancel == nullptr) { - LOGW("get oncancel in callback failed"); + LOGW("JsAnimator: get oncancel in callback failed"); + napi_close_handle_scope(env, scope); return; } napi_call_function(env, NULL, oncancel, 0, NULL, &ret); + napi_close_handle_scope(env, scope); }); napi_value undefined; napi_get_undefined(env, &undefined); @@ -505,15 +537,23 @@ static napi_value SetOnrepeat(napi_env env, napi_callback_info info) animatorResult->SetOnrepeatRef(onrepeatRef); animator->ClearRepeatListeners(); animator->AddRepeatListener([env, onrepeatRef] { - LOGI("JsAnimator: onrepeat->AddIdleListener"); + LOGI("JsAnimator: onrepeat"); + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + if (scope == nullptr) { + LOGW("JsAnimator: open handle scope failed"); + return; + } napi_value ret = nullptr; napi_value onrepeat = nullptr; auto result = napi_get_reference_value(env, onrepeatRef, &onrepeat); if (result != napi_ok || onrepeat == nullptr) { - LOGW("get onrepeat in callback failed"); + LOGW("JsAnimator: get onrepeat in callback failed"); + napi_close_handle_scope(env, scope); return; } napi_call_function(env, NULL, onrepeat, 0, NULL, &ret); + napi_close_handle_scope(env, scope); }); napi_value undefined; napi_get_undefined(env, &undefined); From 6eb3fb25e1df1d21d18b69048e350d3ce5e328ed Mon Sep 17 00:00:00 2001 From: zhoutianer Date: Wed, 24 May 2023 11:22:01 +0800 Subject: [PATCH 62/99] fix border xts Signed-off-by: zhoutianer Change-Id: Ib6ee53abcc2da4e8972ff6114801efebf6cc5a4f Signed-off-by: zhoutianer --- .../core/components_ng/base/view_abstract.cpp | 1 - .../base/view_abstract_model_ng.h | 7 +- .../core/components_ng/property/BUILD.gn | 1 + .../property/border_property.cpp | 203 ++++++++++++++++++ .../components_ng/property/border_property.h | 118 +++++----- .../components_ng/render/render_property.h | 45 +--- .../accessibility/accessibilitynode/BUILD.gn | 1 + .../accessibility/accessibilityutils/BUILD.gn | 1 + .../test/base/frame_node/BUILD.gn | 1 + .../test/base/geometry_node/BUILD.gn | 1 + .../test/base/inspector/BUILD.gn | 1 + .../components_ng/test/base/ui_node/BUILD.gn | 1 + .../test/base/view_abstract/BUILD.gn | 1 + .../test/base/view_abstract_model/BUILD.gn | 1 + .../base/view_full_update_model_ng/BUILD.gn | 1 + .../view_partial_update_model_ng/BUILD.gn | 1 + .../test/base/view_stack_processor/BUILD.gn | 1 + .../test/event/click_event/BUILD.gn | 1 + .../test/event/drag_event/BUILD.gn | 1 + .../test/event/event_hub/BUILD.gn | 1 + .../test/event/focus_hub/BUILD.gn | 1 + .../test/event/gesture_event_hub/BUILD.gn | 1 + .../test/event/input_event_hub/BUILD.gn | 1 + .../test/event/long_press_event/BUILD.gn | 1 + .../test/event/pan_event/BUILD.gn | 1 + .../test/event/scrollable_event/BUILD.gn | 1 + .../test/event/touch_event/BUILD.gn | 1 + .../test/image_provider/BUILD.gn | 1 + .../test/layout/box_layout_algorithm/BUILD.gn | 1 + .../test/layout/layout_property/BUILD.gn | 1 + .../test/layout/layout_wrapper/BUILD.gn | 1 + .../layout/layout_wrapper_builder/BUILD.gn | 1 + .../test/manager/shared_overlay/BUILD.gn | 1 + .../test/pattern/ability_component/BUILD.gn | 1 + .../components_ng/test/pattern/badge/BUILD.gn | 1 + .../components_ng/test/pattern/blank/BUILD.gn | 1 + .../test/pattern/bubble/BUILD.gn | 1 + .../test/pattern/button/BUILD.gn | 1 + .../test/pattern/calendar/BUILD.gn | 1 + .../test/pattern/checkbox/BUILD.gn | 1 + .../test/pattern/checkboxgroup/BUILD.gn | 1 + .../test/pattern/container_modal/BUILD.gn | 1 + .../test/pattern/counter/BUILD.gn | 1 + .../test/pattern/custom_dialog/BUILD.gn | 1 + .../test/pattern/data_panel/BUILD.gn | 1 + .../test/pattern/divider/BUILD.gn | 1 + .../components_ng/test/pattern/flex/BUILD.gn | 1 + .../components_ng/test/pattern/form/BUILD.gn | 1 + .../components_ng/test/pattern/gauge/BUILD.gn | 1 + .../components_ng/test/pattern/grid/BUILD.gn | 1 + .../test/pattern/grid_col/BUILD.gn | 1 + .../test/pattern/hyperlink/BUILD.gn | 1 + .../components_ng/test/pattern/image/BUILD.gn | 1 + .../test/pattern/indexer/BUILD.gn | 1 + .../test/pattern/linear_layout/BUILD.gn | 1 + .../test/pattern/linear_split/BUILD.gn | 1 + .../components_ng/test/pattern/list/BUILD.gn | 1 + .../components_ng/test/pattern/menu/BUILD.gn | 1 + .../test/pattern/navigation/BUILD.gn | 1 + .../test/pattern/overlay/BUILD.gn | 1 + .../test/pattern/patternlock/BUILD.gn | 1 + .../test/pattern/picker/BUILD.gn | 1 + .../test/pattern/plugin/BUILD.gn | 1 + .../test/pattern/qrcode/BUILD.gn | 1 + .../components_ng/test/pattern/radio/BUILD.gn | 1 + .../test/pattern/rating/BUILD.gn | 1 + .../test/pattern/refresh/BUILD.gn | 1 + .../test/pattern/scroll/BUILD.gn | 1 + .../test/pattern/search/BUILD.gn | 1 + .../test/pattern/security_component/BUILD.gn | 1 + .../test/pattern/select/BUILD.gn | 1 + .../test/pattern/select_overlay/BUILD.gn | 1 + .../test/pattern/side_bar/BUILD.gn | 1 + .../test/pattern/stepper/BUILD.gn | 1 + .../test/pattern/swiper/BUILD.gn | 1 + .../components_ng/test/pattern/tabs/BUILD.gn | 1 + .../components_ng/test/pattern/text/BUILD.gn | 1 + .../test/pattern/text_clock/BUILD.gn | 1 + .../test/pattern/textfield/BUILD.gn | 1 + .../test/pattern/texttimer/BUILD.gn | 1 + .../test/pattern/toggle/BUILD.gn | 1 + .../components_ng/test/pattern/video/BUILD.gn | 1 + .../test/pattern/xcomponent/BUILD.gn | 1 + .../test/property/accessibility/BUILD.gn | 1 + .../test/property/calc_length/BUILD.gn | 1 + .../test/property/gradient/BUILD.gn | 1 + .../test/property/grid_property/BUILD.gn | 1 + .../test/property/measure_utils/BUILD.gn | 1 + .../test/property/property_test/BUILD.gn | 1 + .../test/syntax/for_each/BUILD.gn | 1 + .../test/syntax/if_else/BUILD.gn | 1 + .../test/syntax/lazy_for_each/BUILD.gn | 1 + test/unittest/BUILD.gn | 1 + .../core/pattern/window_scene/BUILD.gn | 1 + test/unittest/core/pipeline/BUILD.gn | 1 + .../core/render/render_context/BUILD.gn | 1 + 96 files changed, 363 insertions(+), 102 deletions(-) create mode 100644 frameworks/core/components_ng/property/border_property.cpp diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 6b7a5d4783c..429fa0cfd5e 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -424,7 +424,6 @@ void ViewAbstract::SetBorderRadius(const Dimension& value) } BorderRadiusProperty borderRadius; borderRadius.SetRadius(value); - borderRadius.SetRadiusFlag(true); ACE_UPDATE_RENDER_CONTEXT(BorderRadius, borderRadius); } diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.h b/frameworks/core/components_ng/base/view_abstract_model_ng.h index b3506f17e80..080a95151bb 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.h +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.h @@ -135,7 +135,7 @@ public: { ViewAbstract::SetForegroundBlurStyle(fgBlurStyle); } - + void SetSphericalEffect(double radio) override { ViewAbstract::SetSphericalEffect(radio); @@ -257,6 +257,7 @@ public: borderRadius.radiusTopRight = radiusTopRight; borderRadius.radiusBottomLeft = radiusBottomLeft; borderRadius.radiusBottomRight = radiusBottomRight; + borderRadius.multiValued = true; ViewAbstract::SetBorderRadius(borderRadius); } @@ -272,6 +273,7 @@ public: borderColors.rightColor = colorRight; borderColors.topColor = colorTop; borderColors.bottomColor = colorBottom; + borderColors.multiValued = true; ViewAbstract::SetBorderColor(borderColors); } @@ -288,6 +290,7 @@ public: borderWidth.rightDimen = right; borderWidth.topDimen = top; borderWidth.bottomDimen = bottom; + borderWidth.multiValued = true; ViewAbstract::SetBorderWidth(borderWidth); } @@ -304,6 +307,7 @@ public: borderStyles.styleRight = styleRight.value_or(BorderStyle::SOLID); borderStyles.styleTop = styleTop.value_or(BorderStyle::SOLID); borderStyles.styleBottom = styleBottom.value_or(BorderStyle::SOLID); + borderStyles.multiValued = true; ViewAbstract::SetBorderStyle(borderStyles); } @@ -821,6 +825,7 @@ public: { ViewAbstract::SetForegroundColorStrategy(strategy); } + private: void RegisterMenuAppearCallback( std::vector& params, std::function&& buildFunc, const MenuParam& menuParam); diff --git a/frameworks/core/components_ng/property/BUILD.gn b/frameworks/core/components_ng/property/BUILD.gn index 4328aa11917..f960fce7b9f 100644 --- a/frameworks/core/components_ng/property/BUILD.gn +++ b/frameworks/core/components_ng/property/BUILD.gn @@ -17,6 +17,7 @@ import( build_component_ng("property_ng") { sources = [ "accessibility_property.cpp", + "border_property.cpp", "calc_length.cpp", "gradient_property.cpp", "grid_property.cpp", diff --git a/frameworks/core/components_ng/property/border_property.cpp b/frameworks/core/components_ng/property/border_property.cpp new file mode 100644 index 00000000000..19f7a2ae2e9 --- /dev/null +++ b/frameworks/core/components_ng/property/border_property.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "border_property.h" + +namespace OHOS::Ace::NG { +void BorderStyleProperty::ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + static const char* BORDER_STYLE[] = { + "BorderStyle.Solid", + "BorderStyle.Dashed", + "BorderStyle.Dotted", + "BorderStyle.None", + }; + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("left", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); + res->Put("top", BORDER_STYLE[static_cast(styleTop.value_or(BorderStyle::SOLID))]); + res->Put("right", BORDER_STYLE[static_cast(styleRight.value_or(BorderStyle::SOLID))]); + res->Put("bottom", BORDER_STYLE[static_cast(styleBottom.value_or(BorderStyle::SOLID))]); + + json->Put("borderStyle", res); + borderJson->Put("style", res); + } else { + json->Put("borderStyle", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); + borderJson->Put("style", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); + } +} + +std::string BorderWidthPropertyT::ToString() const +{ + std::string str; + str.append("leftDimen: [").append(leftDimen.has_value() ? leftDimen->ToString() : "NA").append("]"); + str.append("rightDimen: [").append(rightDimen.has_value() ? rightDimen->ToString() : "NA").append("]"); + str.append("topDimen: [").append(topDimen.has_value() ? topDimen->ToString() : "NA").append("]"); + str.append("bottomDimen: [").append(bottomDimen.has_value() ? bottomDimen->ToString() : "NA").append("]"); + return str; +} + +void BorderWidthPropertyT::ToJsonValue( + std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("left", leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("top", topDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("right", rightDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("bottom", bottomDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + + borderJson->Put("width", res); + json->Put("borderWidth", borderJson); + } else { + auto left = leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString(); + borderJson->Put("width", left.c_str()); + json->Put("borderWidth", left.c_str()); + } +} + +bool BorderWidthPropertyT::UpdateWithCheck(const BorderWidthPropertyT& value) +{ + bool isModified = false; + if (value.leftDimen.has_value() && (leftDimen != value.leftDimen)) { + leftDimen = value.leftDimen; + isModified = true; + } + if (value.rightDimen.has_value() && (rightDimen != value.rightDimen)) { + rightDimen = value.rightDimen; + isModified = true; + } + if (value.topDimen.has_value() && (topDimen != value.topDimen)) { + topDimen = value.topDimen; + isModified = true; + } + if (value.bottomDimen.has_value() && (bottomDimen != value.bottomDimen)) { + bottomDimen = value.bottomDimen; + isModified = true; + } + return isModified; +} + +void BorderColorProperty::ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("left", leftColor.value_or(Color()).ColorToString().c_str()); + res->Put("right", rightColor.value_or(Color()).ColorToString().c_str()); + res->Put("top", topColor.value_or(Color()).ColorToString().c_str()); + res->Put("bottom", bottomColor.value_or(Color()).ColorToString().c_str()); + + borderJson->Put("color", res); + json->Put("borderColor", res); + } else { + auto left = leftColor.value_or(Color()).ColorToString(); + borderJson->Put("color", left.c_str()); + json->Put("borderColor", left.c_str()); + } +} + +std::string BorderColorProperty::ToString() const +{ + std::string str; + str.append("leftColor: [").append(leftColor.has_value() ? leftColor->ColorToString() : "NA").append("]"); + str.append("rightColor: [").append(rightColor.has_value() ? rightColor->ColorToString() : "NA").append("]"); + str.append("topColor: [").append(topColor.has_value() ? topColor->ColorToString() : "NA").append("]"); + str.append("bottomColor: [").append(bottomColor.has_value() ? bottomColor->ColorToString() : "NA").append("]"); + return str; +} + +void BorderRadiusPropertyT::ToJsonValue( + std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("topLeft", radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("topRight", radiusTopRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("bottomLeft", radiusBottomLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("bottomRight", radiusBottomRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + + json->Put("borderRadius", res); + borderJson->Put("radius", res); + } else { + auto left = radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString(); + json->Put("borderRadius", left.c_str()); + borderJson->Put("radius", left.c_str()); + } +} + +bool BorderRadiusPropertyT::UpdateWithCheck(const BorderRadiusPropertyT& value) +{ + bool isModified = false; + if (value.radiusTopLeft.has_value() && (radiusTopLeft != value.radiusTopLeft)) { + radiusTopLeft = value.radiusTopLeft; + isModified = true; + } + if (value.radiusTopRight.has_value() && (radiusTopRight != value.radiusTopRight)) { + radiusTopRight = value.radiusTopRight; + isModified = true; + } + if (value.radiusBottomLeft.has_value() && (radiusBottomLeft != value.radiusBottomLeft)) { + radiusBottomLeft = value.radiusBottomLeft; + isModified = true; + } + if (value.radiusBottomRight.has_value() && (radiusBottomRight != value.radiusBottomRight)) { + radiusBottomRight = value.radiusBottomRight; + isModified = true; + } + return isModified; +} + +void BorderStyleProperty::SetBorderStyle(const BorderStyle& borderStyle) +{ + styleLeft = borderStyle; + styleRight = borderStyle; + styleTop = borderStyle; + styleBottom = borderStyle; +} + +bool BorderStyleProperty::operator==(const BorderStyleProperty& value) const +{ + return (styleLeft == value.styleLeft) && (styleRight == value.styleRight) && (styleTop == value.styleTop) && + (styleBottom == value.styleBottom); +} + +void BorderWidthPropertyT::SetBorderWidth(const Dimension& borderWidth) +{ + leftDimen = borderWidth; + rightDimen = borderWidth; + topDimen = borderWidth; + bottomDimen = borderWidth; +} + +bool BorderWidthPropertyT::operator==(const BorderWidthPropertyT& value) const +{ + return (leftDimen == value.leftDimen) && (rightDimen == value.rightDimen) && (topDimen == value.topDimen) && + (bottomDimen == value.bottomDimen); +} + +void BorderRadiusPropertyT::SetRadius(const Dimension& borderRadius) +{ + radiusTopLeft = borderRadius; + radiusTopRight = borderRadius; + radiusBottomLeft = borderRadius; + radiusBottomRight = borderRadius; +} + +bool BorderRadiusPropertyT::operator==(const BorderRadiusPropertyT& value) const +{ + return (radiusTopLeft == value.radiusTopLeft) && (radiusTopRight == value.radiusTopRight) && + (radiusBottomLeft == value.radiusBottomLeft) && (radiusBottomRight == value.radiusBottomRight); +} +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/property/border_property.h b/frameworks/core/components_ng/property/border_property.h index 3a0cc479d6f..83f00032de7 100644 --- a/frameworks/core/components_ng/property/border_property.h +++ b/frameworks/core/components_ng/property/border_property.h @@ -20,7 +20,6 @@ #include "base/geometry/dimension.h" #include "base/json/json_util.h" -#include "base/utils/utils.h" #include "core/components/common/layout/constants.h" #include "core/components/common/properties/color.h" @@ -32,7 +31,6 @@ struct BorderRadiusPropertyT { std::optional radiusTopRight; std::optional radiusBottomRight; std::optional radiusBottomLeft; - std::optional radiusFlag; void SetRadius(const T& borderRadius) { @@ -42,12 +40,6 @@ struct BorderRadiusPropertyT { radiusBottomRight = borderRadius; } - // This function is used when the input value is length - void SetRadiusFlag(bool flag) - { - radiusFlag = flag; - } - bool operator==(const BorderRadiusPropertyT& value) const { return (radiusTopLeft == value.radiusTopLeft) && (radiusTopRight == value.radiusTopRight) && @@ -93,6 +85,23 @@ struct BorderRadiusPropertyT { } }; +template<> +struct BorderRadiusPropertyT { + std::optional radiusTopLeft; + std::optional radiusTopRight; + std::optional radiusBottomRight; + std::optional radiusBottomLeft; + bool multiValued = false; + + bool operator==(const BorderRadiusPropertyT& value) const; + + void SetRadius(const Dimension& borderRadius); + + bool UpdateWithCheck(const BorderRadiusPropertyT& value); + + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; +}; + template<> struct BorderRadiusPropertyT { std::optional radiusTopLeft; @@ -148,14 +157,14 @@ struct BorderRadiusPropertyT { } }; -template -struct BorderColorPropertyT { - std::optional leftColor; - std::optional rightColor; - std::optional topColor; - std::optional bottomColor; +struct BorderColorProperty { + std::optional leftColor; + std::optional rightColor; + std::optional topColor; + std::optional bottomColor; + bool multiValued = false; - void SetColor(const T& borderColor) + void SetColor(const Color& borderColor) { leftColor = borderColor; rightColor = borderColor; @@ -163,21 +172,15 @@ struct BorderColorPropertyT { bottomColor = borderColor; } - bool operator==(const BorderColorPropertyT& value) const + bool operator==(const BorderColorProperty& value) const { return (leftColor == value.leftColor) && (rightColor == value.rightColor) && (topColor == value.topColor) && (bottomColor == value.bottomColor); } - std::string ToString() const - { - std::string str; - str.append("leftColor: [").append(leftColor.has_value() ? leftColor->ToString() : "NA").append("]"); - str.append("rightColor: [").append(rightColor.has_value() ? rightColor->ToString() : "NA").append("]"); - str.append("topColor: [").append(topColor.has_value() ? topColor->ToString() : "NA").append("]"); - str.append("bottomColor: [").append(bottomColor.has_value() ? bottomColor->ToString() : "NA").append("]"); - return str; - } + std::string ToString() const; + + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; }; template @@ -222,21 +225,30 @@ struct BorderWidthPropertyT { } return isModified; } +}; - std::string ToString() const - { - std::string str; - str.append("leftDimen: [").append(leftDimen.has_value() ? leftDimen->ToString() : "NA").append("]"); - str.append("rightDimen: [").append(rightDimen.has_value() ? rightDimen->ToString() : "NA").append("]"); - str.append("topDimen: [").append(topDimen.has_value() ? topDimen->ToString() : "NA").append("]"); - str.append("bottomDimen: [").append(bottomDimen.has_value() ? bottomDimen->ToString() : "NA").append("]"); - return str; - } +template<> +struct BorderWidthPropertyT { + std::optional leftDimen; + std::optional topDimen; + std::optional rightDimen; + std::optional bottomDimen; + bool multiValued = true; + + void SetBorderWidth(const Dimension& borderWidth); + + bool operator==(const BorderWidthPropertyT& value) const; + + bool UpdateWithCheck(const BorderWidthPropertyT& value); void ToJsonValue(std::unique_ptr& json) const { json->Put("borderWidth", leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); } + + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; + + std::string ToString() const; }; template<> @@ -290,44 +302,24 @@ struct BorderWidthPropertyT { } }; -template -struct BorderStylePropertyT { - std::optional styleLeft; - std::optional styleRight; - std::optional styleTop; - std::optional styleBottom; +struct BorderStyleProperty { + std::optional styleLeft; + std::optional styleRight; + std::optional styleTop; + std::optional styleBottom; + bool multiValued = false; - void SetBorderStyle(const T& borderStyle) - { - styleLeft = borderStyle; - styleRight = borderStyle; - styleTop = borderStyle; - styleBottom = borderStyle; - } + void SetBorderStyle(const BorderStyle& borderStyle); - bool operator==(const BorderStylePropertyT& value) const - { - return (styleLeft == value.styleLeft) && (styleRight == value.styleRight) && (styleTop == value.styleTop) && - (styleBottom == value.styleBottom); - } + bool operator==(const BorderStyleProperty& value) const; - std::string ToString() const - { - std::string str; - str.append("styleLeft: [").append(styleLeft.has_value() ? styleLeft->ToString() : "NA").append("]"); - str.append("styleRight: [").append(styleRight.has_value() ? styleRight->ToString() : "NA").append("]"); - str.append("styleTop: [").append(styleTop.has_value() ? styleTop->ToString() : "NA").append("]"); - str.append("styleBottom: [").append(styleBottom.has_value() ? styleBottom->ToString() : "NA").append("]"); - return str; - } + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; }; using BorderRadiusPropertyF = BorderRadiusPropertyT; using BorderRadiusProperty = BorderRadiusPropertyT; -using BorderColorProperty = BorderColorPropertyT; using BorderWidthPropertyF = BorderWidthPropertyT; using BorderWidthProperty = BorderWidthPropertyT; -using BorderStyleProperty = BorderStylePropertyT; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/render/render_property.h b/frameworks/core/components_ng/render/render_property.h index d24a1781298..842651a00c6 100644 --- a/frameworks/core/components_ng/render/render_property.h +++ b/frameworks/core/components_ng/render/render_property.h @@ -18,14 +18,14 @@ #include "base/geometry/ng/offset_t.h" #include "base/geometry/ng/vector.h" +#include "core/components/common/properties/clip_path.h" #include "core/components/common/properties/color.h" #include "core/components/common/properties/decoration.h" #include "core/components/common/properties/shadow.h" -#include "core/components/common/properties/clip_path.h" #include "core/components_ng/property/border_property.h" +#include "core/components_ng/property/gradient_property.h" #include "core/components_ng/property/overlay_property.h" #include "core/components_ng/property/property.h" -#include "core/components_ng/property/gradient_property.h" #include "core/components_ng/property/transition_property.h" #include "core/image/image_source_info.h" @@ -126,42 +126,13 @@ struct BorderProperty { void ToJsonValue(std::unique_ptr& json) const { - static const char* BORDER_STYLE[] = { - "BorderStyle.Solid", - "BorderStyle.Dashed", - "BorderStyle.Dotted", - }; - json->Put("borderStyle", - BORDER_STYLE[static_cast( - propBorderStyle.value_or(BorderStyleProperty()).styleLeft.value_or(BorderStyle::SOLID))]); - json->Put("borderColor", - propBorderColor.value_or(BorderColorProperty()).leftColor.value_or(Color()).ColorToString().c_str()); auto jsonBorder = JsonUtil::Create(true); - jsonBorder->Put("width", propBorderWidth.value_or(BorderWidthProperty()) - .leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonBorder->Put("color", - propBorderColor.value_or(BorderColorProperty()).leftColor.value_or(Color()).ColorToString().c_str()); - jsonBorder->Put("style", - BORDER_STYLE[static_cast( - propBorderStyle.value_or(BorderStyleProperty()).styleLeft.value_or(BorderStyle::SOLID))]); - if (propBorderRadius.value_or(BorderRadiusProperty()).radiusFlag) { - json->Put("borderRadius", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonBorder->Put("radius", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - } else { - auto jsonRadius = JsonUtil::Create(true); - jsonRadius->Put("topLeft", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonRadius->Put("topRight", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonRadius->Put("bottomLeft", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusBottomLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonRadius->Put("bottomRight", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusBottomRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - json->Put("borderRadius", jsonRadius); - jsonBorder->Put("radius", jsonRadius); - } + + propBorderStyle.value_or(BorderStyleProperty()).ToJsonValue(json, jsonBorder); + propBorderColor.value_or(BorderColorProperty()).ToJsonValue(json, jsonBorder); + propBorderWidth.value_or(BorderWidthProperty()).ToJsonValue(json, jsonBorder); + propBorderRadius.value_or(BorderRadiusProperty()).ToJsonValue(json, jsonBorder); + json->Put("border", jsonBorder->ToString().c_str()); } }; diff --git a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn index 896a602882c..8268b99e63c 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("accessibility_node_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn index e04123b6cee..0afe19f8758 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("accessibility_utils_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/frame_node/BUILD.gn b/frameworks/core/components_ng/test/base/frame_node/BUILD.gn index e5c6c3991dc..50202bb5cb3 100644 --- a/frameworks/core/components_ng/test/base/frame_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/frame_node/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("frame_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn b/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn index 3f3cf6efb73..23931c6903b 100644 --- a/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("geometry_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/inspector/BUILD.gn b/frameworks/core/components_ng/test/base/inspector/BUILD.gn index 1d2aab9df67..7828ee40902 100755 --- a/frameworks/core/components_ng/test/base/inspector/BUILD.gn +++ b/frameworks/core/components_ng/test/base/inspector/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("inspector_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/ui_node/BUILD.gn b/frameworks/core/components_ng/test/base/ui_node/BUILD.gn index 8b0970cbaf5..373bb3374c6 100644 --- a/frameworks/core/components_ng/test/base/ui_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/ui_node/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ui_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn b/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn index 4c19cf43d08..d5992c85f6f 100755 --- a/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("view_abstract_test") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn b/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn index a98950e7370..bb7dbc18f7d 100755 --- a/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("view_abstract_model_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn b/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn index 602c29a5887..c90a9b9fa73 100755 --- a/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("view_full_update_model_ng_test") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn b/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn index d46645cdccf..af7c127a4da 100644 --- a/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("view_partial_update_model_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn b/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn index 14b88d04455..ce5feff939d 100644 --- a/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("view_stack_processor_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/event/click_event/BUILD.gn b/frameworks/core/components_ng/test/event/click_event/BUILD.gn index 37ab3fb469c..3d6ed144e9d 100644 --- a/frameworks/core/components_ng/test/event/click_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/click_event/BUILD.gn @@ -38,6 +38,7 @@ ohos_unittest("click_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/drag_event/BUILD.gn b/frameworks/core/components_ng/test/event/drag_event/BUILD.gn index 468de38c3f2..cfce2c1fb98 100644 --- a/frameworks/core/components_ng/test/event/drag_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/drag_event/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("drag_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/event_hub/BUILD.gn index c064d51268e..80ff433f50d 100644 --- a/frameworks/core/components_ng/test/event/event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/event_hub/BUILD.gn @@ -36,6 +36,7 @@ ohos_unittest("event_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn b/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn index 15551a8d95d..3348b04a9a9 100644 --- a/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("focus_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn index 4b4a69224a8..5360cc398b7 100644 --- a/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn @@ -35,6 +35,7 @@ ohos_unittest("gesture_event_hub_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp", "$ace_root/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp", "$ace_root/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn index dae19d3112d..9c08006011d 100644 --- a/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn @@ -32,6 +32,7 @@ ohos_unittest("input_event_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn b/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn index d033845f1b7..5fd74698775 100644 --- a/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("long_press_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/pan_event/BUILD.gn b/frameworks/core/components_ng/test/event/pan_event/BUILD.gn index c7d7d01792d..f127ca39473 100644 --- a/frameworks/core/components_ng/test/event/pan_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/pan_event/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("pan_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn b/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn index 0868a340371..01ec49d831c 100644 --- a/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("scrollable_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/touch_event/BUILD.gn b/frameworks/core/components_ng/test/event/touch_event/BUILD.gn index 044473ab349..e3a470f7fc8 100644 --- a/frameworks/core/components_ng/test/event/touch_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/touch_event/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("touch_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/image_provider/BUILD.gn b/frameworks/core/components_ng/test/image_provider/BUILD.gn index 4e5c511cdf8..28aa4ea88d9 100644 --- a/frameworks/core/components_ng/test/image_provider/BUILD.gn +++ b/frameworks/core/components_ng/test/image_provider/BUILD.gn @@ -92,6 +92,7 @@ ohos_unittest("image_provider_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn b/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn index 2730f731d56..b913c0a7df1 100755 --- a/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("box_layout_algorithm_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn index bfeaeb91ba0..56db0446cb4 100755 --- a/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("layout_property_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/syntax/for_each_node.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn index 2941ac20a53..34bec3012cc 100755 --- a/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("layout_wrapper_test_ng") { "$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/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn index d7bedcf56ca..cdad88ebf3c 100755 --- a/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("layout_wrapper_build_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn b/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn index 5d5426cb73c..0da528ebfcb 100644 --- a/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn @@ -41,6 +41,7 @@ ohos_unittest("shared_overlay_manager_test_ng") { "$ace_root/frameworks/core/components_ng/event/touch_event.cpp", "$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_overlay_manager.cpp", "$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_transition_effect.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn b/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn index 43edc4802c2..54d2baefedb 100644 --- a/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn @@ -60,6 +60,7 @@ ohos_unittest("ability_component_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_pattern.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp", diff --git a/frameworks/core/components_ng/test/pattern/badge/BUILD.gn b/frameworks/core/components_ng/test/pattern/badge/BUILD.gn index 4d7de6f01ed..3557680dcd6 100644 --- a/frameworks/core/components_ng/test/pattern/badge/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/badge/BUILD.gn @@ -105,6 +105,7 @@ ohos_unittest("badge_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/blank/BUILD.gn b/frameworks/core/components_ng/test/pattern/blank/BUILD.gn index 8fd774609a4..2c86a61b9fb 100644 --- a/frameworks/core/components_ng/test/pattern/blank/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/blank/BUILD.gn @@ -75,6 +75,7 @@ ohos_unittest("blank_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn b/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn index 174be42ac4e..a6ce1f1b62c 100644 --- a/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn @@ -106,6 +106,7 @@ ohos_unittest("bubble_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/button/BUILD.gn b/frameworks/core/components_ng/test/pattern/button/BUILD.gn index 28a865bc630..7631dc37737 100644 --- a/frameworks/core/components_ng/test/pattern/button/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/button/BUILD.gn @@ -93,6 +93,7 @@ ohos_unittest("button_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn b/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn index 8e905b0b0bf..97fb83faca0 100644 --- a/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn @@ -114,6 +114,7 @@ ohos_unittest("calendar_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn b/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn index 353bc611df1..876a3f2c58b 100644 --- a/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("checkbox_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn b/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn index 84f7996da19..0b6fb270b45 100644 --- a/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("checkboxgroup_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn b/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn index 0364b7c1490..28f2756d462 100644 --- a/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn @@ -113,6 +113,7 @@ ohos_unittest("container_modal_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/counter/BUILD.gn b/frameworks/core/components_ng/test/pattern/counter/BUILD.gn index 29293849e46..ff15f06ca78 100644 --- a/frameworks/core/components_ng/test/pattern/counter/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/counter/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("counter_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn b/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn index dfd9a527a89..f95f600e29b 100644 --- a/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn @@ -80,6 +80,7 @@ ohos_unittest("custom_dialog_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_overlay_modifier.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn b/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn index 55e0c386c56..762b0c039bf 100644 --- a/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn @@ -78,6 +78,7 @@ ohos_unittest("data_panel_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/divider/BUILD.gn b/frameworks/core/components_ng/test/pattern/divider/BUILD.gn index c4669a5c47a..8c2b660bde2 100644 --- a/frameworks/core/components_ng/test/pattern/divider/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/divider/BUILD.gn @@ -72,6 +72,7 @@ ohos_unittest("divider_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/flex/BUILD.gn b/frameworks/core/components_ng/test/pattern/flex/BUILD.gn index 80bab974069..d0c0234ae64 100644 --- a/frameworks/core/components_ng/test/pattern/flex/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/flex/BUILD.gn @@ -65,6 +65,7 @@ ohos_unittest("flex_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/form/BUILD.gn b/frameworks/core/components_ng/test/pattern/form/BUILD.gn index 714a02a1219..5835f5d60e1 100644 --- a/frameworks/core/components_ng/test/pattern/form/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/form/BUILD.gn @@ -84,6 +84,7 @@ ohos_unittest("form_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn b/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn index 86bfaf260db..a0d8cf63015 100644 --- a/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn @@ -74,6 +74,7 @@ ohos_unittest("gauge_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid/BUILD.gn index 821d60490e2..c9d5d868620 100644 --- a/frameworks/core/components_ng/test/pattern/grid/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid/BUILD.gn @@ -137,6 +137,7 @@ ohos_unittest("grid_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn index 2b1075cd6f4..1e73410d553 100644 --- a/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn @@ -71,6 +71,7 @@ ohos_unittest("grid_col_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn b/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn index 3c6af90484a..ca46d0fcaa8 100644 --- a/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn @@ -88,6 +88,7 @@ ohos_unittest("hyperlink_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/image/BUILD.gn b/frameworks/core/components_ng/test/pattern/image/BUILD.gn index be445e50a6e..517760f9164 100644 --- a/frameworks/core/components_ng/test/pattern/image/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/image/BUILD.gn @@ -95,6 +95,7 @@ ohos_unittest("image_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn b/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn index 3f5185a22c1..3a7fcfec11f 100644 --- a/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn @@ -143,6 +143,7 @@ ohos_unittest("indexer_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn b/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn index dabc0ad5c58..f051bbf1cd2 100644 --- a/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn @@ -49,6 +49,7 @@ ohos_unittest("linear_layout_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn b/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn index 307f663f4da..85d3be605c2 100644 --- a/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn @@ -81,6 +81,7 @@ ohos_unittest("linear_split_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/list/BUILD.gn b/frameworks/core/components_ng/test/pattern/list/BUILD.gn index 782d907b53d..c394020d2fe 100644 --- a/frameworks/core/components_ng/test/pattern/list/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/list/BUILD.gn @@ -57,6 +57,7 @@ common_sources = [ # components_ng_property "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn index bbea2e95341..f0eaf324e1c 100644 --- a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn @@ -162,6 +162,7 @@ ohos_unittest("menu_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn b/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn index cb95b4042b6..85ded65aaf0 100755 --- a/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn @@ -108,6 +108,7 @@ ohos_unittest("navigation_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn index 063892619bf..78b3a96393e 100644 --- a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn @@ -129,6 +129,7 @@ ohos_unittest("overlay_manager_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn b/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn index a78b43380b8..b123922864a 100644 --- a/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("patternlock_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/picker/BUILD.gn b/frameworks/core/components_ng/test/pattern/picker/BUILD.gn index f7cd5948f72..de6bf73e400 100644 --- a/frameworks/core/components_ng/test/pattern/picker/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/picker/BUILD.gn @@ -133,6 +133,7 @@ ohos_unittest("picker_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/time_picker/timepicker_row_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/time_picker/toss_animation_controller.cpp", "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn b/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn index f4e01e83d9e..19470a3edb4 100644 --- a/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn @@ -86,6 +86,7 @@ ohos_unittest("plugin_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn b/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn index 5bd21a7741d..a9dd54698a5 100644 --- a/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("qrcode_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/radio/BUILD.gn b/frameworks/core/components_ng/test/pattern/radio/BUILD.gn index 844d1b7d9b7..2e3cc4cc53b 100644 --- a/frameworks/core/components_ng/test/pattern/radio/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/radio/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("radio_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/rating/BUILD.gn b/frameworks/core/components_ng/test/pattern/rating/BUILD.gn index 144a69f0842..e33f41f3eb1 100644 --- a/frameworks/core/components_ng/test/pattern/rating/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/rating/BUILD.gn @@ -68,6 +68,7 @@ ohos_unittest("rating_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn b/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn index 02518b0fcc2..f03d313af9a 100644 --- a/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn @@ -84,6 +84,7 @@ ohos_unittest("refresh_pattern_test_ng") { # components_ng_property "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn b/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn index 18eeddcc7eb..c5ae2ae58c9 100644 --- a/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn @@ -114,6 +114,7 @@ ohos_unittest("scroll_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/search/BUILD.gn b/frameworks/core/components_ng/test/pattern/search/BUILD.gn index a9a06921949..c797186bae6 100644 --- a/frameworks/core/components_ng/test/pattern/search/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/search/BUILD.gn @@ -110,6 +110,7 @@ ohos_unittest("search_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn b/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn index 37fb291fdad..faf0e758c89 100644 --- a/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn @@ -94,6 +94,7 @@ ohos_unittest("security_component_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select/BUILD.gn b/frameworks/core/components_ng/test/pattern/select/BUILD.gn index 2d41be645f7..271671555af 100644 --- a/frameworks/core/components_ng/test/pattern/select/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select/BUILD.gn @@ -69,6 +69,7 @@ ohos_unittest("select_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn index 317cfee4e5c..43d21668e27 100644 --- a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn @@ -155,6 +155,7 @@ ohos_unittest("select_overlay_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn b/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn index 573e5b641e2..f776020a375 100644 --- a/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn @@ -111,6 +111,7 @@ ohos_unittest("side_bar_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn b/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn index 5cc4e75c758..d75e7dfb821 100644 --- a/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn @@ -166,6 +166,7 @@ ohos_unittest("stepper_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn b/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn index 133b3f464a6..fd8d74ab50d 100644 --- a/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("swiper_indicator_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn b/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn index 32a6fc42bd5..44250278f94 100644 --- a/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn @@ -137,6 +137,7 @@ ohos_unittest("tabs_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text/BUILD.gn b/frameworks/core/components_ng/test/pattern/text/BUILD.gn index bf747e82b4b..55275fcc4e3 100644 --- a/frameworks/core/components_ng/test/pattern/text/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text/BUILD.gn @@ -107,6 +107,7 @@ ohos_unittest("text_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn b/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn index c0f45454ed8..31711546a65 100644 --- a/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("text_clock_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_layout_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_pattern.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/render_context.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn index 5d0b68a90d5..8ad233e66e4 100644 --- a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn @@ -170,6 +170,7 @@ ohos_unittest("textfield_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn b/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn index fdc43218e97..9ae7eac712d 100644 --- a/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("text_timer_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_layout_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_pattern.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/render_context.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn b/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn index 823ac50781c..8d904df1b1b 100644 --- a/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("toggle_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/video/BUILD.gn b/frameworks/core/components_ng/test/pattern/video/BUILD.gn index f13c06471b5..6de310b0d7b 100644 --- a/frameworks/core/components_ng/test/pattern/video/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/video/BUILD.gn @@ -145,6 +145,7 @@ ohos_unittest("video_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn b/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn index bafe03b6772..4e68d2caba5 100644 --- a/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn @@ -78,6 +78,7 @@ ohos_unittest("xcomponent_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/accessibility/BUILD.gn b/frameworks/core/components_ng/test/property/accessibility/BUILD.gn index 67904e96578..175786000c9 100644 --- a/frameworks/core/components_ng/test/property/accessibility/BUILD.gn +++ b/frameworks/core/components_ng/test/property/accessibility/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("accessibility_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/calc_length/BUILD.gn b/frameworks/core/components_ng/test/property/calc_length/BUILD.gn index 1beb1023736..83957eb8b30 100644 --- a/frameworks/core/components_ng/test/property/calc_length/BUILD.gn +++ b/frameworks/core/components_ng/test/property/calc_length/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("calc_length_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/gradient/BUILD.gn b/frameworks/core/components_ng/test/property/gradient/BUILD.gn index 3590c7d47d8..b714a01207c 100644 --- a/frameworks/core/components_ng/test/property/gradient/BUILD.gn +++ b/frameworks/core/components_ng/test/property/gradient/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("gradient_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/grid_property/BUILD.gn b/frameworks/core/components_ng/test/property/grid_property/BUILD.gn index 871d50e1456..21e8ba2e8b7 100755 --- a/frameworks/core/components_ng/test/property/grid_property/BUILD.gn +++ b/frameworks/core/components_ng/test/property/grid_property/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("grid_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn index 5bd838bb369..e2f15d639dd 100755 --- a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn +++ b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn @@ -22,6 +22,7 @@ ohos_unittest("measure_utils_test_ng") { "$ace_root/frameworks/core/components/common/properties/color.cpp", # components_ng + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/property_test/BUILD.gn b/frameworks/core/components_ng/test/property/property_test/BUILD.gn index 8b2eae73d67..ea143c8c4c6 100755 --- a/frameworks/core/components_ng/test/property/property_test/BUILD.gn +++ b/frameworks/core/components_ng/test/property/property_test/BUILD.gn @@ -18,6 +18,7 @@ ohos_unittest("property_test_ng") { module_out_path = property_test_output_path sources = [ + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "property_test_ng.cpp", ] diff --git a/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn b/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn index d067e2e3b27..4af8f263b96 100644 --- a/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn @@ -85,6 +85,7 @@ ohos_unittest("for_each_syntax_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn b/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn index 4e9a5b4b5c7..2d1eeeae255 100644 --- a/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn @@ -80,6 +80,7 @@ ohos_unittest("if_else_syntax_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn b/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn index f581b605a59..7367e94aee4 100644 --- a/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("lazy_for_each_syntax_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 43b6d912f3c..3da06a0a267 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -189,6 +189,7 @@ ohos_source_set("ace_components_property") { part_name = ace_engine_part sources = [ "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_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", diff --git a/test/unittest/core/pattern/window_scene/BUILD.gn b/test/unittest/core/pattern/window_scene/BUILD.gn index d3c0a831561..4ce5606faea 100755 --- a/test/unittest/core/pattern/window_scene/BUILD.gn +++ b/test/unittest/core/pattern/window_scene/BUILD.gn @@ -91,6 +91,7 @@ ohos_unittest("window_scene_test") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/test/unittest/core/pipeline/BUILD.gn b/test/unittest/core/pipeline/BUILD.gn index 1bf80da74fd..4ae2ac6257c 100644 --- a/test/unittest/core/pipeline/BUILD.gn +++ b/test/unittest/core/pipeline/BUILD.gn @@ -202,6 +202,7 @@ ohos_unittest("pipeline_context_test_ng") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock/mock_image_pattern.cpp", # property + "$ace_root/frameworks/core/components_ng/property/border_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", diff --git a/test/unittest/core/render/render_context/BUILD.gn b/test/unittest/core/render/render_context/BUILD.gn index 5896a0c8985..412bfb65d22 100755 --- a/test/unittest/core/render/render_context/BUILD.gn +++ b/test/unittest/core/render/render_context/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("render_context_test_ng") { "$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/border_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", From f6f574b0c05e0be1ba2663dbd0bb0369e44da7bd Mon Sep 17 00:00:00 2001 From: jiangdayuan Date: Wed, 24 May 2023 15:52:27 +0800 Subject: [PATCH 63/99] fix Signed-off-by: jiangdayuan Change-Id: I1a5669bacc91587d5865d5261900d0e732434dba --- .../bridge/declarative_frontend/jsview/js_view_context.cpp | 4 ++-- frameworks/core/pipeline/pipeline_base.cpp | 4 ++-- frameworks/core/pipeline/pipeline_base.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp index 9714b003e75..a8dab65eb0e 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_context.cpp @@ -216,7 +216,7 @@ void JSViewContext::JSAnimation(const JSCallbackInfo& info) CHECK_NULL_VOID(container); auto pipelineContextBase = container->GetPipelineContext(); CHECK_NULL_VOID(pipelineContextBase); - if (pipelineContextBase->GetEnableImplicitAnimation() && pipelineContextBase->IsFormRender()) { + if (!pipelineContextBase->GetEnableImplicitAnimation() && pipelineContextBase->IsFormRender()) { LOGW("Form need enable implicit animation in finish callback."); return; } @@ -277,7 +277,7 @@ void JSViewContext::JSAnimateTo(const JSCallbackInfo& info) CHECK_NULL_VOID(container); auto pipelineContext = container->GetPipelineContext(); CHECK_NULL_VOID(pipelineContext); - if (pipelineContext->GetEnableImplicitAnimation() && pipelineContext->IsFormRender()) { + if (!pipelineContext->GetEnableImplicitAnimation() && pipelineContext->IsFormRender()) { LOGW("Form need enable implicit animation in finish callback."); return; } diff --git a/frameworks/core/pipeline/pipeline_base.cpp b/frameworks/core/pipeline/pipeline_base.cpp index fcfa9c18acc..255f3960bc6 100644 --- a/frameworks/core/pipeline/pipeline_base.cpp +++ b/frameworks/core/pipeline/pipeline_base.cpp @@ -507,10 +507,10 @@ void PipelineBase::OpenImplicitAnimation( CHECK_NULL_VOID(context); CHECK_NULL_VOID(finishCallback); if (context->IsFormRender()) { - context->SetEnableImplicitAnimation(true); + context->SetEnableImplicitAnimation(false); finishCallback(); context->FlushBuild(); - context->SetEnableImplicitAnimation(false); + context->SetEnableImplicitAnimation(true); return; } finishCallback(); diff --git a/frameworks/core/pipeline/pipeline_base.h b/frameworks/core/pipeline/pipeline_base.h index acbc1538225..0f902d8dc82 100644 --- a/frameworks/core/pipeline/pipeline_base.h +++ b/frameworks/core/pipeline/pipeline_base.h @@ -978,7 +978,7 @@ private: OnRouterChangeCallback onRouterChangeCallback_ = nullptr; PostRTTaskCallback postRTTaskCallback_; std::function gsVsyncCallback_; - bool enableImplicitAnimation_ = false; + bool enableImplicitAnimation_ = true; ACE_DISALLOW_COPY_AND_MOVE(PipelineBase); }; From 8a393beae5093c2b59af836b9463ef78096e8e73 Mon Sep 17 00:00:00 2001 From: zhangxiao150 Date: Wed, 24 May 2023 02:26:34 +0000 Subject: [PATCH 64/99] =?UTF-8?q?=20=E4=BF=AE=E5=A4=8Dbutton=E5=92=8Ctoggl?= =?UTF-8?q?e=20button=E4=BD=BF=E7=94=A8=E4=BA=86UpdateClipEdge=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E7=84=A6=E7=82=B9=E7=8A=B6=E6=80=81=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangxiao150 Change-Id: Icb0eed8e658747ff080a6148bdefa92cfc92897d --- frameworks/core/components_ng/pattern/button/button_pattern.cpp | 1 - .../core/components_ng/pattern/button/toggle_button_pattern.cpp | 1 - frameworks/core/components_ng/pattern/toggle/toggle_model_ng.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/button/button_pattern.cpp b/frameworks/core/components_ng/pattern/button/button_pattern.cpp index a0f108bb44b..5e753725ad5 100644 --- a/frameworks/core/components_ng/pattern/button/button_pattern.cpp +++ b/frameworks/core/components_ng/pattern/button/button_pattern.cpp @@ -43,7 +43,6 @@ void ButtonPattern::OnAttachToFrameNode() auto renderContext = host->GetRenderContext(); CHECK_NULL_VOID(renderContext); renderContext->SetClipToFrame(true); - renderContext->UpdateClipEdge(true); auto buttonTheme = pipeline->GetTheme(); CHECK_NULL_VOID(buttonTheme); clickedColor_ = buttonTheme->GetClickedColor(); diff --git a/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp b/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp index 256a26f3f01..f20ec64a212 100644 --- a/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp +++ b/frameworks/core/components_ng/pattern/button/toggle_button_pattern.cpp @@ -36,7 +36,6 @@ void ToggleButtonPattern::OnAttachToFrameNode() auto renderContext = host->GetRenderContext(); CHECK_NULL_VOID(renderContext); renderContext->SetClipToFrame(true); - renderContext->UpdateClipEdge(true); } void ToggleButtonPattern::InitParameters() diff --git a/frameworks/core/components_ng/pattern/toggle/toggle_model_ng.cpp b/frameworks/core/components_ng/pattern/toggle/toggle_model_ng.cpp index ad10ee1ce17..7b114c3c824 100644 --- a/frameworks/core/components_ng/pattern/toggle/toggle_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/toggle/toggle_model_ng.cpp @@ -251,7 +251,6 @@ void ToggleModelNG::CreateButton(int32_t nodeId) auto frameNode = FrameNode::GetOrCreateFrameNode( V2::TOGGLE_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); stack->Push(frameNode); - NG::ViewAbstract::SetHoverEffectAuto(HoverEffectType::SCALE); } void ToggleModelNG::AddNewChild(const RefPtr& parentFrame, int32_t nodeId, int32_t index) From 7e0a25ef9189a2666eb0e693fcb79bd5d5f91f49 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 23 May 2023 20:56:59 +0800 Subject: [PATCH 65/99] [tdd] improve accessibility_node tdd Change-Id: I32c92e0aca70e519923b6a85e19a90e8c07d2312 Signed-off-by: fred --- .../accessibility/accessibilitynode/BUILD.gn | 1 + .../accessibility_node_test_ng.cpp | 189 ++++++++++++++++-- 2 files changed, 168 insertions(+), 22 deletions(-) diff --git a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn index 896a602882c..10aa4e00387 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn @@ -92,6 +92,7 @@ ohos_unittest("accessibility_node_test_ng") { "$ace_root/frameworks/core/components_ng/test/mock/syntax/mock_for_each_node.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", + "$ace_root/test/mock/core/common/mock_container.cpp", ] sources += [ diff --git a/frameworks/core/components_ng/test/accessibility/accessibilitynode/accessibility_node_test_ng.cpp b/frameworks/core/components_ng/test/accessibility/accessibilitynode/accessibility_node_test_ng.cpp index 081e207ab21..c405f2f3c99 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilitynode/accessibility_node_test_ng.cpp +++ b/frameworks/core/components_ng/test/accessibility/accessibilitynode/accessibility_node_test_ng.cpp @@ -20,7 +20,9 @@ #include "frameworks/core/accessibility/accessibility_manager.h" #include "frameworks/core/accessibility/accessibility_node.h" #include "frameworks/core/accessibility/accessibility_utils.h" - +#include "core/common/container.h" +#include "test/mock/core/common/mock_container.h" +#include "core/pipeline_ng/test/mock/mock_pipeline_base.h" using namespace testing; using namespace testing::ext; @@ -31,7 +33,7 @@ const char VALUE[] = "value"; const char TYPE[] = "type"; const char DISABLED[] = "disabled"; const char GROUP[] = "accessibilitygroup"; -const char TEXT[] = "accessibilitytext"; +const char ACCESS_TEXT[] = "accessibilitytext"; const char DESCRIPTION[] = "accessibilitydescription"; const char IMPORTANCE[] = "accessibilityimportance"; const char SHOW[] = "show"; @@ -41,11 +43,19 @@ const char CLICK[] = "click"; const char LONG_PRESS[] = "longpress"; const char FOCUS[] = "focus"; const char BLUR[] = "blur"; +const char FAKE[] = "fake"; +const char INPUT_TYPE_CHECKBOX[] = "checkbox"; +const char INPUT_TYPE_RADIO[] = "radio"; +const char INPUT_TYPE_PASSWORD[] = "password"; } // namespace class AccessibilityNodeTestNg : public testing::Test { public: - static void SetUpTestCase() {}; + static void SetUpTestCase() + { + MockPipelineBase::SetUp(); + MockContainer::SetUp(); + }; static void TearDownTestCase() {}; }; @@ -59,44 +69,36 @@ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest001, TestSize.Level1) std::string nodeName = "accessibilityNodeTest"; AccessibilityNode accessibilityNode(id, nodeName); EXPECT_FALSE(accessibilityNode.ActionClick()); - ActionClickImpl actionClickImpl = []() {}; - accessibilityNode.SetActionClickImpl(actionClickImpl); + accessibilityNode.SetActionClickImpl([]() {}); EXPECT_TRUE(accessibilityNode.ActionClick()); EXPECT_FALSE(accessibilityNode.ActionLongClick()); - ActionLongClickImpl actionLongClickImpl = []() {}; - accessibilityNode.SetActionLongClickImpl(actionLongClickImpl); + accessibilityNode.SetActionLongClickImpl([]() {}); EXPECT_TRUE(accessibilityNode.ActionLongClick()); EXPECT_FALSE(accessibilityNode.ActionSetText(nodeName)); - ActionSetTextImpl actionSetTextImpl = [](const std::string& text) {}; - accessibilityNode.SetActionSetTextImpl(actionSetTextImpl); + accessibilityNode.SetActionSetTextImpl([](const std::string& text) {}); EXPECT_TRUE(accessibilityNode.ActionSetText(nodeName)); EXPECT_FALSE(accessibilityNode.ActionScrollForward()); - ActionScrollForwardImpl actionScrollForwardImpl = []() { return true; }; - accessibilityNode.SetActionScrollForward(actionScrollForwardImpl); + accessibilityNode.SetActionScrollForward([]() { return true; }); EXPECT_TRUE(accessibilityNode.ActionScrollForward()); EXPECT_FALSE(accessibilityNode.ActionScrollBackward()); - ActionScrollBackwardImpl actionScrollBackwardImpl = []() { return true; }; - accessibilityNode.SetActionScrollBackward(actionScrollBackwardImpl); + accessibilityNode.SetActionScrollBackward([]() { return true; }); EXPECT_TRUE(accessibilityNode.ActionScrollBackward()); bool result = true; EXPECT_FALSE(accessibilityNode.ActionAccessibilityFocus(result)); - ActionAccessibilityFocusImpl actionAccessibilityFocusImpl = [](bool result) {}; - accessibilityNode.SetActionAccessibilityFocusImpl(actionAccessibilityFocusImpl); + accessibilityNode.SetActionAccessibilityFocusImpl([](bool result) {}); EXPECT_TRUE(accessibilityNode.ActionAccessibilityFocus(result)); EXPECT_FALSE(accessibilityNode.ActionFocus()); - ActionFocusImpl actionFocusImpl = []() {}; - accessibilityNode.SetActionFocusImpl(actionFocusImpl); + accessibilityNode.SetActionFocusImpl([]() {}); EXPECT_TRUE(accessibilityNode.ActionFocus()); accessibilityNode.ActionUpdateIds(); - ActionUpdateIdsImpl actionUpdateIdsImpl = []() {}; - accessibilityNode.SetActionUpdateIdsImpl(actionUpdateIdsImpl); + accessibilityNode.SetActionUpdateIdsImpl([]() {}); accessibilityNode.ActionUpdateIds(); } @@ -115,9 +117,9 @@ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest002, TestSize.Level1) accessibilityNode.SetPositionInfo(positionInfo); EXPECT_EQ(accessibilityNode.rect_.Height(), TEST_NUMBER); - accessibilityNode.OnFocusChange(false); accessibilityNode.focusChangeEventId_ = [](const std::string& str) {}; - accessibilityNode.OnFocusChange(true); + accessibilityNode.SetFocusedState(false); + accessibilityNode.SetFocusedState(true); EXPECT_EQ(accessibilityNode.GetSupportAction().size(), 0); accessibilityNode.supportActions_ = static_cast(AceAction::ACTION_SCROLL_FORWARD); @@ -139,7 +141,7 @@ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest003, TestSize.Level1) vec.emplace_back(std::make_pair(DISABLED, "ACCESSIBILITY_DISABLED")); vec.emplace_back(std::make_pair(TYPE, "ACCESSIBILITY_TYPE")); vec.emplace_back(std::make_pair(GROUP, "ACCESSIBILITY_GROUP")); - vec.emplace_back(std::make_pair(TEXT, "ACCESSIBILITY_TEXT")); + vec.emplace_back(std::make_pair(ACCESS_TEXT, "ACCESSIBILITY_TEXT")); vec.emplace_back(std::make_pair(DESCRIPTION, "ACCESSIBILITY_DESCRIPTION")); vec.emplace_back(std::make_pair(IMPORTANCE, "ACCESSIBILITY_IMPORTANCE")); vec.emplace_back(std::make_pair(ID, "ID")); @@ -155,6 +157,9 @@ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest003, TestSize.Level1) accessibilityNode.attrs_.emplace_back(std::make_pair(IMPORTANCE, "ACCESSIBILITY_IMPORTANCE")); accessibilityNode.SetAttr(vec); EXPECT_EQ(accessibilityNode.importantForAccessibility_, "ACCESSIBILITY_IMPORTANCE"); + + accessibilityNode.SetTag("text"); + accessibilityNode.SetAttr(vec); } /** @@ -173,6 +178,7 @@ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest004, TestSize.Level1) vec.emplace_back(LONG_PRESS); vec.emplace_back(FOCUS); vec.emplace_back(BLUR); + vec.emplace_back(FAKE); accessibilityNode.AddEvent(0, vec); EXPECT_TRUE(accessibilityNode.isClickable_); @@ -185,13 +191,152 @@ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest004, TestSize.Level1) */ HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest005, TestSize.Level1) { + /** + * @tc.steps: step1. create AccessibilityNode and vector. + */ NodeId id = 0; std::string nodeName = "text"; AccessibilityNode accessibilityNode(id, nodeName); + + /** + * @tc.steps: step2. create offset. + */ + Offset offset(1.0, 1.0); + + /** + * @tc.steps: step3. create child and add node twice. + * @tc.expected: only one can add success. + */ auto child = AceType::MakeRefPtr(1, "child"); accessibilityNode.AddNode(child, 0); + accessibilityNode.AddNode(child, 0); EXPECT_EQ(accessibilityNode.children_.size(), 1); + + /** + * @tc.steps: step4. call AddOffsetForChildren. + * @tc.expected: accessibilityNode offset is meet expectations. + */ + accessibilityNode.AddOffsetForChildren(offset); + EXPECT_EQ(accessibilityNode.GetLeft(), 1); + + /** + * @tc.steps: step5. call remove node. + * @tc.expected: child remove success. + */ accessibilityNode.RemoveNode(child); EXPECT_EQ(accessibilityNode.children_.size(), 0); } + +/** + * @tc.name: accessibilityNodeTest006 + * @tc.type: FUNC + */ +HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest006, TestSize.Level1) +{ + /** + * @tc.steps: step1. create AccessibilityNode and vector. + */ + NodeId id = 0; + AccessibilityNode currentNode(id, "test"); + std::vector> vec; + + /** + * @tc.steps: step2. config pare and call SetAttr. + * @tc.expected: currentNode params text_ is meet expectations. + */ + vec.emplace_back(std::make_pair(VALUE, "value")); + currentNode.SetAttr(vec); + EXPECT_EQ(currentNode.text_, "value"); + + /** + * @tc.steps: step3. create a parent node and setTag recall SetAttr. + * @tc.expected: currentNode params text_ is meet expectations. + */ + auto parentNode = AceType::MakeRefPtr(1, "parent"); + currentNode.SetParentNode(parentNode); + currentNode.SetTag("text"); + currentNode.SetAttr(vec); + EXPECT_NE(parentNode->text_, "value"); + + /** + * @tc.steps: step4. put a fake value in pair and set tag popup. + * @tc.expected: currentNode params text_ is meet expectations. + */ + vec.emplace_back(std::make_pair(FAKE, "FAKE_VALUE")); + parentNode->SetTag("popup"); + currentNode.SetAttr(vec); + EXPECT_EQ(parentNode->text_, "value"); + + /** + * @tc.steps: step5. set tag input, put a wrong type in pair, initialization parameters. + * @tc.expected: currentNode params isCheckable_ is false. + */ + currentNode.SetTag("input"); + currentNode.isFocusable_ = false; + currentNode.isCheckable_ = false; + currentNode.isCheckable_ = false; + vec.emplace_back(std::make_pair(TYPE, FAKE)); + currentNode.SetAttr(vec); + EXPECT_FALSE(currentNode.isCheckable_); + + /** + * @tc.steps: step6. remove fake pair and put type with INPUT_TYPE_CHECKBOX. + * @tc.expected: currentNode params isCheckable_ is true. + */ + vec.pop_back(); + vec.emplace_back(std::make_pair(TYPE, INPUT_TYPE_CHECKBOX)); + currentNode.SetAttr(vec); + EXPECT_TRUE(currentNode.isCheckable_); + + /** + * @tc.steps: step7. remove fake pair and put type with INPUT_TYPE_RADIO. + * @tc.expected: currentNode params isCheckable_ is true. + */ + currentNode.isCheckable_ = false; + vec.pop_back(); + vec.emplace_back(std::make_pair(TYPE, INPUT_TYPE_RADIO)); + currentNode.SetAttr(vec); + EXPECT_TRUE(currentNode.isCheckable_); + + /** + * @tc.steps: step8. remove fake pair and put type with INPUT_TYPE_PASSWORD. + * @tc.expected: currentNode params isPassword_ is true. + */ + vec.pop_back(); + vec.emplace_back(std::make_pair(TYPE, INPUT_TYPE_PASSWORD)); + currentNode.SetAttr(vec); + EXPECT_TRUE(currentNode.isPassword_); +} + +/** + * @tc.name: accessibilityNodeTest007 + * @tc.type: FUNC + */ +HWTEST_F(AccessibilityNodeTestNg, accessibilityNodeTest007, TestSize.Level1) +{ + /** + * @tc.steps: step1. create EventMarker with empty eventId and AccessibilityNode. + */ + NodeId id = 0; + int32_t pageId = 1; + auto marker = EventMarker("", "event", pageId); + std::string nodeName = "text"; + AccessibilityNode accessibilityNode(id, nodeName); + + /** + * @tc.steps: step2. call SetFocusChangeEventMarker function. + * @tc.expected: the param focusChangeEventId_ in accessibilityNode is null. + */ + accessibilityNode.SetFocusChangeEventMarker(marker); + EXPECT_FALSE(accessibilityNode.focusChangeEventId_); + + /** + * @tc.steps: step3. set eventId not empty and config Container, then recall SetFocusChangeEventMarker. + * @tc.expected: the param focusChangeEventId_ in accessibilityNode is null. + */ + marker.data_->eventId = std::to_string(id); + MockContainer::Current()->pipelineContext_ = MockPipelineBase::GetCurrent(); + accessibilityNode.SetFocusChangeEventMarker(marker); + EXPECT_FALSE(accessibilityNode.focusChangeEventId_); +} } // namespace OHOS::Ace::NG From 06c95dc415081090b937c87075d3a1f77dc7f150 Mon Sep 17 00:00:00 2001 From: zcdqs Date: Wed, 24 May 2023 16:27:33 +0800 Subject: [PATCH 66/99] fix grid scroll bar position Signed-off-by: zcdqs Change-Id: I7862b152c5cddbb2d89114e1064d4ff425679311 --- frameworks/core/components_ng/pattern/grid/grid_pattern.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp b/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp index 4de41baa526..5d2d3398968 100644 --- a/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp +++ b/frameworks/core/components_ng/pattern/grid/grid_pattern.cpp @@ -1003,7 +1003,7 @@ void GridPattern::UpdateScrollBarOffset() continue; } auto lineStart = line->second.begin()->second; - auto lineEnd = line->second.end()->second; + auto lineEnd = line->second.rbegin()->second; itemCount += (lineEnd - lineStart + 1); heightSum += item.second + mainGap; } From 10beb6149a68d1f87c895dc0f09d0b21fd5d03ab Mon Sep 17 00:00:00 2001 From: WangJiazhen Date: Tue, 23 May 2023 20:09:53 +0800 Subject: [PATCH 67/99] Fix cursh when StartPoint/EndPoint was not given in line component. Signed-off-by: WangJiazhen Change-Id: Id5fa8fbcd2605013758a0a6f09ba0f6cdf4726a4 --- .../components_ng/pattern/shape/line_pattern.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frameworks/core/components_ng/pattern/shape/line_pattern.h b/frameworks/core/components_ng/pattern/shape/line_pattern.h index e6ff046ca28..badabff4078 100644 --- a/frameworks/core/components_ng/pattern/shape/line_pattern.h +++ b/frameworks/core/components_ng/pattern/shape/line_pattern.h @@ -29,6 +29,8 @@ class LinePattern : public ShapePattern { DECLARE_ACE_TYPE(LinePattern, ShapePattern); public: + static constexpr ShapePoint DEFAULT_POINT = ShapePoint(0.0, 0.0); + LinePattern() = default; ~LinePattern() override = default; @@ -50,6 +52,21 @@ public: return MakeRefPtr(); } + void OnModifyDone() override + { + auto host = GetHost(); + CHECK_NULL_RETURN(host, std::nullopt); + auto paintProperty = host->GetPaintProperty(); + CHECK_NULL_RETURN(paintProperty, std::nullopt); + if (!paintProperty->HasStartPoint()) { + paintProperty->UpdateStartPoint(DEFAULT_POINT); + } + if (!paintProperty->HasEndPoint()) { + paintProperty->UpdateEndPoint(DEFAULT_POINT); + } + ShapePattern::OnModifyDone(); + } + private: ACE_DISALLOW_COPY_AND_MOVE(LinePattern); }; From 72688c7e309ca57157a02851a5c3326012892916 Mon Sep 17 00:00:00 2001 From: lijuan Date: Thu, 18 May 2023 08:11:42 +0000 Subject: [PATCH 68/99] =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E4=BB=A5=E5=A4=96=E5=8C=BA=E5=9F=9F=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=96=87=E6=9C=AC=E9=80=89=E4=B8=AD=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijuan --- frameworks/core/common/event_manager.cpp | 14 ++++ frameworks/core/common/event_manager.h | 4 +- .../select_overlay/select_overlay_manager.cpp | 30 +++++++++ .../select_overlay/select_overlay_manager.h | 3 + .../select_overlay/select_overlay_node.cpp | 24 +++++++ .../select_overlay/select_overlay_node.h | 2 + .../select_overlay/select_overlay_pattern.h | 9 +++ .../pattern/text/text_pattern.cpp | 39 ++++++++--- .../components_ng/pattern/text/text_pattern.h | 1 + .../select_overlay_manager_test_ng.cpp | 66 +++++++++++++++++++ .../mock_select_overlay_manager.cpp | 7 ++ .../mock_select_overlay_node.cpp | 5 ++ .../core/pipeline_ng/pipeline_context.cpp | 2 + .../core/pipeline/mock_event_manager.cpp | 4 ++ 14 files changed, 200 insertions(+), 10 deletions(-) diff --git a/frameworks/core/common/event_manager.cpp b/frameworks/core/common/event_manager.cpp index b7d5d7d4637..bd69c2b742d 100644 --- a/frameworks/core/common/event_manager.cpp +++ b/frameworks/core/common/event_manager.cpp @@ -21,6 +21,7 @@ #include "base/utils/utils.h" #include "core/common/container.h" #include "core/components_ng/base/frame_node.h" +#include "core/components_ng/manager/select_overlay/select_overlay_manager.h" #include "core/event/ace_events.h" #include "core/event/key_event.h" #include "core/event/touch_event.h" @@ -150,6 +151,19 @@ void EventManager::HandleGlobalEvent(const TouchEvent& touchPoint, const RefPtr< inSelectedRect_ = false; } +void EventManager::HandleGlobalEventNG( + const TouchEvent& touchPoint, const RefPtr& selectOverlayManager) +{ + if (touchPoint.type != TouchType::DOWN || touchPoint.sourceType != SourceType::MOUSE) { + return; + } + const NG::PointF point { touchPoint.x, touchPoint.y }; + CHECK_NULL_VOID_NOLOG(selectOverlayManager); + if (!selectOverlayManager->IsInSelectedOrSelectOverlayArea(point)) { + selectOverlayManager->DestroySelectOverlay(); + } +} + void EventManager::HandleOutOfRectCallback(const Point& point, std::vector& rectCallbackList) { for (auto iter = rectCallbackList.begin(); iter != rectCallbackList.end();) { diff --git a/frameworks/core/common/event_manager.h b/frameworks/core/common/event_manager.h index e4f5efed116..1b6fef6714e 100644 --- a/frameworks/core/common/event_manager.h +++ b/frameworks/core/common/event_manager.h @@ -34,7 +34,8 @@ namespace OHOS::Ace { namespace NG { class FrameNode; -} +class SelectOverlayManager; +} // namespace NG class RenderNode; class Element; class TextOverlayManager; @@ -125,6 +126,7 @@ public: return instanceId_; } void HandleGlobalEvent(const TouchEvent& touchPoint, const RefPtr& textOverlayManager); + void HandleGlobalEventNG(const TouchEvent& touchPoint, const RefPtr& selectOverlayManager); void CollectTabIndexNodes(const RefPtr& rootNode); diff --git a/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.cpp b/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.cpp index f4f0b577f6b..b5576e036d3 100644 --- a/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.cpp +++ b/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.cpp @@ -66,6 +66,20 @@ void SelectOverlayManager::DestroySelectOverlay(int32_t overlayId) } } +void SelectOverlayManager::DestroySelectOverlay() +{ + auto rootNode = rootNodeWeak_.Upgrade(); + CHECK_NULL_VOID(rootNode); + auto current = selectOverlayItem_.Upgrade(); + if (current) { + LOGD("destroy overlay, id is %{public}d.", current->GetId()); + rootNode->RemoveChild(current); + rootNode->MarkNeedSyncRenderTree(); + rootNode->RebuildRenderContextTree(); + selectOverlayItem_.Reset(); + } +} + bool SelectOverlayManager::HasSelectOverlay(int32_t overlayId) { auto current = selectOverlayItem_.Upgrade(); @@ -73,6 +87,22 @@ bool SelectOverlayManager::HasSelectOverlay(int32_t overlayId) return current->GetId() == overlayId; } +bool SelectOverlayManager::IsInSelectedOrSelectOverlayArea(const PointF& point) +{ + auto current = selectOverlayItem_.Upgrade(); + CHECK_NULL_RETURN_NOLOG(current, false); + auto selectOverlayNode = DynamicCast(current); + if (selectOverlayNode) { + return selectOverlayNode->IsInSelectedOrSelectOverlayArea(point); + } else { + auto menuRect = current->GetGeometryNode()->GetFrameRect(); + if (menuRect.IsInRegion(point)) { + return true; + } + } + return false; +} + RefPtr SelectOverlayManager::GetSelectOverlayNode(int32_t overlayId) { auto current = selectOverlayItem_.Upgrade(); diff --git a/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.h b/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.h index 4b90b8912a1..555310e6315 100644 --- a/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.h +++ b/frameworks/core/components_ng/manager/select_overlay/select_overlay_manager.h @@ -44,9 +44,12 @@ public: // Destroy the pop-up interface and delete the pop-up information. void DestroySelectOverlay(const RefPtr& proxy); void DestroySelectOverlay(int32_t overlayId); + void DestroySelectOverlay(); bool HasSelectOverlay(int32_t overlayId); + bool IsInSelectedOrSelectOverlayArea(const PointF& point); + RefPtr GetSelectOverlayNode(int32_t overlayId); bool IsSameSelectOverlayInfo(const SelectOverlayInfo& info); diff --git a/frameworks/core/components_ng/pattern/select_overlay/select_overlay_node.cpp b/frameworks/core/components_ng/pattern/select_overlay/select_overlay_node.cpp index e617ca5838a..c329ba855e7 100644 --- a/frameworks/core/components_ng/pattern/select_overlay/select_overlay_node.cpp +++ b/frameworks/core/components_ng/pattern/select_overlay/select_overlay_node.cpp @@ -809,4 +809,28 @@ RefPtr SelectOverlayNode::CreateMenuNode(const std::shared_ptrHandleGlobalEventNG(scalePoint, selectOverlayManager_); TouchRestrict touchRestrict { TouchRestrict::NONE }; touchRestrict.sourceType = point.sourceType; touchRestrict.touchEvent = point; diff --git a/test/unittest/core/pipeline/mock_event_manager.cpp b/test/unittest/core/pipeline/mock_event_manager.cpp index 1bfa6cda6e4..bc1c238eb8b 100644 --- a/test/unittest/core/pipeline/mock_event_manager.cpp +++ b/test/unittest/core/pipeline/mock_event_manager.cpp @@ -35,6 +35,10 @@ void EventManager::TouchTest( void EventManager::HandleGlobalEvent(const TouchEvent& touchPoint, const RefPtr& textOverlayManager) {} +void EventManager::HandleGlobalEventNG( + const TouchEvent& touchPoint, const RefPtr& selectOverlayManager) +{} + void EventManager::HandleOutOfRectCallback(const Point& point, std::vector& rectCallbackList) {} void EventManager::TouchTest( From ce0eb9ffd44cb9486aeded420a30454fa703423e Mon Sep 17 00:00:00 2001 From: chengfeiwang Date: Wed, 24 May 2023 07:14:21 +0000 Subject: [PATCH 69/99] fix rating image display Signed-off-by: chengfeiwang Change-Id: Id78650713cd606bb54bbebf569fe1289f8aa49da --- .../pattern/rating/rating_modifier.h | 8 ++- .../pattern/rating/rating_pattern.cpp | 26 +++++-- .../pattern/rating/rating_pattern.h | 1 + .../render/adapter/skia_image.cpp | 6 -- .../pattern/rating/rating_pattern_test_ng.cpp | 68 +++++++++++++++++-- 5 files changed, 90 insertions(+), 19 deletions(-) diff --git a/frameworks/core/components_ng/pattern/rating/rating_modifier.h b/frameworks/core/components_ng/pattern/rating/rating_modifier.h index ad6a81d0e23..07ae6b1d61f 100644 --- a/frameworks/core/components_ng/pattern/rating/rating_modifier.h +++ b/frameworks/core/components_ng/pattern/rating/rating_modifier.h @@ -68,7 +68,7 @@ public: } bool JudgeImageUri(const std::string& foregroundUri, const std::string& secondaryUri, - const std::string& backgroundUri, const RectF& dstRect) + const std::string& backgroundUri, const ImagePaintConfig& foregroundConfig) { if (foregroundUri_ != foregroundUri) { return true; @@ -80,7 +80,11 @@ public: return true; } CHECK_NULL_RETURN(foregroundImageCanvas_, true); - if (foregroundImageCanvas_->GetPaintConfig().dstRect_ != dstRect) { + if (foregroundImageCanvas_->GetPaintConfig().dstRect_ != foregroundConfig.dstRect_) { + return true; + } + if (foregroundImageCanvas_->GetPaintConfig().scaleX_ != foregroundConfig.scaleX_ || + foregroundImageCanvas_->GetPaintConfig().scaleY_ != foregroundConfig.scaleY_) { return true; } // No need to update three CanvasImages diff --git a/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp b/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp index 6d17210dda3..9f14f8fc54d 100644 --- a/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp +++ b/frameworks/core/components_ng/pattern/rating/rating_pattern.cpp @@ -117,7 +117,6 @@ void RatingPattern::OnImageLoadSuccess(int32_t imageFlag) secondaryConfig_.dstRect_ = secondaryImageLoadingCtx_->GetDstRect(); imageSuccessStateCode_ = imageFlag | imageSuccessStateCode_; } - if (imageFlag == 0b100) { backgroundImageCanvas_ = backgroundImageLoadingCtx_->MoveCanvasImage(); backgroundConfig_.srcRect_ = backgroundImageLoadingCtx_->GetSrcRect(); @@ -144,6 +143,25 @@ void RatingPattern::OnImageDataReady(int32_t imageFlag) } } +void RatingPattern::UpdatePaintConfig() +{ + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto geometryNode = host->GetGeometryNode(); + CHECK_NULL_VOID(geometryNode); + auto frameSize = geometryNode->GetFrameSize(); + auto contentSize = geometryNode->GetContentSize(); + foregroundConfig_.imageFit_ = ImageFit::FILL; + secondaryConfig_.imageFit_ = ImageFit::FILL; + backgroundConfig_.imageFit_ = ImageFit::FILL; + foregroundConfig_.scaleX_ = contentSize.Height() / frameSize.Width(); + foregroundConfig_.scaleY_ = contentSize.Height() / frameSize.Height(); + secondaryConfig_.scaleX_ = contentSize.Height() / frameSize.Width(); + secondaryConfig_.scaleY_ = contentSize.Height() / frameSize.Height(); + backgroundConfig_.scaleX_ = contentSize.Height() / frameSize.Width(); + backgroundConfig_.scaleY_ = contentSize.Height() / frameSize.Height(); +} + RefPtr RatingPattern::CreateNodePaintMethod() { CHECK_NULL_RETURN(foregroundImageCanvas_, nullptr); @@ -153,9 +171,7 @@ RefPtr RatingPattern::CreateNodePaintMethod() CHECK_NULL_RETURN(layoutProperty, nullptr); auto starNum = layoutProperty->GetStars().value_or(GetStarNumFromTheme().value_or(OHOS::Ace::DEFAULT_RATING_STAR_NUM)); - foregroundConfig_.imageFit_ = ImageFit::TOP_LEFT; - secondaryConfig_.imageFit_ = ImageFit::TOP_LEFT; - backgroundConfig_.imageFit_ = ImageFit::TOP_LEFT; + UpdatePaintConfig(); if (!ratingModifier_) { ratingModifier_ = AceType::MakeRefPtr(); } @@ -164,7 +180,7 @@ RefPtr RatingPattern::CreateNodePaintMethod() if (ratingModifier_->JudgeImageUri( layoutProperty->GetForegroundImageSourceInfo()->GetSrc(), layoutProperty->GetSecondaryImageSourceInfo()->GetSrc(), - layoutProperty->GetBackgroundImageSourceInfo()->GetSrc(), foregroundConfig_.dstRect_) && + layoutProperty->GetBackgroundImageSourceInfo()->GetSrc(), foregroundConfig_) && imageSuccessStateCode_ == RATING_IMAGE_SUCCESS_CODE) { ratingModifier_->UpdateImageUri( layoutProperty->GetForegroundImageSourceInfo()->GetSrc(), diff --git a/frameworks/core/components_ng/pattern/rating/rating_pattern.h b/frameworks/core/components_ng/pattern/rating/rating_pattern.h index 556e2e0c1e9..4f4b76e928f 100644 --- a/frameworks/core/components_ng/pattern/rating/rating_pattern.h +++ b/frameworks/core/components_ng/pattern/rating/rating_pattern.h @@ -104,6 +104,7 @@ private: void LoadForeground(); void LoadSecondary(); void LoadBackground(); + void UpdatePaintConfig(); void OnImageDataReady(int32_t imageFlag); void OnImageLoadSuccess(int32_t imageFlag); void CheckImageInfoHasChangedOrNot( diff --git a/frameworks/core/components_ng/render/adapter/skia_image.cpp b/frameworks/core/components_ng/render/adapter/skia_image.cpp index 94518ef7bba..0b2abbb61d8 100644 --- a/frameworks/core/components_ng/render/adapter/skia_image.cpp +++ b/frameworks/core/components_ng/render/adapter/skia_image.cpp @@ -193,12 +193,6 @@ bool SkiaImage::DrawWithRecordingCanvas( #endif auto radii = ImagePainterUtils::ToSkRadius(radiusXY); recordingCanvas->ClipAdaptiveRRect(radii.get()); - if (config.imageFit_ == ImageFit::TOP_LEFT) { - SkAutoCanvasRestore acr(recordingCanvas, true); - auto skSrcRect = SkRect::MakeXYWH(srcRect.GetLeft(), srcRect.GetTop(), srcRect.GetWidth(), srcRect.GetHeight()); - auto skDstRect = SkRect::MakeXYWH(dstRect.GetLeft(), dstRect.GetTop(), dstRect.GetWidth(), dstRect.GetHeight()); - recordingCanvas->concat(SkMatrix::MakeRectToRect(skSrcRect, skDstRect, SkMatrix::kFill_ScaleToFit)); - } recordingCanvas->scale(config.scaleX_, config.scaleY_); Rosen::RsImageInfo rsImageInfo((int)(config.imageFit_), (int)(config.imageRepeat_), radii.get(), 1.0, GetUniqueID(), diff --git a/frameworks/core/components_ng/test/pattern/rating/rating_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/rating/rating_pattern_test_ng.cpp index 4d63a7951cf..24bcfc661c3 100644 --- a/frameworks/core/components_ng/test/pattern/rating/rating_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/rating/rating_pattern_test_ng.cpp @@ -17,14 +17,9 @@ #include "gtest/gtest.h" #include "third_party/libpng/png.h" - -#include "base/memory/ace_type.h" -#include "core/components_ng/test/mock/render/mock_canvas_image.h" -#include "core/components_ng/test/mock/theme/mock_theme_manager.h" -#include "core/image/image_source_info.h" - #define private public #define protected public +#include "base/memory/ace_type.h" #include "core/components/rating/rating_theme.h" #include "core/components/theme/icon_theme.h" #include "core/components_ng/base/view_stack_processor.h" @@ -32,7 +27,10 @@ #include "core/components_ng/pattern/rating/rating_model_ng.h" #include "core/components_ng/pattern/rating/rating_pattern.h" #include "core/components_ng/pattern/rating/rating_render_property.h" +#include "core/components_ng/test/mock/render/mock_canvas_image.h" +#include "core/components_ng/test/mock/theme/mock_theme_manager.h" #include "core/components_v2/inspector/inspector_constants.h" +#include "core/image/image_source_info.h" #include "core/pipeline/base/constants.h" #include "core/pipeline_ng/pipeline_context.h" #include "core/pipeline_ng/test/mock/mock_pipeline_base.h" @@ -59,6 +57,8 @@ constexpr double DEFAULT_RATING_SCORE = 0.0; constexpr double DEFAULT_STEP_SIZE = 0.5; constexpr double RATING_STEP_SIZE = 0.7; constexpr double RATING_STEP_SIZE_2 = DEFAULT_STAR_NUM + DEFAULT_STAR_NUM; +const float FRAME_WIDTH = 400.0f; +const float FRAME_HEIGHT = 400.0f; const float CONTAINER_WIDTH = 300.0f; const float CONTAINER_HEIGHT = 300.0f; const SizeF CONTAINER_SIZE(CONTAINER_WIDTH, CONTAINER_HEIGHT); @@ -660,6 +660,62 @@ HWTEST_F(RatingPatternTestNg, RatingPatternTest011, TestSize.Level1) EXPECT_EQ(ratingPattern->ratingModifier_->backgroundUri_, RESOURCE_URL); } +/** + * @tc.name: RatingPatternTest012 + * @tc.desc: Test rating three images render scale. + * @tc.type: FUNC + */ +HWTEST_F(RatingPatternTestNg, RatingPatternTest012, TestSize.Level1) +{ + /** + * @tc.steps: step1. create rating FrameNode and Pattern, and initialize rating modifier. + */ + RatingModelNG rating; + rating.Create(); + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_TRUE(frameNode != nullptr && frameNode->GetTag() == V2::RATING_ETS_TAG); + auto ratingPattern = frameNode->GetPattern(); + ASSERT_NE(ratingPattern, nullptr); + ratingPattern->foregroundImageCanvas_ = AceType::MakeRefPtr(); + ratingPattern->secondaryImageCanvas_ = AceType::MakeRefPtr(); + ratingPattern->backgroundImageCanvas_ = AceType::MakeRefPtr(); + auto paintMethod1 = ratingPattern->CreateNodePaintMethod(); + ASSERT_NE(paintMethod1, nullptr); + ASSERT_NE(ratingPattern->ratingModifier_, nullptr); + /** + * @tc.steps: step2. update PaintConfig. + */ + frameNode->geometryNode_->SetFrameSize(SizeF(FRAME_WIDTH, FRAME_HEIGHT)); + frameNode->geometryNode_->SetContentSize(CONTAINER_SIZE); + ratingPattern->imageSuccessStateCode_ = RATING_IMAGE_SUCCESS_CODE; + auto paintMethod2 = ratingPattern->CreateNodePaintMethod(); + ASSERT_NE(paintMethod2, nullptr); + ASSERT_NE(ratingPattern->ratingModifier_, nullptr); + auto scaleX = CONTAINER_SIZE.Height() / FRAME_WIDTH; + auto scaleY = CONTAINER_SIZE.Height() / FRAME_HEIGHT; + EXPECT_EQ(ratingPattern->foregroundConfig_.scaleX_, scaleX); + EXPECT_EQ(ratingPattern->foregroundConfig_.scaleY_, scaleY); + EXPECT_EQ(ratingPattern->secondaryConfig_.scaleX_, scaleX); + EXPECT_EQ(ratingPattern->secondaryConfig_.scaleY_, scaleY); + EXPECT_EQ(ratingPattern->backgroundConfig_.scaleX_, scaleX); + EXPECT_EQ(ratingPattern->backgroundConfig_.scaleY_, scaleY); + ASSERT_NE(ratingPattern->ratingModifier_->foregroundImageCanvas_->paintConfig_, nullptr); + ASSERT_NE(ratingPattern->ratingModifier_->secondaryImageCanvas_->paintConfig_, nullptr); + ASSERT_NE(ratingPattern->ratingModifier_->backgroundImageCanvas_->paintConfig_, nullptr); + EXPECT_EQ(ratingPattern->foregroundConfig_.scaleX_, + ratingPattern->ratingModifier_->foregroundImageCanvas_->GetPaintConfig().scaleX_); + EXPECT_EQ(ratingPattern->foregroundConfig_.scaleY_, + ratingPattern->ratingModifier_->foregroundImageCanvas_->GetPaintConfig().scaleY_); + EXPECT_EQ(ratingPattern->secondaryConfig_.scaleX_, + ratingPattern->ratingModifier_->secondaryImageCanvas_->GetPaintConfig().scaleX_); + EXPECT_EQ(ratingPattern->secondaryConfig_.scaleY_, + ratingPattern->ratingModifier_->secondaryImageCanvas_->GetPaintConfig().scaleY_); + EXPECT_EQ(ratingPattern->backgroundConfig_.scaleX_, + ratingPattern->ratingModifier_->backgroundImageCanvas_->GetPaintConfig().scaleX_); + EXPECT_EQ(ratingPattern->backgroundConfig_.scaleY_, + ratingPattern->ratingModifier_->backgroundImageCanvas_->GetPaintConfig().scaleY_); +} + /** * @tc.name: RatingOnChangeEventTest001 * @tc.desc: Test setting out-of-bounds ratingScore and starNum values. From e9b17a77835ceec42a5b8dafb4fa21ffde1680f4 Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 24 May 2023 16:42:57 +0800 Subject: [PATCH 70/99] the initial commit for maxwidth and get transform Signed-off-by: limeng --- .../jsview/js_canvas_renderer.cpp | 47 ++++++++++++++++--- .../declarative_frontend/jsview/js_matrix2d.h | 5 ++ .../custom_paint/canvas_paint_method.cpp | 39 +++++++++++---- .../custom_paint/canvas_paint_method.h | 10 ++-- .../custom_paint_paint_method.cpp | 31 ++++++++++++ .../custom_paint/custom_paint_paint_method.h | 2 + .../custom_paint/custom_paint_pattern.cpp | 17 ++++--- .../custom_paint/custom_paint_pattern.h | 5 +- .../offscreen_canvas_paint_method.cpp | 36 ++++++++++---- .../offscreen_canvas_paint_method.h | 8 ++-- .../custom_paint/offscreen_canvas_pattern.cpp | 15 ++++-- .../custom_paint/offscreen_canvas_pattern.h | 6 ++- .../preview_mock/preview_mock_model_ng.cpp | 3 +- .../custom_paint_pattern_test_ng.cpp | 4 +- 14 files changed, 179 insertions(+), 49 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp index 80791b9e35f..cc23661ffa9 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp @@ -286,14 +286,24 @@ void JSCanvasRenderer::JsFillText(const JSCallbackInfo& info) JSViewAbstract::ParseJsDouble(info[2], y); x = SystemProperties::Vp2Px(x); y = SystemProperties::Vp2Px(y); - + std::optional maxWidth; + if (info.Length() >= 4) { + double width = 0; + if (info[3]->IsUndefined()) { + width = FLT_MAX; + } else if (info[3]->IsNumber()) { + JSViewAbstract::ParseJsDouble(info[3], width); + width = SystemProperties::Vp2Px(width); + } + maxWidth = width; + } if (Container::IsCurrentUseNewPipeline()) { if (isOffscreen_ && offscreenCanvasPattern_) { - offscreenCanvasPattern_->FillText(text, x, y, paintState_); + offscreenCanvasPattern_->FillText(text, x, y, maxWidth, paintState_); return; } if (!isOffscreen_ && customPaintPattern_) { - customPaintPattern_->FillText(text, x, y); + customPaintPattern_->FillText(text, x, y, maxWidth); } return; } @@ -323,14 +333,24 @@ void JSCanvasRenderer::JsStrokeText(const JSCallbackInfo& info) JSViewAbstract::ParseJsDouble(info[2], y); x = SystemProperties::Vp2Px(x); y = SystemProperties::Vp2Px(y); - + std::optional maxWidth; + if (info.Length() >= 4 && info[3]->IsNumber()) { + double width = 0; + if (info[3]->IsUndefined()) { + width = FLT_MAX; + } else if (info[3]->IsNumber()) { + JSViewAbstract::ParseJsDouble(info[3], width); + width = SystemProperties::Vp2Px(width); + } + maxWidth = width; + } if (Container::IsCurrentUseNewPipeline()) { if (isOffscreen_ && offscreenCanvasPattern_) { - offscreenCanvasPattern_->StrokeText(text, x, y, paintState_); + offscreenCanvasPattern_->StrokeText(text, x, y, maxWidth, paintState_); return; } if (!isOffscreen_ && customPaintPattern_) { - customPaintPattern_->StrokeText(text, x, y); + customPaintPattern_->StrokeText(text, x, y, maxWidth); } return; } @@ -2567,7 +2587,20 @@ void JSCanvasRenderer::JsScale(const JSCallbackInfo& info) void JSCanvasRenderer::JsGetTransform(const JSCallbackInfo& info) { - return; + JSRef obj = JSClass::NewInstance(); + obj->SetProperty("__type", "Matrix2D"); + if (Container::IsCurrentUseNewPipeline()) { + TransformParam param; + if (isOffscreen_ && offscreenCanvasPattern_) { + param = offscreenCanvasPattern_->GetTransform(); + } else if (!isOffscreen_ && customPaintPattern_) { + param = customPaintPattern_->GetTransform(); + } + auto matrix = Referenced::Claim(obj->Unwrap()); + CHECK_NULL_VOID(matrix); + matrix->SetTransform(param); + } + info.SetReturnValue(obj); } void JSCanvasRenderer::JsSetTransform(const JSCallbackInfo& info) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_matrix2d.h b/frameworks/bridge/declarative_frontend/jsview/js_matrix2d.h index 7217e102e17..037819d9767 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_matrix2d.h +++ b/frameworks/bridge/declarative_frontend/jsview/js_matrix2d.h @@ -87,6 +87,11 @@ public: return transform_; } + void SetTransform(const TransformParam& param) + { + transform_ = param; + } + std::string ToString() const; ACE_DISALLOW_COPY_AND_MOVE(JSMatrix2d); diff --git a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp index 5693fd8df4b..6bfc9e7fc62 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp @@ -353,7 +353,8 @@ void CanvasPaintMethod::TransferFromImageBitmap(PaintWrapper* paintWrapper, PutImageData(paintWrapper, *imageData); } -void CanvasPaintMethod::FillText(PaintWrapper* paintWrapper, const std::string& text, double x, double y) +void CanvasPaintMethod::FillText( + PaintWrapper* paintWrapper, const std::string& text, double x, double y, std::optional maxWidth) { CHECK_NULL_VOID(paintWrapper); auto offset = paintWrapper->GetContentOffset(); @@ -361,10 +362,11 @@ void CanvasPaintMethod::FillText(PaintWrapper* paintWrapper, const std::string& auto success = UpdateParagraph(offset, text, false, HasShadow()); CHECK_NULL_VOID(success); - PaintText(offset, frameSize, x, y, false, HasShadow()); + PaintText(offset, frameSize, x, y, maxWidth, false, HasShadow()); } -void CanvasPaintMethod::StrokeText(PaintWrapper* paintWrapper, const std::string& text, double x, double y) +void CanvasPaintMethod::StrokeText( + PaintWrapper* paintWrapper, const std::string& text, double x, double y, std::optional maxWidth) { CHECK_NULL_VOID(paintWrapper); auto offset = paintWrapper->GetContentOffset(); @@ -373,12 +375,12 @@ void CanvasPaintMethod::StrokeText(PaintWrapper* paintWrapper, const std::string if (HasShadow()) { auto success = UpdateParagraph(offset, text, true, true); CHECK_NULL_VOID(success); - PaintText(offset, frameSize, x, y, true, true); + PaintText(offset, frameSize, x, y, maxWidth, true, true); } auto success = UpdateParagraph(offset, text, true); CHECK_NULL_VOID(success); - PaintText(offset, frameSize, x, y, true); + PaintText(offset, frameSize, x, y, maxWidth, true); } double CanvasPaintMethod::MeasureText(const std::string& text, const PaintState& state) @@ -458,10 +460,10 @@ TextMetrics CanvasPaintMethod::MeasureTextMetrics(const std::string& text, const return textMetrics; } -void CanvasPaintMethod::PaintText( - const OffsetF& offset, const SizeF& frameSize, double x, double y, bool isStroke, bool hasShadow) +void CanvasPaintMethod::PaintText(const OffsetF& offset, const SizeF& frameSize, double x, double y, + std::optional maxWidth, bool isStroke, bool hasShadow) { - paragraph_->Layout(frameSize.Width()); + paragraph_->Layout(FLT_MAX); auto width = paragraph_->GetMaxIntrinsicWidth(); if (frameSize.Width() > width) { paragraph_->Layout(std::ceil(width)); @@ -472,16 +474,33 @@ void CanvasPaintMethod::PaintText( isStroke ? strokeState_.GetTextStyle().GetTextBaseline() : fillState_.GetTextStyle().GetTextBaseline(); double dy = offset.GetY() + y + GetBaselineOffset(baseline, paragraph_); + std::optional scale = CalcTextScale(paragraph_->GetMaxIntrinsicWidth(), maxWidth); if (hasShadow) { skCanvas_->save(); auto shadowOffsetX = shadow_.GetOffset().GetX(); auto shadowOffsetY = shadow_.GetOffset().GetY(); + if (scale.has_value()) { + if (!NearZero(scale.value())) { + dx /= scale.value(); + shadowOffsetX /= scale.value(); + } + skCanvas_->scale(scale.value(), 1); + } paragraph_->Paint(skCanvas_.get(), dx + shadowOffsetX, dy + shadowOffsetY); skCanvas_->restore(); return; } - - paragraph_->Paint(skCanvas_.get(), dx, dy); + if (scale.has_value()) { + if (!NearZero(scale.value())) { + dx /= scale.value(); + } + skCanvas_->save(); + skCanvas_->scale(scale.value(), 1); + paragraph_->Paint(skCanvas_.get(), dx, dy); + skCanvas_->restore(); + } else { + paragraph_->Paint(skCanvas_.get(), dx, dy); + } } double CanvasPaintMethod::GetBaselineOffset(TextBaseline baseline, std::unique_ptr& paragraph) diff --git a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h index 63254ddf4bb..47f1a13defe 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h +++ b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.h @@ -65,8 +65,10 @@ public: std::string ToDataURL(const std::string& args); std::string GetJsonData(const std::string& path); - void FillText(PaintWrapper* paintWrapper, const std::string& text, double x, double y); - void StrokeText(PaintWrapper* paintWrapper, const std::string& text, double x, double y); + void FillText( + PaintWrapper* paintWrapper, const std::string& text, double x, double y, std::optional maxWidth); + void StrokeText( + PaintWrapper* paintWrapper, const std::string& text, double x, double y, std::optional maxWidth); double MeasureText(const std::string& text, const PaintState& state); double MeasureTextHeight(const std::string& text, const PaintState& state); TextMetrics MeasureTextMetrics(const std::string& text, const PaintState& state); @@ -80,8 +82,8 @@ private: void ImageObjFailed() override; sk_sp GetImage(const std::string& src) override; - void PaintText( - const OffsetF& offset, const SizeF& contentSize, double x, double y, bool isStroke, bool hasShadow = false); + void PaintText(const OffsetF& offset, const SizeF& contentSize, double x, double y, std::optional maxWidth, + bool isStroke, bool hasShadow = false); double GetBaselineOffset(TextBaseline baseline, std::unique_ptr& paragraph); bool UpdateParagraph(const OffsetF& offset, const std::string& text, bool isStroke, bool hasShadow = false); void UpdateTextStyleForeground(const OffsetF& offset, bool isStroke, txt::TextStyle& txtStyle, bool hasShadow); diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp index f7e0b98a4d4..85148060a30 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp @@ -1628,4 +1628,35 @@ bool CustomPaintPaintMethod::HasImageShadow() const return !(NearZero(imageShadow_->GetOffset().GetX()) && NearZero(imageShadow_->GetOffset().GetY()) && NearZero(imageShadow_->GetBlurRadius())); } + +std::optional CustomPaintPaintMethod::CalcTextScale(double maxIntrinsicWidth, std::optional maxWidth) +{ + std::optional scale; + if (NearEqual(maxIntrinsicWidth, 0) || !maxWidth.has_value()) { + return scale; + } + if (Negative(maxWidth.value())) { + maxWidth = 0.0f; + } + double maxWidthValue = maxWidth.value(); + if (GreatNotEqual(maxIntrinsicWidth, maxWidthValue)) { + scale = maxWidthValue / maxIntrinsicWidth; + } + return scale; +} + +TransformParam CustomPaintPaintMethod::GetTransform() const +{ + TransformParam param; + if (skCanvas_.get() != nullptr) { + SkMatrix matrix = skCanvas_->getTotalMatrix(); + param.scaleX = matrix.getScaleX(); + param.scaleY = matrix.getScaleY(); + param.skewX = matrix.getSkewX(); + param.skewY = matrix.getSkewY(); + param.translateX = matrix.getTranslateX(); + param.translateY = matrix.getTranslateY(); + } + return param; +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h index 772e75d4fc8..7af2a935b9f 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.h @@ -89,6 +89,7 @@ public: void Scale(double x, double y); void Rotate(double angle); virtual void SetTransform(const TransformParam& param) = 0; + virtual TransformParam GetTransform() const; void ResetTransform(); void Transform(const TransformParam& param); void Translate(double x, double y); @@ -293,6 +294,7 @@ public: } protected: + std::optional CalcTextScale(double maxIntrinsicWidth, std::optional maxWidth); bool HasShadow() const; void UpdateLineDash(SkPaint& paint); void UpdatePaintShader(const OffsetF& offset, SkPaint& paint, const Ace::Gradient& gradient); diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp index 46db2a74a21..f7a7d7ed799 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.cpp @@ -281,10 +281,10 @@ void CustomPaintPattern::QuadraticCurveTo(const QuadraticCurveParam& param) host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } -void CustomPaintPattern::FillText(const std::string& text, double x, double y) +void CustomPaintPattern::FillText(const std::string& text, double x, double y, std::optional maxWidth) { - auto task = [text, x, y](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { - paintMethod.FillText(paintWrapper, text, x, y); + auto task = [text, x, y, maxWidth](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { + paintMethod.FillText(paintWrapper, text, x, y, maxWidth); }; paintMethod_->PushTask(task); auto host = GetHost(); @@ -292,10 +292,10 @@ void CustomPaintPattern::FillText(const std::string& text, double x, double y) host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } -void CustomPaintPattern::StrokeText(const std::string& text, double x, double y) +void CustomPaintPattern::StrokeText(const std::string& text, double x, double y, std::optional maxWidth) { - auto task = [text, x, y](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { - paintMethod.StrokeText(paintWrapper, text, x, y); + auto task = [text, x, y, maxWidth](CanvasPaintMethod& paintMethod, PaintWrapper* paintWrapper) { + paintMethod.StrokeText(paintWrapper, text, x, y, maxWidth); }; paintMethod_->PushTask(task); auto host = GetHost(); @@ -842,4 +842,9 @@ void CustomPaintPattern::SetFilterParam(const std::string& filterStr) CHECK_NULL_VOID(host); host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } + +TransformParam CustomPaintPattern::GetTransform() const +{ + return paintMethod_->GetTransform(); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.h b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.h index 75eb4f280d6..4aae8b6f4df 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.h +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_pattern.h @@ -73,8 +73,8 @@ public: void BezierCurveTo(const BezierCurveParam& param); void QuadraticCurveTo(const QuadraticCurveParam& param); - void FillText(const std::string& text, double x, double y); - void StrokeText(const std::string& text, double x, double y); + void FillText(const std::string& text, double x, double y, std::optional maxWidth); + void StrokeText(const std::string& text, double x, double y, std::optional maxWidth); double MeasureText(const std::string& text, const PaintState& state); double MeasureTextHeight(const std::string& text, const PaintState& state); TextMetrics MeasureTextMetrics(const std::string& text, const PaintState& state); @@ -133,6 +133,7 @@ public: void SetTextDirection(TextDirection direction); void SetFilterParam(const std::string& filterStr); + TransformParam GetTransform() const; private: void OnAttachToFrameNode() override; diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp index 447a513ed28..62b8b6b3a36 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp @@ -287,27 +287,29 @@ std::unique_ptr OffscreenCanvasPaintMethod::GetImageData( return imageData; } -void OffscreenCanvasPaintMethod::FillText(const std::string& text, double x, double y, const PaintState& state) +void OffscreenCanvasPaintMethod::FillText( + const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state) { if (!UpdateOffParagraph(text, false, state, HasShadow())) { return; } - PaintText(text, x, y, false, HasShadow()); + PaintText(text, x, y, maxWidth, false, HasShadow()); } -void OffscreenCanvasPaintMethod::StrokeText(const std::string& text, double x, double y, const PaintState& state) +void OffscreenCanvasPaintMethod::StrokeText( + const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state) { if (HasShadow()) { if (!UpdateOffParagraph(text, true, state, true)) { return; } - PaintText(text, x, y, true, true); + PaintText(text, x, y, maxWidth, true, true); } if (!UpdateOffParagraph(text, true, state)) { return; } - PaintText(text, x, y, true); + PaintText(text, x, y, maxWidth, true); } double OffscreenCanvasPaintMethod::MeasureText(const std::string& text, const PaintState& state) @@ -378,9 +380,9 @@ TextMetrics OffscreenCanvasPaintMethod::MeasureTextMetrics(const std::string& te } void OffscreenCanvasPaintMethod::PaintText( - const std::string& text, double x, double y, bool isStroke, bool hasShadow) + const std::string& text, double x, double y, std::optional maxWidth, bool isStroke, bool hasShadow) { - paragraph_->Layout(width_); + paragraph_->Layout(FLT_MAX); if (width_ > paragraph_->GetMaxIntrinsicWidth()) { paragraph_->Layout(std::ceil(paragraph_->GetMaxIntrinsicWidth())); } @@ -390,15 +392,33 @@ void OffscreenCanvasPaintMethod::PaintText( isStroke ? strokeState_.GetTextStyle().GetTextBaseline() : fillState_.GetTextStyle().GetTextBaseline(); double dy = y + GetBaselineOffset(baseline, paragraph_); + std::optional scale = CalcTextScale(paragraph_->GetMaxIntrinsicWidth(), maxWidth); if (hasShadow) { skCanvas_->save(); auto shadowOffsetX = shadow_.GetOffset().GetX(); auto shadowOffsetY = shadow_.GetOffset().GetY(); + if (scale.has_value()) { + if (!NearZero(scale.value())) { + dx /= scale.value(); + shadowOffsetX /= scale.value(); + } + skCanvas_->scale(scale.value(), 1); + } paragraph_->Paint(skCanvas_.get(), dx + shadowOffsetX, dy + shadowOffsetY); skCanvas_->restore(); return; } - paragraph_->Paint(skCanvas_.get(), dx, dy); + if (scale.has_value()) { + if (!NearZero(scale.value())) { + dx /= scale.value(); + } + skCanvas_->save(); + skCanvas_->scale(scale.value(), 1); + paragraph_->Paint(skCanvas_.get(), dx, dy); + skCanvas_->restore(); + } else { + paragraph_->Paint(skCanvas_.get(), dx, dy); + } } double OffscreenCanvasPaintMethod::GetBaselineOffset(TextBaseline baseline, std::unique_ptr& paragraph) diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h index 59cd6891c9f..9395162187b 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.h @@ -33,8 +33,9 @@ public: std::unique_ptr GetImageData(double left, double top, double width, double height); std::string ToDataURL(const std::string& type, const double quality); - void FillText(const std::string& text, double x, double y, const PaintState& state); - void StrokeText(const std::string& text, double x, double y, const PaintState& state); + void FillText(const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state); + void StrokeText( + const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state); double MeasureText(const std::string& text, const PaintState& state); double MeasureTextHeight(const std::string& text, const PaintState& state); TextMetrics MeasureTextMetrics(const std::string& text, const PaintState& state); @@ -54,7 +55,8 @@ private: sk_sp GetImage(const std::string& src) override { return sk_sp(); } - void PaintText(const std::string& text, double x, double y, bool isStroke, bool hasShadow = false); + void PaintText(const std::string& text, double x, double y, std::optional maxWidth, bool isStroke, + bool hasShadow = false); double GetBaselineOffset(TextBaseline baseline, std::unique_ptr& paragraph); bool UpdateOffParagraph(const std::string& text, bool isStroke, const PaintState& state, bool hasShadow = false); void UpdateTextStyleForeground(bool isStroke, txt::TextStyle& txtStyle, bool hasShadow); diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.cpp b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.cpp index c97723347db..cfbb782c68c 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.cpp @@ -129,14 +129,16 @@ void OffscreenCanvasPattern::QuadraticCurveTo(const QuadraticCurveParam& param) offscreenPaintMethod_->QuadraticCurveTo(nullptr, param); } -void OffscreenCanvasPattern::FillText(const std::string& text, double x, double y, const PaintState& state) +void OffscreenCanvasPattern::FillText( + const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state) { - offscreenPaintMethod_->FillText(text, x, y, state); + offscreenPaintMethod_->FillText(text, x, y, maxWidth, state); } -void OffscreenCanvasPattern::StrokeText(const std::string& text, double x, double y, const PaintState& state) +void OffscreenCanvasPattern::StrokeText( + const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state) { - offscreenPaintMethod_->StrokeText(text, x, y, state); + offscreenPaintMethod_->StrokeText(text, x, y, maxWidth, state); } double OffscreenCanvasPattern::MeasureText(const std::string& text, const PaintState& state) @@ -392,4 +394,9 @@ std::string OffscreenCanvasPattern::ToDataURL(const std::string& type, const dou { return offscreenPaintMethod_->ToDataURL(type, quality); } + +TransformParam OffscreenCanvasPattern::GetTransform() const +{ + return offscreenPaintMethod_->GetTransform(); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.h b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.h index 9d0c4101784..11b462ed984 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.h +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_pattern.h @@ -51,8 +51,9 @@ public: void BezierCurveTo(const BezierCurveParam& param); void QuadraticCurveTo(const QuadraticCurveParam& param); - void FillText(const std::string& text, double x, double y, const PaintState& state); - void StrokeText(const std::string& text, double x, double y, const PaintState& state); + void FillText(const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state); + void StrokeText( + const std::string& text, double x, double y, std::optional maxWidth, const PaintState& state); double MeasureText(const std::string& text, const PaintState& state); double MeasureTextHeight(const std::string& text, const PaintState& state); TextMetrics MeasureTextMetrics(const std::string& text, const PaintState& state); @@ -107,6 +108,7 @@ public: void ResetTransform(); void Transform(const TransformParam& param); void Translate(double x, double y); + TransformParam GetTransform() const; std::string ToDataURL(const std::string& type, const double quality); private: diff --git a/frameworks/core/components_ng/pattern/preview_mock/preview_mock_model_ng.cpp b/frameworks/core/components_ng/pattern/preview_mock/preview_mock_model_ng.cpp index 7437db3c514..c540b7ecf1e 100644 --- a/frameworks/core/components_ng/pattern/preview_mock/preview_mock_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/preview_mock/preview_mock_model_ng.cpp @@ -37,7 +37,8 @@ void PreviewMockModelNG::Create(const std::string& content) auto pattern = frameNode->GetPattern(); pattern->SetAntiAlias(true); pattern->UpdateFontSize(DEFAULT_FONT_SIZE); - pattern->FillText(presentationText, 0, DEFAULT_OFFSET); + std::optional maxWidth; + pattern->FillText(presentationText, 0, DEFAULT_OFFSET, maxWidth); auto layoutProperty = frameNode->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); layoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(DEFAULT_HEIGHT))); diff --git a/frameworks/core/components_ng/test/pattern/custom_paint/custom_paint_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/custom_paint/custom_paint_pattern_test_ng.cpp index 6136e3defbe..40b6c04afb7 100644 --- a/frameworks/core/components_ng/test/pattern/custom_paint/custom_paint_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/custom_paint/custom_paint_pattern_test_ng.cpp @@ -300,11 +300,11 @@ HWTEST_F(CustomPaintPatternTestNg, CustomPaintPatternTestNg006, TestSize.Level1) * @tc.steps2: Test functions about text. * @tc.expected: The task queue of paintMethod is changed to unempty. */ - customPattern->FillText(DEFAULT_STR, DEFAULT_DOUBLE0, DEFAULT_DOUBLE0); + customPattern->FillText(DEFAULT_STR, DEFAULT_DOUBLE0, DEFAULT_DOUBLE0, std::optional(0)); EXPECT_TRUE(paintMethod->HasTask()); paintMethod->tasks_.clear(); - customPattern->StrokeText(DEFAULT_STR, DEFAULT_DOUBLE0, DEFAULT_DOUBLE0); + customPattern->StrokeText(DEFAULT_STR, DEFAULT_DOUBLE0, DEFAULT_DOUBLE0, std::optional(0)); EXPECT_TRUE(paintMethod->HasTask()); TextAlign textAlign = TextAlign::CENTER; From ab7c05e8fb57d39bf6f630a3cf303da00cf0fbbb Mon Sep 17 00:00:00 2001 From: liyujie Date: Wed, 24 May 2023 17:03:57 +0800 Subject: [PATCH 71/99] add ace coverage flags to ace_config Signed-off-by: liyujie Change-Id: I70e574e0db4e78401927abb7432b1bd31d0168d7 --- BUILD.gn | 6 ++++++ build/BUILD.gn | 5 ++++- .../test/pattern/swiper/swiper_pattern_test_ng.cpp | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a92ca379320..cfd51a5a8f5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -63,6 +63,12 @@ config("ace_config") { cflags_cc += [ "-std=c++17" ] defines += [ "_USE_MATH_DEFINES" ] } + + ldflags = [] + if (ace_engine_feature_enable_coverage) { + cflags += [ "--coverage" ] + ldflags += [ "--coverage" ] + } } config("ace_test_config") { diff --git a/build/BUILD.gn b/build/BUILD.gn index 0695d70cef0..7e658838243 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -120,7 +120,10 @@ foreach(item, ace_platforms) { ] } - configs = [ "$ace_root:ace_test_config" ] + configs = [ + "$ace_root:ace_test_config", + "$ace_root/test/unittest:ace_coverage_config", + ] deps = [ "$ace_root/adapter/ohos/osal:ace_osal_ohos", diff --git a/frameworks/core/components_ng/test/pattern/swiper/swiper_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/swiper/swiper_pattern_test_ng.cpp index 05c61df8b8d..2d379f42168 100644 --- a/frameworks/core/components_ng/test/pattern/swiper/swiper_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/swiper/swiper_pattern_test_ng.cpp @@ -107,7 +107,6 @@ HWTEST_F(SwiperPatternTestNg, SwiperEvent001, TestSize.Level1) auto pattern = swiperNode->GetPattern(); pattern->HandleTouchEvent(touchEventInfo); EXPECT_FALSE(pattern->indicatorDoingAnimation_); - const char* name = "HandleTouchDown"; pattern->HandleTouchEvent(touchEventInfo); EXPECT_FALSE(pattern->indicatorDoingAnimation_); From 898832b1ba9c46b8dfb81efe229b9cef0cb79a35 Mon Sep 17 00:00:00 2001 From: wanglichao Date: Wed, 24 May 2023 17:39:20 +0800 Subject: [PATCH 72/99] Grid TDD Signed-off-by: wanglichao Change-Id: I1af23e8fd20ef97c6734140335776c78d9f541a9 --- .../test/pattern/grid/grid_test_ng.cpp | 889 +++++++++--------- 1 file changed, 442 insertions(+), 447 deletions(-) diff --git a/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp b/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp index c2be873d152..a0a4768e923 100644 --- a/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/grid/grid_test_ng.cpp @@ -60,17 +60,15 @@ constexpr int32_t CHILDREN_COUNT = 100; constexpr int32_t ALGORITHM_RELATE_LALUE_FIRST = 2; constexpr int32_t ALGORITHM_RELATE_LALUE_SECOND = 0; const SizeF CONTAINER_SIZE(DEVICE_WIDTH, DEVICE_HEIGHT); -const Dimension GRID_ROWS_GAP = Dimension(5, DimensionUnit::PX); -const std::string SCROLL_BAR_COLOR = "#909090"; -constexpr float DEFAULT_ROOT_WIDTH = 720.f; -constexpr float DEFAULT_ROOT_HEIGHT = 1136.f; -constexpr float DEFAULT_ITEM_HEIGHT = 100.f; -constexpr float DEFAULT_ITEM_WIDTH = 100.f; -constexpr float DEFAULT_GRID_HEIGHT = 300.f; +const Dimension GRID_ROWS_GAP = Dimension(5); +constexpr float ITEM_HEIGHT = 100.f; +constexpr float ITEM_WIDTH = 100.f; +constexpr float GRID_HEIGHT = 300.f; +const std::string TEMPLATE_4 = "1fr 1fr 1fr 1fr"; } // namespace class GridTestNg : public testing::Test { -public: +protected: static void SetUpTestSuite(); static void TearDownTestSuite(); void SetUp() override; @@ -78,15 +76,18 @@ public: void GetInstance(); static void SetWidth(const Dimension& width); static void SetHeight(const Dimension& height); - void CreateGridItem(int32_t number); - void CreateHorizontalGridItem(int32_t number); - void CreateGridItemWithButton(int32_t number); - void CreateHorizontalGridItemWithButton(int32_t number); + void CreateGridItem(int32_t count = 10, Axis direction = Axis::VERTICAL, bool focusable = false); RefPtr RunMeasureAndLayout( - float width = DEFAULT_ROOT_WIDTH, float height = DEFAULT_GRID_HEIGHT); + float width = DEVICE_WIDTH, float height = GRID_HEIGHT); RefPtr GetItemFrameNode(int32_t index); RefPtr GetItemPattern(int32_t index); RefPtr GetItemFocusHub(int32_t index); + void UpdateCurrentOffset(float offset); + void MouseSelect(Offset start, Offset end); + void MouseSelectRelease(); + + testing::AssertionResult IsEqualNextFocusNode( + int32_t currentIndex, std::map next); RefPtr frameNode_; RefPtr pattern_; @@ -145,48 +146,17 @@ void GridTestNg::SetHeight(const Dimension& height) layoutProperty->UpdateUserDefinedIdealSize(CalcSize(std::nullopt, CalcLength(height))); } -void GridTestNg::CreateGridItem(int32_t number) +void GridTestNg::CreateGridItem(int32_t count, Axis direction, bool focusable) { - for (int32_t i = 0; i < number; i++) { + for (int32_t i = 0; i < count; i++) { GridItemModelNG gridItemModel; gridItemModel.Create(); - SetHeight(Dimension(DEFAULT_ITEM_HEIGHT)); - ViewStackProcessor::GetInstance()->Pop(); - } -} - -void GridTestNg::CreateHorizontalGridItem(int32_t number) -{ - for (int32_t i = 0; i < number; i++) { - GridItemModelNG gridItemModel; - gridItemModel.Create(); - SetWidth(Dimension(DEFAULT_ITEM_WIDTH)); - ViewStackProcessor::GetInstance()->Pop(); - } -} - -void GridTestNg::CreateGridItemWithButton(int32_t number) -{ - for (int32_t i = 0; i < number; i++) { - GridItemModelNG gridItemModel; - gridItemModel.Create(); - SetHeight(Dimension(DEFAULT_ITEM_HEIGHT)); - { - ButtonModelNG buttonModelNG; - buttonModelNG.CreateWithLabel("label"); - ViewStackProcessor::GetInstance()->Pop(); + if (direction == Axis::VERTICAL) { + SetHeight(Dimension(ITEM_HEIGHT)); + } else { + SetWidth(Dimension(ITEM_WIDTH)); } - ViewStackProcessor::GetInstance()->Pop(); - } -} - -void GridTestNg::CreateHorizontalGridItemWithButton(int32_t number) -{ - for (int32_t i = 0; i < number; i++) { - GridItemModelNG gridItemModel; - gridItemModel.Create(); - SetWidth(Dimension(DEFAULT_ITEM_WIDTH)); - { + if (focusable) { ButtonModelNG buttonModelNG; buttonModelNG.CreateWithLabel("label"); ViewStackProcessor::GetInstance()->Pop(); @@ -200,8 +170,8 @@ RefPtr GridTestNg::RunMeasureAndLayout(float width, float height) RefPtr layoutWrapper = frameNode_->CreateLayoutWrapper(false, false); layoutWrapper->SetActive(); LayoutConstraintF LayoutConstraint; - LayoutConstraint.parentIdealSize = { DEFAULT_ROOT_WIDTH, DEFAULT_ROOT_HEIGHT }; - LayoutConstraint.percentReference = { DEFAULT_ROOT_WIDTH, DEFAULT_ROOT_HEIGHT }; + LayoutConstraint.parentIdealSize = { DEVICE_WIDTH, DEVICE_HEIGHT }; + LayoutConstraint.percentReference = { DEVICE_WIDTH, DEVICE_HEIGHT }; LayoutConstraint.selfIdealSize = { width, height }; LayoutConstraint.maxSize = { width, height }; layoutWrapper->Measure(LayoutConstraint); @@ -212,22 +182,70 @@ RefPtr GridTestNg::RunMeasureAndLayout(float width, float height) RefPtr GridTestNg::GetItemFrameNode(int32_t index) { - auto item = frameNode_->GetChildAtIndex(index); - return AceType::DynamicCast(item); + return AceType::DynamicCast(frameNode_->GetChildAtIndex(index)); } RefPtr GridTestNg::GetItemPattern(int32_t index) { - auto item = frameNode_->GetChildAtIndex(index); - auto itemFrameNode = AceType::DynamicCast(item); - return itemFrameNode->GetPattern(); + return GetItemFrameNode(index)->GetPattern(); } RefPtr GridTestNg::GetItemFocusHub(int32_t index) { - auto item = frameNode_->GetChildAtIndex(index); - auto itemFrameNode = AceType::DynamicCast(item); - return itemFrameNode->GetOrCreateFocusHub(); + return GetItemFrameNode(index)->GetOrCreateFocusHub(); +} + +void GridTestNg::MouseSelect(Offset start, Offset end) +{ + MouseInfo info; + info.SetButton(MouseButton::LEFT_BUTTON); + info.SetAction(MouseAction::PRESS); + info.SetLocalLocation(start); + pattern_->HandleMouseEventWithoutKeyboard(info); + if (start != end) { + info.SetAction(MouseAction::MOVE); + info.SetLocalLocation(end); + pattern_->HandleMouseEventWithoutKeyboard(info); + } +} + +void GridTestNg::MouseSelectRelease() +{ + MouseInfo info; + info.SetButton(MouseButton::LEFT_BUTTON); + info.SetAction(MouseAction::RELEASE); + pattern_->HandleMouseEventWithoutKeyboard(info); +} + +void GridTestNg::UpdateCurrentOffset(float offset) +{ + pattern_->UpdateCurrentOffset(offset, SCROLL_FROM_UPDATE); + RunMeasureAndLayout(); +} + +testing::AssertionResult GridTestNg::IsEqualNextFocusNode( + int32_t currentIndex, std::map next) +{ + RefPtr currentFocusNode = GetItemFocusHub(currentIndex); + currentFocusNode->RequestFocusImmediately(); + for (auto iter = next.begin(); iter != next.end(); iter++) { + FocusStep step = iter->first; + int32_t nextIndex = iter->second; + RefPtr nextFocusNode = pattern_->GetNextFocusNode(step, currentFocusNode).Upgrade(); + if (nextIndex == -1 && nextFocusNode != nullptr) { + return testing::AssertionFailure() << + "Next FocusNode is not null." << + " FocusStep: " << static_cast(step) << + " nextIndex: " << nextIndex; + } + if (nextIndex != -1 && nextFocusNode != GetItemFocusHub(nextIndex)) { + return testing::AssertionFailure() << + "Get wrong next FocusNode." << + " FocusStep: " << static_cast(step) << + " nextIndex: " << nextIndex; + } + } + return testing::AssertionSuccess(); } /** @@ -245,58 +263,38 @@ HWTEST_F(GridTestNg, Property001, TestSize.Level1) gridModelNG.SetColumnsTemplate("1fr 1fr"); gridModelNG.SetRowsGap(Dimension(5)); gridModelNG.SetColumnsGap(Dimension(10)); - gridModelNG.SetCachedCount(5); - gridModelNG.SetLayoutDirection(FlexDirection::ROW); - gridModelNG.SetMaxCount(10); - gridModelNG.SetMinCount(1); - gridModelNG.SetCellLength(200); - gridModelNG.SetEditable(true); gridModelNG.SetEdgeEffect(EdgeEffect::SPRING); - gridModelNG.SetScrollBarMode(static_cast(NG::DisplayMode::ON)); - gridModelNG.SetScrollBarWidth("10px"); - gridModelNG.SetScrollBarColor("#909090"); CreateGridItem(10); GetInstance(); RunMeasureAndLayout(); - /** - * @tc.steps: step1. compare grid properties and expected value. - * @tc.expected: grid properties equals expected value. - */ EXPECT_EQ(layoutProperty_->GetRowsTemplateValue(), "1fr 1fr 1fr"); EXPECT_EQ(layoutProperty_->GetColumnsTemplateValue(), "1fr 1fr"); EXPECT_EQ(layoutProperty_->GetRowsGapValue(), Dimension(5)); EXPECT_EQ(layoutProperty_->GetColumnsGapValue(), Dimension(10)); - EXPECT_EQ(layoutProperty_->GetCachedCountValue(), 5); - EXPECT_EQ(layoutProperty_->GetGridDirectionValue(), FlexDirection::ROW); - EXPECT_EQ(layoutProperty_->GetMaxCountValue(), 10); - EXPECT_EQ(layoutProperty_->GetMinCountValue(), 1); - EXPECT_EQ(layoutProperty_->GetCellLengthValue(), 200); - EXPECT_EQ(layoutProperty_->GetEditableValue(), true); EXPECT_EQ(layoutProperty_->GetEdgeEffectValue(), EdgeEffect::SPRING); - auto paintProperty = frameNode_->GetPaintProperty(); - ASSERT_NE(paintProperty, nullptr); - EXPECT_EQ(paintProperty->GetScrollBarMode(), NG::DisplayMode::ON); - EXPECT_EQ(paintProperty->GetScrollBarWidth(), StringUtils::StringToDimensionWithUnit("10px")); - EXPECT_EQ(paintProperty->GetScrollBarColor(), Color::FromString("#909090")); - auto json = JsonUtil::Create(true); layoutProperty_->ToJsonValue(json); EXPECT_NE(json, nullptr); + + layoutProperty_->UpdateEdgeEffect(EdgeEffect::FADE); + auto json2 = JsonUtil::Create(true); + layoutProperty_->ToJsonValue(json2); + EXPECT_EQ(json2->GetString("edgeEffect"), "EdgeEffect.Fade"); } /** * @tc.name: Property002 - * @tc.desc: Test illegal row/col template. + * @tc.desc: Test empty row/col template. * @tc.type: FUNC */ HWTEST_F(GridTestNg, Property002, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetRowsTemplate("abcd1234 *&^%$"); - gridModelNG.SetColumnsTemplate("abcd1234 *&^%$"); + gridModelNG.SetRowsTemplate(""); + gridModelNG.SetColumnsTemplate(""); CreateGridItem(10); GetInstance(); RunMeasureAndLayout(); @@ -305,31 +303,31 @@ HWTEST_F(GridTestNg, Property002, TestSize.Level1) * @tc.steps: step1. compare grid properties and expected value after change. * @tc.expected: grid properties equals expected value after change. */ - EXPECT_EQ(layoutProperty_->GetRowsTemplateValue(), ""); - EXPECT_EQ(layoutProperty_->GetColumnsTemplateValue(), ""); + EXPECT_EQ(layoutProperty_->GetRowsTemplateValue(), "1fr"); + EXPECT_EQ(layoutProperty_->GetColumnsTemplateValue(), "1fr"); } /** * @tc.name: Property003 - * @tc.desc: Test special property. + * @tc.desc: Test Negative Gap * @tc.type: FUNC */ HWTEST_F(GridTestNg, Property003, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetMultiSelectable(true); - gridModelNG.SetSupportAnimation(true); + gridModelNG.SetRowsGap(Dimension(-5)); + gridModelNG.SetColumnsGap(Dimension(-10)); CreateGridItem(10); GetInstance(); RunMeasureAndLayout(); /** - * @tc.steps: step1. Check whether the updated properties and parameters are correct. - * @tc.expected: parameters are correct. + * @tc.steps: step1. Verify GapValue + * @tc.expected: Gap not be set */ - EXPECT_TRUE(pattern_->multiSelectable_); - EXPECT_TRUE(pattern_->supportAnimation_); + EXPECT_EQ(layoutProperty_->GetRowsGap(), std::nullopt); + EXPECT_EQ(layoutProperty_->GetColumnsGap(), std::nullopt); } /** @@ -605,7 +603,7 @@ HWTEST_F(GridTestNg, GridTest004, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); for (int32_t i = 0; i < 6; ++i) { EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -624,7 +622,7 @@ HWTEST_F(GridTestNg, GridTest005, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 250.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 250.f); for (int32_t i = 0; i < 9; ++i) { EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -643,9 +641,9 @@ HWTEST_F(GridTestNg, GridTest006, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateCurrentOffset(-50.f, SCROLL_FROM_UPDATE); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); for (int32_t i = 0; i < 9; ++i) { EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -664,9 +662,9 @@ HWTEST_F(GridTestNg, GridTest007, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateCurrentOffset(-100.f, SCROLL_FROM_UPDATE); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); for (int32_t i = 3; i < 9; ++i) { EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -685,9 +683,9 @@ HWTEST_F(GridTestNg, GridTest008, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateStartIndex(8); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); for (int32_t i = 0; i < 3; ++i) { EXPECT_FALSE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -706,9 +704,9 @@ HWTEST_F(GridTestNg, GridTest009, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateStartIndex(1); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); for (int32_t i = 6; i < 9; ++i) { EXPECT_FALSE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -727,9 +725,9 @@ HWTEST_F(GridTestNg, GridTest010, TestSize.Level1) CreateGridItem(9); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateStartIndex(3); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); for (int32_t i = 0; i < 6; ++i) { EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(i, false)->IsActive()); } @@ -748,9 +746,9 @@ HWTEST_F(GridTestNg, GridTest011, TestSize.Level1) CreateGridItem(10); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateStartIndex(8); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); EXPECT_FALSE(layoutWrapper->GetOrCreateChildByIndex(9, false)->IsActive()); } @@ -767,14 +765,14 @@ HWTEST_F(GridTestNg, GridTest012, TestSize.Level1) CreateGridItem(10); GetInstance(); - RefPtr layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + RefPtr layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); pattern_->UpdateStartIndex(9); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(9, false)->IsActive()); EXPECT_FALSE(layoutWrapper->GetOrCreateChildByIndex(0, false)->IsActive()); pattern_->UpdateStartIndex(0); - layoutWrapper = RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 200.f); + layoutWrapper = RunMeasureAndLayout(DEVICE_WIDTH, 200.f); EXPECT_FALSE(layoutWrapper->GetOrCreateChildByIndex(9, false)->IsActive()); EXPECT_TRUE(layoutWrapper->GetOrCreateChildByIndex(0, false)->IsActive()); } @@ -788,7 +786,7 @@ HWTEST_F(GridTestNg, EventHub001, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); @@ -796,7 +794,7 @@ HWTEST_F(GridTestNg, EventHub001, TestSize.Level1) /** * @tc.steps: step1. Mock GetPaintRectWithTransform. */ - RectF gridRect(0.f, 0.f, DEFAULT_ROOT_WIDTH, DEFAULT_ROOT_HEIGHT); + RectF gridRect(0.f, 0.f, DEVICE_WIDTH, DEVICE_HEIGHT); EXPECT_CALL( *(AceType::RawPtr(AceType::DynamicCast(frameNode_->renderContext_))), GetPaintRectWithTransform()) @@ -806,7 +804,7 @@ HWTEST_F(GridTestNg, EventHub001, TestSize.Level1) * @tc.steps: step2. Run GetInsertPosition func. * @tc.expected: Verify return value. */ - EXPECT_EQ(eventHub_->GetInsertPosition(DEFAULT_ROOT_WIDTH + 1, DEFAULT_ROOT_HEIGHT), -1); // out of grid + EXPECT_EQ(eventHub_->GetInsertPosition(DEVICE_WIDTH + 1, DEVICE_HEIGHT), -1); // out of grid EXPECT_EQ(eventHub_->GetInsertPosition(0.f, 0.f), 0); // 0, 0 EXPECT_EQ(eventHub_->GetInsertPosition(90.f, 50.f), 0); // first item EXPECT_EQ(eventHub_->GetInsertPosition(360.f, 50.f), 1); // between the second and third @@ -825,7 +823,7 @@ HWTEST_F(GridTestNg, EventHub002, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); @@ -844,7 +842,7 @@ HWTEST_F(GridTestNg, PositionController001, TestSize.Level1) RefPtr positionController = gridModelNG.CreatePositionController(); RefPtr scrollBarProxy = gridModelNG.CreateScrollBarProxy(); gridModelNG.Create(positionController, scrollBarProxy); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(14); GetInstance(); RunMeasureAndLayout(); @@ -914,8 +912,8 @@ HWTEST_F(GridTestNg, PositionController002, TestSize.Level1) RefPtr positionController = gridModelNG.CreatePositionController(); RefPtr scrollBarProxy = gridModelNG.CreateScrollBarProxy(); gridModelNG.Create(positionController, scrollBarProxy); - gridModelNG.SetRowsTemplate("1fr 1fr 1fr 1fr"); - CreateHorizontalGridItem(14); + gridModelNG.SetRowsTemplate(TEMPLATE_4); + CreateGridItem(14, Axis::HORIZONTAL); GetInstance(); /** @@ -973,7 +971,7 @@ HWTEST_F(GridTestNg, LayoutInfo001, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); @@ -982,7 +980,7 @@ HWTEST_F(GridTestNg, LayoutInfo001, TestSize.Level1) * @tc.steps: step1. Change Grid size. * @tc.expected: Verify endMainLineIndex_. */ - RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 100.f); + RunMeasureAndLayout(DEVICE_WIDTH, 100.f); EXPECT_EQ(pattern_->GetGridLayoutInfo().endMainLineIndex_, 1); } @@ -995,7 +993,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest001, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetMultiSelectable(true); gridModelNG.SetEditable(true); CreateGridItem(14); @@ -1050,7 +1048,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest003, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(14); GetInstance(); RunMeasureAndLayout(); @@ -1106,7 +1104,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest005, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(14); GetInstance(); RunMeasureAndLayout(); @@ -1137,7 +1135,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest006, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(14); GetInstance(); RunMeasureAndLayout(); @@ -1167,7 +1165,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest007, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(10); GetInstance(); RunMeasureAndLayout(); @@ -1216,7 +1214,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest008, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); /** * @tc.steps: step1. Create heading GridItem. @@ -1225,7 +1223,7 @@ HWTEST_F(GridTestNg, GridAccessibilityTest008, TestSize.Level1) gridItemModel.Create(); gridItemModel.SetColumnStart(0); gridItemModel.SetColumnEnd(3); - SetHeight(Dimension(DEFAULT_ITEM_HEIGHT)); + SetHeight(Dimension(ITEM_HEIGHT)); ViewStackProcessor::GetInstance()->Pop(); CreateGridItem(10); GetInstance(); @@ -1260,7 +1258,7 @@ HWTEST_F(GridTestNg, MouseSelect001, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetMultiSelectable(true); CreateGridItem(8); GetInstance(); @@ -1270,15 +1268,8 @@ HWTEST_F(GridTestNg, MouseSelect001, TestSize.Level1) * @tc.steps: step1. Click the (0, 0) point of firstItem. * @tc.expected: item not selected on MouseAction::PRESS. */ - MouseInfo info; - info.SetButton(MouseButton::LEFT_BUTTON); - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(0.f, 0.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - RefPtr firstItemPattern = GetItemPattern(0); - EXPECT_FALSE(firstItemPattern->IsSelected()); - info.SetAction(MouseAction::RELEASE); // Release the mouse to deselect. - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(Offset(0.f, 0.f), Offset(0.f, 0.f)); + EXPECT_FALSE(GetItemPattern(0)->IsSelected()); } /** @@ -1295,98 +1286,66 @@ HWTEST_F(GridTestNg, MouseSelect002, TestSize.Level1) GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetMultiSelectable(true); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); /** - * @tc.steps: step1. Select (0, 0) - (284, 100) zone. + * @tc.steps: step1. Select (0, 0) - (180, 100) zone. * @tc.expected: The 1st, 2nd, 5th, 6th items are selected. */ - MouseInfo info; - info.SetButton(MouseButton::LEFT_BUTTON); - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(0.f, 0.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(Offset(180.f, 100.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(Offset(0.f, 0.f), Offset(180.f, 100.f)); EXPECT_TRUE(GetItemPattern(0)->IsSelected()); EXPECT_TRUE(GetItemPattern(1)->IsSelected()); EXPECT_TRUE(GetItemPattern(4)->IsSelected()); EXPECT_TRUE(GetItemPattern(5)->IsSelected()); - info.SetAction(MouseAction::RELEASE); // Release the mouse to deselect. - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelectRelease(); /** * @tc.steps: step2. Select (90, 50) - (270, 150) zone, from the LEFT_TOP to the RIGHT_BOTTOM. * @tc.expected: The 1st, 2nd, 5th, 6th are selected. */ - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(LEFT_TOP); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(RIGHT_BOTTOM); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(LEFT_TOP, RIGHT_BOTTOM); EXPECT_TRUE(GetItemPattern(0)->IsSelected()); EXPECT_TRUE(GetItemPattern(1)->IsSelected()); EXPECT_TRUE(GetItemPattern(4)->IsSelected()); EXPECT_TRUE(GetItemPattern(5)->IsSelected()); - info.SetAction(MouseAction::RELEASE); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelectRelease(); /** * @tc.steps: step3. Select (90, 50) - (270, 150) zone, from the RIGHT_TOP to the LEFT_BOTTOM. * @tc.expected: The 1st, 2nd, 5th, 6th are selected. */ - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(RIGHT_TOP); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(LEFT_BOTTOM); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(RIGHT_TOP, LEFT_BOTTOM); EXPECT_TRUE(GetItemPattern(0)->IsSelected()); EXPECT_TRUE(GetItemPattern(1)->IsSelected()); EXPECT_TRUE(GetItemPattern(4)->IsSelected()); EXPECT_TRUE(GetItemPattern(5)->IsSelected()); - info.SetAction(MouseAction::RELEASE); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelectRelease(); /** * @tc.steps: step4. Select (90, 50) - (270, 150) zone, from the LEFT_BOTTOM to the RIGHT_TOP. * @tc.expected: The 1st, 2nd, 5th, 6th are selected. */ - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(LEFT_BOTTOM); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(RIGHT_TOP); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(LEFT_BOTTOM, RIGHT_TOP); EXPECT_TRUE(GetItemPattern(0)->IsSelected()); EXPECT_TRUE(GetItemPattern(1)->IsSelected()); EXPECT_TRUE(GetItemPattern(4)->IsSelected()); EXPECT_TRUE(GetItemPattern(5)->IsSelected()); - info.SetAction(MouseAction::RELEASE); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelectRelease(); /** * @tc.steps: step5. Select (90, 50) - (270, 150) zone, from the RIGHT_BOTTOM to the LEFT_TOP. * @tc.expected: The 1st, 2nd, 5th, 6th are selected. */ - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(RIGHT_BOTTOM); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(LEFT_TOP); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(RIGHT_BOTTOM, LEFT_TOP); EXPECT_TRUE(GetItemPattern(0)->IsSelected()); EXPECT_TRUE(GetItemPattern(1)->IsSelected()); EXPECT_TRUE(GetItemPattern(4)->IsSelected()); EXPECT_TRUE(GetItemPattern(5)->IsSelected()); - info.SetAction(MouseAction::RELEASE); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelectRelease(); } /** @@ -1398,20 +1357,28 @@ HWTEST_F(GridTestNg, MouseSelect003, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetMultiSelectable(true); - /** - * @tc.steps: step1. Create gridItem. - */ bool isSixthItemSelected = false; auto selectCallback = [&isSixthItemSelected](bool) { isSixthItemSelected = true; }; - for (int32_t i = 0; i < 8; i++) { + for (int32_t i = 0; i < 10; i++) { GridItemModelNG gridItemModel; gridItemModel.Create(); - SetHeight(Dimension(DEFAULT_ITEM_HEIGHT)); + SetHeight(Dimension(ITEM_HEIGHT)); + /** + * ___180__360___540___720 + * |____|__1__|__2__|____|100 + * |____|__5__|_____|____|200 + * |____|_____| 300 + */ if (i == 1) { gridItemModel.SetSelectable(false); } + if (i == 2) { + auto itemFrameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + auto itemEvent = itemFrameNode->GetEventHub(); + itemEvent->SetEnabled(false); + } if (i == 5) { gridItemModel.SetOnSelect(std::move(selectCallback)); } @@ -1421,22 +1388,14 @@ HWTEST_F(GridTestNg, MouseSelect003, TestSize.Level1) RunMeasureAndLayout(); /** - * @tc.steps: step2. Select (225, 50) - (315, 150) zone. - * @tc.expected: The 2nd item is not selected but 6th item is selected. + * @tc.steps: step2. Select (225, 50) - (315, 150) zone, include 2nd, 3rd, 6th, 7th item. + * @tc.expected: The 2nd and 3rd item is not selected but 6th item is selected. */ - MouseInfo info; - info.SetButton(MouseButton::LEFT_BUTTON); - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(225.f, 50.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(Offset(315.f, 150.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); + MouseSelect(Offset(225.f, 50.f), Offset(315.f, 150.f)); EXPECT_FALSE(GetItemPattern(1)->IsSelected()); + EXPECT_FALSE(GetItemPattern(2)->IsSelected()); EXPECT_TRUE(GetItemPattern(5)->IsSelected()); EXPECT_TRUE(isSixthItemSelected); - info.SetAction(MouseAction::RELEASE); - pattern_->HandleMouseEventWithoutKeyboard(info); } /** @@ -1448,7 +1407,7 @@ HWTEST_F(GridTestNg, MouseSelect004, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetMultiSelectable(true); CreateGridItem(8); GetInstance(); @@ -1479,12 +1438,15 @@ HWTEST_F(GridTestNg, MouseSelect005, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetMultiSelectable(true); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); + const Offset startOffset = Offset(225.f, 50.f); + const Offset endOffset = Offset(315.f, 150.f); + /** * @tc.steps: step1. Select (225, 50) - (315, 150) zone with RIGHT_BUTTON. * @tc.expected: The item is not selected. @@ -1492,81 +1454,31 @@ HWTEST_F(GridTestNg, MouseSelect005, TestSize.Level1) MouseInfo info; info.SetButton(MouseButton::RIGHT_BUTTON); // Use RIGHT_BUTTON to select. info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(225.f, 50.f)); + info.SetLocalLocation(startOffset); pattern_->HandleMouseEventWithoutKeyboard(info); info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(Offset(315.f, 150.f)); + info.SetLocalLocation(endOffset); pattern_->HandleMouseEventWithoutKeyboard(info); EXPECT_FALSE(GetItemPattern(1)->IsSelected()); - info.SetAction(MouseAction::RELEASE); - pattern_->HandleMouseEventWithoutKeyboard(info); /** - * @tc.steps: step2. Select (225, 50) - (315, 150) zone and trigger other MouseAction. - * @tc.expected: The item is still selected when trigger other MouseAction. - */ - info.SetButton(MouseButton::LEFT_BUTTON); // Use RIGHT_BUTTON to select. - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(225.f, 50.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(Offset(315.f, 150.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - EXPECT_TRUE(GetItemPattern(1)->IsSelected()); - info.SetAction(MouseAction::HOVER); // Trigger other MouseAction. - pattern_->HandleMouseEventWithoutKeyboard(info); - EXPECT_TRUE(GetItemPattern(1)->IsSelected()); -} - -/** - * @tc.name: MouseSelect006 - * @tc.desc: Test mouse right button click on selected item - * @tc.type: FUNC - */ -HWTEST_F(GridTestNg, MouseSelect006, TestSize.Level1) -{ - GridModelNG gridModelNG; - gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); - gridModelNG.SetMultiSelectable(true); - CreateGridItem(8); - GetInstance(); - RunMeasureAndLayout(); - - /** - * @tc.steps: step1. Select (0, 0) - (284, 100) zone. - * @tc.expected: The 1st, 2nd, 5th, 6th items are selected. - */ - MouseInfo info; - info.SetButton(MouseButton::LEFT_BUTTON); - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(0.f, 0.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - info.SetAction(MouseAction::MOVE); - info.SetLocalLocation(Offset(180.f, 100.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - EXPECT_TRUE(GetItemPattern(0)->IsSelected()); - EXPECT_TRUE(GetItemPattern(1)->IsSelected()); - EXPECT_TRUE(GetItemPattern(4)->IsSelected()); - EXPECT_TRUE(GetItemPattern(5)->IsSelected()); - - /** - * @tc.steps: step2. Right click on (150.f, 50.f), in selected zone. - * @tc.expected: The 1st item is still selected. - */ - info.SetButton(MouseButton::RIGHT_BUTTON); - info.SetAction(MouseAction::PRESS); - info.SetLocalLocation(Offset(150.f, 50.f)); - pattern_->HandleMouseEventWithoutKeyboard(info); - EXPECT_TRUE(GetItemPattern(0)->IsSelected()); - - /** - * @tc.steps: step3. Left click on (280.f, 100.f), out of selected zone. - * @tc.expected: The 1st item is not selected. + * @tc.steps: step2. Select (225, 50) - (315, 150) zone with HOVER + * @tc.expected: The item is not Selected */ info.SetButton(MouseButton::LEFT_BUTTON); - info.SetLocalLocation(Offset(280.f, 100.f)); + info.SetAction(MouseAction::HOVER); // HOVER + info.SetLocalLocation(startOffset); pattern_->HandleMouseEventWithoutKeyboard(info); + info.SetAction(MouseAction::MOVE); + info.SetLocalLocation(endOffset); + pattern_->HandleMouseEventWithoutKeyboard(info); + EXPECT_FALSE(GetItemPattern(1)->IsSelected()); + + /** + * @tc.steps: step3. Move distance < FRAME_SELECTION_DISTANCE + * @tc.expected: The item is not Selected + */ + MouseSelect(Offset(0.f, 0.f), Offset(1.f, 1.f)); EXPECT_FALSE(GetItemPattern(0)->IsSelected()); } @@ -1579,12 +1491,8 @@ HWTEST_F(GridTestNg, Drag001, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetEditable(true); - - /** - * @tc.steps: step1. SetOnItemDragStart to get customNode. - */ auto onItemDragStart = [](const ItemDragInfo&, int32_t) { auto dragItem = AceType::MakeRefPtr("test", 0, AceType::MakeRefPtr()); return AceType::DynamicCast(dragItem); @@ -1593,21 +1501,14 @@ HWTEST_F(GridTestNg, Drag001, TestSize.Level1) CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); - - /** - * @tc.steps: step2. Get frameNode and eventHub and RunMeasureAndLayout. - */ eventHub_->onItemDragStart_ = onItemDragStart; - /** - * @tc.steps: step3. Set info. - */ GestureEvent info; Point globalPoint = Point(270.f, 50.f); // Point at the second item. info.SetGlobalPoint(globalPoint); /** - * @tc.steps: step4. Trigger HandleOnItemDragStart. + * @tc.steps: step1. Trigger HandleOnItemDragStart, HandleOnItemDragUpdate, HandleOnItemDragEnd. * @tc.expected: Verify some values of the drag. */ eventHub_->HandleOnItemDragStart(info); @@ -1615,11 +1516,6 @@ HWTEST_F(GridTestNg, Drag001, TestSize.Level1) ASSERT_NE(eventHub_->dragDropProxy_, nullptr); auto itemFrameNode = GetItemFrameNode(1); EXPECT_EQ(eventHub_->draggingItem_, itemFrameNode); - - /** - * @tc.steps: step5. Trigger HandleOnItemDragUpdate, HandleOnItemDragEnd. - * @tc.expected: Verify some values of the drag. - */ eventHub_->HandleOnItemDragUpdate(info); eventHub_->HandleOnItemDragEnd(info); EXPECT_EQ(eventHub_->draggedIndex_, 0); @@ -1627,7 +1523,7 @@ HWTEST_F(GridTestNg, Drag001, TestSize.Level1) EXPECT_EQ(eventHub_->draggingItem_, nullptr); /** - * @tc.steps: step6. Trigger HandleOnItemDragStart, HandleOnItemDragUpdate, HandleOnItemDragEnd. + * @tc.steps: step2. Trigger HandleOnItemDragStart, HandleOnItemDragUpdate, HandleOnItemDragCancel. * @tc.expected: Verify some values of the drag. */ eventHub_->HandleOnItemDragStart(info); @@ -1647,21 +1543,18 @@ HWTEST_F(GridTestNg, Drag002, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetEditable(true); gridModelNG.SetSupportAnimation(true); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); - - /** - * @tc.steps: step1. Create draggingItem_. - */ auto onItemDragStart = [](const ItemDragInfo&, int32_t) { auto dragItem = AceType::MakeRefPtr("test", 0, AceType::MakeRefPtr()); return AceType::DynamicCast(dragItem); }; eventHub_->onItemDragStart_ = onItemDragStart; + GestureEvent info; Point globalPoint = Point(270.f, 50.f); info.SetGlobalPoint(globalPoint); @@ -1669,7 +1562,7 @@ HWTEST_F(GridTestNg, Drag002, TestSize.Level1) /** * @tc.steps: step1. Drag 1st item to out of Grid. - * @tc.expected: Verify GetOriginalIndex. + * @tc.expected: GetOriginalIndex return number of GridItem. */ ItemDragInfo dragInfo; dragInfo.SetX(0.f); @@ -1679,35 +1572,30 @@ HWTEST_F(GridTestNg, Drag002, TestSize.Level1) EXPECT_EQ(pattern_->GetOriginalIndex(), 8); /** - * @tc.steps: step2. Drag 1st item to 3rd item. - * @tc.expected: Verify GetOriginalIndex. + * @tc.steps: step2. Drag 2nd item to 3rd item, Drag 3 item to 2 item. + * @tc.expected: GetOriginalIndex changed. */ eventHub_->FireOnItemDragEnter(dragInfo); - eventHub_->FireOnItemDragLeave(dragInfo, 1); eventHub_->FireOnItemDragMove(dragInfo, 1, 2); EXPECT_EQ(pattern_->GetOriginalIndex(), 2); - eventHub_->FireOnItemDrop(dragInfo, 0, 2, true); - EXPECT_EQ(pattern_->GetOriginalIndex(), -1); - - /** - * @tc.steps: step2. Drag 4th item to 3rd item. - * @tc.expected: Verify GetOriginalIndex. - */ + eventHub_->FireOnItemDragLeave(dragInfo, -1); eventHub_->FireOnItemDragEnter(dragInfo); - eventHub_->FireOnItemDragLeave(dragInfo, 3); - eventHub_->FireOnItemDragMove(dragInfo, 3, 2); - EXPECT_EQ(pattern_->GetOriginalIndex(), 2); + // 3 to 2 + eventHub_->FireOnItemDragMove(dragInfo, 2, 1); + EXPECT_EQ(pattern_->GetOriginalIndex(), 1); + // SupportAnimation, ClearDragState eventHub_->FireOnItemDrop(dragInfo, 0, 1, true); EXPECT_EQ(pattern_->GetOriginalIndex(), -1); /** - * @tc.steps: step4. Move something to 3rd item. - * @tc.expected: Verify GetOriginalIndex. + * @tc.steps: step3. Move something to 3rd item. + * @tc.expected: GetOriginalIndex changed. */ eventHub_->FireOnItemDragEnter(dragInfo); eventHub_->FireOnItemDragLeave(dragInfo, -1); eventHub_->FireOnItemDragMove(dragInfo, -1, 2); EXPECT_EQ(pattern_->GetOriginalIndex(), 2); + // SupportAnimation, ClearDragState eventHub_->FireOnItemDrop(dragInfo, -1, 1, true); EXPECT_EQ(pattern_->GetOriginalIndex(), -1); } @@ -1727,8 +1615,8 @@ HWTEST_F(GridTestNg, FocusStep001, TestSize.Level1) */ GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); - CreateGridItemWithButton(10); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); + CreateGridItem(10, Axis::VERTICAL, true); GetInstance(); RunMeasureAndLayout(); @@ -1736,81 +1624,91 @@ HWTEST_F(GridTestNg, FocusStep001, TestSize.Level1) * @tc.steps: step1. GetNextFocusNode from left_top. * @tc.expected: Verify all condition of FocusStep. */ - RefPtr currentFocusNode = GetItemFocusHub(0); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(1)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), GetItemFocusHub(3)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex1 = 0; + std::map next1 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, -1}, + {FocusStep::UP, -1}, + {FocusStep::RIGHT, 1}, + {FocusStep::DOWN, 4}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, 3}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex1, next1)); /** * @tc.steps: step2. GetNextFocusNode from right_top. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(3); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(2)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(7)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), GetItemFocusHub(0)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex2 = 3; + std::map next2 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 2}, + {FocusStep::UP, -1}, + {FocusStep::RIGHT, 4}, + {FocusStep::DOWN, 7}, + {FocusStep::LEFT_END, 0}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex2, next2)); /** * @tc.steps: step3. GetNextFocusNode from left_bottom. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(8); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(7)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(9)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), GetItemFocusHub(9)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex3 = 8; + std::map next3 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 7}, + {FocusStep::UP, 4}, + {FocusStep::RIGHT, 9}, + {FocusStep::DOWN, -1}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, 9}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex3, next3)); /** * @tc.steps: step4. GetNextFocusNode from right_bottom. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(9); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(8)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(5)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), GetItemFocusHub(8)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex4 = 9; + std::map next4 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 8}, + {FocusStep::UP, 5}, + {FocusStep::RIGHT, -1}, + {FocusStep::DOWN, -1}, + {FocusStep::LEFT_END, 8}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex4, next4)); /** * @tc.steps: step5. GetNextFocusNode from middle. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(5); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(1)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(6)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(9)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), GetItemFocusHub(7)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex5 = 5; + std::map next5 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 4}, + {FocusStep::UP, 1}, + {FocusStep::RIGHT, 6}, + {FocusStep::DOWN, 9}, + {FocusStep::LEFT_END, 4}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, 7}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex5, next5)); } /** @@ -1829,90 +1727,188 @@ HWTEST_F(GridTestNg, FocusStep002, TestSize.Level1) */ GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetRowsTemplate("1fr 1fr 1fr 1fr"); - CreateHorizontalGridItemWithButton(10); + gridModelNG.SetRowsTemplate(TEMPLATE_4); + CreateGridItem(10, Axis::HORIZONTAL, true); GetInstance(); - RunMeasureAndLayout(DEFAULT_ROOT_WIDTH, 400.f); + RunMeasureAndLayout(DEVICE_WIDTH, 400.f); /** * @tc.steps: step1. GetNextFocusNode from left_top. * @tc.expected: Verify all condition of FocusStep. */ - RefPtr currentFocusNode = GetItemFocusHub(0); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(1)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), GetItemFocusHub(3)); + constexpr int32_t currentIndex1 = 0; + std::map next1 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, -1}, + {FocusStep::UP, -1}, + {FocusStep::RIGHT, 4}, + {FocusStep::DOWN, 1}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, 3} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex1, next1)); /** * @tc.steps: step2. GetNextFocusNode from right_top. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(8); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(7)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(9)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), GetItemFocusHub(9)); + constexpr int32_t currentIndex2 = 8; + std::map next2 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 4}, + {FocusStep::UP, 7}, + {FocusStep::RIGHT, -1}, + {FocusStep::DOWN, 9}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, -1}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, 9} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex2, next2)); /** * @tc.steps: step3. GetNextFocusNode from left_bottom. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(3); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(2)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(7)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), GetItemFocusHub(0)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex3 = 3; + std::map next3 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, -1}, + {FocusStep::UP, 2}, + {FocusStep::RIGHT, 7}, + {FocusStep::DOWN, 4}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, 0}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex3, next3)); /** * @tc.steps: step4. GetNextFocusNode from right_bottom. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(9); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(5)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(8)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), GetItemFocusHub(8)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), nullptr); + constexpr int32_t currentIndex4 = 9; + std::map next4 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 5}, + {FocusStep::UP, 8}, + {FocusStep::RIGHT, -1}, + {FocusStep::DOWN, -1}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, 8}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, -1} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex4, next4)); /** * @tc.steps: step5. GetNextFocusNode from middle. * @tc.expected: Verify all condition of FocusStep. */ - currentFocusNode = GetItemFocusHub(5); - currentFocusNode->RequestFocusImmediately(); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::NONE, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT, currentFocusNode).Upgrade(), GetItemFocusHub(1)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT, currentFocusNode).Upgrade(), GetItemFocusHub(9)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN, currentFocusNode).Upgrade(), GetItemFocusHub(6)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::LEFT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::UP_END, currentFocusNode).Upgrade(), GetItemFocusHub(4)); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::RIGHT_END, currentFocusNode).Upgrade(), nullptr); - EXPECT_EQ(pattern_->GetNextFocusNode(FocusStep::DOWN_END, currentFocusNode).Upgrade(), GetItemFocusHub(7)); + constexpr int32_t currentIndex5 = 5; + std::map next5 = { + {FocusStep::NONE, -1}, + {FocusStep::LEFT, 1}, + {FocusStep::UP, 4}, + {FocusStep::RIGHT, 9}, + {FocusStep::DOWN, 6}, + {FocusStep::LEFT_END, -1}, + {FocusStep::UP_END, 4}, + {FocusStep::RIGHT_END, -1}, + {FocusStep::DOWN_END, 7} + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex5, next5)); +} + +/** + * @tc.name: FocusStep003 + * @tc.desc: Test GetNextFocusNode func when has unfocuseable item + * @tc.type: FUNC + */ +HWTEST_F(GridTestNg, FocusStep003, TestSize.Level1) +{ + GridModelNG gridModelNG; + gridModelNG.Create(nullptr, nullptr); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); + CreateGridItem(10, Axis::VERTICAL, true); + GetInstance(); + RunMeasureAndLayout(); + + /** + * @tc.steps: step1. GetNextFocusNode from 1st item and FocusStep::RIGHT. + * @tc.expected: The 3rd item is focused. + */ + GetItemFocusHub(1)->SetFocusable(false); // The 2nd item can not focus. + constexpr int32_t currentIndex = 0; + std::map next = { + {FocusStep::RIGHT, 2}, + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex, next)); +} + +/** + * @tc.name: FocusStep004 + * @tc.desc: Test GetNextFocusNode func from top boundary item in Scrollable Grid + * @tc.type: FUNC + */ +HWTEST_F(GridTestNg, FocusStep004, TestSize.Level1) +{ + GridModelNG gridModelNG; + gridModelNG.Create(nullptr, nullptr); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); + CreateGridItem(18, Axis::VERTICAL, true); + GetInstance(); + RunMeasureAndLayout(); + + /** + * @tc.steps: step1. Scroll to second row + */ + constexpr float scrollOffset = -ITEM_HEIGHT - 1.f; + UpdateCurrentOffset(scrollOffset); + + /** + * @tc.steps: step2. UP + */ + constexpr int32_t currentIndex = 4; + std::map next = { + {FocusStep::UP, -1}, + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex, next)); + EXPECT_EQ(pattern_->gridLayoutInfo_.jumpIndex_, 3); +} + +/** + * @tc.name: FocusStep005 + * @tc.desc: Test GetNextFocusNode func from bottom boundary item in Scrollable Grid + * @tc.type: FUNC + */ +HWTEST_F(GridTestNg, FocusStep005, TestSize.Level1) +{ + GridModelNG gridModelNG; + gridModelNG.Create(nullptr, nullptr); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); + CreateGridItem(18, Axis::VERTICAL, true); + GetInstance(); + RunMeasureAndLayout(); + + /** + * @tc.steps: step1. Scroll to first row + */ + constexpr float scrollOffset = -ITEM_HEIGHT + 1.f; + UpdateCurrentOffset(scrollOffset); + + /** + * @tc.steps: step2. DOWN + */ + constexpr int32_t currentIndex = 15; + std::map next = { + {FocusStep::DOWN, -1}, + }; + EXPECT_TRUE(IsEqualNextFocusNode(currentIndex, next)); + EXPECT_EQ(pattern_->gridLayoutInfo_.jumpIndex_, 16); } /** @@ -2176,22 +2172,6 @@ HWTEST_F(GridTestNg, GridPatternTest009, TestSize.Level1) EXPECT_TRUE(outBoundary); } -/** - * @tc.name: GridPatternTest010 - * @tc.desc: Test grid pattern CreateNodePaintMethod function - * @tc.type: FUNC - */ -HWTEST_F(GridTestNg, GridPatternTest010, TestSize.Level1) -{ - GridModelNG gridModelNG; - gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetRowsTemplate("1fr 1fr"); - gridModelNG.SetRowsGap(GRID_ROWS_GAP); - CreateGridItem(10); - GetInstance(); - EXPECT_NE(pattern_->CreateNodePaintMethod(), nullptr); -} - /** * @tc.name: GridPatternTest011 * @tc.desc: Test grid pattern OnModifyDone function @@ -2379,7 +2359,6 @@ HWTEST_F(GridTestNg, GridPaintMethodTest001, TestSize.Level1) GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); gridModelNG.SetRowsTemplate("1fr 1fr"); - gridModelNG.SetRowsGap(GRID_ROWS_GAP); CreateGridItem(10); GetInstance(); @@ -2397,6 +2376,22 @@ HWTEST_F(GridTestNg, GridPaintMethodTest001, TestSize.Level1) EXPECT_CALL(rsCanvas, AttachBrush(_)).WillRepeatedly(ReturnRef(rsCanvas)); EXPECT_CALL(rsCanvas, DrawRect(_)).WillRepeatedly(Return()); drawFunction(rsCanvas); + + /** + * @tc.steps: step1. When EdgeEffect::SPRING + * @tc.expected: CreateNodePaintMethod would not trigger SetEdgeEffect + */ + pattern_->SetEdgeEffect(EdgeEffect::SPRING); + paintMethod = AceType::DynamicCast(pattern_->CreateNodePaintMethod()); + EXPECT_EQ(paintMethod->edgeEffect_.Upgrade(), nullptr); + + /** + * @tc.steps: step2. When EdgeEffect::FADE + * @tc.expected: CreateNodePaintMethod would trigger SetEdgeEffect + */ + pattern_->SetEdgeEffect(EdgeEffect::FADE); + paintMethod = AceType::DynamicCast(pattern_->CreateNodePaintMethod()); + EXPECT_NE(paintMethod->edgeEffect_.Upgrade(), nullptr); } /** @@ -2547,7 +2542,7 @@ HWTEST_F(GridTestNg, EventHubCoverage001, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); @@ -2584,7 +2579,7 @@ HWTEST_F(GridTestNg, EventHubCoverage002, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetEditable(true); CreateGridItem(8); GetInstance(); @@ -2625,7 +2620,7 @@ HWTEST_F(GridTestNg, EventHubCoverage003, TestSize.Level1) { GridModelNG gridModelNG; gridModelNG.Create(nullptr, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); gridModelNG.SetEditable(true); gridModelNG.SetOnItemDragEnter([](const ItemDragInfo) {}); gridModelNG.SetOnItemDragMove([](const ItemDragInfo&, int32_t, int32_t) {}); @@ -2671,7 +2666,7 @@ HWTEST_F(GridTestNg, PositionControllerCoverage001, TestSize.Level1) GridModelNG gridModelNG; RefPtr positionController = gridModelNG.CreatePositionController(); gridModelNG.Create(positionController, nullptr); - gridModelNG.SetColumnsTemplate("1fr 1fr 1fr 1fr"); + gridModelNG.SetColumnsTemplate(TEMPLATE_4); CreateGridItem(8); GetInstance(); RunMeasureAndLayout(); From 05990aef4007c547ed0da86ddf5be4dcb50b06d2 Mon Sep 17 00:00:00 2001 From: wangchensu Date: Wed, 24 May 2023 17:46:03 +0800 Subject: [PATCH 73/99] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchensu Change-Id: Ib35c2db711efb3700fd29f40431feb6a5746cadb --- frameworks/core/components/form/sub_container.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/core/components/form/sub_container.cpp b/frameworks/core/components/form/sub_container.cpp index 6aeead13691..ab60d807b34 100644 --- a/frameworks/core/components/form/sub_container.cpp +++ b/frameworks/core/components/form/sub_container.cpp @@ -378,7 +378,7 @@ void SubContainer::ProcessSharedImage(const std::map Date: Wed, 24 May 2023 17:46:33 +0800 Subject: [PATCH 74/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbindmenu/bindcontextmen?= =?UTF-8?q?u=EF=BC=8C=E9=85=8D=E7=BD=AEoptions=E6=97=B6=E4=BB=85=E9=85=8D?= =?UTF-8?q?=E7=BD=AEplacement=EF=BC=8C=E9=85=8D=E7=BD=AEplacement.rigth/ri?= =?UTF-8?q?ghttop/rigthbottom=EF=BC=8C=E5=AE=9E=E9=99=85=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E4=B8=8E=E9=A2=84=E6=9C=9F=E6=95=88=E6=9E=9C=E4=B8=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng --- .../pattern/menu/menu_layout_algorithm.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp index 024e97016e6..1210f6099c7 100644 --- a/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/menu/menu_layout_algorithm.cpp @@ -425,10 +425,10 @@ OffsetF MenuLayoutAlgorithm::MenuLayoutAvoidAlgorithm( } x += windowsOffsetX + pageOffset.GetX(); y += windowsOffsetY + pageOffset.GetY(); - x = std::clamp(x, windowsOffsetX + pageOffset.GetX(), - wrapperSize_.Width() - size.Width() - margin_ * 2.0f + windowsOffsetX + pageOffset.GetX()); - y = std::clamp(y, windowsOffsetY + pageOffset.GetY(), - wrapperSize_.Height() - size.Height() - margin_ * 2.0f + windowsOffsetY + pageOffset.GetY()); + x = std::clamp(x, windowsOffsetX + pageOffset.GetX() + margin_, + wrapperSize_.Width() - size.Width() - margin_ + windowsOffsetX + pageOffset.GetX()); + y = std::clamp(y, windowsOffsetY + pageOffset.GetY() + margin_, + wrapperSize_.Height() - size.Height() - margin_ + windowsOffsetY + pageOffset.GetY()); return OffsetF(x, y); } @@ -440,8 +440,8 @@ OffsetF MenuLayoutAlgorithm::MenuLayoutAvoidAlgorithm( y -= pageOffset_.GetY(); } } - x = std::clamp(x, 0.0f, wrapperSize_.Width() - size.Width() - margin_ * 2.0f); - y = std::clamp(y, 0.0f, wrapperSize_.Height() - size.Height() - margin_ * 2.0f); + x = std::clamp(x, margin_, wrapperSize_.Width() - size.Width() - margin_); + y = std::clamp(y, margin_, wrapperSize_.Height() - size.Height() - margin_); return OffsetF(x, y); } @@ -686,15 +686,15 @@ OffsetF MenuLayoutAlgorithm::FitToScreen(const OffsetF& fitPosition, const SizeF } x += windowsOffsetX + pageOffset.GetX(); y += windowsOffsetY + pageOffset.GetY(); - x = std::clamp(x, windowsOffsetX + pageOffset.GetX(), - wrapperSize_.Width() - childSize.Width() - margin_ * 2.0f + windowsOffsetX + pageOffset.GetX()); - y = std::clamp(y, windowsOffsetY + pageOffset.GetY(), - wrapperSize_.Height() - childSize.Height() - margin_ * 2.0f + windowsOffsetY + pageOffset.GetY()); + x = std::clamp(x, windowsOffsetX + pageOffset.GetX() + margin_, + wrapperSize_.Width() - childSize.Width() - margin_ + windowsOffsetX + pageOffset.GetX()); + y = std::clamp(y, windowsOffsetY + pageOffset.GetY() + margin_, + wrapperSize_.Height() - childSize.Height() - margin_ + windowsOffsetY + pageOffset.GetY()); return OffsetF(x, y); } - x = std::clamp(x, 0.0f, wrapperSize_.Width() - childSize.Width() - margin_ * 2.0f); - y = std::clamp(y, 0.0f, wrapperSize_.Height() - childSize.Height() - margin_ * 2.0f); + x = std::clamp(x, margin_, wrapperSize_.Width() - childSize.Width() - margin_); + y = std::clamp(y, margin_, wrapperSize_.Height() - childSize.Height() - margin_); return OffsetF(x, y); } From 952ee1a026392c665bf22e0223ee63ce7182675d Mon Sep 17 00:00:00 2001 From: aryawang Date: Wed, 24 May 2023 10:18:09 +0000 Subject: [PATCH 75/99] =?UTF-8?q?indexer=20popup=E6=96=87=E5=AD=97?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aryawang Change-Id: Icefe1959131a68dbe3de78adf3db3807efdff686 --- .../core/components_ng/pattern/indexer/indexer_pattern.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/indexer/indexer_pattern.cpp b/frameworks/core/components_ng/pattern/indexer/indexer_pattern.cpp index 7712c37ab17..f1131e14447 100644 --- a/frameworks/core/components_ng/pattern/indexer/indexer_pattern.cpp +++ b/frameworks/core/components_ng/pattern/indexer/indexer_pattern.cpp @@ -783,8 +783,6 @@ void IndexerPattern::ChangeListItemsSelectedStyle(int32_t clickIndex) popupClickedIndex_ = clickIndex; auto host = GetHost(); CHECK_NULL_VOID(popupNode_); - auto context = PipelineContext::GetCurrentContext(); - CHECK_NULL_VOID(context); auto pipeline = PipelineContext::GetCurrentContext(); CHECK_NULL_VOID(pipeline); auto indexerTheme = pipeline->GetTheme(); @@ -796,7 +794,7 @@ void IndexerPattern::ChangeListItemsSelectedStyle(int32_t clickIndex) auto popupSelectedTextColor = paintProperty->GetPopupSelectedColor().value_or(indexerTheme->GetPopupDefaultColor()); auto popupUnselectedTextColor = - paintProperty->GetPopupUnselectedColor().value_or(indexerTheme->GetPopupDefaultColor()); + paintProperty->GetPopupUnselectedColor().value_or(indexerTheme->GetDefaultTextColor()); auto popupItemBackground = paintProperty->GetPopupItemBackground().value_or(indexerTheme->GetPopupBackgroundColor()); auto listNode = popupNode_->GetLastChild(); From c2430a080f4c758095cd7a7cf449e2e36e272ccc Mon Sep 17 00:00:00 2001 From: zhangbingce Date: Wed, 24 May 2023 18:22:47 +0800 Subject: [PATCH 76/99] =?UTF-8?q?[canvas]drawimage=E6=8E=A5=E5=8F=A3global?= =?UTF-8?q?Alpha=E5=B1=9E=E6=80=A7=E6=9C=AA=E7=94=9F=E6=95=88=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangbingce Change-Id: Ib5005ed402400e9656baf7925baee14792271fff --- .../pattern/custom_paint/canvas_paint_method.cpp | 4 ++++ .../pattern/custom_paint/offscreen_canvas_paint_method.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp index 2c13069d801..665b7e277bc 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp @@ -197,6 +197,10 @@ void CanvasPaintMethod::DrawImage( PaintShadow(path, *imageShadow_, skCanvas); } + if (globalState_.HasGlobalAlpha()) { + imagePaint_.setAlphaf(globalState_.GetAlpha()); + } + switch (canvasImage.flag) { case 0: skCanvas_->drawImage(image, canvasImage.dx, canvasImage.dy); diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp index 9c50920e274..866da9848cf 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp @@ -145,6 +145,10 @@ void OffscreenCanvasPaintMethod::DrawImage( path.addRect(skRect); RosenDecorationPainter::PaintShadow(path, *imageShadow_, skCanvas); } + + if (globalState_.HasGlobalAlpha()) { + imagePaint_.setAlphaf(globalState_.GetAlpha()); + } switch (canvasImage.flag) { case 0: skCanvas->drawImage(image, canvasImage.dx, canvasImage.dy); From 81c8f70c1a07a765c7076fb6ec14bd525b3f0dc8 Mon Sep 17 00:00:00 2001 From: wangchensu Date: Tue, 23 May 2023 23:17:32 +0800 Subject: [PATCH 77/99] =?UTF-8?q?pluginmanager=20push=20&=20request=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0SystemApi=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangchensu Change-Id: I0e5f855e18f0dff46cd8c6c37c861f65642764c2 --- interfaces/napi/kits/plugincomponent/BUILD.gn | 1 + .../kits/plugincomponent/js_plugin_component.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/interfaces/napi/kits/plugincomponent/BUILD.gn b/interfaces/napi/kits/plugincomponent/BUILD.gn index 3ef08b1958a..7be2c952722 100644 --- a/interfaces/napi/kits/plugincomponent/BUILD.gn +++ b/interfaces/napi/kits/plugincomponent/BUILD.gn @@ -43,6 +43,7 @@ ohos_shared_library("plugincomponent") { external_deps = [ "ability_base:base", "ability_base:want", + "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/interfaces/napi/kits/plugincomponent/js_plugin_component.cpp b/interfaces/napi/kits/plugincomponent/js_plugin_component.cpp index afba2bc5257..d8f877ecc0e 100644 --- a/interfaces/napi/kits/plugincomponent/js_plugin_component.cpp +++ b/interfaces/napi/kits/plugincomponent/js_plugin_component.cpp @@ -22,6 +22,7 @@ #include "js_plugin_want.h" #include "napi/native_api.h" #include "napi/native_node_api.h" +#include "tokenid_kit.h" #include "core/components/plugin/plugin_component_manager.h" @@ -254,6 +255,12 @@ static napi_value JSPush(napi_env env, napi_callback_info info) { HILOG_INFO("%{public}s called.", __func__); + auto selfToken = IPCSkeleton::GetSelfTokenID(); + if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) { + HILOG_INFO("This application is not system-app, can not use system-api"); + return nullptr; + } + ACEAsyncJSCallbackInfo* asyncCallbackInfo = AceCreateAsyncJSCallbackInfo(env); if (asyncCallbackInfo == nullptr) { return AceWrapVoidToJS(env); @@ -520,6 +527,12 @@ static napi_value JSRequest(napi_env env, napi_callback_info info) { HILOG_INFO("%{public}s called.", __func__); + auto selfToken = IPCSkeleton::GetSelfTokenID(); + if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) { + HILOG_INFO("This application is not system-app, can not use system-api"); + return nullptr; + } + ACEAsyncJSCallbackInfo* asyncCallbackInfo = AceCreateAsyncJSCallbackInfo(env); if (asyncCallbackInfo == nullptr) { return AceWrapVoidToJS(env); From d4cad47e015550c47b5743304a7a2777910ebe51 Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Wed, 24 May 2023 11:07:28 +0000 Subject: [PATCH 78/99] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!1?= =?UTF-8?q?3430=20:=20=E4=BF=AE=E5=A4=8D=EF=BC=9Aborder=20XTS'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/components_ng/base/view_abstract.cpp | 1 + .../base/view_abstract_model_ng.h | 7 +- .../core/components_ng/property/BUILD.gn | 1 - .../property/border_property.cpp | 203 ------------------ .../components_ng/property/border_property.h | 118 +++++----- .../components_ng/render/render_property.h | 45 +++- .../accessibility/accessibilitynode/BUILD.gn | 1 - .../accessibility/accessibilityutils/BUILD.gn | 1 - .../test/base/frame_node/BUILD.gn | 1 - .../test/base/geometry_node/BUILD.gn | 1 - .../test/base/inspector/BUILD.gn | 1 - .../components_ng/test/base/ui_node/BUILD.gn | 1 - .../test/base/view_abstract/BUILD.gn | 1 - .../test/base/view_abstract_model/BUILD.gn | 1 - .../base/view_full_update_model_ng/BUILD.gn | 1 - .../view_partial_update_model_ng/BUILD.gn | 1 - .../test/base/view_stack_processor/BUILD.gn | 1 - .../test/event/click_event/BUILD.gn | 1 - .../test/event/drag_event/BUILD.gn | 1 - .../test/event/event_hub/BUILD.gn | 1 - .../test/event/focus_hub/BUILD.gn | 1 - .../test/event/gesture_event_hub/BUILD.gn | 1 - .../test/event/input_event_hub/BUILD.gn | 1 - .../test/event/long_press_event/BUILD.gn | 1 - .../test/event/pan_event/BUILD.gn | 1 - .../test/event/scrollable_event/BUILD.gn | 1 - .../test/event/touch_event/BUILD.gn | 1 - .../test/image_provider/BUILD.gn | 1 - .../test/layout/box_layout_algorithm/BUILD.gn | 1 - .../test/layout/layout_property/BUILD.gn | 1 - .../test/layout/layout_wrapper/BUILD.gn | 1 - .../layout/layout_wrapper_builder/BUILD.gn | 1 - .../test/manager/shared_overlay/BUILD.gn | 1 - .../test/pattern/ability_component/BUILD.gn | 1 - .../components_ng/test/pattern/badge/BUILD.gn | 1 - .../components_ng/test/pattern/blank/BUILD.gn | 1 - .../test/pattern/bubble/BUILD.gn | 1 - .../test/pattern/button/BUILD.gn | 1 - .../test/pattern/calendar/BUILD.gn | 1 - .../test/pattern/checkbox/BUILD.gn | 1 - .../test/pattern/checkboxgroup/BUILD.gn | 1 - .../test/pattern/container_modal/BUILD.gn | 1 - .../test/pattern/counter/BUILD.gn | 1 - .../test/pattern/custom_dialog/BUILD.gn | 1 - .../test/pattern/data_panel/BUILD.gn | 1 - .../test/pattern/divider/BUILD.gn | 1 - .../components_ng/test/pattern/flex/BUILD.gn | 1 - .../components_ng/test/pattern/form/BUILD.gn | 1 - .../components_ng/test/pattern/gauge/BUILD.gn | 1 - .../components_ng/test/pattern/grid/BUILD.gn | 1 - .../test/pattern/grid_col/BUILD.gn | 1 - .../test/pattern/hyperlink/BUILD.gn | 1 - .../components_ng/test/pattern/image/BUILD.gn | 1 - .../test/pattern/indexer/BUILD.gn | 1 - .../test/pattern/linear_layout/BUILD.gn | 1 - .../test/pattern/linear_split/BUILD.gn | 1 - .../components_ng/test/pattern/list/BUILD.gn | 1 - .../components_ng/test/pattern/menu/BUILD.gn | 1 - .../test/pattern/navigation/BUILD.gn | 1 - .../test/pattern/overlay/BUILD.gn | 1 - .../test/pattern/patternlock/BUILD.gn | 1 - .../test/pattern/picker/BUILD.gn | 1 - .../test/pattern/plugin/BUILD.gn | 1 - .../test/pattern/qrcode/BUILD.gn | 1 - .../components_ng/test/pattern/radio/BUILD.gn | 1 - .../test/pattern/rating/BUILD.gn | 1 - .../test/pattern/refresh/BUILD.gn | 1 - .../test/pattern/scroll/BUILD.gn | 1 - .../test/pattern/search/BUILD.gn | 1 - .../test/pattern/security_component/BUILD.gn | 1 - .../test/pattern/select/BUILD.gn | 1 - .../test/pattern/select_overlay/BUILD.gn | 1 - .../test/pattern/side_bar/BUILD.gn | 1 - .../test/pattern/stepper/BUILD.gn | 1 - .../test/pattern/swiper/BUILD.gn | 1 - .../components_ng/test/pattern/tabs/BUILD.gn | 1 - .../components_ng/test/pattern/text/BUILD.gn | 1 - .../test/pattern/text_clock/BUILD.gn | 1 - .../test/pattern/textfield/BUILD.gn | 1 - .../test/pattern/texttimer/BUILD.gn | 1 - .../test/pattern/toggle/BUILD.gn | 1 - .../components_ng/test/pattern/video/BUILD.gn | 1 - .../test/pattern/xcomponent/BUILD.gn | 1 - .../test/property/accessibility/BUILD.gn | 1 - .../test/property/calc_length/BUILD.gn | 1 - .../test/property/gradient/BUILD.gn | 1 - .../test/property/grid_property/BUILD.gn | 1 - .../test/property/measure_utils/BUILD.gn | 1 - .../test/property/property_test/BUILD.gn | 1 - .../test/syntax/for_each/BUILD.gn | 1 - .../test/syntax/if_else/BUILD.gn | 1 - .../test/syntax/lazy_for_each/BUILD.gn | 1 - test/unittest/BUILD.gn | 1 - .../core/pattern/window_scene/BUILD.gn | 1 - test/unittest/core/pipeline/BUILD.gn | 1 - .../core/render/render_context/BUILD.gn | 1 - 96 files changed, 102 insertions(+), 363 deletions(-) delete mode 100644 frameworks/core/components_ng/property/border_property.cpp diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 429fa0cfd5e..6b7a5d4783c 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -424,6 +424,7 @@ void ViewAbstract::SetBorderRadius(const Dimension& value) } BorderRadiusProperty borderRadius; borderRadius.SetRadius(value); + borderRadius.SetRadiusFlag(true); ACE_UPDATE_RENDER_CONTEXT(BorderRadius, borderRadius); } diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.h b/frameworks/core/components_ng/base/view_abstract_model_ng.h index 080a95151bb..b3506f17e80 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.h +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.h @@ -135,7 +135,7 @@ public: { ViewAbstract::SetForegroundBlurStyle(fgBlurStyle); } - + void SetSphericalEffect(double radio) override { ViewAbstract::SetSphericalEffect(radio); @@ -257,7 +257,6 @@ public: borderRadius.radiusTopRight = radiusTopRight; borderRadius.radiusBottomLeft = radiusBottomLeft; borderRadius.radiusBottomRight = radiusBottomRight; - borderRadius.multiValued = true; ViewAbstract::SetBorderRadius(borderRadius); } @@ -273,7 +272,6 @@ public: borderColors.rightColor = colorRight; borderColors.topColor = colorTop; borderColors.bottomColor = colorBottom; - borderColors.multiValued = true; ViewAbstract::SetBorderColor(borderColors); } @@ -290,7 +288,6 @@ public: borderWidth.rightDimen = right; borderWidth.topDimen = top; borderWidth.bottomDimen = bottom; - borderWidth.multiValued = true; ViewAbstract::SetBorderWidth(borderWidth); } @@ -307,7 +304,6 @@ public: borderStyles.styleRight = styleRight.value_or(BorderStyle::SOLID); borderStyles.styleTop = styleTop.value_or(BorderStyle::SOLID); borderStyles.styleBottom = styleBottom.value_or(BorderStyle::SOLID); - borderStyles.multiValued = true; ViewAbstract::SetBorderStyle(borderStyles); } @@ -825,7 +821,6 @@ public: { ViewAbstract::SetForegroundColorStrategy(strategy); } - private: void RegisterMenuAppearCallback( std::vector& params, std::function&& buildFunc, const MenuParam& menuParam); diff --git a/frameworks/core/components_ng/property/BUILD.gn b/frameworks/core/components_ng/property/BUILD.gn index f960fce7b9f..4328aa11917 100644 --- a/frameworks/core/components_ng/property/BUILD.gn +++ b/frameworks/core/components_ng/property/BUILD.gn @@ -17,7 +17,6 @@ import( build_component_ng("property_ng") { sources = [ "accessibility_property.cpp", - "border_property.cpp", "calc_length.cpp", "gradient_property.cpp", "grid_property.cpp", diff --git a/frameworks/core/components_ng/property/border_property.cpp b/frameworks/core/components_ng/property/border_property.cpp deleted file mode 100644 index 19f7a2ae2e9..00000000000 --- a/frameworks/core/components_ng/property/border_property.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -#include "border_property.h" - -namespace OHOS::Ace::NG { -void BorderStyleProperty::ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const -{ - static const char* BORDER_STYLE[] = { - "BorderStyle.Solid", - "BorderStyle.Dashed", - "BorderStyle.Dotted", - "BorderStyle.None", - }; - if (multiValued) { - auto res = JsonUtil::Create(true); - res->Put("left", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); - res->Put("top", BORDER_STYLE[static_cast(styleTop.value_or(BorderStyle::SOLID))]); - res->Put("right", BORDER_STYLE[static_cast(styleRight.value_or(BorderStyle::SOLID))]); - res->Put("bottom", BORDER_STYLE[static_cast(styleBottom.value_or(BorderStyle::SOLID))]); - - json->Put("borderStyle", res); - borderJson->Put("style", res); - } else { - json->Put("borderStyle", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); - borderJson->Put("style", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); - } -} - -std::string BorderWidthPropertyT::ToString() const -{ - std::string str; - str.append("leftDimen: [").append(leftDimen.has_value() ? leftDimen->ToString() : "NA").append("]"); - str.append("rightDimen: [").append(rightDimen.has_value() ? rightDimen->ToString() : "NA").append("]"); - str.append("topDimen: [").append(topDimen.has_value() ? topDimen->ToString() : "NA").append("]"); - str.append("bottomDimen: [").append(bottomDimen.has_value() ? bottomDimen->ToString() : "NA").append("]"); - return str; -} - -void BorderWidthPropertyT::ToJsonValue( - std::unique_ptr& json, std::unique_ptr& borderJson) const -{ - if (multiValued) { - auto res = JsonUtil::Create(true); - res->Put("left", leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - res->Put("top", topDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - res->Put("right", rightDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - res->Put("bottom", bottomDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - - borderJson->Put("width", res); - json->Put("borderWidth", borderJson); - } else { - auto left = leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString(); - borderJson->Put("width", left.c_str()); - json->Put("borderWidth", left.c_str()); - } -} - -bool BorderWidthPropertyT::UpdateWithCheck(const BorderWidthPropertyT& value) -{ - bool isModified = false; - if (value.leftDimen.has_value() && (leftDimen != value.leftDimen)) { - leftDimen = value.leftDimen; - isModified = true; - } - if (value.rightDimen.has_value() && (rightDimen != value.rightDimen)) { - rightDimen = value.rightDimen; - isModified = true; - } - if (value.topDimen.has_value() && (topDimen != value.topDimen)) { - topDimen = value.topDimen; - isModified = true; - } - if (value.bottomDimen.has_value() && (bottomDimen != value.bottomDimen)) { - bottomDimen = value.bottomDimen; - isModified = true; - } - return isModified; -} - -void BorderColorProperty::ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const -{ - if (multiValued) { - auto res = JsonUtil::Create(true); - res->Put("left", leftColor.value_or(Color()).ColorToString().c_str()); - res->Put("right", rightColor.value_or(Color()).ColorToString().c_str()); - res->Put("top", topColor.value_or(Color()).ColorToString().c_str()); - res->Put("bottom", bottomColor.value_or(Color()).ColorToString().c_str()); - - borderJson->Put("color", res); - json->Put("borderColor", res); - } else { - auto left = leftColor.value_or(Color()).ColorToString(); - borderJson->Put("color", left.c_str()); - json->Put("borderColor", left.c_str()); - } -} - -std::string BorderColorProperty::ToString() const -{ - std::string str; - str.append("leftColor: [").append(leftColor.has_value() ? leftColor->ColorToString() : "NA").append("]"); - str.append("rightColor: [").append(rightColor.has_value() ? rightColor->ColorToString() : "NA").append("]"); - str.append("topColor: [").append(topColor.has_value() ? topColor->ColorToString() : "NA").append("]"); - str.append("bottomColor: [").append(bottomColor.has_value() ? bottomColor->ColorToString() : "NA").append("]"); - return str; -} - -void BorderRadiusPropertyT::ToJsonValue( - std::unique_ptr& json, std::unique_ptr& borderJson) const -{ - if (multiValued) { - auto res = JsonUtil::Create(true); - res->Put("topLeft", radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - res->Put("topRight", radiusTopRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - res->Put("bottomLeft", radiusBottomLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - res->Put("bottomRight", radiusBottomRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - - json->Put("borderRadius", res); - borderJson->Put("radius", res); - } else { - auto left = radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString(); - json->Put("borderRadius", left.c_str()); - borderJson->Put("radius", left.c_str()); - } -} - -bool BorderRadiusPropertyT::UpdateWithCheck(const BorderRadiusPropertyT& value) -{ - bool isModified = false; - if (value.radiusTopLeft.has_value() && (radiusTopLeft != value.radiusTopLeft)) { - radiusTopLeft = value.radiusTopLeft; - isModified = true; - } - if (value.radiusTopRight.has_value() && (radiusTopRight != value.radiusTopRight)) { - radiusTopRight = value.radiusTopRight; - isModified = true; - } - if (value.radiusBottomLeft.has_value() && (radiusBottomLeft != value.radiusBottomLeft)) { - radiusBottomLeft = value.radiusBottomLeft; - isModified = true; - } - if (value.radiusBottomRight.has_value() && (radiusBottomRight != value.radiusBottomRight)) { - radiusBottomRight = value.radiusBottomRight; - isModified = true; - } - return isModified; -} - -void BorderStyleProperty::SetBorderStyle(const BorderStyle& borderStyle) -{ - styleLeft = borderStyle; - styleRight = borderStyle; - styleTop = borderStyle; - styleBottom = borderStyle; -} - -bool BorderStyleProperty::operator==(const BorderStyleProperty& value) const -{ - return (styleLeft == value.styleLeft) && (styleRight == value.styleRight) && (styleTop == value.styleTop) && - (styleBottom == value.styleBottom); -} - -void BorderWidthPropertyT::SetBorderWidth(const Dimension& borderWidth) -{ - leftDimen = borderWidth; - rightDimen = borderWidth; - topDimen = borderWidth; - bottomDimen = borderWidth; -} - -bool BorderWidthPropertyT::operator==(const BorderWidthPropertyT& value) const -{ - return (leftDimen == value.leftDimen) && (rightDimen == value.rightDimen) && (topDimen == value.topDimen) && - (bottomDimen == value.bottomDimen); -} - -void BorderRadiusPropertyT::SetRadius(const Dimension& borderRadius) -{ - radiusTopLeft = borderRadius; - radiusTopRight = borderRadius; - radiusBottomLeft = borderRadius; - radiusBottomRight = borderRadius; -} - -bool BorderRadiusPropertyT::operator==(const BorderRadiusPropertyT& value) const -{ - return (radiusTopLeft == value.radiusTopLeft) && (radiusTopRight == value.radiusTopRight) && - (radiusBottomLeft == value.radiusBottomLeft) && (radiusBottomRight == value.radiusBottomRight); -} -} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/property/border_property.h b/frameworks/core/components_ng/property/border_property.h index 83f00032de7..3a0cc479d6f 100644 --- a/frameworks/core/components_ng/property/border_property.h +++ b/frameworks/core/components_ng/property/border_property.h @@ -20,6 +20,7 @@ #include "base/geometry/dimension.h" #include "base/json/json_util.h" +#include "base/utils/utils.h" #include "core/components/common/layout/constants.h" #include "core/components/common/properties/color.h" @@ -31,6 +32,7 @@ struct BorderRadiusPropertyT { std::optional radiusTopRight; std::optional radiusBottomRight; std::optional radiusBottomLeft; + std::optional radiusFlag; void SetRadius(const T& borderRadius) { @@ -40,6 +42,12 @@ struct BorderRadiusPropertyT { radiusBottomRight = borderRadius; } + // This function is used when the input value is length + void SetRadiusFlag(bool flag) + { + radiusFlag = flag; + } + bool operator==(const BorderRadiusPropertyT& value) const { return (radiusTopLeft == value.radiusTopLeft) && (radiusTopRight == value.radiusTopRight) && @@ -85,23 +93,6 @@ struct BorderRadiusPropertyT { } }; -template<> -struct BorderRadiusPropertyT { - std::optional radiusTopLeft; - std::optional radiusTopRight; - std::optional radiusBottomRight; - std::optional radiusBottomLeft; - bool multiValued = false; - - bool operator==(const BorderRadiusPropertyT& value) const; - - void SetRadius(const Dimension& borderRadius); - - bool UpdateWithCheck(const BorderRadiusPropertyT& value); - - void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; -}; - template<> struct BorderRadiusPropertyT { std::optional radiusTopLeft; @@ -157,14 +148,14 @@ struct BorderRadiusPropertyT { } }; -struct BorderColorProperty { - std::optional leftColor; - std::optional rightColor; - std::optional topColor; - std::optional bottomColor; - bool multiValued = false; +template +struct BorderColorPropertyT { + std::optional leftColor; + std::optional rightColor; + std::optional topColor; + std::optional bottomColor; - void SetColor(const Color& borderColor) + void SetColor(const T& borderColor) { leftColor = borderColor; rightColor = borderColor; @@ -172,15 +163,21 @@ struct BorderColorProperty { bottomColor = borderColor; } - bool operator==(const BorderColorProperty& value) const + bool operator==(const BorderColorPropertyT& value) const { return (leftColor == value.leftColor) && (rightColor == value.rightColor) && (topColor == value.topColor) && (bottomColor == value.bottomColor); } - std::string ToString() const; - - void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; + std::string ToString() const + { + std::string str; + str.append("leftColor: [").append(leftColor.has_value() ? leftColor->ToString() : "NA").append("]"); + str.append("rightColor: [").append(rightColor.has_value() ? rightColor->ToString() : "NA").append("]"); + str.append("topColor: [").append(topColor.has_value() ? topColor->ToString() : "NA").append("]"); + str.append("bottomColor: [").append(bottomColor.has_value() ? bottomColor->ToString() : "NA").append("]"); + return str; + } }; template @@ -225,30 +222,21 @@ struct BorderWidthPropertyT { } return isModified; } -}; -template<> -struct BorderWidthPropertyT { - std::optional leftDimen; - std::optional topDimen; - std::optional rightDimen; - std::optional bottomDimen; - bool multiValued = true; - - void SetBorderWidth(const Dimension& borderWidth); - - bool operator==(const BorderWidthPropertyT& value) const; - - bool UpdateWithCheck(const BorderWidthPropertyT& value); + std::string ToString() const + { + std::string str; + str.append("leftDimen: [").append(leftDimen.has_value() ? leftDimen->ToString() : "NA").append("]"); + str.append("rightDimen: [").append(rightDimen.has_value() ? rightDimen->ToString() : "NA").append("]"); + str.append("topDimen: [").append(topDimen.has_value() ? topDimen->ToString() : "NA").append("]"); + str.append("bottomDimen: [").append(bottomDimen.has_value() ? bottomDimen->ToString() : "NA").append("]"); + return str; + } void ToJsonValue(std::unique_ptr& json) const { json->Put("borderWidth", leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); } - - void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; - - std::string ToString() const; }; template<> @@ -302,24 +290,44 @@ struct BorderWidthPropertyT { } }; -struct BorderStyleProperty { - std::optional styleLeft; - std::optional styleRight; - std::optional styleTop; - std::optional styleBottom; - bool multiValued = false; +template +struct BorderStylePropertyT { + std::optional styleLeft; + std::optional styleRight; + std::optional styleTop; + std::optional styleBottom; - void SetBorderStyle(const BorderStyle& borderStyle); + void SetBorderStyle(const T& borderStyle) + { + styleLeft = borderStyle; + styleRight = borderStyle; + styleTop = borderStyle; + styleBottom = borderStyle; + } - bool operator==(const BorderStyleProperty& value) const; + bool operator==(const BorderStylePropertyT& value) const + { + return (styleLeft == value.styleLeft) && (styleRight == value.styleRight) && (styleTop == value.styleTop) && + (styleBottom == value.styleBottom); + } - void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; + std::string ToString() const + { + std::string str; + str.append("styleLeft: [").append(styleLeft.has_value() ? styleLeft->ToString() : "NA").append("]"); + str.append("styleRight: [").append(styleRight.has_value() ? styleRight->ToString() : "NA").append("]"); + str.append("styleTop: [").append(styleTop.has_value() ? styleTop->ToString() : "NA").append("]"); + str.append("styleBottom: [").append(styleBottom.has_value() ? styleBottom->ToString() : "NA").append("]"); + return str; + } }; using BorderRadiusPropertyF = BorderRadiusPropertyT; using BorderRadiusProperty = BorderRadiusPropertyT; +using BorderColorProperty = BorderColorPropertyT; using BorderWidthPropertyF = BorderWidthPropertyT; using BorderWidthProperty = BorderWidthPropertyT; +using BorderStyleProperty = BorderStylePropertyT; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/render/render_property.h b/frameworks/core/components_ng/render/render_property.h index 842651a00c6..d24a1781298 100644 --- a/frameworks/core/components_ng/render/render_property.h +++ b/frameworks/core/components_ng/render/render_property.h @@ -18,14 +18,14 @@ #include "base/geometry/ng/offset_t.h" #include "base/geometry/ng/vector.h" -#include "core/components/common/properties/clip_path.h" #include "core/components/common/properties/color.h" #include "core/components/common/properties/decoration.h" #include "core/components/common/properties/shadow.h" +#include "core/components/common/properties/clip_path.h" #include "core/components_ng/property/border_property.h" -#include "core/components_ng/property/gradient_property.h" #include "core/components_ng/property/overlay_property.h" #include "core/components_ng/property/property.h" +#include "core/components_ng/property/gradient_property.h" #include "core/components_ng/property/transition_property.h" #include "core/image/image_source_info.h" @@ -126,13 +126,42 @@ struct BorderProperty { void ToJsonValue(std::unique_ptr& json) const { + static const char* BORDER_STYLE[] = { + "BorderStyle.Solid", + "BorderStyle.Dashed", + "BorderStyle.Dotted", + }; + json->Put("borderStyle", + BORDER_STYLE[static_cast( + propBorderStyle.value_or(BorderStyleProperty()).styleLeft.value_or(BorderStyle::SOLID))]); + json->Put("borderColor", + propBorderColor.value_or(BorderColorProperty()).leftColor.value_or(Color()).ColorToString().c_str()); auto jsonBorder = JsonUtil::Create(true); - - propBorderStyle.value_or(BorderStyleProperty()).ToJsonValue(json, jsonBorder); - propBorderColor.value_or(BorderColorProperty()).ToJsonValue(json, jsonBorder); - propBorderWidth.value_or(BorderWidthProperty()).ToJsonValue(json, jsonBorder); - propBorderRadius.value_or(BorderRadiusProperty()).ToJsonValue(json, jsonBorder); - + jsonBorder->Put("width", propBorderWidth.value_or(BorderWidthProperty()) + .leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + jsonBorder->Put("color", + propBorderColor.value_or(BorderColorProperty()).leftColor.value_or(Color()).ColorToString().c_str()); + jsonBorder->Put("style", + BORDER_STYLE[static_cast( + propBorderStyle.value_or(BorderStyleProperty()).styleLeft.value_or(BorderStyle::SOLID))]); + if (propBorderRadius.value_or(BorderRadiusProperty()).radiusFlag) { + json->Put("borderRadius", propBorderRadius.value_or(BorderRadiusProperty()) + .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + jsonBorder->Put("radius", propBorderRadius.value_or(BorderRadiusProperty()) + .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + } else { + auto jsonRadius = JsonUtil::Create(true); + jsonRadius->Put("topLeft", propBorderRadius.value_or(BorderRadiusProperty()) + .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + jsonRadius->Put("topRight", propBorderRadius.value_or(BorderRadiusProperty()) + .radiusTopRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + jsonRadius->Put("bottomLeft", propBorderRadius.value_or(BorderRadiusProperty()) + .radiusBottomLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + jsonRadius->Put("bottomRight", propBorderRadius.value_or(BorderRadiusProperty()) + .radiusBottomRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + json->Put("borderRadius", jsonRadius); + jsonBorder->Put("radius", jsonRadius); + } json->Put("border", jsonBorder->ToString().c_str()); } }; diff --git a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn index 8268b99e63c..896a602882c 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn @@ -63,7 +63,6 @@ ohos_unittest("accessibility_node_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn index 0afe19f8758..e04123b6cee 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn @@ -63,7 +63,6 @@ ohos_unittest("accessibility_utils_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/frame_node/BUILD.gn b/frameworks/core/components_ng/test/base/frame_node/BUILD.gn index 50202bb5cb3..e5c6c3991dc 100644 --- a/frameworks/core/components_ng/test/base/frame_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/frame_node/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("frame_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn b/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn index 23931c6903b..3f3cf6efb73 100644 --- a/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("geometry_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/inspector/BUILD.gn b/frameworks/core/components_ng/test/base/inspector/BUILD.gn index 7828ee40902..1d2aab9df67 100755 --- a/frameworks/core/components_ng/test/base/inspector/BUILD.gn +++ b/frameworks/core/components_ng/test/base/inspector/BUILD.gn @@ -56,7 +56,6 @@ ohos_unittest("inspector_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/ui_node/BUILD.gn b/frameworks/core/components_ng/test/base/ui_node/BUILD.gn index 373bb3374c6..8b0970cbaf5 100644 --- a/frameworks/core/components_ng/test/base/ui_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/ui_node/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("ui_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn b/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn index d5992c85f6f..4c19cf43d08 100755 --- a/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("view_abstract_test") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn b/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn index bb7dbc18f7d..a98950e7370 100755 --- a/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn @@ -56,7 +56,6 @@ ohos_unittest("view_abstract_model_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn b/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn index c90a9b9fa73..602c29a5887 100755 --- a/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("view_full_update_model_ng_test") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn b/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn index af7c127a4da..d46645cdccf 100644 --- a/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("view_partial_update_model_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn b/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn index ce5feff939d..14b88d04455 100644 --- a/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn @@ -50,7 +50,6 @@ ohos_unittest("view_stack_processor_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/event/click_event/BUILD.gn b/frameworks/core/components_ng/test/event/click_event/BUILD.gn index 3d6ed144e9d..37ab3fb469c 100644 --- a/frameworks/core/components_ng/test/event/click_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/click_event/BUILD.gn @@ -38,7 +38,6 @@ ohos_unittest("click_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/drag_event/BUILD.gn b/frameworks/core/components_ng/test/event/drag_event/BUILD.gn index cfce2c1fb98..468de38c3f2 100644 --- a/frameworks/core/components_ng/test/event/drag_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/drag_event/BUILD.gn @@ -39,7 +39,6 @@ ohos_unittest("drag_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/event_hub/BUILD.gn index 80ff433f50d..c064d51268e 100644 --- a/frameworks/core/components_ng/test/event/event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/event_hub/BUILD.gn @@ -36,7 +36,6 @@ ohos_unittest("event_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn b/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn index 3348b04a9a9..15551a8d95d 100644 --- a/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn @@ -34,7 +34,6 @@ ohos_unittest("focus_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn index 5360cc398b7..4b4a69224a8 100644 --- a/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn @@ -35,7 +35,6 @@ ohos_unittest("gesture_event_hub_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp", "$ace_root/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp", "$ace_root/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn index 9c08006011d..dae19d3112d 100644 --- a/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn @@ -32,7 +32,6 @@ ohos_unittest("input_event_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn b/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn index 5fd74698775..d033845f1b7 100644 --- a/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn @@ -34,7 +34,6 @@ ohos_unittest("long_press_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/pan_event/BUILD.gn b/frameworks/core/components_ng/test/event/pan_event/BUILD.gn index f127ca39473..c7d7d01792d 100644 --- a/frameworks/core/components_ng/test/event/pan_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/pan_event/BUILD.gn @@ -39,7 +39,6 @@ ohos_unittest("pan_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn b/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn index 01ec49d831c..0868a340371 100644 --- a/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn @@ -39,7 +39,6 @@ ohos_unittest("scrollable_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/touch_event/BUILD.gn b/frameworks/core/components_ng/test/event/touch_event/BUILD.gn index e3a470f7fc8..044473ab349 100644 --- a/frameworks/core/components_ng/test/event/touch_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/touch_event/BUILD.gn @@ -34,7 +34,6 @@ ohos_unittest("touch_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/image_provider/BUILD.gn b/frameworks/core/components_ng/test/image_provider/BUILD.gn index 28aa4ea88d9..4e5c511cdf8 100644 --- a/frameworks/core/components_ng/test/image_provider/BUILD.gn +++ b/frameworks/core/components_ng/test/image_provider/BUILD.gn @@ -92,7 +92,6 @@ ohos_unittest("image_provider_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn b/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn index b913c0a7df1..2730f731d56 100755 --- a/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("box_layout_algorithm_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn index 56db0446cb4..bfeaeb91ba0 100755 --- a/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn @@ -56,7 +56,6 @@ ohos_unittest("layout_property_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/syntax/for_each_node.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn index 34bec3012cc..2941ac20a53 100755 --- a/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn @@ -59,7 +59,6 @@ ohos_unittest("layout_wrapper_test_ng") { "$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/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn index cdad88ebf3c..d7bedcf56ca 100755 --- a/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("layout_wrapper_build_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn b/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn index 0da528ebfcb..5d5426cb73c 100644 --- a/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn @@ -41,7 +41,6 @@ ohos_unittest("shared_overlay_manager_test_ng") { "$ace_root/frameworks/core/components_ng/event/touch_event.cpp", "$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_overlay_manager.cpp", "$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_transition_effect.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn b/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn index 54d2baefedb..43edc4802c2 100644 --- a/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn @@ -60,7 +60,6 @@ ohos_unittest("ability_component_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_pattern.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp", diff --git a/frameworks/core/components_ng/test/pattern/badge/BUILD.gn b/frameworks/core/components_ng/test/pattern/badge/BUILD.gn index 3557680dcd6..4d7de6f01ed 100644 --- a/frameworks/core/components_ng/test/pattern/badge/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/badge/BUILD.gn @@ -105,7 +105,6 @@ ohos_unittest("badge_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/blank/BUILD.gn b/frameworks/core/components_ng/test/pattern/blank/BUILD.gn index 2c86a61b9fb..8fd774609a4 100644 --- a/frameworks/core/components_ng/test/pattern/blank/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/blank/BUILD.gn @@ -75,7 +75,6 @@ ohos_unittest("blank_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn b/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn index a6ce1f1b62c..174be42ac4e 100644 --- a/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn @@ -106,7 +106,6 @@ ohos_unittest("bubble_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/button/BUILD.gn b/frameworks/core/components_ng/test/pattern/button/BUILD.gn index 7631dc37737..28a865bc630 100644 --- a/frameworks/core/components_ng/test/pattern/button/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/button/BUILD.gn @@ -93,7 +93,6 @@ ohos_unittest("button_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn b/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn index 97fb83faca0..8e905b0b0bf 100644 --- a/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn @@ -114,7 +114,6 @@ ohos_unittest("calendar_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn b/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn index 876a3f2c58b..353bc611df1 100644 --- a/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("checkbox_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn b/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn index 0b6fb270b45..84f7996da19 100644 --- a/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn @@ -54,7 +54,6 @@ ohos_unittest("checkboxgroup_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn b/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn index 28f2756d462..0364b7c1490 100644 --- a/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn @@ -113,7 +113,6 @@ ohos_unittest("container_modal_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/counter/BUILD.gn b/frameworks/core/components_ng/test/pattern/counter/BUILD.gn index ff15f06ca78..29293849e46 100644 --- a/frameworks/core/components_ng/test/pattern/counter/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/counter/BUILD.gn @@ -64,7 +64,6 @@ ohos_unittest("counter_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn b/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn index f95f600e29b..dfd9a527a89 100644 --- a/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn @@ -80,7 +80,6 @@ ohos_unittest("custom_dialog_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_overlay_modifier.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn b/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn index 762b0c039bf..55e0c386c56 100644 --- a/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn @@ -78,7 +78,6 @@ ohos_unittest("data_panel_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/divider/BUILD.gn b/frameworks/core/components_ng/test/pattern/divider/BUILD.gn index 8c2b660bde2..c4669a5c47a 100644 --- a/frameworks/core/components_ng/test/pattern/divider/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/divider/BUILD.gn @@ -72,7 +72,6 @@ ohos_unittest("divider_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/flex/BUILD.gn b/frameworks/core/components_ng/test/pattern/flex/BUILD.gn index d0c0234ae64..80bab974069 100644 --- a/frameworks/core/components_ng/test/pattern/flex/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/flex/BUILD.gn @@ -65,7 +65,6 @@ ohos_unittest("flex_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/form/BUILD.gn b/frameworks/core/components_ng/test/pattern/form/BUILD.gn index 09faaf2341e..68c036bd506 100644 --- a/frameworks/core/components_ng/test/pattern/form/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/form/BUILD.gn @@ -84,7 +84,6 @@ ohos_unittest("form_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn b/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn index a0d8cf63015..86bfaf260db 100644 --- a/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn @@ -74,7 +74,6 @@ ohos_unittest("gauge_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid/BUILD.gn index c9d5d868620..821d60490e2 100644 --- a/frameworks/core/components_ng/test/pattern/grid/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid/BUILD.gn @@ -137,7 +137,6 @@ ohos_unittest("grid_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn index 1e73410d553..2b1075cd6f4 100644 --- a/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("grid_col_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn b/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn index ca46d0fcaa8..3c6af90484a 100644 --- a/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn @@ -88,7 +88,6 @@ ohos_unittest("hyperlink_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/image/BUILD.gn b/frameworks/core/components_ng/test/pattern/image/BUILD.gn index 517760f9164..be445e50a6e 100644 --- a/frameworks/core/components_ng/test/pattern/image/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/image/BUILD.gn @@ -95,7 +95,6 @@ ohos_unittest("image_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn b/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn index 3a7fcfec11f..3f5185a22c1 100644 --- a/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn @@ -143,7 +143,6 @@ ohos_unittest("indexer_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn b/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn index f051bbf1cd2..dabc0ad5c58 100644 --- a/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn @@ -49,7 +49,6 @@ ohos_unittest("linear_layout_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn b/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn index 85d3be605c2..307f663f4da 100644 --- a/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn @@ -81,7 +81,6 @@ ohos_unittest("linear_split_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/list/BUILD.gn b/frameworks/core/components_ng/test/pattern/list/BUILD.gn index c394020d2fe..782d907b53d 100644 --- a/frameworks/core/components_ng/test/pattern/list/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/list/BUILD.gn @@ -57,7 +57,6 @@ common_sources = [ # components_ng_property "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn index f0eaf324e1c..bbea2e95341 100644 --- a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn @@ -162,7 +162,6 @@ ohos_unittest("menu_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn b/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn index 85ded65aaf0..cb95b4042b6 100755 --- a/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn @@ -108,7 +108,6 @@ ohos_unittest("navigation_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn index 78b3a96393e..063892619bf 100644 --- a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn @@ -129,7 +129,6 @@ ohos_unittest("overlay_manager_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn b/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn index b123922864a..a78b43380b8 100644 --- a/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn @@ -58,7 +58,6 @@ ohos_unittest("patternlock_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/picker/BUILD.gn b/frameworks/core/components_ng/test/pattern/picker/BUILD.gn index de6bf73e400..f7cd5948f72 100644 --- a/frameworks/core/components_ng/test/pattern/picker/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/picker/BUILD.gn @@ -133,7 +133,6 @@ ohos_unittest("picker_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/time_picker/timepicker_row_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/time_picker/toss_animation_controller.cpp", "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn b/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn index 19470a3edb4..f4e01e83d9e 100644 --- a/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn @@ -86,7 +86,6 @@ ohos_unittest("plugin_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn b/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn index a9dd54698a5..5bd21a7741d 100644 --- a/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("qrcode_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/radio/BUILD.gn b/frameworks/core/components_ng/test/pattern/radio/BUILD.gn index 2e3cc4cc53b..844d1b7d9b7 100644 --- a/frameworks/core/components_ng/test/pattern/radio/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/radio/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("radio_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/rating/BUILD.gn b/frameworks/core/components_ng/test/pattern/rating/BUILD.gn index e33f41f3eb1..144a69f0842 100644 --- a/frameworks/core/components_ng/test/pattern/rating/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/rating/BUILD.gn @@ -68,7 +68,6 @@ ohos_unittest("rating_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn b/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn index f03d313af9a..02518b0fcc2 100644 --- a/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn @@ -84,7 +84,6 @@ ohos_unittest("refresh_pattern_test_ng") { # components_ng_property "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn b/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn index c5ae2ae58c9..18eeddcc7eb 100644 --- a/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn @@ -114,7 +114,6 @@ ohos_unittest("scroll_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/search/BUILD.gn b/frameworks/core/components_ng/test/pattern/search/BUILD.gn index c797186bae6..a9a06921949 100644 --- a/frameworks/core/components_ng/test/pattern/search/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/search/BUILD.gn @@ -110,7 +110,6 @@ ohos_unittest("search_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn b/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn index faf0e758c89..37fb291fdad 100644 --- a/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn @@ -94,7 +94,6 @@ ohos_unittest("security_component_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select/BUILD.gn b/frameworks/core/components_ng/test/pattern/select/BUILD.gn index 271671555af..2d41be645f7 100644 --- a/frameworks/core/components_ng/test/pattern/select/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("select_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn index 43d21668e27..317cfee4e5c 100644 --- a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn @@ -155,7 +155,6 @@ ohos_unittest("select_overlay_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn b/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn index f776020a375..573e5b641e2 100644 --- a/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn @@ -111,7 +111,6 @@ ohos_unittest("side_bar_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn b/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn index d75e7dfb821..5cc4e75c758 100644 --- a/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn @@ -166,7 +166,6 @@ ohos_unittest("stepper_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn b/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn index fd8d74ab50d..133b3f464a6 100644 --- a/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn @@ -64,7 +64,6 @@ ohos_unittest("swiper_indicator_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn b/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn index 44250278f94..32a6fc42bd5 100644 --- a/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn @@ -137,7 +137,6 @@ ohos_unittest("tabs_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text/BUILD.gn b/frameworks/core/components_ng/test/pattern/text/BUILD.gn index 693972d09b2..dfbb773288e 100644 --- a/frameworks/core/components_ng/test/pattern/text/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text/BUILD.gn @@ -106,7 +106,6 @@ ohos_unittest("text_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn b/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn index 31711546a65..c0f45454ed8 100644 --- a/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn @@ -43,7 +43,6 @@ ohos_unittest("text_clock_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_layout_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_pattern.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/render_context.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn index 8ad233e66e4..5d0b68a90d5 100644 --- a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn @@ -170,7 +170,6 @@ ohos_unittest("textfield_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn b/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn index 9ae7eac712d..fdc43218e97 100644 --- a/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn @@ -43,7 +43,6 @@ ohos_unittest("text_timer_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_layout_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_pattern.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/render_context.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn b/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn index 8d904df1b1b..823ac50781c 100644 --- a/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn @@ -58,7 +58,6 @@ ohos_unittest("toggle_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/video/BUILD.gn b/frameworks/core/components_ng/test/pattern/video/BUILD.gn index 25886f29c4c..993261ae0e7 100644 --- a/frameworks/core/components_ng/test/pattern/video/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/video/BUILD.gn @@ -144,7 +144,6 @@ ohos_unittest("video_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn b/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn index 4e68d2caba5..bafe03b6772 100644 --- a/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn @@ -78,7 +78,6 @@ ohos_unittest("xcomponent_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/accessibility/BUILD.gn b/frameworks/core/components_ng/test/property/accessibility/BUILD.gn index 175786000c9..67904e96578 100644 --- a/frameworks/core/components_ng/test/property/accessibility/BUILD.gn +++ b/frameworks/core/components_ng/test/property/accessibility/BUILD.gn @@ -63,7 +63,6 @@ ohos_unittest("accessibility_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/calc_length/BUILD.gn b/frameworks/core/components_ng/test/property/calc_length/BUILD.gn index 83957eb8b30..1beb1023736 100644 --- a/frameworks/core/components_ng/test/property/calc_length/BUILD.gn +++ b/frameworks/core/components_ng/test/property/calc_length/BUILD.gn @@ -63,7 +63,6 @@ ohos_unittest("calc_length_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/gradient/BUILD.gn b/frameworks/core/components_ng/test/property/gradient/BUILD.gn index b714a01207c..3590c7d47d8 100644 --- a/frameworks/core/components_ng/test/property/gradient/BUILD.gn +++ b/frameworks/core/components_ng/test/property/gradient/BUILD.gn @@ -63,7 +63,6 @@ ohos_unittest("gradient_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/grid_property/BUILD.gn b/frameworks/core/components_ng/test/property/grid_property/BUILD.gn index 21e8ba2e8b7..871d50e1456 100755 --- a/frameworks/core/components_ng/test/property/grid_property/BUILD.gn +++ b/frameworks/core/components_ng/test/property/grid_property/BUILD.gn @@ -52,7 +52,6 @@ ohos_unittest("grid_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn index e2f15d639dd..5bd838bb369 100755 --- a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn +++ b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn @@ -22,7 +22,6 @@ ohos_unittest("measure_utils_test_ng") { "$ace_root/frameworks/core/components/common/properties/color.cpp", # components_ng - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/property_test/BUILD.gn b/frameworks/core/components_ng/test/property/property_test/BUILD.gn index ea143c8c4c6..8b2eae73d67 100755 --- a/frameworks/core/components_ng/test/property/property_test/BUILD.gn +++ b/frameworks/core/components_ng/test/property/property_test/BUILD.gn @@ -18,7 +18,6 @@ ohos_unittest("property_test_ng") { module_out_path = property_test_output_path sources = [ - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "property_test_ng.cpp", ] diff --git a/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn b/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn index 4af8f263b96..d067e2e3b27 100644 --- a/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn @@ -85,7 +85,6 @@ ohos_unittest("for_each_syntax_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn b/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn index 2d1eeeae255..4e9a5b4b5c7 100644 --- a/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn @@ -80,7 +80,6 @@ ohos_unittest("if_else_syntax_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn b/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn index 7367e94aee4..f581b605a59 100644 --- a/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn @@ -52,7 +52,6 @@ ohos_unittest("lazy_for_each_syntax_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 3da06a0a267..43b6d912f3c 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -189,7 +189,6 @@ ohos_source_set("ace_components_property") { part_name = ace_engine_part sources = [ "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", - "$ace_root/frameworks/core/components_ng/property/border_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", diff --git a/test/unittest/core/pattern/window_scene/BUILD.gn b/test/unittest/core/pattern/window_scene/BUILD.gn index 4ce5606faea..d3c0a831561 100755 --- a/test/unittest/core/pattern/window_scene/BUILD.gn +++ b/test/unittest/core/pattern/window_scene/BUILD.gn @@ -91,7 +91,6 @@ ohos_unittest("window_scene_test") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", # components_ng_property - "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/test/unittest/core/pipeline/BUILD.gn b/test/unittest/core/pipeline/BUILD.gn index 4ae2ac6257c..1bf80da74fd 100644 --- a/test/unittest/core/pipeline/BUILD.gn +++ b/test/unittest/core/pipeline/BUILD.gn @@ -202,7 +202,6 @@ ohos_unittest("pipeline_context_test_ng") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock/mock_image_pattern.cpp", # property - "$ace_root/frameworks/core/components_ng/property/border_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", diff --git a/test/unittest/core/render/render_context/BUILD.gn b/test/unittest/core/render/render_context/BUILD.gn index 412bfb65d22..5896a0c8985 100755 --- a/test/unittest/core/render/render_context/BUILD.gn +++ b/test/unittest/core/render/render_context/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("render_context_test_ng") { "$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/border_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", From 25ea529d7de7c8277e45b46ac2092cda83fbd6f7 Mon Sep 17 00:00:00 2001 From: wangtao Date: Wed, 24 May 2023 06:33:22 +0000 Subject: [PATCH 79/99] add TextField TDD testcases Signed-off-by: wangtao --- .../pattern/textfield/textfield_test_ng.cpp | 349 +++++++++++++++++- 1 file changed, 347 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/test/pattern/textfield/textfield_test_ng.cpp b/frameworks/core/components_ng/test/pattern/textfield/textfield_test_ng.cpp index c06548d19ef..a51b6f9ca90 100644 --- a/frameworks/core/components_ng/test/pattern/textfield/textfield_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/textfield/textfield_test_ng.cpp @@ -357,7 +357,7 @@ HWTEST_F(TextFieldPatternTestNg, EditingValueFilter001, TestSize.Level1) EXPECT_EQ(valueToUpdate, "filter_value1test"); layoutProperty->UpdateInputFilter("test"); textFieldPattern->EditingValueFilter(valueToUpdate, result); - EXPECT_EQ(valueToUpdate, "test"); + EXPECT_EQ(valueToUpdate, "1test"); } /** @@ -3553,4 +3553,349 @@ HWTEST_F(TextFieldPatternTestNg, ShowOverlay001, TestSize.Level1) EXPECT_EQ(firstHandle, std::nullopt); EXPECT_EQ(secondHandle, std::nullopt); } -} // namespace OHOS::Ace::NG + +/** + * @tc.name: TextFieldModelNGSetShowUnderLine + * @tc.desc: test SetShowUnderLine. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, TextFieldModelNGSetShowUnderLine, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create TextFieldPattern and TextFieldLayoutProperty. + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + auto layoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + + /** + * @tc.steps: step2. test branch - showUnderLine is true and PropertyChangeFlag is PROPERTY_UPDATE_NORMAL. + * @tc.expected: Check the ShowUnderLine of the pattern. + */ + TextFieldModelNG textFieldModelNG; + textFieldModelNG.SetShowUnderline(true); + layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_NORMAL); + EXPECT_TRUE(layoutProperty->GetShowUnderline().value()); + + /** + * @tc.steps: step3. test branch - showUnderLine is false. + * @tc.expected: Check the ShowUnderLine of the pattern. + */ + textFieldModelNG.SetShowUnderline(false); + EXPECT_FALSE(layoutProperty->GetShowUnderline().value()); + + /** + * @tc.steps: step4. test branch - showUnderLine is true and PropertyChangeFlag not equal PROPERTY_UPDATE_NORMAL. + * @tc.expected: Check the ShowUnderLine of the pattern. + */ + layoutProperty->UpdatePropertyChangeFlag(PROPERTY_UPDATE_MEASURE); + textFieldModelNG.SetShowUnderline(true); + EXPECT_TRUE(layoutProperty->GetShowUnderline().value()); + + /** + * @tc.steps: step5. test branch - showUnderLine is true and layoutProperty has text color. + * @tc.expected: Check the ShowUnderLine of the pattern. + */ + layoutProperty->UpdateTextColor(Color::FromString("#FF909090")); + textFieldModelNG.SetShowUnderline(true); + EXPECT_TRUE(layoutProperty->GetShowUnderline().value()); +} + +/** + * @tc.name: TextFieldModelNGProcessDefaultPadding + * @tc.desc: test ProcessDefaultPadding. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, TextFieldModelNGProcessDefaultPadding, TestSize.Level2) +{ + /** + * @tc.steps: step1. Crate TextFieldLayoutProperty and MockThemeManager. + * @tc.expected: Check if they are nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto layoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + auto themeManager = AceType::MakeRefPtr(); + MockPipelineBase::GetCurrent()->SetThemeManager(themeManager); + EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(AceType::MakeRefPtr())); + + /** + * @tc.steps: step2. let ShowUnderLine be true. + * @tc.expected: Check the paddingProperty. + */ + TextFieldModelNG textFieldModelNG; + PaddingProperty paddingProperty; + + layoutProperty->UpdateShowUnderline(true); + textFieldModelNG.ProcessDefaultPadding(paddingProperty); + Dimension vertical { 12.0, DimensionUnit::PX }; + Dimension horizontal { 0.0, DimensionUnit::PX }; + EXPECT_EQ(paddingProperty.top.value().GetDimension(), vertical); + EXPECT_EQ(paddingProperty.bottom.value().GetDimension(), vertical); + EXPECT_EQ(paddingProperty.left.value().GetDimension(), horizontal); + EXPECT_EQ(paddingProperty.right.value().GetDimension(), horizontal); + + /** + * @tc.steps: step3. let ShowUnderLine be false. + * @tc.expected: Check the value of the updated property. + */ + layoutProperty->UpdateShowUnderline(false); + textFieldModelNG.ProcessDefaultPadding(paddingProperty); + Dimension zero { 0.0, DimensionUnit::PX }; + EXPECT_EQ(paddingProperty.top.value().GetDimension(), zero); + EXPECT_EQ(paddingProperty.bottom.value().GetDimension(), zero); + EXPECT_EQ(paddingProperty.left.value().GetDimension(), zero); + EXPECT_EQ(paddingProperty.right.value().GetDimension(), zero); +} + +/** + * @tc.name: TextFieldModelNGSetWidthAuto + * @tc.desc: test SetWidthAuto. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, TextFieldModelNGSetWidthAuto, TestSize.Level2) +{ + /** + * @tc.steps: step1. Crate TextFieldLayoutProperty + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto layoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + + /** + * @tc.steps: step2. call SetWidthAuto. + * @tc.expected: Check the value of WidthAuto. + */ + TextFieldModelNG textFieldModelNG; + textFieldModelNG.SetWidthAuto(true); + EXPECT_TRUE(layoutProperty->GetWidthAuto().value_or(false)); + + textFieldModelNG.SetWidthAuto(false); + EXPECT_FALSE(layoutProperty->GetWidthAuto().value_or(true)); +} + +/** + * @tc.name: OnDirtyLayoutWrapperSwap + * @tc.desc: test OnDirtyLayoutWrapperSwap + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, OnDirtyLayoutWrapperSwap, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create LayoutWrapper. + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto geometryNode = frameNode->GetGeometryNode(); + ASSERT_NE(geometryNode, nullptr); + auto layoutProperty = GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + RefPtr layoutWrapper = AceType::MakeRefPtr(frameNode, geometryNode, layoutProperty); + ASSERT_NE(layoutWrapper, nullptr); + auto textFieldPattern = GetPattern(); + ASSERT_NE(textFieldPattern, nullptr); + auto textFieldLayoutAlgorithm = textFieldPattern->CreateLayoutAlgorithm(); + layoutWrapper->SetLayoutAlgorithm(AceType::MakeRefPtr(textFieldLayoutAlgorithm)); + + /** + * @tc.steps: step2. Call OnDirtyLayoutWrapperSwap. + * @tc.expected: Check the return value. + */ + DirtySwapConfig dirtySwapConfig; + EXPECT_TRUE(textFieldPattern->OnDirtyLayoutWrapperSwap(layoutWrapper, dirtySwapConfig)); +} + +/** + * @tc.name: GetFontFamily + * @tc.desc: test GetFontFamily. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, GetFontFamily, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create TextFieldLayoutProperty. + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + auto layoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + + /** + * @tc.steps: step2. Call GetFontFamily. + * @tc.expected: Check the font family return from GetFontFamily. + */ + std::vector fontFamily = { "Sans", "serif" }; + layoutProperty->UpdateFontFamily(fontFamily); + + auto getFontFamily = pattern->GetFontFamily(); + EXPECT_STREQ(getFontFamily.c_str(), "Sans,serif"); +} + +/** + * @tc.name: UpdateCaretPositionByMouseMovement + * @tc.desc: test UpdateCaretPositionByMouseMovement. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, UpdateCaretPositionByMouseMovement, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create frameNode.Get pattern. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + + /** + * @tc.steps: step2. call function UpdateCaretPositionByMouseMovement. + * @tc.expected: Check the return value. + */ + EXPECT_FALSE(pattern->UpdateCaretPositionByMouseMovement()); + pattern->UpdateEditingValue(TEXT_VALUE, 5); + pattern->UpdateCaretPositionByMouseMovement(); + EXPECT_FALSE(pattern->UpdateCaretPositionByMouseMovement()); + + pattern->lastTouchOffset_.SetX(8); + pattern->contentRect_.SetLeft(4); + pattern->contentRect_.SetWidth(2); + EXPECT_TRUE(pattern->UpdateCaretPositionByMouseMovement()); +} + +/** + * @tc.name: UpdateSelectionOffset + * @tc.desc: test UpdateSelectionOffset. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, UpdateSelectionOffset, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create TextFieldPattern. + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + + /** + * @tc.steps: step2. setup condition parameters. + * @tc.expected: Check the value of the updated property. + */ + pattern->SetInSelectMode(SelectionMode::SELECT_ALL); + pattern->textSelector_.baseOffset = 5; + pattern->textSelector_.destinationOffset = 6; + pattern->textRect_.SetLeft(4); + pattern->textRect_.SetWidth(4); + pattern->UpdateSelectionOffset(); + EXPECT_EQ(pattern->GetTextSelector().selectionBaseOffset.GetX(), 4); + EXPECT_EQ(pattern->GetTextSelector().selectionDestinationOffset.GetX(), 8); + + std::vector textBoxes; + RSTypographyProperties::TextBox textBox; + textBoxes.emplace_back(textBox); + pattern->textBoxes_ = textBoxes; + pattern->textRect_.SetLeft(5); + pattern->textRect_.SetWidth(5); + pattern->UpdateSelectionOffset(); + EXPECT_EQ(pattern->GetTextSelector().selectionBaseOffset.GetX(), 5); + EXPECT_EQ(pattern->GetTextSelector().selectionDestinationOffset.GetX(), 10); +} + +/** + * @tc.name: UpdateCaretPositionByTextEdit + * @tc.desc: test UpdateCaretPositionByTextEdit. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, UpdateCaretPositionByTextEdit, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create TextFieldPattern. + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto layoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + + /** + * @tc.steps: step2. let editing text be empty. + * @tc.expected: Check CaretRect property. + */ + layoutProperty->UpdateMaxLines(2); + layoutProperty->UpdateTextAlign(TextAlign::START); + pattern->textRect_.SetLeft(8); + pattern->textRect_.SetTop(5); + pattern->UpdateEditingValue("", 0); + pattern->UpdateCaretPositionByTextEdit(); + EXPECT_EQ(pattern->GetCaretRect().GetX(), 8); + EXPECT_EQ(pattern->GetCaretRect().GetY(), 5); + + /** + * @tc.steps: step3. let editing text caret position be zero. + * @tc.expected: Check CaretRect property. + */ + pattern->UpdateEditingValue(TEXT_VALUE, 0); + pattern->textEditingValue_.caretPosition = 0; + pattern->UpdateCaretPositionByTextEdit(); + EXPECT_EQ(pattern->GetCaretRect().GetX(), 8); + EXPECT_EQ(pattern->GetCaretRect().GetY(), 5); + + /** + * @tc.steps: step4. editing text not empty and caret position > 0. + * @tc.expected: Check CaretRect property. + */ + pattern->textEditingValue_.caretPosition = 1; + pattern->contentRect_.SetLeft(4); + pattern->UpdateCaretPositionByTextEdit(); + EXPECT_EQ(pattern->GetCaretRect().GetX(), 4); + EXPECT_EQ(pattern->GetCaretRect().GetY(), 5); +} + +/** + * @tc.name: GetCopyOptionString + * @tc.desc: test GetCopyOptionString. + * @tc.type: FUNC + */ +HWTEST_F(TextFieldPatternTestNg, GetCopyOptionString, TestSize.Level2) +{ + /** + * @tc.steps: step1. Create TextFieldPattern. + * @tc.expected: Check it is not nullptr. + */ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + ASSERT_NE(frameNode, nullptr); + auto layoutProperty = frameNode->GetLayoutProperty(); + ASSERT_NE(layoutProperty, nullptr); + auto pattern = frameNode->GetPattern(); + ASSERT_NE(pattern, nullptr); + + /** + * @tc.steps: step2. build all test items and call GetCopyOptionString. + * @tc.expected: Check the return value. + */ + struct OptionData { + CopyOptions options; + std::string expectOptionString; + }; + std::vector allOptions = { { CopyOptions::InApp, "CopyOptions.InApp" }, + { CopyOptions::Local, "CopyOptions.Local" }, { CopyOptions::Distributed, "CopyOptions.Distributed" }, + { CopyOptions::None, "CopyOptions.None" } }; + for (auto optionData : allOptions) { + layoutProperty->UpdateCopyOptions(optionData.options); + EXPECT_STREQ(pattern->GetCopyOptionString().c_str(), optionData.expectOptionString.c_str()); + } +} +} // namespace OHOS::Ace::NG \ No newline at end of file From 38639b01ce01a0e7609edd3756d56ef69cc3527a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=A8=9F?= Date: Wed, 24 May 2023 11:36:02 +0000 Subject: [PATCH 80/99] update frameworks/core/components_ng/pattern/text/text_pattern.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李娟 --- frameworks/core/components_ng/pattern/text/text_pattern.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index d4821d04790..510762cec73 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -59,7 +59,6 @@ void TextPattern::OnDetachFromFrameNode(FrameNode* node) LOGD("Unregister surface change callback with id %{public}d", surfaceChangedCallbackId_.value_or(-1)); pipeline->UnregisterSurfaceChangedCallback(surfaceChangedCallbackId_.value_or(-1)); } - ResetSelection(); } void TextPattern::CloseSelectOverlay() From 4ffe0ecc3a0a22a90ef34b1d2e6a5875a615ae0c Mon Sep 17 00:00:00 2001 From: lizhan Date: Tue, 23 May 2023 19:33:15 +0800 Subject: [PATCH 81/99] =?UTF-8?q?=E8=A1=A5=E5=85=85TDD=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9Etemplates=5Fparser=E7=9A=84tdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lizhan Change-Id: I1d1d3ba7d1fc101a50c4822010894fb45896e9d9 Committer: lizhan Change-Id: I7c654a742eaf4289ad7a2958b971fb47b52343a5 --- .../test/base/inspector/inspector_test_ng.cpp | 53 ++++-- test/unittest/core/BUILD.gn | 1 + test/unittest/core/property/BUILD.gn | 21 +++ .../property/templates_parser_test_ng.cpp | 159 ++++++++++++++++++ 4 files changed, 223 insertions(+), 11 deletions(-) create mode 100644 test/unittest/core/property/BUILD.gn create mode 100644 test/unittest/core/property/templates_parser_test_ng.cpp diff --git a/frameworks/core/components_ng/test/base/inspector/inspector_test_ng.cpp b/frameworks/core/components_ng/test/base/inspector/inspector_test_ng.cpp index efd55cb0cc1..b5af66f099e 100755 --- a/frameworks/core/components_ng/test/base/inspector/inspector_test_ng.cpp +++ b/frameworks/core/components_ng/test/base/inspector/inspector_test_ng.cpp @@ -16,25 +16,26 @@ #include #include #include -#include #include +#include + #include "gtest/gtest.h" #define protected public #define private public +#include "cJSON.h" +#include "interfaces/inner_api/ace/ui_content.h" +#include "test/mock/base/mock_task_executor.h" + #include "base/utils/utils.h" -#include "core/components_ng/base/inspector.h" #include "core/common/ace_application_info.h" +#include "core/components_ng/base/inspector.h" #include "core/components_ng/base/ui_node.h" +#include "core/components_ng/pattern/stage/stage_manager.h" #include "core/components_ng/pattern/text/span_node.h" #include "core/components_v2/inspector/inspector_constants.h" #include "core/pipeline_ng/pipeline_context.h" #include "core/pipeline_ng/test/mock/mock_pipeline_base.h" -#include "core/components_ng/pattern/stage/stage_manager.h" -#include "interfaces/inner_api/ace/ui_content.h" -#include "cJSON.h" -#undef private -#undef protected using namespace testing; using namespace testing::ext; @@ -129,7 +130,7 @@ HWTEST_F(InspectorTestNg, InspectorTestNg002, TestSize.Level1) */ context1->rootNode_ = ONE; ASSERT_NE(context1, nullptr); - auto test2 =Inspector::GetInspectorNodeByKey(key); + auto test2 = Inspector::GetInspectorNodeByKey(key); EXPECT_EQ(test2, ""); /** * @tc.steps: step3. callback GetInspectorNodeByKey @@ -156,8 +157,14 @@ HWTEST_F(InspectorTestNg, InspectorTestNg003, TestSize.Level1) context1->GetStageManager()->GetLastPage()->GetParent()->SetParent(ONE); + /** + * @tc.steps: step2. call GetInspector + * @tc.expected: the return value is empty string + */ auto test1 = Inspector::GetInspector(false); + EXPECT_NE(test1, ""); auto test3 = Inspector::GetInspector(true); + EXPECT_NE(test3, ""); context1->stageManager_ = nullptr; } @@ -240,7 +247,32 @@ HWTEST_F(InspectorTestNg, InspectorTestNg006, TestSize.Level1) children.push_back(TWO); auto test = Inspector::GetInspector(false); + + /** + * @tc.steps: step2 add child to two and create a temp node with tag "temp" + call GetInspector + * @tc.expected: the return value is empty string + */ + THREE->isInternal_ = true; + TWO->AddChild(PAGE); + TWO->AddChild(THREE); + TWO->AddChild(STAGE); + auto temp = FrameNode::CreateFrameNode("temp", 5, AceType::MakeRefPtr(), true); + STAGE->AddChild(temp); + ONE->tag_ = "stage"; + auto test1 = Inspector::GetInspector(false); + EXPECT_NE(test1, ""); + + PAGE->hostPageId_ = TWO->GetPageId(); + auto test2 = Inspector::GetInspector(false); + EXPECT_NE(test2, ""); + + TWO->children_.clear(); + auto test3 = Inspector::GetInspector(false); + EXPECT_NE(test3, ""); + context1->stageManager_ = nullptr; + ONE->tag_ = "one"; } /** @@ -265,8 +297,7 @@ HWTEST_F(InspectorTestNg, InspectorTestNg007, TestSize.Level1) ONE->children_.pop_back(); auto pageRootNode = context1->GetStageManager()->GetLastPage(); auto test = Inspector::GetInspector(false); - EXPECT_EQ(test, - "{\"$type\":\"root\",\"width\":\"0.000000\",\"height\":\"0.000000\",\"$resolution\":\"0.000000\"}"); + EXPECT_EQ(test, "{\"$type\":\"root\",\"width\":\"0.000000\",\"height\":\"0.000000\",\"$resolution\":\"0.000000\"}"); context1->stageManager_ = nullptr; } -} // namespace OHOS::Ace::NG \ No newline at end of file +} // namespace OHOS::Ace::NG diff --git a/test/unittest/core/BUILD.gn b/test/unittest/core/BUILD.gn index 136de4f652b..af647d7b988 100644 --- a/test/unittest/core/BUILD.gn +++ b/test/unittest/core/BUILD.gn @@ -21,6 +21,7 @@ group("core_unittest") { "gestures:gestures_test_ng", "pattern:core_pattern_unittest", "pipeline:pipeline_context_test_ng", + "property:templates_parser_test_ng", "render:render_unittest", ] } diff --git a/test/unittest/core/property/BUILD.gn b/test/unittest/core/property/BUILD.gn new file mode 100644 index 00000000000..5d7553f1df5 --- /dev/null +++ b/test/unittest/core/property/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (c) 2022-2023 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. + +import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") + +ace_unittest("templates_parser_test_ng") { + sources = [ + "$ace_root/frameworks/core/components_ng/property/templates_parser.cpp", + "templates_parser_test_ng.cpp", + ] +} diff --git a/test/unittest/core/property/templates_parser_test_ng.cpp b/test/unittest/core/property/templates_parser_test_ng.cpp new file mode 100644 index 00000000000..2481e7e2718 --- /dev/null +++ b/test/unittest/core/property/templates_parser_test_ng.cpp @@ -0,0 +1,159 @@ +/* + * 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 +#include +#include + +#include "gtest/gtest.h" + +#define protected public +#define private public + +#include "core/components_ng/property/templates_parser.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Ace::NG { +namespace {} + +class TemplatesParserTestNg : public testing::Test { +public: + static void SetUpTestSuite() {}; + static void TeardownTestSuite() {}; +}; + +/** + * @tc.name: TemplatesParserTestNg001 + * @tc.desc: Test ParseTemplateArgs. + * @tc.type: FUNC + */ +HWTEST_F(TemplatesParserTestNg, TemplatesParserTestNg001, TestSize.Level1) +{ + /** + * @tc.steps: step1 init args of ParseTemplateArgs. + * @tc.steps: step1 call ParseTemplateArgs. + * @tc.expected: the return value is same as the forth val of tuple. + */ + double size = 0; + double gap = 0; + int32_t childrenCount = 0; + std::vector, double, double, int32_t, std::vector>> parms = { + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return ""; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "abc"; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "1fr 2px 3%"; + }, + size, gap, childrenCount, { -2, 0, 0 } }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "1fr 2px 900%"; + }, + size, gap, childrenCount, { -2, 0, 0 } }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "auto-fill 1fr 3fr"; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 100; + childrenCount = 5; + return "0.1fr 20px 100px"; + }, + size, gap, childrenCount, { -12, 0, 0 } }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "repeat"; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "auto-fill"; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "repeat(1, 100px 2px 3px 4px 5px 6px 7px 8px)"; + }, + size, gap, childrenCount, { 0, 0, 0, 0, 0, 0, 0, 0 } }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "repeatabcdefghi"; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "repeat(3, 100px a b c d e f g)"; + }, + size, gap, childrenCount, {} }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "repeat auto-fill 1fr 2px 900%"; + }, + size, gap, childrenCount, { 0 } }, + { [&]() { + size = 200; + gap = 10; + childrenCount = 5; + return "auto-fill arepeatpx10vp10 10)2"; + }, + size, gap, childrenCount, { 0 } }, + }; + for (auto [args, size, gap, childrenCount, rt] : parms) { + auto result = ParseTemplateArgs(args(), size, gap, childrenCount); + if (rt.size() == 0) { + EXPECT_EQ(result.size(), 0); + continue; + } + EXPECT_NE(result.size(), 0); + for (int i = 0; i < rt.size() && i < result.size(); i++) { + EXPECT_EQ(rt[i], result[i]); + } + } +} +} // namespace OHOS::Ace::NG From 0be79b9c27f3e848bc6d419879e2e5feea79ed1e Mon Sep 17 00:00:00 2001 From: zhoutianer Date: Wed, 24 May 2023 11:22:01 +0800 Subject: [PATCH 82/99] fix border xts Signed-off-by: zhoutianer Change-Id: Ib6ee53abcc2da4e8972ff6114801efebf6cc5a4f Signed-off-by: zhoutianer --- .../core/components_ng/base/view_abstract.cpp | 1 - .../base/view_abstract_model_ng.h | 7 +- .../core/components_ng/property/BUILD.gn | 1 + .../property/border_property.cpp | 203 ++++++++++++++++++ .../components_ng/property/border_property.h | 118 +++++----- .../components_ng/render/render_property.h | 45 +--- .../accessibility/accessibilitynode/BUILD.gn | 1 + .../accessibility/accessibilityutils/BUILD.gn | 1 + .../test/base/frame_node/BUILD.gn | 1 + .../test/base/geometry_node/BUILD.gn | 1 + .../test/base/inspector/BUILD.gn | 1 + .../components_ng/test/base/ui_node/BUILD.gn | 1 + .../test/base/view_abstract/BUILD.gn | 1 + .../test/base/view_abstract_model/BUILD.gn | 1 + .../base/view_full_update_model_ng/BUILD.gn | 1 + .../view_partial_update_model_ng/BUILD.gn | 1 + .../test/base/view_stack_processor/BUILD.gn | 1 + .../test/event/click_event/BUILD.gn | 1 + .../test/event/drag_event/BUILD.gn | 1 + .../test/event/event_hub/BUILD.gn | 1 + .../test/event/focus_hub/BUILD.gn | 1 + .../test/event/gesture_event_hub/BUILD.gn | 1 + .../test/event/input_event_hub/BUILD.gn | 1 + .../test/event/long_press_event/BUILD.gn | 1 + .../test/event/pan_event/BUILD.gn | 1 + .../test/event/scrollable_event/BUILD.gn | 1 + .../test/event/touch_event/BUILD.gn | 1 + .../test/image_provider/BUILD.gn | 1 + .../test/layout/box_layout_algorithm/BUILD.gn | 1 + .../test/layout/layout_property/BUILD.gn | 1 + .../test/layout/layout_wrapper/BUILD.gn | 1 + .../layout/layout_wrapper_builder/BUILD.gn | 1 + .../test/manager/shared_overlay/BUILD.gn | 1 + .../test/pattern/ability_component/BUILD.gn | 1 + .../components_ng/test/pattern/badge/BUILD.gn | 1 + .../components_ng/test/pattern/blank/BUILD.gn | 1 + .../test/pattern/bubble/BUILD.gn | 1 + .../test/pattern/button/BUILD.gn | 1 + .../test/pattern/calendar/BUILD.gn | 1 + .../test/pattern/checkbox/BUILD.gn | 1 + .../test/pattern/checkboxgroup/BUILD.gn | 1 + .../test/pattern/container_modal/BUILD.gn | 1 + .../test/pattern/counter/BUILD.gn | 1 + .../test/pattern/custom_dialog/BUILD.gn | 1 + .../test/pattern/data_panel/BUILD.gn | 1 + .../test/pattern/divider/BUILD.gn | 1 + .../components_ng/test/pattern/flex/BUILD.gn | 1 + .../components_ng/test/pattern/form/BUILD.gn | 1 + .../components_ng/test/pattern/gauge/BUILD.gn | 1 + .../components_ng/test/pattern/grid/BUILD.gn | 1 + .../test/pattern/grid_col/BUILD.gn | 1 + .../test/pattern/grid_row/BUILD.gn | 1 + .../test/pattern/hyperlink/BUILD.gn | 1 + .../components_ng/test/pattern/image/BUILD.gn | 1 + .../test/pattern/indexer/BUILD.gn | 1 + .../test/pattern/linear_layout/BUILD.gn | 1 + .../test/pattern/linear_split/BUILD.gn | 1 + .../components_ng/test/pattern/list/BUILD.gn | 1 + .../components_ng/test/pattern/menu/BUILD.gn | 1 + .../test/pattern/navigation/BUILD.gn | 1 + .../test/pattern/overlay/BUILD.gn | 1 + .../test/pattern/patternlock/BUILD.gn | 1 + .../test/pattern/picker/BUILD.gn | 1 + .../test/pattern/plugin/BUILD.gn | 1 + .../test/pattern/qrcode/BUILD.gn | 1 + .../components_ng/test/pattern/radio/BUILD.gn | 1 + .../test/pattern/rating/BUILD.gn | 1 + .../test/pattern/refresh/BUILD.gn | 1 + .../test/pattern/scroll/BUILD.gn | 1 + .../test/pattern/search/BUILD.gn | 1 + .../test/pattern/security_component/BUILD.gn | 1 + .../test/pattern/select/BUILD.gn | 1 + .../test/pattern/select_overlay/BUILD.gn | 1 + .../test/pattern/side_bar/BUILD.gn | 1 + .../test/pattern/stepper/BUILD.gn | 1 + .../test/pattern/swiper/BUILD.gn | 1 + .../components_ng/test/pattern/tabs/BUILD.gn | 1 + .../components_ng/test/pattern/text/BUILD.gn | 1 + .../test/pattern/text_clock/BUILD.gn | 1 + .../test/pattern/textfield/BUILD.gn | 1 + .../test/pattern/texttimer/BUILD.gn | 1 + .../test/pattern/toggle/BUILD.gn | 1 + .../components_ng/test/pattern/video/BUILD.gn | 1 + .../test/pattern/xcomponent/BUILD.gn | 1 + .../test/property/accessibility/BUILD.gn | 1 + .../test/property/calc_length/BUILD.gn | 1 + .../test/property/gradient/BUILD.gn | 1 + .../test/property/grid_property/BUILD.gn | 1 + .../test/property/measure_utils/BUILD.gn | 1 + .../test/property/property_test/BUILD.gn | 1 + .../test/syntax/for_each/BUILD.gn | 1 + .../test/syntax/if_else/BUILD.gn | 1 + .../test/syntax/lazy_for_each/BUILD.gn | 1 + test/unittest/BUILD.gn | 1 + .../core/pattern/window_scene/BUILD.gn | 1 + test/unittest/core/pipeline/BUILD.gn | 1 + .../core/render/render_context/BUILD.gn | 1 + 97 files changed, 364 insertions(+), 102 deletions(-) create mode 100644 frameworks/core/components_ng/property/border_property.cpp diff --git a/frameworks/core/components_ng/base/view_abstract.cpp b/frameworks/core/components_ng/base/view_abstract.cpp index 6b7a5d4783c..429fa0cfd5e 100644 --- a/frameworks/core/components_ng/base/view_abstract.cpp +++ b/frameworks/core/components_ng/base/view_abstract.cpp @@ -424,7 +424,6 @@ void ViewAbstract::SetBorderRadius(const Dimension& value) } BorderRadiusProperty borderRadius; borderRadius.SetRadius(value); - borderRadius.SetRadiusFlag(true); ACE_UPDATE_RENDER_CONTEXT(BorderRadius, borderRadius); } diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.h b/frameworks/core/components_ng/base/view_abstract_model_ng.h index b3506f17e80..080a95151bb 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.h +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.h @@ -135,7 +135,7 @@ public: { ViewAbstract::SetForegroundBlurStyle(fgBlurStyle); } - + void SetSphericalEffect(double radio) override { ViewAbstract::SetSphericalEffect(radio); @@ -257,6 +257,7 @@ public: borderRadius.radiusTopRight = radiusTopRight; borderRadius.radiusBottomLeft = radiusBottomLeft; borderRadius.radiusBottomRight = radiusBottomRight; + borderRadius.multiValued = true; ViewAbstract::SetBorderRadius(borderRadius); } @@ -272,6 +273,7 @@ public: borderColors.rightColor = colorRight; borderColors.topColor = colorTop; borderColors.bottomColor = colorBottom; + borderColors.multiValued = true; ViewAbstract::SetBorderColor(borderColors); } @@ -288,6 +290,7 @@ public: borderWidth.rightDimen = right; borderWidth.topDimen = top; borderWidth.bottomDimen = bottom; + borderWidth.multiValued = true; ViewAbstract::SetBorderWidth(borderWidth); } @@ -304,6 +307,7 @@ public: borderStyles.styleRight = styleRight.value_or(BorderStyle::SOLID); borderStyles.styleTop = styleTop.value_or(BorderStyle::SOLID); borderStyles.styleBottom = styleBottom.value_or(BorderStyle::SOLID); + borderStyles.multiValued = true; ViewAbstract::SetBorderStyle(borderStyles); } @@ -821,6 +825,7 @@ public: { ViewAbstract::SetForegroundColorStrategy(strategy); } + private: void RegisterMenuAppearCallback( std::vector& params, std::function&& buildFunc, const MenuParam& menuParam); diff --git a/frameworks/core/components_ng/property/BUILD.gn b/frameworks/core/components_ng/property/BUILD.gn index 4328aa11917..f960fce7b9f 100644 --- a/frameworks/core/components_ng/property/BUILD.gn +++ b/frameworks/core/components_ng/property/BUILD.gn @@ -17,6 +17,7 @@ import( build_component_ng("property_ng") { sources = [ "accessibility_property.cpp", + "border_property.cpp", "calc_length.cpp", "gradient_property.cpp", "grid_property.cpp", diff --git a/frameworks/core/components_ng/property/border_property.cpp b/frameworks/core/components_ng/property/border_property.cpp new file mode 100644 index 00000000000..19f7a2ae2e9 --- /dev/null +++ b/frameworks/core/components_ng/property/border_property.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "border_property.h" + +namespace OHOS::Ace::NG { +void BorderStyleProperty::ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + static const char* BORDER_STYLE[] = { + "BorderStyle.Solid", + "BorderStyle.Dashed", + "BorderStyle.Dotted", + "BorderStyle.None", + }; + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("left", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); + res->Put("top", BORDER_STYLE[static_cast(styleTop.value_or(BorderStyle::SOLID))]); + res->Put("right", BORDER_STYLE[static_cast(styleRight.value_or(BorderStyle::SOLID))]); + res->Put("bottom", BORDER_STYLE[static_cast(styleBottom.value_or(BorderStyle::SOLID))]); + + json->Put("borderStyle", res); + borderJson->Put("style", res); + } else { + json->Put("borderStyle", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); + borderJson->Put("style", BORDER_STYLE[static_cast(styleLeft.value_or(BorderStyle::SOLID))]); + } +} + +std::string BorderWidthPropertyT::ToString() const +{ + std::string str; + str.append("leftDimen: [").append(leftDimen.has_value() ? leftDimen->ToString() : "NA").append("]"); + str.append("rightDimen: [").append(rightDimen.has_value() ? rightDimen->ToString() : "NA").append("]"); + str.append("topDimen: [").append(topDimen.has_value() ? topDimen->ToString() : "NA").append("]"); + str.append("bottomDimen: [").append(bottomDimen.has_value() ? bottomDimen->ToString() : "NA").append("]"); + return str; +} + +void BorderWidthPropertyT::ToJsonValue( + std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("left", leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("top", topDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("right", rightDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("bottom", bottomDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + + borderJson->Put("width", res); + json->Put("borderWidth", borderJson); + } else { + auto left = leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString(); + borderJson->Put("width", left.c_str()); + json->Put("borderWidth", left.c_str()); + } +} + +bool BorderWidthPropertyT::UpdateWithCheck(const BorderWidthPropertyT& value) +{ + bool isModified = false; + if (value.leftDimen.has_value() && (leftDimen != value.leftDimen)) { + leftDimen = value.leftDimen; + isModified = true; + } + if (value.rightDimen.has_value() && (rightDimen != value.rightDimen)) { + rightDimen = value.rightDimen; + isModified = true; + } + if (value.topDimen.has_value() && (topDimen != value.topDimen)) { + topDimen = value.topDimen; + isModified = true; + } + if (value.bottomDimen.has_value() && (bottomDimen != value.bottomDimen)) { + bottomDimen = value.bottomDimen; + isModified = true; + } + return isModified; +} + +void BorderColorProperty::ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("left", leftColor.value_or(Color()).ColorToString().c_str()); + res->Put("right", rightColor.value_or(Color()).ColorToString().c_str()); + res->Put("top", topColor.value_or(Color()).ColorToString().c_str()); + res->Put("bottom", bottomColor.value_or(Color()).ColorToString().c_str()); + + borderJson->Put("color", res); + json->Put("borderColor", res); + } else { + auto left = leftColor.value_or(Color()).ColorToString(); + borderJson->Put("color", left.c_str()); + json->Put("borderColor", left.c_str()); + } +} + +std::string BorderColorProperty::ToString() const +{ + std::string str; + str.append("leftColor: [").append(leftColor.has_value() ? leftColor->ColorToString() : "NA").append("]"); + str.append("rightColor: [").append(rightColor.has_value() ? rightColor->ColorToString() : "NA").append("]"); + str.append("topColor: [").append(topColor.has_value() ? topColor->ColorToString() : "NA").append("]"); + str.append("bottomColor: [").append(bottomColor.has_value() ? bottomColor->ColorToString() : "NA").append("]"); + return str; +} + +void BorderRadiusPropertyT::ToJsonValue( + std::unique_ptr& json, std::unique_ptr& borderJson) const +{ + if (multiValued) { + auto res = JsonUtil::Create(true); + res->Put("topLeft", radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("topRight", radiusTopRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("bottomLeft", radiusBottomLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + res->Put("bottomRight", radiusBottomRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); + + json->Put("borderRadius", res); + borderJson->Put("radius", res); + } else { + auto left = radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString(); + json->Put("borderRadius", left.c_str()); + borderJson->Put("radius", left.c_str()); + } +} + +bool BorderRadiusPropertyT::UpdateWithCheck(const BorderRadiusPropertyT& value) +{ + bool isModified = false; + if (value.radiusTopLeft.has_value() && (radiusTopLeft != value.radiusTopLeft)) { + radiusTopLeft = value.radiusTopLeft; + isModified = true; + } + if (value.radiusTopRight.has_value() && (radiusTopRight != value.radiusTopRight)) { + radiusTopRight = value.radiusTopRight; + isModified = true; + } + if (value.radiusBottomLeft.has_value() && (radiusBottomLeft != value.radiusBottomLeft)) { + radiusBottomLeft = value.radiusBottomLeft; + isModified = true; + } + if (value.radiusBottomRight.has_value() && (radiusBottomRight != value.radiusBottomRight)) { + radiusBottomRight = value.radiusBottomRight; + isModified = true; + } + return isModified; +} + +void BorderStyleProperty::SetBorderStyle(const BorderStyle& borderStyle) +{ + styleLeft = borderStyle; + styleRight = borderStyle; + styleTop = borderStyle; + styleBottom = borderStyle; +} + +bool BorderStyleProperty::operator==(const BorderStyleProperty& value) const +{ + return (styleLeft == value.styleLeft) && (styleRight == value.styleRight) && (styleTop == value.styleTop) && + (styleBottom == value.styleBottom); +} + +void BorderWidthPropertyT::SetBorderWidth(const Dimension& borderWidth) +{ + leftDimen = borderWidth; + rightDimen = borderWidth; + topDimen = borderWidth; + bottomDimen = borderWidth; +} + +bool BorderWidthPropertyT::operator==(const BorderWidthPropertyT& value) const +{ + return (leftDimen == value.leftDimen) && (rightDimen == value.rightDimen) && (topDimen == value.topDimen) && + (bottomDimen == value.bottomDimen); +} + +void BorderRadiusPropertyT::SetRadius(const Dimension& borderRadius) +{ + radiusTopLeft = borderRadius; + radiusTopRight = borderRadius; + radiusBottomLeft = borderRadius; + radiusBottomRight = borderRadius; +} + +bool BorderRadiusPropertyT::operator==(const BorderRadiusPropertyT& value) const +{ + return (radiusTopLeft == value.radiusTopLeft) && (radiusTopRight == value.radiusTopRight) && + (radiusBottomLeft == value.radiusBottomLeft) && (radiusBottomRight == value.radiusBottomRight); +} +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/property/border_property.h b/frameworks/core/components_ng/property/border_property.h index 3a0cc479d6f..83f00032de7 100644 --- a/frameworks/core/components_ng/property/border_property.h +++ b/frameworks/core/components_ng/property/border_property.h @@ -20,7 +20,6 @@ #include "base/geometry/dimension.h" #include "base/json/json_util.h" -#include "base/utils/utils.h" #include "core/components/common/layout/constants.h" #include "core/components/common/properties/color.h" @@ -32,7 +31,6 @@ struct BorderRadiusPropertyT { std::optional radiusTopRight; std::optional radiusBottomRight; std::optional radiusBottomLeft; - std::optional radiusFlag; void SetRadius(const T& borderRadius) { @@ -42,12 +40,6 @@ struct BorderRadiusPropertyT { radiusBottomRight = borderRadius; } - // This function is used when the input value is length - void SetRadiusFlag(bool flag) - { - radiusFlag = flag; - } - bool operator==(const BorderRadiusPropertyT& value) const { return (radiusTopLeft == value.radiusTopLeft) && (radiusTopRight == value.radiusTopRight) && @@ -93,6 +85,23 @@ struct BorderRadiusPropertyT { } }; +template<> +struct BorderRadiusPropertyT { + std::optional radiusTopLeft; + std::optional radiusTopRight; + std::optional radiusBottomRight; + std::optional radiusBottomLeft; + bool multiValued = false; + + bool operator==(const BorderRadiusPropertyT& value) const; + + void SetRadius(const Dimension& borderRadius); + + bool UpdateWithCheck(const BorderRadiusPropertyT& value); + + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; +}; + template<> struct BorderRadiusPropertyT { std::optional radiusTopLeft; @@ -148,14 +157,14 @@ struct BorderRadiusPropertyT { } }; -template -struct BorderColorPropertyT { - std::optional leftColor; - std::optional rightColor; - std::optional topColor; - std::optional bottomColor; +struct BorderColorProperty { + std::optional leftColor; + std::optional rightColor; + std::optional topColor; + std::optional bottomColor; + bool multiValued = false; - void SetColor(const T& borderColor) + void SetColor(const Color& borderColor) { leftColor = borderColor; rightColor = borderColor; @@ -163,21 +172,15 @@ struct BorderColorPropertyT { bottomColor = borderColor; } - bool operator==(const BorderColorPropertyT& value) const + bool operator==(const BorderColorProperty& value) const { return (leftColor == value.leftColor) && (rightColor == value.rightColor) && (topColor == value.topColor) && (bottomColor == value.bottomColor); } - std::string ToString() const - { - std::string str; - str.append("leftColor: [").append(leftColor.has_value() ? leftColor->ToString() : "NA").append("]"); - str.append("rightColor: [").append(rightColor.has_value() ? rightColor->ToString() : "NA").append("]"); - str.append("topColor: [").append(topColor.has_value() ? topColor->ToString() : "NA").append("]"); - str.append("bottomColor: [").append(bottomColor.has_value() ? bottomColor->ToString() : "NA").append("]"); - return str; - } + std::string ToString() const; + + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; }; template @@ -222,21 +225,30 @@ struct BorderWidthPropertyT { } return isModified; } +}; - std::string ToString() const - { - std::string str; - str.append("leftDimen: [").append(leftDimen.has_value() ? leftDimen->ToString() : "NA").append("]"); - str.append("rightDimen: [").append(rightDimen.has_value() ? rightDimen->ToString() : "NA").append("]"); - str.append("topDimen: [").append(topDimen.has_value() ? topDimen->ToString() : "NA").append("]"); - str.append("bottomDimen: [").append(bottomDimen.has_value() ? bottomDimen->ToString() : "NA").append("]"); - return str; - } +template<> +struct BorderWidthPropertyT { + std::optional leftDimen; + std::optional topDimen; + std::optional rightDimen; + std::optional bottomDimen; + bool multiValued = true; + + void SetBorderWidth(const Dimension& borderWidth); + + bool operator==(const BorderWidthPropertyT& value) const; + + bool UpdateWithCheck(const BorderWidthPropertyT& value); void ToJsonValue(std::unique_ptr& json) const { json->Put("borderWidth", leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); } + + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; + + std::string ToString() const; }; template<> @@ -290,44 +302,24 @@ struct BorderWidthPropertyT { } }; -template -struct BorderStylePropertyT { - std::optional styleLeft; - std::optional styleRight; - std::optional styleTop; - std::optional styleBottom; +struct BorderStyleProperty { + std::optional styleLeft; + std::optional styleRight; + std::optional styleTop; + std::optional styleBottom; + bool multiValued = false; - void SetBorderStyle(const T& borderStyle) - { - styleLeft = borderStyle; - styleRight = borderStyle; - styleTop = borderStyle; - styleBottom = borderStyle; - } + void SetBorderStyle(const BorderStyle& borderStyle); - bool operator==(const BorderStylePropertyT& value) const - { - return (styleLeft == value.styleLeft) && (styleRight == value.styleRight) && (styleTop == value.styleTop) && - (styleBottom == value.styleBottom); - } + bool operator==(const BorderStyleProperty& value) const; - std::string ToString() const - { - std::string str; - str.append("styleLeft: [").append(styleLeft.has_value() ? styleLeft->ToString() : "NA").append("]"); - str.append("styleRight: [").append(styleRight.has_value() ? styleRight->ToString() : "NA").append("]"); - str.append("styleTop: [").append(styleTop.has_value() ? styleTop->ToString() : "NA").append("]"); - str.append("styleBottom: [").append(styleBottom.has_value() ? styleBottom->ToString() : "NA").append("]"); - return str; - } + void ToJsonValue(std::unique_ptr& json, std::unique_ptr& borderJson) const; }; using BorderRadiusPropertyF = BorderRadiusPropertyT; using BorderRadiusProperty = BorderRadiusPropertyT; -using BorderColorProperty = BorderColorPropertyT; using BorderWidthPropertyF = BorderWidthPropertyT; using BorderWidthProperty = BorderWidthPropertyT; -using BorderStyleProperty = BorderStylePropertyT; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/render/render_property.h b/frameworks/core/components_ng/render/render_property.h index d24a1781298..842651a00c6 100644 --- a/frameworks/core/components_ng/render/render_property.h +++ b/frameworks/core/components_ng/render/render_property.h @@ -18,14 +18,14 @@ #include "base/geometry/ng/offset_t.h" #include "base/geometry/ng/vector.h" +#include "core/components/common/properties/clip_path.h" #include "core/components/common/properties/color.h" #include "core/components/common/properties/decoration.h" #include "core/components/common/properties/shadow.h" -#include "core/components/common/properties/clip_path.h" #include "core/components_ng/property/border_property.h" +#include "core/components_ng/property/gradient_property.h" #include "core/components_ng/property/overlay_property.h" #include "core/components_ng/property/property.h" -#include "core/components_ng/property/gradient_property.h" #include "core/components_ng/property/transition_property.h" #include "core/image/image_source_info.h" @@ -126,42 +126,13 @@ struct BorderProperty { void ToJsonValue(std::unique_ptr& json) const { - static const char* BORDER_STYLE[] = { - "BorderStyle.Solid", - "BorderStyle.Dashed", - "BorderStyle.Dotted", - }; - json->Put("borderStyle", - BORDER_STYLE[static_cast( - propBorderStyle.value_or(BorderStyleProperty()).styleLeft.value_or(BorderStyle::SOLID))]); - json->Put("borderColor", - propBorderColor.value_or(BorderColorProperty()).leftColor.value_or(Color()).ColorToString().c_str()); auto jsonBorder = JsonUtil::Create(true); - jsonBorder->Put("width", propBorderWidth.value_or(BorderWidthProperty()) - .leftDimen.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonBorder->Put("color", - propBorderColor.value_or(BorderColorProperty()).leftColor.value_or(Color()).ColorToString().c_str()); - jsonBorder->Put("style", - BORDER_STYLE[static_cast( - propBorderStyle.value_or(BorderStyleProperty()).styleLeft.value_or(BorderStyle::SOLID))]); - if (propBorderRadius.value_or(BorderRadiusProperty()).radiusFlag) { - json->Put("borderRadius", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonBorder->Put("radius", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - } else { - auto jsonRadius = JsonUtil::Create(true); - jsonRadius->Put("topLeft", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonRadius->Put("topRight", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusTopRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonRadius->Put("bottomLeft", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusBottomLeft.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - jsonRadius->Put("bottomRight", propBorderRadius.value_or(BorderRadiusProperty()) - .radiusBottomRight.value_or(Dimension(0.0, DimensionUnit::VP)).ToString().c_str()); - json->Put("borderRadius", jsonRadius); - jsonBorder->Put("radius", jsonRadius); - } + + propBorderStyle.value_or(BorderStyleProperty()).ToJsonValue(json, jsonBorder); + propBorderColor.value_or(BorderColorProperty()).ToJsonValue(json, jsonBorder); + propBorderWidth.value_or(BorderWidthProperty()).ToJsonValue(json, jsonBorder); + propBorderRadius.value_or(BorderRadiusProperty()).ToJsonValue(json, jsonBorder); + json->Put("border", jsonBorder->ToString().c_str()); } }; diff --git a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn index 896a602882c..8268b99e63c 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilitynode/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("accessibility_node_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn b/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn index e04123b6cee..0afe19f8758 100644 --- a/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn +++ b/frameworks/core/components_ng/test/accessibility/accessibilityutils/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("accessibility_utils_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/frame_node/BUILD.gn b/frameworks/core/components_ng/test/base/frame_node/BUILD.gn index e5c6c3991dc..50202bb5cb3 100644 --- a/frameworks/core/components_ng/test/base/frame_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/frame_node/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("frame_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn b/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn index 3f3cf6efb73..23931c6903b 100644 --- a/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/geometry_node/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("geometry_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/inspector/BUILD.gn b/frameworks/core/components_ng/test/base/inspector/BUILD.gn index 1d2aab9df67..7828ee40902 100755 --- a/frameworks/core/components_ng/test/base/inspector/BUILD.gn +++ b/frameworks/core/components_ng/test/base/inspector/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("inspector_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/ui_node/BUILD.gn b/frameworks/core/components_ng/test/base/ui_node/BUILD.gn index 8b0970cbaf5..373bb3374c6 100644 --- a/frameworks/core/components_ng/test/base/ui_node/BUILD.gn +++ b/frameworks/core/components_ng/test/base/ui_node/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("ui_node_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn b/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn index 4c19cf43d08..d5992c85f6f 100755 --- a/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_abstract/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("view_abstract_test") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn b/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn index a98950e7370..bb7dbc18f7d 100755 --- a/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_abstract_model/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("view_abstract_model_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn b/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn index 602c29a5887..c90a9b9fa73 100755 --- a/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_full_update_model_ng/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("view_full_update_model_ng_test") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn b/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn index d46645cdccf..af7c127a4da 100644 --- a/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_partial_update_model_ng/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("view_partial_update_model_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn b/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn index 14b88d04455..ce5feff939d 100644 --- a/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn +++ b/frameworks/core/components_ng/test/base/view_stack_processor/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("view_stack_processor_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/event/click_event/BUILD.gn b/frameworks/core/components_ng/test/event/click_event/BUILD.gn index 37ab3fb469c..3d6ed144e9d 100644 --- a/frameworks/core/components_ng/test/event/click_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/click_event/BUILD.gn @@ -38,6 +38,7 @@ ohos_unittest("click_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/drag_event/BUILD.gn b/frameworks/core/components_ng/test/event/drag_event/BUILD.gn index 468de38c3f2..cfce2c1fb98 100644 --- a/frameworks/core/components_ng/test/event/drag_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/drag_event/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("drag_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/event_hub/BUILD.gn index c064d51268e..80ff433f50d 100644 --- a/frameworks/core/components_ng/test/event/event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/event_hub/BUILD.gn @@ -36,6 +36,7 @@ ohos_unittest("event_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn b/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn index 15551a8d95d..3348b04a9a9 100644 --- a/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/focus_hub/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("focus_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn index 4b4a69224a8..5360cc398b7 100644 --- a/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/gesture_event_hub/BUILD.gn @@ -35,6 +35,7 @@ ohos_unittest("gesture_event_hub_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/multi_fingers_recognizer.cpp", "$ace_root/frameworks/core/components_ng/manager/drag_drop/drag_drop_manager.cpp", "$ace_root/frameworks/core/components_ng/manager/drag_drop/drag_drop_proxy.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn b/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn index dae19d3112d..9c08006011d 100644 --- a/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn +++ b/frameworks/core/components_ng/test/event/input_event_hub/BUILD.gn @@ -32,6 +32,7 @@ ohos_unittest("input_event_hub_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn b/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn index d033845f1b7..5fd74698775 100644 --- a/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/long_press_event/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("long_press_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/pan_event/BUILD.gn b/frameworks/core/components_ng/test/event/pan_event/BUILD.gn index c7d7d01792d..f127ca39473 100644 --- a/frameworks/core/components_ng/test/event/pan_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/pan_event/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("pan_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn b/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn index 0868a340371..01ec49d831c 100644 --- a/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/scrollable_event/BUILD.gn @@ -39,6 +39,7 @@ ohos_unittest("scrollable_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/event/touch_event/BUILD.gn b/frameworks/core/components_ng/test/event/touch_event/BUILD.gn index 044473ab349..e3a470f7fc8 100644 --- a/frameworks/core/components_ng/test/event/touch_event/BUILD.gn +++ b/frameworks/core/components_ng/test/event/touch_event/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("touch_event_test_ng") { "$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/recognizers/multi_fingers_recognizer.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/image_provider/BUILD.gn b/frameworks/core/components_ng/test/image_provider/BUILD.gn index 4e5c511cdf8..28aa4ea88d9 100644 --- a/frameworks/core/components_ng/test/image_provider/BUILD.gn +++ b/frameworks/core/components_ng/test/image_provider/BUILD.gn @@ -92,6 +92,7 @@ ohos_unittest("image_provider_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn b/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn index 2730f731d56..b913c0a7df1 100755 --- a/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/box_layout_algorithm/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("box_layout_algorithm_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn index bfeaeb91ba0..56db0446cb4 100755 --- a/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_property/BUILD.gn @@ -56,6 +56,7 @@ ohos_unittest("layout_property_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/syntax/for_each_node.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn index 2941ac20a53..34bec3012cc 100755 --- a/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_wrapper/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("layout_wrapper_test_ng") { "$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/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn b/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn index d7bedcf56ca..cdad88ebf3c 100755 --- a/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn +++ b/frameworks/core/components_ng/test/layout/layout_wrapper_builder/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("layout_wrapper_build_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn b/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn index 5d5426cb73c..0da528ebfcb 100644 --- a/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/manager/shared_overlay/BUILD.gn @@ -41,6 +41,7 @@ ohos_unittest("shared_overlay_manager_test_ng") { "$ace_root/frameworks/core/components_ng/event/touch_event.cpp", "$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_overlay_manager.cpp", "$ace_root/frameworks/core/components_ng/manager/shared_overlay/shared_transition_effect.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn b/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn index 43edc4802c2..54d2baefedb 100644 --- a/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/ability_component/BUILD.gn @@ -60,6 +60,7 @@ ohos_unittest("ability_component_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_layout_algorithm.cpp", "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/ability_component/ability_component_pattern.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp", diff --git a/frameworks/core/components_ng/test/pattern/badge/BUILD.gn b/frameworks/core/components_ng/test/pattern/badge/BUILD.gn index 4d7de6f01ed..3557680dcd6 100644 --- a/frameworks/core/components_ng/test/pattern/badge/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/badge/BUILD.gn @@ -105,6 +105,7 @@ ohos_unittest("badge_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/blank/BUILD.gn b/frameworks/core/components_ng/test/pattern/blank/BUILD.gn index 8fd774609a4..2c86a61b9fb 100644 --- a/frameworks/core/components_ng/test/pattern/blank/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/blank/BUILD.gn @@ -75,6 +75,7 @@ ohos_unittest("blank_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn b/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn index 174be42ac4e..a6ce1f1b62c 100644 --- a/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/bubble/BUILD.gn @@ -106,6 +106,7 @@ ohos_unittest("bubble_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/button/BUILD.gn b/frameworks/core/components_ng/test/pattern/button/BUILD.gn index 28a865bc630..7631dc37737 100644 --- a/frameworks/core/components_ng/test/pattern/button/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/button/BUILD.gn @@ -93,6 +93,7 @@ ohos_unittest("button_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn b/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn index 8e905b0b0bf..97fb83faca0 100644 --- a/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/calendar/BUILD.gn @@ -114,6 +114,7 @@ ohos_unittest("calendar_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn b/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn index 353bc611df1..876a3f2c58b 100644 --- a/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/checkbox/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("checkbox_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn b/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn index 84f7996da19..0b6fb270b45 100644 --- a/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/checkboxgroup/BUILD.gn @@ -54,6 +54,7 @@ ohos_unittest("checkboxgroup_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn b/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn index 0364b7c1490..28f2756d462 100644 --- a/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/container_modal/BUILD.gn @@ -113,6 +113,7 @@ ohos_unittest("container_modal_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/counter/BUILD.gn b/frameworks/core/components_ng/test/pattern/counter/BUILD.gn index 29293849e46..ff15f06ca78 100644 --- a/frameworks/core/components_ng/test/pattern/counter/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/counter/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("counter_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn b/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn index dfd9a527a89..f95f600e29b 100644 --- a/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/custom_dialog/BUILD.gn @@ -80,6 +80,7 @@ ohos_unittest("custom_dialog_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_overlay_modifier.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn b/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn index 55e0c386c56..762b0c039bf 100644 --- a/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/data_panel/BUILD.gn @@ -78,6 +78,7 @@ ohos_unittest("data_panel_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/divider/BUILD.gn b/frameworks/core/components_ng/test/pattern/divider/BUILD.gn index c4669a5c47a..8c2b660bde2 100644 --- a/frameworks/core/components_ng/test/pattern/divider/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/divider/BUILD.gn @@ -72,6 +72,7 @@ ohos_unittest("divider_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/flex/BUILD.gn b/frameworks/core/components_ng/test/pattern/flex/BUILD.gn index 80bab974069..d0c0234ae64 100644 --- a/frameworks/core/components_ng/test/pattern/flex/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/flex/BUILD.gn @@ -65,6 +65,7 @@ ohos_unittest("flex_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/form/BUILD.gn b/frameworks/core/components_ng/test/pattern/form/BUILD.gn index 68c036bd506..09faaf2341e 100644 --- a/frameworks/core/components_ng/test/pattern/form/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/form/BUILD.gn @@ -84,6 +84,7 @@ ohos_unittest("form_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn b/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn index 86bfaf260db..a0d8cf63015 100644 --- a/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/gauge/BUILD.gn @@ -74,6 +74,7 @@ ohos_unittest("gauge_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid/BUILD.gn index 821d60490e2..c9d5d868620 100644 --- a/frameworks/core/components_ng/test/pattern/grid/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid/BUILD.gn @@ -137,6 +137,7 @@ ohos_unittest("grid_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn index 2b1075cd6f4..1e73410d553 100644 --- a/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid_col/BUILD.gn @@ -71,6 +71,7 @@ ohos_unittest("grid_col_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn b/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn index 9090277fe0b..53102aeca1d 100644 --- a/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/grid_row/BUILD.gn @@ -101,6 +101,7 @@ ohos_unittest("grid_row_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn b/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn index 3c6af90484a..ca46d0fcaa8 100644 --- a/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/hyperlink/BUILD.gn @@ -88,6 +88,7 @@ ohos_unittest("hyperlink_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/image/BUILD.gn b/frameworks/core/components_ng/test/pattern/image/BUILD.gn index be445e50a6e..517760f9164 100644 --- a/frameworks/core/components_ng/test/pattern/image/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/image/BUILD.gn @@ -95,6 +95,7 @@ ohos_unittest("image_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn b/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn index 3f5185a22c1..3a7fcfec11f 100644 --- a/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/indexer/BUILD.gn @@ -143,6 +143,7 @@ ohos_unittest("indexer_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn b/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn index dabc0ad5c58..f051bbf1cd2 100644 --- a/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/linear_layout/BUILD.gn @@ -49,6 +49,7 @@ ohos_unittest("linear_layout_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn b/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn index 307f663f4da..85d3be605c2 100644 --- a/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/linear_split/BUILD.gn @@ -81,6 +81,7 @@ ohos_unittest("linear_split_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/list/BUILD.gn b/frameworks/core/components_ng/test/pattern/list/BUILD.gn index 782d907b53d..c394020d2fe 100644 --- a/frameworks/core/components_ng/test/pattern/list/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/list/BUILD.gn @@ -57,6 +57,7 @@ common_sources = [ # components_ng_property "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn index bbea2e95341..f0eaf324e1c 100644 --- a/frameworks/core/components_ng/test/pattern/menu/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/menu/BUILD.gn @@ -162,6 +162,7 @@ ohos_unittest("menu_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn b/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn index cb95b4042b6..85ded65aaf0 100755 --- a/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/navigation/BUILD.gn @@ -108,6 +108,7 @@ ohos_unittest("navigation_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_paint_method.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn index 063892619bf..78b3a96393e 100644 --- a/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/overlay/BUILD.gn @@ -129,6 +129,7 @@ ohos_unittest("overlay_manager_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn b/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn index a78b43380b8..b123922864a 100644 --- a/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/patternlock/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("patternlock_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/picker/BUILD.gn b/frameworks/core/components_ng/test/pattern/picker/BUILD.gn index f7cd5948f72..de6bf73e400 100644 --- a/frameworks/core/components_ng/test/pattern/picker/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/picker/BUILD.gn @@ -133,6 +133,7 @@ ohos_unittest("picker_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/time_picker/timepicker_row_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/time_picker/toss_animation_controller.cpp", "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn b/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn index f4e01e83d9e..19470a3edb4 100644 --- a/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/plugin/BUILD.gn @@ -86,6 +86,7 @@ ohos_unittest("plugin_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn b/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn index 5bd21a7741d..a9dd54698a5 100644 --- a/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/qrcode/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("qrcode_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/radio/BUILD.gn b/frameworks/core/components_ng/test/pattern/radio/BUILD.gn index 844d1b7d9b7..2e3cc4cc53b 100644 --- a/frameworks/core/components_ng/test/pattern/radio/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/radio/BUILD.gn @@ -53,6 +53,7 @@ ohos_unittest("radio_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/rating/BUILD.gn b/frameworks/core/components_ng/test/pattern/rating/BUILD.gn index 144a69f0842..e33f41f3eb1 100644 --- a/frameworks/core/components_ng/test/pattern/rating/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/rating/BUILD.gn @@ -68,6 +68,7 @@ ohos_unittest("rating_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn b/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn index 02518b0fcc2..f03d313af9a 100644 --- a/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/refresh/BUILD.gn @@ -84,6 +84,7 @@ ohos_unittest("refresh_pattern_test_ng") { # components_ng_property "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn b/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn index 18eeddcc7eb..c5ae2ae58c9 100644 --- a/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/scroll/BUILD.gn @@ -114,6 +114,7 @@ ohos_unittest("scroll_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/search/BUILD.gn b/frameworks/core/components_ng/test/pattern/search/BUILD.gn index a9a06921949..c797186bae6 100644 --- a/frameworks/core/components_ng/test/pattern/search/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/search/BUILD.gn @@ -110,6 +110,7 @@ ohos_unittest("search_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn b/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn index 37fb291fdad..faf0e758c89 100644 --- a/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/security_component/BUILD.gn @@ -94,6 +94,7 @@ ohos_unittest("security_component_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select/BUILD.gn b/frameworks/core/components_ng/test/pattern/select/BUILD.gn index 2d41be645f7..271671555af 100644 --- a/frameworks/core/components_ng/test/pattern/select/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select/BUILD.gn @@ -69,6 +69,7 @@ ohos_unittest("select_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", diff --git a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn index 317cfee4e5c..43d21668e27 100644 --- a/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/select_overlay/BUILD.gn @@ -155,6 +155,7 @@ ohos_unittest("select_overlay_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn b/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn index 573e5b641e2..f776020a375 100644 --- a/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/side_bar/BUILD.gn @@ -111,6 +111,7 @@ ohos_unittest("side_bar_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn b/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn index 5cc4e75c758..d75e7dfb821 100644 --- a/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/stepper/BUILD.gn @@ -166,6 +166,7 @@ ohos_unittest("stepper_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn b/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn index 133b3f464a6..fd8d74ab50d 100644 --- a/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/swiper/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("swiper_indicator_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn b/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn index 32a6fc42bd5..44250278f94 100644 --- a/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/tabs/BUILD.gn @@ -137,6 +137,7 @@ ohos_unittest("tabs_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text/BUILD.gn b/frameworks/core/components_ng/test/pattern/text/BUILD.gn index dfbb773288e..693972d09b2 100644 --- a/frameworks/core/components_ng/test/pattern/text/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text/BUILD.gn @@ -106,6 +106,7 @@ ohos_unittest("text_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text/text_pattern.cpp", "$ace_root/frameworks/core/components_ng/pattern/text/text_styles.cpp", "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn b/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn index c0f45454ed8..31711546a65 100644 --- a/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/text_clock/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("text_clock_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_layout_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/text_clock/text_clock_pattern.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/render_context.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn index 5d0b68a90d5..8ad233e66e4 100644 --- a/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/textfield/BUILD.gn @@ -170,6 +170,7 @@ ohos_unittest("textfield_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn b/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn index fdc43218e97..9ae7eac712d 100644 --- a/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/texttimer/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("text_timer_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_layout_property.cpp", "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp", "$ace_root/frameworks/core/components_ng/pattern/texttimer/text_timer_pattern.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "$ace_root/frameworks/core/components_ng/render/render_context.cpp", "$ace_root/frameworks/core/components_v2/inspector/inspector_constants.cpp", diff --git a/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn b/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn index 823ac50781c..8d904df1b1b 100644 --- a/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/toggle/BUILD.gn @@ -58,6 +58,7 @@ ohos_unittest("toggle_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/layout/layout_wrapper_builder.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/video/BUILD.gn b/frameworks/core/components_ng/test/pattern/video/BUILD.gn index 993261ae0e7..25886f29c4c 100644 --- a/frameworks/core/components_ng/test/pattern/video/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/video/BUILD.gn @@ -144,6 +144,7 @@ ohos_unittest("video_pattern_test_ng") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn b/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn index bafe03b6772..4e68d2caba5 100644 --- a/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn +++ b/frameworks/core/components_ng/test/pattern/xcomponent/BUILD.gn @@ -78,6 +78,7 @@ ohos_unittest("xcomponent_pattern_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/accessibility/BUILD.gn b/frameworks/core/components_ng/test/property/accessibility/BUILD.gn index 67904e96578..175786000c9 100644 --- a/frameworks/core/components_ng/test/property/accessibility/BUILD.gn +++ b/frameworks/core/components_ng/test/property/accessibility/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("accessibility_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/calc_length/BUILD.gn b/frameworks/core/components_ng/test/property/calc_length/BUILD.gn index 1beb1023736..83957eb8b30 100644 --- a/frameworks/core/components_ng/test/property/calc_length/BUILD.gn +++ b/frameworks/core/components_ng/test/property/calc_length/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("calc_length_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/gradient/BUILD.gn b/frameworks/core/components_ng/test/property/gradient/BUILD.gn index 3590c7d47d8..b714a01207c 100644 --- a/frameworks/core/components_ng/test/property/gradient/BUILD.gn +++ b/frameworks/core/components_ng/test/property/gradient/BUILD.gn @@ -63,6 +63,7 @@ ohos_unittest("gradient_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/grid_property/BUILD.gn b/frameworks/core/components_ng/test/property/grid_property/BUILD.gn index 871d50e1456..21e8ba2e8b7 100755 --- a/frameworks/core/components_ng/test/property/grid_property/BUILD.gn +++ b/frameworks/core/components_ng/test/property/grid_property/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("grid_property_test_ng") { "$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/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn index 5bd838bb369..e2f15d639dd 100755 --- a/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn +++ b/frameworks/core/components_ng/test/property/measure_utils/BUILD.gn @@ -22,6 +22,7 @@ ohos_unittest("measure_utils_test_ng") { "$ace_root/frameworks/core/components/common/properties/color.cpp", # components_ng + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/property/property_test/BUILD.gn b/frameworks/core/components_ng/test/property/property_test/BUILD.gn index 8b2eae73d67..ea143c8c4c6 100755 --- a/frameworks/core/components_ng/test/property/property_test/BUILD.gn +++ b/frameworks/core/components_ng/test/property/property_test/BUILD.gn @@ -18,6 +18,7 @@ ohos_unittest("property_test_ng") { module_out_path = property_test_output_path sources = [ + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/property.cpp", "property_test_ng.cpp", ] diff --git a/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn b/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn index d067e2e3b27..4af8f263b96 100644 --- a/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/for_each/BUILD.gn @@ -85,6 +85,7 @@ ohos_unittest("for_each_syntax_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn b/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn index 4e9a5b4b5c7..2d1eeeae255 100644 --- a/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/if_else/BUILD.gn @@ -80,6 +80,7 @@ ohos_unittest("if_else_syntax_test_ng") { "$ace_root/frameworks/core/components_ng/gestures/recognizers/recognizer_group.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn b/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn index f581b605a59..7367e94aee4 100644 --- a/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn +++ b/frameworks/core/components_ng/test/syntax/lazy_for_each/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("lazy_for_each_syntax_test_ng") { "$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/grid_container/grid_container_layout_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 43b6d912f3c..3da06a0a267 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -189,6 +189,7 @@ ohos_source_set("ace_components_property") { part_name = ace_engine_part sources = [ "$ace_root/frameworks/core/components_ng/property/accessibility_property.cpp", + "$ace_root/frameworks/core/components_ng/property/border_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", diff --git a/test/unittest/core/pattern/window_scene/BUILD.gn b/test/unittest/core/pattern/window_scene/BUILD.gn index d3c0a831561..4ce5606faea 100755 --- a/test/unittest/core/pattern/window_scene/BUILD.gn +++ b/test/unittest/core/pattern/window_scene/BUILD.gn @@ -91,6 +91,7 @@ ohos_unittest("window_scene_test") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock_icon_theme.cpp", # components_ng_property + "$ace_root/frameworks/core/components_ng/property/border_property.cpp", "$ace_root/frameworks/core/components_ng/property/calc_length.cpp", "$ace_root/frameworks/core/components_ng/property/grid_property.cpp", "$ace_root/frameworks/core/components_ng/property/measure_utils.cpp", diff --git a/test/unittest/core/pipeline/BUILD.gn b/test/unittest/core/pipeline/BUILD.gn index 1bf80da74fd..4ae2ac6257c 100644 --- a/test/unittest/core/pipeline/BUILD.gn +++ b/test/unittest/core/pipeline/BUILD.gn @@ -202,6 +202,7 @@ ohos_unittest("pipeline_context_test_ng") { "$ace_root/frameworks/core/components_ng/test/pattern/image/mock/mock_image_pattern.cpp", # property + "$ace_root/frameworks/core/components_ng/property/border_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", diff --git a/test/unittest/core/render/render_context/BUILD.gn b/test/unittest/core/render/render_context/BUILD.gn index 5896a0c8985..412bfb65d22 100755 --- a/test/unittest/core/render/render_context/BUILD.gn +++ b/test/unittest/core/render/render_context/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("render_context_test_ng") { "$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/border_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", From 99d4dc1322a276b449f62bb1fb081ff247445c6a Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 24 May 2023 12:05:38 +0000 Subject: [PATCH 83/99] fix the comment of review Signed-off-by: limeng --- .../pattern/custom_paint/custom_paint_paint_method.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp index 37911ea7dcf..6349c780a44 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp @@ -573,10 +573,6 @@ void CustomPaintPaintMethod::StrokeRect(PaintWrapper* paintWrapper, const Rect& GetStrokePaint(paint, options); #endif paint.setAntiAlias(antiAlias_); - if (strokeState_.GetPaintStyle() == PaintStyle::Color) { - paint.setColor(strokeState_.GetColor().GetValue()); - } - paint.setStyle(SkPaint::Style::kStroke_Style); SkRect skRect = SkRect::MakeLTRB(rect.Left() + offset.GetX(), rect.Top() + offset.GetY(), rect.Right() + offset.GetX(), offset.GetY() + rect.Bottom()); if (HasShadow()) { From f782f0c42175db07987007d583b46401cf391af5 Mon Sep 17 00:00:00 2001 From: yeyinglong Date: Wed, 24 May 2023 20:22:40 +0800 Subject: [PATCH 84/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dblur=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E5=92=8Cinspector=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yeyinglong --- .../bridge/declarative_frontend/jsview/js_view_abstract.cpp | 4 ++-- frameworks/core/components_ng/render/render_property.cpp | 5 ++--- frameworks/core/components_ng/render/render_property.h | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp index 9a8597d4fe9..ac76ec94732 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_view_abstract.cpp @@ -5207,7 +5207,7 @@ void JSViewAbstract::SetPaddingRight(const JSCallbackInfo& info) void JSViewAbstract::SetBlur(float radius) { - CalcDimension dimensionRadius(radius, DimensionUnit::PX); + CalcDimension dimensionRadius(radius, DimensionUnit::VP); ViewAbstractModel::GetInstance()->SetFrontBlur(dimensionRadius); } @@ -5218,7 +5218,7 @@ void JSViewAbstract::SetColorBlend(Color color) void JSViewAbstract::SetBackdropBlur(float radius) { - CalcDimension dimensionRadius(radius, DimensionUnit::PX); + CalcDimension dimensionRadius(radius, DimensionUnit::VP); ViewAbstractModel::GetInstance()->SetBackdropBlur(dimensionRadius); } diff --git a/frameworks/core/components_ng/render/render_property.cpp b/frameworks/core/components_ng/render/render_property.cpp index bfe83a2e2d7..43781de66af 100644 --- a/frameworks/core/components_ng/render/render_property.cpp +++ b/frameworks/core/components_ng/render/render_property.cpp @@ -75,7 +75,6 @@ void RenderPositionProperty::ToJsonValue(std::unique_ptr& json) const void GraphicsProperty::ToJsonValue(std::unique_ptr& json) const { - json->Put("blur", round(propFrontBlurRadius.value_or(0.0_vp).Value() * 100) / 100); json->Put("grayscale", propFrontGrayScale.has_value() ? propFrontGrayScale->Value() : 0.0); json->Put("brightness", propFrontBrightness.has_value() ? propFrontBrightness->Value() : 1.0); json->Put("saturate", propFrontSaturate.has_value() ? propFrontSaturate->Value() : 1.0); @@ -129,12 +128,12 @@ void BackgroundProperty::ToJsonValue(std::unique_ptr& json) const jsonValue->Put("y", 0.0); json->Put("backgroundImagePosition", jsonValue); } - json->Put("backdropBlur", (propBlurRadius.value_or(Dimension(0))).ConvertToPx()); + json->Put("backdropBlur", (propBlurRadius.value_or(Dimension(0))).ConvertToVp()); } void ForegroundProperty::ToJsonValue(std::unique_ptr& json) const { - json->Put("frontBlur", (propBlurRadius.value_or(Dimension(0))).ConvertToPx()); + json->Put("blur", (propBlurRadius.value_or(Dimension(0))).ConvertToVp()); } void ClipProperty::ToJsonValue(std::unique_ptr& json) const diff --git a/frameworks/core/components_ng/render/render_property.h b/frameworks/core/components_ng/render/render_property.h index d24a1781298..b900f4b91c3 100644 --- a/frameworks/core/components_ng/render/render_property.h +++ b/frameworks/core/components_ng/render/render_property.h @@ -183,7 +183,6 @@ struct GraphicsProperty { ACE_DEFINE_PROPERTY_GROUP_ITEM(FrontInvert, Dimension); ACE_DEFINE_PROPERTY_GROUP_ITEM(FrontHueRotate, float); ACE_DEFINE_PROPERTY_GROUP_ITEM(FrontColorBlend, Color); - ACE_DEFINE_PROPERTY_GROUP_ITEM(FrontBlurRadius, Dimension); ACE_DEFINE_PROPERTY_GROUP_ITEM(BackShadow, Shadow); void ToJsonValue(std::unique_ptr& json) const; }; From f7ef74c0a8b7f7b0d7a7827589d56bfa358929a9 Mon Sep 17 00:00:00 2001 From: lihao Date: Wed, 24 May 2023 18:08:00 +0800 Subject: [PATCH 85/99] Preview not show appbar when component Mode Signed-off-by: lihao Change-Id: Ibae9848d1a2023697c4d1825629e7a8ba3fd0bc6 --- adapter/preview/entrance/ace_container.cpp | 5 +++-- adapter/preview/entrance/ace_container.h | 1 + adapter/preview/entrance/ace_run_args.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/adapter/preview/entrance/ace_container.cpp b/adapter/preview/entrance/ace_container.cpp index d7619097011..1a1c3aa8640 100644 --- a/adapter/preview/entrance/ace_container.cpp +++ b/adapter/preview/entrance/ace_container.cpp @@ -72,7 +72,7 @@ const char LOCALE_KEY[] = "locale"; } // namespace std::once_flag AceContainer::onceFlag_; - +bool AceContainer::isComponentMode_ = false; AceContainer::AceContainer(int32_t instanceId, FrontendType type, RefPtr context, bool useCurrentEventRunner) : instanceId_(instanceId), messageBridge_(AceType::MakeRefPtr()), type_(type), context_(context) { @@ -939,7 +939,7 @@ void AceContainer::AttachView(std::unique_ptr window, AceViewPreview* vi pipelineContext_->SetWindowModal(windowModal_); pipelineContext_->SetDrawDelegate(aceView_->GetDrawDelegate()); pipelineContext_->SetIsJsCard(type_ == FrontendType::JS_CARD); - if (installationFree_) { + if (installationFree_ && !isComponentMode_) { LOGD("installationFree:%{public}d, labelId:%{public}d", installationFree_, labelId_); pipelineContext_->SetInstallationFree(installationFree_); pipelineContext_->SetAppLabelId(labelId_); @@ -1033,6 +1033,7 @@ void AceContainer::InitDeviceInfo(int32_t instanceId, const AceRunArgs& runArgs) config.SetColorMode(runArgs.deviceConfig.colorMode); config.SetFontRatio(runArgs.deviceConfig.fontRatio); container->SetResourceConfiguration(config); + isComponentMode_ = runArgs.isComponentMode; } RefPtr AceContainer::GetContainerInstance(int32_t instanceId) diff --git a/adapter/preview/entrance/ace_container.h b/adapter/preview/entrance/ace_container.h index 614d577db4c..4667ae39f4b 100644 --- a/adapter/preview/entrance/ace_container.h +++ b/adapter/preview/entrance/ace_container.h @@ -287,6 +287,7 @@ private: // app bar to use bool installationFree_ = false; int32_t labelId_; + static bool isComponentMode_; ACE_DISALLOW_COPY_AND_MOVE(AceContainer); }; diff --git a/adapter/preview/entrance/ace_run_args.h b/adapter/preview/entrance/ace_run_args.h index eadd5f5f47e..e0167057cb5 100644 --- a/adapter/preview/entrance/ace_run_args.h +++ b/adapter/preview/entrance/ace_run_args.h @@ -92,6 +92,7 @@ struct ACE_FORCE_EXPORT_WITH_PREVIEW AceRunArgs { // Container sdk path. std::string containerSdkPath = ""; + bool isComponentMode = false; }; } // namespace OHOS::Ace::Platform From 16fb9ac06696466ef845f02e54d5739bf5bdc2b1 Mon Sep 17 00:00:00 2001 From: zhangbingce Date: Tue, 23 May 2023 22:05:07 +0800 Subject: [PATCH 86/99] =?UTF-8?q?[canvas]fillstyle=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=80=BC=E5=A4=84=E7=90=86&&=E9=80=8F=E6=98=8E=E5=BA=A6?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangbingce Change-Id: I496daeae89713cf1fa0b161070af154511109893 --- .../jsview/js_canvas_renderer.cpp | 7 ++++--- .../custom_paint/custom_paint_paint_method.cpp | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp index 8f16d80c826..8c474003be0 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp @@ -663,9 +663,10 @@ void JSCanvasRenderer::JsSetFillStyle(const JSCallbackInfo& info) return; } if (info[0]->IsString()) { - std::string colorStr = ""; - JSViewAbstract::ParseJsString(info[0], colorStr); - auto color = Color::FromString(colorStr); + Color color; + if (!JSViewAbstract::CheckColor(info[0], color, "CanvasRenderer", "fillStyle")) { + return; + } if (Container::IsCurrentUseNewPipeline()) { if (isOffscreen_ && offscreenCanvasPattern_) { diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp index f7e0b98a4d4..db15bedf0b8 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp @@ -528,7 +528,9 @@ void CustomPaintPaintMethod::FillRect(PaintWrapper* paintWrapper, const Rect& re InitImagePaint(paint, options); #endif paint.setAntiAlias(antiAlias_); - paint.setColor(fillState_.GetColor().GetValue()); + if (fillState_.GetPaintStyle() == OHOS::Ace::PaintStyle::Color) { + paint.setColor(fillState_.GetColor().GetValue()); + } paint.setStyle(SkPaint::Style::kFill_Style); SkRect skRect = SkRect::MakeLTRB(rect.Left() + offset.GetX(), rect.Top() + offset.GetY(), rect.Right() + offset.GetX(), offset.GetY() + rect.Bottom()); @@ -660,7 +662,9 @@ void CustomPaintPaintMethod::Fill(PaintWrapper* paintWrapper) InitImagePaint(paint, options); #endif paint.setAntiAlias(antiAlias_); - paint.setColor(fillState_.GetColor().GetValue()); + if (fillState_.GetPaintStyle() == OHOS::Ace::PaintStyle::Color) { + paint.setColor(fillState_.GetColor().GetValue()); + } paint.setStyle(SkPaint::Style::kFill_Style); if (HasShadow()) { PaintShadow(skPath_, shadow_, skCanvas_.get()); @@ -707,7 +711,9 @@ void CustomPaintPaintMethod::Path2DFill(const OffsetF& offset) InitImagePaint(paint, options); #endif paint.setAntiAlias(antiAlias_); - paint.setColor(fillState_.GetColor().GetValue()); + if (fillState_.GetPaintStyle() == OHOS::Ace::PaintStyle::Color) { + paint.setColor(fillState_.GetColor().GetValue()); + } paint.setStyle(SkPaint::Style::kFill_Style); if (HasShadow()) { PaintShadow(skPath2d_, shadow_, skCanvas_.get()); From 5c170207631aa29c5ba5c00d11d63419146f5af7 Mon Sep 17 00:00:00 2001 From: luoying_ace_admin Date: Wed, 24 May 2023 19:22:55 +0800 Subject: [PATCH 87/99] picker bugfix Signed-off-by: luoying_ace_admin Change-Id: Iffefe532a7f5505f587cb9c226e83dd01a8b1ae2 --- .../text_picker/textpicker_column_pattern.cpp | 5 ----- .../pattern/text_picker/textpicker_dialog_view.cpp | 9 +-------- .../text_picker/textpicker_layout_algorithm.cpp | 13 +++++++++---- .../pattern/text_picker/textpicker_model_ng.cpp | 8 -------- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp index 414784303bc..cf64bb9d1fd 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp @@ -32,7 +32,6 @@ namespace OHOS::Ace::NG { namespace { -const uint32_t OPTION_COUNT_PHONE_LANDSCAPE = 3; const Dimension FONT_SIZE = Dimension(2.0); const int32_t ANIMATION_ZERO_TO_OUTER = 200; // 200ms for animation that from zero to outer. const int32_t ANIMATION_OUTER_TO_ZERO = 150; // 150ms for animation that from outer to zero. @@ -252,10 +251,6 @@ uint32_t TextPickerColumnPattern::GetShowOptionCount() const auto pickerTheme = context->GetTheme(); CHECK_NULL_RETURN(pickerTheme, 0); auto showCount = pickerTheme->GetShowOptionCount(); - if (SystemProperties::GetDeviceType() == DeviceType::PHONE && - SystemProperties::GetDeviceOrientation() == DeviceOrientation::LANDSCAPE) { - showCount = OPTION_COUNT_PHONE_LANDSCAPE; - } return showCount; } diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_dialog_view.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_dialog_view.cpp index b8f5746181a..1d300bc8eee 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_dialog_view.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_dialog_view.cpp @@ -33,9 +33,6 @@ #include "core/components_ng/base/view_abstract_model.h" namespace OHOS::Ace::NG { -namespace { -const uint32_t OPTION_COUNT_PHONE_LANDSCAPE = 3; -} // namespace RefPtr TextPickerDialogView::Show(const DialogProperties& dialogProperties, const TextPickerSettingData& settingData, @@ -74,10 +71,6 @@ RefPtr TextPickerDialogView::RangeShow(const DialogProperties& dialog CalcSize(NG::CalcLength(Dimension(1.0, DimensionUnit::PERCENT)), std::nullopt)); pickerNodeLayout->UpdateCanLoop(settingData.canLoop); uint32_t showCount = pickerTheme->GetShowOptionCount(); - if (SystemProperties::GetDeviceType() == DeviceType::PHONE && - SystemProperties::GetDeviceOrientation() == DeviceOrientation::LANDSCAPE) { - showCount = OPTION_COUNT_PHONE_LANDSCAPE; - } OptionsCreateNode(textPickerPattern, settingData, textPickerNode, showCount, 1, pickerTheme); SetDefaultPickerItemHeight(settingData.height); SetTextProperties(pickerTheme, settingData.properties); @@ -569,4 +562,4 @@ void TextPickerDialogView::SetDialogAcceptEvent(const RefPtr& frameNo eventHub->SetDialogAcceptEvent(std::move(onChange)); } -} // namespace OHOS::Ace::NG \ No newline at end of file +} // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_algorithm.cpp index fbdd065839c..b74d886fce5 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_algorithm.cpp @@ -24,10 +24,9 @@ namespace OHOS::Ace::NG { namespace { const int32_t DIVIDER_SIZE = 2; -const int32_t TEXT_PICKER_CHILD_SIZE = 5; +const int32_t OPTION_COUNT_PHONE_LANDSCAPE = 3; const float PICKER_HEIGHT_HALF = 2.5f; const float ITEM_HEIGHT_HALF = 2.0f; -const int32_t TEXT_PICKER_GRADIENT_CHILD_SIZE = 4; const int32_t MAX_HALF_DISPLAY_COUNT = 2; } // namespace void TextPickerLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) @@ -55,11 +54,17 @@ void TextPickerLayoutAlgorithm::Measure(LayoutWrapper* layoutWrapper) } } + uint32_t showCount_ = pickerTheme->GetShowOptionCount(); + if (SystemProperties::GetDeviceType() == DeviceType::PHONE && + SystemProperties::GetDeviceOrientation() == DeviceOrientation::LANDSCAPE) { + showCount_ = OPTION_COUNT_PHONE_LANDSCAPE; + } + if (isDefaultPickerItemHeight_) { - pickerHeight = static_cast(defaultPickerItemHeight_ * TEXT_PICKER_CHILD_SIZE); + pickerHeight = static_cast(defaultPickerItemHeight_ * showCount_); } else { pickerHeight = - static_cast(pickerTheme->GetGradientHeight().ConvertToPx() * TEXT_PICKER_GRADIENT_CHILD_SIZE + + static_cast(pickerTheme->GetGradientHeight().ConvertToPx() * (showCount_ - 1) + pickerTheme->GetDividerSpacing().ConvertToPx()); } diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp index 8b688275022..7d491c1ad56 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp @@ -33,10 +33,6 @@ #include "core/pipeline_ng/pipeline_context.h" namespace OHOS::Ace::NG { -namespace { -const uint32_t OPTION_COUNT_PHONE_LANDSCAPE = 3; -} // namespace - void TextPickerModelNG::Create(RefPtr pickerTheme, uint32_t columnKind) { auto* stack = ViewStackProcessor::GetInstance(); @@ -49,10 +45,6 @@ void TextPickerModelNG::Create(RefPtr pickerTheme, uint32_t columnK CHECK_NULL_VOID(pickerTheme); uint32_t showCount = pickerTheme->GetShowOptionCount(); - if (SystemProperties::GetDeviceType() == DeviceType::PHONE && - SystemProperties::GetDeviceOrientation() == DeviceOrientation::LANDSCAPE) { - showCount = OPTION_COUNT_PHONE_LANDSCAPE; - } if (textPickerNode->GetChildren().empty()) { auto columnNode = CreateColumnNode(columnKind, showCount); From 249056d498c3daed01fec12e28300b9ca6996333 Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 24 May 2023 21:25:34 +0800 Subject: [PATCH 88/99] fix the problem of review Signed-off-by: limeng --- .../bridge/declarative_frontend/jsview/js_canvas_renderer.cpp | 4 ++-- .../pattern/custom_paint/canvas_paint_method.cpp | 4 ++-- .../pattern/custom_paint/custom_paint_paint_method.cpp | 4 ++-- .../pattern/custom_paint/offscreen_canvas_paint_method.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp index cc23661ffa9..39f7fd95f5c 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp @@ -288,7 +288,7 @@ void JSCanvasRenderer::JsFillText(const JSCallbackInfo& info) y = SystemProperties::Vp2Px(y); std::optional maxWidth; if (info.Length() >= 4) { - double width = 0; + double width = 0.0; if (info[3]->IsUndefined()) { width = FLT_MAX; } else if (info[3]->IsNumber()) { @@ -335,7 +335,7 @@ void JSCanvasRenderer::JsStrokeText(const JSCallbackInfo& info) y = SystemProperties::Vp2Px(y); std::optional maxWidth; if (info.Length() >= 4 && info[3]->IsNumber()) { - double width = 0; + double width = 0.0; if (info[3]->IsUndefined()) { width = FLT_MAX; } else if (info[3]->IsNumber()) { diff --git a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp index 6bfc9e7fc62..36acd4c4b33 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/canvas_paint_method.cpp @@ -484,7 +484,7 @@ void CanvasPaintMethod::PaintText(const OffsetF& offset, const SizeF& frameSize, dx /= scale.value(); shadowOffsetX /= scale.value(); } - skCanvas_->scale(scale.value(), 1); + skCanvas_->scale(scale.value(), 1.0); } paragraph_->Paint(skCanvas_.get(), dx + shadowOffsetX, dy + shadowOffsetY); skCanvas_->restore(); @@ -495,7 +495,7 @@ void CanvasPaintMethod::PaintText(const OffsetF& offset, const SizeF& frameSize, dx /= scale.value(); } skCanvas_->save(); - skCanvas_->scale(scale.value(), 1); + skCanvas_->scale(scale.value(), 1.0); paragraph_->Paint(skCanvas_.get(), dx, dy); skCanvas_->restore(); } else { diff --git a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp index 85148060a30..4da1e30ff08 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/custom_paint_paint_method.cpp @@ -1632,7 +1632,7 @@ bool CustomPaintPaintMethod::HasImageShadow() const std::optional CustomPaintPaintMethod::CalcTextScale(double maxIntrinsicWidth, std::optional maxWidth) { std::optional scale; - if (NearEqual(maxIntrinsicWidth, 0) || !maxWidth.has_value()) { + if (NearZero(maxIntrinsicWidth) || !maxWidth.has_value()) { return scale; } if (Negative(maxWidth.value())) { @@ -1648,7 +1648,7 @@ std::optional CustomPaintPaintMethod::CalcTextScale(double maxIntrinsicW TransformParam CustomPaintPaintMethod::GetTransform() const { TransformParam param; - if (skCanvas_.get() != nullptr) { + if (skCanvas_ != nullptr) { SkMatrix matrix = skCanvas_->getTotalMatrix(); param.scaleX = matrix.getScaleX(); param.scaleY = matrix.getScaleY(); diff --git a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp index 62b8b6b3a36..1671fdd9e19 100644 --- a/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp +++ b/frameworks/core/components_ng/pattern/custom_paint/offscreen_canvas_paint_method.cpp @@ -402,7 +402,7 @@ void OffscreenCanvasPaintMethod::PaintText( dx /= scale.value(); shadowOffsetX /= scale.value(); } - skCanvas_->scale(scale.value(), 1); + skCanvas_->scale(scale.value(), 1.0); } paragraph_->Paint(skCanvas_.get(), dx + shadowOffsetX, dy + shadowOffsetY); skCanvas_->restore(); @@ -413,7 +413,7 @@ void OffscreenCanvasPaintMethod::PaintText( dx /= scale.value(); } skCanvas_->save(); - skCanvas_->scale(scale.value(), 1); + skCanvas_->scale(scale.value(), 1.0); paragraph_->Paint(skCanvas_.get(), dx, dy); skCanvas_->restore(); } else { From 66defe5e71ff310bd48f32005e70d912129afee0 Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 24 May 2023 13:26:17 +0000 Subject: [PATCH 89/99] fix the comment of review Signed-off-by: limeng --- .../bridge/declarative_frontend/jsview/js_canvas_renderer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp index 9b7ca2af819..77f3c767e49 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp @@ -769,10 +769,8 @@ void JSCanvasRenderer::JsSetStrokeStyle(const JSCallbackInfo& info) return; } if (info[0]->IsString()) { - static const char componentCanvasRenderer[] = "CanvasRenderer"; - static const char propCanvasRendererStrokeStyle[] = "strokeStyle"; Color color; - if (!JSViewAbstract::CheckColor(info[0], color, componentCanvasRenderer, propCanvasRendererStrokeStyle)) { + if (!JSViewAbstract::CheckColor(info[0], color, "CanvasRenderer", "strokeStyle")) { return; } if (Container::IsCurrentUseNewPipeline()) { From 22f062b994706560c1b3c2b95fa687e27167396f Mon Sep 17 00:00:00 2001 From: jinweiliu Date: Wed, 24 May 2023 13:32:18 +0000 Subject: [PATCH 90/99] fix video Signed-off-by: jinweiliu Change-Id: Ic494b2858d40a5fdd75c580fa3c0727ca427da3c --- .../core/components/video/media_player_callback.h | 11 ++++++----- .../components_ng/pattern/video/video_pattern.cpp | 13 +------------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/frameworks/core/components/video/media_player_callback.h b/frameworks/core/components/video/media_player_callback.h index c15bc4bdc5e..50c516ceec6 100644 --- a/frameworks/core/components/video/media_player_callback.h +++ b/frameworks/core/components/video/media_player_callback.h @@ -92,37 +92,38 @@ public: ContainerScope scope(instanceId_); switch (type) { case OHOS::Media::INFO_TYPE_SEEKDONE: - LOGI("video OnSeekDone callback"); + LOGD("video OnSeekDone callback"); if (positionUpdatedEvent_) { positionUpdatedEvent_(extra / MILLISECONDS_TO_SECONDS); } break; case OHOS::Media::INFO_TYPE_EOS: - LOGI("video OnEndOfStream callback"); + LOGD("video OnEndOfStream callback"); if (endOfStreamEvent_) { endOfStreamEvent_(); } break; case OHOS::Media::INFO_TYPE_STATE_CHANGE: - LOGI("video OnStateChanged callback"); + LOGD("video OnStateChanged callback"); PrintState(static_cast(extra)); if (stateChangedEvent_) { stateChangedEvent_(ConvertToPlaybackStatus(extra)); } break; case OHOS::Media::INFO_TYPE_POSITION_UPDATE: - LOGI("video INFO_TYPE_POSITION_UPDATE callback"); + LOGD("video INFO_TYPE_POSITION_UPDATE callback"); if (positionUpdatedEvent_) { positionUpdatedEvent_(extra / MILLISECONDS_TO_SECONDS); } break; case OHOS::Media::INFO_TYPE_RESOLUTION_CHANGE: + LOGD("video INFO_TYPE_RESOLUTION_CHANGE callback"); if (resolutionChangeEvent_) { resolutionChangeEvent_(); } break; case OHOS::Media::INFO_TYPE_MESSAGE: - LOGI("OnMessage callback type: %{public}d", extra); + LOGD("OnMessage callback type: %{public}d", extra); break; default: break; diff --git a/frameworks/core/components_ng/pattern/video/video_pattern.cpp b/frameworks/core/components_ng/pattern/video/video_pattern.cpp index fc285e9ae0a..5e943b48b04 100644 --- a/frameworks/core/components_ng/pattern/video/video_pattern.cpp +++ b/frameworks/core/components_ng/pattern/video/video_pattern.cpp @@ -733,16 +733,6 @@ void VideoPattern::UpdateControllerBar() controllerLayoutProperty->UpdateVisibility(VisibleType::VISIBLE); controller->MarkModifyDone(); } - for (const auto& child : children) { - if (child->GetTag() == V2::ROW_ETS_TAG) { - if (isDrag_) { - host->RemoveChild(child); - auto controlBar = CreateControlBar(); - host->AddChild(controlBar); - } - break; - } - } } else { auto video = AceType::DynamicCast(host); CHECK_NULL_VOID(video); @@ -1300,6 +1290,7 @@ void VideoPattern::EnableDrag() auto records = unifiedData->GetRecords(); if (records.size() == 0) { LOGE("unifiedRecords is empty"); + return; } auto video = reinterpret_cast(records[0].get()); videoSrc = video->GetUri(); @@ -1361,10 +1352,8 @@ void VideoPattern::EnableDrag() if (!isInitialState) { this->SetIsStop(true); } - this->SetIsDrag(true); auto frameNode = this->GetHost(); frameNode->MarkModifyDone(); - this->SetIsDrag(false); }; #endif auto eventHub = host->GetEventHub(); From ef4be4bb4212e719ff2b0cb86b80c0c8564c2bd8 Mon Sep 17 00:00:00 2001 From: limeng Date: Wed, 24 May 2023 13:50:32 +0000 Subject: [PATCH 91/99] fix the bugs Signed-off-by: limeng --- .../bridge/declarative_frontend/jsview/js_canvas_renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp index 39f7fd95f5c..4426750873b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_canvas_renderer.cpp @@ -334,7 +334,7 @@ void JSCanvasRenderer::JsStrokeText(const JSCallbackInfo& info) x = SystemProperties::Vp2Px(x); y = SystemProperties::Vp2Px(y); std::optional maxWidth; - if (info.Length() >= 4 && info[3]->IsNumber()) { + if (info.Length() >= 4) { double width = 0.0; if (info[3]->IsUndefined()) { width = FLT_MAX; From 9014f56d5b07a12fdace7473d119ed7c18ea1e66 Mon Sep 17 00:00:00 2001 From: fengjituo111 Date: Wed, 24 May 2023 15:05:22 +0000 Subject: [PATCH 92/99] =?UTF-8?q?=E4=BC=98=E5=8C=96Popup=E9=81=BF=E8=AE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengjituo111 Change-Id: I857509d314233065a6c75717500c8b2419ed84a4 --- .../bubble/bubble_layout_algorithm.cpp | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp index 8d4658219d8..8d87a07383e 100644 --- a/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp @@ -144,10 +144,10 @@ void BubbleLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper) if (children.empty()) { return; } - selfSize_ = layoutWrapper->GetGeometryNode()->GetFrameSize(); // bubble's size + selfSize_ = layoutWrapper->GetGeometryNode()->GetFrameSize(); // window's size auto child = children.front(); - childSize_ = child->GetGeometryNode()->GetMarginFrameSize(); // bubble's child's size - childOffset_ = GetChildPosition(childSize_, bubbleProp); // bubble's child's offset + childSize_ = child->GetGeometryNode()->GetMarginFrameSize(); // bubble's size + childOffset_ = GetChildPosition(childSize_, bubbleProp); // bubble's offset bool useCustom = bubbleProp->GetUseCustom().value_or(false); UpdateChildPosition(bubbleProp); UpdateTouchRegion(); @@ -198,6 +198,8 @@ OffsetF BubbleLayoutAlgorithm::GetChildPosition(const SizeF& childSize, const Re targetOffset_.GetY() - childSize.Height() - targetSpace - arrowHeight_); OffsetF topArrowPosition; OffsetF bottomArrowPosition; + OffsetF oppositePosition; + OffsetF fitPosition; InitArrowTopAndBottomPosition(topArrowPosition, bottomArrowPosition, topPosition, bottomPosition, childSize); OffsetF originOffset = @@ -210,25 +212,36 @@ OffsetF BubbleLayoutAlgorithm::GetChildPosition(const SizeF& childSize, const Re if (errorType == ErrorPositionType::NORMAL) { return childPosition; } - // If childPosition is error, adjust bubble to bottom. - if (placement_ != Placement::TOP || errorType == ErrorPositionType::TOP_LEFT_ERROR) { - childPosition = FitToScreen(bottomPosition, childSize); + + if (placement_ == Placement::TOP || placement_ == Placement::TOP_LEFT || placement_ == Placement::TOP_RIGHT) { + fitPosition = topPosition; + arrowPosition_ = topArrowPosition; + arrowPlacement_ = Placement::TOP; + } else { + fitPosition = bottomPosition; arrowPosition_ = bottomArrowPosition; arrowPlacement_ = Placement::BOTTOM; - if (GetErrorPositionType(childPosition, childSize) == ErrorPositionType::NORMAL) { - return childPosition; - } } - // If childPosition is error, adjust bubble to top. - childPosition = FitToScreen(topPosition, childSize); - arrowPosition_ = topArrowPosition; - arrowPlacement_ = Placement::TOP; + + childPosition = FitToScreen(fitPosition, childSize); + if (GetErrorPositionType(childPosition, childSize) == ErrorPositionType::NORMAL) { return childPosition; } + + oppositePosition = fitPosition == topPosition ? bottomPosition : topPosition; + arrowPosition_ = arrowPosition_ == topArrowPosition ? bottomArrowPosition : topArrowPosition; + arrowPlacement_ = arrowPlacement_ == Placement::TOP ? Placement::BOTTOM : Placement::TOP; + + childPosition = FitToScreen(fitPosition, childSize); + + if (GetErrorPositionType(childPosition, childSize) == ErrorPositionType::NORMAL) { + return childPosition; + } + // If childPosition is error, adjust bubble to origin position. arrowPlacement_ = placement_; - arrowPosition_ = arrowPlacement_ == Placement::TOP ? topArrowPosition : bottomArrowPosition; + // Todo arrowPositom may need to adjust return originOffset; } @@ -241,7 +254,8 @@ void BubbleLayoutAlgorithm::InitArrowTopAndBottomPosition(OffsetF& topArrowPosit childSize.Height() + arrowHeight_); bottomArrowPosition = bottomPosition + OffsetF(std::max(padding_.Left().ConvertToPx(), border_.BottomLeftRadius().GetX().ConvertToPx()) + - BEZIER_WIDTH_HALF.ConvertToPx(), -arrowHeight_); + BEZIER_WIDTH_HALF.ConvertToPx(), + -arrowHeight_); } OffsetF BubbleLayoutAlgorithm::GetPositionWithPlacement(const SizeF& childSize, const OffsetF& topPosition, From 49029a61de7846d5d38f3724395f64f2f2bcb219 Mon Sep 17 00:00:00 2001 From: yangwt Date: Wed, 24 May 2023 15:19:15 +0000 Subject: [PATCH 93/99] =?UTF-8?q?=E8=A7=A3=E5=86=B3swiper=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=88=86=E5=B8=83=E5=BC=8F=E6=8E=A5=E6=94=B6=E7=AB=AF?= =?UTF-8?q?=E6=9C=AA=E5=B8=83=E5=B1=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwt Change-Id: I74e660e7b5403dec76d58ac944f18d9149af360b --- .../components_ng/pattern/swiper/swiper_pattern.cpp | 10 +++++++++- .../core/components_ng/pattern/swiper/swiper_pattern.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp index 498599dd00f..c2b8fd4233d 100644 --- a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp +++ b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.cpp @@ -63,7 +63,8 @@ void SwiperPattern::FromJson(const std::unique_ptr& json) auto currentOffsetTimes = static_cast(json->GetDouble("currentOffsetTimes")); if (currentOffsetTimes != currentOffsetTimes_) { LOGD("UITree currentOffsetTimes=%{public}f", currentOffsetTimes); - host->UpdateAnimatablePropertyFloat(PROPERTY_NAME, currentOffsetTimes); + currentOffsetTimes_ = currentOffsetTimes; + OnlyUpdateAnimatableProperty(); } Pattern::FromJson(json); } @@ -200,6 +201,7 @@ void SwiperPattern::OnModifyDone() targetIndex_ = currentIndex_; currentOffsetTimes_ = currentIndex_; + OnlyUpdateAnimatableProperty(); CalculateItemRange(); RegisterVisibleAreaChange(); InitSwiperController(); @@ -1005,8 +1007,14 @@ void SwiperPattern::PlayTranslateAnimation(int32_t duration) void SwiperPattern::ForcedStopTranslateAnimation() { if (!AnimationUtils::IsRunning(animation_)) { + animation_ = nullptr; return; } + OnlyUpdateAnimatableProperty(); +} + +void SwiperPattern::OnlyUpdateAnimatableProperty() +{ auto host = GetHost(); CHECK_NULL_VOID(host); std::string propertyName = PROPERTY_NAME; diff --git a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h index 47c579427f8..a6111e3579f 100644 --- a/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h +++ b/frameworks/core/components_ng/pattern/swiper/swiper_pattern.h @@ -383,6 +383,7 @@ private: bool CalculateItemRange(); void PlayTranslateAnimation(int32_t duration); void ForcedStopTranslateAnimation(); + void OnlyUpdateAnimatableProperty(); void GoAutoPlay(); void ForcedFinishAutoPlay(); void HandleFinishAutoPlayAnimationEnds(); From 4ab0004038092947008bddc4f7ede7091bfc3ace Mon Sep 17 00:00:00 2001 From: hehongyang9 Date: Wed, 24 May 2023 23:14:18 +0800 Subject: [PATCH 94/99] fix scheduler crash because of overflow check Signed-off-by: hehongyang9 Change-Id: I545fd33f1f43709a0c65c0727eafc54d700e4368 --- frameworks/core/animation/scheduler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frameworks/core/animation/scheduler.cpp b/frameworks/core/animation/scheduler.cpp index 503ff0b0dfe..b7b3b9e139f 100644 --- a/frameworks/core/animation/scheduler.cpp +++ b/frameworks/core/animation/scheduler.cpp @@ -60,8 +60,12 @@ void Scheduler::OnFrame(uint64_t nanoTimestamp) } // Refresh the startup time every frame. - uint64_t elapsedTimeMs = (nanoTimestamp - startupTimestamp_) / 1000000; - startupTimestamp_ += elapsedTimeMs * 1000000; + uint64_t elapsedTimeMs = 0; + if (nanoTimestamp > startupTimestamp_) { + static const uint64_t milliToNano = 1000000; + elapsedTimeMs = (nanoTimestamp - startupTimestamp_) / milliToNano; + startupTimestamp_ += elapsedTimeMs * milliToNano; + } // Consume previous schedule as default. scheduleId_ = 0; From b52c3aff4ef80f06588c2743298a0ddbc5eef115 Mon Sep 17 00:00:00 2001 From: zhouchaobo Date: Thu, 25 May 2023 10:56:36 +0800 Subject: [PATCH 95/99] NavBar set clip edge Signed-off-by: zhouchaobo Change-Id: I2a0053a1d698594122c8b6d9b11ab859b3ce41cf --- .../components_ng/pattern/navigation/navigation_model_ng.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp b/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp index db94f2aaf4d..3814c95d12a 100644 --- a/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/navigation/navigation_model_ng.cpp @@ -291,6 +291,9 @@ void NavigationModelNG::Create() int32_t navBarNodeId = ElementRegister::GetInstance()->MakeUniqueId(); auto navBarNode = NavBarNode::GetOrCreateNavBarNode( V2::NAVBAR_ETS_TAG, navBarNodeId, []() { return AceType::MakeRefPtr(); }); + auto navBarRenderContext = navBarNode->GetRenderContext(); + CHECK_NULL_VOID(navBarRenderContext); + navBarRenderContext->UpdateClipEdge(true); navigationGroupNode->AddChild(navBarNode); navigationGroupNode->SetNavBarNode(navBarNode); From 6be6bb698efebcee950da37f01c7d4d07f666ef8 Mon Sep 17 00:00:00 2001 From: jinweiliu Date: Thu, 25 May 2023 02:56:55 +0000 Subject: [PATCH 96/99] fix ut Signed-off-by: jinweiliu Change-Id: Ida53775d8bea4bb19ed56b79d40c8a262f379b70 --- .../components_ng/test/pattern/video/video_pattern_test_ng.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp b/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp index d3b21553e9d..8ac2273c908 100644 --- a/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp +++ b/frameworks/core/components_ng/test/pattern/video/video_pattern_test_ng.cpp @@ -1576,8 +1576,5 @@ HWTEST_F(VideoPropertyTestNg, VideoPatternTest020, TestSize.Level1) videoPattern->isInitialState_ = false; dragEnd(nullptr, json->ToString()); EXPECT_TRUE(videoPattern->isStop_); - videoPattern->SetIsDrag(true); - dragEnd(nullptr, json->ToString()); - EXPECT_FALSE(videoPattern->isDrag_); } } // namespace OHOS::Ace::NG From 8cc91ca2476746e16958adfe67327dcf3a34188b Mon Sep 17 00:00:00 2001 From: yangguangzhao Date: Thu, 25 May 2023 14:00:21 +0800 Subject: [PATCH 97/99] web remove std::move string Signed-off-by: yangguangzhao --- frameworks/core/components/web/resource/web_delegate.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/core/components/web/resource/web_delegate.cpp b/frameworks/core/components/web/resource/web_delegate.cpp index 5b2032f24b0..00f9a55315a 100644 --- a/frameworks/core/components/web/resource/web_delegate.cpp +++ b/frameworks/core/components/web/resource/web_delegate.cpp @@ -2396,8 +2396,7 @@ void WebDelegate::InitWebViewWithSurface() initArgs.web_engine_args_to_add.push_back( std::string("--init-background-color=").append(std::to_string(delegate->backgroundColor_))); if (!system::GetBoolParameter(BACKGROUMD_MEDIA_SUSPEND, true)) { - initArgs.web_engine_args_to_add.emplace_back( - std::move(std::string("--disable-background-media-suspend"))); + initArgs.web_engine_args_to_add.emplace_back(std::string("--disable-background-media-suspend")); } initArgs.multi_renderer_process = system::GetBoolParameter(MULTI_RENDER_PROCESS, false); if (isEnhanceSurface) { From a95f67bf4cb99ab3c67e654c9357f481fc4a973c Mon Sep 17 00:00:00 2001 From: lijuan Date: Thu, 25 May 2023 06:27:02 +0000 Subject: [PATCH 98/99] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=B6=E5=AE=83?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BD=8D=E7=BD=AE=E5=8F=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?text=E8=8F=9C=E5=8D=95=E4=BD=8D=E7=BD=AE=E4=B8=8D=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijuan --- .../pattern/text/text_pattern.cpp | 18 +++++++++--------- .../components_ng/pattern/text/text_pattern.h | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.cpp b/frameworks/core/components_ng/pattern/text/text_pattern.cpp index 794ae74f543..9d8349cf051 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text/text_pattern.cpp @@ -70,6 +70,7 @@ void TextPattern::CloseSelectOverlay() void TextPattern::ResetSelection() { + showSelectOverlay_ = false; textSelector_.Update(-1, -1); auto host = GetHost(); CHECK_NULL_VOID(host); @@ -158,7 +159,7 @@ void TextPattern::HandleLongPress(GestureEvent& info) auto textPaintOffset = contentRect_.GetOffset() - OffsetF(0.0, std::min(baselineOffset_, 0.0f)); Offset textOffset = { info.GetLocalLocation().GetX() - textPaintOffset.GetX(), info.GetLocalLocation().GetY() - textPaintOffset.GetY() }; - + showSelectOverlay_ = true; InitSelection(textOffset); CalculateHandleOffsetAndShowOverlay(); ShowSelectOverlay(textSelector_.firstHandle, textSelector_.secondHandle); @@ -267,10 +268,7 @@ void TextPattern::HandleOnCopy() if (copyOption_ != CopyOptions::None) { clipboard_->SetData(value, copyOption_); } - textSelector_.Update(-1, -1); - auto host = GetHost(); - CHECK_NULL_VOID(host); - host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); + ResetSelection(); } void TextPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& secondHandle) @@ -333,10 +331,7 @@ void TextPattern::ShowSelectOverlay(const RectF& firstHandle, const RectF& secon void TextPattern::HandleOnOverlayClose() { - textSelector_.Update(-1, -1); - auto host = GetHost(); - CHECK_NULL_VOID(host); - host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); + ResetSelection(); } void TextPattern::HandleOnSelectAll() @@ -773,6 +768,11 @@ bool TextPattern::OnDirtyLayoutWrapperSwap(const RefPtr& dirty, c contentRect_ = dirty->GetGeometryNode()->GetContentRect(); contentOffset_ = dirty->GetGeometryNode()->GetContentOffset(); textStyle_ = textLayoutAlgorithm->GetTextStyle(); + + if (showSelectOverlay_) { + CalculateHandleOffsetAndShowOverlay(); + ShowSelectOverlay(textSelector_.firstHandle, textSelector_.secondHandle); + } return true; } diff --git a/frameworks/core/components_ng/pattern/text/text_pattern.h b/frameworks/core/components_ng/pattern/text/text_pattern.h index 08f48c1a20f..71237e41d22 100644 --- a/frameworks/core/components_ng/pattern/text/text_pattern.h +++ b/frameworks/core/components_ng/pattern/text/text_pattern.h @@ -268,6 +268,7 @@ private: bool clickEventInitialized_ = false; bool mouseEventInitialized_ = false; bool panEventInitialized_ = false; + bool showSelectOverlay_ = false; std::optional textStyle_; std::optional surfaceChangedCallbackId_; From b5cb8d90e5ce45e19538ec1b2a46811f2334b2a9 Mon Sep 17 00:00:00 2001 From: fengjituo111 Date: Sat, 20 May 2023 12:19:45 +0000 Subject: [PATCH 99/99] =?UTF-8?q?=E3=80=90popup=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E8=BE=83=E5=B0=8F=E4=B8=94=E9=9D=A0=E8=BF=91?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E6=97=B6=EF=BC=8C=E9=81=BF=E5=85=8D=E6=B0=94?= =?UTF-8?q?=E6=B3=A1=E4=B8=8E=E7=AE=AD=E5=A4=B4=E4=BA=A7=E7=94=9F=E5=88=86?= =?UTF-8?q?=E5=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengjituo111 Change-Id: Id14bfd6b346c23dfd99929fc196193c5e28e29d1 --- .../pattern/bubble/bubble_layout_algorithm.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp b/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp index b2fe3a044f5..e5d65ea4d6a 100644 --- a/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp +++ b/frameworks/core/components_ng/pattern/bubble/bubble_layout_algorithm.cpp @@ -229,6 +229,11 @@ OffsetF BubbleLayoutAlgorithm::GetChildPosition(const SizeF& childSize, const Re void BubbleLayoutAlgorithm::InitArrowTopAndBottomPosition(OffsetF& topArrowPosition, OffsetF& bottomArrowPosition, OffsetF& topPosition, OffsetF& bottomPosition, const SizeF& childSize) { + auto arrowCenter = targetOffset_.GetX() + targetSize_.Width() / 2.0; + auto horizonSpacing = static_cast(HORIZON_SPACING_WITH_SCREEN.ConvertToPx()); + double arrowWidth = ARROW_WIDTH.ConvertToPx(); + float radius = borderRadius_.ConvertToPx(); + auto safePosition = horizonSpacing + radius + arrowWidth / 2.0; topArrowPosition = topPosition + OffsetF(std::max(padding_.Left().ConvertToPx(), border_.TopLeftRadius().GetX().ConvertToPx()) + BEZIER_WIDTH_HALF.ConvertToPx(), @@ -237,6 +242,16 @@ void BubbleLayoutAlgorithm::InitArrowTopAndBottomPosition(OffsetF& topArrowPosit border_.BottomLeftRadius().GetX().ConvertToPx()) + BEZIER_WIDTH_HALF.ConvertToPx(), -arrowHeight_); + // move the arrow to safe position while arrow too close to window + // In order not to separate the bubble from the arrow + if (arrowCenter < safePosition) { + topArrowPosition = topArrowPosition + OffsetF(safePosition - arrowCenter, 0); + bottomArrowPosition = bottomArrowPosition + OffsetF(safePosition - arrowCenter, 0); + } + if (arrowCenter > selfSize_.Width() - safePosition) { + topArrowPosition = topArrowPosition - OffsetF(arrowCenter + safePosition - selfSize_.Width(), 0); + bottomArrowPosition = bottomArrowPosition - OffsetF(arrowCenter + safePosition - selfSize_.Width(), 0); + } } OffsetF BubbleLayoutAlgorithm::GetPositionWithPlacement(const SizeF& childSize, const OffsetF& topPosition,