Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
cc880159
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,发现更多精彩内容 >>
提交
cc880159
编写于
3月 31, 2021
作者:
O
openharmony_ci
提交者:
Gitee
3月 31, 2021
浏览文件
操作
浏览文件
下载
差异文件
!34 add auto test framework
Merge pull request !34 from 邓志豪/master
上级
b40c5b7e
396747da
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
581 addition
and
4 deletion
+581
-4
test/framework/include/compare_tools.h
test/framework/include/compare_tools.h
+55
-0
test/framework/include/ui_auto_test.h
test/framework/include/ui_auto_test.h
+37
-0
test/framework/include/ui_auto_test_group.h
test/framework/include/ui_auto_test_group.h
+33
-0
test/framework/include/ui_test_app.h
test/framework/include/ui_test_app.h
+26
-1
test/framework/src/compare_tools.cpp
test/framework/src/compare_tools.cpp
+140
-0
test/framework/src/test_ability.cpp
test/framework/src/test_ability.cpp
+17
-1
test/framework/src/test_case_list_adapter.cpp
test/framework/src/test_case_list_adapter.cpp
+1
-0
test/framework/src/ui_auto_test.cpp
test/framework/src/ui_auto_test.cpp
+108
-0
test/framework/src/ui_auto_test_group.cpp
test/framework/src/ui_auto_test_group.cpp
+42
-0
test/framework/src/ui_test_app.cpp
test/framework/src/ui_test_app.cpp
+25
-1
test/framework/src/ui_test_group.cpp
test/framework/src/ui_test_group.cpp
+1
-1
test/uitest/test_render/ui_auto_test_render.cpp
test/uitest/test_render/ui_auto_test_render.cpp
+45
-0
test/uitest/test_render/ui_auto_test_render.h
test/uitest/test_render/ui_auto_test_render.h
+34
-0
test/uitest/test_render/ui_test_render.cpp
test/uitest/test_render/ui_test_render.cpp
+1
-0
test/uitest/test_render/ui_test_render.h
test/uitest/test_render/ui_test_render.h
+4
-0
tools/qt/simulator/test/test.pro
tools/qt/simulator/test/test.pro
+12
-0
未找到文件。
test/framework/include/compare_tools.h
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GRAPHIC_LITE_COMPARE_TOOLS_H
#define GRAPHIC_LITE_COMPARE_TOOLS_H
#include "graphic_config.h"
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif // _WIN32
#ifdef _WIN32
#define UI_AUTO_TEST_RESOURCE_PATH "..\\simulator\\config\\auto_test\\"
#else
#define UI_AUTO_TEST_RESOURCE_PATH (RESOURCE_DIR "auto_test/")
#endif
namespace
OHOS
{
namespace
{
constexpr
uint16_t
DEFAULT_WAIT_TIME_MS
=
300
;
constexpr
size_t
DEFAULT_FILE_NAME_MAX_LENGTH
=
256
;
}
class
CompareTools
{
public:
enum
CompareMode
:
uint8_t
{
COMPARE_BINARY
,
COMPARE_IMAGE
};
static
void
WaitSuspend
();
static
bool
StrnCatPath
(
char
*
filePath
,
size_t
pathMax
,
const
char
*
fileName
,
size_t
count
);
static
bool
CompareFile
(
const
char
*
filePath
,
size_t
length
,
uint8_t
flag
);
static
bool
SaveFile
(
const
char
*
filePath
,
size_t
length
,
uint8_t
flag
);
static
bool
CheckFileExist
(
const
char
*
filePath
,
size_t
length
);
private:
static
bool
CompareBinary
(
const
char
*
filePath
,
size_t
length
);
static
bool
SaveFrameBuffToBinary
(
const
char
*
filePath
,
size_t
length
);
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_COMPARE_TOOLS_H
test/framework/include/ui_auto_test.h
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GRAPHIC_LITE_UI_AUTO_TEST_H
#define GRAPHIC_LITE_UI_AUTO_TEST_H
#include "components/ui_view.h"
namespace
OHOS
{
class
UIAutoTest
{
public:
UIAutoTest
()
{}
virtual
~
UIAutoTest
()
{}
virtual
void
RunTestList
()
=
0
;
virtual
void
Reset
()
const
=
0
;
void
ResetMainMenu
()
const
;
void
EnterSubMenu
(
const
char
*
id
)
const
;
void
ClickViewById
(
const
char
*
id
)
const
;
void
DragViewToHead
(
const
char
*
id
)
const
;
void
CompareByBinary
(
const
char
*
fileName
)
const
;
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_UI_AUTO_TEST_H
test/framework/include/ui_auto_test_group.h
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GRAPHIC_LITE_UI_AUTO_TEST_GROUP_H
#define GRAPHIC_LITE_UI_AUTO_TEST_GROUP_H
#include "gfx_utils/list.h"
#include "ui_auto_test.h"
namespace
OHOS
{
class
UIAutoTestGroup
{
public:
static
void
SetUpTestCase
();
static
List
<
UIAutoTest
*>&
GetTestCase
();
static
void
TearDownTestCase
();
private:
static
List
<
UIAutoTest
*>
testCaseList_
;
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_UI_AUTO_TEST_GROUP_H
\ No newline at end of file
test/framework/include/ui_test_app.h
浏览文件 @
cc880159
...
...
@@ -22,7 +22,12 @@
#include "components/ui_list.h"
#include "test_case_list_adapter.h"
#define ENABEL_UI_AUTO_TEST 0
namespace
OHOS
{
namespace
{
constexpr
char
*
UI_TEST_MAIN_LIST_ID
=
"main_list"
;
constexpr
char
*
UI_TEST_BACK_BUTTON_ID
=
"back_button"
;
}
class
UITestApp
{
public:
static
UITestApp
*
GetInstance
()
...
...
@@ -49,5 +54,25 @@ private:
UILabel
*
testCaseLabel_
=
nullptr
;
UILabel
*
testLabel_
=
nullptr
;
};
#if ENABEL_UI_AUTO_TEST
class
UIAutoTestApp
{
public:
static
UIAutoTestApp
*
GetInstance
()
{
static
UIAutoTestApp
instance
;
return
&
instance
;
}
void
Start
();
private:
UIAutoTestApp
()
{}
~
UIAutoTestApp
()
{}
UIAutoTestApp
(
const
UIAutoTestApp
&
)
=
delete
;
UIAutoTestApp
&
operator
=
(
const
UIAutoTestApp
&
)
=
delete
;
UIAutoTestApp
(
UIAutoTestApp
&&
)
=
delete
;
UIAutoTestApp
&
operator
=
(
UIAutoTestApp
&&
)
=
delete
;
};
#endif // ENABEL_UI_AUTO_TEST
}
// namespace OHOS
#endif
\ No newline at end of file
#endif
test/framework/src/compare_tools.cpp
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "compare_tools.h"
#include "dock/screen_device_proxy.h"
#include "draw/draw_utils.h"
#include "file.h"
#include "gfx_utils/graphic_log.h"
#include "graphic_config.h"
#include "securec.h"
namespace
OHOS
{
void
CompareTools
::
WaitSuspend
()
{
#ifdef _WIN32
Sleep
(
DEFAULT_WAIT_TIME_MS
);
#else
usleep
(
1000
*
DEFAULT_WAIT_TIME_MS
);
// 1000: us to ms
#endif // _WIN32
}
bool
CompareTools
::
StrnCatPath
(
char
*
filePath
,
size_t
pathMax
,
const
char
*
fileName
,
size_t
count
)
{
if
((
filePath
==
nullptr
)
||
(
pathMax
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
char
dest
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
UI_AUTO_TEST_RESOURCE_PATH
;
if
(
strncat_s
(
dest
,
DEFAULT_FILE_NAME_MAX_LENGTH
,
fileName
,
count
)
!=
EOK
)
{
return
false
;
}
if
(
memcpy_s
(
static_cast
<
void
*>
(
filePath
),
pathMax
,
dest
,
DEFAULT_FILE_NAME_MAX_LENGTH
)
!=
EOK
)
{
return
false
;
}
return
true
;
}
bool
CompareTools
::
CompareFile
(
const
char
*
src
,
size_t
length
,
uint8_t
flag
)
{
switch
(
flag
)
{
case
COMPARE_BINARY
:
return
CompareBinary
(
src
,
length
);
case
COMPARE_IMAGE
:
// Unrealized : image for comparison
break
;
default:
break
;
}
return
false
;
}
bool
CompareTools
::
SaveFile
(
const
char
*
src
,
size_t
length
,
uint8_t
flag
)
{
switch
(
flag
)
{
case
COMPARE_BINARY
:
return
SaveFrameBuffToBinary
(
src
,
length
);
case
COMPARE_IMAGE
:
// Unrealized : save frame buff as image
break
;
default:
break
;
}
return
false
;
}
bool
CompareTools
::
CompareBinary
(
const
char
*
filePath
,
size_t
length
)
{
if
((
filePath
==
nullptr
)
||
(
length
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
FILE
*
fd
=
fopen
(
filePath
,
"rb"
);
if
(
fd
==
nullptr
)
{
return
false
;
}
uint8_t
*
frameBuf
=
ScreenDeviceProxy
::
GetInstance
()
->
GetBuffer
();
uint8_t
sizeByColorMode
=
DrawUtils
::
GetByteSizeByColorMode
(
ScreenDeviceProxy
::
GetInstance
()
->
GetBufferMode
());
uint32_t
buffSize
=
HORIZONTAL_RESOLUTION
*
VERTICAL_RESOLUTION
*
sizeByColorMode
;
uint8_t
*
readBuf
=
reinterpret_cast
<
uint8_t
*>
(
malloc
(
buffSize
));
if
(
fread
(
readBuf
,
buffSize
,
sizeof
(
uint8_t
),
fd
)
<
0
)
{
fclose
(
fd
);
free
(
readBuf
);
return
false
;
}
for
(
int32_t
i
=
0
;
i
<
(
buffSize
/
sizeof
(
uint8_t
));
i
++
)
{
if
(
readBuf
[
i
]
!=
frameBuf
[
i
])
{
GRAPHIC_LOGE
(
"[DIFF]:fileName=%s, read[%d]=%x, write[%d]=%x"
,
filePath
,
i
,
readBuf
[
i
],
frameBuf
[
i
]);
fclose
(
fd
);
free
(
readBuf
);
return
false
;
}
}
fclose
(
fd
);
free
(
readBuf
);
return
true
;
}
bool
CompareTools
::
SaveFrameBuffToBinary
(
const
char
*
filePath
,
size_t
length
)
{
if
((
filePath
==
nullptr
)
||
(
length
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
FILE
*
fd
=
fopen
(
filePath
,
"wb+"
);
if
(
fd
==
nullptr
)
{
return
false
;
}
uint8_t
*
frameBuf
=
ScreenDeviceProxy
::
GetInstance
()
->
GetBuffer
();
uint8_t
sizeByColorMode
=
DrawUtils
::
GetByteSizeByColorMode
(
ScreenDeviceProxy
::
GetInstance
()
->
GetBufferMode
());
uint32_t
buffSize
=
HORIZONTAL_RESOLUTION
*
VERTICAL_RESOLUTION
*
sizeByColorMode
;
if
(
fwrite
(
frameBuf
,
buffSize
,
sizeof
(
uint8_t
),
fd
)
<
0
)
{
fclose
(
fd
);
return
false
;
}
fclose
(
fd
);
return
true
;
}
bool
CompareTools
::
CheckFileExist
(
const
char
*
filePath
,
size_t
length
)
{
if
((
filePath
==
nullptr
)
||
(
length
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
FILE
*
fd
=
fopen
(
filePath
,
"r"
);
if
(
fd
==
nullptr
)
{
return
false
;
}
fclose
(
fd
);
return
true
;
}
}
// namespace OHOS
\ No newline at end of file
test/framework/src/test_ability.cpp
浏览文件 @
cc880159
...
...
@@ -14,8 +14,24 @@
*/
#include "ui_test_app.h"
#if ENABEL_UI_AUTO_TEST
#ifdef _WIN32
#include <thread>
#endif // _WIN32
void
*
AutoTestThread
()
{
OHOS
::
UIAutoTestApp
::
GetInstance
()
->
Start
();
}
#endif // ENABEL_UI_AUTO_TEST
void
RunApp
()
{
OHOS
::
UITestApp
::
GetInstance
()
->
Start
();
}
\ No newline at end of file
#if ENABEL_UI_AUTO_TEST
#ifdef _WIN32
std
::
thread
autoTestPthread
(
AutoTestThread
);
autoTestPthread
.
detach
();
#endif // _WIN32
#endif // ENABEL_UI_AUTO_TEST
}
test/framework/src/test_case_list_adapter.cpp
浏览文件 @
cc880159
...
...
@@ -179,6 +179,7 @@ UIView* TestCaseListAdapter::GetView(UIView* inView, int16_t index)
listener
=
new
BtnOnClickUiTestListener
(
rootView_
,
mainList_
,
backBtn_
,
&
node
->
data_
,
testCaseLabel_
,
testLabel_
);
item
->
SetOnClickListener
(
listener
);
item
->
SetText
(
node
->
data_
.
sliceId
);
item
->
SetViewId
(
node
->
data_
.
sliceId
);
item
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
24
);
// 24: means font size
item
->
SetViewIndex
(
index
);
item
->
SetAlign
(
TEXT_ALIGNMENT_LEFT
);
...
...
test/framework/src/ui_auto_test.cpp
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ui_auto_test.h"
#include "compare_tools.h"
#include "components/root_view.h"
#include "components/ui_list.h"
#include "components/ui_view_group.h"
#include "dfx/event_injector.h"
#include "ui_test_app.h"
#include "ui_test_group.h"
namespace
OHOS
{
void
UIAutoTest
::
ResetMainMenu
()
const
{
while
(
RootView
::
GetInstance
()
->
GetChildById
(
UI_TEST_MAIN_LIST_ID
)
==
nullptr
)
{
ClickViewById
(
UI_TEST_BACK_BUTTON_ID
);
}
}
void
UIAutoTest
::
EnterSubMenu
(
const
char
*
id
)
const
{
if
(
id
==
nullptr
)
{
return
;
}
UIView
*
view
=
RootView
::
GetInstance
()
->
GetChildById
(
id
);
if
(
view
==
nullptr
)
{
UIView
*
view
=
RootView
::
GetInstance
()
->
GetChildById
(
UI_TEST_MAIN_LIST_ID
);
if
(
view
==
nullptr
)
{
return
;
}
ListNode
<
TestCaseInfo
>*
node
=
UITestGroup
::
GetTestCase
().
Begin
();
while
(
node
!=
UITestGroup
::
GetTestCase
().
End
())
{
if
((
node
->
data_
.
sliceId
!=
nullptr
)
&&
(
strcmp
(
id
,
node
->
data_
.
sliceId
)
==
0
))
{
UITestGroup
::
GetTestCase
().
PushFront
(
node
->
data_
);
UITestGroup
::
GetTestCase
().
Remove
(
node
);
break
;
}
node
=
node
->
next_
;
}
reinterpret_cast
<
UIList
*>
(
view
)
->
RefreshList
();
CompareTools
::
WaitSuspend
();
}
ClickViewById
(
id
);
}
void
UIAutoTest
::
ClickViewById
(
const
char
*
id
)
const
{
if
(
id
==
nullptr
)
{
return
;
}
UIView
*
view
=
RootView
::
GetInstance
()
->
GetChildById
(
id
);
if
(
view
==
nullptr
)
{
return
;
}
Point
point
;
point
.
x
=
view
->
GetOrigRect
().
GetX
();
point
.
y
=
view
->
GetOrigRect
().
GetY
();
EventInjector
::
GetInstance
()
->
SetClickEvent
(
point
);
CompareTools
::
WaitSuspend
();
}
void
UIAutoTest
::
DragViewToHead
(
const
char
*
id
)
const
{
if
(
id
==
nullptr
)
{
return
;
}
UIView
*
view
=
RootView
::
GetInstance
()
->
GetChildById
(
id
);
if
(
view
==
nullptr
)
{
return
;
}
Point
startPoint
;
startPoint
.
x
=
view
->
GetOrigRect
().
GetX
();
startPoint
.
y
=
view
->
GetOrigRect
().
GetY
();
Point
endPoint
;
endPoint
.
x
=
50
;
// 50 :end point x position;
endPoint
.
y
=
80
;
// 80 :end point y position;
EventInjector
::
GetInstance
()
->
SetDragEvent
(
startPoint
,
endPoint
,
80
);
// 80: drag time
CompareTools
::
WaitSuspend
();
}
void
UIAutoTest
::
CompareByBinary
(
const
char
*
fileName
)
const
{
if
(
fileName
==
nullptr
)
{
return
;
}
char
filePath
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
CompareTools
::
StrnCatPath
(
filePath
,
DEFAULT_FILE_NAME_MAX_LENGTH
,
fileName
,
strlen
(
fileName
));
if
(
CompareTools
::
CheckFileExist
(
filePath
,
sizeof
(
filePath
)))
{
CompareTools
::
CompareFile
(
filePath
,
sizeof
(
filePath
),
CompareTools
::
CompareMode
::
COMPARE_BINARY
);
}
else
{
CompareTools
::
SaveFile
(
filePath
,
sizeof
(
filePath
),
CompareTools
::
CompareMode
::
COMPARE_BINARY
);
}
}
}
// namespace OHOS
test/framework/src/ui_auto_test_group.cpp
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ui_auto_test_group.h"
#include "graphic_config.h"
#include "test_render/ui_auto_test_render.h"
namespace
OHOS
{
List
<
UIAutoTest
*>
UIAutoTestGroup
::
testCaseList_
;
void
UIAutoTestGroup
::
SetUpTestCase
()
{
testCaseList_
.
PushBack
(
new
UIAutoTestRender
());
}
List
<
UIAutoTest
*>&
UIAutoTestGroup
::
GetTestCase
()
{
return
testCaseList_
;
}
void
UIAutoTestGroup
::
TearDownTestCase
()
{
ListNode
<
UIAutoTest
*>*
node
=
testCaseList_
.
Begin
();
while
(
node
!=
testCaseList_
.
End
())
{
delete
node
->
data_
;
node
=
node
->
next_
;
}
testCaseList_
.
Clear
();
}
}
// namespace OHOS
test/framework/src/ui_test_app.cpp
浏览文件 @
cc880159
...
...
@@ -18,6 +18,12 @@
#include "test_resource_config.h"
#include "ui_test.h"
#include "ui_test_group.h"
#if ENABEL_UI_AUTO_TEST
#include "compare_tools.h"
#include "dfx/event_injector.h"
#include "ui_auto_test_group.h"
#include "ui_auto_test.h"
#endif // ENABEL_UI_AUTO_TEST
namespace
OHOS
{
void
UITestApp
::
Start
()
...
...
@@ -37,6 +43,7 @@ void UITestApp::Init()
backBtn_
->
SetPosition
(
0
,
0
);
backBtn_
->
Resize
(
163
,
64
);
// 163: button width; 64: button height
backBtn_
->
SetText
(
"Back"
);
backBtn_
->
SetViewId
(
UI_TEST_BACK_BUTTON_ID
);
backBtn_
->
SetLablePosition
(
72
,
0
);
// 72: button label x-coordinate
backBtn_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
24
);
// 24: means font size
backBtn_
->
SetImageSrc
(
TEST_BACK_LEFT_ARROW
,
TEST_BACK_LEFT_ARROW
);
...
...
@@ -71,6 +78,7 @@ void UITestApp::Init()
mainList_
->
SetPosition
(
24
,
deltaHeight
);
// 24: x-coordinate
mainList_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
()
-
deltaHeight
);
mainList_
->
SetThrowDrag
(
true
);
mainList_
->
SetViewId
(
UI_TEST_MAIN_LIST_ID
);
adapter_
=
new
TestCaseListAdapter
(
rootView_
,
mainList_
,
backBtn_
,
testCaseLabel_
,
testLabel_
);
UITestGroup
::
SetUpTestCase
();
mainList_
->
SetAdapter
(
adapter_
);
...
...
@@ -97,4 +105,20 @@ UITestApp::~UITestApp()
rootView_
=
nullptr
;
}
}
}
// namespace OHOS
\ No newline at end of file
#if ENABEL_UI_AUTO_TEST
void
UIAutoTestApp
::
Start
()
{
EventInjector
::
GetInstance
()
->
RegisterEventInjector
(
EventDataType
::
POINT_TYPE
);
EventInjector
::
GetInstance
()
->
RegisterEventInjector
(
EventDataType
::
KEY_TYPE
);
CompareTools
::
WaitSuspend
();
UIAutoTestGroup
::
SetUpTestCase
();
ListNode
<
UIAutoTest
*>*
node
=
UIAutoTestGroup
::
GetTestCase
().
Begin
();
while
(
node
!=
UIAutoTestGroup
::
GetTestCase
().
End
())
{
node
->
data_
->
RunTestList
();
node
->
data_
->
ResetMainMenu
();
node
=
node
->
next_
;
}
}
#endif // ENABEL_UI_AUTO_TEST
}
// namespace OHOS
test/framework/src/ui_test_group.cpp
浏览文件 @
cc880159
...
...
@@ -103,7 +103,7 @@ void UITestGroup::SetUpTestCase()
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Canvas"
,
new
UITestCanvas
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Draw_Rect"
,
new
UITestDrawRect
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Draw_Line"
,
new
UITestDrawLine
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Render"
,
new
UITestRender
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
UI_TEST_RENDER_ID
,
new
UITestRender
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Anti_Aliasing"
,
new
UITestAntiAliasing
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"UIList"
,
new
UITestUIList
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"UISwipeView"
,
new
UITestUISwipeView
()});
...
...
test/uitest/test_render/ui_auto_test_render.cpp
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ui_auto_test_render.h"
#include "ui_test_render.h"
namespace
OHOS
{
void
UIAutoTestRender
::
Reset
()
const
{
ResetMainMenu
();
EnterSubMenu
(
UI_TEST_RENDER_ID
);
}
void
UIAutoTestRender
::
RunTestList
()
{
Reset
();
UIKitRenderTestRender001
();
UIKitRenderTestRenderMeasure001
();
}
void
UIAutoTestRender
::
UIKitRenderTestRender001
()
const
{
const
char
*
fileName
=
"ui_test_render_001.bin"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestRender
::
UIKitRenderTestRenderMeasure001
()
const
{
ClickViewById
(
UI_TEST_RENDER_UPDATA_BUTTON_ID_01
);
const
char
*
fileName
=
"ui_test_render_measure_001.bin"
;
CompareByBinary
(
fileName
);
}
}
// namespace OHOS
test/uitest/test_render/ui_auto_test_render.h
0 → 100644
浏览文件 @
cc880159
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GRAPHIC_LITE_UI_AUTO_TEST_RENDER_H
#define GRAPHIC_LITE_UI_AUTO_TEST_RENDER_H
#include "ui_auto_test.h"
namespace
OHOS
{
class
UIAutoTestRender
:
public
UIAutoTest
{
public:
UIAutoTestRender
()
{}
~
UIAutoTestRender
()
{}
void
Reset
()
const
;
void
RunTestList
();
void
UIKitRenderTestRender001
()
const
;
void
UIKitRenderTestRenderMeasure001
()
const
;
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_UI_AUTO_TEST_RENDER_H
\ No newline at end of file
test/uitest/test_render/ui_test_render.cpp
浏览文件 @
cc880159
...
...
@@ -133,6 +133,7 @@ void UITestRender::UIKit_Render_Test_RenderMeasure_001()
group
->
Add
(
labelButton_
);
labelButton_
->
Resize
(
BUTTON_WIDHT3
,
BUTTON_HEIGHT3
);
labelButton_
->
SetText
(
"更新label"
);
labelButton_
->
SetViewId
(
UI_TEST_RENDER_UPDATA_BUTTON_ID_01
);
labelButton_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
FONT_DEFAULT_SIZE
);
labelButton_
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
labelButton_
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
PRESSED
);
...
...
test/uitest/test_render/ui_test_render.h
浏览文件 @
cc880159
...
...
@@ -22,6 +22,10 @@
#include "ui_test.h"
namespace
OHOS
{
namespace
{
constexpr
char
*
UI_TEST_RENDER_ID
=
"Render"
;
constexpr
char
*
UI_TEST_RENDER_UPDATA_BUTTON_ID_01
=
"test_render_updata_buttin_01"
;
}
class
UITestRender
:
public
UITest
,
public
UIView
::
OnClickListener
{
public:
UITestRender
()
:
container_
(
nullptr
)
{}
...
...
tools/qt/simulator/test/test.pro
浏览文件 @
cc880159
...
...
@@ -65,6 +65,12 @@ SOURCES += \
..
/../../../
test
/
uitest
/
test_view_percent
/
ui_test_view_percent
.
cpp
\
..
/../../../
test
/
uitest
/
test_view_scale_rotate
/
ui_test_view_scale_rotate
.
cpp
SOURCES
+=
\
..
/../../../
test
/
framework
/
src
/
ui_auto_test
.
cpp
\
..
/../../../
test
/
framework
/
src
/
ui_auto_test_group
.
cpp
\
..
/../../../
test
/
framework
/
src
/
compare_tools
.
cpp
\
..
/../../../
test
/
uitest
/
test_render
/
ui_auto_test_render
.
cpp
\
HEADERS
+=
\
..
/../../../
test
/
framework
/
include
/
test_case_list_adapter
.
h
\
..
/../../../
test
/
framework
/
include
/
ui_test_app
.
h
\
...
...
@@ -111,6 +117,12 @@ HEADERS += \
..
/../../../
test
/
uitest
/
test_view_percent
/
ui_test_view_percent
.
h
\
..
/../../../
test
/
uitest
/
test_view_scale_rotate
/
ui_test_view_scale_rotate
.
h
HEADERS
+=
\
..
/../../../
test
/
framework
/
include
/
ui_auto_test
.
h
\
..
/../../../
test
/
framework
/
include
/
ui_auto_test_group
.
h
\
..
/../../../
test
/
framework
/
include
/
compare_tools
.
h
\
..
/../../../
test
/
uitest
/
test_render
/
ui_auto_test_render
.
h
INCLUDEPATH
+=
\
..
/../../../
frameworks
\
..
/../../../../
utils
/
frameworks
/
windows
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录