mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
!49233 Image tdd覆盖率提升
Merge pull request !49233 from zhoulianhai/image_tdd
This commit is contained in:
commit
2217819dc5
@ -1850,4 +1850,68 @@ HWTEST_F(ImageTestNg, TestImageResizable001, TestSize.Level1)
|
||||
EXPECT_EQ(imageRenderProperty->GetImageResizableSliceValue(defaultImageResizableSlice), tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ImagePatternCreateModifierContent001
|
||||
* @tc.desc: Test CreateModifierContent.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImageTestNg, ImagePatternCreateModifierContent001, TestSize.Level1)
|
||||
{
|
||||
auto frameNode = ImageTestNg::CreateImageNode(IMAGE_SRC_URL, ALT_SRC_URL);
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
EXPECT_EQ(frameNode->GetTag(), V2::IMAGE_ETS_TAG);
|
||||
auto imagePattern = frameNode->GetPattern<ImagePattern>();
|
||||
ASSERT_NE(imagePattern, nullptr);
|
||||
frameNode->MarkModifyDone();
|
||||
ASSERT_NE(imagePattern->loadingCtx_, nullptr);
|
||||
ASSERT_NE(imagePattern->altLoadingCtx_, nullptr);
|
||||
auto contentModifier = AceType::MakeRefPtr<ImageContentModifier>();
|
||||
ASSERT_NE(contentModifier, nullptr);
|
||||
/**
|
||||
* @tc.cases: case1. Test content modifier onDraw.
|
||||
*/
|
||||
EXPECT_TRUE(imagePattern->CreateNodePaintMethod() != nullptr);
|
||||
Testing::MockCanvas canvas;
|
||||
DrawingContext context { canvas, WIDTH, HEIGHT };
|
||||
auto canvasImage = AceType::MakeRefPtr<NG::MockCanvasImage>();
|
||||
CanvasImageModifierWrapper wrapper;
|
||||
wrapper.SetCanvasImage(canvasImage);
|
||||
contentModifier->SetCanvasImageWrapper(wrapper);
|
||||
ASSERT_NE(contentModifier->canvasImageWrapper_->Get().GetCanvasImage(), nullptr);
|
||||
contentModifier->onDraw(context);
|
||||
EXPECT_FALSE(contentModifier->sensitive_->Get());
|
||||
/**
|
||||
* @tc.cases: case2. Set sensitive true.
|
||||
*/
|
||||
contentModifier->sensitive_->Set(true);
|
||||
contentModifier->onDraw(context);
|
||||
EXPECT_TRUE(contentModifier->sensitive_->Get());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ImageReset001
|
||||
* @tc.desc: Test ImageReset.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImageTestNg, ImageReset001, TestSize.Level1)
|
||||
{
|
||||
ImageModelNG image;
|
||||
RefPtr<PixelMap> pixMap = nullptr;
|
||||
ImageInfoConfig imageInfoConfig;
|
||||
imageInfoConfig.src = std::make_shared<std::string>("");
|
||||
imageInfoConfig.bundleName = BUNDLE_NAME;
|
||||
imageInfoConfig.moduleName = MODULE_NAME;
|
||||
image.Create(imageInfoConfig, pixMap);
|
||||
auto frameNode = AceType::DynamicCast<FrameNode>(ViewStackProcessor::GetInstance()->Finish());
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
EXPECT_EQ(frameNode->GetTag(), V2::IMAGE_ETS_TAG);
|
||||
|
||||
auto imagePattern = frameNode->GetPattern<ImagePattern>();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
|
||||
imagePattern->SetNeedLoadAlt(true);
|
||||
image.ResetImage();
|
||||
EXPECT_EQ(imagePattern->needLoadAlt_, true);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -1954,4 +1954,98 @@ HWTEST_F(ImageTestOneNg, ImageModelNGFailedTest001, TestSize.Level1)
|
||||
ImageModelNGFailedTest001_Properties03(image);
|
||||
frameNode->MarkModifyDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ImageImageInterpolation001
|
||||
* @tc.desc: Test ImageGetImageInterpolation.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImageTestOneNg, ImageImageInterpolation001, TestSize.Level1)
|
||||
{
|
||||
ImageModelNG image;
|
||||
RefPtr<PixelMap> pixMap = nullptr;
|
||||
ImageInfoConfig imageInfoConfig;
|
||||
imageInfoConfig.src = std::make_shared<std::string>(IMAGE_SRC_URL);
|
||||
imageInfoConfig.bundleName = BUNDLE_NAME;
|
||||
imageInfoConfig.moduleName = MODULE_NAME;
|
||||
image.Create(imageInfoConfig, pixMap);
|
||||
image.SetAlt(ImageSourceInfo { ALT_SRC_URL });
|
||||
image.SetSyncMode(true);
|
||||
image.SetImageFill(SVG_FILL_COLOR_DEFAULT);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
image.SetBorderRadius(frameNode, IMAGE_SOURCEINFO_HEIGHT);
|
||||
auto imagePattern = frameNode->GetPattern<ImagePattern>();
|
||||
ASSERT_NE(imagePattern, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.cases: case1. ImageInterpolation LOW.
|
||||
*/
|
||||
image.SetImageInterpolation(ImageInterpolation::LOW);
|
||||
|
||||
auto imageRenderProperty = frameNode->GetPaintProperty<ImageRenderProperty>();
|
||||
ASSERT_NE(imageRenderProperty, nullptr);
|
||||
imagePattern->DumpRenderInfo();
|
||||
EXPECT_EQ(imageRenderProperty->GetImageInterpolation().value(), ImageInterpolation::LOW);
|
||||
|
||||
/**
|
||||
* @tc.cases: case2. ImageInterpolation MEDIUM.
|
||||
*/
|
||||
image.SetImageInterpolation(ImageInterpolation::MEDIUM);
|
||||
imagePattern->DumpRenderInfo();
|
||||
EXPECT_EQ(imageRenderProperty->GetImageInterpolation().value(), ImageInterpolation::MEDIUM);
|
||||
|
||||
/**
|
||||
* @tc.cases: case3. ImageInterpolation HIGH.
|
||||
*/
|
||||
image.SetImageInterpolation(ImageInterpolation::HIGH);
|
||||
imagePattern->DumpRenderInfo();
|
||||
EXPECT_EQ(imageRenderProperty->GetImageInterpolation().value(), ImageInterpolation::HIGH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ImageDynamicRangeMode 001
|
||||
* @tc.desc: Test ImageDynamicRangeMode.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImageTestOneNg, ImageDynamicRangeMode001, TestSize.Level1)
|
||||
{
|
||||
ImageModelNG image;
|
||||
RefPtr<PixelMap> pixMap = nullptr;
|
||||
ImageInfoConfig imageInfoConfig;
|
||||
imageInfoConfig.src = std::make_shared<std::string>(IMAGE_SRC_URL);
|
||||
imageInfoConfig.bundleName = BUNDLE_NAME;
|
||||
imageInfoConfig.moduleName = MODULE_NAME;
|
||||
image.Create(imageInfoConfig, pixMap);
|
||||
image.SetAlt(ImageSourceInfo { ALT_SRC_URL });
|
||||
image.SetSyncMode(true);
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
ASSERT_NE(frameNode, nullptr);
|
||||
auto imagePattern = frameNode->GetPattern<ImagePattern>();
|
||||
ASSERT_NE(imagePattern, nullptr);
|
||||
|
||||
/**
|
||||
* @tc.cases: case1. DynamicRangeMode HIGH.
|
||||
*/
|
||||
image.SetDynamicRangeMode(DynamicRangeMode::HIGH);
|
||||
|
||||
auto imageRenderProperty = frameNode->GetPaintProperty<ImageRenderProperty>();
|
||||
ASSERT_NE(imageRenderProperty, nullptr);
|
||||
imagePattern->DumpRenderInfo();
|
||||
EXPECT_EQ(imageRenderProperty->GetDynamicMode().value(), DynamicRangeMode::HIGH);
|
||||
|
||||
/**
|
||||
* @tc.cases: case2. DynamicRangeMode CONSTRAINT.
|
||||
*/
|
||||
image.SetDynamicRangeMode(DynamicRangeMode::CONSTRAINT);
|
||||
imagePattern->DumpRenderInfo();
|
||||
EXPECT_EQ(imageRenderProperty->GetDynamicMode().value(), DynamicRangeMode::CONSTRAINT);
|
||||
|
||||
/**
|
||||
* @tc.cases: case2. DynamicRangeMode STANDARD.
|
||||
*/
|
||||
image.SetDynamicRangeMode(DynamicRangeMode::STANDARD);
|
||||
imagePattern->DumpRenderInfo();
|
||||
EXPECT_EQ(imageRenderProperty->GetDynamicMode().value(), DynamicRangeMode::STANDARD);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
Loading…
Reference in New Issue
Block a user