• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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//@ts-ignore
16import {TabPaneFps} from "../../../../../../dist/trace/component/trace/sheet/fps/TabPaneFps.js";
17const sqlit = require("../../../../../../dist/trace/database/SqlLite.js")
18jest.mock("../../../../../../dist/trace/database/SqlLite.js");
19
20window.ResizeObserver = window.ResizeObserver ||
21    jest.fn().mockImplementation(() => ({
22        disconnect: jest.fn(),
23        observe: jest.fn(),
24        unobserve: jest.fn(),
25    }));
26
27describe('TabPaneFps Test', () => {
28    let tabPaneFps = new TabPaneFps();
29
30    it('TabPaneFpsTest01', function () {
31        let mockgetTabFps = sqlit.getTabFps
32        mockgetTabFps.mockResolvedValue(
33            [
34            {   leftNs  : 10,
35                rightNs: 10,
36            }]
37        )
38        let a = {rightNs: 1, leftNs:1}
39        expect(tabPaneFps.data = a).toBeTruthy();
40    });
41
42    it('TabPaneFpsTest02', function () {
43        let mockgetTabFps = sqlit.getTabFps
44        mockgetTabFps.mockResolvedValue([])
45        let a = {rightNs: 1, leftNs:1}
46        expect(tabPaneFps.data = a).toBeTruthy();
47    });
48
49    it('TabPaneFpsTest03', function () {
50        expect(tabPaneFps.initHtml()).toMatchInlineSnapshot(`
51"
52        <style>
53        :host{
54            display: flex;
55            flex-direction: column;
56            padding: 10px 10px;
57        }
58        </style>
59        <label id=\\"time-range\\" style=\\"width: 100%;height: 20px;text-align: end;font-size: 10pt;margin-bottom: 5px\\">Selected range:0.0 ms</label>
60        <lit-table id=\\"tb-fps\\" style=\\"height: auto\\">
61            <lit-table-column width=\\"1fr\\" title=\\"Time\\" data-index=\\"timeStr\\" key=\\"timeStr\\" align=\\"flex-start\\">
62            </lit-table-column>
63            <lit-table-column width=\\"1fr\\" title=\\"FPS\\" data-index=\\"fps\\" key=\\"fps\\" align=\\"flex-start\\" >
64            </lit-table-column>
65        </lit-table>
66        "
67`)
68    });
69})