mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-10-07 00:13:44 +00:00
!45017 修复ContentClip:修正不同滚动容器的默认值
Merge pull request !45017 from 周沺耳/dev
This commit is contained in:
commit
4aa2d20e92
@ -125,6 +125,6 @@ void JSScrollableBase::JSClipContent(const JSCallbackInfo& info)
|
||||
}
|
||||
}
|
||||
// default
|
||||
NG::ScrollableModelNG::SetContentClip(NG::ContentClipMode::CONTENT_ONLY, nullptr);
|
||||
NG::ScrollableModelNG::SetContentClip(NG::ContentClipMode::DEFAULT, nullptr);
|
||||
}
|
||||
} // namespace OHOS::Ace::Framework
|
||||
|
@ -58,13 +58,17 @@ public:
|
||||
|
||||
void UpdateContentModifier(PaintWrapper* paintWrapper) override;
|
||||
|
||||
|
||||
void SetContentModifier(const RefPtr<GridContentModifier>& modify)
|
||||
{
|
||||
gridContentModifier_ = modify;
|
||||
}
|
||||
|
||||
private:
|
||||
void ApplyDefaultContentClip(const RefPtr<RenderContext>& ctx, const RefPtr<GeometryNode>& geometryNode) override
|
||||
{
|
||||
ctx->SetContentClip(geometryNode->GetFrameRect());
|
||||
}
|
||||
|
||||
RefPtr<GridContentModifier> gridContentModifier_;
|
||||
WeakPtr<ScrollBar> scrollBar_;
|
||||
WeakPtr<ScrollEdgeEffect> edgeEffect_;
|
||||
|
@ -49,11 +49,17 @@ void ListPaintMethod::UpdateContentModifier(PaintWrapper* paintWrapper)
|
||||
frameSize.MinusPadding(*padding->left, *padding->right, *padding->top, *padding->bottom);
|
||||
}
|
||||
UpdateFadingGradient(renderContext);
|
||||
bool hasPadding = padding && padding->HasValue();
|
||||
bool clip = hasPadding && (!renderContext || renderContext->GetClipEdge().value_or(true));
|
||||
listContentModifier_->SetClipOffset(paddingOffset);
|
||||
listContentModifier_->SetClipSize(frameSize);
|
||||
listContentModifier_->SetClip(clip);
|
||||
|
||||
if (TryContentClip(paintWrapper)) {
|
||||
listContentModifier_->SetClip(false);
|
||||
} else {
|
||||
const bool hasPadding = padding && padding->HasValue();
|
||||
bool clip = hasPadding && (!renderContext || renderContext->GetClipEdge().value_or(true));
|
||||
listContentModifier_->SetClipOffset(paddingOffset);
|
||||
listContentModifier_->SetClipSize(frameSize);
|
||||
listContentModifier_->SetClip(clip);
|
||||
}
|
||||
|
||||
float contentSize = vertical_ ? frameSize.Width() : frameSize.Height();
|
||||
if (!divider_.strokeWidth.IsValid() || totalItemCount_ <= 0 ||
|
||||
divider_.strokeWidth.Unit() == DimensionUnit::PERCENT ||
|
||||
@ -63,8 +69,7 @@ void ListPaintMethod::UpdateContentModifier(PaintWrapper* paintWrapper)
|
||||
return;
|
||||
}
|
||||
Axis axis = vertical_ ? Axis::HORIZONTAL : Axis::VERTICAL;
|
||||
DividerInfo dividerInfo = {
|
||||
.constrainStrokeWidth = divider_.strokeWidth.ConvertToPx(),
|
||||
DividerInfo dividerInfo = { .constrainStrokeWidth = divider_.strokeWidth.ConvertToPx(),
|
||||
.crossSize = vertical_ ? frameSize.Height() : frameSize.Width(),
|
||||
.startMargin = std::max(0.0, divider_.startMargin.ConvertToPx()),
|
||||
.endMargin = std::max(0.0, divider_.endMargin.ConvertToPx()),
|
||||
@ -76,10 +81,11 @@ void ListPaintMethod::UpdateContentModifier(PaintWrapper* paintWrapper)
|
||||
.totalItemCount = totalItemCount_,
|
||||
.color = divider_.color,
|
||||
.laneGutter = laneGutter_,
|
||||
.mainSize = size
|
||||
};
|
||||
.mainSize = size };
|
||||
float checkMargin = dividerInfo.crossSize / dividerInfo.lanes - dividerInfo.startMargin - dividerInfo.endMargin;
|
||||
if (NearZero(checkMargin)) return;
|
||||
if (NearZero(checkMargin)) {
|
||||
return;
|
||||
}
|
||||
if (LessNotEqual(checkMargin, 0.0f)) {
|
||||
dividerInfo.startMargin = 0.0f;
|
||||
dividerInfo.endMargin = 0.0f;
|
||||
@ -100,8 +106,7 @@ void ListPaintMethod::UpdateDividerList(const DividerInfo& dividerInfo)
|
||||
bool nextIsPressed = false;
|
||||
for (const auto& child : itemPosition_) {
|
||||
auto nextId = child.first - lanes;
|
||||
nextIsPressed = nextId < 0 || lastIsItemGroup || child.second.isGroup ?
|
||||
false : itemPosition_[nextId].isPressed;
|
||||
nextIsPressed = nextId < 0 || lastIsItemGroup || child.second.isGroup ? false : itemPosition_[nextId].isPressed;
|
||||
if (!isFirstItem && !(child.second.isPressed || nextIsPressed)) {
|
||||
dividerMap[child.second.id] = HandleDividerList(child.first, lastIsItemGroup, laneIdx, dividerInfo);
|
||||
}
|
||||
@ -148,8 +153,7 @@ ListDivider ListPaintMethod::HandleDividerList(
|
||||
}
|
||||
}
|
||||
if (dividerInfo.lanes > 1 && !lastIsGroup && !itemPosition_.at(index).isGroup) {
|
||||
crossPos +=
|
||||
laneIdx * ((dividerInfo.crossSize - fSpacingTotal) / dividerInfo.lanes + dividerInfo.laneGutter);
|
||||
crossPos += laneIdx * ((dividerInfo.crossSize - fSpacingTotal) / dividerInfo.lanes + dividerInfo.laneGutter);
|
||||
divider.length = laneLen;
|
||||
} else {
|
||||
divider.length = crossLen;
|
||||
@ -178,8 +182,7 @@ ListDivider ListPaintMethod::HandleLastLineIndex(int32_t index, int32_t laneIdx,
|
||||
}
|
||||
}
|
||||
if (dividerInfo.lanes > 1 && !itemPosition_.at(index).isGroup) {
|
||||
crossPos +=
|
||||
laneIdx * ((dividerInfo.crossSize - fSpacingTotal) / dividerInfo.lanes + dividerInfo.laneGutter);
|
||||
crossPos += laneIdx * ((dividerInfo.crossSize - fSpacingTotal) / dividerInfo.lanes + dividerInfo.laneGutter);
|
||||
divider.length = laneLen;
|
||||
} else {
|
||||
divider.length = crossLen;
|
||||
|
@ -124,6 +124,11 @@ public:
|
||||
void UpdateOverlayModifier(PaintWrapper* paintWrapper) override;
|
||||
|
||||
private:
|
||||
void ApplyDefaultContentClip(const RefPtr<RenderContext>& ctx, const RefPtr<GeometryNode>& geometryNode) override
|
||||
{
|
||||
ctx->SetContentClip(geometryNode->GetPaddingRect());
|
||||
}
|
||||
|
||||
V2::ItemDivider divider_;
|
||||
int32_t lanes_ = 1;
|
||||
int32_t totalItemCount_ = 0;
|
||||
|
@ -33,6 +33,7 @@ void ScrollPaintMethod::UpdateContentModifier(PaintWrapper* paintWrapper)
|
||||
auto renderContext = paintWrapper->GetRenderContext();
|
||||
CHECK_NULL_VOID(renderContext);
|
||||
UpdateFadingGradient(renderContext);
|
||||
TryContentClip(paintWrapper);
|
||||
}
|
||||
|
||||
void ScrollPaintMethod::PaintScrollEffect(RSCanvas& canvas, PaintWrapper* paintWrapper) const
|
||||
|
@ -68,6 +68,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void ApplyDefaultContentClip(const RefPtr<RenderContext>& ctx, const RefPtr<GeometryNode>& geometryNode) override
|
||||
{
|
||||
ctx->SetContentClip(geometryNode->GetFrameRect());
|
||||
}
|
||||
|
||||
RefPtr<ScrollContentModifier> scrollContentModifier_;
|
||||
void PaintScrollEffect(RSCanvas& canvas, PaintWrapper* paintWrapper) const;
|
||||
|
||||
|
@ -91,6 +91,9 @@ bool ScrollablePaintMethod::TryContentClip(PaintWrapper* wrapper)
|
||||
case ContentClipMode::BOUNDARY:
|
||||
renderContext->SetContentClip(wrapper->GetGeometryNode()->GetFrameRect());
|
||||
break;
|
||||
case ContentClipMode::DEFAULT:
|
||||
ApplyDefaultContentClip(renderContext, wrapper->GetGeometryNode());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ public:
|
||||
{}
|
||||
~ScrollablePaintMethod() override = default;
|
||||
|
||||
|
||||
void SetOverlayRenderContext(const RefPtr<RenderContext>& overlayRenderContext)
|
||||
{
|
||||
overlayRenderContext_ = overlayRenderContext;
|
||||
@ -52,20 +51,25 @@ protected:
|
||||
*
|
||||
* @return true if content clip is set up
|
||||
*/
|
||||
static bool TryContentClip(PaintWrapper* wrapper);
|
||||
bool TryContentClip(PaintWrapper* wrapper);
|
||||
|
||||
bool vertical_ = false;
|
||||
bool isReverse_ = false;
|
||||
bool isVerticalReverse_ = false;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Apply Scrollable's default content clip area
|
||||
*/
|
||||
virtual void ApplyDefaultContentClip(
|
||||
const RefPtr<RenderContext>& ctx, const RefPtr<GeometryNode>& geometryNode) = 0;
|
||||
|
||||
RefPtr<RenderContext> overlayRenderContext_;
|
||||
bool isFadingTop_ = false;
|
||||
bool isFadingBottom_ = false;
|
||||
float percentFading_ = 0.0f;
|
||||
float startPercent_ = 0.0f;
|
||||
float endPercent_ = 1.0f;
|
||||
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLLABLE_SCROLLABLE_PAINT_METHOD_H
|
||||
|
@ -41,6 +41,7 @@ enum class ContentClipMode {
|
||||
BOUNDARY, // corresponding to FrameRect, area excluding margin
|
||||
SAFE_AREA, // CONTENT_ONLY area + SafeAreaPadding (which can stack up with ancestor's SafeAreaPadding)
|
||||
CUSTOM, // inner enum, not present in JS. Custom shape's offset is relative to FrameOffset.
|
||||
DEFAULT, // Different scrollable components have different default clip values.
|
||||
};
|
||||
using ContentClip = std::pair<ContentClipMode, RefPtr<ShapeRect>>;
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "core/components_ng/pattern/scrollable/scrollable_paint_method.h"
|
||||
#include "core/components_ng/pattern/waterflow/water_flow_content_modifier.h"
|
||||
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
class ACE_EXPORT WaterFlowPaintMethod : public ScrollablePaintMethod {
|
||||
DECLARE_ACE_TYPE(WaterFlowPaintMethod, ScrollablePaintMethod)
|
||||
@ -71,6 +70,11 @@ public:
|
||||
void UpdateOverlayModifier(PaintWrapper* paintWrapper) override;
|
||||
|
||||
private:
|
||||
void ApplyDefaultContentClip(const RefPtr<RenderContext>& ctx, const RefPtr<GeometryNode>& geometryNode) override
|
||||
{
|
||||
ctx->SetContentClip(geometryNode->GetPaddingRect());
|
||||
}
|
||||
|
||||
RefPtr<WaterFlowContentModifier> contentModifier_;
|
||||
WeakPtr<ScrollBar> scrollBar_;
|
||||
WeakPtr<ScrollEdgeEffect> edgeEffect_;
|
||||
|
@ -14,12 +14,10 @@
|
||||
*/
|
||||
|
||||
#include "list_test_ng.h"
|
||||
#include "test/mock/core/render/mock_render_context.h"
|
||||
#include "test/unittest/core/pattern/scrollable/scrollable_test_utils.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
|
||||
namespace {
|
||||
} // namespace
|
||||
|
||||
class ListScrollVisibleContentChangeTestNg : public ListTestNg {
|
||||
public:
|
||||
};
|
||||
@ -559,7 +557,7 @@ HWTEST_F(ListScrollVisibleContentChangeTestNg, OnScrollVisibleContentChange008,
|
||||
EXPECT_TRUE(IsEqual(startInfo, startExpect));
|
||||
EXPECT_TRUE(IsEqual(endInfo, endExpect));
|
||||
|
||||
startExpect = { 0, 1, 0};
|
||||
startExpect = { 0, 1, 0 };
|
||||
endExpect = { 1, 1, 1 };
|
||||
ScrollTo(ITEM_HEIGHT);
|
||||
EXPECT_TRUE(IsEqual(startInfo, startExpect));
|
||||
@ -570,7 +568,7 @@ HWTEST_F(ListScrollVisibleContentChangeTestNg, OnScrollVisibleContentChange008,
|
||||
* @tc.cases: startChanged == endChanged == true and indexChanged == false
|
||||
* @tc.expected: startExpect.index = 0
|
||||
*/
|
||||
startExpect = { 0, 2, -1};
|
||||
startExpect = { 0, 2, -1 };
|
||||
endExpect = { 1, 1, 0 };
|
||||
pattern_->ScrollTo(20);
|
||||
FlushLayoutTask(frameNode_);
|
||||
@ -594,7 +592,7 @@ HWTEST_F(ListScrollVisibleContentChangeTestNg, OnScrollVisibleContentChange008,
|
||||
* @tc.cases: startChanged == true and indexChanged == endChanged == false
|
||||
* @tc.expected: endExpect.indexInGroup = 0
|
||||
*/
|
||||
startExpect = { 0, 1, 0};
|
||||
startExpect = { 0, 1, 0 };
|
||||
pattern_->ScrollTo(60);
|
||||
FlushLayoutTask(frameNode_);
|
||||
EXPECT_EQ(pattern_->GetTotalOffset(), 60);
|
||||
@ -798,7 +796,7 @@ HWTEST_F(ListScrollVisibleContentChangeTestNg, OnScrollVisibleContentChange011,
|
||||
EXPECT_TRUE(IsEqual(startInfo, startExpect));
|
||||
EXPECT_TRUE(IsEqual(endInfo, endExpect));
|
||||
|
||||
startExpect = { 0, 1, 0};
|
||||
startExpect = { 0, 1, 0 };
|
||||
endExpect = { 1, 1, 1 };
|
||||
ScrollTo(ITEM_HEIGHT);
|
||||
EXPECT_TRUE(IsEqual(startInfo, startExpect));
|
||||
@ -877,7 +875,7 @@ HWTEST_F(ListScrollVisibleContentChangeTestNg, OnScrollVisibleContentChange012,
|
||||
EXPECT_TRUE(IsEqual(startInfo, startExpect));
|
||||
EXPECT_TRUE(IsEqual(endInfo, endExpect));
|
||||
|
||||
startExpect = { 0, 1, 0};
|
||||
startExpect = { 0, 1, 0 };
|
||||
endExpect = { 1, 1, 1 };
|
||||
ScrollTo(ITEM_HEIGHT);
|
||||
EXPECT_TRUE(IsEqual(startInfo, startExpect));
|
||||
@ -932,4 +930,25 @@ HWTEST_F(ListScrollVisibleContentChangeTestNg, OnScrollVisibleContentChange012,
|
||||
EXPECT_TRUE(IsEqual(endInfo, endExpect));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ContentClip001
|
||||
* @tc.desc: Test ContentClip
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ListScrollVisibleContentChangeTestNg, ContentClip001, TestSize.Level1)
|
||||
{
|
||||
ListModelNG model = CreateList();
|
||||
CreateGroupWithSetting(5, V2::ListItemGroupStyle::NONE);
|
||||
CreateDone(frameNode_);
|
||||
|
||||
paintProperty_->UpdateContentClip({ ContentClipMode::DEFAULT, nullptr });
|
||||
auto ctx = AceType::DynamicCast<MockRenderContext>(frameNode_->GetRenderContext());
|
||||
ASSERT_TRUE(ctx);
|
||||
EXPECT_CALL(*ctx, SetContentClip(ClipRectEq(frameNode_->GetGeometryNode()->GetPaddingRect()))).Times(1);
|
||||
FlushLayoutTask(frameNode_);
|
||||
|
||||
paintProperty_->UpdateContentClip({ ContentClipMode::BOUNDARY, nullptr });
|
||||
EXPECT_CALL(*ctx, SetContentClip(ClipRectEq(frameNode_->GetGeometryNode()->GetFrameRect()))).Times(1);
|
||||
FlushLayoutTask(frameNode_);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
@ -57,6 +57,7 @@ void ListTestNg::SetUpTestSuite()
|
||||
MockPipelineContext::GetCurrentContext()->taskExecutor_ = AceType::MakeRefPtr<MockTaskExecutor>();
|
||||
EXPECT_CALL(*MockPipelineContext::pipeline_, FlushUITasks).Times(AnyNumber());
|
||||
MockAnimationManager::Enable(true);
|
||||
testing::FLAGS_gmock_verbose = "error";
|
||||
}
|
||||
|
||||
void ListTestNg::TearDownTestSuite()
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "scroll_test_ng.h"
|
||||
#include "test/mock/core/pipeline/mock_pipeline_context.h"
|
||||
#include "test/mock/core/rosen/mock_canvas.h"
|
||||
#include "test/unittest/core/pattern/scrollable/scrollable_test_utils.h"
|
||||
#include "test/mock/core/render/mock_render_context.h"
|
||||
|
||||
#include "core/components_ng/pattern/scroll/effect/scroll_fade_effect.h"
|
||||
#include "core/components_ng/pattern/scroll/scroll_spring_effect.h"
|
||||
@ -657,4 +659,26 @@ HWTEST_F(ScrollEffectTestNg, EdgeEffectOption004, TestSize.Level1)
|
||||
EXPECT_TRUE(pattern_->GetAlwaysEnabled());
|
||||
EXPECT_TRUE(pattern_->GetScrollableEvent()->GetEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ContentClip001
|
||||
* @tc.desc: Test ContentClip
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ScrollEffectTestNg, ContentClip001, TestSize.Level1)
|
||||
{
|
||||
ScrollModelNG model = CreateScroll();
|
||||
CreateContent(2000.f);
|
||||
CreateScrollDone();
|
||||
|
||||
paintProperty_->UpdateContentClip({ ContentClipMode::DEFAULT, nullptr });
|
||||
auto ctx = AceType::DynamicCast<MockRenderContext>(frameNode_->GetRenderContext());
|
||||
ASSERT_TRUE(ctx);
|
||||
EXPECT_CALL(*ctx, SetContentClip(ClipRectEq(frameNode_->GetGeometryNode()->GetPaddingRect()))).Times(1);
|
||||
FlushLayoutTask(frameNode_);
|
||||
|
||||
paintProperty_->UpdateContentClip({ ContentClipMode::BOUNDARY, nullptr });
|
||||
EXPECT_CALL(*ctx, SetContentClip(ClipRectEq(frameNode_->GetGeometryNode()->GetFrameRect()))).Times(1);
|
||||
FlushLayoutTask(frameNode_);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -45,6 +45,7 @@ void ScrollTestNg::SetUpTestSuite()
|
||||
auto scrollableTheme = ScrollableTheme::Builder().Build(scrollableThemeConstants);
|
||||
EXPECT_CALL(*themeManager, GetTheme(ScrollableTheme::TypeId())).WillRepeatedly(Return(scrollableTheme));
|
||||
MockAnimationManager::Enable(true);
|
||||
testing::FLAGS_gmock_verbose = "error";
|
||||
}
|
||||
|
||||
void ScrollTestNg::TearDownTestSuite()
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "scrollable_test_ng.h"
|
||||
#include "test/mock/core/animation/mock_animation_manager.h"
|
||||
#include "test/mock/base/mock_task_executor.h"
|
||||
#include "test/mock/core/animation/mock_animation_manager.h"
|
||||
#include "test/mock/core/common/mock_container.h"
|
||||
#include "test/mock/core/common/mock_theme_manager.h"
|
||||
#include "test/mock/core/pipeline/mock_pipeline_context.h"
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#include "core/components/scroll/scroll_bar_theme.h"
|
||||
#include "core/components_ng/pattern/button/button_pattern.h"
|
||||
#include "core/components_ng/pattern/text/text_pattern.h"
|
||||
#include "core/components_ng/pattern/grid/grid_paint_method.h"
|
||||
#include "core/components_ng/pattern/overlay/sheet_drag_bar_pattern.h"
|
||||
#include "core/components_ng/pattern/refresh/refresh_pattern.h"
|
||||
#include "core/components_ng/pattern/root/root_pattern.h"
|
||||
@ -34,6 +34,7 @@
|
||||
#include "core/components_ng/pattern/scrollable/scrollable_item_pool.h"
|
||||
#include "core/components_ng/pattern/scrollable/scrollable_model_ng.h"
|
||||
#include "core/components_ng/pattern/scrollable/scrollable_paint_property.h"
|
||||
#include "core/components_ng/pattern/text/text_pattern.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
class ScrollableCoverTestNg : public ScrollableTestNg {
|
||||
@ -155,7 +156,7 @@ HWTEST_F(ScrollableCoverTestNg, SetScrollBarWidthTest001, TestSize.Level1)
|
||||
ScrollableModelNG::SetScrollBarWidth(SCROLLBAR_WIDTH_PERCENT);
|
||||
EXPECT_EQ(scrollablePn->GetBarWidth().Value(), SCROLLBAR_WIDTH_VALUE_PERCENT);
|
||||
EXPECT_EQ(scrollablePn->GetBarWidth().Unit(), DimensionUnit::PERCENT);
|
||||
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. Set ScrollBarWidth to vp width with frameNode
|
||||
* @tc.expected: ScrollablePaintProperty ScrollBarWidth is updated to vp width
|
||||
@ -223,25 +224,25 @@ HWTEST_F(ScrollableCoverTestNg, ToJsonValueTest001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create a ScrollablePaintProperty object and set Property
|
||||
*/
|
||||
*/
|
||||
ScrollableModelNG::SetScrollBarColor(SCROLLBAR_COLOR_BLUE);
|
||||
ScrollableModelNG::SetScrollBarWidth(SCROLLBAR_WIDTH_PX);
|
||||
auto scrollablePn = scroll_->GetPaintProperty<ScrollablePaintProperty>();
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Set properties
|
||||
*/
|
||||
*/
|
||||
scrollablePn->UpdateScrollBarMode(DisplayMode::AUTO);
|
||||
/**
|
||||
* @tc.steps: step3. Convert to JSON
|
||||
*/
|
||||
*/
|
||||
auto json = JsonUtil::Create(true);
|
||||
InspectorFilter filter;
|
||||
scrollablePn->ToJsonValue(json, filter);
|
||||
|
||||
/**
|
||||
* @tc.steps: step4. Convert to JSON
|
||||
*/
|
||||
*/
|
||||
EXPECT_EQ(json->GetString("scrollBar"), BAR_STATE_AUTO);
|
||||
EXPECT_EQ(json->GetString("scrollBarColor"), SCROLLBAR_COLOR_BLUE);
|
||||
EXPECT_EQ(json->GetString("scrollBarWidth"), SCROLLBAR_WIDTH_PX);
|
||||
@ -262,10 +263,8 @@ HWTEST_F(ScrollableCoverTestNg, AllocateTest001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create a ScrollableItem object and set ScrollableItemPool
|
||||
*/
|
||||
auto patternCreator = []() -> RefPtr<Pattern> {
|
||||
return AceType::MakeRefPtr<Pattern>();
|
||||
};
|
||||
*/
|
||||
auto patternCreator = []() -> RefPtr<Pattern> { return AceType::MakeRefPtr<Pattern>(); };
|
||||
auto tag = "testTag";
|
||||
auto nodeFirst = 1;
|
||||
auto nodeSecond = 2;
|
||||
@ -275,11 +274,11 @@ HWTEST_F(ScrollableCoverTestNg, AllocateTest001, TestSize.Level1)
|
||||
scrollableItemPool->pool_[tag].push_back(Referenced::RawPtr(existingItem));
|
||||
/**
|
||||
* @tc.steps: step2. Call Allocate
|
||||
*/
|
||||
*/
|
||||
auto result = scrollableItemPool->Allocate(tag, nodeSecond, patternCreator);
|
||||
/**
|
||||
* @tc.steps: step3. Verify that the Allocate function was triggered
|
||||
*/
|
||||
*/
|
||||
ASSERT_NE(result, nullptr);
|
||||
EXPECT_EQ(result->GetTag(), tag);
|
||||
EXPECT_EQ(result->GetId(), nodeSecond);
|
||||
@ -294,19 +293,17 @@ HWTEST_F(ScrollableCoverTestNg, DeallocateTest001, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create a ScrollableItem object and set ScrollableItemPool
|
||||
*/
|
||||
*/
|
||||
auto tag = "testTag";
|
||||
auto nodeFirst = 1;
|
||||
auto nodeSecond = 2;
|
||||
auto poolSize = 2;
|
||||
auto patternCreator = []() -> RefPtr<Pattern> {
|
||||
return AceType::MakeRefPtr<Pattern>();
|
||||
};
|
||||
auto patternCreator = []() -> RefPtr<Pattern> { return AceType::MakeRefPtr<Pattern>(); };
|
||||
auto item1 = ScrollableItem::GetOrCreateScrollableItem(tag, nodeFirst, patternCreator);
|
||||
auto item2 = ScrollableItem::GetOrCreateScrollableItem(tag, nodeSecond, patternCreator);
|
||||
/**
|
||||
* @tc.steps: step2. Call Deallocate
|
||||
*/
|
||||
*/
|
||||
auto scrollableItemPool = std::make_shared<ScrollableItemPool>(poolSize);
|
||||
scrollableItemPool->Deallocate(Referenced::RawPtr(item1));
|
||||
scrollableItemPool->Deallocate(Referenced::RawPtr(item2));
|
||||
@ -390,9 +387,7 @@ HWTEST_F(ScrollableCoverTestNg, HandleTouchCancel001, TestSize.Level1)
|
||||
*/
|
||||
auto scrollable = AceType::MakeRefPtr<Scrollable>();
|
||||
bool isCalled = false;
|
||||
auto scrollOverCallback = [&isCalled](double velocity) {
|
||||
isCalled = true;
|
||||
};
|
||||
auto scrollOverCallback = [&isCalled](double velocity) { isCalled = true; };
|
||||
scrollable->state_ = Scrollable::AnimationState::IDLE;
|
||||
scrollable->scrollOverCallback_ = scrollOverCallback;
|
||||
/**
|
||||
@ -439,9 +434,7 @@ HWTEST_F(ScrollableCoverTestNg, GetGainTest001, TestSize.Level1)
|
||||
* @tc.steps: step1. Create a Scrollable object and initalizes the parameters
|
||||
*/
|
||||
auto scrollable = AceType::MakeRefPtr<Scrollable>();
|
||||
auto continuousSlidingCallback = []() {
|
||||
return 100.0;
|
||||
};
|
||||
auto continuousSlidingCallback = []() { return 100.0; };
|
||||
scrollable->continuousSlidingCallback_ = continuousSlidingCallback;
|
||||
scrollable->dragCount_ = 5;
|
||||
scrollable->preGain_ = 1.0;
|
||||
@ -467,9 +460,7 @@ HWTEST_F(ScrollableCoverTestNg, GetGainTest002, TestSize.Level1)
|
||||
* @tc.steps: step1. Create a Scrollable object and initalizes the parameters
|
||||
*/
|
||||
auto scrollable = AceType::MakeRefPtr<Scrollable>();
|
||||
auto continuousSlidingCallback = []() {
|
||||
return 100.0;
|
||||
};
|
||||
auto continuousSlidingCallback = []() { return 100.0; };
|
||||
scrollable->continuousSlidingCallback_ = continuousSlidingCallback;
|
||||
scrollable->dragCount_ = 5;
|
||||
scrollable->preGain_ = 1.0;
|
||||
@ -626,17 +617,13 @@ HWTEST_F(ScrollableCoverTestNg, ProcessScrollMotionStopTest001, TestSize.Level1)
|
||||
scrollable->needScrollSnapChange_ = true;
|
||||
scrollable->isDragUpdateStop_ = false;
|
||||
scrollable->scrollPause_ = false;
|
||||
scrollable->calcPredictSnapOffsetCallback_ = [](float delta, float dragDistance, float velocity) {
|
||||
return 0.0f;
|
||||
};
|
||||
scrollable->calcPredictSnapOffsetCallback_ = [](float delta, float dragDistance, float velocity) { return 0.0f; };
|
||||
scrollable->currentVelocity_ = 10.0f;
|
||||
auto propertyCallback = [](float offset) {};
|
||||
scrollable->frictionOffsetProperty_ =
|
||||
scrollable->frictionOffsetProperty_ =
|
||||
AceType::MakeRefPtr<NodeAnimatablePropertyFloat>(0.0, std::move(propertyCallback));
|
||||
bool scrollEndCalled = false;
|
||||
scrollable->scrollEnd_ = [&scrollEndCalled]() {
|
||||
scrollEndCalled = true;
|
||||
};
|
||||
scrollable->scrollEnd_ = [&scrollEndCalled]() { scrollEndCalled = true; };
|
||||
/**
|
||||
* @tc.steps: step2. Call ProcessScrollMotionStop
|
||||
* @tc.expected: Verify that the scroll snap change is processed correctly
|
||||
@ -810,7 +797,7 @@ HWTEST_F(ScrollableCoverTestNg, OnScrollStartEndTest001, TestSize.Level1)
|
||||
auto refreshNode = FrameNode::CreateFrameNode("Refresh", -1, AceType::MakeRefPtr<RefreshPattern>());
|
||||
scroll_->MountToParent(refreshNode);
|
||||
refreshNode->MarkModifyDone();
|
||||
scrollPn->refreshCoordination_= AceType::MakeRefPtr<RefreshCoordination>(scrollPn->GetHost());
|
||||
scrollPn->refreshCoordination_ = AceType::MakeRefPtr<RefreshCoordination>(scrollPn->GetHost());
|
||||
bool isDragTest = false;
|
||||
float mainVelocityTest = 0.0f;
|
||||
auto startCallBack = [&isDragTest, &mainVelocityTest](bool isDrag, float mainVelocity) {
|
||||
@ -855,7 +842,7 @@ HWTEST_F(ScrollableCoverTestNg, IsRefreshInScroll001, TestSize.Level1)
|
||||
auto refreshNode = FrameNode::CreateFrameNode("Refresh", -1, AceType::MakeRefPtr<RefreshPattern>());
|
||||
scroll_->MountToParent(refreshNode);
|
||||
refreshNode->MarkModifyDone();
|
||||
scrollPn->refreshCoordination_= AceType::MakeRefPtr<RefreshCoordination>(scrollPn->GetHost());
|
||||
scrollPn->refreshCoordination_ = AceType::MakeRefPtr<RefreshCoordination>(scrollPn->GetHost());
|
||||
auto refreshPn = refreshNode->GetPattern<RefreshPattern>();
|
||||
refreshPn->scrollOffset_ = 50.0;
|
||||
/**
|
||||
@ -934,11 +921,9 @@ HWTEST_F(ScrollableCoverTestNg, OnWindowHide001, TestSize.Level1)
|
||||
*/
|
||||
auto scrollPn = scroll_->GetPattern<PartiallyMockedScrollable>();
|
||||
auto propertyCallback = [](float offset) {};
|
||||
const std::function<bool(double, int32_t)> scrollCallback = [](double offset, int32_t source) {
|
||||
return true;
|
||||
};
|
||||
const std::function<bool(double, int32_t)> scrollCallback = [](double offset, int32_t source) { return true; };
|
||||
auto scrollable = AceType::MakeRefPtr<Scrollable>(scrollCallback, scrollPn->GetAxis());
|
||||
scrollable->frictionOffsetProperty_ =
|
||||
scrollable->frictionOffsetProperty_ =
|
||||
AceType::MakeRefPtr<NodeAnimatablePropertyFloat>(0.0, std::move(propertyCallback));
|
||||
scrollable->state_ = Scrollable::AnimationState::FRICTION;
|
||||
ASSERT_NE(scrollPn->scrollableEvent_, nullptr);
|
||||
@ -1833,7 +1818,7 @@ HWTEST_F(ScrollableCoverTestNg, UpdateFadingEdgeTest001, TestSize.Level1)
|
||||
scroll_->overlayNode_ = overlayNode;
|
||||
scroll_->GetGeometryNode()->SetFrameSize(SizeF(700.0, 800.0));
|
||||
auto paintProperty = scroll_->GetPaintProperty<ScrollablePaintProperty>();
|
||||
auto paint = AceType::MakeRefPtr<ScrollablePaintMethod>(false, false);
|
||||
auto paint = AceType::MakeRefPtr<GridPaintMethod>(false, false, nullptr);
|
||||
/**
|
||||
* @tc.steps: step1. call UpdateFadingEdge with UpdateFadingEdge false.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user