Repeat Node Debug日志输出增加nodeId,解冲突

Signed-off-by: maoruihao <maoruihao@huawei.com>
This commit is contained in:
maoruihao 2024-11-18 21:07:41 +08:00
commit 4184c6a2c0
9 changed files with 671 additions and 34 deletions

View File

@ -206,7 +206,7 @@ void ClickRecognizer::OnRejected()
void ClickRecognizer::HandleTouchDownEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW,
"Id:%{public}d, click %{public}d down, ETF: %{public}d, CTP: %{public}d, state: %{public}d",
event.touchEventId, event.id, equalsToFingers_, currentTouchPointsNum_, refereeState_);
if (!firstInputTime_.has_value()) {
@ -303,7 +303,7 @@ void ClickRecognizer::TriggerClickAccepted(const TouchEvent& event)
void ClickRecognizer::HandleTouchUpEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, click %{public}d up, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, click %{public}d up, state: %{public}d", event.touchEventId,
event.id, refereeState_);
auto pipeline = PipelineBase::GetCurrentContextSafelyWithCheck();
// In a card scenario, determine the interval between finger pressing and finger lifting. Delete this section of
@ -376,7 +376,7 @@ void ClickRecognizer::HandleTouchMoveEvent(const TouchEvent& event)
void ClickRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, click %{public}d cancel", event.touchEventId, event.id);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, click %{public}d cancel", event.touchEventId, event.id);
if (IsRefereeFinished()) {
return;
}

View File

@ -111,7 +111,7 @@ void LongPressRecognizer::ThumbnailTimer(int32_t time)
void LongPressRecognizer::HandleTouchDownEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d down, state: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d down, state: %{public}d",
event.touchEventId, event.id, refereeState_);
if (!firstInputTime_.has_value()) {
firstInputTime_ = event.time;
@ -170,7 +170,7 @@ void LongPressRecognizer::HandleTouchDownEvent(const TouchEvent& event)
void LongPressRecognizer::HandleTouchUpEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d up, state: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d up, state: %{public}d",
event.touchEventId, event.id, refereeState_);
auto context = PipelineContext::GetCurrentContextSafelyWithCheck();
CHECK_NULL_VOID(context);
@ -223,7 +223,7 @@ void LongPressRecognizer::HandleTouchMoveEvent(const TouchEvent& event)
void LongPressRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d cancel, TPS:%{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, LongPress %{public}d cancel, TPS:%{public}d",
event.touchEventId, event.id, static_cast<int32_t>(touchPoints_.size()));
if (refereeState_ == RefereeState::FAIL) {
return;

View File

@ -190,7 +190,7 @@ void PanRecognizer::HandleTouchDownEvent(const TouchEvent& event)
firstInputTime_ = event.time;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d down, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d down, state: %{public}d", event.touchEventId,
event.id, refereeState_);
fingers_ = newFingers_;
distance_ = newDistance_;
@ -243,7 +243,7 @@ void PanRecognizer::HandleTouchDownEvent(const AxisEvent& event)
if (event.isRotationEvent) {
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d axis start, state:%{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d axis start, state:%{public}d",
event.touchEventId, event.id, refereeState_);
fingers_ = newFingers_;
distance_ = newDistance_;
@ -277,7 +277,7 @@ void PanRecognizer::HandleTouchDownEvent(const AxisEvent& event)
void PanRecognizer::HandleTouchUpEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW,
"Id:%{public}d, pan %{public}d up, state: %{public}d, currentFingers: %{public}d, fingers: %{public}d",
event.touchEventId, event.id, refereeState_, currentFingers_, fingers_);
if (fingersId_.find(event.id) != fingersId_.end()) {
@ -330,7 +330,7 @@ void PanRecognizer::HandleTouchUpEvent(const TouchEvent& event)
void PanRecognizer::HandleTouchUpEvent(const AxisEvent& event)
{
isTouchEventFinished_ = false;
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d axis end, state: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d axis end, state: %{public}d",
event.touchEventId, event.id, refereeState_);
// if axisEvent received rotateEvent, no need to active Pan recognizer.
if (event.isRotationEvent) {
@ -505,7 +505,7 @@ bool PanRecognizer::HandlePanAccept()
void PanRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d cancel", event.touchEventId, event.id);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan %{public}d cancel", event.touchEventId, event.id);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;
@ -524,7 +524,7 @@ void PanRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
void PanRecognizer::HandleTouchCancelEvent(const AxisEvent& event)
{
isTouchEventFinished_ = false;
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan axis cancel", event.touchEventId);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pan axis cancel", event.touchEventId);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;

View File

@ -78,7 +78,7 @@ bool PinchRecognizer::IsCtrlBeingPressed(const AxisEvent& event)
void PinchRecognizer::HandleTouchDownEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch %{public}d down, begin to detect pinch,"
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch %{public}d down, begin to detect pinch,"
"state: %{public}d", event.touchEventId, event.id, refereeState_);
if (touchPoints_.size() == 1 && refereeState_ == RefereeState::FAIL) {
refereeState_ = RefereeState::READY;
@ -123,7 +123,7 @@ void PinchRecognizer::HandleTouchDownEvent(const AxisEvent& event)
if (IsRefereeFinished()) {
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch axis start, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch axis start, state: %{public}d", event.touchEventId,
refereeState_);
if (refereeState_ == RefereeState::READY && (NearEqual(event.pinchAxisScale, 1.0) || IsCtrlBeingPressed(event))) {
scale_ = 1.0f;
@ -144,7 +144,7 @@ void PinchRecognizer::HandleTouchUpEvent(const TouchEvent& event)
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW,
"Id:%{public}d, pinch %{public}d up, state: %{public}d, activeSize:%{public}d, fingers:%{public}d",
event.touchEventId, event.id, refereeState_, static_cast<int32_t>(activeFingers_.size()), fingers_);
if (static_cast<int32_t>(activeFingers_.size()) < fingers_ && refereeState_ != RefereeState::SUCCEED) {
@ -178,7 +178,7 @@ void PinchRecognizer::HandleTouchUpEvent(const TouchEvent& event)
void PinchRecognizer::HandleTouchUpEvent(const AxisEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch axis end, state: %{public}d, isPinchEnd: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch axis end, state: %{public}d, isPinchEnd: %{public}d",
event.touchEventId, refereeState_, isPinchEnd_);
// if axisEvent received rotateEvent, no need to active Pinch recognizer.
if (isPinchEnd_ || event.isRotationEvent) {
@ -304,7 +304,7 @@ void PinchRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
if (!IsActiveFinger(event.id)) {
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch %{public}d cancel", event.touchEventId, event.id);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch %{public}d cancel", event.touchEventId, event.id);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;
@ -321,7 +321,7 @@ void PinchRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
void PinchRecognizer::HandleTouchCancelEvent(const AxisEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch axis cancel", event.touchEventId);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, pinch axis cancel", event.touchEventId);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;

View File

@ -67,7 +67,7 @@ void RotationRecognizer::OnRejected()
void RotationRecognizer::HandleTouchDownEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation %{public}d down, state: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation %{public}d down, state: %{public}d",
event.touchEventId, event.id, refereeState_);
if (!firstInputTime_.has_value()) {
firstInputTime_ = event.time;
@ -104,7 +104,7 @@ void RotationRecognizer::HandleTouchDownEvent(const AxisEvent& event)
if (!event.isRotationEvent) {
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation axis start, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation axis start, state: %{public}d", event.touchEventId,
refereeState_);
lastAxisEvent_ = event;
touchPoints_[event.id] = TouchEvent();
@ -123,7 +123,7 @@ void RotationRecognizer::HandleTouchUpEvent(const TouchEvent& event)
if (!IsActiveFinger(event.id)) {
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation %{public}d up, state: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation %{public}d up, state: %{public}d",
event.touchEventId, event.id, refereeState_);
if (static_cast<int32_t>(activeFingers_.size()) < DEFAULT_ROTATION_FINGERS &&
refereeState_ != RefereeState::SUCCEED) {
@ -156,7 +156,7 @@ void RotationRecognizer::HandleTouchUpEvent(const TouchEvent& event)
void RotationRecognizer::HandleTouchUpEvent(const AxisEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation axis end, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation axis end, state: %{public}d", event.touchEventId,
refereeState_);
// if rotation recognizer received another axisEvent, no need to active.
if (!event.isRotationEvent) {
@ -264,7 +264,7 @@ void RotationRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
if (!IsActiveFinger(event.id)) {
return;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation %{public}d cancel", event.touchEventId, event.id);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation %{public}d cancel", event.touchEventId, event.id);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;
@ -282,7 +282,7 @@ void RotationRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
void RotationRecognizer::HandleTouchCancelEvent(const AxisEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation axis cancel", event.touchEventId);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, rotation axis cancel", event.touchEventId);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;

View File

@ -88,7 +88,7 @@ void SwipeRecognizer::HandleTouchDownEvent(const TouchEvent& event)
firstInputTime_ = event.time;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe %{public}d down, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe %{public}d down, state: %{public}d", event.touchEventId,
event.id, refereeState_);
if (fingers_ > MAX_SWIPE_FINGERS) {
Adjudicate(Claim(this), GestureDisposal::REJECT);
@ -127,7 +127,7 @@ void SwipeRecognizer::HandleTouchDownEvent(const AxisEvent& event)
if (!firstInputTime_.has_value()) {
firstInputTime_ = event.time;
}
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe axis start, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe axis start, state: %{public}d", event.touchEventId,
refereeState_);
if (direction_.type == SwipeDirection::NONE) {
Adjudicate(Claim(this), GestureDisposal::REJECT);
@ -146,7 +146,7 @@ void SwipeRecognizer::HandleTouchDownEvent(const AxisEvent& event)
void SwipeRecognizer::HandleTouchUpEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe %{public}d up, state: %{public}d", event.touchEventId,
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe %{public}d up, state: %{public}d", event.touchEventId,
event.id, refereeState_);
if (fingersId_.find(event.id) != fingersId_.end()) {
fingersId_.erase(event.id);
@ -191,7 +191,7 @@ void SwipeRecognizer::HandleTouchUpEvent(const TouchEvent& event)
void SwipeRecognizer::HandleTouchUpEvent(const AxisEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe axis end, state: %{public}d",
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe axis end, state: %{public}d",
event.touchEventId, refereeState_);
globalPoint_ = Point(event.x, event.y);
touchPoints_[event.id] = TouchEvent();
@ -305,7 +305,7 @@ void SwipeRecognizer::HandleTouchMoveEvent(const AxisEvent& event)
void SwipeRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe %{public}d cancel", event.touchEventId, event.id);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe %{public}d cancel", event.touchEventId, event.id);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;
@ -318,7 +318,7 @@ void SwipeRecognizer::HandleTouchCancelEvent(const TouchEvent& event)
void SwipeRecognizer::HandleTouchCancelEvent(const AxisEvent& event)
{
TAG_LOGI(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe axis cancel", event.touchEventId);
TAG_LOGD(AceLogTag::ACE_INPUTKEYFLOW, "Id:%{public}d, swipe axis cancel", event.touchEventId);
if ((refereeState_ != RefereeState::SUCCEED) && (refereeState_ != RefereeState::FAIL)) {
Adjudicate(AceType::Claim(this), GestureDisposal::REJECT);
return;

View File

@ -73,10 +73,9 @@ void RepeatVirtualScrollNode::DoSetActiveChildRange(
cacheStart = 0;
cacheEnd = 0;
}
TAG_LOGD(AceLogTag::ACE_REPEAT,
"DoSetActiveChildRange: Repeat(nodeId): %{public}d: start: %{public}d - end: %{public}d; cacheStart: "
"%{public}d, cacheEnd: %{public}d: ==> keep in L1: %{public}d - %{public}d,",
GetId(), start, end, cacheStart, cacheEnd, start - cacheStart, end + cacheEnd);
TAG_LOGD(AceLogTag::ACE_REPEAT, "Repeat(%{public}d).DoSetActiveChildRange start: %{public}d - end: %{public}d; "
"cacheStart: %{public}d, cacheEnd: %{public}d: ==> keep in L1: %{public}d - %{public}d",
static_cast<int32_t>(GetId()), start, end, cacheStart, cacheEnd, start - cacheStart, end + cacheEnd);
ACE_SCOPED_TRACE("Repeat.DoSetActiveChildRange start[%d] - end[%d]; cacheStart[%d], cacheEnd[%d]",
start, end, cacheStart, cacheEnd);

View File

@ -36,6 +36,7 @@ ace_unittest("navigation_test_ng") {
"navigation_sync_stack_test_ng.cpp",
"navigation_system_bar_style_test_ng.cpp",
"navigation_test_ng.cpp",
"title_bar_pattern_test_ng.cpp",
"title_bar_test_ng.cpp",
"tool_bar_test_ng.cpp",
]

View File

@ -0,0 +1,637 @@
/*
* Copyright (c) 2024 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 "gtest/gtest.h"
#define protected public
#define private public
#include "core/common/agingadapation/aging_adapation_dialog_util.h"
#include "core/components_ng/pattern/button/button_pattern.h"
#include "core/components_ng/pattern/navigation/title_bar_node.h"
#include "core/components_ng/pattern/navigation/title_bar_pattern.h"
#include "core/components_ng/pattern/scroll/scroll_pattern.h"
#include "core/components_ng/pattern/text/text_pattern.h"
#include "test/mock/core/common/mock_container.h"
#include "test/mock/core/pipeline/mock_pipeline_context.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS::Ace::NG {
namespace {
} // namespace
class TitleBarPatternTestNg : public testing::Test {
public:
static void SetUpTestSuite();
static void TearDownTestSuite();
};
void TitleBarPatternTestNg::SetUpTestSuite()
{
MockPipelineContext::SetUp();
MockContainer::SetUp();
}
void TitleBarPatternTestNg::TearDownTestSuite()
{
MockPipelineContext::TearDown();
MockContainer::TearDown();
}
/**
* @tc.name: UpdateTitleModeChange001
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleModeChange function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleModeChange001, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::MINI;
EXPECT_NE(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
titleBarPattern->UpdateTitleModeChange();
}
/**
* @tc.name: UpdateTitleModeChange002
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleModeChange function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleModeChange002, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
titleBarPattern->maxTitleBarHeight_ = 0.0f;
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
EXPECT_TRUE(NearZero(titleBarPattern->maxTitleBarHeight_));
titleBarPattern->UpdateTitleModeChange();
}
/**
* @tc.name: UpdateTitleModeChange003
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleModeChange function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleModeChange003, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
titleBarPattern->maxTitleBarHeight_ = 10.0f;
auto geometryNode = titleBarNode->GetGeometryNode();
ASSERT_NE(geometryNode, nullptr);
SizeF frameSize(10.0f, titleBarPattern->maxTitleBarHeight_ + 10.0f);
geometryNode->SetFrameSize(frameSize);
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
EXPECT_FALSE(NearZero(titleBarPattern->maxTitleBarHeight_));
EXPECT_TRUE(geometryNode->GetFrameSize().Height() >= titleBarPattern->maxTitleBarHeight_);
titleBarPattern->UpdateTitleModeChange();
}
/**
* @tc.name: UpdateTitleModeChange004
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleModeChange function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleModeChange004, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
titleBarPattern->maxTitleBarHeight_ = static_cast<float>(TITLEBAR_HEIGHT_MINI.ConvertToPx()) + 10.0f;
auto geometryNode = titleBarNode->GetGeometryNode();
ASSERT_NE(geometryNode, nullptr);
SizeF frameSize(10.0f, titleBarPattern->maxTitleBarHeight_ - 10.0f);
geometryNode->SetFrameSize(frameSize);
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
EXPECT_FALSE(NearZero(titleBarPattern->maxTitleBarHeight_));
auto titleBarHeight = geometryNode->GetFrameSize().Height();
EXPECT_FALSE(titleBarHeight >= titleBarPattern->maxTitleBarHeight_);
EXPECT_TRUE(NearEqual(titleBarHeight, static_cast<float>(TITLEBAR_HEIGHT_MINI.ConvertToPx())));
titleBarPattern->UpdateTitleModeChange();
}
/**
* @tc.name: UpdateTitleModeChange005
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleModeChange function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleModeChange005, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
titleBarPattern->maxTitleBarHeight_ = static_cast<float>(TITLEBAR_HEIGHT_MINI.ConvertToPx()) + 20.0f;
auto geometryNode = titleBarNode->GetGeometryNode();
ASSERT_NE(geometryNode, nullptr);
SizeF frameSize(10.0f, titleBarPattern->maxTitleBarHeight_ - 10.0f);
geometryNode->SetFrameSize(frameSize);
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
EXPECT_FALSE(NearZero(titleBarPattern->maxTitleBarHeight_));
auto titleBarHeight = geometryNode->GetFrameSize().Height();
EXPECT_FALSE(titleBarHeight >= titleBarPattern->maxTitleBarHeight_);
EXPECT_FALSE(NearEqual(titleBarHeight, static_cast<float>(TITLEBAR_HEIGHT_MINI.ConvertToPx())));
titleBarPattern->UpdateTitleModeChange();
}
/**
* @tc.name: UpdateTitleBarByCoordScroll001
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleBarByCoordScroll function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleBarByCoordScroll001, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
titleBarPattern->UpdateTitleBarByCoordScroll(0.0f);
}
/**
* @tc.name: UpdateTitleBarByCoordScroll002
* @tc.desc: Increase the coverage of NavigationPattern::UpdateTitleBarByCoordScroll function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, UpdateTitleBarByCoordScroll002, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::MINI;
EXPECT_NE(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
titleBarPattern->UpdateTitleBarByCoordScroll(0.0f);
}
/**
* @tc.name: DumpInfo001
* @tc.desc: Increase the coverage of NavigationPattern::DumpInfo function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, DumpInfo001, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
EXPECT_EQ(titleBarNode->GetTitle(), nullptr);
titleBarPattern->DumpInfo();
}
/**
* @tc.name: DumpInfo002
* @tc.desc: Increase the coverage of NavigationPattern::DumpInfo function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, DumpInfo002, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto mainTitleNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 201, AceType::MakeRefPtr<TextPattern>());
titleBarNode->SetTitle(mainTitleNode);
mainTitleNode->layoutProperty_ = nullptr;
EXPECT_NE(titleBarNode->GetTitle(), nullptr);
auto mainTitleProperty = mainTitleNode->GetLayoutProperty<TextLayoutProperty>();
EXPECT_EQ(mainTitleProperty, nullptr);
titleBarPattern->DumpInfo();
}
/**
* @tc.name: DumpInfo003
* @tc.desc: Increase the coverage of NavigationPattern::DumpInfo function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, DumpInfo003, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto mainTitleNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 201, AceType::MakeRefPtr<TextPattern>());
titleBarNode->SetTitle(mainTitleNode);
EXPECT_NE(titleBarNode->GetTitle(), nullptr);
auto mainTitleProperty = mainTitleNode->GetLayoutProperty<TextLayoutProperty>();
EXPECT_NE(mainTitleProperty, nullptr);
titleBarPattern->DumpInfo();
}
/**
* @tc.name: DumpInfo004
* @tc.desc: Increase the coverage of NavigationPattern::DumpInfo function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, DumpInfo004, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
EXPECT_EQ(titleBarNode->GetSubtitle(), nullptr);
titleBarPattern->DumpInfo();
}
/**
* @tc.name: DumpInfo005
* @tc.desc: Increase the coverage of NavigationPattern::DumpInfo function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, DumpInfo005, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto subTitleNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 201, AceType::MakeRefPtr<TextPattern>());
titleBarNode->SetSubtitle(subTitleNode);
subTitleNode->layoutProperty_ = nullptr;
EXPECT_NE(titleBarNode->GetSubtitle(), nullptr);
auto subTitleProperty = subTitleNode->GetLayoutProperty<TextLayoutProperty>();
EXPECT_EQ(subTitleProperty, nullptr);
titleBarPattern->DumpInfo();
}
/**
* @tc.name: DumpInfo006
* @tc.desc: Increase the coverage of NavigationPattern::DumpInfo function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, DumpInfo006, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto subTitleNode = FrameNode::CreateFrameNode(V2::TEXT_ETS_TAG, 201, AceType::MakeRefPtr<TextPattern>());
titleBarNode->SetSubtitle(subTitleNode);
EXPECT_NE(titleBarNode->GetSubtitle(), nullptr);
auto subTitleProperty = subTitleNode->GetLayoutProperty<TextLayoutProperty>();
EXPECT_NE(subTitleProperty, nullptr);
titleBarPattern->DumpInfo();
}
/**
* @tc.name: GetTitleBarHeightLessThanMaxBarHeight001
* @tc.desc: Increase the coverage of NavigationPattern::GetTitleBarHeightLessThanMaxBarHeight function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, GetTitleBarHeightLessThanMaxBarHeight001, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::MINI;
EXPECT_NE(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
float ret = titleBarPattern->GetTitleBarHeightLessThanMaxBarHeight();
EXPECT_EQ(ret, 0.0f);
}
/**
* @tc.name: GetTitleBarHeightLessThanMaxBarHeight002
* @tc.desc: Increase the coverage of NavigationPattern::GetTitleBarHeightLessThanMaxBarHeight function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, GetTitleBarHeightLessThanMaxBarHeight002, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
titleBarPattern->GetTitleBarHeightLessThanMaxBarHeight();
}
/**
* @tc.name: GetTitleBarHeightLessThanMaxBarHeight003
* @tc.desc: Increase the coverage of NavigationPattern::GetTitleBarHeightLessThanMaxBarHeight function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, GetTitleBarHeightLessThanMaxBarHeight003, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
titleBarPattern->options_.brOptions.barStyle = BarStyle::STANDARD;
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
EXPECT_NE(titleBarPattern->options_.brOptions.barStyle.value_or(BarStyle::STANDARD), BarStyle::STACK);
titleBarPattern->GetTitleBarHeightLessThanMaxBarHeight();
}
/**
* @tc.name: GetTitleBarHeightLessThanMaxBarHeight004
* @tc.desc: Increase the coverage of NavigationPattern::GetTitleBarHeightLessThanMaxBarHeight function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, GetTitleBarHeightLessThanMaxBarHeight004, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto titleBarLayoutProperty = titleBarNode->GetLayoutProperty<TitleBarLayoutProperty>();
ASSERT_NE(titleBarLayoutProperty, nullptr);
titleBarLayoutProperty->propTitleMode_ = NavigationTitleMode::FREE;
titleBarPattern->options_.brOptions.barStyle = BarStyle::STACK;
EXPECT_EQ(titleBarLayoutProperty->GetTitleModeValue(NavigationTitleMode::FREE), NavigationTitleMode::FREE);
EXPECT_EQ(titleBarPattern->options_.brOptions.barStyle.value_or(BarStyle::STANDARD), BarStyle::STACK);
titleBarPattern->GetTitleBarHeightLessThanMaxBarHeight();
}
/**
* @tc.name: HandleLongPress001
* @tc.desc: Increase the coverage of NavigationPattern::HandleLongPress function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, HandleLongPress001, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto backButtonNode = FrameNode::GetOrCreateFrameNode(
V2::BACK_BUTTON_ETS_TAG, 201, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
EXPECT_EQ(titleBarPattern->dialogNode_, nullptr);
titleBarPattern->HandleLongPress(backButtonNode);
}
/**
* @tc.name: HandleLongPress002
* @tc.desc: Increase the coverage of NavigationPattern::HandleLongPress function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, HandleLongPress002, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto backButtonNode = FrameNode::GetOrCreateFrameNode(
V2::BACK_BUTTON_ETS_TAG, 201, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
titleBarPattern->dialogNode_ = FrameNode::CreateFrameNode(V2::COLUMN_ETS_TAG,
301, AceType::MakeRefPtr<LinearLayoutPattern>(true));
EXPECT_NE(titleBarPattern->dialogNode_, nullptr);
titleBarPattern->HandleLongPress(backButtonNode);
}
/**
* @tc.name: HandleLongPress003
* @tc.desc: Increase the coverage of NavigationPattern::HandleLongPress function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, HandleLongPress003, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto backButtonNode = FrameNode::GetOrCreateFrameNode(
V2::BACK_BUTTON_ETS_TAG, 201, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
auto symbolNode = FrameNode::GetOrCreateFrameNode(
V2::SYMBOL_ETS_TAG, 301, []() { return AceType::MakeRefPtr<TextPattern>(); });
backButtonNode->children_.emplace_back(symbolNode);
auto backButtonIconNode = AceType::DynamicCast<FrameNode>(backButtonNode->GetFirstChild());
ASSERT_NE(backButtonIconNode, nullptr);
EXPECT_EQ(backButtonIconNode->GetTag(), V2::SYMBOL_ETS_TAG);
titleBarPattern->HandleLongPress(backButtonNode);
}
/**
* @tc.name: HandleLongPress004
* @tc.desc: Increase the coverage of NavigationPattern::HandleLongPress function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, HandleLongPress004, TestSize.Level1)
{
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto backButtonNode = FrameNode::GetOrCreateFrameNode(
V2::BACK_BUTTON_ETS_TAG, 201, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
auto textNode = FrameNode::GetOrCreateFrameNode(
V2::TEXT_ETS_TAG, 301, []() { return AceType::MakeRefPtr<TextPattern>(); });
backButtonNode->children_.emplace_back(textNode);
auto backButtonIconNode = AceType::DynamicCast<FrameNode>(backButtonNode->GetFirstChild());
ASSERT_NE(backButtonIconNode, nullptr);
EXPECT_NE(backButtonIconNode->GetTag(), V2::SYMBOL_ETS_TAG);
titleBarPattern->HandleLongPress(backButtonNode);
}
/**
* @tc.name: OnFontScaleConfigurationUpdate001
* @tc.desc: Increase the coverage of NavigationPattern::OnFontScaleConfigurationUpdate function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, OnFontScaleConfigurationUpdate001, TestSize.Level1)
{
TitleBarPatternTestNg::SetUpTestSuite();
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto backButtonNode = FrameNode::GetOrCreateFrameNode(
V2::BACK_BUTTON_ETS_TAG, 201, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
auto textNode = FrameNode::GetOrCreateFrameNode(
V2::TEXT_ETS_TAG, 301, []() { return AceType::MakeRefPtr<TextPattern>(); });
backButtonNode->children_.emplace_back(textNode);
titleBarNode->SetBackButton(backButtonNode);
auto pipeline = titleBarNode->GetContext();
ASSERT_NE(pipeline, nullptr);
pipeline->fontScale_ = AgingAdapationDialogUtil::GetDialogBigFontSizeScale() - 1.0f;
EXPECT_TRUE(LessNotEqual(pipeline->GetFontScale(), AgingAdapationDialogUtil::GetDialogBigFontSizeScale()));
titleBarPattern->OnFontScaleConfigurationUpdate();
TitleBarPatternTestNg::TearDownTestSuite();
}
/**
* @tc.name: OnFontScaleConfigurationUpdate002
* @tc.desc: Increase the coverage of NavigationPattern::OnFontScaleConfigurationUpdate function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, OnFontScaleConfigurationUpdate002, TestSize.Level1)
{
TitleBarPatternTestNg::SetUpTestSuite();
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto backButtonNode = FrameNode::GetOrCreateFrameNode(
V2::BACK_BUTTON_ETS_TAG, 201, []() { return AceType::MakeRefPtr<ButtonPattern>(); });
auto textNode = FrameNode::GetOrCreateFrameNode(
V2::TEXT_ETS_TAG, 301, []() { return AceType::MakeRefPtr<TextPattern>(); });
backButtonNode->children_.emplace_back(textNode);
titleBarNode->SetBackButton(backButtonNode);
auto pipeline = titleBarNode->GetContext();
ASSERT_NE(pipeline, nullptr);
pipeline->fontScale_ = AgingAdapationDialogUtil::GetDialogBigFontSizeScale() + 1.0f;
EXPECT_FALSE(LessNotEqual(pipeline->GetFontScale(), AgingAdapationDialogUtil::GetDialogBigFontSizeScale()));
titleBarPattern->OnFontScaleConfigurationUpdate();
TitleBarPatternTestNg::TearDownTestSuite();
}
/**
* @tc.name: OnModifyDone001
* @tc.desc: Increase the coverage of NavigationPattern::OnModifyDone function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, OnModifyDone001, TestSize.Level1)
{
TitleBarPatternTestNg::SetUpTestSuite();
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto pipeline = titleBarNode->GetContext();
ASSERT_NE(pipeline, nullptr);
pipeline->fontScale_ = AgingAdapationDialogUtil::GetDialogBigFontSizeScale() + 1.0f;
EXPECT_TRUE(GreatOrEqual(pipeline->GetFontScale(), AgingAdapationDialogUtil::GetDialogBigFontSizeScale()));
titleBarPattern->OnModifyDone();
TitleBarPatternTestNg::TearDownTestSuite();
}
/**
* @tc.name: OnModifyDone002
* @tc.desc: Increase the coverage of NavigationPattern::OnModifyDone function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, OnModifyDone002, TestSize.Level1)
{
TitleBarPatternTestNg::SetUpTestSuite();
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto pipeline = titleBarNode->GetContext();
ASSERT_NE(pipeline, nullptr);
pipeline->fontScale_ = AgingAdapationDialogUtil::GetDialogBigFontSizeScale() - 1.0f;
EXPECT_FALSE(GreatOrEqual(pipeline->GetFontScale(), AgingAdapationDialogUtil::GetDialogBigFontSizeScale()));
titleBarPattern->OnModifyDone();
TitleBarPatternTestNg::TearDownTestSuite();
}
/**
* @tc.name: OnModifyDone003
* @tc.desc: Increase the coverage of NavigationPattern::OnModifyDone function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, OnModifyDone003, TestSize.Level1)
{
TitleBarPatternTestNg::SetUpTestSuite();
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto pipeline = titleBarNode->GetContext();
ASSERT_NE(pipeline, nullptr);
pipeline->fontScale_ = AgingAdapationDialogUtil::GetDialogBigFontSizeScale() - 1.0f;
titleBarPattern->options_.enableHoverMode = false;
EXPECT_FALSE(GreatOrEqual(pipeline->GetFontScale(), AgingAdapationDialogUtil::GetDialogBigFontSizeScale()));
EXPECT_FALSE(titleBarPattern->options_.enableHoverMode);
titleBarPattern->OnModifyDone();
TitleBarPatternTestNg::TearDownTestSuite();
}
/**
* @tc.name: OnModifyDone004
* @tc.desc: Increase the coverage of NavigationPattern::OnModifyDone function.
* @tc.type: FUNC
*/
HWTEST_F(TitleBarPatternTestNg, OnModifyDone004, TestSize.Level1)
{
TitleBarPatternTestNg::SetUpTestSuite();
auto titleBarNode = TitleBarNode::GetOrCreateTitleBarNode(
"TitleBar", 101, []() { return AceType::MakeRefPtr<TitleBarPattern>(); });
auto titleBarPattern = titleBarNode->GetPattern<TitleBarPattern>();
ASSERT_NE(titleBarPattern, nullptr);
auto pipeline = titleBarNode->GetContext();
ASSERT_NE(pipeline, nullptr);
pipeline->fontScale_ = AgingAdapationDialogUtil::GetDialogBigFontSizeScale() - 1.0f;
titleBarPattern->options_.enableHoverMode = true;
titleBarPattern->currentFoldCreaseRegion_.emplace_back(Rect());
EXPECT_FALSE(GreatOrEqual(pipeline->GetFontScale(), AgingAdapationDialogUtil::GetDialogBigFontSizeScale()));
EXPECT_TRUE(titleBarPattern->options_.enableHoverMode);
EXPECT_FALSE(titleBarPattern->currentFoldCreaseRegion_.empty());
titleBarPattern->OnModifyDone();
TitleBarPatternTestNg::TearDownTestSuite();
}
} // namespace OHOS::Ace::NG