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 { describe, it, expect } from '@ohos/hypium'; 17import pcsNetworkTest from 'libpcsNetworkTest.so' 18import pcsAudioTest from 'libpcsAudioTest.so' 19import softwareNdk from 'libsoftwareNdk.so' 20import openglNdk from 'libopenglNdk.so' 21import { BusinessError } from '@ohos.base'; 22 23export default function pcsNdkTest() { 24 describe('PCSNdkTest', () => { 25 let SuccessResult1 = 0 26 let SuccessResult2 = 1 27 /* 28 * @tc.number: G-HARDWARE-0200 29 * @tc.name: testSocketApi0100 30 * @tc.desc: 【G-HARDWARE-0200】必须支持 IPV4 协议栈,必须提供 Linux BSD Socket API 或者 LWIP BSD Socket API 之一 31 * @tc.size: MediumTest 32 * @tc.type: Function 33 * @tc.level: Level 0 34 */ 35 it('testSocketApi0100', 0, async (done: Function) => { 36 let recvParam = 0 37 expect(pcsNetworkTest.Socket()).assertLarger(SuccessResult1); 38 expect(pcsNetworkTest.Connect()).assertEqual(SuccessResult1); 39 expect(pcsNetworkTest.Bind()).assertEqual(SuccessResult1); 40 expect(pcsNetworkTest.Listen()).assertEqual(SuccessResult1) 41 expect(pcsNetworkTest.Send()).assertLarger(SuccessResult1); 42 expect(pcsNetworkTest.Recv(recvParam)).assertEqual(SuccessResult2); 43 done() 44 }); 45 46 /* 47 * @tc.number: G-SOFTWARE-0300 48 * @tc.name: testC99Standard0100 49 * @tc.desc: 【G-SOFTWARE-0300】C 运行时的 API 必须遵循 C99 standard、POSIX.1.2008 规范。 50 * @tc.size: MediumTest 51 * @tc.type: Function 52 * @tc.level: Level 0 53 */ 54 it('testC99Standard0100', 0, async (done: Function) => { 55 let index0 = 0 56 let index1 = 1 57 let initArray0Result = 1 58 let initArray1Result = 0 59 let boolArray0Result = 0 60 let boolArray1Result = 1 61 let initArray = softwareNdk.InitArray() 62 expect(initArray[index0]).assertEqual(initArray0Result) 63 expect(initArray[index1]).assertEqual(initArray1Result) 64 let bools = softwareNdk.GetBool() 65 expect(bools[index0]).assertEqual(boolArray0Result) 66 expect(bools[index1]).assertEqual(boolArray1Result) 67 done() 68 }) 69 70 /* 71 * @tc.number: C-S|STD-SOFTWARE-0804 72 * @tc.name: testAudioDecoding0100 73 * @tc.desc: 【C-S|STD-SOFTWARE-0804】必须支持 MP3 格式解码, 支持单/双声道, 74 * 支持8~320kbps 的固定码率、变码率模式, 支持 MP3(.mp3)容器格式 75 * @tc.size: MediumTest 76 * @tc.type: Function 77 * @tc.level: Level 0 78 */ 79 it('testAudioDecoding0100', 0, async (done: Function) => { 80 expect(pcsAudioTest.OH_AudioCodec_Flush_First()).assertEqual(SuccessResult1); 81 expect(pcsAudioTest.OH_AudioCodec_Flush_Second()).assertEqual(SuccessResult1); 82 done(); 83 }); 84 85 /* 86 * @tc.number: C-ALL-HARDWARE-0201 87 * @tc.name: testHardwareAcceleration0100 88 * @tc.desc: 【C-ALL-HARDWARE-0201】如果支持图形显示,并且支持图形的 2D 或 3D 硬件加速:默认情况下必须启用硬件加速。 89 * @tc.size: MediumTest 90 * @tc.type: Function 91 * @tc.level: Level 0 92 */ 93 it('testHardwareAcceleration0100', 0, async (done: Function) => { 94 try { 95 let openglExist = openglNdk.OpenglExist() 96 if(openglExist == 0) { 97 expect(openglNdk.OpenglEnabled()).assertEqual(SuccessResult1) 98 } 99 } catch (error) { 100 let err: BusinessError = error as BusinessError 101 console.log(`the device not support opengl code: ${err.code}, msg: ${err.message}`) 102 } 103 done() 104 }) 105 }) 106}