From 7c53d63cea3348084119756eddd30029e5ab7b51 Mon Sep 17 00:00:00 2001 From: fengzewu Date: Sat, 24 Sep 2022 18:22:42 +0800 Subject: [PATCH 1/3] add ut Signed-off-by: fengzewu --- frameworks/innerkitsimpl/test/BUILD.gn | 64 +++++++++++++++ .../test/unittest/image_creator_napi_test.cpp | 55 +++++++++++++ .../image_plugins_libjpegplugin_test.cpp | 79 +++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 frameworks/innerkitsimpl/test/unittest/image_creator_napi_test.cpp create mode 100644 frameworks/innerkitsimpl/test/unittest/image_plugins_libjpegplugin_test.cpp diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn index f2ca0f7..6b33343 100644 --- a/frameworks/innerkitsimpl/test/BUILD.gn +++ b/frameworks/innerkitsimpl/test/BUILD.gn @@ -201,6 +201,70 @@ ohos_unittest("imagecolorspacetest") { "//foundation/multimedia/image_standard/test/resource/image/ohos_test.xml" external_deps = [ "c_utils:utils" ] } +ohos_unittest("imagepluginslibjpegplugintest") { + module_out_path = module_output_path + + include_dirs = [ + "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/converter/include", + "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils/include", + "//foundation/multimedia/image_framework/interfaces/innerkits/include", + "//foundation/multimedia/image_framework/plugins/manager/include", + "//foundation/multimedia/utils/include", + "//foundation/graphic/graphic_2d/utils/color_manager/export", + "//third_party/googletest/googletest/include", + "//commonlibrary/c_utils/base/include", + ] + + cflags = [ + "-DIMAGE_DEBUG_FLAG", + "-DIMAGE_COLORSPACE_FLAG", + ] + + sources = [ "//foundation/multimedia/image_framework/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp" ] + + deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//foundation/graphic/graphic_2d/utils/color_manager:color_manager", + "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils", + "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + resource_config_file = "//foundation/multimedia/image_framework/test/resource/image/ohos_test.xml" + external_deps = [ "c_utils:utils" ] +} +ohos_unittest("ImageCreatorNapiTest") { + module_out_path = module_output_path + + include_dirs = [ + "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/converter/include", + "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils/include", + "//foundation/multimedia/image_framework/interfaces/innerkits/include", + "//foundation/multimedia/image_framework/plugins/manager/include", + "//foundation/multimedia/utils/include", + "//foundation/graphic/graphic_2d/utils/color_manager/export", + "//third_party/googletest/googletest/include", + "//commonlibrary/c_utils/base/include", + ] + + cflags = [ + "-DIMAGE_DEBUG_FLAG", + "-DIMAGE_COLORSPACE_FLAG", + ] + + sources = [ "//foundation/multimedia/image_framework/kits/js/common/image_creator_napi.cpp" ] + + deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//foundation/graphic/graphic_2d/utils/color_manager:color_manager", + "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils", + "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + resource_config_file = "//foundation/multimedia/image_framework/test/resource/image/ohos_test.xml" + external_deps = [ "c_utils:utils" ] +} ################################################ group("unittest") { diff --git a/frameworks/innerkitsimpl/test/unittest/image_creator_napi_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_creator_napi_test.cpp new file mode 100644 index 0000000..e5ba08d --- /dev/null +++ b/frameworks/innerkitsimpl/test/unittest/image_creator_napi_test.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 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 "image_creator_napi.h" +#include +#include "media_errors.h" +#include "hilog/log.h" +#include "image_napi_utils.h" +#include "image_creator_context.h" +#include "image_napi.h" +#include "image_creator_manager.h" + +using namespace testing::ext; +using namespace OHOS::Media; + +namespace OHOS { +namespace Multimedia { +class ImageCreatorNapiTest : public testing::Test { +public: + ImageCreatorNapiTest() {} + ~ImageCreatorNapiTest() {} +}; + +/** + * @tc.name: ImageCreatorNapi001 + * @tc.desc: test ProcessPremulF16Pixel + * @tc.type: FUNC + */ +HWTEST_F(ImageCreatorNapiTest, ImageCreatorNapi001, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImageCreatorNapiTest: ImageCreatorNapi001 start"; + /** + * @tc.steps: step1. set env, info. + * @tc.expected: step1. The new env and info are nullptr. + */ + napi_env env = nullptr; + napi_callback_info info = nullptr; + napi_value ret = ImageCreatorNapi::JsTest(env, info); + EXPECT_EQ(res, true); + GTEST_LOG_(INFO) << "ImageCreatorNapiTest: ImageCreatorNapi001 end"; +} +} +} \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/unittest/image_plugins_libjpegplugin_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_plugins_libjpegplugin_test.cpp new file mode 100644 index 0000000..070f297 --- /dev/null +++ b/frameworks/innerkitsimpl/test/unittest/image_plugins_libjpegplugin_test.cpp @@ -0,0 +1,79 @@ +/* + * 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 +#include "jpeg_decoder.h" +#include +#include "jerror.h" +#include "media_errors.h" +#include "string_ex.h" +#ifndef _WIN32 +#include "securec.h" +#else +#include "memory.h" +#endif + +using namespace testing::ext; +using namespace OHOS::Media; + +namespace OHOS { +namespace Multimedia { +class ImagePluginsLibjpegpluginTest : public testing::Test { +public: + ImagePluginsLibjpegpluginTest() {} + ~ImagePluginsLibjpegpluginTest() {} +}; + +/** + * @tc.name: Libjpegplugin001 + * @tc.desc: test ProcessPremulF16Pixel + * @tc.type: FUNC + */ +HWTEST_F(ImagePluginsLibjpegpluginTest, Libjpegplugin001, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImagePluginsLibjpegpluginTest: Libjpegplugin001 start"; + /** + * @tc.steps: step1. set index, key, value. + * @tc.expected: step1. The new value is default_exif_value. + */ + uint32_t index = 0; + std::string value = "default_exif_value"; + std::string key = "BitsPerSample"; + uint32_t ret = JpegDecoder::GetImagePropertyString(index, key, value); + EXPECT_EQ(res, true); + GTEST_LOG_(INFO) << "ImagePluginsLibjpegpluginTest: Libjpegplugin001 end"; +} + +/** + * @tc.name: Libjpegplugin001 + * @tc.desc: test ProcessPremulF16Pixel + * @tc.type: FUNC + */ +HWTEST_F(ImagePluginsLibjpegpluginTest, Libjpegplugin001, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "ImagePluginsLibjpegpluginTest: Libjpegplugin001 start"; + /** + * @tc.steps: step1. set index, key, value. + * @tc.expected: step1. The new value is 0. + */ + uint32_t index = 0; + std::string value = "0"; + std::string key = "BitsPerSample"; + uint32_t ret = JpegDecoder::GetImagePropertyString(index, key, value); + EXPECT_EQ(res, true); + GTEST_LOG_(INFO) << "ImagePluginsLibjpegpluginTest: Libjpegplugin001 end"; +} +} +} \ No newline at end of file From a326e99c8e6e921da01dd876ecaf795025173646 Mon Sep 17 00:00:00 2001 From: fengzewu Date: Sat, 24 Sep 2022 19:02:43 +0800 Subject: [PATCH 2/3] fix debug Signed-off-by: fengzewu --- frameworks/innerkitsimpl/test/BUILD.gn | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn index 6b33343..f2d9164 100644 --- a/frameworks/innerkitsimpl/test/BUILD.gn +++ b/frameworks/innerkitsimpl/test/BUILD.gn @@ -224,8 +224,6 @@ ohos_unittest("imagepluginslibjpegplugintest") { deps = [ "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/graphic/graphic_2d/utils/color_manager:color_manager", - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils", "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", @@ -256,8 +254,6 @@ ohos_unittest("ImageCreatorNapiTest") { deps = [ "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/graphic/graphic_2d/utils/color_manager:color_manager", - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils:image_utils", "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", From 63c47ae7ef57ad0eb4c1aa0671a37aa472d313da Mon Sep 17 00:00:00 2001 From: fengzewu Date: Sat, 24 Sep 2022 19:28:28 +0800 Subject: [PATCH 3/3] fix febug Signed-off-by: fengzewu --- frameworks/innerkitsimpl/test/BUILD.gn | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn index f2d9164..074b6be 100644 --- a/frameworks/innerkitsimpl/test/BUILD.gn +++ b/frameworks/innerkitsimpl/test/BUILD.gn @@ -205,10 +205,10 @@ ohos_unittest("imagepluginslibjpegplugintest") { module_out_path = module_output_path include_dirs = [ - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/converter/include", - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils/include", - "//foundation/multimedia/image_framework/interfaces/innerkits/include", - "//foundation/multimedia/image_framework/plugins/manager/include", + "//foundation/multimedia/image_standard/frameworks/innerkitsimpl/converter/include", + "//foundation/multimedia/image_standard/frameworks/innerkitsimpl/utils/include", + "//foundation/multimedia/image_standard/interfaces/innerkits/include", + "//foundation/multimedia/image_standard/plugins/manager/include", "//foundation/multimedia/utils/include", "//foundation/graphic/graphic_2d/utils/color_manager/export", "//third_party/googletest/googletest/include", @@ -220,25 +220,27 @@ ohos_unittest("imagepluginslibjpegplugintest") { "-DIMAGE_COLORSPACE_FLAG", ] - sources = [ "//foundation/multimedia/image_framework/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp" ] + sources = [ "//foundation/multimedia/image_standard/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp" ] deps = [ "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", + "//foundation/graphic/graphic_2d/utils/color_manager:color_manager", + "//foundation/multimedia/image_standard/frameworks/innerkitsimpl/utils:image_utils", + "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] - resource_config_file = "//foundation/multimedia/image_framework/test/resource/image/ohos_test.xml" + resource_config_file = "//foundation/multimedia/image_standard/test/resource/image/ohos_test.xml" external_deps = [ "c_utils:utils" ] } ohos_unittest("ImageCreatorNapiTest") { module_out_path = module_output_path include_dirs = [ - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/converter/include", - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/utils/include", - "//foundation/multimedia/image_framework/interfaces/innerkits/include", - "//foundation/multimedia/image_framework/plugins/manager/include", + "//foundation/multimedia/image_standard/frameworks/innerkitsimpl/converter/include", + "//foundation/multimedia/image_standard/frameworks/innerkitsimpl/utils/include", + "//foundation/multimedia/image_standard/interfaces/innerkits/include", + "//foundation/multimedia/image_standard/plugins/manager/include", "//foundation/multimedia/utils/include", "//foundation/graphic/graphic_2d/utils/color_manager/export", "//third_party/googletest/googletest/include", @@ -250,18 +252,19 @@ ohos_unittest("ImageCreatorNapiTest") { "-DIMAGE_COLORSPACE_FLAG", ] - sources = [ "//foundation/multimedia/image_framework/kits/js/common/image_creator_napi.cpp" ] + sources = [ "//foundation/multimedia/image_standard/kits/js/common/image_creator_napi.cpp" ] deps = [ "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", - "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", + "//foundation/graphic/graphic_2d/utils/color_manager:color_manager", + "//foundation/multimedia/image_standard/frameworks/innerkitsimpl/utils:image_utils", + "//foundation/multimedia/image_standard/interfaces/innerkits:image_native", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", ] - resource_config_file = "//foundation/multimedia/image_framework/test/resource/image/ohos_test.xml" + resource_config_file = "//foundation/multimedia/image_standard/test/resource/image/ohos_test.xml" external_deps = [ "c_utils:utils" ] } - ################################################ group("unittest") { testonly = true