Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
1c4bb21e
G
Graphic Ui
项目概览
OpenHarmony
/
Graphic Ui
大约 1 年 前同步成功
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Graphic Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c4bb21e
编写于
5月 11, 2021
作者:
O
openharmony_ci
提交者:
Gitee
5月 11, 2021
浏览文件
操作
浏览文件
下载
差异文件
!147 增加margin padding border 自动化测试用例
Merge pull request !147 from guyuanzhang/margin
上级
a7944365
b022a0b5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
0 deletion
+86
-0
test/unittest/components/ui_view_unit_test.cpp
test/unittest/components/ui_view_unit_test.cpp
+86
-0
未找到文件。
test/unittest/components/ui_view_unit_test.cpp
浏览文件 @
1c4bb21e
...
...
@@ -27,6 +27,13 @@ namespace {
const
int16_t
DEFAULE_HEIGHT
=
100
;
const
int16_t
BUTTON_WIDTH
=
20
;
const
int16_t
BUTTON_HEIGHT
=
20
;
const
int16_t
MARGIN_LEFT
=
50
;
const
int16_t
MARGIN_TOP
=
30
;
const
int16_t
PADDING_LEFT
=
10
;
const
int16_t
PADDING_TOP
=
20
;
const
int16_t
PADDING_RIGHT
=
30
;
const
int16_t
PADDING_BOTTOM
=
40
;
const
int16_t
BORDER_WIDTH
=
10
;
const
float
POS_X_PERCENT
=
0.1
;
const
float
POS_Y_PERCENT
=
0.2
;
const
float
DEFAULT_WIDTH_PERCENT
=
0.3
;
...
...
@@ -1037,4 +1044,83 @@ HWTEST_F(UIViewTest, Graphic_UIView_Test_Scale_002, TestSize.Level1)
EXPECT_EQ
((
DEFAULE_WIDTH
-
1
)
>>
1
,
polygon
[
2
].
x_
);
// 2: polygon num
EXPECT_EQ
((
DEFAULE_WIDTH
-
1
)
>>
1
,
polygon
[
2
].
x_
);
// 2: polygon num
}
/**
* @tc.name: Graphic_UIView_Test_Margin_001
* @tc.desc: Test whether the Rect is normal in the margin scenario.
* @tc.type: FUNC
* @tc.require: AR000FQNFP
*/
HWTEST_F
(
UIViewTest
,
Graphic_UIView_Test_Margin_001
,
TestSize
.
Level0
)
{
if
(
view_
==
nullptr
)
{
EXPECT_NE
(
0
,
0
);
return
;
}
view_
->
SetStyle
(
STYLE_MARGIN_LEFT
,
MARGIN_LEFT
);
view_
->
SetStyle
(
STYLE_MARGIN_TOP
,
MARGIN_TOP
);
view_
->
SetPosition
(
0
,
0
,
DEFAULE_WIDTH
,
DEFAULE_HEIGHT
);
EXPECT_EQ
(
DEFAULE_WIDTH
,
view_
->
GetWidth
());
EXPECT_EQ
(
DEFAULE_HEIGHT
,
view_
->
GetHeight
());
EXPECT_EQ
(
0
,
view_
->
GetX
());
EXPECT_EQ
(
0
,
view_
->
GetY
());
Rect
rect
=
view_
->
GetRelativeRect
();
EXPECT_EQ
(
MARGIN_LEFT
,
rect
.
GetX
());
EXPECT_EQ
(
MARGIN_TOP
,
rect
.
GetY
());
}
/**
* @tc.name: Graphic_UIView_Test_Padding_001
* @tc.desc: Test whether the Rect is normal in the setting padding scene.
* @tc.type: FUNC
* @tc.require: AR000FQNFP
*/
HWTEST_F
(
UIViewTest
,
Graphic_UIView_Test_Padding_001
,
TestSize
.
Level0
)
{
if
(
view_
==
nullptr
)
{
EXPECT_NE
(
0
,
0
);
return
;
}
view_
->
SetStyle
(
STYLE_PADDING_LEFT
,
PADDING_LEFT
);
view_
->
SetStyle
(
STYLE_PADDING_TOP
,
PADDING_TOP
);
view_
->
SetStyle
(
STYLE_PADDING_RIGHT
,
PADDING_RIGHT
);
view_
->
SetStyle
(
STYLE_PADDING_BOTTOM
,
PADDING_BOTTOM
);
view_
->
SetPosition
(
0
,
0
,
DEFAULE_WIDTH
,
DEFAULE_HEIGHT
);
Rect
rect
=
view_
->
GetContentRect
();
EXPECT_EQ
(
PADDING_LEFT
,
rect
.
GetX
());
EXPECT_EQ
(
PADDING_TOP
,
rect
.
GetY
());
EXPECT_EQ
(
PADDING_LEFT
+
DEFAULE_WIDTH
-
1
,
rect
.
GetRight
());
EXPECT_EQ
(
PADDING_TOP
+
DEFAULE_HEIGHT
-
1
,
rect
.
GetBottom
());
rect
=
view_
->
GetRelativeRect
();
EXPECT_EQ
(
0
,
rect
.
GetX
());
EXPECT_EQ
(
0
,
rect
.
GetY
());
EXPECT_EQ
(
PADDING_LEFT
+
PADDING_RIGHT
+
DEFAULE_WIDTH
-
1
,
rect
.
GetRight
());
EXPECT_EQ
(
PADDING_TOP
+
PADDING_BOTTOM
+
DEFAULE_HEIGHT
-
1
,
rect
.
GetBottom
());
}
/**
* @tc.name: Graphic_UIView_Test_Border_001
* @tc.desc: Test whether the Rect is normal in the setting of the border scene.
* @tc.type: FUNC
* @tc.require: AR000FQNFP
*/
HWTEST_F
(
UIViewTest
,
Graphic_UIView_Test_Border_001
,
TestSize
.
Level0
)
{
if
(
view_
==
nullptr
)
{
EXPECT_NE
(
0
,
0
);
return
;
}
view_
->
SetStyle
(
STYLE_BORDER_WIDTH
,
BORDER_WIDTH
);
view_
->
SetPosition
(
0
,
0
,
DEFAULE_WIDTH
,
DEFAULE_HEIGHT
);
Rect
rect
=
view_
->
GetContentRect
();
EXPECT_EQ
(
BORDER_WIDTH
,
rect
.
GetX
());
EXPECT_EQ
(
BORDER_WIDTH
,
rect
.
GetY
());
EXPECT_EQ
(
BORDER_WIDTH
+
DEFAULE_WIDTH
-
1
,
rect
.
GetRight
());
EXPECT_EQ
(
BORDER_WIDTH
+
DEFAULE_HEIGHT
-
1
,
rect
.
GetBottom
());
rect
=
view_
->
GetRelativeRect
();
EXPECT_EQ
(
0
,
rect
.
GetX
());
EXPECT_EQ
(
0
,
rect
.
GetY
());
EXPECT_EQ
(
BORDER_WIDTH
+
BORDER_WIDTH
+
DEFAULE_WIDTH
-
1
,
rect
.
GetRight
());
EXPECT_EQ
(
BORDER_WIDTH
+
BORDER_WIDTH
+
DEFAULE_HEIGHT
-
1
,
rect
.
GetBottom
());
}
}
// namespace OHOS
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录