• 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 { TabPaneVmTrackerShmComparison } from '../../../../../../src/trace/component/trace/sheet/vmtracker/TabPaneVmTrackerShmComparison';
16
17const sqlite = require('../../../../../../src/trace/database/sql/Memory.sql');
18jest.mock('../../../../../../src/trace/database/sql/Memory.sql');
19jest.mock('../../../../../../src/base-ui/select/LitSelect', () => {
20  return {};
21});
22jest.mock('../../../../../../src/base-ui/table/lit-table', () => {
23  return {
24    snapshotDataSource: () => {},
25    removeAttribute: () => {},
26  };
27});
28jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {});
29jest.mock('../../../../../../src/trace/component/trace/base/TraceRow', () => {
30  return {};
31});
32jest.mock('../../../../../../src/trace/bean/NativeHook', () => {
33  return {};
34});
35jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerCommon', () => {
36  return {
37    ns2s: () => {},
38  };
39});
40// @ts-ignore
41window.ResizeObserver =
42  window.ResizeObserver ||
43  jest.fn().mockImplementation(() => ({
44    disconnect: jest.fn(),
45    observe: jest.fn(),
46    unobserve: jest.fn(),
47  }));
48
49describe('TabPaneVmTrackerShmComparison Test', () => {
50  let tabPaneVmTrackerShmComparison = new TabPaneVmTrackerShmComparison();
51  let getVmTrackerShmSelectionData = sqlite.queryVmTrackerShmSelectionData;
52  getVmTrackerShmSelectionData.mockResolvedValue([
53    {
54      startNS: 25165824,
55      ipid: 1,
56      fd: 2,
57      size: 1000,
58      adj: 10,
59      name: 1,
60      id: 4,
61      time: 2,
62      purged: 20,
63      count: 2,
64      flag: 0,
65    },
66  ]);
67  let data = [
68    {
69      name: 'Snapshot0',
70      startNs: 8214061,
71      value: 0,
72    },
73  ];
74  let datalist = [
75    {
76      name: 'Snapshot2',
77      startNs: 9806561,
78      value: 0,
79    },
80    {
81      name: 'Snapshot1',
82      startNs: 47781,
83      value: 0,
84    },
85  ];
86  tabPaneVmTrackerShmComparison.init = jest.fn(() => true);
87  it('TabPaneVmTrackerShmComparison01', function () {
88    tabPaneVmTrackerShmComparison.initSelect = jest.fn(() => true);
89    expect(tabPaneVmTrackerShmComparison.setShmData(data, datalist)).toBeUndefined();
90  });
91  it('TabPaneVmTrackerShmComparison02', function () {
92    expect(tabPaneVmTrackerShmComparison.updateComparisonData(0, 10)).toBeTruthy();
93  });
94  it('TabPaneVmTrackerShmComparison03', function () {
95    expect(tabPaneVmTrackerShmComparison.calSizeObj(data, datalist)).toBeTruthy();
96  });
97});
98