• 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//@ts-ignore
16import {TabPaneLiveProcesses} from "../../../../../dist/trace/component/trace/sheet/TabPaneLiveProcesses.js";
17window.ResizeObserver = window.ResizeObserver ||
18    jest.fn().mockImplementation(() => ({
19        disconnect: jest.fn(),
20        observe: jest.fn(),
21        unobserve: jest.fn(),
22    }));
23
24describe('TabPaneLiveProcesses Test',function (){
25    let tabPaneLiveProcesses = new TabPaneLiveProcesses();
26
27    it('TabPaneLiveProcessesTest01 ', function () {
28        tabPaneLiveProcesses.queryResult.length = 1;
29        expect(tabPaneLiveProcesses.filterData()).toBeUndefined();
30    });
31
32    it('TabPaneLiveProcessesTest02 ', function () {
33        const live={
34            processId:1,
35            processName:"",
36            responsibleProcess:"",
37            userName:"",
38            cpu:"1",
39            threads:-1,
40            memory:'',
41            diskReads:-1,
42            diskWrite:-1
43        }
44        expect(tabPaneLiveProcesses.toLiveProcessArray(live)).not.toBeUndefined();
45    });
46
47    it('TabPaneLiveProcessesTest03 ', function () {
48        expect(tabPaneLiveProcesses.sortByColumn({
49            key:'startTime',
50        })).toBeUndefined();
51    });
52
53    it('TabPaneLiveProcessesTest07 ', function () {
54        expect(tabPaneLiveProcesses.sortByColumn({
55            key:'cpuTime',
56        })).toBeUndefined();
57    });
58
59    it('TabPaneLiveProcessesTest04 ', function () {
60        expect(tabPaneLiveProcesses.sortByColumn({
61            key:!'startTime'|| !'cpuTime',
62        })).toBeUndefined();
63    });
64
65    it('TabPaneLiveProcessesTest05', function () {
66        expect(tabPaneLiveProcesses.timeFormat(70000)).toBe("1:10.0s ");
67    });
68
69    it('TabPaneLiveProcessesTest06', function () {
70        expect(tabPaneLiveProcesses.timeFormat(2000)).toBe("2.0s ");
71    });
72})