• 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 { TabPaneSmapsSample } from '../../../../../../src/trace/component/trace/sheet/smaps/TabPaneSmapsSample';
17import { SelectionParam } from '../../../../../../src/trace/bean/BoxSelection';
18jest.mock('../../../../../../src/js-heap/model/DatabaseStruct', () => {
19  return {};
20});
21jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
22  return {};
23});
24jest.mock('../../../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
25  return {};
26});
27window.ResizeObserver =
28  window.ResizeObserver ||
29  jest.fn().mockImplementation(() => ({
30    disconnect: jest.fn(),
31    observe: jest.fn(),
32    unobserve: jest.fn(),
33  }));
34const intersectionObserverMock = () => ({
35  observe: () => null,
36});
37window.IntersectionObserver = jest.fn().mockImplementation(intersectionObserverMock);
38describe('TabPaneSmapsSample', () => {
39  let tabpane = new TabPaneSmapsSample();
40  let selectionParam = new SelectionParam();
41  tabpane.queryDataByDB = jest.fn();
42  tabpane.setSmaps = jest.fn();
43  tabpane.initElements();
44  selectionParam.rightNs = 100000000;
45  selectionParam.leftNs = 0;
46  const mockParentElement = document.createElement('div');
47  mockParentElement.style.height = '100px';
48  Object.defineProperty(tabpane, 'parentElement', {
49    value: mockParentElement,
50    writable: true,
51  });
52
53  it('TabPaneSmapsSampleTest01', () => {
54    tabpane.initElements();
55    tabpane.init = jest.fn();
56    tabpane.data = selectionParam;
57    expect(tabpane.setSmaps).toHaveBeenCalled();
58  });
59
60  it('TabPaneSmapsSampleTest02', () => {
61    tabpane.initElements();
62    expect(tabpane.initElements()).toBeUndefined();
63    expect(tabpane.connectedCallback()).toBeUndefined();
64    expect(tabpane.initHtml()).not.toBeUndefined();
65    expect(tabpane.sortByColumn({ key: 'rssStr', sort: 2 })).toBeUndefined();
66    expect(tabpane.sortByColumn({ key: 'sizeStr', sort: 2 })).toBeUndefined();
67    expect(tabpane.sortByColumn({ key: 'fds', sort: 2 })).toBeUndefined();
68    expect(tabpane.sortByColumn({ key: 'number', sort: 2 })).toBeUndefined();
69  });
70});
71