提交 b963df17 编写于 作者: O openharmony_ci 提交者: Gitee

!190 【图形】TDD测试问题

Merge pull request !190 from 邓志豪/TDDProblem
......@@ -249,6 +249,7 @@ void UIButton::Enable()
void UIButton::SetState(ButtonState state)
{
state_ = state;
style_ = buttonStyles_[state_];
Invalidate();
}
......
......@@ -53,6 +53,9 @@ UITimePicker::UITimePicker()
} else {
style_ = &(StyleDefault::GetPickerHighlightStyle());
}
#if ENABLE_FOCUS_MANAGER
focusable_ = true;
#endif
highlightFontId_ = style_->font_;
highlightColor_ = style_->textColor_;
......
......@@ -27,6 +27,7 @@
#endif
namespace OHOS {
bool UIFont::setFontAllocFlag_ = false;
UIFont::UIFont() : instance_(nullptr), defaultInstance_(nullptr){};
UIFont::~UIFont(){};
......@@ -38,11 +39,13 @@ UIFont* UIFont::GetInstance()
if (instance.instance_ == nullptr) {
instance.defaultInstance_ = new UIFontVector();
instance.instance_ = instance.defaultInstance_;
setFontAllocFlag_ = true;
}
#else
if (instance.instance_ == nullptr) {
instance.defaultInstance_ = new UIFontBitmap();
instance.instance_ = instance.defaultInstance_;
setFontAllocFlag_ = true;
}
#endif
return &instance;
......@@ -51,9 +54,10 @@ UIFont* UIFont::GetInstance()
void UIFont::SetFont(BaseFont* font)
{
if (font != nullptr) {
if (defaultInstance_ != nullptr) {
if (defaultInstance_ != nullptr && setFontAllocFlag_) {
delete defaultInstance_;
defaultInstance_ = nullptr;
setFontAllocFlag_ = false;
}
defaultInstance_ = font;
instance_ = font;
......
......@@ -24,9 +24,6 @@ ThemeManager& ThemeManager::GetInstance()
void ThemeManager::SetCurrent(Theme* theme)
{
if (theme_ != nullptr) {
delete theme_;
}
theme_ = theme;
}
} // namespace OHOS
\ No newline at end of file
......@@ -233,6 +233,7 @@ private:
BaseFont* instance_;
BaseFont* defaultInstance_;
static bool setFontAllocFlag_;
};
} // namespace OHOS
#endif
......@@ -78,7 +78,10 @@ public:
private:
ThemeManager() : theme_(nullptr) {}
~ThemeManager() {}
virtual ~ThemeManager()
{
theme_ = nullptr;
}
Theme* theme_;
};
......
......@@ -57,6 +57,7 @@ void FocusManagerTest::SetUpTestCase(void)
void FocusManagerTest::TearDownTestCase(void)
{
FocusManager::GetInstance()->ClearFocus();
if (viewGroup_ != nullptr) {
viewGroup_->Remove(label1_);
viewGroup_->Remove(label2_);
......@@ -71,7 +72,6 @@ void FocusManagerTest::TearDownTestCase(void)
delete label2_;
label2_ = nullptr;
}
FocusManager::GetInstance()->ClearFocus();
}
/**
......
......@@ -80,7 +80,6 @@ HWTEST_F(UIFontTest, Graphic_Font_Test_GetInstance_001, TestSize.Level0)
*/
HWTEST_F(UIFontTest, Graphic_Font_Test_IsVectorFont_001, TestSize.Level1)
{
UIFont::GetInstance()->SetFont(font_);
#if ENABLE_VECTOR_FONT
bool ret = UIFont::GetInstance()->IsVectorFont();
EXPECT_EQ(ret, true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册