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 xpowerDataThreadInfoReceiver, 18 xpowerDataThreadCountReceiver, 19 chartXpowerThreadCountDataSql, 20 chartXpowerThreadInfoDataSql, 21} from '../../../../../src/trace/database/data-trafic/xpower/XpowerThreadReceiver'; 22 23describe('xpowerDataThreadReceiver Test', () => { 24 let data = { 25 id: 'd460ac73-bcff-4021-9680-f4672b083e25', 26 name: 162, 27 action: 'exec-proto', 28 params: { 29 startNS: 0, 30 endNS: 30108564984, 31 recordStartNS: 203639463442, 32 recordEndNS: 233748028426, 33 width: 507, 34 trafic: 0, 35 }, 36 }; 37 38 it('xpowerDataThreadReceiverTest01', () => { 39 const args = { 40 recordStartNS: 1000, 41 endNS: 3000, 42 startNS: 2000, 43 width: 10, 44 }; 45 expect(chartXpowerThreadCountDataSql(args)).toBeTruthy(); 46 }); 47 48 it('xpowerDataThreadReceiverTest02', () => { 49 (self as unknown as Worker).postMessage = jest.fn(() => true); 50 expect( 51 xpowerDataThreadInfoReceiver(data, () => { 52 return [{dur: 8}]; 53 }) 54 ).toBeUndefined(); 55 }); 56 57 it('xpowerDataThreadReceiverTest03', () => { 58 const args = { 59 recordStartNS: 1000, 60 endNS: 3000, 61 startNS: 2000, 62 width: 10, 63 }; 64 expect(chartXpowerThreadInfoDataSql(args)).toBeTruthy(); 65 }); 66 67 it('xpowerDataThreadReceiverTest04', () => { 68 (self as unknown as Worker).postMessage = jest.fn(() => true); 69 expect( 70 xpowerDataThreadCountReceiver(data, () => { 71 return [{dur: 80}]; 72 }) 73 ).toBeUndefined(); 74 }); 75}); 76