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

!190 【图形】TDD测试问题

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