1/* 2 * Copyright (C) 2022 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 { DataMessage } from '../../../src/hdc/message/DataMessage'; 17import { TextEncoder } from 'util'; 18 19describe('DataMessage Test', () => { 20 let dataMessage = new DataMessage(); 21 dataMessage.body = true; 22 it('DataMessageTest01', function () { 23 expect(dataMessage).not.toBeUndefined(); 24 }); 25 26 it('DataMessageTest02', function () { 27 expect(dataMessage.usbHead).toBeUndefined(); 28 }); 29 30 it('DataMessageTest03', function () { 31 dataMessage.usbHead = true; 32 expect(dataMessage.usbHead).toBeTruthy(); 33 }); 34 35 it('DataMessageTest04', function () { 36 expect(dataMessage.channelId).toBe(-1); 37 }); 38 39 it('DataMessageTest05', function () { 40 dataMessage.channelId = true; 41 expect(dataMessage.channelId).toBeTruthy(); 42 }); 43 44 it('DataMessageTest06', function () { 45 expect(dataMessage.result).toBe(''); 46 }); 47 48 it('DataMessageTest07', function () { 49 dataMessage.result = true; 50 expect(dataMessage.result).toBeTruthy(); 51 }); 52 53 it('DataMessageTest08', function () { 54 expect(dataMessage.channelClose).toBeFalsy(); 55 }); 56 57 it('DataMessageTest09', function () { 58 dataMessage.channelClose = true; 59 expect(dataMessage.channelClose).toBeTruthy(); 60 }); 61 62 it('DataMessageTest10', function () { 63 expect(dataMessage.commandFlag).toBe(-1); 64 }); 65 66 it('DataMessageTest11', function () { 67 dataMessage.commandFlag = true; 68 expect(dataMessage.commandFlag).toBeTruthy(); 69 }); 70 71 it('DataMessageTest12', function () { 72 expect(dataMessage.resArrayBuffer).toBeUndefined(); 73 }); 74 75 it('DataMessageTest13', function () { 76 dataMessage.resArrayBuffer = true; 77 expect(dataMessage.resArrayBuffer).toBeTruthy(); 78 }); 79 80 it('DataMessageTest14', function () { 81 expect(dataMessage.toString()).not.toBeUndefined(); 82 }); 83 84 it('DataMessageTest15', function () { 85 expect(dataMessage.getChannelId()).not.toBeUndefined(); 86 }); 87 88 it('DataMessageTest16', function () { 89 expect(dataMessage.getData()).not.toBeUndefined(); 90 }); 91 92 it('DataMessageTest17', function () { 93 let end = new TextEncoder(); 94 95 dataMessage.resArrayBuffer = end.encode('111'); 96 expect(dataMessage.getDataToString()).toBe('111'); 97 }); 98}); 99