mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-01-09 02:11:26 +00:00
!34225 【质量加固】CalendarPicker和DatePicker
Merge pull request !34225 from yangziyong/CalendarDatePicker_24_0520
This commit is contained in:
commit
69081ebe2d
@ -209,7 +209,6 @@ HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles003, TestSize
|
|||||||
info1.fontSize = Dimension(100);
|
info1.fontSize = Dimension(100);
|
||||||
buttonInfos.push_back(info1);
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
|
||||||
size_t sizet = 0;
|
size_t sizet = 0;
|
||||||
|
|
||||||
auto* stack = ViewStackProcessor::GetInstance();
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
@ -778,4 +777,468 @@ HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles014, TestSize
|
|||||||
auto testval3 = buttonLayoutProperty->GetButtonRoleValue();
|
auto testval3 = buttonLayoutProperty->GetButtonRoleValue();
|
||||||
EXPECT_EQ(testval3, ButtonRole::NORMAL);
|
EXPECT_EQ(testval3, ButtonRole::NORMAL);
|
||||||
}
|
}
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles015
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles015, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
}
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles016
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles016, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(100000);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100000));
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles017
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles017, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(1);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles018
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles018, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
info1.fontSize = Dimension(1);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
info2.fontSize = Dimension(0);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(1));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval2 = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval2, Dimension(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles019
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles019, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
ButtonInfo info3;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
info2.fontSize = Dimension(100);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
info2.fontSize = Dimension(1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval2 = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval2, Dimension(100));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval3 = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval3, Dimension(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles020
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles020, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
info1.fontColor = Color::BLACK;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
|
||||||
|
auto testval2 = buttonLayoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval2, Color::BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles021
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles021, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(1);
|
||||||
|
info1.fontColor = Color::FOREGROUND;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(1));
|
||||||
|
|
||||||
|
auto testval2 = buttonLayoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval2, Color::FOREGROUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles022
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles022, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(100);
|
||||||
|
info1.fontColor = Color::GREEN;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100));
|
||||||
|
|
||||||
|
auto testval2 = buttonLayoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval2, Color::GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @tc.name: CalendarPickerUpdateButtonStyles023
|
||||||
|
// * @tc.desc: Test UpdateButtonStyle.
|
||||||
|
// * @tc.type: FUNC
|
||||||
|
// */
|
||||||
|
HWTEST_F(CalendarPickerTestUpdate, CalendarPickerUpdateButtonStyles023, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
ButtonInfo info3;
|
||||||
|
info1.fontSize = Dimension(100);
|
||||||
|
info2.fontSize = Dimension(0);
|
||||||
|
info3.fontSize = Dimension(1);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
buttonInfos.push_back(info3);
|
||||||
|
size_t sizet = 0;
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
CreateCalendarPicker();
|
||||||
|
RefPtr<UINode> element = ViewStackProcessor::GetInstance()->Finish();
|
||||||
|
EXPECT_EQ(element->GetTag(), V2::CALENDAR_PICKER_ETS_TAG);
|
||||||
|
auto frameNode = AceType::DynamicCast<FrameNode>(element);
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
auto layoutProperty = frameNode->GetLayoutProperty<CalendarPickerLayoutProperty>();
|
||||||
|
ASSERT_NE(layoutProperty, nullptr);
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(
|
||||||
|
V2::BUTTON_ETS_TAG, stack->ClaimNodeId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
ASSERT_NE(buttonNode, nullptr);
|
||||||
|
auto buttonLayoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
ASSERT_NE(renderContext, nullptr);
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
ASSERT_NE(themeManager, nullptr);
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100));
|
||||||
|
sizet++;
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval2 = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval2, Dimension(0));
|
||||||
|
sizet++;
|
||||||
|
CalendarDialogView::UpdateButtonStyles(buttonInfos, sizet, buttonLayoutProperty, renderContext);
|
||||||
|
ASSERT_NE(buttonLayoutProperty, nullptr);
|
||||||
|
auto testval3 = buttonLayoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval3, Dimension(1));
|
||||||
|
}
|
||||||
} // namespace OHOS::Ace::NG
|
} // namespace OHOS::Ace::NG
|
@ -60,7 +60,9 @@
|
|||||||
|
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
using namespace testing::ext;
|
using namespace testing::ext;
|
||||||
|
|
||||||
namespace OHOS::Ace::NG {
|
namespace OHOS::Ace::NG {
|
||||||
|
|
||||||
class DatePickerTestUpdate : public testing::Test {
|
class DatePickerTestUpdate : public testing::Test {
|
||||||
public:
|
public:
|
||||||
static void SetUpTestSuite();
|
static void SetUpTestSuite();
|
||||||
@ -732,4 +734,505 @@ HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles014, TestSi
|
|||||||
auto testval3 = layoutProperty->GetButtonRoleValue();
|
auto testval3 = layoutProperty->GetButtonRoleValue();
|
||||||
EXPECT_EQ(testval3, ButtonRole::NORMAL);
|
EXPECT_EQ(testval3, ButtonRole::NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles015
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles015, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles016
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles016, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(100);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles017
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles017, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(1);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles018
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles018, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(1);
|
||||||
|
info1.fontColor = Color::BLACK;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(1));
|
||||||
|
|
||||||
|
auto testval3 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval3, Color::BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles019
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles019, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
info1.fontColor = Color::GREEN;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
|
||||||
|
auto testval3 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval3, Color::GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles020
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles020, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
info1.fontSize = Dimension(100);
|
||||||
|
info1.fontColor = Color::FOREGROUND;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100));
|
||||||
|
|
||||||
|
auto testval3 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval3, Color::FOREGROUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles021
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles021, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
info2.fontSize = Dimension(1);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval2 = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval2, Dimension(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles022
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles022, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
info1.fontSize = Dimension(100);
|
||||||
|
info2.fontSize = Dimension(0);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval2 = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval2, Dimension(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles023
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles023, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
ButtonInfo info3;
|
||||||
|
info1.fontSize = Dimension(20);
|
||||||
|
info2.fontSize = Dimension(100);
|
||||||
|
info3.fontSize = Dimension(0);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
buttonInfos.push_back(info3);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(20));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval2 = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval2, Dimension(100));
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval3 = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval3, Dimension(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles024
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles024, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
info1.fontSize = Dimension(100);
|
||||||
|
info1.fontColor = Color::FOREGROUND;
|
||||||
|
info2.fontSize = Dimension(1);
|
||||||
|
info2.fontColor = Color::GREEN;
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(100));
|
||||||
|
auto testval2 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval2, Color::FOREGROUND);
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval3 = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval3, Dimension(1));
|
||||||
|
auto testval4 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval4, Color::GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: DataPickerDialogViewUpdateButtonStyles025
|
||||||
|
* @tc.desc: Test UpdateButtonStyle.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(DatePickerTestUpdate, DataPickerDialogViewUpdateButtonStyles025, TestSize.Level1)
|
||||||
|
{
|
||||||
|
std::vector<ButtonInfo> buttonInfos;
|
||||||
|
ButtonInfo info1;
|
||||||
|
ButtonInfo info2;
|
||||||
|
info1.fontSize = Dimension(0);
|
||||||
|
info1.fontColor = Color::GREEN;
|
||||||
|
info2.fontColor = Color::FOREGROUND;
|
||||||
|
info2.fontSize = Dimension(20);
|
||||||
|
buttonInfos.push_back(info1);
|
||||||
|
buttonInfos.push_back(info2);
|
||||||
|
size_t sizet = 0;
|
||||||
|
|
||||||
|
auto* stack = ViewStackProcessor::GetInstance();
|
||||||
|
ASSERT_NE(stack, nullptr);
|
||||||
|
|
||||||
|
auto theme = MockPipelineContext::GetCurrent()->GetTheme<PickerTheme>();
|
||||||
|
ASSERT_NE(theme, nullptr);
|
||||||
|
DatePickerModel::GetInstance()->CreateDatePicker(theme);
|
||||||
|
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||||
|
ASSERT_NE(frameNode, nullptr);
|
||||||
|
|
||||||
|
auto buttonNode = FrameNode::GetOrCreateFrameNode(V2::BUTTON_ETS_TAG,
|
||||||
|
ElementRegister::GetInstance()->MakeUniqueId(), []() { return AceType::MakeRefPtr<ButtonPattern>(); });
|
||||||
|
CHECK_NULL_VOID(buttonNode);
|
||||||
|
auto layoutProperty = buttonNode->GetLayoutProperty<ButtonLayoutProperty>();
|
||||||
|
|
||||||
|
auto renderContext = buttonNode->GetRenderContext();
|
||||||
|
auto themeManager = AceType::MakeRefPtr<MockThemeManager>();
|
||||||
|
MockPipelineContext::GetCurrent()->SetThemeManager(themeManager);
|
||||||
|
auto buttonTheme = AceType::MakeRefPtr<ButtonTheme>();
|
||||||
|
ASSERT_NE(buttonTheme, nullptr);
|
||||||
|
EXPECT_CALL(*themeManager, GetTheme(_)).WillRepeatedly(Return(buttonTheme));
|
||||||
|
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval, Dimension(0));
|
||||||
|
auto testval2 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval2, Color::GREEN);
|
||||||
|
|
||||||
|
sizet++;
|
||||||
|
DatePickerDialogView::UpdateButtonStyles(buttonInfos, sizet, layoutProperty, renderContext);
|
||||||
|
auto testval3 = layoutProperty->GetFontSizeValue();
|
||||||
|
EXPECT_EQ(testval3, Dimension(20));
|
||||||
|
auto testval4 = layoutProperty->GetFontColorValue();
|
||||||
|
EXPECT_EQ(testval4, Color::FOREGROUND);
|
||||||
|
}
|
||||||
} // namespace OHOS::Ace::NG
|
} // namespace OHOS::Ace::NG
|
Loading…
Reference in New Issue
Block a user