graphictest

Signed-off-by: 王德海 <wangdehai2@huawei.com>
Change-Id: I3731560dcf13d45529ac33ca82affd74bcfac06a
This commit is contained in:
王德海 2024-08-01 12:04:35 +08:00
parent 74764d375a
commit 0486e58af2
62 changed files with 45 additions and 27 deletions

View File

@ -14,19 +14,34 @@
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
module_output_path = "graphic_2d/rosen/graphic_test/graphic_test"
module_output_path = "graphic_2d/graphic_test/graphic_test"
group("unittest") {
drawing_engine_sources = []
hardware_manager_sources = []
open_capability_sources = []
rs_display_effect_sources = []
rs_framework_sources = []
rs_func_feature_sources = []
rs_perform_feature_sources = []
group("test") {
testonly = true
deps = [ ":RSGraphicTestTemplateTest" ]
deps = [ ":RSGraphicTest" ]
}
## Build RSGraphicTestTemplateTest
ohos_unittest("RSGraphicTestTemplateTest") {
## Build RSGraphicTest
ohos_unittest("RSGraphicTest") {
module_out_path = module_output_path
sources = [ "test_template.cpp" ]
sources = []
sources += drawing_engine_sources
sources += hardware_manager_sources
sources += open_capability_sources
sources += rs_display_effect_sources
sources += rs_framework_sources
sources += rs_func_feature_sources
sources += rs_perform_feature_sources
deps = [ "$graphic_2d_root/rosen/graphic_test/graphic_test_framework:rs_graphic_test_main" ]
deps = [ "$graphic_2d_root/graphic_test/graphic_test_framework:rs_graphic_test_main" ]
defines = []
external_deps = [

View File

@ -27,6 +27,7 @@ public:
auto size = GetScreenSize();
SetSurfaceBounds({0, 0, size.x_ / 2.0f, size.y_ / 2.0f});
SetSurfaceColor(RSColor(0xffff0000));
SetImageSavePath("/data/local/graphic_test/test_template/");
}
// called after each tests

View File

@ -13,7 +13,7 @@
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
import("../../modules/render_service_base/config.gni")
import("${graphic_2d_root}/rosen/modules/render_service_base/config.gni")
config("rs_graphic_test_config") {
include_dirs = [

View File

@ -33,6 +33,7 @@ public:
void SetSurfaceBounds(const Vector4f& bounds);
void SetSurfaceColor(const RSColor& color);
void RegisterNode(std::shared_ptr<RSNode> node);
void SetImageSavePath(const std::string path);
// overrides gtest functions
static void SetUpTestCase();
@ -49,6 +50,7 @@ private:
Vector4f surfaceBounds_;
std::vector<std::shared_ptr<RSNode>> nodes_;
static uint32_t imageWriteId_;
std::string imageSavePath_ = "";
};
} // namespace Rosen
} // namespace OHOS

View File

@ -112,6 +112,9 @@ void RSGraphicTest::TearDown()
RSParameterParse::Instance().surfaceCaptureWaitTime);
if (pixelMap) {
std::string filename = RSParameterParse::Instance().imageSavePath;
if (imageSavePath_ != "") {
filename = imageSavePath_;
}
filename += testInfo->test_case_name() + std::string("_");
filename += testInfo->name() + std::string(".png");
if (std::filesystem::exists(filename)) {
@ -158,5 +161,21 @@ void RSGraphicTest::SetSurfaceColor(const RSColor& color)
RSGraphicTestDirector::Instance().SetSurfaceColor(color);
}
void RSGraphicTest::SetImageSavePath(const std::string path)
{
namespace fs = std::filesystem;
if (!fs::exists(path)) {
if (!fs::create_directories(path)) {
LOGE("RSGraphicTestDirector create dir failed");
}
} else {
if (!fs::is_directory(path)) {
LOGE("RSGraphicTestDirector path is not dir");
return;
}
}
imageSavePath_ = path;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -1,19 +0,0 @@
# Copyright (c) 2024 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.
import("//foundation/graphic/graphic_2d/graphic_config.gni")
group("test") {
testonly = true
deps = []
}