• 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 { SpChartManager } from '../../../../src/trace/component/chart/SpChartManager';
17import { SpLogChart } from '../../../../src/trace/component/chart/SpLogChart';
18
19const sqlite = require('../../../../src/trace/database/SqlLite');
20jest.mock('../../../../src/trace/database/SqlLite');
21
22window.ResizeObserver =
23  window.ResizeObserver ||
24  jest.fn().mockImplementation(() => ({
25    disconnect: jest.fn(),
26    observe: jest.fn(),
27    unobserve: jest.fn(),
28  }));
29
30describe('SpLogChart Test', () => {
31  let logChart = new SpLogChart(new SpChartManager());
32  let queryLog = sqlite.queryLogData;
33  let queryLogData = [
34    {
35      id: 2,
36      startTs: 0,
37      level: 'I',
38      depth: 1,
39      tag: 'C02d0c/Hiprofiler',
40      context: 'ParseTimeExtend: update ts with 0 to 33727453411',
41      time: 1502029274737385200,
42      pid: 1119,
43      tid: 1172,
44      processName: 'hiprofiler_plug',
45      dur: 1,
46      frame: {
47        x: 0,
48        y: 7,
49        width: 1,
50        height: 7,
51      },
52    },
53    {
54      id: 37,
55      startTs: 76402674,
56      level: 'W',
57      depth: 2,
58      tag: 'C01300/AbilityManagerService',
59      context: '[ability_manager_service.cpp(UpdateCallerInfo:6178)]UpdateCallerInfo caller abilityRecord is null.',
60      time: 1502029274813788000,
61      pid: 558,
62      tid: 558,
63      processName: 'foundation',
64      dur: 1,
65      frame: {
66        x: 3,
67        y: 14,
68        width: 1,
69        height: 7,
70      },
71    },
72    {
73      id: 99,
74      startTs: 579581683,
75      level: 'E',
76      depth: 3,
77      tag: 'C01300/AbilityManagerService',
78      context: '[ability_interceptor.cpp(CheckCrowdtest:104)]GetApplicaionInfo from bms failed.',
79      time: 1502029275316967000,
80      pid: 558,
81      tid: 558,
82      processName: 'foundation',
83      dur: 1,
84      frame: {
85        x: 29,
86        y: 21,
87        width: 1,
88        height: 7,
89      },
90    },
91  ];
92  queryLog.mockResolvedValue(queryLogData);
93  it('SpLogChart01', function () {
94    expect(logChart.init()).toBeDefined();
95  });
96});
97