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 { virtualMemoryDataReceiver } from '../../../../src/trace/database/data-trafic/VirtualMemoryDataReceiver';
17
18jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
19  return {};
20});
21
22describe('VirtualMemoryDataReceiver Test', () => {
23  let data = {
24    action: "exec-proto",
25    id: "30",
26    name: 12,
27    params:
28      {
29        endNS: 109726762483,
30        filterId: 6347,
31        recordEndNS: 490640100187894,
32        recordStartNS: 490530373425411,
33        sharedArrayBuffers: undefined,
34        startNS: 0,
35        t: 1703643817436,
36        trafic: 3,
37        width: 1407
38      }
39  }
40
41  let vmData = [{
42    virtualMemData: {
43      delta: -1,
44      duration: 252,
45      filterId: 6347,
46      maxValue: -1,
47      startTime: 19680640101,
48      value: 423440
49    }
50  }]
51  it('VirtualMemoryReceiverTest01', async () => {
52    const mockCallback = jest.fn(() => vmData);
53    const mockPostMessage = jest.fn();
54    (self as unknown as Worker).postMessage = mockPostMessage;
55    virtualMemoryDataReceiver(data, mockCallback);
56    expect(mockCallback).toHaveBeenCalled();
57  });
58});