提交 61a1938a 编写于 作者: S shiqichang

Description:TDD test

issuesno:https://gitee.com/openharmony/graphic_ui/issues/I5OVWQ
Feature or Bugfix: Feature
Binary Source:No
Signed-off-by: Nshiqichang <shiqichang@huawei.com>
Change-Id: I9bc24411ec84048604894192911d0af852524e03

Change-Id: I70c4f7a1cf540187b94380182769be2701e31bbc
上级 d240b051
......@@ -96,6 +96,11 @@ public:
decimal_ = 0;
}
int16_t GetAnimatorSpeed() const
{
return speed_;
}
private:
static constexpr uint8_t ANIM_WAIT_COUNT = 50;
int16_t startPos_;
......@@ -403,6 +408,11 @@ void UILabel::SetRollSpeed(uint16_t speed)
}
}
uint16_t UILabel::GetRollSpeed() const
{
return hasAnimator_ ? static_cast<LabelAnimator*>(animator_.animator)->GetAnimatorSpeed() : animator_.speed;
}
void UILabel::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea)
{
InitLabelText();
......
......@@ -196,6 +196,25 @@ public:
*/
void UpdateClock(bool clockInit) override;
/**
* @brief Obtains the color_.
*
* @return Returns the color_.
*/
ColorType GetColor() const
{
return color_;
}
/**
* @brief Obtains the leadingZero_.
*
* @return Returns the leadingZero_.
*/
bool GetLeadingZero() const
{
return leadingZero_;
}
protected:
static constexpr uint8_t TIME_ELEMENT_COUNT = 3;
UILabel* timeLabels_[TIME_ELEMENT_COUNT];
......
......@@ -271,6 +271,16 @@ public:
void SetResizeMode(ImageResizeMode mode);
void SetWidth(int16_t width) override;
void SetHeight(int16_t height) override;
/**
* @brief Obtains the ImageResizeMode.
*
* @return Returns ImageResizeMode.
*/
ImageResizeMode GetResizeMode() const
{
return imageResizeMode_;
}
#if (ENABLE_GIF == 1)
Animator* GetGifImageAnimator() const
{
......
......@@ -363,6 +363,13 @@ public:
*/
void SetRollSpeed(uint16_t speed);
/**
* @brief Obtains the scroll speed for this text.
*
* @return Returns the scroll speed.
*/
uint16_t GetRollSpeed() const;
/**
* @brief Obtains the width of this text.
*
......
......@@ -67,10 +67,10 @@ namespace {
const double END_X = 150.0;
const double END_Y = 100.0;
const double END_R = 80.0;
const double COLOR_STOP_0 = 0.0;
const double COLOR_STOP_1 = 0.3;
const double COLOR_STOP_2 = 0.6;
const double COLOR_STOP_3 = 1.0;
const float COLOR_STOP_0 = 0.0;
const float COLOR_STOP_1 = 0.3;
const float COLOR_STOP_2 = 0.6;
const float COLOR_STOP_3 = 1.0;
const float ROTATE = 10;
const int16_t LINE_X = 30;
const int16_t LINE_Y = 70;
......
......@@ -142,4 +142,66 @@ HWTEST_F(UICircleProgressTest, UICircleProgressSetStartAngle_001, TestSize.Level
circleProgress_->SetEndAngle(endAngle);
EXPECT_EQ(circleProgress_->GetEndAngle(), endAngle);
}
/**
* @tc.name: UICircleProgressOnPreDraw_001
* @tc.desc: Verify OnPreDraw function, equal.
*/
HWTEST_F(UICircleProgressTest, UICircleProgressOnPreDraw_001, TestSize.Level0)
{
if (circleProgress_ == nullptr) {
EXPECT_NE(0, 0);
return;
}
Rect* invalidatedArea = new Rect();
EXPECT_EQ(circleProgress_->OnPreDraw(*invalidatedArea), false);
delete invalidatedArea;
invalidatedArea = nullptr;
}
/**
* @tc.name: UICircleProgressSetProgressImagePosition_001
* @tc.desc: Verify SetProgressImagePosition function, equal.
*/
HWTEST_F(UICircleProgressTest, UICircleProgressSetProgressImagePosition_001, TestSize.Level0)
{
if (circleProgress_ == nullptr) {
EXPECT_NE(0, 0);
return;
}
int16_t x = 1;
int16_t y = 1;
UIView* view = new UIView();
circleProgress_->SetCenterPosition(x, y);
int16_t x1 = x + view->GetStyleConst().paddingLeft_ + view->GetStyleConst().borderWidth_;
int16_t y1 = y + view->GetStyleConst().paddingTop_ + view->GetStyleConst().borderWidth_;
circleProgress_->SetProgressImagePosition(x, y);
EXPECT_EQ(circleProgress_->GetCenterPosition().x, x1);
EXPECT_EQ(circleProgress_->GetCenterPosition().y, y1);
delete view;
view = nullptr;
}
/**
* @tc.name: UICircleProgressSetBackgroundImagePosition_001
* @tc.desc: Verify SetBackgroundImagePosition function, equal.
*/
HWTEST_F(UICircleProgressTest, UICircleProgressSetBackgroundImagePosition_001, TestSize.Level0)
{
if (circleProgress_ == nullptr) {
EXPECT_NE(0, 0);
return;
}
int16_t x = 1;
int16_t y = 1;
UIView* view = new UIView();
circleProgress_->SetCenterPosition(x, y);
int16_t x1 = x + view->GetStyleConst().paddingLeft_ + view->GetStyleConst().borderWidth_;
int16_t y1 = y + view->GetStyleConst().paddingTop_ + view->GetStyleConst().borderWidth_;
circleProgress_->SetBackgroundImagePosition(x, y);
EXPECT_EQ(circleProgress_->GetCenterPosition().x, x1);
EXPECT_EQ(circleProgress_->GetCenterPosition().y, y1);
delete view;
view = nullptr;
}
} // namespace OHOS
......@@ -174,4 +174,54 @@ HWTEST_F(UIDigitalClockTest, UIDigitalClockSetTime12Hour_002, TestSize.Level1)
EXPECT_EQ(digitalClock_->GetCurrentMinute(), CURRENT_MINUTE);
EXPECT_EQ(digitalClock_->GetCurrentSecond(), CURRENT_SECOND);
}
/**
* @tc.name: UIDigitalClockSetFont_001
* @tc.desc: Verify SetFont function, equal.
*/
HWTEST_F(UIDigitalClockTest, UIDigitalClockSetFont_001, TestSize.Level1)
{
if (digitalClock_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
uint8_t size = 10;
const char* name = "xxx";
digitalClock_->SetFont(name, size);
digitalClock_->UpdateClock(false);
Text* text = new Text();
EXPECT_EQ(text->GetFontId(), 0);
delete text;
text = nullptr;
}
/**
* @tc.name: UIDigitalClockSetColor_001
* @tc.desc: Verify SetColor function, equal.
*/
HWTEST_F(UIDigitalClockTest, UIDigitalClockSetColor_001, TestSize.Level1)
{
if (digitalClock_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
ColorType color = Color::Red();
digitalClock_->SetColor(color);
EXPECT_EQ(digitalClock_->GetColor().full, color.full);
}
/**
* @tc.name: UIDigitalClockDisplayLeadingZero_001
* @tc.desc: Verify DisplayLeadingZero function, equal.
*/
HWTEST_F(UIDigitalClockTest, UIDigitalClockDisplayLeadingZero_001, TestSize.Level1)
{
if (digitalClock_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
bool flag = false;
digitalClock_->DisplayLeadingZero(flag);
EXPECT_EQ(digitalClock_->GetLeadingZero(), flag);
}
}
......@@ -364,4 +364,37 @@ HWTEST_F(UIImageAnimatorViewTest, UIImageAnimatorViewSetFillMode_004, TestSize.L
imageAnimator_->Stop();
EXPECT_STREQ(imageAnimator_->GetPath(), g_imageAnimatorInfo[2].imagePath); // 2: the last image
}
/**
* @tc.name: UIImageAnimatorViewSetImageAnimatorSrc_003
* @tc.desc: Verify SetImageAnimatorSrc function, equal.
*/
HWTEST_F(UIImageAnimatorViewTest, UIImageAnimatorViewSetImageAnimatorSrc_003, TestSize.Level1)
{
if (imageAnimator_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
const uint8_t imageSize = IMAGE_SIZE;
const uint16_t timeOfUpdate = 1;
imageAnimator_->SetImageAnimatorSrc(g_imageAnimatorInfo, imageSize, timeOfUpdate);
EXPECT_EQ(imageAnimator_->GetTimeOfUpdate(), timeOfUpdate);
}
/**
* @tc.name: UIImageAnimatorViewSetRepeatTimes_001
* @tc.desc: Verify SetRepeatTimes function, equal.
*/
HWTEST_F(UIImageAnimatorViewTest, UIImageAnimatorViewSetRepeatTimes_001, TestSize.Level1)
{
if (imageAnimator_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
uint32_t times = 1;
imageAnimator_->SetRepeatTimes(times);
EXPECT_EQ(imageAnimator_->GetRepeatTimes(), times);
}
} // namespace OHOS
......@@ -149,6 +149,19 @@ HWTEST_F(UIImageViewTest, UIImageViewSetSrc_003, TestSize.Level1)
imageView_->SetSrc(strPath);
EXPECT_STREQ(imageView_->GetPath(), strPath);
}
/**
* @tc.name: UIImageViewGetGifImageAnimator_001
* @tc.desc: Verify GetGifImageAnimator function, equal.
*/
HWTEST_F(UIImageViewTest, UIImageViewGetGifImageAnimator_001, TestSize.Level0)
{
if (imageView_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
EXPECT_EQ(imageView_->GetGifImageAnimator(), nullptr);
}
#endif
/**
......@@ -479,4 +492,50 @@ HWTEST_F(UIImageViewTest, UIImageViewSetTransformAlgorithm_001, TestSize.Level0)
imageView_->SetTransformAlgorithm(algorithm);
EXPECT_EQ(imageView_->GetTransformAlgorithm(), algorithm);
}
/**
* @tc.name: UIImageViewOnPreDraw_001
* @tc.desc: Verify OnPreDraw function, equal.
*/
HWTEST_F(UIImageViewTest, UIImageViewOnPreDraw_001, TestSize.Level0)
{
if (imageView_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
Rect* invalidatedArea = new Rect();
EXPECT_EQ(imageView_->OnPreDraw(*invalidatedArea), true);
delete invalidatedArea;
invalidatedArea = nullptr;
}
/**
* @tc.name: UIImageViewGetSrcType_001
* @tc.desc: Verify GetSrcType function, equal.
*/
HWTEST_F(UIImageViewTest, UIImageViewGetSrcType_001, TestSize.Level0)
{
if (imageView_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
char* srcPath = nullptr;
imageView_->SetSrc(srcPath);
EXPECT_EQ(imageView_->GetSrcType(), 2); // 0 : IMG_SRC_VARIABLE 1 : IMG_SRC_FILE 2 : IMG_SRC_UNKNOWN
}
/**
* @tc.name: UIImageViewSetResizeMode_001
* @tc.desc: Verify SetResizeMode function, equal.
*/
HWTEST_F(UIImageViewTest, UIImageViewSetResizeMode_001, TestSize.Level0)
{
if (imageView_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
UIImageView::ImageResizeMode mode = UIImageView::NONE;
imageView_->SetResizeMode(mode);
EXPECT_EQ(imageView_->GetResizeMode(), mode); // 0 : IMG_SRC_VARIABLE 1 : IMG_SRC_FILE 2 : IMG_SRC_UNKNOWN
}
} // namespace OHOS
......@@ -17,6 +17,7 @@
#include <climits>
#include <gtest/gtest.h>
#include "font/ui_font.h"
using namespace testing::ext;
namespace OHOS {
......@@ -224,4 +225,130 @@ HWTEST_F(UILabelTest, UILabelSetFont_001, TestSize.Level1)
EXPECT_EQ(label_->GetFontId(), fontId);
}
/**
* @tc.name: UILabelSetStyle_001
* @tc.desc: Verify SetStyle function, equal.
*/
HWTEST_F(UILabelTest, UILabelSetStyle_001, TestSize.Level1)
{
if (label_ == nullptr) {
EXPECT_NE(0, 0);
return;
}
UIView* view = new UIView();
Style style;
style.borderOpa_ = OPA_OPAQUE;
label_->SetStyle(style);
EXPECT_EQ(view->GetStyleConst().borderOpa_, OPA_OPAQUE);
label_->SetStyle(STYLE_LINE_OPA, OPA_OPAQUE);
EXPECT_EQ(view->GetStyle(STYLE_LINE_OPA), OPA_OPAQUE);
delete view;
view = nullptr;
}
/**
* @tc.name: UILabelOnPreDraw_001
* @tc.desc: Verify OnPreDraw function, equal.
*/
HWTEST_F(UILabelTest, UILabelOnPreDraw_001, TestSize.Level1)
{
if (label_ == nullptr) {
EXPECT_NE(0, 0);
return;
}
Rect* invalidatedArea = new Rect();
EXPECT_EQ(label_->OnPreDraw(*invalidatedArea), false);
delete invalidatedArea;
invalidatedArea = nullptr;
}
#if ENABLE_VECTOR_FONT
/**
* @tc.name: UILabelSetText_002
* @tc.desc: Verify SetText function.
*/
HWTEST_F(UILabelTest, UILabelSetText_002, TestSize.Level1)
{
if (label_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
SpannableString spannableString("图形子系统测试正常粗体斜体粗斜体");
spannableString.SetTextStyle(TEXT_STYLE_ITALIC, 11, 13);
spannableString.SetTextStyle(TEXT_STYLE_BOLD, 9, 11);
spannableString.SetTextStyle(TEXT_STYLE_BOLD_ITALIC, 13, 16);
label_->SetText(&spannableString);
EXPECT_EQ(spannableString.spanList_.Size(), 3);
}
#endif
/**
* @tc.name: UILabelSetFontId_001
* @tc.desc: Verify SetFontId function.
*/
HWTEST_F(UILabelTest, UILabelSetFontId_001, TestSize.Level0)
{
if (label_ == nullptr) {
EXPECT_NE(0, 0);
return;
}
const uint8_t fontId = 16;
label_->SetFontId(fontId);
if (!UIFont::GetInstance()->IsVectorFont()) {
EXPECT_EQ(label_->GetFontId(), fontId);
} else {
EXPECT_EQ(label_->GetFontId(), 0);
}
}
/**
* @tc.name: UILabelSetRollSpeed_001
* @tc.desc: Verify SetRollSpeed function.
*/
HWTEST_F(UILabelTest, UILabelSetRollSpeed_001, TestSize.Level0)
{
if (label_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
const uint16_t RollSpeed = 50;
label_->SetRollSpeed(RollSpeed);
EXPECT_EQ(label_->GetRollSpeed(), RollSpeed);
}
/**
* @tc.name: UILabelGetTextSize_001
* @tc.desc: Verify GetTextSize function.
*/
HWTEST_F(UILabelTest, UILabelGetTextSize_001, TestSize.Level0)
{
if (label_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
Text* labelText = new Text();
EXPECT_EQ(labelText->GetTextSize().x, label_->GetTextWidth());
EXPECT_EQ(labelText->GetTextSize().y, label_->GetTextHeight());
delete labelText;
labelText = nullptr;
}
/**
* @tc.name: UILabelSetSize_001
* @tc.desc: Verify SetSize function.
*/
HWTEST_F(UILabelTest, UILabelSetSize_001, TestSize.Level0)
{
if (label_ == nullptr) {
EXPECT_EQ(1, 0);
return;
}
label_->SetWidth(0);
EXPECT_EQ(label_->GetWidth(), 0);
label_->SetHeight(0);
EXPECT_EQ(label_->GetHeight(), 0);
}
} // namespace OHOS
......@@ -150,11 +150,7 @@ HWTEST_F(UIFontTest, Graphic_Font_Test_GetFontId_002, TestSize.Level1)
HWTEST_F(UIFontTest, Graphic_Font_Test_GetHeight_001, TestSize.Level1)
{
uint16_t height = UIFont::GetInstance()->GetHeight(FONT_ID, 0);
#if ENABLE_VECTOR_FONT
EXPECT_EQ(height, 0);
#else
EXPECT_EQ(height, static_cast<uint16_t>(INVALID_RET));
#endif
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册