• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21    it('UtilsTest_getLocalId_01', () => {
22        expect(Utils.getLocalId()).toBeTruthy()
23    })
24
25    it('UtilsTest_getLocalId_02', () => {
26        Utils.localId = 4294967295;
27        expect(Utils.getLocalId()).toBe(1);
28    });
29
30    it('UtilsTest_getSessionId_01', () => {
31        expect(Utils.getSessionId()).toBeTruthy()
32    })
33
34    it('UtilsTest_formatCommand_01', () => {
35        expect(Utils.formatCommand("hdc_std shell killall hiprofilerd hiprofiler_plugins native_daemon hiperf" +
36            " hiprofiler_cmd")).toEqual({"bJumpDo": false, "cmdFlag": 1001, "parameters": "killall hiprofilerd hiprofiler_plugins native_daemon hiperf hiprofiler_cmd"})
37    })
38
39    it('UtilsTest_formatCommand_02', () => {
40        expect(Utils.formatCommand("abc")).toEqual({"bJumpDo": true, "cmdFlag": -1, "parameters": ""})
41    })
42
43    it('UtilsTest_formatCommand_03', () => {
44        expect(Utils.formatCommand("hdc")).toEqual({"bJumpDo": true, "cmdFlag": -1, "parameters": ""});
45    });
46
47    it('UtilsTest_numToHexString_01', () => {
48        expect(Utils.numToHexString(1)).toBe("0x1")
49    })
50
51    it('UtilsTest_numToHexString_02', () => {
52        expect(Utils.numToHexString(-1)).toBe("0xffffffff")
53    })
54
55    it('UtilsTest_numToHexString_03', () => {
56        expect(Utils.numToHexString(undefined)).toBe("0x0")
57    })
58
59});