• 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 */
15import { TabPaneCpuAbility } from '../../../../../../src/trace/component/trace/sheet/ability/TabPaneCpuAbility';
16const abilitySqlite = require('../../../../../../src/trace/database/sql/Ability.sql');
17jest.mock('../../../../../../src/trace/database/sql/Ability.sql');
18
19jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => {
20  return {};
21});
22
23window.ResizeObserver =
24  window.ResizeObserver ||
25  jest.fn().mockImplementation(() => ({
26    disconnect: jest.fn(),
27    observe: jest.fn(),
28    unobserve: jest.fn(),
29  }));
30
31describe('TabPaneCpuAbility Test', () => {
32  let tabPaneCpuAbility = new TabPaneCpuAbility();
33  let val = [
34    {
35      startNs: 0,
36      rightNs: 1000,
37      leftNs:0,
38    }
39  ];
40  let getTabCpuData = abilitySqlite.getTabCpuAbilityData;
41  let cpuData = [
42    {
43      startTime: 0,
44      duration: 1000,
45      totalLoad:2,
46      userLoad:2,
47      systemLoad:3,
48      threads:1,
49    }
50  ];
51  getTabCpuData.mockResolvedValue(cpuData);
52  it('TabPaneCpuAbilityTest01', function () {
53    tabPaneCpuAbility.queryCpuResult.length = 2;
54    expect(tabPaneCpuAbility.filterData()).toBeUndefined();
55  });
56
57  it('TabPaneCpuAbilityTest02', function () {
58    const systemCpuSummary = {
59      startTimeStr: '',
60      durationStr: '',
61      totalLoadStr: '',
62      userLoadStr: '',
63      systemLoadStr: '',
64      threadsStr: '',
65    };
66    expect(tabPaneCpuAbility.toCpuAbilityArray(systemCpuSummary)).not.toBeUndefined();
67  });
68
69  it('TabPaneCpuAbilityTest03 ', function () {
70    expect(
71      tabPaneCpuAbility.sortByColumn({
72        key: 'startTime',
73      })
74    ).toBeUndefined();
75  });
76
77  it('TabPaneCpuAbilityTest04 ', function () {
78    expect(
79      tabPaneCpuAbility.sortByColumn({
80        key: !'startTime',
81      })
82    ).toBeUndefined();
83  });
84
85  it('TabPaneCpuAbilityTest05 ', function () {
86    expect(
87      tabPaneCpuAbility.sortByColumn({
88        key: 'totalLoadStr',
89      })
90    ).toBeUndefined();
91  });
92
93  it('TabPaneCpuAbilityTest06 ', function () {
94    expect(
95      tabPaneCpuAbility.sortByColumn({
96        key: 'userLoadStr',
97      })
98    ).toBeUndefined();
99  });
100
101  it('TabPaneCpuAbilityTest07 ', function () {
102    expect(
103      tabPaneCpuAbility.sortByColumn({
104        key: 'systemLoadStr',
105      })
106    ).toBeUndefined();
107  });
108
109  it('TabPaneCpuAbilityTest08 ', function () {
110    expect(
111      tabPaneCpuAbility.sortByColumn({
112        key: 'durationStr',
113      })
114    ).toBeUndefined();
115  });
116  it('TabPaneCpuAbilityTest09 ', function () {
117    expect(
118        tabPaneCpuAbility.queryDataByDB({val
119        })
120    ).toBeUndefined();
121  });
122});
123