• 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
16import { SpEBPFChart } from '../../../../src/trace/component/chart/SpEBPFChart';
17import { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager';
18const sqlit = require('../../../../src/trace/database/SqlLite');
19jest.mock('../../../../src/trace/database/SqlLite');
20jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
21  return {};
22});
23import { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow';
24jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {});
25window.ResizeObserver =
26  window.ResizeObserver ||
27  jest.fn().mockImplementation(() => ({
28    disconnect: jest.fn(),
29    observe: jest.fn(),
30    unobserve: jest.fn(),
31  }));
32
33describe('SpFileSystemChart Test', () => {
34  let hasFileSysData = sqlit.hasFileSysData;
35  hasFileSysData.mockResolvedValue([
36    {
37      fsCount: 2,
38      vmCount: 2,
39      ioCount: 2,
40    },
41  ]);
42
43  let ss = new SpChartManager();
44  let spEBPFChart = new SpEBPFChart(ss);
45  spEBPFChart.initFileCallchain = jest.fn(() => true);
46  it('SpMpsChart01', function () {
47    spEBPFChart.init();
48    expect(spEBPFChart).toBeDefined();
49  });
50  it('SpMpsChart02', function () {
51    ss.displayTip = jest.fn(() => true);
52    expect(spEBPFChart.focusHandler(TraceRow)).toBeUndefined();
53  });
54});
55