• 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
16import hilog from '@ohos.hilog';
17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
18import avcodec from 'libentry.so'
19
20interface GeneratedObjectLiteralInterface_1 {
21  DRM_ALG_CENC_UNENCRYPTED: number;
22  DRM_ALG_CENC_AES_CTR: number;
23  DRM_ALG_CENC_AES_WV: number;
24  DRM_ALG_CENC_AES_CBC: number;
25  DRM_ALG_CENC_SM4_CBC: number;
26  DRM_ALG_CENC_SM4_CTR: number;
27}
28
29let DrmCencAlgo: GeneratedObjectLiteralInterface_1 = {
30  DRM_ALG_CENC_UNENCRYPTED : 0,
31  DRM_ALG_CENC_AES_CTR : 1,
32  DRM_ALG_CENC_AES_WV : 2,
33  DRM_ALG_CENC_AES_CBC : 3,
34  DRM_ALG_CENC_SM4_CBC :4,
35  DRM_ALG_CENC_SM4_CTR :5
36}
37
38interface GeneratedObjectLiteralInterface_2 {
39  DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET: number;
40  DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET: number;
41}
42
43let DrmCencInfoMode: GeneratedObjectLiteralInterface_2 = {
44  DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET : 0,
45  DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET : 1,
46}
47
48export default function abilityTest() {
49  describe('AVCodecdrmTest', () => {
50    // Defines a test suite. Two parameters are supported: test suite name and test suite function.
51    beforeAll(() => {
52      // Presets an action, which is performed only once before all test cases of the test suite start.
53      // This API supports only one parameter: preset action function.
54    })
55    beforeEach(() => {
56      // Presets an action, which is performed before each unit test case starts.
57      // The number of execution times is the same as the number of test cases defined by **it**.
58      // This API supports only one parameter: preset action function.
59    })
60    afterEach(() => {
61      // Presets a clear action, which is performed after each unit test case ends.
62      // The number of execution times is the same as the number of test cases defined by **it**.
63      // This API supports only one parameter: clear action function.
64    })
65    afterAll(() => {
66      // Presets a clear action, which is performed after all test cases of the test suite end.
67      // This API supports only one parameter: clear action function.
68    })
69    /**
70     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0100
71     * @tc.name       : test CencInfo_Destroy
72     * @tc.desc       : test OH_AVCencInfo_Destroy and create
73     * @tc.size       : MediumTest
74     * @tc.type       : Function
75     * @tc.level      : Level 0
76     */
77    it('SUB_MULTIMEIDA_AVCODEC_DRM_0100', 0, async (done: Function) => {
78      let result: number = avcodec.Test_CencInfo_Destroy("ptr");
79      expect(result).assertEqual(0);
80      done();
81    });
82    /**
83     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0200
84     * @tc.name       : test AVCencInfo_SetAlgorithm
85     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
86     * @tc.size       : MediumTest
87     * @tc.type       : Function
88     * @tc.level      : Level 0
89     */
90    it('SUB_MULTIMEIDA_AVCODEC_DRM_0200', 0, async (done: Function) => {
91      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", DrmCencAlgo.DRM_ALG_CENC_UNENCRYPTED);
92      expect(result).assertEqual(0);
93      done();
94    });
95    /**
96     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0300
97     * @tc.name       : test AVCencInfo_SetAlgorithm
98     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
99     * @tc.size       : MediumTest
100     * @tc.type       : Function
101     * @tc.level      : Level 0
102     */
103    it('SUB_MULTIMEIDA_AVCODEC_DRM_0300', 0, async (done: Function) => {
104      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", DrmCencAlgo.DRM_ALG_CENC_AES_CTR);
105      expect(result).assertEqual(0);
106      done();
107    });
108    /**
109     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0400
110     * @tc.name       : test AVCencInfo_SetAlgorithm
111     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
112     * @tc.size       : MediumTest
113     * @tc.type       : Function
114     * @tc.level      : Level 0
115     */
116    it('SUB_MULTIMEIDA_AVCODEC_DRM_0400', 0, async (done: Function) => {
117      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", DrmCencAlgo.DRM_ALG_CENC_AES_WV);
118      expect(result).assertEqual(0);
119      done();
120    });
121    /**
122     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0500
123     * @tc.name       : test AVCencInfo_SetAlgorithm
124     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
125     * @tc.size       : MediumTest
126     * @tc.type       : Function
127     * @tc.level      : Level 0
128     */
129    it('SUB_MULTIMEIDA_AVCODEC_DRM_0500', 0, async (done: Function) => {
130      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", DrmCencAlgo.DRM_ALG_CENC_AES_CBC);
131      expect(result).assertEqual(0);
132      done();
133    });
134    /**
135     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0600
136     * @tc.name       : test AVCencInfo_SetAlgorithm
137     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
138     * @tc.size       : MediumTest
139     * @tc.type       : Function
140     * @tc.level      : Level 0
141     */
142    it('SUB_MULTIMEIDA_AVCODEC_DRM_0600', 0, async (done: Function) => {
143      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", DrmCencAlgo.DRM_ALG_CENC_SM4_CBC);
144      expect(result).assertEqual(0);
145      done();
146    });
147    /**
148     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0700
149     * @tc.name       : test AVCencInfo_SetAlgorithm
150     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
151     * @tc.size       : MediumTest
152     * @tc.type       : Function
153     * @tc.level      : Level 0
154     */
155    it('SUB_MULTIMEIDA_AVCODEC_DRM_0700', 0, async (done: Function) => {
156      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", DrmCencAlgo.DRM_ALG_CENC_SM4_CTR);
157      expect(result).assertEqual(0);
158      done();
159    });
160    /**
161     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0800
162     * @tc.name       : test AVCencInfo_SetAlgorithm
163     * @tc.desc       : test OH_AVCencInfo_SetAlgorithm
164     * @tc.size       : MediumTest
165     * @tc.type       : Function
166     * @tc.level      : Level 0
167     */
168    it('SUB_MULTIMEIDA_AVCODEC_DRM_0800', 0, async (done: Function) => {
169      let result: number = avcodec.Test_AVCencInfo_SetAlgorithm("ptr", -1);
170      expect(result).assertEqual(0);
171      done();
172    });
173    /**
174     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_0900
175     * @tc.name       : test OH_AVCencInfo_SetKeyIdAndIv
176     * @tc.desc       : handle: string;
177     *                  keyid: string; keyidlen: number;
178     *                  iv:string, ivlen: number
179     * @tc.size       : MediumTest
180     * @tc.type       : Function
181     * @tc.level      : Level 0
182     */
183    it('SUB_MULTIMEIDA_AVCODEC_DRM_0900', 0, async (done: Function) => {
184      let result: number = avcodec.Test_AVCencInfo_SetKeyIdAndIv("ptr", "ptr", 16, "ptr", 16);
185      expect(result).assertEqual(0);
186      done();
187    });
188    /**
189     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_1000
190     * @tc.name       : test OH_AVCencInfo_SetKeyIdAndIv
191     * @tc.desc       : handle: string;
192     *                  keyid: string; keyidlen: number;
193     *                  iv:string, ivlen: number
194     * @tc.size       : MediumTest
195     * @tc.type       : Function
196     * @tc.level      : Level 0
197     */
198    it('SUB_MULTIMEIDA_AVCODEC_DRM_1000', 0, async (done: Function) => {
199      let result: number = avcodec.Test_AVCencInfo_SetKeyIdAndIv("ptr", "ptr", 8, "ptr", 16);
200      expect(result).assertEqual(3);
201      done();
202    });
203    /**
204     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_1100
205     * @tc.name       : test OH_AVCencInfo_SetKeyIdAndIv
206     * @tc.desc       : handle: string;
207     *                  keyid: string; keyidlen: number;
208     *                  iv:string, ivlen: number
209     * @tc.size       : MediumTest
210     * @tc.type       : Function
211     * @tc.level      : Level 0
212     */
213    it('SUB_MULTIMEIDA_AVCODEC_DRM_1100', 0, async (done: Function) => {
214      let result: number = avcodec.Test_AVCencInfo_SetKeyIdAndIv("ptr", "ptr", 16, "ptr", 7);
215      expect(result).assertEqual(3);
216      done();
217    });
218    /**
219     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_1200
220     * @tc.name       : test AVCencInfo_SetSubsampleInfo
221     * @tc.desc       : handle: string;
222     *                  enblocknum: number;
223     *                  skipblocknum: number;
224     *                  fstenoffset:number;
225     *                  subsamplenum:number, subsample:string
226     * @tc.size       : MediumTest
227     * @tc.type       : Function
228     * @tc.level      : Level 0
229     */
230    it('SUB_MULTIMEIDA_AVCODEC_DRM_1200', 0, async (done: Function) => {
231      let result: number = avcodec.Test_AVCencInfo_SetSubsampleInfo("ptr", 10, 2, 0, 4, "ptr");
232      expect(result).assertEqual(0);
233      done();
234    });
235    /**
236     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_1300
237     * @tc.name       : test AVCencInfo_SetMode
238     * @tc.desc       : handle: string;  mode: number
239     * @tc.size       : MediumTest
240     * @tc.type       : Function
241     * @tc.level      : Level 0
242     */
243    it('SUB_MULTIMEIDA_AVCODEC_DRM_1300', 0, async (done: Function) => {
244      let result: number = avcodec.Test_AVCencInfo_SetMode("ptr", DrmCencInfoMode.DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET);
245      expect(result).assertEqual(0);
246      done();
247    });
248    /**
249     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_1400
250     * @tc.name       : test AVCencInfo_SetMode
251     * @tc.desc       : handle: string;  mode: number
252     * @tc.size       : MediumTest
253     * @tc.type       : Function
254     * @tc.level      : Level 0
255     */
256    it('SUB_MULTIMEIDA_AVCODEC_DRM_1400', 0, async (done: Function) => {
257      let result: number = avcodec.Test_AVCencInfo_SetMode("ptr", DrmCencInfoMode.DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET);
258      expect(result).assertEqual(0);
259      done();
260    });
261    /**
262     * @tc.number     : SUB_MULTIMEIDA_AVCODEC_DRM_1500
263     * @tc.name       : test AVCencInfo_SetAVBuffer
264     * @tc.desc       : handle: string;  buff: string
265     * @tc.size       : MediumTest
266     * @tc.type       : Function
267     * @tc.level      : Level 0
268     */
269    it('SUB_MULTIMEIDA_AVCODEC_DRM_1500', 0, async (done: Function) => {
270      let result: number = avcodec.Test_AVCencInfo_SetAVBuffer("ptr", "ptr");
271      expect(result).assertEqual(0);
272      done();
273    });
274
275  })
276}