• 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_ERRND: -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 function mockZlib() {
38  const zlib = {
39    ErrorCode,
40    MemLevel,
41    CompressLevel,
42    CompressStrategy,
43    Options: {
44      level: CompressLevel,
45      memLevel: MemLevel,
46      strategy: CompressStrategy,
47    },
48    zipFile(...args) {
49      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.")
50      return new Promise((resolve, reject) => {
51        resolve()
52      })
53    },
54
55    unzipFile(...args) {
56      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.")
57      return new Promise((resolve, reject) => {
58        resolve()
59      })
60    }
61  }
62  return zlib;
63}