1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 #include "pixel_map_napi.h" 18 #include "image_packer_napi.h" 19 #include "image_source_napi.h" 20 21 using namespace testing::ext; 22 namespace OHOS { 23 namespace Media { 24 class NapiTest : public testing::Test { 25 public: NapiTest()26 NapiTest() {} ~NapiTest()27 ~NapiTest() {} 28 }; 29 30 /** 31 * @tc.name: NapiTest001 32 * @tc.desc: IsLockPixelMap 33 * @tc.type: FUNC 34 */ 35 HWTEST_F(NapiTest, NapiTest001, TestSize.Level3) 36 { 37 GTEST_LOG_(INFO) << "NapiTest: NapiTest001 start"; 38 PixelMapNapi napi; 39 bool res = napi.IsLockPixelMap(); 40 ASSERT_EQ(res, false); 41 42 GTEST_LOG_(INFO) << "NapiTest: NapiTest001 end"; 43 } 44 45 /** 46 * @tc.name: NapiTest002 47 * @tc.desc: LockPixelMap 48 * @tc.type: FUNC 49 */ 50 HWTEST_F(NapiTest, NapiTest002, TestSize.Level3) 51 { 52 GTEST_LOG_(INFO) << "NapiTest: NapiTest002 start"; 53 PixelMapNapi napi; 54 bool res = napi.LockPixelMap(); 55 ASSERT_EQ(res, true); 56 57 GTEST_LOG_(INFO) << "NapiTest: NapiTest002 end"; 58 } 59 60 /** 61 * @tc.name: NapiTest003 62 * @tc.desc: UnlockPixelMap 63 * @tc.type: FUNC 64 */ 65 HWTEST_F(NapiTest, NapiTest003, TestSize.Level3) 66 { 67 GTEST_LOG_(INFO) << "NapiTest: NapiTest003 start"; 68 PixelMapNapi napi; 69 napi.UnlockPixelMap(); 70 bool res = napi.LockPixelMap(); 71 ASSERT_EQ(res, true); 72 73 GTEST_LOG_(INFO) << "NapiTest: NapiTest003 end"; 74 } 75 76 /** 77 * @tc.name: NapiTest004 78 * @tc.desc: GetPixelMap(env, pixelmap) 79 * @tc.type: FUNC 80 */ 81 HWTEST_F(NapiTest, NapiTest004, TestSize.Level3) 82 { 83 GTEST_LOG_(INFO) << "NapiTest: NapiTest004 start"; 84 PixelMapNapi napi; 85 napi_env env = nullptr; 86 napi_value pixelmap = nullptr; 87 std::shared_ptr<PixelMap> res = napi.GetPixelMap(env, pixelmap); 88 ASSERT_EQ(res, nullptr); 89 90 GTEST_LOG_(INFO) << "NapiTest: NapiTest004 end"; 91 } 92 93 /** 94 * @tc.name: NapiTest005 95 * @tc.desc: GetPixelMap() 96 * @tc.type: FUNC 97 */ 98 HWTEST_F(NapiTest, NapiTest005, TestSize.Level3) 99 { 100 GTEST_LOG_(INFO) << "NapiTest: NapiTest005 start"; 101 PixelMapNapi napi; 102 std::shared_ptr<PixelMap>* res = napi.GetPixelMap(); 103 ASSERT_NE(res, nullptr); 104 105 GTEST_LOG_(INFO) << "NapiTest: NapiTest005 end"; 106 } 107 108 /** 109 * @tc.name: NapiTest006 110 * @tc.desc: OH_PixelMap_SetDensity 111 * @tc.type: FUNC 112 */ 113 HWTEST_F(NapiTest, NapiTest006, TestSize.Level3) 114 { 115 GTEST_LOG_(INFO) << "NapiTest: NapiTest006 start"; 116 PixelMapNapi napi; 117 napi_env env = nullptr; 118 napi_value exports = nullptr; 119 napi_value res = napi.Init(env, exports); 120 ASSERT_EQ(res, nullptr); 121 122 GTEST_LOG_(INFO) << "NapiTest: NapiTest006 end"; 123 } 124 125 /** 126 * @tc.name: NapiTest007 127 * @tc.desc: OH_PixelMap_SetOpacity 128 * @tc.type: FUNC 129 */ 130 HWTEST_F(NapiTest, NapiTest007, TestSize.Level3) 131 { 132 GTEST_LOG_(INFO) << "NapiTest: NapiTest007 start"; 133 PixelMapNapi napi; 134 napi_env env = nullptr; 135 std::shared_ptr<PixelMap> pixelmap = nullptr; 136 napi_value res = napi.CreatePixelMap(env, pixelmap); 137 ASSERT_EQ(res, nullptr); 138 139 GTEST_LOG_(INFO) << "NapiTest: NapiTest007 end"; 140 } 141 142 /** 143 * @tc.name: NapiTest008 144 * @tc.desc: Init 145 * @tc.type: FUNC 146 */ 147 HWTEST_F(NapiTest, NapiTest008, TestSize.Level3) 148 { 149 GTEST_LOG_(INFO) << "NapiTest: NapiTest008 start"; 150 ImagePackerNapi napi; 151 napi_env env = nullptr; 152 napi_value exports = nullptr; 153 napi_value res = napi.Init(env, exports); 154 ASSERT_EQ(res, nullptr); 155 156 GTEST_LOG_(INFO) << "NapiTest: NapiTest008 end"; 157 } 158 159 /** 160 * @tc.name: NapiTest009 161 * @tc.desc: CreateImagePacker 162 * @tc.type: FUNC 163 */ 164 HWTEST_F(NapiTest, NapiTest009, TestSize.Level3) 165 { 166 GTEST_LOG_(INFO) << "NapiTest: NapiTest009 start"; 167 ImagePackerNapi napi; 168 napi_env env = nullptr; 169 napi_callback_info info = nullptr; 170 napi_value res = napi.CreateImagePacker(env, info); 171 ASSERT_EQ(res, nullptr); 172 173 GTEST_LOG_(INFO) << "NapiTest: NapiTest009 end"; 174 } 175 176 /** 177 * @tc.name: NapiTest0010 178 * @tc.desc: OH_PixelMap_SetOpacity 179 * @tc.type: FUNC 180 */ 181 HWTEST_F(NapiTest, NapiTest0010, TestSize.Level3) 182 { 183 GTEST_LOG_(INFO) << "NapiTest: NapiTest0010 start"; 184 ImageSourceNapi napi; 185 napi_env env = nullptr; 186 napi_value exports = nullptr; 187 napi_value res = napi.Init(env, exports); 188 ASSERT_EQ(res, nullptr); 189 190 GTEST_LOG_(INFO) << "NapiTest: NapiTest0010 end"; 191 } 192 193 /** 194 * @tc.name: NapiTest0011 195 * @tc.desc: OH_PixelMap_SetOpacity 196 * @tc.type: FUNC 197 */ 198 HWTEST_F(NapiTest, NapiTest0011, TestSize.Level3) 199 { 200 GTEST_LOG_(INFO) << "NapiTest: NapiTest0011 start"; 201 ImageSourceNapi napi; 202 std::shared_ptr<IncrementalPixelMap> res = napi.GetIncrementalPixelMap(); 203 ASSERT_EQ(res, nullptr); 204 205 GTEST_LOG_(INFO) << "NapiTest: NapiTest0011 end"; 206 } 207 208 /** 209 * @tc.name: NapiTest0012 210 * @tc.desc: SetIncrementalPixelMap 211 * @tc.type: FUNC 212 */ 213 HWTEST_F(NapiTest, NapiTest0012, TestSize.Level3) 214 { 215 GTEST_LOG_(INFO) << "NapiTest: NapiTest0012 start"; 216 ImageSourceNapi napi; 217 std::shared_ptr<IncrementalPixelMap> incrementalPixelMap = nullptr; 218 napi.SetIncrementalPixelMap(incrementalPixelMap); 219 220 GTEST_LOG_(INFO) << "NapiTest: NapiTest0012 end"; 221 } 222 223 /** 224 * @tc.name: NapiTest0013 225 * @tc.desc: GetIncrementalPixelMap 226 * @tc.type: FUNC 227 */ 228 HWTEST_F(NapiTest, NapiTest0013, TestSize.Level3) 229 { 230 GTEST_LOG_(INFO) << "NapiTest: NapiTest0013 start"; 231 ImageSourceNapi napi; 232 std::shared_ptr<ImageSource> imageSource = nullptr; 233 napi.SetNativeImageSource(imageSource); 234 235 GTEST_LOG_(INFO) << "NapiTest: NapiTest0013 end"; 236 } 237 238 /** 239 * @tc.name: NapiTest0014 240 * @tc.desc: OH_PixelMap_SetOpacity 241 * @tc.type: FUNC 242 */ 243 HWTEST_F(NapiTest, NapiTest0014, TestSize.Level3) 244 { 245 GTEST_LOG_(INFO) << "NapiTest: NapiTest0014 start"; 246 ImageSourceNapi napi; 247 ImageResource resource; 248 napi.SetImageResource(resource); 249 250 GTEST_LOG_(INFO) << "NapiTest: NapiTest0014 end"; 251 } 252 /** 253 * @tc.name: NapiTest0015 254 * @tc.desc: OH_PixelMap_SetOpacity 255 * @tc.type: FUNC 256 */ 257 HWTEST_F(NapiTest, NapiTest0015, TestSize.Level3) 258 { 259 GTEST_LOG_(INFO) << "NapiTest: NapiTest0015 start"; 260 ImageSourceNapi napi; 261 ImageResource resource = napi.GetImageResource(); 262 ASSERT_EQ(resource.buffer, nullptr); 263 264 GTEST_LOG_(INFO) << "NapiTest: NapiTest0015 end"; 265 } 266 } 267 } 268 269