1fb726d48Sopenharmony_ci/*
2fb726d48Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3fb726d48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb726d48Sopenharmony_ci * you may not use this file except in compliance with the License.
5fb726d48Sopenharmony_ci * You may obtain a copy of the License at
6fb726d48Sopenharmony_ci *
7fb726d48Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fb726d48Sopenharmony_ci *
9fb726d48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb726d48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb726d48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb726d48Sopenharmony_ci * See the License for the specific language governing permissions and
13fb726d48Sopenharmony_ci * limitations under the License.
14fb726d48Sopenharmony_ci */
15fb726d48Sopenharmony_ci
16fb726d48Sopenharmony_ciimport { TraceRow } from '../../../../src/trace/component/trace/base/TraceRow';
17fb726d48Sopenharmony_ciimport { threadPool } from '../../../../src/trace/database/SqlLite';
18fb726d48Sopenharmony_ciimport {
19fb726d48Sopenharmony_ci  abilityDmaDataSender,
20fb726d48Sopenharmony_ci  abilityGpuMemoryDataSender,
21fb726d48Sopenharmony_ci  abilityPurgeableDataSender,
22fb726d48Sopenharmony_ci  dmaDataSender,
23fb726d48Sopenharmony_ci  gpuGpuDataSender,
24fb726d48Sopenharmony_ci  gpuMemoryDataSender,
25fb726d48Sopenharmony_ci  gpuResourceDataSender,
26fb726d48Sopenharmony_ci  gpuTotalDataSender,
27fb726d48Sopenharmony_ci  gpuWindowDataSender,
28fb726d48Sopenharmony_ci  purgeableDataSender,
29fb726d48Sopenharmony_ci  shmDataSender,
30fb726d48Sopenharmony_ci  sMapsDataSender
31fb726d48Sopenharmony_ci} from '../../../../src/trace/database/data-trafic/VmTrackerDataSender';
32fb726d48Sopenharmony_ciimport { SnapshotStruct } from '../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot';
33fb726d48Sopenharmony_cijest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {});
34fb726d48Sopenharmony_cijest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
35fb726d48Sopenharmony_ci  return {};
36fb726d48Sopenharmony_ci});
37fb726d48Sopenharmony_cijest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
38fb726d48Sopenharmony_ci  return {};
39fb726d48Sopenharmony_ci});
40fb726d48Sopenharmony_cidescribe('VmTrackerDataSender Test', () => {
41fb726d48Sopenharmony_ci  let data = {
42fb726d48Sopenharmony_ci    dur: 1000,
43fb726d48Sopenharmony_ci    endNs: 576258,
44fb726d48Sopenharmony_ci    frame: {x: 61, y: 3, width: 13, height: 33},
45fb726d48Sopenharmony_ci    name: "SnapShot 1",
46fb726d48Sopenharmony_ci    startNs: 476258,
47fb726d48Sopenharmony_ci    textWidth: 54.6826,
48fb726d48Sopenharmony_ci    value: 21313
49fb726d48Sopenharmony_ci  }
50fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest01', () => {
51fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
52fb726d48Sopenharmony_ci      callback(data, 1, true);
53fb726d48Sopenharmony_ci    });
54fb726d48Sopenharmony_ci    let sMapsTraceRow = TraceRow.skeleton<SnapshotStruct>();
55fb726d48Sopenharmony_ci    sMapsDataSender('dirty', sMapsTraceRow).then(result => {
56fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
57fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
58fb726d48Sopenharmony_ci    });
59fb726d48Sopenharmony_ci  });
60fb726d48Sopenharmony_ci
61fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest02', () => {
62fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
63fb726d48Sopenharmony_ci      callback(data, 1, true);
64fb726d48Sopenharmony_ci    });
65fb726d48Sopenharmony_ci    let dmaTraceRow = TraceRow.skeleton<SnapshotStruct>();
66fb726d48Sopenharmony_ci    dmaDataSender(1, dmaTraceRow).then(result => {
67fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
68fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
69fb726d48Sopenharmony_ci    });
70fb726d48Sopenharmony_ci  });
71fb726d48Sopenharmony_ci
72fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest03', () => {
73fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
74fb726d48Sopenharmony_ci      callback(data, 1, true);
75fb726d48Sopenharmony_ci    });
76fb726d48Sopenharmony_ci    let gpuMemoryTraceRow = TraceRow.skeleton<SnapshotStruct>();
77fb726d48Sopenharmony_ci    gpuMemoryDataSender(1, gpuMemoryTraceRow).then(result => {
78fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
79fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
80fb726d48Sopenharmony_ci    });
81fb726d48Sopenharmony_ci  });
82fb726d48Sopenharmony_ci
83fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest04', () => {
84fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
85fb726d48Sopenharmony_ci      callback(data, 1, true);
86fb726d48Sopenharmony_ci    });
87fb726d48Sopenharmony_ci    let gpuResourceTraceRow = TraceRow.skeleton<SnapshotStruct>();
88fb726d48Sopenharmony_ci    gpuResourceDataSender(13, gpuResourceTraceRow).then(result => {
89fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
90fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
91fb726d48Sopenharmony_ci    });
92fb726d48Sopenharmony_ci  });
93fb726d48Sopenharmony_ci
94fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest05', () => {
95fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
96fb726d48Sopenharmony_ci      callback(data, 1, true);
97fb726d48Sopenharmony_ci    });
98fb726d48Sopenharmony_ci    let gpuGpuTraceRow = TraceRow.skeleton<SnapshotStruct>();
99fb726d48Sopenharmony_ci    gpuGpuDataSender(13, "'mem.graph_pss'", gpuGpuTraceRow).then(result => {
100fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
101fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
102fb726d48Sopenharmony_ci    });
103fb726d48Sopenharmony_ci  });
104fb726d48Sopenharmony_ci
105fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest06', () => {
106fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
107fb726d48Sopenharmony_ci      callback(data, 1, true);
108fb726d48Sopenharmony_ci    });
109fb726d48Sopenharmony_ci    let gpuTotalTraceRow = TraceRow.skeleton<SnapshotStruct>();
110fb726d48Sopenharmony_ci    gpuTotalDataSender(13, gpuTotalTraceRow).then(result => {
111fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
112fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
113fb726d48Sopenharmony_ci    });
114fb726d48Sopenharmony_ci  });
115fb726d48Sopenharmony_ci
116fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest07', () => {
117fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
118fb726d48Sopenharmony_ci      callback(data, 1, true);
119fb726d48Sopenharmony_ci    });
120fb726d48Sopenharmony_ci    let gpuWindowTraceRow = TraceRow.skeleton<SnapshotStruct>();
121fb726d48Sopenharmony_ci    gpuWindowDataSender(13, 15, gpuWindowTraceRow).then(result => {
122fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
123fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
124fb726d48Sopenharmony_ci    });
125fb726d48Sopenharmony_ci  });
126fb726d48Sopenharmony_ci
127fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest08', () => {
128fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
129fb726d48Sopenharmony_ci      callback(data, 1, true);
130fb726d48Sopenharmony_ci    });
131fb726d48Sopenharmony_ci    let shmTraceRow = TraceRow.skeleton<SnapshotStruct>();
132fb726d48Sopenharmony_ci    shmDataSender(13, shmTraceRow).then(result => {
133fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
134fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
135fb726d48Sopenharmony_ci    });
136fb726d48Sopenharmony_ci  });
137fb726d48Sopenharmony_ci
138fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest09', () => {
139fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
140fb726d48Sopenharmony_ci      callback(data, 1, true);
141fb726d48Sopenharmony_ci    });
142fb726d48Sopenharmony_ci    let purgeableTraceRow = TraceRow.skeleton<SnapshotStruct>();
143fb726d48Sopenharmony_ci    purgeableDataSender(13, purgeableTraceRow).then(result => {
144fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
145fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
146fb726d48Sopenharmony_ci    });
147fb726d48Sopenharmony_ci  });
148fb726d48Sopenharmony_ci
149fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest10', () => {
150fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
151fb726d48Sopenharmony_ci      callback(data, 1, true);
152fb726d48Sopenharmony_ci    });
153fb726d48Sopenharmony_ci    let abilityPurgeablTraceRow = TraceRow.skeleton<SnapshotStruct>();
154fb726d48Sopenharmony_ci    abilityPurgeableDataSender(abilityPurgeablTraceRow, 1000000000, false).then(result => {
155fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
156fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
157fb726d48Sopenharmony_ci    });
158fb726d48Sopenharmony_ci  });
159fb726d48Sopenharmony_ci
160fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest11', () => {
161fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
162fb726d48Sopenharmony_ci      callback(data, 1, true);
163fb726d48Sopenharmony_ci    });
164fb726d48Sopenharmony_ci    let abilityDmaTraceRow = TraceRow.skeleton<SnapshotStruct>();
165fb726d48Sopenharmony_ci    abilityDmaDataSender(abilityDmaTraceRow, 1000000000).then(result => {
166fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
167fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
168fb726d48Sopenharmony_ci    });
169fb726d48Sopenharmony_ci  });
170fb726d48Sopenharmony_ci
171fb726d48Sopenharmony_ci  it('VmTrackerDataSenderTest12', () => {
172fb726d48Sopenharmony_ci    threadPool.submitProto = jest.fn((query: number, params: any, callback: Function) => {
173fb726d48Sopenharmony_ci      callback(data, 1, true);
174fb726d48Sopenharmony_ci    });
175fb726d48Sopenharmony_ci    let abilityGpuMemoryTraceRow = TraceRow.skeleton<SnapshotStruct>();
176fb726d48Sopenharmony_ci    abilityGpuMemoryDataSender(abilityGpuMemoryTraceRow, 1000000000).then(result => {
177fb726d48Sopenharmony_ci      expect(result).toHaveLength(1);
178fb726d48Sopenharmony_ci      expect(threadPool.submitProto).toHaveBeenCalled();
179fb726d48Sopenharmony_ci    });
180fb726d48Sopenharmony_ci  });
181fb726d48Sopenharmony_ci});