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