diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn index f2ca0f7..074b6be 100644 --- a/frameworks/innerkitsimpl/test/BUILD.gn +++ b/frameworks/innerkitsimpl/test/BUILD.gn @@ -201,7 +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_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", + "//commonlibrary/c_utils/base/include", + ] + + cflags = [ + "-DIMAGE_DEBUG_FLAG", + "-DIMAGE_COLORSPACE_FLAG", + ] + + sources = [ "//foundation/multimedia/image_standard/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_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_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_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", + "//commonlibrary/c_utils/base/include", + ] + + cflags = [ + "-DIMAGE_DEBUG_FLAG", + "-DIMAGE_COLORSPACE_FLAG", + ] + + sources = [ "//foundation/multimedia/image_standard/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_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_standard/test/resource/image/ohos_test.xml" + external_deps = [ "c_utils:utils" ] +} ################################################ group("unittest") { testonly = true 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