mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 09:10:54 +00:00
tdd用例补充
Signed-off-by: luhan <luhan22@huawei.com>
This commit is contained in:
parent
9b3a1d8270
commit
95bf04a754
@ -137,6 +137,10 @@ HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, PlaybackInCorrespondThreadTest,
|
||||
auto drawable = std::make_shared<RSCanvasDrawingRenderNodeDrawable>(std::move(node));
|
||||
drawable->PostPlaybackInCorrespondThread();
|
||||
ASSERT_FALSE(drawable->canvas_);
|
||||
|
||||
drawable->renderParams_ = std::make_unique<RSRenderParams>(0);
|
||||
drawable->PostPlaybackInCorrespondThread();
|
||||
ASSERT_FALSE(drawable->canvas_);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,6 +187,26 @@ HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, InitSurfaceForVKTest, TestSize.L
|
||||
EXPECT_EQ(result, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: InitSurfaceForGL
|
||||
* @tc.desc: Test InitSurfaceForGL Can Run
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1KMY
|
||||
*/
|
||||
HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, InitSurfaceForGLTest, TestSize.Level1)
|
||||
{
|
||||
auto node = std::make_shared<RSRenderNode>(0);
|
||||
auto drawable = std::make_shared<RSCanvasDrawingRenderNodeDrawable>(std::move(node));
|
||||
Drawing::Canvas drawingCanvas;
|
||||
RSPaintFilterCanvas canvas(&drawingCanvas);
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
drawable->surface_ = std::make_shared<Drawing::Surface>();
|
||||
drawable->surface_->cachedCanvas_ = std::make_shared<Drawing::Canvas>(0, 0);
|
||||
bool result = drawable->InitSurfaceForGL(width, height, canvas);
|
||||
EXPECT_EQ(result, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FlushForGL
|
||||
* @tc.desc: Test If FlushForGL Can Run
|
||||
@ -568,4 +592,17 @@ HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, ResetSurfaceWithTextureTest, Tes
|
||||
ASSERT_EQ(result, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @tc.name: Purge
|
||||
* @tc.desc: Test If Purge Can Run
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1KMY
|
||||
*/
|
||||
HWTEST_F(RSCanvasDrawingRenderNodeDrawableTest, PurgeTest, TestSize.Level1)
|
||||
{
|
||||
auto node = std::make_shared<RSRenderNode>(0);
|
||||
auto drawable = std::make_shared<RSCanvasDrawingRenderNodeDrawable>(std::move(node));
|
||||
drawable->Purge();
|
||||
}
|
||||
}
|
||||
|
@ -431,6 +431,19 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, HardCursorCreateLayerTest, TestSize.Le
|
||||
|
||||
auto result = displayDrawable_->HardCursorCreateLayer(processor);
|
||||
ASSERT_EQ(result, false);
|
||||
|
||||
HardCursorInfo hardInfo;
|
||||
hardInfo.id = 1;
|
||||
auto renderNode = std::make_shared<RSRenderNode>(hardInfo.id);
|
||||
hardInfo.drawablePtr = RSRenderNodeDrawableAdapter::OnGenerate(renderNode);
|
||||
EXPECT_NE(hardInfo.drawablePtr, nullptr);
|
||||
result = displayDrawable_->HardCursorCreateLayer(processor);
|
||||
ASSERT_EQ(result, false);
|
||||
|
||||
NodeId id = 1;
|
||||
hardInfo.drawablePtr->renderParams_ = std::make_unique<RSRenderParams>(id);
|
||||
result = displayDrawable_->HardCursorCreateLayer(processor);
|
||||
ASSERT_EQ(result, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -567,6 +580,13 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, CheckFilterCacheFullyCoveredTest, Test
|
||||
|
||||
renderDrawableAdapter->renderParams_->SetGlobalAlpha(0.f);
|
||||
RSDisplayRenderNodeDrawable::CheckFilterCacheFullyCovered(*surfaceParams, screenRect);
|
||||
|
||||
renderDrawableAdapter->renderParams_->SetHasBlurFilter(true);
|
||||
renderDrawableAdapter->renderParams_->SetGlobalAlpha(1.f);
|
||||
renderDrawableAdapter->renderParams_->SetHasGlobalCorner(false);
|
||||
renderDrawableAdapter->renderParams_->SetNodeType(RSRenderNodeType::CANVAS_NODE);
|
||||
renderDrawableAdapter->renderParams_->SetEffectNodeShouldPaint(true);
|
||||
RSDisplayRenderNodeDrawable::CheckFilterCacheFullyCovered(*surfaceParams, screenRect);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -581,6 +601,13 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, OnDrawTest, TestSize.Level1)
|
||||
Drawing::Canvas canvas;
|
||||
displayDrawable_->OnDraw(canvas);
|
||||
ASSERT_NE(displayDrawable_->renderParams_, nullptr);
|
||||
|
||||
HardCursorInfo hardInfo;
|
||||
hardInfo.id = 1;
|
||||
auto renderNode = std::make_shared<RSRenderNode>(hardInfo.id);
|
||||
hardInfo.drawablePtr = RSRenderNodeDrawableAdapter::OnGenerate(renderNode);
|
||||
displayDrawable_->OnDraw(canvas);
|
||||
ASSERT_NE(displayDrawable_->renderParams_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -656,7 +683,7 @@ HWTEST_F(RSDisplayRenderNodeDrawableTest, DrawMirrorTest, TestSize.Level1)
|
||||
ASSERT_NE(renderNode_, nullptr);
|
||||
ASSERT_NE(displayDrawable_, nullptr);
|
||||
ASSERT_NE(displayDrawable_->renderParams_, nullptr);
|
||||
|
||||
|
||||
displayDrawable_->PrepareOffscreenRender(*displayDrawable_);
|
||||
auto params = static_cast<RSDisplayRenderParams*>(displayDrawable_->GetRenderParams().get());
|
||||
auto processor = RSProcessorFactory::CreateProcessor(params->GetCompositeType());
|
||||
|
@ -658,6 +658,22 @@ HWTEST_F(RSRenderNodeDrawableTest, DrawCachedImageTest, TestSize.Level1)
|
||||
drawable->DrawCachedImage(paintFilterCanvas, params.GetCacheSize());
|
||||
drawable->ClearCachedSurface();
|
||||
|
||||
Drawing::Canvas canvas1(0, 0); // width and height
|
||||
RSPaintFilterCanvas paintFilterCanvas1(&canvas1);
|
||||
drawable->DrawCachedImage(paintFilterCanvas1, params.GetCacheSize());
|
||||
drawable->ClearCachedSurface();
|
||||
|
||||
Drawing::Canvas canvas2(10, 10); // width and height
|
||||
RSPaintFilterCanvas paintFilterCanvas2(&canvas2);
|
||||
drawable->DrawCachedImage(paintFilterCanvas2, params.GetCacheSize());
|
||||
|
||||
auto rsFilter = std::make_shared<RSFilter>();
|
||||
drawable->DrawCachedImage(paintFilterCanvas2, params.GetCacheSize(), rsFilter);
|
||||
drawable->isDrawAreaEnable_ = DrawAreaEnableState::DRAW_AREA_ENABLE;
|
||||
drawable->DrawCachedImage(paintFilterCanvas2, params.GetCacheSize());
|
||||
drawable->ClearCachedSurface();
|
||||
drawable->isDrawAreaEnable_ = DrawAreaEnableState::DRAW_AREA_INIT;
|
||||
|
||||
drawable->cachedSurface_ = std::make_shared<Drawing::Surface>();
|
||||
drawable->cachedImage_ = std::make_shared<Drawing::Image>();
|
||||
auto drawingCanvas = std::make_shared<Drawing::Canvas>();
|
||||
@ -850,4 +866,60 @@ HWTEST_F(RSRenderNodeDrawableTest, CheckRegionAndDrawWithFilter, TestSize.Level1
|
||||
drawable->CheckRegionAndDrawWithFilter(begin, filterInfoVec, canvas, params);
|
||||
ASSERT_FALSE(drawable->filterInfoVec_.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: UpdateCacheSurface
|
||||
* @tc.desc: Test If UpdateCacheSurface Can Run
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1KMY
|
||||
*/
|
||||
HWTEST_F(RSRenderNodeDrawableTest, UpdateCacheSurfaceTest, TestSize.Level1)
|
||||
{
|
||||
auto drawable = RSRenderNodeDrawableTest::CreateDrawable();
|
||||
Drawing::Canvas canvas;
|
||||
RSRenderParams params(RSRenderNodeDrawableTest::id);
|
||||
RSPaintFilterCanvas paintFilterCanvas(&canvas);
|
||||
drawable->UpdateCacheSurface(paintFilterCanvas, params);
|
||||
ASSERT_FALSE(params.GetRSFreezeFlag());
|
||||
|
||||
Drawing::Canvas canvas1(10, 10); // width and height
|
||||
RSPaintFilterCanvas paintFilterCanvas1(&canvas1);
|
||||
drawable->UpdateCacheSurface(paintFilterCanvas1, params);
|
||||
ASSERT_EQ(params.foregroundFilterCache_, nullptr);
|
||||
|
||||
params.freezeFlag_ = true;
|
||||
bool includeProperty = true;
|
||||
params.SetDrawingCacheIncludeProperty(includeProperty);
|
||||
drawable->UpdateCacheSurface(paintFilterCanvas1, params);
|
||||
ASSERT_EQ(params.foregroundFilterCache_, nullptr);
|
||||
ASSERT_TRUE(params.GetRSFreezeFlag());
|
||||
|
||||
|
||||
params.foregroundFilterCache_ = std::make_shared<RSFilter>();
|
||||
drawable->UpdateCacheSurface(paintFilterCanvas1, params);
|
||||
ASSERT_NE(params.foregroundFilterCache_, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ProcessedNodeCount
|
||||
* @tc.desc: Test ProcessedNodeCount
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIB1KMY
|
||||
*/
|
||||
HWTEST_F(RSRenderNodeDrawableTest, ProcessedNodeCountTest, TestSize.Level1)
|
||||
{
|
||||
auto drawable = RSRenderNodeDrawableTest::CreateDrawable();
|
||||
|
||||
drawable->ClearTotalProcessedNodeCount();
|
||||
drawable->ClearProcessedNodeCount();
|
||||
drawable->TotalProcessedNodeCountInc();
|
||||
drawable->ProcessedNodeCountInc();
|
||||
ASSERT_EQ(drawable->GetTotalProcessedNodeCount(), 1);
|
||||
ASSERT_EQ(drawable->GetProcessedNodeCount(), 1);
|
||||
|
||||
drawable->ClearTotalProcessedNodeCount();
|
||||
drawable->ClearProcessedNodeCount();
|
||||
ASSERT_EQ(drawable->GetTotalProcessedNodeCount(), 0);
|
||||
ASSERT_EQ(drawable->GetProcessedNodeCount(), 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user