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 16// @ts-ignore 17import {SpVirtualMemChart} from "../../../../dist/trace/component/chart/SpVirtualMemChart.js" 18// @ts-ignore 19import {SpSystemTrace} from "../../../../dist/trace/component/SpSystemTrace.js"; 20// @ts-ignore 21import {TraceRow} from "../../../../dist/trace/component/trace/base/TraceRow.js"; 22 23const sqlit = require("../../../../dist/trace/database/SqlLite.js") 24jest.mock("../../../../dist/trace/database/SqlLite.js"); 25 26window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ 27 disconnect: jest.fn(), 28 observe: jest.fn(), 29 unobserve: jest.fn(), 30})); 31 32describe('SpVirtualMemChart Test', () => { 33 let spVirtualMemChart = new SpVirtualMemChart(new SpSystemTrace()) 34 let MockVirtualMemory = sqlit.queryVirtualMemory; 35 MockVirtualMemory.mockResolvedValue([{ 36 id:0, 37 name:"name" 38 }]) 39 40 let MockVirtualMemoryData = sqlit.queryVirtualMemoryData; 41 MockVirtualMemoryData.mockResolvedValue([{ 42 startTime:0, 43 value:20, 44 filterID:0 45 }]) 46 47 it('SpVirtualMemChart01', function () { 48 spVirtualMemChart.init() 49 expect(spVirtualMemChart).toBeDefined(); 50 }); 51 52 it('SpVirtualMemChart02', function () { 53 let folder = new TraceRow({ 54 canvasNumber: 1, 55 alpha: false, 56 contextId: '2d', 57 isOffScreen: SpSystemTrace.isCanvasOffScreen 58 }); 59 spVirtualMemChart.initVirtualMemoryRow(folder,2,"name",2) 60 expect(spVirtualMemChart).toBeDefined(); 61 }); 62}) 63