• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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 */
15export const MemLevel = {
16    MEM_LEVEL_MIN: 1,
17    MEM_LEVEL_MAX: 9,
18    MEM_LEVEL_DEFAULT: 8
19};
20export const ErrorCode = {
21    ERROR_CODE_OK: 0,
22    ERROR_CODE_ERRNO: -1,
23};
24export const CompressLevel = {
25    COMPRESS_LEVEL_NO_COMPRESSION: 0,
26    COMPRESS_LEVEL_BEST_SPEED: 1,
27    COMPRESS_LEVEL_BEST_COMPRESSION: 9,
28    COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1
29};
30export const CompressStrategy = {
31    COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0,
32    COMPRESS_STRATEGY_FILTERED: 1,
33    COMPRESS_STRATEGY_HUFFMAN_ONLY: 2,
34    COMPRESS_STRATEGY_RLE: 3,
35    COMPRESS_STRATEGY_FIXED: 4
36};
37export const Options = {
38    level: CompressLevel,
39    memLevel: MemLevel,
40    strategy: CompressStrategy,
41};
42export function mockZlib() {
43    const zlib = {
44        ErrorCode,
45        MemLevel,
46        CompressLevel,
47        CompressStrategy,
48        Options,
49        zipFile: function(...args) {
50            console.warn("zlib.zipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.")
51            return new Promise((resolve) => {
52                resolve();
53            })
54        },
55
56        unzipFile: function(...args) {
57            console.warn("zlib.unzipFile interface mocked in the Previewer. How this interface works on the Previewer may be different from that on a real device.")
58            return new Promise((resolve) => {
59                resolve();
60            })
61        }
62    }
63    return zlib;
64}