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

!34 add auto test framework

Merge pull request !34 from 邓志豪/master
/*
* 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
/*
* 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
/*
* 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
...@@ -22,7 +22,12 @@ ...@@ -22,7 +22,12 @@
#include "components/ui_list.h" #include "components/ui_list.h"
#include "test_case_list_adapter.h" #include "test_case_list_adapter.h"
#define ENABEL_UI_AUTO_TEST 0
namespace OHOS { namespace OHOS {
namespace {
constexpr char* UI_TEST_MAIN_LIST_ID = "main_list";
constexpr char* UI_TEST_BACK_BUTTON_ID = "back_button";
}
class UITestApp { class UITestApp {
public: public:
static UITestApp* GetInstance() static UITestApp* GetInstance()
...@@ -49,5 +54,25 @@ private: ...@@ -49,5 +54,25 @@ private:
UILabel* testCaseLabel_ = nullptr; UILabel* testCaseLabel_ = nullptr;
UILabel* testLabel_ = 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 } // namespace OHOS
#endif #endif
\ No newline at end of file
/*
* 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
...@@ -14,8 +14,24 @@ ...@@ -14,8 +14,24 @@
*/ */
#include "ui_test_app.h" #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() void RunApp()
{ {
OHOS::UITestApp::GetInstance()->Start(); OHOS::UITestApp::GetInstance()->Start();
} #if ENABEL_UI_AUTO_TEST
\ No newline at end of file #ifdef _WIN32
std::thread autoTestPthread(AutoTestThread);
autoTestPthread.detach();
#endif // _WIN32
#endif // ENABEL_UI_AUTO_TEST
}
...@@ -179,6 +179,7 @@ UIView* TestCaseListAdapter::GetView(UIView* inView, int16_t index) ...@@ -179,6 +179,7 @@ UIView* TestCaseListAdapter::GetView(UIView* inView, int16_t index)
listener = new BtnOnClickUiTestListener(rootView_, mainList_, backBtn_, &node->data_, testCaseLabel_, testLabel_); listener = new BtnOnClickUiTestListener(rootView_, mainList_, backBtn_, &node->data_, testCaseLabel_, testLabel_);
item->SetOnClickListener(listener); item->SetOnClickListener(listener);
item->SetText(node->data_.sliceId); item->SetText(node->data_.sliceId);
item->SetViewId(node->data_.sliceId);
item->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); // 24: means font size item->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); // 24: means font size
item->SetViewIndex(index); item->SetViewIndex(index);
item->SetAlign(TEXT_ALIGNMENT_LEFT); item->SetAlign(TEXT_ALIGNMENT_LEFT);
......
/*
* 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
/*
* 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
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
#include "test_resource_config.h" #include "test_resource_config.h"
#include "ui_test.h" #include "ui_test.h"
#include "ui_test_group.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 { namespace OHOS {
void UITestApp::Start() void UITestApp::Start()
...@@ -37,6 +43,7 @@ void UITestApp::Init() ...@@ -37,6 +43,7 @@ void UITestApp::Init()
backBtn_->SetPosition(0, 0); backBtn_->SetPosition(0, 0);
backBtn_->Resize(163, 64); // 163: button width; 64: button height backBtn_->Resize(163, 64); // 163: button width; 64: button height
backBtn_->SetText("Back"); backBtn_->SetText("Back");
backBtn_->SetViewId(UI_TEST_BACK_BUTTON_ID);
backBtn_->SetLablePosition(72, 0); // 72: button label x-coordinate backBtn_->SetLablePosition(72, 0); // 72: button label x-coordinate
backBtn_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); // 24: means font size backBtn_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); // 24: means font size
backBtn_->SetImageSrc(TEST_BACK_LEFT_ARROW, TEST_BACK_LEFT_ARROW); backBtn_->SetImageSrc(TEST_BACK_LEFT_ARROW, TEST_BACK_LEFT_ARROW);
...@@ -71,6 +78,7 @@ void UITestApp::Init() ...@@ -71,6 +78,7 @@ void UITestApp::Init()
mainList_->SetPosition(24, deltaHeight); // 24: x-coordinate mainList_->SetPosition(24, deltaHeight); // 24: x-coordinate
mainList_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - deltaHeight); mainList_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - deltaHeight);
mainList_->SetThrowDrag(true); mainList_->SetThrowDrag(true);
mainList_->SetViewId(UI_TEST_MAIN_LIST_ID);
adapter_ = new TestCaseListAdapter(rootView_, mainList_, backBtn_, testCaseLabel_, testLabel_); adapter_ = new TestCaseListAdapter(rootView_, mainList_, backBtn_, testCaseLabel_, testLabel_);
UITestGroup::SetUpTestCase(); UITestGroup::SetUpTestCase();
mainList_->SetAdapter(adapter_); mainList_->SetAdapter(adapter_);
...@@ -97,4 +105,20 @@ UITestApp::~UITestApp() ...@@ -97,4 +105,20 @@ UITestApp::~UITestApp()
rootView_ = nullptr; 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
...@@ -103,7 +103,7 @@ void UITestGroup::SetUpTestCase() ...@@ -103,7 +103,7 @@ void UITestGroup::SetUpTestCase()
testCaseList_.PushBack(TestCaseInfo{"Canvas", new UITestCanvas()}); testCaseList_.PushBack(TestCaseInfo{"Canvas", new UITestCanvas()});
testCaseList_.PushBack(TestCaseInfo{"Draw_Rect", new UITestDrawRect()}); testCaseList_.PushBack(TestCaseInfo{"Draw_Rect", new UITestDrawRect()});
testCaseList_.PushBack(TestCaseInfo{"Draw_Line", new UITestDrawLine()}); 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{"Anti_Aliasing", new UITestAntiAliasing()});
testCaseList_.PushBack(TestCaseInfo{"UIList", new UITestUIList()}); testCaseList_.PushBack(TestCaseInfo{"UIList", new UITestUIList()});
testCaseList_.PushBack(TestCaseInfo{"UISwipeView", new UITestUISwipeView()}); testCaseList_.PushBack(TestCaseInfo{"UISwipeView", new UITestUISwipeView()});
......
/*
* 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
/*
* 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
...@@ -133,6 +133,7 @@ void UITestRender::UIKit_Render_Test_RenderMeasure_001() ...@@ -133,6 +133,7 @@ void UITestRender::UIKit_Render_Test_RenderMeasure_001()
group->Add(labelButton_); group->Add(labelButton_);
labelButton_->Resize(BUTTON_WIDHT3, BUTTON_HEIGHT3); labelButton_->Resize(BUTTON_WIDHT3, BUTTON_HEIGHT3);
labelButton_->SetText("更新label"); labelButton_->SetText("更新label");
labelButton_->SetViewId(UI_TEST_RENDER_UPDATA_BUTTON_ID_01);
labelButton_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); 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::RELEASED);
labelButton_->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED); labelButton_->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
#include "ui_test.h" #include "ui_test.h"
namespace OHOS { 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 { class UITestRender : public UITest, public UIView::OnClickListener {
public: public:
UITestRender() : container_(nullptr) {} UITestRender() : container_(nullptr) {}
......
...@@ -65,6 +65,12 @@ SOURCES += \ ...@@ -65,6 +65,12 @@ SOURCES += \
../../../../test/uitest/test_view_percent/ui_test_view_percent.cpp \ ../../../../test/uitest/test_view_percent/ui_test_view_percent.cpp \
../../../../test/uitest/test_view_scale_rotate/ui_test_view_scale_rotate.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 += \ HEADERS += \
../../../../test/framework/include/test_case_list_adapter.h \ ../../../../test/framework/include/test_case_list_adapter.h \
../../../../test/framework/include/ui_test_app.h \ ../../../../test/framework/include/ui_test_app.h \
...@@ -111,6 +117,12 @@ HEADERS += \ ...@@ -111,6 +117,12 @@ HEADERS += \
../../../../test/uitest/test_view_percent/ui_test_view_percent.h \ ../../../../test/uitest/test_view_percent/ui_test_view_percent.h \
../../../../test/uitest/test_view_scale_rotate/ui_test_view_scale_rotate.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 += \ INCLUDEPATH += \
../../../../frameworks \ ../../../../frameworks \
../../../../../utils/frameworks/windows \ ../../../../../utils/frameworks/windows \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册