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 16// @ts-ignore 17import { Utils } from '../../../dist/hdc/common/Utils.js'; 18 19describe('UtilsTest', () => { 20 it('UtilsTest_getLocalId_01', () => { 21 expect(Utils.getLocalId()).toBeTruthy(); 22 }); 23 24 it('UtilsTest_getLocalId_02', () => { 25 Utils.localId = 4294967295; 26 expect(Utils.getLocalId()).toBe(1); 27 }); 28 29 it('UtilsTest_getSessionId_01', () => { 30 expect(Utils.getSessionId()).toBeTruthy(); 31 }); 32 33 it('UtilsTest_formatCommand_01', () => { 34 expect( 35 Utils.formatCommand( 36 'hdc_std shell killall hiprofilerd hiprofiler_plugins native_daemon hiperf' + ' hiprofiler_cmd' 37 ) 38 ).toEqual({ 39 bJumpDo: false, 40 cmdFlag: 1001, 41 parameters: 'killall hiprofilerd hiprofiler_plugins native_daemon hiperf hiprofiler_cmd', 42 }); 43 }); 44 45 it('UtilsTest_formatCommand_02', () => { 46 expect(Utils.formatCommand('abc')).toEqual({ 47 bJumpDo: true, 48 cmdFlag: -1, 49 parameters: '', 50 }); 51 }); 52 53 it('UtilsTest_formatCommand_03', () => { 54 expect(Utils.formatCommand('hdc')).toEqual({ 55 bJumpDo: true, 56 cmdFlag: -1, 57 parameters: '', 58 }); 59 }); 60 61 it('UtilsTest_numToHexString_01', () => { 62 expect(Utils.numToHexString(1)).toBe('0x1'); 63 }); 64 65 it('UtilsTest_numToHexString_02', () => { 66 expect(Utils.numToHexString(-1)).toBe('0xffffffff'); 67 }); 68 69 it('UtilsTest_numToHexString_03', () => { 70 expect(Utils.numToHexString(undefined)).toBe('0x0'); 71 }); 72}); 73