Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
b9132fb4
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,发现更多精彩内容 >>
提交
b9132fb4
编写于
7月 12, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 12, 2021
浏览文件
操作
浏览文件
下载
差异文件
!254 自动化用例增强
Merge pull request !254 from 邓志豪/AUTOTEST
上级
5022ffeb
0493063c
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
774 addition
and
336 deletion
+774
-336
test/framework/BUILD.gn
test/framework/BUILD.gn
+16
-9
test/framework/include/auto_test_app.h
test/framework/include/auto_test_app.h
+13
-11
test/framework/include/auto_test_case_group.h
test/framework/include/auto_test_case_group.h
+41
-0
test/framework/include/compare_tools.h
test/framework/include/compare_tools.h
+21
-14
test/framework/include/test_case_list_adapter.h
test/framework/include/test_case_list_adapter.h
+5
-6
test/framework/include/ui_auto_test.h
test/framework/include/ui_auto_test.h
+3
-4
test/framework/include/ui_test_app.h
test/framework/include/ui_test_app.h
+12
-15
test/framework/src/auto_test_app.cpp
test/framework/src/auto_test_app.cpp
+62
-0
test/framework/src/auto_test_case_group.cpp
test/framework/src/auto_test_case_group.cpp
+12
-12
test/framework/src/compare_tools.cpp
test/framework/src/compare_tools.cpp
+134
-102
test/framework/src/test_ability.cpp
test/framework/src/test_ability.cpp
+5
-25
test/framework/src/test_case_list_adapter.cpp
test/framework/src/test_case_list_adapter.cpp
+16
-24
test/framework/src/ui_auto_test.cpp
test/framework/src/ui_auto_test.cpp
+11
-2
test/framework/src/ui_test_app.cpp
test/framework/src/ui_test_app.cpp
+117
-79
test/uitest/test_layout/ui_auto_test_basic_layout.cpp
test/uitest/test_layout/ui_auto_test_basic_layout.cpp
+192
-0
test/uitest/test_layout/ui_auto_test_basic_layout.h
test/uitest/test_layout/ui_auto_test_basic_layout.h
+49
-0
test/uitest/test_layout/ui_test_basic_layout.cpp
test/uitest/test_layout/ui_test_basic_layout.cpp
+21
-21
test/uitest/test_layout/ui_test_basic_layout.h
test/uitest/test_layout/ui_test_basic_layout.h
+25
-2
test/uitest/test_render/ui_auto_test_render.cpp
test/uitest/test_render/ui_auto_test_render.cpp
+3
-3
tools/qt/simulator/libui/libui.pro
tools/qt/simulator/libui/libui.pro
+4
-1
tools/qt/simulator/test/test.pro
tools/qt/simulator/test/test.pro
+12
-6
未找到文件。
test/framework/BUILD.gn
浏览文件 @
b9132fb4
...
...
@@ -13,7 +13,11 @@ import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/subsystem/graphic/config.gni")
config("graphic_test_config") {
defines = [ "ENABLE_UI_AUTO_TEST=1" ]
if (ohos_kernel_type == "linux") {
defines = [ "AUTO_TEST_RESOURCE_PATH=\"/storage/data/auto_test/\"" ]
} else {
defines = [ "AUTO_TEST_RESOURCE_PATH=\"/user/data/auto_test/\"" ]
}
}
test_sources = [
...
...
@@ -71,14 +75,18 @@ test_sources = [
"src/ui_test_group.cpp",
]
test_sources += [
auto_test_sources = [
"../uitest/test_layout/ui_auto_test_basic_layout.cpp",
"../uitest/test_render/ui_auto_test_render.cpp",
"src/auto_test_app.cpp",
"src/auto_test_case_group.cpp",
"src/compare_tools.cpp",
"src/ui_auto_test.cpp",
"src/ui_auto_test_group.cpp",
]
static_library("framework") {
sources = test_sources
sources += auto_test_sources
include_dirs = [
"common",
...
...
@@ -98,11 +106,12 @@ static_library("framework") {
"//foundation/graphic/wms:wms_client",
]
configs += [ "//foundation/graphic/ui:graphic_define_config" ]
public_configs = [ ":graphic_test_config" ]
}
static_library("auto_framework") {
sources = test_sources
sources += auto_test_sources
include_dirs = [
"common",
"include",
...
...
@@ -114,7 +123,7 @@ static_library("auto_framework") {
"//foundation/multimedia/utils/lite/interfaces/kits",
"//foundation/multimedia/media_lite/interfaces/kits/player_lite",
]
defines = [ "ENABEL_UI_AUTO_TEST=1" ]
ldflags = [
"-lstdc++",
"-lpthread",
...
...
@@ -125,10 +134,8 @@ static_library("auto_framework") {
"//foundation/graphic/ui:ui",
"//foundation/graphic/wms:wms_client",
]
configs += [
":graphic_test_config",
"//foundation/graphic/ui:graphic_define_config",
]
configs += [ "//foundation/graphic/ui:graphic_define_config" ]
public_configs = [ ":graphic_test_config" ]
}
group("lite_graphic_test_framework") {
...
...
test/framework/include/
ui_auto_test_grou
p.h
→
test/framework/include/
auto_test_ap
p.h
浏览文件 @
b9132fb4
...
...
@@ -13,21 +13,23 @@
* 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"
#ifndef GRAPHIC_LITE_AUTO_TEST_APP_H
#define GRAPHIC_LITE_AUTO_TEST_APP_H
namespace
OHOS
{
class
UIAutoTestGrou
p
{
class
AutoTestAp
p
{
public:
static
void
SetUpTestCase
();
static
List
<
UIAutoTest
*>&
GetTestCase
();
static
void
TearDownTestCase
();
static
AutoTestApp
*
GetInstance
();
void
Start
();
private:
static
List
<
UIAutoTest
*>
testCaseList_
;
AutoTestApp
()
{}
virtual
~
AutoTestApp
();
AutoTestApp
(
const
AutoTestApp
&
)
=
delete
;
AutoTestApp
&
operator
=
(
const
AutoTestApp
&
)
=
delete
;
AutoTestApp
(
AutoTestApp
&&
)
=
delete
;
AutoTestApp
&
operator
=
(
AutoTestApp
&&
)
=
delete
;
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_UI_AUTO_TEST_GROUP_H
\ No newline at end of file
#endif // GRAPHIC_LITE_AUTO_TEST_APP_H
test/framework/include/auto_test_case_group.h
0 → 100644
浏览文件 @
b9132fb4
/*
* 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_AUTO_TEST_CASE_GROUP_H
#define GRAPHIC_LITE_AUTO_TEST_CASE_GROUP_H
#include "gfx_utils/list.h"
namespace
OHOS
{
class
AutoTestCaseGroup
{
public:
class
AutoTestCase
{
public:
AutoTestCase
()
{}
virtual
~
AutoTestCase
()
{}
virtual
void
RunTestList
()
=
0
;
virtual
void
Reset
()
const
=
0
;
virtual
void
ResetMainMenu
()
const
=
0
;
};
static
List
<
AutoTestCase
*>&
GetTestCase
();
static
void
TearDownTestCase
();
static
void
AddTestCase
(
AutoTestCase
*
testCaseInfo
);
private:
static
List
<
AutoTestCase
*>
testCaseList_
;
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_AUTO_TEST_CASE_GROUP_H
test/framework/include/compare_tools.h
浏览文件 @
b9132fb4
...
...
@@ -23,28 +23,36 @@
#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
;
constexpr
uint8_t
BITMAP_HEADER_SIZE
=
54
;
}
class
CompareTools
{
public:
enum
CompareMode
:
uint8_t
{
COMPARE_BINARY
,
COMPARE_IMAGE
struct
BitmapInfoHeader
{
uint32_t
bfSize
;
uint16_t
bfReserved1
;
uint16_t
bfReserved2
;
uint32_t
bfOffBits
;
uint32_t
biSize
;
int32_t
biWidth
;
int32_t
biHeight
;
uint16_t
biPlanes
;
uint16_t
biBitCount
;
uint32_t
biCompression
;
uint32_t
biSizeImage
;
uint32_t
biXPelsPerMeter
;
uint32_t
biYPelsPerMeter
;
uint32_t
biClrUsed
;
uint32_t
biClrImportant
;
};
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
CompareFile
(
const
char
*
filePath
,
size_t
length
);
static
bool
SaveFile
(
const
char
*
filePath
,
size_t
length
);
static
bool
CheckFileExist
(
const
char
*
filePath
,
size_t
length
);
static
void
SetLogPath
(
const
char
*
filePath
,
size_t
length
);
static
void
UnsetLogPath
();
...
...
@@ -54,9 +62,8 @@ private:
virtual
~
CompareTools
()
{}
static
bool
SaveLog
(
const
char
*
buff
,
size_t
bufSize
);
static
bool
CompareBinary
(
const
char
*
filePath
,
size_t
length
);
static
bool
SaveFrameBuffToBinary
(
const
char
*
filePath
,
size_t
length
);
static
bool
CompareByBit
(
uint32_t
fd
);
static
bool
SaveByBit
(
uint32_t
fd
);
static
bool
enableLog_
;
static
char
*
logPath_
;
};
...
...
test/framework/include/test_case_list_adapter.h
浏览文件 @
b9132fb4
...
...
@@ -24,21 +24,20 @@
namespace
OHOS
{
class
TestCaseListAdapter
:
public
AbstractAdapter
{
public:
TestCaseListAdapter
(
RootView
*
rootView
,
UIView
*
mainList
,
UILabelButton
*
backBtn
,
UILabel
*
label
,
UILabel
*
testTitleLabel
)
:
rootView_
(
rootView
),
mainList_
(
mainList
),
backBtn_
(
backBtn
),
testCaseLabel_
(
label
),
testLabel_
(
testTitleLabel
)
{}
TestCaseListAdapter
(
UIViewGroup
*
mainMenu
,
UILabelButton
*
backBtn
,
UILabel
*
testTitleLabel
)
:
rootView_
(
RootView
::
GetInstance
()),
mainMenu_
(
mainMenu
),
backBtn_
(
backBtn
),
testCaseLabel_
(
testTitleLabel
)
{}
~
TestCaseListAdapter
()
{}
UIView
*
GetView
(
UIView
*
inView
,
int16_t
index
)
override
;
int16_t
GetItemWidthWithMargin
(
int16_t
index
)
override
;
int16_t
GetItemHeightWithMargin
(
int16_t
index
)
override
;
uint16_t
GetCount
()
override
;
private:
RootView
*
rootView_
;
UIView
*
mainList
_
;
UIView
Group
*
mainMenu
_
;
UILabelButton
*
backBtn_
;
UILabel
*
testCaseLabel_
;
UILabel
*
testLabel_
;
};
}
// namespace OHOS
#endif // TEST_CASE_LIST_ADAPTER_H
\ No newline at end of file
test/framework/include/ui_auto_test.h
浏览文件 @
b9132fb4
...
...
@@ -16,17 +16,16 @@
#ifndef GRAPHIC_LITE_UI_AUTO_TEST_H
#define GRAPHIC_LITE_UI_AUTO_TEST_H
#include "auto_test_case_group.h"
#include "components/ui_view.h"
namespace
OHOS
{
class
UIAutoTest
{
class
UIAutoTest
:
public
AutoTestCaseGroup
::
AutoTestCase
{
public:
UIAutoTest
()
{}
virtual
~
UIAutoTest
()
{}
virtual
void
RunTestList
()
=
0
;
virtual
void
Reset
()
const
=
0
;
static
void
SetUpTestCase
();
void
ResetMainMenu
()
const
;
void
EnterSubMenu
(
const
char
*
id
)
const
;
void
ClickViewById
(
const
char
*
id
)
const
;
...
...
test/framework/include/ui_test_app.h
浏览文件 @
b9132fb4
...
...
@@ -20,6 +20,7 @@
#include "components/ui_label.h"
#include "components/ui_label_button.h"
#include "components/ui_list.h"
#include "graphic_thread.h"
#include "test_case_list_adapter.h"
namespace
OHOS
{
...
...
@@ -27,11 +28,15 @@ namespace {
constexpr
char
*
UI_TEST_MAIN_LIST_ID
=
"main_list"
;
constexpr
char
*
UI_TEST_BACK_BUTTON_ID
=
"back_button"
;
}
#ifdef _WIN32
DWORD
AutoTestThread
(
LPVOID
);
#elif defined __linux__ || defined __LITEOS__ || defined __APPLE__
void
*
AutoTestThread
(
void
*
);
#endif // _WIN32
class
UITestApp
{
public:
static
UITestApp
*
GetInstance
();
void
Start
();
void
Init
();
private:
UITestApp
()
{}
...
...
@@ -42,26 +47,18 @@ private:
UITestApp
(
UITestApp
&&
)
=
delete
;
UITestApp
&
operator
=
(
UITestApp
&&
)
=
delete
;
void
Init
();
void
InitMainMenu
();
void
InitBackBtn
();
void
InitTestLabel
();
RootView
*
rootView_
=
nullptr
;
UIList
*
mainList_
=
nullptr
;
TestCaseListAdapter
*
adapter_
=
nullptr
;
UILabelButton
*
backBtn_
=
nullptr
;
UILabel
*
testCaseLabel_
=
nullptr
;
UILabel
*
testLabel_
=
nullptr
;
};
class
UIAutoTestApp
{
public:
static
UIAutoTestApp
*
GetInstance
();
void
Start
();
private:
UIAutoTestApp
()
{}
virtual
~
UIAutoTestApp
();
UIAutoTestApp
(
const
UIAutoTestApp
&
)
=
delete
;
UIAutoTestApp
&
operator
=
(
const
UIAutoTestApp
&
)
=
delete
;
UIAutoTestApp
(
UIAutoTestApp
&&
)
=
delete
;
UIAutoTestApp
&
operator
=
(
UIAutoTestApp
&&
)
=
delete
;
UILabelButton
*
autoTestBtn_
=
nullptr
;
UIViewGroup
*
mainMenu_
=
nullptr
;
};
}
// namespace OHOS
#endif
test/framework/src/auto_test_app.cpp
0 → 100644
浏览文件 @
b9132fb4
/*
* 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 "auto_test_app.h"
#include "auto_test_case_group.h"
#include "compare_tools.h"
#include "dfx/event_injector.h"
#if ENABLE_WINDOW
#include "window/window.h"
#endif
namespace
OHOS
{
AutoTestApp
*
AutoTestApp
::
GetInstance
()
{
static
AutoTestApp
instance
;
return
&
instance
;
}
void
AutoTestApp
::
Start
()
{
EventInjector
::
GetInstance
()
->
RegisterEventInjector
(
EventDataType
::
POINT_TYPE
);
EventInjector
::
GetInstance
()
->
RegisterEventInjector
(
EventDataType
::
KEY_TYPE
);
#if ENABLE_WINDOW
Window
*
window
=
RootView
::
GetInstance
()
->
GetBoundWindow
();
if
(
window
!=
nullptr
)
{
EventInjector
::
GetInstance
()
->
SetWindowId
(
window
->
GetWindowId
());
}
#endif
CompareTools
::
WaitSuspend
();
ListNode
<
AutoTestCaseGroup
::
AutoTestCase
*>*
node
=
AutoTestCaseGroup
::
GetTestCase
().
Begin
();
while
(
node
!=
AutoTestCaseGroup
::
GetTestCase
().
End
())
{
node
->
data_
->
RunTestList
();
node
->
data_
->
ResetMainMenu
();
node
=
node
->
next_
;
}
}
AutoTestApp
::~
AutoTestApp
()
{
if
(
EventInjector
::
GetInstance
()
->
IsEventInjectorRegistered
(
EventDataType
::
POINT_TYPE
))
{
EventInjector
::
GetInstance
()
->
UnregisterEventInjector
(
EventDataType
::
POINT_TYPE
);
}
if
(
EventInjector
::
GetInstance
()
->
IsEventInjectorRegistered
(
EventDataType
::
KEY_TYPE
))
{
EventInjector
::
GetInstance
()
->
UnregisterEventInjector
(
EventDataType
::
KEY_TYPE
);
}
AutoTestCaseGroup
::
TearDownTestCase
();
}
}
// namespace OHOS
test/framework/src/
ui_auto_test
_group.cpp
→
test/framework/src/
auto_test_case
_group.cpp
浏览文件 @
b9132fb4
...
...
@@ -13,31 +13,31 @@
* limitations under the License.
*/
#include "
ui_auto_test
_group.h"
#include "
auto_test_case
_group.h"
#include "graphic_config.h"
#include "test_render/ui_auto_test_render.h"
namespace
OHOS
{
List
<
UIAutoTest
*>
UIAutoTest
Group
::
testCaseList_
;
List
<
AutoTestCaseGroup
::
AutoTestCase
*>
AutoTestCase
Group
::
testCaseList_
;
void
UIAutoTestGroup
::
SetUpTestCase
()
{
testCaseList_
.
PushBack
(
new
UIAutoTestRender
());
}
List
<
UIAutoTest
*>&
UIAutoTestGroup
::
GetTestCase
()
List
<
AutoTestCaseGroup
::
AutoTestCase
*>&
AutoTestCaseGroup
::
GetTestCase
()
{
return
testCaseList_
;
}
void
UIAutoTest
Group
::
TearDownTestCase
()
void
AutoTestCase
Group
::
TearDownTestCase
()
{
ListNode
<
UIAutoTest
*>*
node
=
testCaseList_
.
Begin
();
ListNode
<
AutoTestCase
*>*
node
=
testCaseList_
.
Begin
();
while
(
node
!=
testCaseList_
.
End
())
{
delete
node
->
data_
;
node
->
data_
=
nullptr
;
node
=
node
->
next_
;
}
testCaseList_
.
Clear
();
}
void
AutoTestCaseGroup
::
AddTestCase
(
AutoTestCase
*
testCaseInfo
)
{
if
(
testCaseInfo
!=
nullptr
)
{
testCaseList_
.
PushBack
(
testCaseInfo
);
}
}
}
// namespace OHOS
test/framework/src/compare_tools.cpp
浏览文件 @
b9132fb4
...
...
@@ -14,14 +14,21 @@
*/
#include "compare_tools.h"
#include <cstring>
#include "common/screen.h"
#include "dock/screen_device_proxy.h"
#include "draw/draw_utils.h"
#include "gfx_utils/file.h"
#include "gfx_utils/graphic_log.h"
#include "gfx_utils/graphic_math.h"
#include "graphic_config.h"
#include "securec.h"
#ifdef _WIN32
#define STR(STRING) #STRING
#define STRPATH(STRING) STR(STRING)
#endif
namespace
OHOS
{
bool
CompareTools
::
enableLog_
=
false
;
char
*
CompareTools
::
logPath_
=
nullptr
;
...
...
@@ -40,137 +47,163 @@ bool CompareTools::StrnCatPath(char* filePath, size_t pathMax, const char* fileN
if
((
filePath
==
nullptr
)
||
(
pathMax
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
char
dest
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
UI_AUTO_TEST_RESOURCE_PATH
;
#ifdef _WIN32
char
dest
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
STRPATH
(
AUTO_TEST_RESOURCE_PATH
);
#else
char
dest
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
AUTO_TEST_RESOURCE_PATH
;
#endif // _WIN32
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
)
{
if
(
memcpy_s
(
static_cast
<
void
*>
(
filePath
),
pathMax
,
dest
,
DEFAULT_FILE_NAME_MAX_LENGTH
)
!=
EOK
)
{
return
false
;
}
return
true
;
}
bool
CompareTools
::
Compare
File
(
const
char
*
src
,
size_t
length
,
uint8_t
flag
)
bool
CompareTools
::
Compare
ByBit
(
uint32_t
fd
)
{
switch
(
flag
)
{
case
COMPARE_BINARY
:
return
CompareBinary
(
src
,
length
);
case
COMPARE_IMAGE
:
// Unrealized : image for comparison
break
;
default:
break
;
ImageInfo
imageBit
;
if
(
!
(
Screen
::
GetInstance
().
GetCurrentScreenBitmap
(
imageBit
)))
{
return
false
;
}
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
struct
BitmapInfoHeader
bitmapInfo
=
{
0
};
lseek
(
fd
,
sizeof
(
uint16_t
),
SEEK_SET
);
if
(
read
(
fd
,
&
bitmapInfo
,
sizeof
(
bitmapInfo
))
<
0
)
{
ImageCacheFree
(
imageBit
);
return
false
;
}
if
(
bitmapInfo
.
biSizeImage
!=
imageBit
.
dataSize
)
{
ImageCacheFree
(
imageBit
);
return
false
;
}
bool
flag
=
true
;
uint32_t
buffSize
=
bitmapInfo
.
biSizeImage
/
MATH_ABS
(
bitmapInfo
.
biHeight
);
auto
buff
=
new
uint8_t
[
buffSize
];
for
(
uint32_t
i
=
0
;
i
<
MATH_ABS
(
bitmapInfo
.
biHeight
);
i
++
)
{
if
(
flag
&&
(
memset_s
(
buff
,
buffSize
,
0
,
buffSize
)
!=
EOK
))
{
flag
=
false
;
break
;
default:
}
uint32_t
ret
=
read
(
fd
,
buff
,
buffSize
);
if
(
ret
<
0
)
{
flag
=
false
;
break
;
}
for
(
uint32_t
j
=
0
;
j
<
ret
;
j
++
)
{
if
(
buff
[
j
]
!=
imageBit
.
data
[
i
*
buffSize
+
j
])
{
flag
=
false
;
break
;
}
}
}
return
false
;
ImageCacheFree
(
imageBit
);
delete
[]
buff
;
buff
=
nullptr
;
return
flag
;
}
bool
CompareTools
::
Compare
Binary
(
const
char
*
filePath
,
size_t
length
)
bool
CompareTools
::
Compare
File
(
const
char
*
filePath
,
size_t
length
)
{
if
((
filePath
==
nullptr
)
||
(
length
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
BufferInfo
*
bufferInfo
=
BaseGfxEngine
::
GetInstance
()
->
GetFBBufferInfo
();
if
(
bufferInfo
==
nullptr
)
{
return
false
;
}
uint8_t
*
frameBuf
=
static_cast
<
uint8_t
*>
(
bufferInfo
->
virAddr
);
if
(
frameBuf
==
nullptr
)
{
return
false
;
}
uint8_t
sizeByColorMode
=
DrawUtils
::
GetByteSizeByColorMode
(
bufferInfo
->
mode
);
uint32_t
buffSize
=
HORIZONTAL_RESOLUTION
*
VERTICAL_RESOLUTION
*
sizeByColorMode
;
uint8_t
*
readBuf
=
new
uint8_t
[
buffSize
];
if
(
readBuf
==
nullptr
)
{
return
false
;
}
FILE
*
fd
=
fopen
(
filePath
,
"rb"
);
if
(
fd
==
nullptr
)
{
delete
[]
readBuf
;
return
false
;
}
if
(
fread
(
readBuf
,
sizeof
(
uint8_t
),
buffSize
,
fd
)
<
0
)
{
delete
[]
readBuf
;
fclose
(
fd
);
#ifdef _WIN32
uint32_t
fd
=
open
(
filePath
,
O_RDONLY
|
O_BINARY
);
#else
uint32_t
fd
=
open
(
filePath
,
O_RDONLY
);
#endif
if
(
fd
==
-
1
)
{
return
false
;
}
bool
ret
=
true
;
for
(
int32_t
i
=
0
;
i
<
(
buffSize
/
sizeof
(
uint8_t
));
i
++
)
{
if
(
readBuf
[
i
]
!=
frameBuf
[
i
])
{
ret
=
false
;
break
;
}
}
if
(
ret
)
{
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[SUCCESS]:fileName=%s"
,
filePath
);
}
else
{
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[FAILURE]:fileName=%s"
,
filePath
);
}
delete
[]
readBuf
;
fclose
(
fd
);
if
(
enableLog_
)
{
char
logBuf
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
if
(
ret
)
{
if
(
sprintf_s
(
logBuf
,
DEFAULT_FILE_NAME_MAX_LENGTH
,
"[SUCCESS]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
bool
flag
=
CompareByBit
(
fd
);
close
(
fd
);
if
(
flag
)
{
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[COMPARE_SUCCESS]:fileName=%s"
,
filePath
);
if
(
enableLog_
)
{
char
logInfo
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
if
(
sprintf_s
(
logInfo
,
sizeof
(
logInfo
),
"[COMPARE_SUCCESS]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
return
false
;
}
}
else
{
if
(
sprintf_s
(
logBuf
,
DEFAULT_FILE_NAME_MAX_LENGTH
,
"[FAILURE]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
SaveLog
(
logInfo
,
strlen
(
logInfo
));
}
}
else
{
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[COMPARE_FAILURE]:fileName=%s"
,
filePath
);
if
(
enableLog_
)
{
char
logInfo
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
if
(
sprintf_s
(
logInfo
,
sizeof
(
logInfo
),
"[COMPARE_FAILURE]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
return
false
;
}
SaveLog
(
logInfo
,
strlen
(
logInfo
));
}
SaveLog
(
logBuf
,
strlen
(
logBuf
));
}
return
ret
;
return
flag
;
}
bool
CompareTools
::
Save
FrameBuffToBinary
(
const
char
*
filePath
,
size_t
length
)
bool
CompareTools
::
Save
ByBit
(
uint32_t
fd
)
{
if
((
filePath
==
nullptr
)
||
(
length
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
BufferInfo
*
bufferInfo
=
BaseGfxEngine
::
GetInstance
()
->
GetFBBufferInfo
();
if
(
bufferInfo
==
nullptr
)
{
ImageInfo
imageBit
;
if
(
!
(
Screen
::
GetInstance
().
GetCurrentScreenBitmap
(
imageBit
)))
{
return
false
;
}
uint8_t
*
frameBuf
=
static_cast
<
uint8_t
*>
(
bufferInfo
->
virAddr
);
if
(
frameBuf
==
nullptr
)
{
HILOG_ERROR
(
HILOG_MODULE_GRAPHIC
,
"GetBuffer failed"
);
return
false
;
bool
flag
=
false
;
uint8_t
sizeByColorMode
=
DrawUtils
::
GetByteSizeByColorMode
(
ScreenDeviceProxy
::
GetInstance
()
->
GetBufferMode
());
uint16_t
bfType
=
0x4D42
;
struct
BitmapInfoHeader
bitmapInfo
=
{
0
};
bitmapInfo
.
bfSize
=
imageBit
.
dataSize
+
BITMAP_HEADER_SIZE
;
bitmapInfo
.
bfOffBits
=
BITMAP_HEADER_SIZE
;
bitmapInfo
.
biSize
=
40
;
// 40: bitmap infomation header size
bitmapInfo
.
biWidth
=
imageBit
.
header
.
width
;
bitmapInfo
.
biHeight
=
-
imageBit
.
header
.
height
;
bitmapInfo
.
biPlanes
=
1
;
bitmapInfo
.
biBitCount
=
sizeByColorMode
*
8
;
// 8: uint8_t bit
bitmapInfo
.
biSizeImage
=
imageBit
.
dataSize
;
if
(
!
flag
&&
(
write
(
fd
,
&
bfType
,
sizeof
(
bfType
))
>
0
))
{
if
(
write
(
fd
,
&
bitmapInfo
,
sizeof
(
bitmapInfo
))
>
0
)
{
if
(
write
(
fd
,
imageBit
.
data
,
imageBit
.
dataSize
)
>
0
)
{
flag
=
true
;
}
}
}
uint8_t
sizeByColorMode
=
DrawUtils
::
GetByteSizeByColorMode
(
bufferInfo
->
mode
);
uint32_t
buffSize
=
HORIZONTAL_RESOLUTION
*
VERTICAL_RESOLUTION
*
sizeByColorMode
;
FILE
*
fd
=
fopen
(
filePath
,
"wb+"
);
if
(
fd
==
nullptr
)
{
ImageCacheFree
(
imageBit
);
return
flag
;
}
bool
CompareTools
::
SaveFile
(
const
char
*
filePath
,
size_t
length
)
{
if
((
filePath
==
nullptr
)
||
(
length
>
DEFAULT_FILE_NAME_MAX_LENGTH
))
{
return
false
;
}
if
(
fwrite
(
frameBuf
,
sizeof
(
uint8_t
),
buffSize
,
fd
)
<
0
)
{
fclose
(
fd
);
#ifdef _WIN32
uint32_t
fd
=
open
(
filePath
,
O_WRONLY
|
O_CREAT
|
O_BINARY
);
#else
uint32_t
fd
=
open
(
filePath
,
O_WRONLY
|
O_CREAT
);
#endif
if
(
fd
==
-
1
)
{
return
false
;
}
fclose
(
fd
);
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[SAVEBIN]:fileName=%s"
,
filePath
);
if
(
enableLog_
)
{
char
logBuf
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
if
(
sprintf_s
(
logBuf
,
DEFAULT_FILE_NAME_MAX_LENGTH
,
"[SAVEBIN]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
return
false
;
bool
flag
=
SaveByBit
(
fd
);
close
(
fd
);
if
(
flag
)
{
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[SAVE_SUCCESS]:filePath = %s"
,
filePath
);
if
(
enableLog_
)
{
char
logInfo
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
if
(
sprintf_s
(
logInfo
,
sizeof
(
logInfo
),
"[SAVE_SUCCESS]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
return
false
;
}
SaveLog
(
logInfo
,
strlen
(
logInfo
));
}
}
else
{
HILOG_INFO
(
HILOG_MODULE_GRAPHIC
,
"[SAVE_FAILURE]:filePath = %s"
,
filePath
);
if
(
enableLog_
)
{
char
logInfo
[
DEFAULT_FILE_NAME_MAX_LENGTH
]
=
{
0
};
if
(
sprintf_s
(
logInfo
,
sizeof
(
logInfo
),
"[SAVE_FAILURE]:fileName=%s
\n
"
,
filePath
)
<
0
)
{
return
false
;
}
SaveLog
(
logInfo
,
strlen
(
logInfo
));
}
SaveLog
(
logBuf
,
strlen
(
logBuf
));
}
return
true
;
return
flag
;
}
bool
CompareTools
::
CheckFileExist
(
const
char
*
filePath
,
size_t
length
)
...
...
@@ -178,11 +211,11 @@ 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
)
{
uint32_t
fd
=
open
(
filePath
,
O_RDONLY
);
if
(
fd
==
-
1
)
{
return
false
;
}
f
close
(
fd
);
close
(
fd
);
return
true
;
}
...
...
@@ -193,7 +226,6 @@ void CompareTools::SetLogPath(const char* filePath, size_t length)
if
(
logPath_
==
nullptr
)
{
return
;
}
if
(
memcpy_s
(
logPath_
,
length
,
filePath
,
length
)
!=
EOK
)
{
HILOG_ERROR
(
HILOG_MODULE_GRAPHIC
,
"memcpy filepath failed"
);
return
;
...
...
@@ -216,17 +248,17 @@ bool CompareTools::SaveLog(const char* buff, size_t bufSize)
if
((
buff
==
nullptr
)
||
(
logPath_
==
nullptr
))
{
return
false
;
}
FILE
*
log
=
fopen
(
logPath_
,
"a"
);
if
(
log
==
nullptr
)
{
uint32_t
logFd
=
open
(
logPath_
,
O_WRONLY
|
O_CREAT
|
O_APPEND
);
if
(
log
Fd
==
-
1
)
{
HILOG_ERROR
(
HILOG_MODULE_GRAPHIC
,
"open log failed"
);
return
false
;
}
if
(
fwrite
(
buff
,
1
,
bufSize
,
log
)
<
0
)
{
fclose
(
log
);
if
(
write
(
logFd
,
buff
,
bufSize
)
<
0
)
{
close
(
logFd
);
HILOG_ERROR
(
HILOG_MODULE_GRAPHIC
,
"write log failed"
);
return
false
;
}
fclose
(
log
);
close
(
logFd
);
return
true
;
}
}
// namespace OHOS
test/framework/src/test_ability.cpp
浏览文件 @
b9132fb4
...
...
@@ -14,33 +14,13 @@
*/
#include "ui_test_app.h"
#ifdef _WIN32
#include <thread>
#else
#include <pthread.h>
#endif // _WIN32
#ifdef _WIN32
void
AutoTestThread
()
#else
void
*
AutoTestThread
(
void
*
)
#endif // _WIN32
{
OHOS
::
UIAutoTestApp
::
GetInstance
()
->
Start
();
}
#include "graphic_thread.h"
void
RunApp
()
{
OHOS
::
UITestApp
::
GetInstance
()
->
Start
();
#if ENABLE_UI_AUTO_TEST
#ifdef _WIN32
std
::
thread
autoTestPthread
(
AutoTestThread
);
autoTestPthread
.
detach
();
#else
pthread_t
thread
;
pthread_create
(
&
thread
,
0
,
AutoTestThread
,
nullptr
);
pthread_detach
(
thread
);
#endif // _WIN32
#endif // ENABLE_UI_AUTO_TEST
#if ENABEL_UI_AUTO_TEST
ThreadAttr
attr
;
ThreadCreate
(
OHOS
::
AutoTestThread
,
nullptr
,
&
attr
);
#endif // ENABEL_UI_AUTO_TEST
}
test/framework/src/test_case_list_adapter.cpp
浏览文件 @
b9132fb4
...
...
@@ -38,11 +38,10 @@ uint16_t TestCaseListAdapter::GetCount()
class
BtnOnClickBackListener
:
public
UIView
::
OnClickListener
{
public:
BtnOnClickBackListener
(
UIViewGroup
*
uiView
,
UIView
*
mainList
,
UIView
Group
*
mainMenu
,
UITest
*
uiTest
,
UILabel
*
testCaseLabel
,
UILabel
*
testLabel
)
:
rootView_
(
uiView
),
mainList_
(
mainList
),
uiTest_
(
uiTest
),
testCaseLabel_
(
testCaseLabel
),
testLabel_
(
testLabel
)
UILabel
*
testCaseLabel
)
:
rootView_
(
uiView
),
mainMenu_
(
mainMenu
),
uiTest_
(
uiTest
),
testCaseLabel_
(
testCaseLabel
)
{
}
...
...
@@ -50,8 +49,7 @@ public:
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
if
((
rootView_
==
nullptr
)
||
(
mainList_
==
nullptr
)
||
(
uiTest_
==
nullptr
)
||
(
testCaseLabel_
==
nullptr
)
||
(
testLabel_
==
nullptr
))
{
if
((
rootView_
==
nullptr
)
||
(
mainMenu_
==
nullptr
)
||
(
uiTest_
==
nullptr
)
||
(
testCaseLabel_
==
nullptr
))
{
return
false
;
}
...
...
@@ -64,33 +62,29 @@ public:
uiTest_
->
TearDown
();
}
rootView_
->
Add
(
testLabel_
);
rootView_
->
Add
(
mainList_
);
rootView_
->
Add
(
mainMenu_
);
rootView_
->
Invalidate
();
return
true
;
}
private:
UIViewGroup
*
rootView_
;
UIView
*
mainList
_
;
UIView
Group
*
mainMenu
_
;
UILabel
*
testCaseLabel_
;
UILabel
*
testLabel_
;
UITest
*
uiTest_
;
};
class
BtnOnClickUiTestListener
:
public
UIView
::
OnClickListener
{
public:
BtnOnClickUiTestListener
(
UIViewGroup
*
uiView
,
UIView
*
mainList
,
UIView
Group
*
mainMenu_
,
UILabelButton
*
backBtn
,
TestCaseInfo
*
uiTestInfo
,
UILabel
*
testCaseLabel
,
UILabel
*
testLabel
)
UILabel
*
testCaseLabel
)
:
rootView_
(
uiView
),
main
List_
(
mainList
),
main
Menu_
(
mainMenu_
),
backBtn_
(
backBtn
),
testCaseLabel_
(
testCaseLabel
),
testLabel_
(
testLabel
),
uiTest_
(
nullptr
),
sliceId_
(
nullptr
)
{
...
...
@@ -102,19 +96,18 @@ public:
~
BtnOnClickUiTestListener
()
{}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
if
((
rootView_
==
nullptr
)
||
(
main
List
_
==
nullptr
)
||
(
backBtn_
==
nullptr
)
||
(
testCaseLabel_
==
nullptr
)
||
(
testLabel_
==
nullptr
)
||
(
uiTest_
==
nullptr
)
||
(
sliceId_
==
nullptr
))
{
if
((
rootView_
==
nullptr
)
||
(
main
Menu
_
==
nullptr
)
||
(
backBtn_
==
nullptr
)
||
(
testCaseLabel_
==
nullptr
)
||
(
uiTest_
==
nullptr
)
||
(
sliceId_
==
nullptr
))
{
return
false
;
}
rootView_
->
Remove
(
testLabel_
);
rootView_
->
Remove
(
mainList_
);
rootView_
->
Remove
(
mainMenu_
);
UIView
::
OnClickListener
*
click
=
backBtn_
->
GetOnClickListener
();
if
(
click
!=
nullptr
)
{
delete
click
;
click
=
nullptr
;
}
click
=
new
BtnOnClickBackListener
(
rootView_
,
main
List_
,
uiTest_
,
testCaseLabel_
,
test
Label_
);
click
=
new
BtnOnClickBackListener
(
rootView_
,
main
Menu_
,
uiTest_
,
testCase
Label_
);
backBtn_
->
SetOnClickListener
(
click
);
rootView_
->
Add
(
backBtn_
);
if
(
testCaseLabel_
!=
nullptr
)
{
...
...
@@ -135,8 +128,7 @@ public:
private:
UIViewGroup
*
rootView_
;
UIView
*
mainList_
;
UILabel
*
testLabel_
;
UIViewGroup
*
mainMenu_
;
UILabelButton
*
backBtn_
;
UITest
*
uiTest_
;
UILabel
*
testCaseLabel_
;
...
...
@@ -176,7 +168,7 @@ UIView* TestCaseListAdapter::GetView(UIView* inView, int16_t index)
for
(
uint16_t
i
=
0
;
i
<
index
;
i
++
)
{
node
=
node
->
next_
;
}
listener
=
new
BtnOnClickUiTestListener
(
rootView_
,
main
List_
,
backBtn_
,
&
node
->
data_
,
testCaseLabel_
,
test
Label_
);
listener
=
new
BtnOnClickUiTestListener
(
rootView_
,
main
Menu_
,
backBtn_
,
&
node
->
data_
,
testCase
Label_
);
item
->
SetOnClickListener
(
listener
);
item
->
SetText
(
node
->
data_
.
sliceId
);
item
->
SetViewId
(
node
->
data_
.
sliceId
);
...
...
@@ -198,7 +190,7 @@ UIView* TestCaseListAdapter::GetView(UIView* inView, int16_t index)
int16_t
TestCaseListAdapter
::
GetItemWidthWithMargin
(
int16_t
index
)
{
// 2: two borders on both sides
// 2: two borders on both sides
return
Screen
::
GetInstance
().
GetWidth
()
-
TEXT_DISTANCE_TO_LEFT_SIDE
+
STYLE_BORDER_WIDTH_VALUE
*
2
;
}
...
...
test/framework/src/ui_auto_test.cpp
浏览文件 @
b9132fb4
...
...
@@ -14,11 +14,14 @@
*/
#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 "test_layout/ui_auto_test_basic_layout.h"
#include "test_render/ui_auto_test_render.h"
#include "ui_test_app.h"
#include "ui_test_group.h"
...
...
@@ -100,9 +103,15 @@ void UIAutoTest::CompareByBinary(const char* fileName) const
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
);
CompareTools
::
CompareFile
(
filePath
,
sizeof
(
filePath
));
}
else
{
CompareTools
::
SaveFile
(
filePath
,
sizeof
(
filePath
)
,
CompareTools
::
CompareMode
::
COMPARE_BINARY
);
CompareTools
::
SaveFile
(
filePath
,
sizeof
(
filePath
));
}
}
void
UIAutoTest
::
SetUpTestCase
()
{
AutoTestCaseGroup
::
AddTestCase
(
new
UIAutoTestRender
());
AutoTestCaseGroup
::
AddTestCase
(
new
UIAutoTestBasicLayout
());
}
}
// namespace OHOS
test/framework/src/ui_test_app.cpp
浏览文件 @
b9132fb4
...
...
@@ -14,19 +14,35 @@
*/
#include "ui_test_app.h"
#include "common/screen.h"
#include "auto_test_app.h"
#include "compare_tools.h"
#include "dfx/event_injector.h"
#include "test_resource_config.h"
#include "ui_auto_test.h"
#include "ui_auto_test_group.h"
#include "ui_test.h"
#include "ui_test_group.h"
#if ENABLE_WINDOW
#include "window/window.h"
#endif
#include "ui_test.h"
namespace
OHOS
{
#ifdef _WIN32
DWORD
AutoTestThread
(
LPVOID
)
#elif defined __linux__ || defined __LITEOS__ || defined __APPLE__
void
*
AutoTestThread
(
void
*
)
#endif // _WIN32
{
#ifdef _WIN32
const
char
logPath
[]
=
".
\\
auto_test_log.txt"
;
CompareTools
::
SetLogPath
(
logPath
,
sizeof
(
logPath
));
#else
const
char
logPath
[]
=
"./auto_test_log.txt"
;
CompareTools
::
SetLogPath
(
logPath
,
sizeof
(
logPath
));
#endif
// 装载用例
UIAutoTest
::
SetUpTestCase
();
AutoTestApp
::
GetInstance
()
->
Start
();
AutoTestCaseGroup
::
TearDownTestCase
();
CompareTools
::
UnsetLogPath
();
}
UITestApp
*
UITestApp
::
GetInstance
()
{
static
UITestApp
instance
;
...
...
@@ -39,11 +55,88 @@ void UITestApp::Start()
rootView_
=
RootView
::
GetInstance
();
rootView_
->
SetPosition
(
0
,
0
);
rootView_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
());
if
(
mainMenu_
==
nullptr
)
{
mainMenu_
=
new
UIViewGroup
();
mainMenu_
->
SetPosition
(
0
,
0
,
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
());
rootView_
->
Add
(
mainMenu_
);
rootView_
->
Invalidate
();
}
}
Init
();
}
class
BtnOnClickOnAutoTestListener
:
public
UIView
::
OnClickListener
{
public:
BtnOnClickOnAutoTestListener
()
{}
virtual
~
BtnOnClickOnAutoTestListener
()
{}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
ThreadCreate
(
AutoTestThread
,
nullptr
,
nullptr
);
}
};
void
UITestApp
::
Init
()
{
InitBackBtn
();
InitTestLabel
();
InitMainMenu
();
}
void
UITestApp
::
InitMainMenu
()
{
if
(
mainMenu_
!=
nullptr
)
{
if
(
testLabel_
==
nullptr
)
{
testLabel_
=
new
UILabel
();
testLabel_
->
Resize
(
300
,
BACK_BUTTON_HEIGHT
);
// 300: test Label width;
testLabel_
->
SetAlign
(
TEXT_ALIGNMENT_LEFT
,
TEXT_ALIGNMENT_CENTER
);
testLabel_
->
SetPosition
(
TEXT_DISTANCE_TO_LEFT_SIDE
,
0
);
testLabel_
->
SetText
(
"Test Demo"
);
testLabel_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
30
);
// 30: means font size
mainMenu_
->
Add
(
testLabel_
);
}
if
(
autoTestBtn_
==
nullptr
)
{
autoTestBtn_
=
new
UILabelButton
();
autoTestBtn_
->
Resize
(
163
,
64
);
// 163: button width; 64: button height
autoTestBtn_
->
SetPosition
(
Screen
::
GetInstance
().
GetWidth
()
-
autoTestBtn_
->
GetWidth
(),
0
);
autoTestBtn_
->
SetText
(
"自动测试"
);
auto
listern
=
new
BtnOnClickOnAutoTestListener
();
autoTestBtn_
->
SetOnClickListener
(
listern
);
autoTestBtn_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
24
);
// 24: means font size
autoTestBtn_
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
0
,
UIButton
::
RELEASED
);
autoTestBtn_
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
0
,
UIButton
::
PRESSED
);
autoTestBtn_
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
0
,
UIButton
::
INACTIVE
);
autoTestBtn_
->
SetStyleForState
(
STYLE_BACKGROUND_OPA
,
0
,
UIButton
::
RELEASED
);
autoTestBtn_
->
SetStyleForState
(
STYLE_BACKGROUND_OPA
,
0
,
UIButton
::
PRESSED
);
autoTestBtn_
->
SetStyleForState
(
STYLE_BACKGROUND_OPA
,
0
,
UIButton
::
INACTIVE
);
mainMenu_
->
Add
(
autoTestBtn_
);
}
if
((
mainList_
==
nullptr
)
&&
(
adapter_
==
nullptr
))
{
uint8_t
deltaHeight
=
60
;
// 60: UIList height(64) - first button border width(4)
constexpr
uint8_t
margin
=
24
;
// 24: x-coordinate
mainList_
=
new
UIList
(
UIList
::
VERTICAL
);
mainList_
->
SetPosition
(
margin
,
deltaHeight
);
mainList_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
()
-
margin
,
Screen
::
GetInstance
().
GetHeight
()
-
deltaHeight
);
mainList_
->
SetThrowDrag
(
true
);
mainList_
->
SetReboundSize
(
50
);
// 50: rebound size
mainList_
->
SetViewId
(
UI_TEST_MAIN_LIST_ID
);
mainList_
->
SetYScrollBarVisible
(
true
);
if
(
backBtn_
==
nullptr
)
{
InitBackBtn
();
}
if
(
testCaseLabel_
==
nullptr
)
{
InitTestLabel
();
}
adapter_
=
new
TestCaseListAdapter
(
mainMenu_
,
backBtn_
,
testCaseLabel_
);
UITestGroup
::
SetUpTestCase
();
mainList_
->
SetAdapter
(
adapter_
);
mainMenu_
->
Add
(
mainList_
);
}
}
}
void
UITestApp
::
InitBackBtn
()
{
if
(
backBtn_
==
nullptr
)
{
backBtn_
=
new
UILabelButton
();
...
...
@@ -63,6 +156,10 @@ void UITestApp::Init()
backBtn_
->
SetStyleForState
(
STYLE_BACKGROUND_OPA
,
0
,
UIButton
::
PRESSED
);
backBtn_
->
SetStyleForState
(
STYLE_BACKGROUND_OPA
,
0
,
UIButton
::
INACTIVE
);
}
}
void
UITestApp
::
InitTestLabel
()
{
if
(
testCaseLabel_
==
nullptr
)
{
testCaseLabel_
=
new
UILabel
();
testCaseLabel_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
(),
BACK_BUTTON_HEIGHT
);
...
...
@@ -70,40 +167,15 @@ void UITestApp::Init()
testCaseLabel_
->
SetText
(
"Test Case Name"
);
testCaseLabel_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
30
);
// 30: means font size
}
if
(
testLabel_
==
nullptr
)
{
testLabel_
=
new
UILabel
();
testLabel_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
(),
BACK_BUTTON_HEIGHT
);
testLabel_
->
SetAlign
(
TEXT_ALIGNMENT_LEFT
,
TEXT_ALIGNMENT_CENTER
);
testLabel_
->
SetPosition
(
TEXT_DISTANCE_TO_LEFT_SIDE
,
0
);
testLabel_
->
SetText
(
"Test Demo"
);
testLabel_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
30
);
// 30: means font size
rootView_
->
Add
(
testLabel_
);
}
if
((
mainList_
==
nullptr
)
&&
(
adapter_
==
nullptr
))
{
uint8_t
deltaHeight
=
60
;
// 60: UIList height(64) - first button border width(4)
constexpr
uint8_t
margin
=
24
;
// 24: x-coordinate
mainList_
=
new
UIList
(
UIList
::
VERTICAL
);
mainList_
->
SetPosition
(
margin
,
deltaHeight
);
mainList_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
()
-
margin
,
Screen
::
GetInstance
().
GetHeight
()
-
deltaHeight
);
mainList_
->
SetThrowDrag
(
true
);
mainList_
->
SetReboundSize
(
50
);
// 50: rebound size
mainList_
->
SetViewId
(
UI_TEST_MAIN_LIST_ID
);
mainList_
->
SetYScrollBarVisible
(
true
);
adapter_
=
new
TestCaseListAdapter
(
rootView_
,
mainList_
,
backBtn_
,
testCaseLabel_
,
testLabel_
);
UITestGroup
::
SetUpTestCase
();
mainList_
->
SetAdapter
(
adapter_
);
rootView_
->
Add
(
mainList_
);
rootView_
->
Invalidate
();
}
}
UITestApp
::~
UITestApp
()
{
if
(
mainList
_
!=
nullptr
)
{
if
(
adapter
_
!=
nullptr
)
{
delete
adapter_
;
adapter_
=
nullptr
;
}
if
(
adapter
_
!=
nullptr
)
{
if
(
mainList
_
!=
nullptr
)
{
delete
mainList_
;
mainList_
=
nullptr
;
}
...
...
@@ -114,52 +186,18 @@ UITestApp::~UITestApp()
if
(
rootView_
!=
nullptr
)
{
rootView_
=
nullptr
;
}
}
UIAutoTestApp
*
UIAutoTestApp
::
GetInstance
()
{
static
UIAutoTestApp
instance
;
return
&
instance
;
}
void
UIAutoTestApp
::
Start
()
{
EventInjector
::
GetInstance
()
->
RegisterEventInjector
(
EventDataType
::
POINT_TYPE
);
EventInjector
::
GetInstance
()
->
RegisterEventInjector
(
EventDataType
::
KEY_TYPE
);
#ifdef _WIN32
char
logPath
[]
=
".
\\
auto_test_log.txt"
;
CompareTools
::
SetLogPath
(
logPath
,
sizeof
(
logPath
));
#else
char
logPath
[]
=
"./auto_test_log.txt"
;
CompareTools
::
SetLogPath
(
logPath
,
sizeof
(
logPath
));
#endif
#if ENABLE_WINDOW
Window
*
window
=
RootView
::
GetInstance
()
->
GetBoundWindow
();
if
(
window
!=
nullptr
)
{
EventInjector
::
GetInstance
()
->
SetWindowId
(
window
->
GetWindowId
());
if
(
autoTestBtn_
!=
nullptr
)
{
auto
listener
=
autoTestBtn_
->
GetOnClickListener
();
if
(
listener
!=
nullptr
)
{
delete
listener
;
autoTestBtn_
->
SetOnClickListener
(
nullptr
);
}
delete
autoTestBtn_
;
autoTestBtn_
=
nullptr
;
}
#endif
CompareTools
::
WaitSuspend
();
UIAutoTestGroup
::
SetUpTestCase
();
ListNode
<
UIAutoTest
*>*
node
=
UIAutoTestGroup
::
GetTestCase
().
Begin
();
while
(
node
!=
UIAutoTestGroup
::
GetTestCase
().
End
())
{
node
->
data_
->
RunTestList
();
node
->
data_
->
ResetMainMenu
();
node
=
node
->
next_
;
if
(
mainMenu_
!=
nullptr
)
{
delete
mainMenu_
;
mainMenu_
=
nullptr
;
}
}
UIAutoTestApp
::~
UIAutoTestApp
()
{
if
(
EventInjector
::
GetInstance
()
->
IsEventInjectorRegistered
(
EventDataType
::
POINT_TYPE
))
{
EventInjector
::
GetInstance
()
->
UnregisterEventInjector
(
EventDataType
::
POINT_TYPE
);
}
if
(
EventInjector
::
GetInstance
()
->
IsEventInjectorRegistered
(
EventDataType
::
KEY_TYPE
))
{
EventInjector
::
GetInstance
()
->
UnregisterEventInjector
(
EventDataType
::
KEY_TYPE
);
}
CompareTools
::
UnsetLogPath
();
UIAutoTestGroup
::
TearDownTestCase
();
}
}
// namespace OHOS
test/uitest/test_layout/ui_auto_test_basic_layout.cpp
0 → 100644
浏览文件 @
b9132fb4
/*
* 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_basic_layout.h"
#include "ui_test_basic_layout.h"
namespace
OHOS
{
void
UIAutoTestBasicLayout
::
Reset
()
const
{
ResetMainMenu
();
EnterSubMenu
(
UI_TEST_BASIC_LAYOUT_ID
);
}
void
UIAutoTestBasicLayout
::
RunTestList
()
{
Reset
();
UIKitBasicLayoutTestMargin001
();
UIKitBasicLayoutTestPadding001
();
UIKitBasicLayoutTestCenterOfParent001
();
UIKitBasicLayoutTestLeftOfParent001
();
UIKitBasicLayoutTestRightOfParent001
();
UIKitBasicLayoutTestTopOfParent001
();
UIKitBasicLayoutTestBottomOfParent001
();
UIKitBasicLayoutTestLeftOfSibling001
();
UIKitBasicLayoutTestRightOfSibling001
();
UIKitBasicLayoutTestTopOfSibling001
();
UIKitBasicLayoutTestBottomOfSibling001
();
UIKitBasicLayoutTestHorCenterOfSibling001
();
UIKitBasicLayoutTestVerCenterOfSibling001
();
UIKitBasicLayoutTestLeftToSibling001
();
UIKitBasicLayoutTestRightToSibling001
();
UIKitBasicLayoutTestTopToSibling001
();
UIKitBasicLayoutTestBottomToSibling001
();
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestMargin001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_MARGIN_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_LEFTOFPARENT_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_margin_top_left_001.bmp"
;
CompareByBinary
(
fileName
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RIGHTOFPARENT_BTN_ID
);
const
char
*
fileName2
=
"ui_test_basic_layout_margin_top_right_001.bmp"
;
CompareByBinary
(
fileName2
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_BOTTOMOFPARENT_BTN_ID
);
const
char
*
fileName3
=
"ui_test_basic_layout_margin_bottom_right_001.bmp"
;
CompareByBinary
(
fileName3
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RIGHTOFPARENT_BTN_ID
);
const
char
*
fileName4
=
"ui_test_basic_layout_margin_bottom_left_001.bmp"
;
CompareByBinary
(
fileName4
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestPadding001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_PADDING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_padding_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestCenterOfParent001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_CENTEROFPARENT_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_center_of_parent_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestLeftOfParent001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_LEFTOFPARENT_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_left_of_parent_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestRightOfParent001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RIGHTOFPARENT_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_right_of_parent_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestTopOfParent001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_TOPOFPARENT_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_top_of_parent_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestBottomOfParent001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_BOTTOMOFPARENT_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_bottom_of_parent_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestLeftOfSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_LEFTOFSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_left_of_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestRightOfSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RIGHTOFSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_right_of_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestTopOfSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_TOPOFSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_top_of_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestBottomOfSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_BOTTOMOFSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_bottom_of_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestHorCenterOfSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_HORCENTEROFSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_hor_center_of_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestVerCenterOfSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_VERCENTEROFSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_ver_center_of_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestLeftToSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_LEFTTOSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_left_to_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestRightToSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RIGHTTOSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_right_to_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestTopToSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_TOPTOSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_top_to_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestBasicLayout
::
UIKitBasicLayoutTestBottomToSibling001
()
const
{
ClickViewById
(
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
ClickViewById
(
UI_TEST_BASIC_LAYOUT_BOTTOMTOSIBLING_BTN_ID
);
const
char
*
fileName
=
"ui_test_basic_layout_bottom_to_sibling_001.bmp"
;
CompareByBinary
(
fileName
);
}
}
// namespace OHOS
\ No newline at end of file
test/uitest/test_layout/ui_auto_test_basic_layout.h
0 → 100644
浏览文件 @
b9132fb4
/*
* 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 UI_AUTO_TEST_BASIC_LAYOUT_H
#define UI_AUTO_TEST_BASIC_LAYOUT_H
#include "ui_auto_test.h"
namespace
OHOS
{
class
UIAutoTestBasicLayout
:
public
UIAutoTest
{
public:
UIAutoTestBasicLayout
()
{}
~
UIAutoTestBasicLayout
()
{}
void
Reset
()
const
;
void
RunTestList
();
void
UIKitBasicLayoutTestMargin001
()
const
;
void
UIKitBasicLayoutTestPadding001
()
const
;
void
UIKitBasicLayoutTestCenterOfParent001
()
const
;
void
UIKitBasicLayoutTestLeftOfParent001
()
const
;
void
UIKitBasicLayoutTestRightOfParent001
()
const
;
void
UIKitBasicLayoutTestTopOfParent001
()
const
;
void
UIKitBasicLayoutTestBottomOfParent001
()
const
;
void
UIKitBasicLayoutTestLeftOfSibling001
()
const
;
void
UIKitBasicLayoutTestRightOfSibling001
()
const
;
void
UIKitBasicLayoutTestTopOfSibling001
()
const
;
void
UIKitBasicLayoutTestBottomOfSibling001
()
const
;
void
UIKitBasicLayoutTestHorCenterOfSibling001
()
const
;
void
UIKitBasicLayoutTestVerCenterOfSibling001
()
const
;
void
UIKitBasicLayoutTestLeftToSibling001
()
const
;
void
UIKitBasicLayoutTestRightToSibling001
()
const
;
void
UIKitBasicLayoutTestTopToSibling001
()
const
;
void
UIKitBasicLayoutTestBottomToSibling001
()
const
;
};
}
// namespace OHOS
#endif // UI_AUTO_TEST_BASIC_LAYOUT_H
\ No newline at end of file
test/uitest/test_layout/ui_test_basic_layout.cpp
浏览文件 @
b9132fb4
...
...
@@ -97,11 +97,11 @@ void UITestBasicLayout::TearDown()
const
UIView
*
UITestBasicLayout
::
GetTestView
()
{
UIKit
_Layout_Test_Basic_Layout_
001
();
UIKit
LayoutTestBasicLayout
001
();
return
container_
;
}
void
UITestBasicLayout
::
UIKit
_Layout_Test_Basic_Layout_
001
()
void
UITestBasicLayout
::
UIKit
LayoutTestBasicLayout
001
()
{
if
(
container_
!=
nullptr
)
{
UIViewGroup
*
uiViewGroup
=
new
UIViewGroup
();
...
...
@@ -157,25 +157,25 @@ void UITestBasicLayout::UIKit_Layout_Test_Basic_Layout_001()
void
UITestBasicLayout
::
InitSetUpButton
()
{
SetUpButton
(
resetBtn_
,
"重置"
);
SetUpButton
(
marginBtn_
,
"margin"
);
SetUpButton
(
padBtn_
,
"padding"
);
SetUpButton
(
lCenterOfParentBtn_
,
"居中"
);
SetUpButton
(
lLeftOfParentBtn_
,
"居左"
);
SetUpButton
(
lRightOfParentBtn_
,
"居右"
);
SetUpButton
(
lTopOfParentBtn_
,
"居上"
);
SetUpButton
(
lBottomOfParentBtn_
,
"居下"
);
SetUpButton
(
aLeftToSiblingBtn_
,
"左侧对齐兄弟"
);
SetUpButton
(
aRightToSiblingBtn_
,
"右侧对齐兄弟"
);
SetUpButton
(
aTopToSiblingBtn_
,
"上侧对齐兄弟"
);
SetUpButton
(
aBottomToSiblingBtn_
,
"下侧对齐兄弟"
);
SetUpButton
(
aHorCenterToSiblingBtn_
,
"水平居中对齐"
);
SetUpButton
(
aVerCenterToSiblingBtn_
,
"竖直居中对齐"
);
SetUpButton
(
lLeftToSiblingBtn_
,
"放至兄弟左侧"
);
SetUpButton
(
lRightToSiblingBtn_
,
"放至兄弟右侧"
);
SetUpButton
(
lTopToSiblingBtn_
,
"放至兄弟上侧"
);
SetUpButton
(
lBottomToSiblingBtn_
,
"放至兄弟下侧"
);
SetUpButton
(
lInvalidLayoutBtn_
,
"非法节点布局"
);
SetUpButton
(
resetBtn_
,
"重置"
,
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
);
SetUpButton
(
marginBtn_
,
"margin"
,
UI_TEST_BASIC_LAYOUT_MARGIN_BTN_ID
);
SetUpButton
(
padBtn_
,
"padding"
,
UI_TEST_BASIC_LAYOUT_PADDING_BTN_ID
);
SetUpButton
(
lCenterOfParentBtn_
,
"居中"
,
UI_TEST_BASIC_LAYOUT_CENTEROFPARENT_BTN_ID
);
SetUpButton
(
lLeftOfParentBtn_
,
"居左"
,
UI_TEST_BASIC_LAYOUT_LEFTOFPARENT_BTN_ID
);
SetUpButton
(
lRightOfParentBtn_
,
"居右"
,
UI_TEST_BASIC_LAYOUT_RIGHTOFPARENT_BTN_ID
);
SetUpButton
(
lTopOfParentBtn_
,
"居上"
,
UI_TEST_BASIC_LAYOUT_TOPOFPARENT_BTN_ID
);
SetUpButton
(
lBottomOfParentBtn_
,
"居下"
,
UI_TEST_BASIC_LAYOUT_BOTTOMOFPARENT_BTN_ID
);
SetUpButton
(
aLeftToSiblingBtn_
,
"左侧对齐兄弟"
,
UI_TEST_BASIC_LAYOUT_LEFTOFSIBLING_BTN_ID
);
SetUpButton
(
aRightToSiblingBtn_
,
"右侧对齐兄弟"
,
UI_TEST_BASIC_LAYOUT_RIGHTOFSIBLING_BTN_ID
);
SetUpButton
(
aTopToSiblingBtn_
,
"上侧对齐兄弟"
,
UI_TEST_BASIC_LAYOUT_TOPOFSIBLING_BTN_ID
);
SetUpButton
(
aBottomToSiblingBtn_
,
"下侧对齐兄弟"
,
UI_TEST_BASIC_LAYOUT_BOTTOMOFSIBLING_BTN_ID
);
SetUpButton
(
aHorCenterToSiblingBtn_
,
"水平居中对齐"
,
UI_TEST_BASIC_LAYOUT_HORCENTEROFSIBLING_BTN_ID
);
SetUpButton
(
aVerCenterToSiblingBtn_
,
"竖直居中对齐"
,
UI_TEST_BASIC_LAYOUT_VERCENTEROFSIBLING_BTN_ID
);
SetUpButton
(
lLeftToSiblingBtn_
,
"放至兄弟左侧"
,
UI_TEST_BASIC_LAYOUT_LEFTTOSIBLING_BTN_ID
);
SetUpButton
(
lRightToSiblingBtn_
,
"放至兄弟右侧"
,
UI_TEST_BASIC_LAYOUT_RIGHTTOSIBLING_BTN_ID
);
SetUpButton
(
lTopToSiblingBtn_
,
"放至兄弟上侧"
,
UI_TEST_BASIC_LAYOUT_TOPTOSIBLING_BTN_ID
);
SetUpButton
(
lBottomToSiblingBtn_
,
"放至兄弟下侧"
,
UI_TEST_BASIC_LAYOUT_BOTTOMTOSIBLING_BTN_ID
);
SetUpButton
(
lInvalidLayoutBtn_
,
"非法节点布局"
,
UI_TEST_BASIC_LAYOUT_INVALIDLAYOUT_BTN_ID
);
}
void
UITestBasicLayout
::
OnClickButton
(
UIView
&
view
)
...
...
test/uitest/test_layout/ui_test_basic_layout.h
浏览文件 @
b9132fb4
...
...
@@ -24,6 +24,28 @@
#include "ui_test.h"
namespace
OHOS
{
namespace
{
constexpr
char
*
UI_TEST_BASIC_LAYOUT_ID
=
"Basic_Layout"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_RESET_BTN_ID
=
"test_basic_layout_reset_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_MARGIN_BTN_ID
=
"test_basic_layout_margin_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_PADDING_BTN_ID
=
"test_basic_layout_padding_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_CENTEROFPARENT_BTN_ID
=
"test_basic_layout_center_of_parent_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_LEFTOFPARENT_BTN_ID
=
"test_basic_layout_left_of_parent_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_RIGHTOFPARENT_BTN_ID
=
"test_basic_layout_right_of_parent_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_TOPOFPARENT_BTN_ID
=
"test_basic_layout_top_of_parent_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_BOTTOMOFPARENT_BTN_ID
=
"test_basic_layout_bottom_of_parent_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_LEFTOFSIBLING_BTN_ID
=
"test_basic_layout_left_of_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_RIGHTOFSIBLING_BTN_ID
=
"test_basic_layout_right_of_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_TOPOFSIBLING_BTN_ID
=
"test_basic_layout_top_of_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_BOTTOMOFSIBLING_BTN_ID
=
"test_basic_layout_bottom_of_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_HORCENTEROFSIBLING_BTN_ID
=
"test_basic_layout_hor_center_of_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_VERCENTEROFSIBLING_BTN_ID
=
"test_basic_layout_ver_center_of_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_LEFTTOSIBLING_BTN_ID
=
"test_basic_layout_left_to_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_RIGHTTOSIBLING_BTN_ID
=
"test_basic_layout_right_to_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_TOPTOSIBLING_BTN_ID
=
"test_basic_layout_top_to_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_BOTTOMTOSIBLING_BTN_ID
=
"test_basic_layout_bottom_to_sibling_button"
;
constexpr
char
*
UI_TEST_BASIC_LAYOUT_INVALIDLAYOUT_BTN_ID
=
"test_basic_layout_invalid_layout_button"
;
}
class
UITestBasicLayout
:
public
UITest
,
public
UIView
::
OnClickListener
{
public:
UITestBasicLayout
()
{}
...
...
@@ -35,7 +57,7 @@ public:
/**
* @brief Test basic layout function.
*/
void
UIKit
_Layout_Test_Basic_Layout_
001
();
void
UIKit
LayoutTestBasicLayout
001
();
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
;
void
OnClickButton
(
UIView
&
view
);
...
...
@@ -72,7 +94,7 @@ private:
UILabelButton
*
padBtn_
=
nullptr
;
UILabelButton
*
setStyle_
=
nullptr
;
void
SetUpButton
(
UILabelButton
*
btn
,
const
char
*
title
)
void
SetUpButton
(
UILabelButton
*
btn
,
const
char
*
title
,
const
char
*
id
=
nullptr
)
{
if
(
btn
==
nullptr
)
{
return
;
...
...
@@ -80,6 +102,7 @@ private:
layout_
->
Add
(
btn
);
btn
->
Resize
(
BUTTON_WIDHT2
,
BUTTON_HEIGHT2
);
btn
->
SetText
(
title
);
btn
->
SetViewId
(
id
);
btn
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
BUTTON_LABEL_SIZE
);
btn
->
SetOnClickListener
(
this
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
...
...
test/uitest/test_render/ui_auto_test_render.cpp
浏览文件 @
b9132fb4
...
...
@@ -32,14 +32,14 @@ void UIAutoTestRender::RunTestList()
void
UIAutoTestRender
::
UIKitRenderTestRender001
()
const
{
const
char
*
fileName
=
"ui_test_render_001.b
in
"
;
const
char
*
fileName
=
"ui_test_render_001.b
mp
"
;
CompareByBinary
(
fileName
);
}
void
UIAutoTestRender
::
UIKitRenderTestRenderMeasure001
()
const
{
ClickViewById
(
UI_TEST_RENDER_UPDATA_BUTTON_ID_01
);
const
char
*
fileName
=
"ui_test_render_measure_001.b
in
"
;
ClickViewById
(
UI_TEST_RENDER_UPDATA_BUTTON_ID_01
);
const
char
*
fileName
=
"ui_test_render_measure_001.b
mp
"
;
CompareByBinary
(
fileName
);
}
}
// namespace OHOS
tools/qt/simulator/libui/libui.pro
浏览文件 @
b9132fb4
...
...
@@ -13,7 +13,10 @@ DEFINES += QT_DEPRECATED_WARNINGS \
"ENABLE_SHAPING=0"
\
"ENABLE_ICU=1"
\
"ENABLE_VECTOR_FONT=1"
\
"ENABLE_BITMAP_FONT=0"
"ENABLE_BITMAP_FONT=0"
\
"ENABLE_MULTI_FONT=0"
\
"ENABLE_STATIC_FONT=0"
DEFINES
+=
QT_COMPILER
...
...
tools/qt/simulator/test/test.pro
浏览文件 @
b9132fb4
...
...
@@ -11,7 +11,9 @@ CONFIG += c++11
DEFINES
+=
QT_DEPRECATED_WARNINGS
\
"ENABLE_ICU=1"
\
"ENABLE_VECTOR_FONT=1"
\
"ENABLE_BITMAP_FONT=0"
"ENABLE_BITMAP_FONT=0"
\
"ENABEL_UI_AUTO_TEST=0"
\
AUTO_TEST_RESOURCE_PATH
=../../
simulator
/
config
/
auto_test
/
\
DEFINES
+=
QT_COMPILER
...
...
@@ -75,10 +77,12 @@ SOURCES += \
..
/../../../
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
/
auto_test_app
.
cpp
\
..
/../../../
test
/
framework
/
src
/
auto_test_case
_group
.
cpp
\
..
/../../../
test
/
framework
/
src
/
compare_tools
.
cpp
\
..
/../../../
test
/
framework
/
src
/
ui_auto_test
.
cpp
\
..
/../../../
test
/
uitest
/
test_render
/
ui_auto_test_render
.
cpp
\
..
/../../../
test
/
uitest
/
test_layout
/
ui_auto_test_basic_layout
.
cpp
HEADERS
+=
\
..
/../../../
test
/
framework
/
common
/
ui_text_language
.
h
\
...
...
@@ -132,10 +136,12 @@ HEADERS += \
..
/../../../
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
/
auto_test_app
.
h
\
..
/../../../
test
/
framework
/
include
/
auto_test_case
_group
.
h
\
..
/../../../
test
/
framework
/
include
/
compare_tools
.
h
\
..
/../../../
test
/
uitest
/
test_render
/
ui_auto_test_render
.
h
..
/../../../
test
/
framework
/
include
/
ui_auto_test
.
h
\
..
/../../../
test
/
uitest
/
test_render
/
ui_auto_test_render
.
h
\
..
/../../../
test
/
uitest
/
test_layout
/
ui_auto_test_basic_layout
.
h
INCLUDEPATH
+=
\
..
/../../../
frameworks
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录