Add UT to effectChain framework

Signed-off-by: zhanghongquan112 <zhanghongquan13@huawei.com>
Change-Id: I00f28707862186d8c7d933a34615c7f5de1d8c96
Signed-off-by: zhanghongquan112 <zhanghongquan13@huawei.com>
This commit is contained in:
zhanghongquan112 2022-02-11 15:35:43 +08:00
parent 5bf1d9de40
commit 0457024275
4 changed files with 178 additions and 0 deletions

View File

@ -42,6 +42,7 @@ group("graphic_standard_test") {
"frameworks/vsync:test",
"frameworks/wmtest:wmtest",
"rosen/modules/composer:test",
"rosen/modules/effect/test/unittest:test",
]
}

View File

@ -0,0 +1,56 @@
# Copyright (c) 2022 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("//build/test.gni")
import("//foundation/graphic/standard/graphic_config.gni")
import("//foundation/graphic/standard/rosen/modules/effect/effect_config.gni")
module_output_path = "graphic_standard/rosen/modules/effect"
ohos_unittest("EffectTest") {
module_out_path = module_output_path
sources = []
deps = [
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
]
if (effect_enable_gpu) {
sources += [ "effect_chain_unittest.cpp" ]
deps += [
"//foundation/graphic/standard:libgl",
"//foundation/graphic/standard/interfaces/kits/napi/graphic/common:graphic_napi_common",
"//foundation/graphic/standard/rosen/modules/effect/effectChain:libeffectchain",
"//foundation/graphic/standard/rosen/modules/effect/egl:libegl_effect",
]
}
configs = [ ":effect_test_config" ]
}
config("effect_test_config") {
visibility = [ ":*" ]
include_dirs = [
"//third_party/EGL/api",
"//third_party/openGLES/api",
"//foundation/graphic/standard/rosen/modules/effect/effectChain/include",
"//foundation/graphic/standard/rosen/modules/effect/egl/include",
]
}
group("test") {
testonly = true
deps = [ ":EffectTest" ]
}

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) 2022 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 "effect_chain_unittest.h"
#include "builder.h"
#include "image_chain.h"
using namespace testing;
using namespace testing::ext;
namespace OHOS {
namespace Rosen {
/**
* @tc.name: BuilderCreateFromConfigTest001
* @tc.desc: Ensure the ability of creating effect chain from config file.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(EffectChainUnittest, BuilderCreateFromConfigTest001, TestSize.Level1)
{
GTEST_LOG_(INFO) << "EffectChainUnittest BuilderCreateFromConfigTest001 start";
/**
* @tc.steps: step1. Create a builder pointer
*/
std::unique_ptr<Builder> builder = std::make_unique<Builder>();
/**
* @tc.steps: step2. Call createFromConfig to load file
*/
ImageChain* imageChain = builder->CreateFromConfig("/cannot/find/config.json");
EXPECT_EQ(imageChain, nullptr);
}
/**
* @tc.name: BuilderCreateFromConfigTest002
* @tc.desc: Ensure the ability of creating effect chain from config file.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(EffectChainUnittest, BuilderCreateFromConfigTest002, TestSize.Level1)
{
GTEST_LOG_(INFO) << "EffectChainUnittest BuilderCreateFromConfigTest002 start";
/**
* @tc.steps: step1. Create a builder pointer
*/
std::unique_ptr<Builder> builder = std::make_unique<Builder>();
/**
* @tc.steps: step2. Call createFromConfig to load file
*/
ImageChain* imageChain = builder->CreateFromConfig("config.json");
EXPECT_EQ(imageChain, nullptr);
}
/**
* @tc.name: BuilderCreateFromConfigTest003
* @tc.desc: Ensure the ability of creating effect chain from config file.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(EffectChainUnittest, BuilderCreateFromConfigTest003, TestSize.Level1)
{
GTEST_LOG_(INFO) << "EffectChainUnittest BuilderCreateFromConfigTest003 start";
/**
* @tc.steps: step1. Create a builder pointer
*/
std::unique_ptr<Builder> builder = std::make_unique<Builder>();
/**
* @tc.steps: step2. Call createFromConfig to load file
*/
ImageChain* imageChain = builder->CreateFromConfig("");
EXPECT_EQ(imageChain, nullptr);
}
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 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 EFFECT_CHAIN_UNITTEST_H
#define EFFECT_CHAIN_UNITTEST_H
#include <gtest/gtest.h>
namespace OHOS {
namespace Rosen {
class EffectChainUnittest : public testing::Test {
public:
static void SetUpTestCase() {};
static void TearDownTestCase() {};
void SetUp() override {};
void TearDown() override {};
};
} // namespace Rosen
} // namespace OHOS
#endif // EFFECT_CHAIN_UNITTEST_H