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 {querySingleVSyncData, drawVSync, enableVSync, setVSyncData } from '../../../../src/trace/component/chart/VSync';
17import { DbPool } from '../../../../src/trace/database/SqlLite';
18
19jest.mock('../../../../src/trace/component/SpSystemTrace', () => {
20  return {};
21});
22jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorkerSnapshot', () => {
23  return {};
24});
25jest.mock('../../../../src/trace/database/ui-worker/ProcedureWorker', () => {
26  return {
27    queryFunc: ()=>{}
28  };
29});
30jest.mock('../../../../src/js-heap/model/DatabaseStruct', () => {});
31jest.mock('../../../../src/trace/component/trace/base/TraceRow', () => {
32  return {}
33});
34
35const sqlit = require('../../../../src/trace/database/sql/SqlLite.sql');
36jest.mock('../../../../src/trace/database/sql/SqlLite.sql');
37
38describe('VSync Test', () => {
39  DbPool.prototype.submit = jest.fn();
40  const canvas = document.createElement('canvas');
41  canvas.width = 10;
42  canvas.height = 10;
43  const ctx = canvas.getContext('2d');
44  it('VSyncTest01 ', function () {
45    let cc = {
46      "vsyncValue": 20
47    };
48    window.localStorage.setItem('FlagsConfig', JSON.stringify(cc));
49    querySingleVSyncData();
50    setVSyncData();
51    drawVSync(ctx, 20, 20);
52    window.SmartEvent = {
53      UI: {
54        loading: true
55      }
56    }
57    window.publish = jest.fn();
58    enableVSync(true, {
59      key: 'k'
60    }, () => {});
61  });
62});
63