!38122 新增tdd用例--0718

Merge pull request !38122 from kangchongtao/0718
This commit is contained in:
openharmony_ci 2024-07-19 05:27:17 +00:00 committed by Gitee
commit f86cf8b977
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 124 additions and 13 deletions

View File

@ -43,6 +43,36 @@ public:
static RefPtr<MockContainer> Current(); static RefPtr<MockContainer> Current();
static RefPtr<MockContainer> GetContainer(int32_t containerId); static RefPtr<MockContainer> GetContainer(int32_t containerId);
void SetIsFormRender(bool isFormRender) override
{
isFormRender_ = isFormRender;
}
bool IsFormRender() const override
{
return isFormRender_;
}
bool IsUIExtensionWindow() override
{
return isUIExtensionWindow_;
}
void SetIsUIExtensionWindow(bool isUIExtensionWindow)
{
isUIExtensionWindow_ = isUIExtensionWindow;
}
bool IsScenceBoardWindow() override
{
return isScenceBoardWindow_;
}
void SetIsScenceBoardWindow(bool isScenceBoardWindow)
{
isScenceBoardWindow_ = isScenceBoardWindow;
}
MOCK_METHOD(void, Initialize, (), (override)); MOCK_METHOD(void, Initialize, (), (override));
MOCK_METHOD(void, Destroy, (), (override)); MOCK_METHOD(void, Destroy, (), (override));
MOCK_METHOD(int32_t, GetInstanceId, (), (const, override)); MOCK_METHOD(int32_t, GetInstanceId, (), (const, override));
@ -68,6 +98,9 @@ public:
private: private:
RefPtr<TaskExecutor> taskExecutor_; RefPtr<TaskExecutor> taskExecutor_;
RefPtr<PipelineBase> pipelineContext_; RefPtr<PipelineBase> pipelineContext_;
bool isFormRender_ = false;
bool isUIExtensionWindow_ = false;
bool isScenceBoardWindow_ = false;
}; };
} // namespace OHOS::Ace } // namespace OHOS::Ace
#endif // FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H #endif // FOUNDATION_ACE_TEST_MOCK_CORE_COMMON_MOCK_CONTAINER_H

View File

@ -753,29 +753,39 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg017, TestSize.Level1)
manager->AddDragFrameNode(frameNode->GetId(), frameNode); manager->AddDragFrameNode(frameNode->GetId(), frameNode);
/** /**
* @tc.steps2: Call the function OnDragEvent with isDragged_=true, currentId_=DEFAULT_INT1 and DRAG_EVENT_END. * @tc.steps2: Call the function OnDragEvent with isDragged_=true, currentId_=DEFAULT_INT1 and
* DRAG_EVENT_START_FOR_CONTROLLER.
* @tc.expected: The currentId_ is equal to DEFAULT_INT1. * @tc.expected: The currentId_ is equal to DEFAULT_INT1.
*/ */
manager->isDragged_ = true; manager->isDragged_ = true;
manager->currentId_ = DEFAULT_INT1; manager->currentId_ = DEFAULT_INT1;
context_->OnDragEvent({ DEFAULT_INT1, DEFAULT_INT1 }, DragEventAction::DRAG_EVENT_END); context_->OnDragEvent({ DEFAULT_INT1, DEFAULT_INT1 }, DragEventAction::DRAG_EVENT_START_FOR_CONTROLLER);
EXPECT_EQ(manager->currentId_, DEFAULT_INT1); EXPECT_EQ(manager->currentId_, DEFAULT_INT1);
/** /**
* @tc.steps2: Call the function OnDragEvent with isDragged_=true, currentId_=DEFAULT_INT1 and DRAG_EVENT_MOVE. * @tc.steps2: Call the function OnDragEvent with isDragged_=true, currentId_=DEFAULT_INT1 and DRAG_EVENT_OUT.
* @tc.expected: The currentId_ is equal to DEFAULT_INT1. * @tc.expected: The currentId_ is equal to DEFAULT_INT1.
*/ */
manager->isDragged_ = true; manager->isDragged_ = true;
manager->currentId_ = DEFAULT_INT1; manager->currentId_ = DEFAULT_INT1;
context_->OnDragEvent({ DEFAULT_INT1, DEFAULT_INT1 }, DragEventAction::DRAG_EVENT_MOVE); context_->OnDragEvent({ DEFAULT_INT1, DEFAULT_INT1 }, DragEventAction::DRAG_EVENT_OUT);
EXPECT_EQ(manager->currentId_, DEFAULT_INT1); EXPECT_EQ(manager->currentId_, DEFAULT_INT1);
/** /**
* @tc.steps3: Call the function OnDragEvent with isDragged_=false, currentId_=DEFAULT_INT1 and DRAG_EVENT_END. * @tc.steps3: Call the function OnDragEvent with isDragged_=false, currentId_=DEFAULT_INT1 and DRAG_EVENT_START.
* @tc.expected: The currentId_ is equal to DEFAULT_INT1. * @tc.expected: The currentId_ is equal to DEFAULT_INT1.
*/ */
manager->isDragged_ = false; manager->isDragged_ = false;
manager->currentId_ = DEFAULT_INT1; manager->currentId_ = DEFAULT_INT1;
context_->OnDragEvent({ DEFAULT_INT10, DEFAULT_INT10 }, DragEventAction::DRAG_EVENT_START);
EXPECT_EQ(manager->currentId_, DEFAULT_INT1);
/**
* @tc.steps4: Call the function OnDragEvent with isDragged_=false, currentId_=DEFAULT_INT1 and DRAG_EVENT_END.
* @tc.expected: The currentId_ is changed to DEFAULT_INT10.
*/
manager->isDragged_ = false;
manager->currentId_ = DEFAULT_INT1;
context_->OnDragEvent({ DEFAULT_INT10, DEFAULT_INT10 }, DragEventAction::DRAG_EVENT_END); context_->OnDragEvent({ DEFAULT_INT10, DEFAULT_INT10 }, DragEventAction::DRAG_EVENT_END);
EXPECT_EQ(manager->currentId_, DEFAULT_INT1); EXPECT_EQ(manager->currentId_, DEFAULT_INT1);
@ -787,6 +797,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg017, TestSize.Level1)
manager->currentId_ = DEFAULT_INT1; manager->currentId_ = DEFAULT_INT1;
context_->OnDragEvent({ DEFAULT_INT10, DEFAULT_INT10 }, DragEventAction::DRAG_EVENT_MOVE); context_->OnDragEvent({ DEFAULT_INT10, DEFAULT_INT10 }, DragEventAction::DRAG_EVENT_MOVE);
EXPECT_EQ(manager->currentId_, DEFAULT_INT1); EXPECT_EQ(manager->currentId_, DEFAULT_INT1);
MockContainer::Current()->SetIsScenceBoardWindow(true);
context_->OnDragEvent({ DEFAULT_INT10, DEFAULT_INT10 }, DragEventAction::DRAG_EVENT_MOVE);
context_->SetIsDragging(false); context_->SetIsDragging(false);
EXPECT_FALSE(context_->IsDragging()); EXPECT_FALSE(context_->IsDragging());
context_->ResetDragging(); context_->ResetDragging();
@ -1238,7 +1250,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg025, TestSize.Level1)
{ "-multimodal" }, { "-rotation", "1", "2", "3" }, { "-animationscale", "1", "2", "3" }, { "-multimodal" }, { "-rotation", "1", "2", "3" }, { "-animationscale", "1", "2", "3" },
{ "-velocityscale", "1", "2", "3" }, { "-scrollfriction", "1", "2", "3" }, { "-threadstuck", "1", "2", "3" }, { "-velocityscale", "1", "2", "3" }, { "-scrollfriction", "1", "2", "3" }, { "-threadstuck", "1", "2", "3" },
{ "-rotation" }, { "-animationscale" }, { "-velocityscale" }, { "-scrollfriction" }, { "-threadstuck" }, { "-rotation" }, { "-animationscale" }, { "-velocityscale" }, { "-scrollfriction" }, { "-threadstuck" },
{ "test" } }; { "test" }, { "-navigation" }, { "-focuswindowscene" }, { "-focusmanager" }, { "-jsdump" }, { "-event" },
{ "-imagecache" }, { "-imagefilecache" }, { "-allelements" }, { "-default" }, { "-overlay" }, { "--stylus" } };
int turn = 0; int turn = 0;
for (; turn < params.size(); turn++) { for (; turn < params.size(); turn++) {
EXPECT_TRUE(context_->OnDumpInfo(params[turn])); EXPECT_TRUE(context_->OnDumpInfo(params[turn]));
@ -1926,6 +1939,8 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg092, TestSize.Level1)
ASSERT_NE(context_, nullptr); ASSERT_NE(context_, nullptr);
std::vector<Ace::RectF> rects; std::vector<Ace::RectF> rects;
context_->TriggerOverlayNodePositionsUpdateCallback(rects); context_->TriggerOverlayNodePositionsUpdateCallback(rects);
context_->RegisterOverlayNodePositionsUpdateCallback([](std::vector<Ace::RectF> rect) {});
context_->TriggerOverlayNodePositionsUpdateCallback(rects);
context_->windowManager_ = AceType::MakeRefPtr<WindowManager>(); context_->windowManager_ = AceType::MakeRefPtr<WindowManager>();
context_->windowModal_ = WindowModal::NORMAL; context_->windowModal_ = WindowModal::NORMAL;
NG::RectF containerModal; NG::RectF containerModal;
@ -1952,12 +1967,17 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg093, TestSize.Level1)
* @tc.expected: All pointer is non-null. * @tc.expected: All pointer is non-null.
*/ */
ASSERT_NE(context_, nullptr); ASSERT_NE(context_, nullptr);
ASSERT_NE(context_->GetWindow(), nullptr);
EXPECT_FALSE(context_->PrintVsyncInfoIfNeed()); EXPECT_FALSE(context_->PrintVsyncInfoIfNeed());
std::list<FrameInfo> dumpFrameInfos_; std::list<FrameInfo> dumpFrameInfos;
FrameInfo frameInfo; FrameInfo frameInfo;
dumpFrameInfos_.push_back(frameInfo); dumpFrameInfos.push_back(frameInfo);
context_->dumpFrameInfos_ = dumpFrameInfos;
EXPECT_FALSE(context_->PrintVsyncInfoIfNeed()); EXPECT_FALSE(context_->PrintVsyncInfoIfNeed());
context_->dumpFrameInfos_.back().frameRecvTime_ = -1;
EXPECT_FALSE(context_->PrintVsyncInfoIfNeed());
context_->dumpFrameInfos_.clear();
} }
/** /**
@ -1974,6 +1994,20 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg094, TestSize.Level1)
ASSERT_NE(context_, nullptr); ASSERT_NE(context_, nullptr);
context_->windowManager_ = AceType::MakeRefPtr<WindowManager>(); context_->windowManager_ = AceType::MakeRefPtr<WindowManager>();
SystemProperties::SetColorMode(ColorMode::DARK);
context_->SetAppBgColor(Color::BLACK);
context_->ChangeDarkModeBrightness();
context_->SetIsJsCard(true);
context_->ChangeDarkModeBrightness();
MockContainer::Current()->SetIsFormRender(true);
context_->ChangeDarkModeBrightness();
MockContainer::Current()->SetIsDynamicRender(true);
context_->ChangeDarkModeBrightness();
MockContainer::Current()->SetIsUIExtensionWindow(true);
context_->ChangeDarkModeBrightness();
context_->SetAppBgColor(Color::BLUE);
context_->ChangeDarkModeBrightness();
SystemProperties::SetColorMode(ColorMode::COLOR_MODE_UNDEFINED);
context_->ChangeDarkModeBrightness(); context_->ChangeDarkModeBrightness();
EXPECT_NE(context_->stageManager_, nullptr); EXPECT_NE(context_->stageManager_, nullptr);
} }

View File

@ -1354,8 +1354,11 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg076, TestSize.Level1)
pipeline->foldStatusChangedCallbackMap_.emplace(2, nullptr); pipeline->foldStatusChangedCallbackMap_.emplace(2, nullptr);
pipeline->foldDisplayModeChangedCallbackMap_.emplace(1, [](FoldDisplayMode foldDisplayMode) {}); pipeline->foldDisplayModeChangedCallbackMap_.emplace(1, [](FoldDisplayMode foldDisplayMode) {});
pipeline->foldDisplayModeChangedCallbackMap_.emplace(2, nullptr); pipeline->foldDisplayModeChangedCallbackMap_.emplace(2, nullptr);
pipeline->transformHintChangedCallbackMap_.emplace(1, nullptr);
pipeline->transformHintChangedCallbackMap_.emplace(2, [](uint32_t num) {});
pipeline->OnFoldStatusChange(FoldStatus::EXPAND); pipeline->OnFoldStatusChange(FoldStatus::EXPAND);
pipeline->OnFoldDisplayModeChange(FoldDisplayMode::FULL); pipeline->OnFoldDisplayModeChange(FoldDisplayMode::FULL);
pipeline->OnTransformHintChanged(0);
EXPECT_NE(PipelineContext::GetContextByContainerId(0), nullptr); EXPECT_NE(PipelineContext::GetContextByContainerId(0), nullptr);
pipeline->AddDirtyPropertyNode(frameNode); pipeline->AddDirtyPropertyNode(frameNode);
EXPECT_TRUE(pipeline->hasIdleTasks_); EXPECT_TRUE(pipeline->hasIdleTasks_);
@ -1446,18 +1449,19 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg078, TestSize.Level1)
*/ */
auto formCallback = [](bool visible) {}; auto formCallback = [](bool visible) {};
pipeline->ContainerModalUnFocus(); pipeline->ContainerModalUnFocus();
pipeline->UpdateTitleInTargetPos(false, 0); pipeline->windowModal_ = WindowModal::NORMAL;
pipeline->SetCloseButtonStatus(false);
pipeline->SetContainerModalTitleVisible(false, true);
pipeline->SetContainerModalTitleHeight(0); pipeline->SetContainerModalTitleHeight(0);
pipeline->UpdateTitleInTargetPos(false, 0);
pipeline->SetContainerModalTitleVisible(false, true);
pipeline->SetCloseButtonStatus(false);
pipeline->GetContainerModalTitleHeight(); pipeline->GetContainerModalTitleHeight();
pipeline->windowModal_ = WindowModal::CONTAINER_MODAL; pipeline->windowModal_ = WindowModal::CONTAINER_MODAL;
pipeline->GetContainerModalTitleHeight();
pipeline->ContainerModalUnFocus(); pipeline->ContainerModalUnFocus();
pipeline->UpdateTitleInTargetPos(false, 0); pipeline->UpdateTitleInTargetPos(false, 0);
pipeline->SetCloseButtonStatus(true); pipeline->SetCloseButtonStatus(true);
pipeline->SetContainerModalTitleVisible(true, false); pipeline->SetContainerModalTitleVisible(true, false);
pipeline->SetContainerModalTitleHeight(0); pipeline->SetContainerModalTitleHeight(0);
pipeline->GetContainerModalTitleHeight();
pipeline->SetAppBgColor(Color::BLACK); pipeline->SetAppBgColor(Color::BLACK);
auto frameNode1 = FrameNode::GetOrCreateFrameNode("test", 6, nullptr); auto frameNode1 = FrameNode::GetOrCreateFrameNode("test", 6, nullptr);
pipeline->activeNode_ = AceType::WeakClaim(AceType::RawPtr(frameNode1)); pipeline->activeNode_ = AceType::WeakClaim(AceType::RawPtr(frameNode1));
@ -1716,7 +1720,7 @@ HWTEST_F(PipelineContextTestNg, UITaskSchedulerTestNg009, TestSize.Level1)
taskScheduler.FlushPersistAfterLayoutTask(); taskScheduler.FlushPersistAfterLayoutTask();
taskScheduler.FlushAfterRenderTask(); taskScheduler.FlushAfterRenderTask();
taskScheduler.FlushAfterLayoutCallbackInImplicitAnimationTask(); taskScheduler.FlushAfterLayoutCallbackInImplicitAnimationTask();
/** /**
* @tc.steps3: Call FlushAfterLayoutCallbackInImplicitAnimationTask/FlushTask * @tc.steps3: Call FlushAfterLayoutCallbackInImplicitAnimationTask/FlushTask
*/ */
@ -1778,5 +1782,45 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg097, TestSize.Level1)
context_->RegisterTouchEventListener(touchEventCallback); context_->RegisterTouchEventListener(touchEventCallback);
ASSERT_EQ(context_->listenerVector_.size(), 0); ASSERT_EQ(context_->listenerVector_.size(), 0);
} }
/**
* @tc.name: PipelineContextTestNg098
* @tc.desc: Test the function AddChangedFrameNode
* @tc.type: FUNC
*/
HWTEST_F(PipelineContextTestNg, PipelineContextTestNg098, TestSize.Level1)
{
/**
* @tc.steps1: AddChangedFrameNode
*/
auto frameNode = AceType::MakeRefPtr<FrameNode>("test1", -1, AceType::MakeRefPtr<Pattern>(), false);
context_->AddChangedFrameNode(frameNode);
EXPECT_EQ(context_->changedNodes_.size(), 1);
context_->AddChangedFrameNode(frameNode);
EXPECT_EQ(context_->changedNodes_.size(), 1);
context_->CleanNodeChangeFlag();
EXPECT_EQ(context_->changedNodes_.size(), 0);
}
/**
* @tc.name: PipelineContextTestNg099
* @tc.desc: Test the function AddFrameNodeChangeListener
* @tc.type: FUNC
*/
HWTEST_F(PipelineContextTestNg, PipelineContextTestNg099, TestSize.Level1)
{
/**
* @tc.steps1: AddFrameNodeChangeListener
*/
auto frameNode = AceType::MakeRefPtr<FrameNode>("test1", -1, AceType::MakeRefPtr<Pattern>(), false);
context_->AddFrameNodeChangeListener(frameNode);
context_->FlushNodeChangeFlag();
EXPECT_EQ(context_->changeInfoListeners_.size(), 1);
context_->AddFrameNodeChangeListener(frameNode);
EXPECT_EQ(context_->changeInfoListeners_.size(), 1);
context_->RemoveFrameNodeChangeListener(frameNode);
context_->FlushNodeChangeFlag();
EXPECT_EQ(context_->changeInfoListeners_.size(), 0);
}
} // namespace NG } // namespace NG
} // namespace OHOS::Ace } // namespace OHOS::Ace