• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 
18 #include "interfaces/inner_api/drawable_descriptor/drawable_descriptor.h"
19 #include "interfaces/inner_api/drawable_descriptor/js_drawable_descriptor.h"
20 #include "node_extened.h"
21 #include "native_drawable_descriptor.h"
22 
23 using namespace testing;
24 using namespace testing::ext;
25 using namespace OHOS::Ace::Napi;
26 
27 namespace OHOS::Ace {
28 
29 class JsDrawableDescriptorTest : public testing::Test {
30 public:
SetUpTestCase()31     static void SetUpTestCase() {};
TearDownTestCase()32     static void TearDownTestCase() {};
33 };
34 
35 /**
36  * @tc.name: JsDrawableDescriptorTest001
37  * @tc.desc: test Export function;
38  * @tc.type: FUNC
39  */
40 HWTEST_F(JsDrawableDescriptorTest, JsDrawableDescriptorTest001, TestSize.Level1)
41 {
42     napi_env env = nullptr;
43     napi_value exports = nullptr;
44     JsDrawableDescriptor jsDrawableDescriptor;
45     napi_value result = jsDrawableDescriptor.Export(env, exports);
46     EXPECT_EQ(result, nullptr);
47 }
48 
49 /**
50  * @tc.name: JsDrawableDescriptorTest002
51  * @tc.desc: test ToNapi function;
52  * @tc.type: FUNC
53  */
54 HWTEST_F(JsDrawableDescriptorTest, JsDrawableDescriptorTest002, TestSize.Level1)
55 {
56     napi_env env = nullptr;
57     DrawableDescriptor* drawable = nullptr;
58     JsDrawableDescriptor jsDrawableDescriptor;
59     napi_value result = jsDrawableDescriptor.ToNapi(env, drawable, DrawableDescriptor::DrawableType::PIXELMAP);
60     EXPECT_EQ(result, nullptr);
61 }
62 
63 /**
64  * @tc.name: JsDrawableDescriptorTest003
65  * @tc.desc: test ToNapi function;
66  * @tc.type: FUNC
67  */
68 HWTEST_F(JsDrawableDescriptorTest, JsDrawableDescriptorTest003, TestSize.Level1)
69 {
70     napi_env env = nullptr;
71     DrawableDescriptor drawable;
72     JsDrawableDescriptor jsDrawableDescriptor;
73     JsDrawableDescriptor::baseConstructor_ = (napi_ref)malloc(1000);
74     napi_value result = jsDrawableDescriptor.ToNapi(env, &drawable, DrawableDescriptor::DrawableType::ANIMATED);
75     EXPECT_EQ(result, nullptr);
76     free(JsDrawableDescriptor::baseConstructor_);
77 }
78 
79 /**
80  * @tc.name: JsDrawableDescriptorTest004
81  * @tc.desc: test ToNapi function;
82  * @tc.type: FUNC
83  */
84 HWTEST_F(JsDrawableDescriptorTest, JsDrawableDescriptorTest004, TestSize.Level1)
85 {
86     napi_env env = nullptr;
87     DrawableDescriptor drawable;
88     JsDrawableDescriptor jsDrawableDescriptor;
89     JsDrawableDescriptor::layeredConstructor_ = (napi_ref)malloc(1000);
90     napi_value result = jsDrawableDescriptor.ToNapi(env, &drawable, DrawableDescriptor::DrawableType::BASE);
91     EXPECT_EQ(result, nullptr);
92     free(JsDrawableDescriptor::layeredConstructor_);
93 }
94 
95 /**
96  * @tc.name: JsDrawableDescriptorTest005
97  * @tc.desc: test ToNapi function;
98  * @tc.type: FUNC
99  */
100 HWTEST_F(JsDrawableDescriptorTest, JsDrawableDescriptorTest005, TestSize.Level1)
101 {
102     napi_env env = nullptr;
103     DrawableDescriptor drawable;
104     JsDrawableDescriptor jsDrawableDescriptor;
105     JsDrawableDescriptor::animatedConstructor_ = (napi_ref)malloc(1000);
106     napi_value result = jsDrawableDescriptor.ToNapi(env, &drawable, DrawableDescriptor::DrawableType::LAYERED);
107     EXPECT_EQ(result, nullptr);
108     free(JsDrawableDescriptor::animatedConstructor_);
109 }
110 
111 /**
112  * @tc.name: JsDrawableDescriptorTest006
113  * @tc.desc: test ToNapi function;
114  * @tc.type: FUNC
115  */
116 HWTEST_F(JsDrawableDescriptorTest, JsDrawableDescriptorTest006, TestSize.Level1)
117 {
118     napi_env env = nullptr;
119     DrawableDescriptor drawable;
120     JsDrawableDescriptor jsDrawableDescriptor;
121     JsDrawableDescriptor::pixelMapConstructor_ = (napi_ref)malloc(1000);
122     napi_value result = jsDrawableDescriptor.ToNapi(env, &drawable, DrawableDescriptor::DrawableType::PIXELMAP);
123     EXPECT_EQ(result, nullptr);
124     free(JsDrawableDescriptor::pixelMapConstructor_);
125 }
126 } // namespace OHOS::Ace
127