• 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 { TabPaneIrqCounter } from '../../../../../../src/trace/component/trace/sheet/irq/TabPaneIrqCounter';
17import { IrqStruct } from '../../../../../../src/trace/database/ui-worker/ProcedureWorkerIrq';
18jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => {
19  return {};
20});
21jest.mock('../../../../../../src/trace/component/trace/sheet/SheetUtils', () => {
22  return {
23    initSort: ()=>{}
24  };
25});
26const sqlite = require('../../../../../../src/trace/database/SqlLite');
27jest.mock('../../../../../../src/trace/database/SqlLite');
28
29window.ResizeObserver =
30  window.ResizeObserver ||
31  jest.fn().mockImplementation(() => ({
32    disconnect: jest.fn(),
33    observe: jest.fn(),
34    unobserve: jest.fn(),
35  }));
36
37describe('TabPaneIrqCounter Test', () => {
38  let tabPaneIrqCounter = new TabPaneIrqCounter();
39  let map = new Map();
40  map.set('irq', [new IrqStruct()]);
41  let frameData = {
42    leftNs: 253,
43    rightNs: 1252,
44    argSetId: 5,
45    startNS: 11111,
46    dur: 22222,
47    name: 'irq',
48    irqMapData: map,
49    framesData: [
50      {
51        id: 25,
52        ts: 254151,
53        dur: 1202,
54        name: '1583',
55        argSetId: 5,
56        type: '0',
57        pid: 20,
58        gpu_dur: 2568,
59        app_dur: 110,
60      },
61    ],
62  };
63
64  let irqData = sqlite.queryIrqDataBoxSelect;
65  irqData.mockResolvedValue([
66    {
67      irqName: "name",
68      wallDuration: 9536,
69      maxDuration: 5239,
70      count: 1,
71      avgDuration: 2563
72    }
73  ]);
74
75  let softIrqData = sqlite.querySoftIrqDataBoxSelect;
76  softIrqData.mockResolvedValue([
77    {
78      irqName: "name",
79      wallDuration: 6765,
80      maxDuration: 56756,
81      count: 1,
82      avgDuration: 46545
83    }
84  ]);
85
86  it('TabPaneIrqCounterTest01', function () {
87    tabPaneIrqCounter.data = frameData;
88    expect(tabPaneIrqCounter.data).toBeUndefined();
89  });
90
91  it('TabPaneIrqCounterTest02', function () {
92    expect(
93      tabPaneIrqCounter.sortByColumn({
94        key: 'jankType',
95      })
96    ).toBeUndefined();
97  });
98});
99