• 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 { TabPerfSampleList } from '../../../../../../src/trace/component/trace/sheet/hiperf/TabPerfSampleList';
17import '../../../../../../src/trace/component/trace/sheet/hiperf/TabPerfSampleList';
18jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => {
19  return {};
20});
21const sqlite = require('../../../../../../src/trace/database/SqlLite');
22jest.mock('../../../../../../src/trace/database/SqlLite');
23// @ts-ignore
24window.ResizeObserver = window.ResizeObserver ||
25  jest.fn().mockImplementation(() => ({
26    unobserve: jest.fn(), disconnect: jest.fn(), observe: jest.fn(),
27  }));
28
29describe('TabPerfSampleList Test', () => {
30  document.body.innerHTML = `<tabpane-perf-sample id="sampleList"></tabpane-perf-sample>`;
31  let sampleList = document.querySelector('#sampleList') as TabPerfSampleList;
32  let sampleListData = {
33    leftNs: 1222,
34    rightNs: 5286,
35  };
36
37  let perfSampleList = [
38    {
39      sampleId: 1,
40      tid: 1522,
41      threadName: 'test',
42      state: 'state',
43      pid: 44147,
44      time: 4744,
45      core: 155,
46    },
47  ];
48  let perfSampleListByTimeRange = sqlite.queryPerfSampleListByTimeRange;
49
50  perfSampleListByTimeRange.mockResolvedValue(perfSampleList);
51  let perfProcess = sqlite.queryPerfProcess;
52  perfProcess.mockResolvedValue([
53    {
54      pid: 44147,
55      processName: 'test1',
56    },
57  ]);
58  let perfSampleCallChainDate = [
59    {
60      callChainId: 255,
61      csampleId: 5525,
62      fileId: 4585,
63      symbolId: 4855,
64      vaddrInFile: 0,
65      symbol: 'name',
66    },
67  ];
68  let perfSampleCallChain = sqlite.queryPerfSampleCallChain;
69  perfSampleCallChain.mockResolvedValue(perfSampleCallChainDate);
70
71  it('TabPerfSampleListTest01', function () {
72    sampleList.data = sampleListData;
73    expect(sampleList.data).toBeUndefined();
74  });
75
76  it('TabPerfSampleListTest02', function () {});
77
78  it('TabPerfSampleListTest03', function () {
79    expect(sampleList.sortPerfSampleTable('timeString', 2)).toBeUndefined();
80  });
81});
82