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