• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * @Author: your name
3 * @Date: 2022-01-20 21:27:31
4 * @LastEditTime: 2022-01-20 21:27:33
5 * @LastEditors: your name
6 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
7 * @FilePath: \third_party_jsframework\runtime\main\extend\systemplugin\featureAbility.js
8 */
9/*
10 * Copyright (c) 2021 Huawei Device Co., Ltd.
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 *
15 *     http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 */
23
24export function mockFeatureAbility() {
25  let FeatureAbilityObject = {
26    getFeatureAbility: function () {
27      const ResultMock = {
28        code: '[PC preview] unknow code',
29        data: '[PC preview] unknow data'
30      }
31      const FeatureAbility = {
32        startAbility: function (...args) {
33          console.warn("Unable to use the FeatureAbility.startAbility method to start another ability in the" +
34            " Previewer. Perform this operation on the emulator or a real device instead.")
35          return new Promise((resolve, reject) => {
36            resolve(ResultMock);
37          })
38        },
39        startAbilityForResult: function (...args) {
40          console.warn("Unable to use the FeatureAbility.startAbilityForResult method to start another ability in" +
41            " the Previewer. Perform this operation on the emulator or a real device instead.")
42          return new Promise((resolve, reject) => {
43            resolve(ResultMock);
44          })
45        },
46        finishWithResult: function (...args) {
47          console.warn("FeatureAbility.finishWithResult interface mocked in the Previewer. How this interface works" +
48            " on the Previewer may be different from that on a real device.")
49          return new Promise((resolve, reject) => {
50            resolve(ResultMock);
51          })
52        },
53        callAbility: function (...args) {
54          console.warn("FeatureAbility.callAbility interface mocked in the Previewer. How this interface works on" +
55            " the Previewer may be different from that on a real device.")
56          return new Promise((resolve, reject) => {
57            resolve(JSON.stringify(ResultMock));
58          })
59        },
60        continueAbility: function (...args) {
61          console.warn("FeatureAbility.continueAbility interface mocked in the Previewer. How this interface works on" +
62            " the Previewer may be different from that on a real device.")
63          return new Promise((resolve, reject) => {
64            resolve(ResultMock);
65          })
66        },
67        subscribeAbilityEvent: function (...args) {
68          console.warn("FeatureAbility.subscribeAbilityEvent interface mocked in the Previewer. How this interface" +
69            " works on the Previewer may be different from that on a real device.")
70          return new Promise((resolve, reject) => {
71            resolve(JSON.stringify(ResultMock));
72          })
73        },
74        unsubscribeAbilityEvent: function (...args) {
75          console.warn("FeatureAbility.unsubscribeAbilityEvent interface mocked in the Previewer. How this interface" +
76            " works on the Previewer may be different from that on a real device.")
77          return new Promise((resolve, reject) => {
78            resolve(JSON.stringify(ResultMock));
79          })
80        }
81      }
82      return FeatureAbility
83    }
84  }
85  global.createLocalParticleAbility = function (...args) {
86    console.warn("createLocalParticleAbility interface mocked in the Previewer. How this interface" +
87      " works on the Previewer may be different from that on a real device.")
88    return new Promise((resolve, reject) => {
89      resolve(paramMock.paramObjectMock);
90    })
91  }
92  global.FeatureAbility = FeatureAbilityObject.getFeatureAbility();
93}