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 { 17 chartXpowerGpuFreqCountDataSql, 18 chartXpowerGpuFreqDataSql, 19 xpowerDataGpuFreqCountReceiver, 20 xpowerDataGpuFreqReceiver, 21} from '../../../../../src/trace/database/data-trafic/xpower/XpowerGpuFrequencyRecevier'; 22import { TraficEnum } from '../../../../../src/trace/database/data-trafic/utils/QueryEnum'; 23 24describe('xpowerDataGpuFreqCountReceiver Test', () => { 25 let data = { 26 id: 'd460ac73-bcff-4021-9680-f4672b083e25', 27 name: 162, 28 action: 'exec-proto', 29 params: { 30 startNS: 0, 31 endNS: 30108569984, 32 recordStartNS: 203939463442, 33 recordEndNS: 233758028426, 34 width: 597, 35 trafic: 0, 36 }, 37 }; 38 39 it('xpowerDataGpuFreqCountReceiverTest01', () => { 40 const args = { 41 recordStartNS: 1001, 42 endNS: 3000, 43 startNS: 2000, 44 width: 110, 45 }; 46 expect(chartXpowerGpuFreqCountDataSql(args)).toBeTruthy(); 47 }); 48 it('xpowerDataGpuFreqCountReceiverTest02', () => { 49 (self as unknown as Worker).postMessage = jest.fn(() => true); 50 expect( 51 xpowerDataGpuFreqCountReceiver(data, () => { 52 return 0; 53 }) 54 ).toBeUndefined(); 55 }); 56 it('xpowerDataGpuFreqCountReceiverTest03', () => { 57 const args = { 58 recordStartNS: 1000, 59 endNS: 3000, 60 startNS: 2000, 61 width: 10, 62 }; 63 expect(chartXpowerGpuFreqDataSql(args)).toBeTruthy(); 64 }); 65 it('xpowerDataGpuFreqCountReceiverTest04', () => { 66 (self as unknown as Worker).postMessage = jest.fn(() => true); 67 expect( 68 xpowerDataGpuFreqReceiver(data, () => { 69 return [{ dur: 88 }]; 70 }) 71 ).toBeUndefined(); 72 }); 73}); 74