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

!111 codex告警问题

Merge pull request !111 from 邓志豪/master
......@@ -53,7 +53,7 @@ private:
CompareTools() {}
virtual ~CompareTools() {}
static bool SaveLog(char* buff, size_t bufSize);
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);
......
......@@ -84,22 +84,23 @@ 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();
if (frameBuf == nullptr) {
return false;
}
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));
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) {
free(readBuf);
delete[] readBuf;
fclose(fd);
return false;
}
......@@ -115,7 +116,7 @@ bool CompareTools::CompareBinary(const char* filePath, size_t length)
} else {
GRAPHIC_LOGI("[FAILURE]:fileName=%s", filePath);
}
free(readBuf);
delete[] readBuf;
fclose(fd);
if (enableLog_) {
char logBuf[DEFAULT_FILE_NAME_MAX_LENGTH] = {0};
......@@ -138,10 +139,6 @@ 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();
if (frameBuf == nullptr) {
GRAPHIC_LOGE("GetBuffer failed");
......@@ -149,6 +146,10 @@ bool CompareTools::SaveFrameBuffToBinary(const char* filePath, size_t length)
}
uint8_t sizeByColorMode = DrawUtils::GetByteSizeByColorMode(ScreenDeviceProxy::GetInstance()->GetBufferMode());
uint32_t buffSize = HORIZONTAL_RESOLUTION * VERTICAL_RESOLUTION * sizeByColorMode;
FILE* fd = fopen(filePath, "wb+");
if (fd == nullptr) {
return false;
}
if (fwrite(frameBuf, sizeof(uint8_t), buffSize, fd) < 0) {
fclose(fd);
return false;
......@@ -202,7 +203,7 @@ void CompareTools::UnsetLogPath()
}
}
bool CompareTools::SaveLog(char* buff, size_t bufSize)
bool CompareTools::SaveLog(const char* buff, size_t bufSize)
{
if ((buff == nullptr) || (logPath_ == nullptr)) {
return false;
......@@ -214,7 +215,7 @@ bool CompareTools::SaveLog(char* buff, size_t bufSize)
}
if (fwrite(buff, 1, bufSize, log) < 0) {
fclose(log);
GRAPHIC_LOGE("wtite log failed");
GRAPHIC_LOGE("write log failed");
return false;
}
fclose(log);
......
......@@ -27,7 +27,6 @@ void* AutoTestThread(void*)
#endif // _WIN32
{
OHOS::UIAutoTestApp::GetInstance()->Start();
pthread_exit(0);
}
......
......@@ -35,6 +35,7 @@ void UIAutoTestGroup::TearDownTestCase()
ListNode<UIAutoTest*>* node = testCaseList_.Begin();
while (node != testCaseList_.End()) {
delete node->data_;
node->data_ = nullptr;
node = node->next_;
}
testCaseList_.Clear();
......
......@@ -13,29 +13,7 @@ import("//build/lite/config/test.gni")
group("lite_graphic_ui_test") {
if (ohos_build_type == "debug") {
deps = [
":graphic_test_animator",
":graphic_test_axis",
":graphic_test_button",
":graphic_test_canvas",
":graphic_test_clock",
":graphic_test_common",
":graphic_test_dfx",
":graphic_test_dialog",
":graphic_test_events",
":graphic_test_focus_manager",
":graphic_test_font",
":graphic_test_image",
":graphic_test_label",
":graphic_test_layout",
":graphic_test_picker",
":graphic_test_progress",
":graphic_test_qrcode",
":graphic_test_render",
":graphic_test_themes",
":graphic_test_video",
":graphic_test_view",
]
deps = [ ":graphic_test_ui_door" ]
}
}
......@@ -61,236 +39,68 @@ config("graphic_test_config") {
}
if (ohos_build_type == "debug") {
commonDeps = [ "//foundation/graphic/ui:ui" ]
unittest("graphic_test_animator") {
unittest("graphic_test_ui_door") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"animator/animator_unit_test.cpp",
"animator/easing_equation_unit_test.cpp",
"animator/interpolation_unit_test.cpp",
]
}
unittest("graphic_test_common") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"common/focus_manager_unit_test.cpp",
"common/hardware_acceleration_unit_test.cpp",
"common/screen_unit_test.cpp",
"common/text_unit_test.cpp",
]
}
unittest("graphic_test_events") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"events/cancel_event_unit_test.cpp",
"events/click_event_unit_test.cpp",
"events/drag_event_unit_test.cpp",
"events/event_bubble_unit_test.cpp",
"events/event_unit_test.cpp",
"events/key_event_unit_test.cpp",
"events/long_press_event_unit_test.cpp",
"events/press_event_unit_test.cpp",
"events/release_event_unit_test.cpp",
"events/virtual_device_event_unit_test.cpp",
]
}
unittest("graphic_test_layout") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "layout/list_layout_unit_test.cpp" ]
}
unittest("graphic_test_render") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "render/render_uni_test.cpp" ]
}
unittest("graphic_test_themes") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "themes/theme_manager_unit_test.cpp" ]
}
unittest("graphic_test_button") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_button_unit_test.cpp",
"components/ui_checkbox_unit_test.cpp",
"components/ui_label_button_unit_test.cpp",
"components/ui_radio_button_unit_test.cpp",
"components/ui_repeat_button_unit_test.cpp",
"components/ui_toggle_button_unit_test.cpp",
]
}
unittest("graphic_test_progress") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_abstract_progress_unit_test.cpp",
"components/ui_box_progress_unit_test.cpp",
"components/ui_circle_progress_unit_test.cpp",
]
}
unittest("graphic_test_clock") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_analog_clock_unit_test.cpp",
"components/ui_digital_clock_unit_test.cpp",
]
}
unittest("graphic_test_label") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_arc_label_unit_test.cpp",
"components/ui_label_unit_test.cpp",
]
}
unittest("graphic_test_axis") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "components/ui_axis_unit_test.cpp" ]
}
unittest("graphic_test_canvas") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_axis_unit_test.cpp",
"components/ui_box_progress_unit_test.cpp",
"components/ui_button_unit_test.cpp",
"components/ui_canvas_unit_test.cpp",
"components/ui_chart_unit_test.cpp",
"components/ui_slider_unit_test.cpp",
]
}
unittest("graphic_test_image") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_checkbox_unit_test.cpp",
"components/ui_circle_progress_unit_test.cpp",
"components/ui_dialog_unit_test.cpp",
"components/ui_digital_clock_unit_test.cpp",
"components/ui_image_animator_unit_test.cpp",
"components/ui_image_unit_test.cpp",
"image/image_load_unit_test.cpp",
]
}
unittest("graphic_test_picker") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_label_button_unit_test.cpp",
"components/ui_label_unit_test.cpp",
"components/ui_picker_unit_test.cpp",
"components/ui_time_picker_unit_test.cpp",
]
}
unittest("graphic_test_qrcode") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "components/ui_qrcode_unit_test.cpp" ]
}
unittest("graphic_test_view") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [
"components/ui_qrcode_unit_test.cpp",
"components/ui_radio_button_unit_test.cpp",
"components/ui_repeat_button_unit_test.cpp",
"components/ui_scroll_view_unit_test.cpp",
"components/ui_slider_unit_test.cpp",
"components/ui_surface_view_unit_test.cpp",
"components/ui_swipe_view_unit_test.cpp",
"components/ui_time_picker_unit_test.cpp",
"components/ui_toggle_button_unit_test.cpp",
"components/ui_video_unit_test.cpp",
"components/ui_view_group_unit_test.cpp",
"components/ui_view_unit_test.cpp",
"dfx/event_injector_unit_test.cpp",
"events/cancel_event_unit_test.cpp",
"events/click_event_unit_test.cpp",
"events/drag_event_unit_test.cpp",
"events/event_bubble_unit_test.cpp",
"events/event_unit_test.cpp",
"events/key_event_unit_test.cpp",
"events/long_press_event_unit_test.cpp",
"events/press_event_unit_test.cpp",
"events/release_event_unit_test.cpp",
"events/virtual_device_event_unit_test.cpp",
"font/ui_font_unit_test.cpp",
"image/image_load_unit_test.cpp",
"layout/list_layout_unit_test.cpp",
"render/render_uni_test.cpp",
"rotate/ui_rotate_input_unit_test.cpp",
"themes/theme_manager_unit_test.cpp",
]
}
unittest("graphic_test_video") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
sources = [ "components/ui_video_unit_test.cpp" ]
deps = commonDeps
deps += [
deps = [
"//foundation/graphic/ui:ui",
"//foundation/multimedia/media_lite/frameworks/player_lite:player_lite",
]
}
unittest("graphic_test_dfx") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "dfx/event_injector_unit_test.cpp" ]
}
unittest("graphic_test_dialog") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "components/ui_dialog_unit_test.cpp" ]
}
unittest("graphic_test_font") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "font/ui_font_unit_test.cpp" ]
}
unittest("graphic_test_rotate") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "rotate/ui_rotate_input_unit_test.cpp" ]
}
unittest("graphic_test_focus_manager") {
output_extension = "bin"
output_dir = "$root_out_dir/test/unittest/graphic"
configs = [ ":graphic_test_config" ]
deps = commonDeps
sources = [ "common/focus_manager_unit_test.cpp" ]
}
}
......@@ -115,6 +115,7 @@ HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_001, TestSize.
UIScrollView* scroll = new UIScrollView();
scroll->RequestFocus();
EXPECT_EQ(scroll, FocusManager::GetInstance()->GetFocusedView());
scroll->ClearFocus();
delete scroll;
}
/**
......@@ -128,6 +129,7 @@ HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_002, TestSize.
UITimePicker* timePicker = new UITimePicker();
timePicker->RequestFocus();
EXPECT_EQ(timePicker, FocusManager::GetInstance()->GetFocusedView());
timePicker->ClearFocus();
delete timePicker;
}
/**
......@@ -141,6 +143,7 @@ HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_003, TestSize.
UISwipeView* swipe = new UISwipeView();
swipe->RequestFocus();
EXPECT_EQ(swipe, FocusManager::GetInstance()->GetFocusedView());
swipe->ClearFocus();
delete swipe;
}
/**
......@@ -154,6 +157,7 @@ HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_004, TestSize.
UIList* list = new UIList();
list->RequestFocus();
EXPECT_EQ(list, FocusManager::GetInstance()->GetFocusedView());
list->ClearFocus();
delete list;
}
/**
......@@ -167,6 +171,7 @@ HWTEST_F(UIRotateInputTest, Graphic_RotateInput_Test_RequestFocus_005, TestSize.
UISlider* slider = new UISlider();
slider->RequestFocus();
EXPECT_EQ(slider, FocusManager::GetInstance()->GetFocusedView());
slider->ClearFocus();
delete slider;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册